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

Side by Side Diff: content/browser/loader/resource_dispatcher_host_browsertest.cc

Issue 1172183002: Move StartsWith[ASCII] to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@string_util3
Patch Set: merger Created 5 years, 6 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
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 "base/memory/ref_counted.h" 5 #include "base/memory/ref_counted.h"
6 #include "base/strings/string_util.h" 6 #include "base/strings/string_util.h"
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "content/browser/download/download_manager_impl.h" 9 #include "content/browser/download/download_manager_impl.h"
10 #include "content/browser/web_contents/web_contents_impl.h" 10 #include "content/browser/web_contents/web_contents_impl.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 }; 96 };
97 97
98 // Test title for content created by javascript window.open(). 98 // Test title for content created by javascript window.open().
99 // See http://crbug.com/5988 99 // See http://crbug.com/5988
100 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, DynamicTitle1) { 100 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, DynamicTitle1) {
101 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 101 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
102 102
103 GURL url(embedded_test_server()->GetURL("/dynamic1.html")); 103 GURL url(embedded_test_server()->GetURL("/dynamic1.html"));
104 base::string16 title; 104 base::string16 title;
105 ASSERT_TRUE(GetPopupTitle(url, &title)); 105 ASSERT_TRUE(GetPopupTitle(url, &title));
106 EXPECT_TRUE(StartsWith(title, ASCIIToUTF16("My Popup Title"), true)) 106 EXPECT_TRUE(base::StartsWith(title, ASCIIToUTF16("My Popup Title"), true))
107 << "Actual title: " << title; 107 << "Actual title: " << title;
108 } 108 }
109 109
110 // Test title for content created by javascript window.open(). 110 // Test title for content created by javascript window.open().
111 // See http://crbug.com/5988 111 // See http://crbug.com/5988
112 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, DynamicTitle2) { 112 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, DynamicTitle2) {
113 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 113 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
114 114
115 GURL url(embedded_test_server()->GetURL("/dynamic2.html")); 115 GURL url(embedded_test_server()->GetURL("/dynamic2.html"));
116 base::string16 title; 116 base::string16 title;
117 ASSERT_TRUE(GetPopupTitle(url, &title)); 117 ASSERT_TRUE(GetPopupTitle(url, &title));
118 EXPECT_TRUE(StartsWith(title, ASCIIToUTF16("My Dynamic Title"), true)) 118 EXPECT_TRUE(base::StartsWith(title, ASCIIToUTF16("My Dynamic Title"), true))
119 << "Actual title: " << title; 119 << "Actual title: " << title;
120 } 120 }
121 121
122 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, 122 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest,
123 SniffHTMLWithNoContentType) { 123 SniffHTMLWithNoContentType) {
124 CheckTitleTest(GetMockURL("content-sniffer-test0.html"), 124 CheckTitleTest(GetMockURL("content-sniffer-test0.html"),
125 "Content Sniffer Test 0"); 125 "Content Sniffer Test 0");
126 } 126 }
127 127
128 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, 128 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest,
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 // Check that the cookie was set. 259 // Check that the cookie was set.
260 EXPECT_EQ("onunloadCookie=foo", GetCookies(url)); 260 EXPECT_EQ("onunloadCookie=foo", GetCookies(url));
261 } 261 }
262 262
263 namespace { 263 namespace {
264 264
265 // Handles |request| by serving a redirect response. 265 // Handles |request| by serving a redirect response.
266 scoped_ptr<net::test_server::HttpResponse> NoContentResponseHandler( 266 scoped_ptr<net::test_server::HttpResponse> NoContentResponseHandler(
267 const std::string& path, 267 const std::string& path,
268 const net::test_server::HttpRequest& request) { 268 const net::test_server::HttpRequest& request) {
269 if (!StartsWithASCII(path, request.relative_url, true)) 269 if (!base::StartsWithASCII(path, request.relative_url, true))
270 return scoped_ptr<net::test_server::HttpResponse>(); 270 return scoped_ptr<net::test_server::HttpResponse>();
271 271
272 scoped_ptr<net::test_server::BasicHttpResponse> http_response( 272 scoped_ptr<net::test_server::BasicHttpResponse> http_response(
273 new net::test_server::BasicHttpResponse); 273 new net::test_server::BasicHttpResponse);
274 http_response->set_code(net::HTTP_NO_CONTENT); 274 http_response->set_code(net::HTTP_NO_CONTENT);
275 return http_response.Pass(); 275 return http_response.Pass();
276 } 276 }
277 277
278 } // namespace 278 } // namespace
279 279
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 // Visit a URL that fails without calling ResourceDispatcherHost::Read. 436 // Visit a URL that fails without calling ResourceDispatcherHost::Read.
437 GURL broken_url("chrome://theme"); 437 GURL broken_url("chrome://theme");
438 NavigateToURL(shell(), broken_url); 438 NavigateToURL(shell(), broken_url);
439 } 439 }
440 440
441 namespace { 441 namespace {
442 442
443 scoped_ptr<net::test_server::HttpResponse> HandleRedirectRequest( 443 scoped_ptr<net::test_server::HttpResponse> HandleRedirectRequest(
444 const std::string& request_path, 444 const std::string& request_path,
445 const net::test_server::HttpRequest& request) { 445 const net::test_server::HttpRequest& request) {
446 if (!StartsWithASCII(request.relative_url, request_path, true)) 446 if (!base::StartsWithASCII(request.relative_url, request_path, true))
447 return scoped_ptr<net::test_server::HttpResponse>(); 447 return scoped_ptr<net::test_server::HttpResponse>();
448 448
449 scoped_ptr<net::test_server::BasicHttpResponse> http_response( 449 scoped_ptr<net::test_server::BasicHttpResponse> http_response(
450 new net::test_server::BasicHttpResponse); 450 new net::test_server::BasicHttpResponse);
451 http_response->set_code(net::HTTP_FOUND); 451 http_response->set_code(net::HTTP_FOUND);
452 http_response->AddCustomHeader( 452 http_response->AddCustomHeader(
453 "Location", request.relative_url.substr(request_path.length())); 453 "Location", request.relative_url.substr(request_path.length()));
454 return http_response.Pass(); 454 return http_response.Pass();
455 } 455 }
456 456
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 NavigateToURLBlockUntilNavigationsComplete( 512 NavigateToURLBlockUntilNavigationsComplete(
513 shell(), 513 shell(),
514 embedded_test_server()->GetURL("/client_redirect.html"), 514 embedded_test_server()->GetURL("/client_redirect.html"),
515 2); 515 2);
516 516
517 EXPECT_TRUE( 517 EXPECT_TRUE(
518 delegate.page_transition() & ui::PAGE_TRANSITION_CLIENT_REDIRECT); 518 delegate.page_transition() & ui::PAGE_TRANSITION_CLIENT_REDIRECT);
519 } 519 }
520 520
521 } // namespace content 521 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698