Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(843)

Side by Side Diff: chrome/browser/chromeos/gview_request_interceptor_unittest.cc

Issue 10855209: Refactoring: ProtocolHandler::MaybeCreateJob takes NetworkDelegate as argument (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Latest merge Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <vector> 6 #include <vector>
7 7
8 #include "base/at_exit.h" 8 #include "base/at_exit.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "chrome/browser/chrome_plugin_service_filter.h" 10 #include "chrome/browser/chrome_plugin_service_filter.h"
(...skipping 27 matching lines...) Expand all
38 const char kHtmlUrl[] = "http://foo.com/index.html"; 38 const char kHtmlUrl[] = "http://foo.com/index.html";
39 const char kPdfBlob[] = "blob:blobinternal:///d17c4eef-28e7-42bd-bafa-78d5cb8"; 39 const char kPdfBlob[] = "blob:blobinternal:///d17c4eef-28e7-42bd-bafa-78d5cb8";
40 40
41 const char kPdfUrlIntercepted[] = 41 const char kPdfUrlIntercepted[] =
42 "http://docs.google.com/gview?url=http%3A//foo.com/file.pdf"; 42 "http://docs.google.com/gview?url=http%3A//foo.com/file.pdf";
43 const char kPptUrlIntercepted[] = 43 const char kPptUrlIntercepted[] =
44 "http://docs.google.com/gview?url=http%3A//foo.com/file.ppt"; 44 "http://docs.google.com/gview?url=http%3A//foo.com/file.ppt";
45 45
46 class GViewURLRequestTestJob : public net::URLRequestTestJob { 46 class GViewURLRequestTestJob : public net::URLRequestTestJob {
47 public: 47 public:
48 explicit GViewURLRequestTestJob(net::URLRequest* request) 48 GViewURLRequestTestJob(net::URLRequest* request,
49 : net::URLRequestTestJob(request, true) { 49 net::NetworkDelegate* network_delegate)
50 : net::URLRequestTestJob(request, network_delegate, true) {
50 } 51 }
51 52
52 virtual bool GetMimeType(std::string* mime_type) const { 53 virtual bool GetMimeType(std::string* mime_type) const {
53 // During the course of a single test, two URLRequestJobs are 54 // During the course of a single test, two URLRequestJobs are
54 // created -- the first is for the viewable document URL, and the 55 // created -- the first is for the viewable document URL, and the
55 // second is for the rediected URL. In order to test the 56 // second is for the rediected URL. In order to test the
56 // interceptor, the mime type of the first request must be one of 57 // interceptor, the mime type of the first request must be one of
57 // the supported viewable mime types. So when the net::URLRequestJob 58 // the supported viewable mime types. So when the net::URLRequestJob
58 // is a request for one of the test URLs that point to viewable 59 // is a request for one of the test URLs that point to viewable
59 // content, return an appropraite mime type. Otherwise, return 60 // content, return an appropraite mime type. Otherwise, return
(...skipping 12 matching lines...) Expand all
72 private: 73 private:
73 ~GViewURLRequestTestJob() {} 74 ~GViewURLRequestTestJob() {}
74 }; 75 };
75 76
76 class GViewRequestProtocolFactory 77 class GViewRequestProtocolFactory
77 : public net::URLRequestJobFactory::ProtocolHandler { 78 : public net::URLRequestJobFactory::ProtocolHandler {
78 public: 79 public:
79 GViewRequestProtocolFactory() {} 80 GViewRequestProtocolFactory() {}
80 virtual ~GViewRequestProtocolFactory() {} 81 virtual ~GViewRequestProtocolFactory() {}
81 82
82 virtual net::URLRequestJob* MaybeCreateJob(net::URLRequest* request) const { 83 virtual net::URLRequestJob* MaybeCreateJob(
83 return new GViewURLRequestTestJob(request); 84 net::URLRequest* request, net::NetworkDelegate* network_delegate) const {
85 return new GViewURLRequestTestJob(request, network_delegate);
84 } 86 }
85 }; 87 };
86 88
87 class GViewRequestInterceptorTest : public testing::Test { 89 class GViewRequestInterceptorTest : public testing::Test {
88 public: 90 public:
89 GViewRequestInterceptorTest() 91 GViewRequestInterceptorTest()
90 : ui_thread_(BrowserThread::UI, &message_loop_), 92 : ui_thread_(BrowserThread::UI, &message_loop_),
91 file_thread_(BrowserThread::FILE, &message_loop_), 93 file_thread_(BrowserThread::FILE, &message_loop_),
92 io_thread_(BrowserThread::IO, &message_loop_), 94 io_thread_(BrowserThread::IO, &message_loop_),
93 plugin_list_(NULL, 0) {} 95 plugin_list_(NULL, 0) {}
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 SetupRequest(&request); 279 SetupRequest(&request);
278 request.Start(); 280 request.Start();
279 MessageLoop::current()->Run(); 281 MessageLoop::current()->Run();
280 EXPECT_EQ(0, test_delegate_.received_redirect_count()); 282 EXPECT_EQ(0, test_delegate_.received_redirect_count());
281 EXPECT_EQ(GURL(kPdfBlob), request.url()); 283 EXPECT_EQ(GURL(kPdfBlob), request.url());
282 } 284 }
283 285
284 } // namespace 286 } // namespace
285 287
286 } // namespace chromeos 288 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gview_request_interceptor.cc ('k') | chrome/browser/chromeos/login/registration_screen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698