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

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: 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 3280 matching lines...) Expand 10 before | Expand all | Expand 10 after
3291 EXPECT_EQ(kData, d.data_received()); 3291 EXPECT_EQ(kData, d.data_received());
3292 } 3292 }
3293 3293
3294 // Check that default A-L header is sent. 3294 // Check that default A-L header is sent.
3295 TEST_F(URLRequestTestHTTP, DefaultAcceptLanguage) { 3295 TEST_F(URLRequestTestHTTP, DefaultAcceptLanguage) {
3296 ASSERT_TRUE(test_server_.Start()); 3296 ASSERT_TRUE(test_server_.Start());
3297 3297
3298 TestNetworkDelegate network_delegate; // must outlive URLRequests 3298 TestNetworkDelegate network_delegate; // must outlive URLRequests
3299 TestURLRequestContext context(true); 3299 TestURLRequestContext context(true);
3300 context.set_network_delegate(&network_delegate); 3300 context.set_network_delegate(&network_delegate);
3301 context.set_accept_language("en"); 3301 ConstHttpUserAgentSettings settings("en", EmptyString(), EmptyString());
3302 context.set_http_user_agent_settings(&settings);
3302 context.Init(); 3303 context.Init();
3303 3304
3304 TestDelegate d; 3305 TestDelegate d;
3305 URLRequest req( 3306 URLRequest req(
3306 test_server_.GetURL("echoheader?Accept-Language"), &d, &context); 3307 test_server_.GetURL("echoheader?Accept-Language"), &d, &context);
3307 req.Start(); 3308 req.Start();
3308 MessageLoop::current()->Run(); 3309 MessageLoop::current()->Run();
3309 EXPECT_EQ("en", d.data_received()); 3310 EXPECT_EQ("en", d.data_received());
3310 } 3311 }
3311 3312
3312 // Check that an empty A-L header is not sent. http://crbug.com/77365. 3313 // Check that an empty A-L header is not sent. http://crbug.com/77365.
3313 TEST_F(URLRequestTestHTTP, EmptyAcceptLanguage) { 3314 TEST_F(URLRequestTestHTTP, EmptyAcceptLanguage) {
3314 ASSERT_TRUE(test_server_.Start()); 3315 ASSERT_TRUE(test_server_.Start());
3315 3316
3316 TestNetworkDelegate network_delegate; // must outlive URLRequests 3317 TestNetworkDelegate network_delegate; // must outlive URLRequests
3317 TestURLRequestContext context(true); 3318 TestURLRequestContext context(true);
3318 context.set_network_delegate(&network_delegate); 3319 context.set_network_delegate(&network_delegate);
3319 context.Init(); 3320 context.Init();
3320 // We override the language after initialization because empty entries 3321 // We override the language after initialization because empty entries
3321 // get overridden by Init(). 3322 // get overridden by Init().
3322 context.set_accept_language(""); 3323 ConstHttpUserAgentSettings settings("", EmptyString(), EmptyString());
3324 context.set_http_user_agent_settings(&settings);
3323 3325
3324 TestDelegate d; 3326 TestDelegate d;
3325 URLRequest req( 3327 URLRequest req(
3326 test_server_.GetURL("echoheader?Accept-Language"), &d, &context); 3328 test_server_.GetURL("echoheader?Accept-Language"), &d, &context);
3327 req.Start(); 3329 req.Start();
3328 MessageLoop::current()->Run(); 3330 MessageLoop::current()->Run();
3329 EXPECT_EQ("None", d.data_received()); 3331 EXPECT_EQ("None", d.data_received());
3330 } 3332 }
3331 3333
3332 // Check that if request overrides the A-L header, the default is not appended. 3334 // 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")); 3381 EXPECT_TRUE(ContainsString(d.data_received(), "identity"));
3380 } 3382 }
3381 3383
3382 // Check that default A-C header is sent. 3384 // Check that default A-C header is sent.
3383 TEST_F(URLRequestTestHTTP, DefaultAcceptCharset) { 3385 TEST_F(URLRequestTestHTTP, DefaultAcceptCharset) {
3384 ASSERT_TRUE(test_server_.Start()); 3386 ASSERT_TRUE(test_server_.Start());
3385 3387
3386 TestNetworkDelegate network_delegate; // must outlive URLRequests 3388 TestNetworkDelegate network_delegate; // must outlive URLRequests
3387 TestURLRequestContext context(true); 3389 TestURLRequestContext context(true);
3388 context.set_network_delegate(&network_delegate); 3390 context.set_network_delegate(&network_delegate);
3389 context.set_accept_charset("en"); 3391 ConstHttpUserAgentSettings settings(EmptyString(), "en", EmptyString());
3392 context.set_http_user_agent_settings(&settings);
3390 context.Init(); 3393 context.Init();
3391 3394
3392 TestDelegate d; 3395 TestDelegate d;
3393 URLRequest req(test_server_.GetURL("echoheader?Accept-Charset"), 3396 URLRequest req(test_server_.GetURL("echoheader?Accept-Charset"),
3394 &d, 3397 &d,
3395 &context); 3398 &context);
3396 req.Start(); 3399 req.Start();
3397 MessageLoop::current()->Run(); 3400 MessageLoop::current()->Run();
3398 EXPECT_EQ("en", d.data_received()); 3401 EXPECT_EQ("en", d.data_received());
3399 } 3402 }
3400 3403
3401 // Check that an empty A-C header is not sent. http://crbug.com/77365. 3404 // Check that an empty A-C header is not sent. http://crbug.com/77365.
3402 TEST_F(URLRequestTestHTTP, EmptyAcceptCharset) { 3405 TEST_F(URLRequestTestHTTP, EmptyAcceptCharset) {
3403 ASSERT_TRUE(test_server_.Start()); 3406 ASSERT_TRUE(test_server_.Start());
3404 3407
3405 TestNetworkDelegate network_delegate; // must outlive URLRequests 3408 TestNetworkDelegate network_delegate; // must outlive URLRequests
3406 TestURLRequestContext context(true); 3409 TestURLRequestContext context(true);
3407 context.set_network_delegate(&network_delegate); 3410 context.set_network_delegate(&network_delegate);
3408 context.Init(); 3411 context.Init();
3409 // We override the accepted charset after initialization because empty 3412 // We override the accepted charset after initialization because empty
3410 // entries get overridden otherwise. 3413 // entries get overridden otherwise.
3411 context.set_accept_charset(""); 3414 ConstHttpUserAgentSettings settings(EmptyString(), "", EmptyString());
3415 context.set_http_user_agent_settings(&settings);
3412 3416
3413 TestDelegate d; 3417 TestDelegate d;
3414 URLRequest req(test_server_.GetURL("echoheader?Accept-Charset"), 3418 URLRequest req(test_server_.GetURL("echoheader?Accept-Charset"),
3415 &d, 3419 &d,
3416 &context); 3420 &context);
3417 req.Start(); 3421 req.Start();
3418 MessageLoop::current()->Run(); 3422 MessageLoop::current()->Run();
3419 EXPECT_EQ("None", d.data_received()); 3423 EXPECT_EQ("None", d.data_received());
3420 } 3424 }
3421 3425
(...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after
4651 4655
4652 EXPECT_FALSE(r.is_pending()); 4656 EXPECT_FALSE(r.is_pending());
4653 EXPECT_EQ(1, d->response_started_count()); 4657 EXPECT_EQ(1, d->response_started_count());
4654 EXPECT_FALSE(d->received_data_before_response()); 4658 EXPECT_FALSE(d->received_data_before_response());
4655 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); 4659 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size));
4656 } 4660 }
4657 } 4661 }
4658 #endif // !defined(DISABLE_FTP_SUPPORT) 4662 #endif // !defined(DISABLE_FTP_SUPPORT)
4659 4663
4660 } // namespace net 4664 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698