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

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

Issue 3390026: net: Append base:: in the StringPrintf calls. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: fix include order Created 10 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
« no previous file with comments | « net/tools/hresolv/hresolv.cc ('k') | net/websockets/websocket_handshake.cc » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/url_request/url_request_unittest.h" 5 #include "net/url_request/url_request_unittest.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <shlobj.h>
10 #include <windows.h> 11 #include <windows.h>
11 #include <shlobj.h>
12 #elif defined(USE_NSS) 12 #elif defined(USE_NSS)
13 #include "base/nss_util.h" 13 #include "base/nss_util.h"
14 #endif 14 #endif
15 15
16 #include <algorithm> 16 #include <algorithm>
17 #include <string> 17 #include <string>
18 18
19 #include "base/file_util.h" 19 #include "base/file_util.h"
20 #include "base/format_macros.h" 20 #include "base/format_macros.h"
21 #include "base/message_loop.h" 21 #include "base/message_loop.h"
22 #include "base/path_service.h" 22 #include "base/path_service.h"
23 #include "base/process_util.h" 23 #include "base/process_util.h"
24 #include "base/string_number_conversions.h"
24 #include "base/string_piece.h" 25 #include "base/string_piece.h"
25 #include "base/string_number_conversions.h" 26 #include "base/stringprintf.h"
26 #include "base/utf_string_conversions.h" 27 #include "base/utf_string_conversions.h"
27 #include "net/base/cookie_monster.h" 28 #include "net/base/cookie_monster.h"
28 #include "net/base/cookie_policy.h" 29 #include "net/base/cookie_policy.h"
29 #include "net/base/load_flags.h" 30 #include "net/base/load_flags.h"
31 #include "net/base/net_errors.h"
30 #include "net/base/net_log.h" 32 #include "net/base/net_log.h"
31 #include "net/base/net_log_unittest.h" 33 #include "net/base/net_log_unittest.h"
32 #include "net/base/net_errors.h"
33 #include "net/base/net_module.h" 34 #include "net/base/net_module.h"
34 #include "net/base/net_util.h" 35 #include "net/base/net_util.h"
35 #include "net/base/ssl_connection_status_flags.h" 36 #include "net/base/ssl_connection_status_flags.h"
36 #include "net/base/upload_data.h" 37 #include "net/base/upload_data.h"
37 #include "net/disk_cache/disk_cache.h" 38 #include "net/disk_cache/disk_cache.h"
38 #include "net/ftp/ftp_network_layer.h" 39 #include "net/ftp/ftp_network_layer.h"
39 #include "net/http/http_cache.h" 40 #include "net/http/http_cache.h"
40 #include "net/http/http_network_layer.h" 41 #include "net/http/http_network_layer.h"
41 #include "net/http/http_request_headers.h" 42 #include "net/http/http_request_headers.h"
42 #include "net/http/http_response_headers.h" 43 #include "net/http/http_response_headers.h"
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 335
335 // Some tests use browser javascript to fetch a 'kill' url that causes 336 // Some tests use browser javascript to fetch a 'kill' url that causes
336 // the server to exit by itself (rather than letting TestServerLauncher's 337 // the server to exit by itself (rather than letting TestServerLauncher's
337 // destructor kill it). We now unit test this mechanism. 338 // destructor kill it). We now unit test this mechanism.
338 TEST_F(URLRequestTest, QuitTest) { 339 TEST_F(URLRequestTest, QuitTest) {
339 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath()); 340 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath());
340 ASSERT_TRUE(test_server.Start()); 341 ASSERT_TRUE(test_server.Start());
341 342
342 // Append the time to avoid problems where the kill page 343 // Append the time to avoid problems where the kill page
343 // is being cached rather than being executed on the server 344 // is being cached rather than being executed on the server
344 std::string page_name = StringPrintf("kill?%u", 345 std::string page_name = base::StringPrintf("kill?%u",
345 static_cast<int>(base::Time::Now().ToInternalValue())); 346 static_cast<int>(base::Time::Now().ToInternalValue()));
346 int retry_count = 5; 347 int retry_count = 5;
347 while (retry_count > 0) { 348 while (retry_count > 0) {
348 bool r = MakeGETRequest(test_server.GetURL(page_name)); 349 bool r = MakeGETRequest(test_server.GetURL(page_name));
349 // BUG #1048625 causes the kill GET to fail. For now we just retry. 350 // BUG #1048625 causes the kill GET to fail. For now we just retry.
350 // Once the bug is fixed, we should remove the while loop and put back 351 // Once the bug is fixed, we should remove the while loop and put back
351 // the following DCHECK. 352 // the following DCHECK.
352 // DCHECK(r); 353 // DCHECK(r);
353 if (r) 354 if (r)
354 break; 355 break;
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 const size_t content_length = last_byte_position - first_byte_position + 1; 798 const size_t content_length = last_byte_position - first_byte_position + 1;
798 std::string partial_buffer_string(buffer.get() + first_byte_position, 799 std::string partial_buffer_string(buffer.get() + first_byte_position,
799 buffer.get() + last_byte_position + 1); 800 buffer.get() + last_byte_position + 1);
800 801
801 TestDelegate d; 802 TestDelegate d;
802 { 803 {
803 TestURLRequest r(temp_url, &d); 804 TestURLRequest r(temp_url, &d);
804 805
805 net::HttpRequestHeaders headers; 806 net::HttpRequestHeaders headers;
806 headers.SetHeader(net::HttpRequestHeaders::kRange, 807 headers.SetHeader(net::HttpRequestHeaders::kRange,
807 StringPrintf("bytes=%" PRIuS "-%" PRIuS, 808 base::StringPrintf(
808 first_byte_position, last_byte_position)); 809 "bytes=%" PRIuS "-%" PRIuS,
810 first_byte_position, last_byte_position));
809 r.SetExtraRequestHeaders(headers); 811 r.SetExtraRequestHeaders(headers);
810 r.Start(); 812 r.Start();
811 EXPECT_TRUE(r.is_pending()); 813 EXPECT_TRUE(r.is_pending());
812 814
813 MessageLoop::current()->Run(); 815 MessageLoop::current()->Run();
814 EXPECT_TRUE(!r.is_pending()); 816 EXPECT_TRUE(!r.is_pending());
815 EXPECT_EQ(1, d.response_started_count()); 817 EXPECT_EQ(1, d.response_started_count());
816 EXPECT_FALSE(d.received_data_before_response()); 818 EXPECT_FALSE(d.received_data_before_response());
817 EXPECT_EQ(static_cast<int>(content_length), d.bytes_received()); 819 EXPECT_EQ(static_cast<int>(content_length), d.bytes_received());
818 // Don't use EXPECT_EQ, it will print out a lot of garbage if check failed. 820 // Don't use EXPECT_EQ, it will print out a lot of garbage if check failed.
(...skipping 21 matching lines...) Expand all
840 const size_t content_length = last_byte_position - first_byte_position + 1; 842 const size_t content_length = last_byte_position - first_byte_position + 1;
841 std::string partial_buffer_string(buffer.get() + first_byte_position, 843 std::string partial_buffer_string(buffer.get() + first_byte_position,
842 buffer.get() + last_byte_position + 1); 844 buffer.get() + last_byte_position + 1);
843 845
844 TestDelegate d; 846 TestDelegate d;
845 { 847 {
846 TestURLRequest r(temp_url, &d); 848 TestURLRequest r(temp_url, &d);
847 849
848 net::HttpRequestHeaders headers; 850 net::HttpRequestHeaders headers;
849 headers.SetHeader(net::HttpRequestHeaders::kRange, 851 headers.SetHeader(net::HttpRequestHeaders::kRange,
850 StringPrintf("bytes=%" PRIuS "-", 852 base::StringPrintf("bytes=%" PRIuS "-",
851 first_byte_position)); 853 first_byte_position));
852 r.SetExtraRequestHeaders(headers); 854 r.SetExtraRequestHeaders(headers);
853 r.Start(); 855 r.Start();
854 EXPECT_TRUE(r.is_pending()); 856 EXPECT_TRUE(r.is_pending());
855 857
856 MessageLoop::current()->Run(); 858 MessageLoop::current()->Run();
857 EXPECT_TRUE(!r.is_pending()); 859 EXPECT_TRUE(!r.is_pending());
858 EXPECT_EQ(1, d.response_started_count()); 860 EXPECT_EQ(1, d.response_started_count());
859 EXPECT_FALSE(d.received_data_before_response()); 861 EXPECT_FALSE(d.received_data_before_response());
860 EXPECT_EQ(static_cast<int>(content_length), d.bytes_received()); 862 EXPECT_EQ(static_cast<int>(content_length), d.bytes_received());
861 // Don't use EXPECT_EQ, it will print out a lot of garbage if check failed. 863 // Don't use EXPECT_EQ, it will print out a lot of garbage if check failed.
(...skipping 1816 matching lines...) Expand 10 before | Expand all | Expand 10 after
2678 TestURLRequest 2680 TestURLRequest
2679 req(test_server_.GetURL("echoheaderoverride?Accept-Charset"), &d); 2681 req(test_server_.GetURL("echoheaderoverride?Accept-Charset"), &d);
2680 req.set_context(new TestURLRequestContext()); 2682 req.set_context(new TestURLRequestContext());
2681 net::HttpRequestHeaders headers; 2683 net::HttpRequestHeaders headers;
2682 headers.SetHeader(net::HttpRequestHeaders::kAcceptCharset, "koi-8r"); 2684 headers.SetHeader(net::HttpRequestHeaders::kAcceptCharset, "koi-8r");
2683 req.SetExtraRequestHeaders(headers); 2685 req.SetExtraRequestHeaders(headers);
2684 req.Start(); 2686 req.Start();
2685 MessageLoop::current()->Run(); 2687 MessageLoop::current()->Run();
2686 EXPECT_EQ(std::string("koi-8r"), d.data_received()); 2688 EXPECT_EQ(std::string("koi-8r"), d.data_received());
2687 } 2689 }
OLDNEW
« no previous file with comments | « net/tools/hresolv/hresolv.cc ('k') | net/websockets/websocket_handshake.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698