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

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

Issue 5607004: net: Remove typedef net::URLRequestJob URLRequestJob; (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased 2 Created 10 years 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) 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 "chrome/browser/plugin_service.h" 8 #include "chrome/browser/plugin_service.h"
9 #include "chrome/common/chrome_paths.h" 9 #include "chrome/common/chrome_paths.h"
10 #include "net/base/load_flags.h" 10 #include "net/base/load_flags.h"
(...skipping 10 matching lines...) Expand all
21 public: 21 public:
22 explicit GViewURLRequestTestJob(net::URLRequest* request) 22 explicit GViewURLRequestTestJob(net::URLRequest* request)
23 : URLRequestTestJob(request, true) { 23 : URLRequestTestJob(request, true) {
24 } 24 }
25 25
26 virtual bool GetMimeType(std::string* mime_type) const { 26 virtual bool GetMimeType(std::string* mime_type) const {
27 // During the course of a single test, two URLRequestJobs are 27 // During the course of a single test, two URLRequestJobs are
28 // created -- the first is for the viewable document URL, and the 28 // created -- the first is for the viewable document URL, and the
29 // second is for the rediected URL. In order to test the 29 // second is for the rediected URL. In order to test the
30 // interceptor, the mime type of the first request must be one of 30 // interceptor, the mime type of the first request must be one of
31 // the supported viewable mime types. So when the URLRequestJob 31 // the supported viewable mime types. So when the net::URLRequestJob
32 // is a request for one of the test URLs that point to viewable 32 // is a request for one of the test URLs that point to viewable
33 // content, return an appropraite mime type. Otherwise, return 33 // content, return an appropraite mime type. Otherwise, return
34 // "text/html". 34 // "text/html".
35 if (request_->url() == GURL("http://foo.com/file.pdf")) { 35 if (request_->url() == GURL("http://foo.com/file.pdf")) {
36 *mime_type = "application/pdf"; 36 *mime_type = "application/pdf";
37 } else if (request_->url() == GURL("http://foo.com/file.ppt")) { 37 } else if (request_->url() == GURL("http://foo.com/file.ppt")) {
38 *mime_type = "application/vnd.ms-powerpoint"; 38 *mime_type = "application/vnd.ms-powerpoint";
39 } else { 39 } else {
40 *mime_type = "text/html"; 40 *mime_type = "text/html";
41 } 41 }
(...skipping 11 matching lines...) Expand all
53 &GViewRequestInterceptorTest::Factory); 53 &GViewRequestInterceptorTest::Factory);
54 interceptor_ = GViewRequestInterceptor::GetGViewRequestInterceptor(); 54 interceptor_ = GViewRequestInterceptor::GetGViewRequestInterceptor();
55 ASSERT_TRUE(PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path_)); 55 ASSERT_TRUE(PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path_));
56 } 56 }
57 57
58 virtual void TearDown() { 58 virtual void TearDown() {
59 net::URLRequest::RegisterProtocolFactory("http", NULL); 59 net::URLRequest::RegisterProtocolFactory("http", NULL);
60 message_loop_.RunAllPending(); 60 message_loop_.RunAllPending();
61 } 61 }
62 62
63 static URLRequestJob* Factory(net::URLRequest* request, 63 static net::URLRequestJob* Factory(net::URLRequest* request,
64 const std::string& scheme) { 64 const std::string& scheme) {
65 return new GViewURLRequestTestJob(request); 65 return new GViewURLRequestTestJob(request);
66 } 66 }
67 67
68 void RegisterPDFPlugin() { 68 void RegisterPDFPlugin() {
69 NPAPI::PluginVersionInfo info; 69 NPAPI::PluginVersionInfo info;
70 info.path = pdf_path_; 70 info.path = pdf_path_;
71 memset(&info.entry_points, 0, sizeof(info.entry_points)); 71 memset(&info.entry_points, 0, sizeof(info.entry_points));
72 NPAPI::PluginList::Singleton()->RegisterInternalPlugin(info); 72 NPAPI::PluginList::Singleton()->RegisterInternalPlugin(info);
73 NPAPI::PluginList::Singleton()->RefreshPlugins(); 73 NPAPI::PluginList::Singleton()->RefreshPlugins();
74 } 74 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 TEST_F(GViewRequestInterceptorTest, InterceptPowerpoint) { 173 TEST_F(GViewRequestInterceptorTest, InterceptPowerpoint) {
174 net::URLRequest request(GURL("http://foo.com/file.ppt"), &test_delegate_); 174 net::URLRequest request(GURL("http://foo.com/file.ppt"), &test_delegate_);
175 request.Start(); 175 request.Start();
176 MessageLoop::current()->Run(); 176 MessageLoop::current()->Run();
177 EXPECT_EQ(1, test_delegate_.received_redirect_count()); 177 EXPECT_EQ(1, test_delegate_.received_redirect_count());
178 EXPECT_EQ(GURL("http://docs.google.com/gview?url=http%3A//foo.com/file.ppt"), 178 EXPECT_EQ(GURL("http://docs.google.com/gview?url=http%3A//foo.com/file.ppt"),
179 request.url()); 179 request.url());
180 } 180 }
181 181
182 } // namespace chromeos 182 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gview_request_interceptor.cc ('k') | chrome/browser/chromeos/login/account_screen_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698