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

Side by Side Diff: net/url_request/url_request_unittest.cc

Issue 10918279: Provide mutable members of UrlRequestContext via pure-virtual interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: lint fixes 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
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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shlobj.h> 9 #include <shlobj.h>
10 #endif 10 #endif
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "net/ftp/ftp_network_layer.h" 45 #include "net/ftp/ftp_network_layer.h"
46 #include "net/http/http_cache.h" 46 #include "net/http/http_cache.h"
47 #include "net/http/http_network_layer.h" 47 #include "net/http/http_network_layer.h"
48 #include "net/http/http_network_session.h" 48 #include "net/http/http_network_session.h"
49 #include "net/http/http_request_headers.h" 49 #include "net/http/http_request_headers.h"
50 #include "net/http/http_response_headers.h" 50 #include "net/http/http_response_headers.h"
51 #include "net/ocsp/nss_ocsp.h" 51 #include "net/ocsp/nss_ocsp.h"
52 #include "net/proxy/proxy_service.h" 52 #include "net/proxy/proxy_service.h"
53 #include "net/socket/ssl_client_socket.h" 53 #include "net/socket/ssl_client_socket.h"
54 #include "net/test/test_server.h" 54 #include "net/test/test_server.h"
55 #include "net/url_request/const_http_user_agent_settings.h"
55 #include "net/url_request/ftp_protocol_handler.h" 56 #include "net/url_request/ftp_protocol_handler.h"
56 #include "net/url_request/url_request.h" 57 #include "net/url_request/url_request.h"
57 #include "net/url_request/url_request_file_dir_job.h" 58 #include "net/url_request/url_request_file_dir_job.h"
58 #include "net/url_request/url_request_http_job.h" 59 #include "net/url_request/url_request_http_job.h"
59 #include "net/url_request/url_request_job_factory_impl.h" 60 #include "net/url_request/url_request_job_factory_impl.h"
60 #include "net/url_request/url_request_redirect_job.h" 61 #include "net/url_request/url_request_redirect_job.h"
61 #include "net/url_request/url_request_test_job.h" 62 #include "net/url_request/url_request_test_job.h"
62 #include "net/url_request/url_request_test_util.h" 63 #include "net/url_request/url_request_test_util.h"
63 #include "testing/gtest/include/gtest/gtest.h" 64 #include "testing/gtest/include/gtest/gtest.h"
64 #include "testing/platform_test.h" 65 #include "testing/platform_test.h"
(...skipping 3226 matching lines...) Expand 10 before | Expand all | Expand 10 after
3291 EXPECT_EQ(kData, d.data_received()); 3292 EXPECT_EQ(kData, d.data_received());
3292 } 3293 }
3293 3294
3294 // Check that default A-L header is sent. 3295 // Check that default A-L header is sent.
3295 TEST_F(URLRequestTestHTTP, DefaultAcceptLanguage) { 3296 TEST_F(URLRequestTestHTTP, DefaultAcceptLanguage) {
3296 ASSERT_TRUE(test_server_.Start()); 3297 ASSERT_TRUE(test_server_.Start());
3297 3298
3298 TestNetworkDelegate network_delegate; // must outlive URLRequests 3299 TestNetworkDelegate network_delegate; // must outlive URLRequests
3299 TestURLRequestContext context(true); 3300 TestURLRequestContext context(true);
3300 context.set_network_delegate(&network_delegate); 3301 context.set_network_delegate(&network_delegate);
3301 context.set_accept_language("en"); 3302 ConstHttpUserAgentSettings settings("en", EmptyString(), EmptyString());
3303 context.set_http_user_agent_settings(&settings);
3302 context.Init(); 3304 context.Init();
3303 3305
3304 TestDelegate d; 3306 TestDelegate d;
3305 URLRequest req( 3307 URLRequest req(
3306 test_server_.GetURL("echoheader?Accept-Language"), &d, &context); 3308 test_server_.GetURL("echoheader?Accept-Language"), &d, &context);
3307 req.Start(); 3309 req.Start();
3308 MessageLoop::current()->Run(); 3310 MessageLoop::current()->Run();
3309 EXPECT_EQ("en", d.data_received()); 3311 EXPECT_EQ("en", d.data_received());
3310 } 3312 }
3311 3313
3312 // Check that an empty A-L header is not sent. http://crbug.com/77365. 3314 // Check that an empty A-L header is not sent. http://crbug.com/77365.
3313 TEST_F(URLRequestTestHTTP, EmptyAcceptLanguage) { 3315 TEST_F(URLRequestTestHTTP, EmptyAcceptLanguage) {
3314 ASSERT_TRUE(test_server_.Start()); 3316 ASSERT_TRUE(test_server_.Start());
3315 3317
3316 TestNetworkDelegate network_delegate; // must outlive URLRequests 3318 TestNetworkDelegate network_delegate; // must outlive URLRequests
3317 TestURLRequestContext context(true); 3319 TestURLRequestContext context(true);
3318 context.set_network_delegate(&network_delegate); 3320 context.set_network_delegate(&network_delegate);
3319 context.Init(); 3321 context.Init();
3320 // We override the language after initialization because empty entries 3322 // We override the language after initialization because empty entries
3321 // get overridden by Init(). 3323 // get overridden by Init().
3322 context.set_accept_language(""); 3324 ConstHttpUserAgentSettings settings("", EmptyString(), EmptyString());
3325 context.set_http_user_agent_settings(&settings);
3323 3326
3324 TestDelegate d; 3327 TestDelegate d;
3325 URLRequest req( 3328 URLRequest req(
3326 test_server_.GetURL("echoheader?Accept-Language"), &d, &context); 3329 test_server_.GetURL("echoheader?Accept-Language"), &d, &context);
3327 req.Start(); 3330 req.Start();
3328 MessageLoop::current()->Run(); 3331 MessageLoop::current()->Run();
3329 EXPECT_EQ("None", d.data_received()); 3332 EXPECT_EQ("None", d.data_received());
3330 } 3333 }
3331 3334
3332 // Check that if request overrides the A-L header, the default is not appended. 3335 // Check that if request overrides the A-L header, the default is not appended.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
3379 EXPECT_TRUE(ContainsString(d.data_received(), "identity")); 3382 EXPECT_TRUE(ContainsString(d.data_received(), "identity"));
3380 } 3383 }
3381 3384
3382 // Check that default A-C header is sent. 3385 // Check that default A-C header is sent.
3383 TEST_F(URLRequestTestHTTP, DefaultAcceptCharset) { 3386 TEST_F(URLRequestTestHTTP, DefaultAcceptCharset) {
3384 ASSERT_TRUE(test_server_.Start()); 3387 ASSERT_TRUE(test_server_.Start());
3385 3388
3386 TestNetworkDelegate network_delegate; // must outlive URLRequests 3389 TestNetworkDelegate network_delegate; // must outlive URLRequests
3387 TestURLRequestContext context(true); 3390 TestURLRequestContext context(true);
3388 context.set_network_delegate(&network_delegate); 3391 context.set_network_delegate(&network_delegate);
3389 context.set_accept_charset("en"); 3392 ConstHttpUserAgentSettings settings(EmptyString(), "en", EmptyString());
3393 context.set_http_user_agent_settings(&settings);
3390 context.Init(); 3394 context.Init();
3391 3395
3392 TestDelegate d; 3396 TestDelegate d;
3393 URLRequest req(test_server_.GetURL("echoheader?Accept-Charset"), 3397 URLRequest req(test_server_.GetURL("echoheader?Accept-Charset"),
3394 &d, 3398 &d,
3395 &context); 3399 &context);
3396 req.Start(); 3400 req.Start();
3397 MessageLoop::current()->Run(); 3401 MessageLoop::current()->Run();
3398 EXPECT_EQ("en", d.data_received()); 3402 EXPECT_EQ("en", d.data_received());
3399 } 3403 }
3400 3404
3401 // Check that an empty A-C header is not sent. http://crbug.com/77365. 3405 // Check that an empty A-C header is not sent. http://crbug.com/77365.
3402 TEST_F(URLRequestTestHTTP, EmptyAcceptCharset) { 3406 TEST_F(URLRequestTestHTTP, EmptyAcceptCharset) {
3403 ASSERT_TRUE(test_server_.Start()); 3407 ASSERT_TRUE(test_server_.Start());
3404 3408
3405 TestNetworkDelegate network_delegate; // must outlive URLRequests 3409 TestNetworkDelegate network_delegate; // must outlive URLRequests
3406 TestURLRequestContext context(true); 3410 TestURLRequestContext context(true);
3407 context.set_network_delegate(&network_delegate); 3411 context.set_network_delegate(&network_delegate);
3408 context.Init(); 3412 context.Init();
3409 // We override the accepted charset after initialization because empty 3413 // We override the accepted charset after initialization because empty
3410 // entries get overridden otherwise. 3414 // entries get overridden otherwise.
3411 context.set_accept_charset(""); 3415 ConstHttpUserAgentSettings settings(EmptyString(), "", EmptyString());
3416 context.set_http_user_agent_settings(&settings);
3412 3417
3413 TestDelegate d; 3418 TestDelegate d;
3414 URLRequest req(test_server_.GetURL("echoheader?Accept-Charset"), 3419 URLRequest req(test_server_.GetURL("echoheader?Accept-Charset"),
3415 &d, 3420 &d,
3416 &context); 3421 &context);
3417 req.Start(); 3422 req.Start();
3418 MessageLoop::current()->Run(); 3423 MessageLoop::current()->Run();
3419 EXPECT_EQ("None", d.data_received()); 3424 EXPECT_EQ("None", d.data_received());
3420 } 3425 }
3421 3426
(...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after
4651 4656
4652 EXPECT_FALSE(r.is_pending()); 4657 EXPECT_FALSE(r.is_pending());
4653 EXPECT_EQ(1, d->response_started_count()); 4658 EXPECT_EQ(1, d->response_started_count());
4654 EXPECT_FALSE(d->received_data_before_response()); 4659 EXPECT_FALSE(d->received_data_before_response());
4655 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); 4660 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size));
4656 } 4661 }
4657 } 4662 }
4658 #endif // !defined(DISABLE_FTP_SUPPORT) 4663 #endif // !defined(DISABLE_FTP_SUPPORT)
4659 4664
4660 } // namespace net 4665 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698