OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string> | 5 #include <string> |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "chrome/browser/chromeos/gview_request_interceptor.h" | 7 #include "chrome/browser/chromeos/gview_request_interceptor.h" |
8 #include "net/base/load_flags.h" | 8 #include "net/base/load_flags.h" |
9 #include "net/url_request/url_request.h" | 9 #include "net/url_request/url_request.h" |
10 #include "net/url_request/url_request_job.h" | 10 #include "net/url_request/url_request_job.h" |
11 #include "net/url_request/url_request_test_job.h" | 11 #include "net/url_request/url_request_test_job.h" |
12 #include "net/url_request/url_request_unittest.h" | 12 #include "net/url_request/url_request_unittest.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
| 15 namespace chromeos { |
| 16 |
15 class GViewURLRequestTestJob : public URLRequestTestJob { | 17 class GViewURLRequestTestJob : public URLRequestTestJob { |
16 public: | 18 public: |
17 explicit GViewURLRequestTestJob(URLRequest* request) | 19 explicit GViewURLRequestTestJob(URLRequest* request) |
18 : URLRequestTestJob(request, true) { | 20 : URLRequestTestJob(request, true) { |
19 } | 21 } |
20 | 22 |
21 virtual bool GetMimeType(std::string* mime_type) const { | 23 virtual bool GetMimeType(std::string* mime_type) const { |
22 // During the course of a single test, two URLRequestJobs are | 24 // During the course of a single test, two URLRequestJobs are |
23 // created -- the first is for the viewable document URL, and the | 25 // created -- the first is for the viewable document URL, and the |
24 // second is for the rediected URL. In order to test the | 26 // second is for the rediected URL. In order to test the |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 92 |
91 TEST_F(GViewRequestInterceptorTest, InterceptPowerpoint) { | 93 TEST_F(GViewRequestInterceptorTest, InterceptPowerpoint) { |
92 URLRequest request(GURL("http://foo.com/file.ppt"), &test_delegate_); | 94 URLRequest request(GURL("http://foo.com/file.ppt"), &test_delegate_); |
93 request.Start(); | 95 request.Start(); |
94 MessageLoop::current()->Run(); | 96 MessageLoop::current()->Run(); |
95 EXPECT_EQ(1, test_delegate_.received_redirect_count()); | 97 EXPECT_EQ(1, test_delegate_.received_redirect_count()); |
96 EXPECT_EQ(GURL("http://docs.google.com/gview?url=http%3A//foo.com/file.ppt"), | 98 EXPECT_EQ(GURL("http://docs.google.com/gview?url=http%3A//foo.com/file.ppt"), |
97 request.url()); | 99 request.url()); |
98 } | 100 } |
99 | 101 |
| 102 } // namespace chromeos |
OLD | NEW |