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

Side by Side Diff: net/proxy/proxy_script_fetcher_impl_unittest.cc

Issue 10836206: Removed static factories for data, ftp, file, and about jobs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: small fix Created 8 years, 3 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
« no previous file with comments | « chrome/browser/profiles/profile_io_data.cc ('k') | net/url_request/url_request_about_job.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "net/proxy/proxy_script_fetcher_impl.h" 5 #include "net/proxy/proxy_script_fetcher_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "net/base/mock_cert_verifier.h" 13 #include "net/base/mock_cert_verifier.h"
14 #include "net/base/mock_host_resolver.h" 14 #include "net/base/mock_host_resolver.h"
15 #include "net/base/net_util.h" 15 #include "net/base/net_util.h"
16 #include "net/base/load_flags.h" 16 #include "net/base/load_flags.h"
17 #include "net/base/ssl_config_service_defaults.h" 17 #include "net/base/ssl_config_service_defaults.h"
18 #include "net/base/test_completion_callback.h" 18 #include "net/base/test_completion_callback.h"
19 #include "net/disk_cache/disk_cache.h" 19 #include "net/disk_cache/disk_cache.h"
20 #include "net/http/http_cache.h" 20 #include "net/http/http_cache.h"
21 #include "net/http/http_network_session.h" 21 #include "net/http/http_network_session.h"
22 #include "net/http/http_server_properties_impl.h" 22 #include "net/http/http_server_properties_impl.h"
23 #include "net/test/test_server.h" 23 #include "net/test/test_server.h"
24 #include "net/url_request/file_protocol_handler.h"
24 #include "net/url_request/url_request_context_storage.h" 25 #include "net/url_request/url_request_context_storage.h"
25 #include "net/url_request/url_request_file_job.h" 26 #include "net/url_request/url_request_file_job.h"
26 #include "net/url_request/url_request_job_factory_impl.h" 27 #include "net/url_request/url_request_job_factory_impl.h"
27 #include "net/url_request/url_request_test_util.h" 28 #include "net/url_request/url_request_test_util.h"
28 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
29 #include "testing/platform_test.h" 30 #include "testing/platform_test.h"
30 31
31 namespace net { 32 namespace net {
32 33
33 // TODO(eroman): 34 // TODO(eroman):
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 context_.set_network_delegate(&network_delegate_); 214 context_.set_network_delegate(&network_delegate_);
214 } 215 }
215 216
216 protected: 217 protected:
217 TestServer test_server_; 218 TestServer test_server_;
218 BasicNetworkDelegate network_delegate_; 219 BasicNetworkDelegate network_delegate_;
219 RequestContext context_; 220 RequestContext context_;
220 }; 221 };
221 222
222 TEST_F(ProxyScriptFetcherImplTest, FileUrl) { 223 TEST_F(ProxyScriptFetcherImplTest, FileUrl) {
224 URLRequestJobFactory job_factory;
225 job_factory.SetProtocolHandler("file", new FileProtocolHandler());
226 context_.set_job_factory(&job_factory);
227
223 ProxyScriptFetcherImpl pac_fetcher(&context_); 228 ProxyScriptFetcherImpl pac_fetcher(&context_);
224 229
225 { // Fetch a non-existent file. 230 { // Fetch a non-existent file.
226 string16 text; 231 string16 text;
227 TestCompletionCallback callback; 232 TestCompletionCallback callback;
228 int result = pac_fetcher.Fetch(GetTestFileUrl("does-not-exist"), 233 int result = pac_fetcher.Fetch(GetTestFileUrl("does-not-exist"),
229 &text, callback.callback()); 234 &text, callback.callback());
230 EXPECT_EQ(ERR_IO_PENDING, result); 235 EXPECT_EQ(ERR_IO_PENDING, result);
231 EXPECT_EQ(ERR_FILE_NOT_FOUND, callback.WaitForResult()); 236 EXPECT_EQ(ERR_FILE_NOT_FOUND, callback.WaitForResult());
232 EXPECT_TRUE(text.empty()); 237 EXPECT_TRUE(text.empty());
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 TestCompletionCallback callback; 351 TestCompletionCallback callback;
347 int result = pac_fetcher.Fetch(url, &text, callback.callback()); 352 int result = pac_fetcher.Fetch(url, &text, callback.callback());
348 EXPECT_EQ(ERR_IO_PENDING, result); 353 EXPECT_EQ(ERR_IO_PENDING, result);
349 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.WaitForResult()); 354 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.WaitForResult());
350 } 355 }
351 } 356 }
352 357
353 TEST_F(ProxyScriptFetcherImplTest, TooLarge) { 358 TEST_F(ProxyScriptFetcherImplTest, TooLarge) {
354 ASSERT_TRUE(test_server_.Start()); 359 ASSERT_TRUE(test_server_.Start());
355 360
361 URLRequestJobFactory job_factory;
362 job_factory.SetProtocolHandler("file", new FileProtocolHandler());
363 context_.set_job_factory(&job_factory);
364
356 ProxyScriptFetcherImpl pac_fetcher(&context_); 365 ProxyScriptFetcherImpl pac_fetcher(&context_);
357 366
358 // Set the maximum response size to 50 bytes. 367 // Set the maximum response size to 50 bytes.
359 int prev_size = pac_fetcher.SetSizeConstraint(50); 368 int prev_size = pac_fetcher.SetSizeConstraint(50);
360 369
361 // These two URLs are the same file, but are http:// vs file:// 370 // These two URLs are the same file, but are http:// vs file://
362 GURL urls[] = { 371 GURL urls[] = {
363 test_server_.GetURL("files/large-pac.nsproxy"), 372 test_server_.GetURL("files/large-pac.nsproxy"),
364 GetTestFileUrl("large-pac.nsproxy") 373 GetTestFileUrl("large-pac.nsproxy")
365 }; 374 };
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 { 497 {
489 GURL url(kEncodedUrlBroken); 498 GURL url(kEncodedUrlBroken);
490 string16 text; 499 string16 text;
491 TestCompletionCallback callback; 500 TestCompletionCallback callback;
492 int result = pac_fetcher.Fetch(url, &text, callback.callback()); 501 int result = pac_fetcher.Fetch(url, &text, callback.callback());
493 EXPECT_EQ(ERR_FAILED, result); 502 EXPECT_EQ(ERR_FAILED, result);
494 } 503 }
495 } 504 }
496 505
497 } // namespace net 506 } // namespace net
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_io_data.cc ('k') | net/url_request/url_request_about_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698