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

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

Issue 567563002: Move url_request_failed_job to net/test/url_request/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile error Created 6 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 | « chrome/browser/policy/policy_browsertest.cc ('k') | content/content_tests.gypi » ('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 "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"
11 #include "content/public/browser/browser_context.h" 11 #include "content/public/browser/browser_context.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 #include "content/public/common/url_constants.h" 14 #include "content/public/common/url_constants.h"
15 #include "content/public/test/browser_test_utils.h" 15 #include "content/public/test/browser_test_utils.h"
16 #include "content/public/test/content_browser_test.h" 16 #include "content/public/test/content_browser_test.h"
17 #include "content/public/test/content_browser_test_utils.h" 17 #include "content/public/test/content_browser_test_utils.h"
18 #include "content/public/test/test_utils.h" 18 #include "content/public/test/test_utils.h"
19 #include "content/shell/browser/shell.h" 19 #include "content/shell/browser/shell.h"
20 #include "content/shell/browser/shell_content_browser_client.h" 20 #include "content/shell/browser/shell_content_browser_client.h"
21 #include "content/shell/browser/shell_network_delegate.h" 21 #include "content/shell/browser/shell_network_delegate.h"
22 #include "content/test/net/url_request_failed_job.h"
23 #include "net/base/net_errors.h" 22 #include "net/base/net_errors.h"
24 #include "net/test/embedded_test_server/embedded_test_server.h" 23 #include "net/test/embedded_test_server/embedded_test_server.h"
25 #include "net/test/embedded_test_server/http_request.h" 24 #include "net/test/embedded_test_server/http_request.h"
26 #include "net/test/embedded_test_server/http_response.h" 25 #include "net/test/embedded_test_server/http_response.h"
26 #include "net/test/url_request/url_request_failed_job.h"
27 #include "net/test/url_request/url_request_mock_http_job.h" 27 #include "net/test/url_request/url_request_mock_http_job.h"
28 28
29 using base::ASCIIToUTF16; 29 using base::ASCIIToUTF16;
30 30
31 namespace content { 31 namespace content {
32 32
33 class ResourceDispatcherHostBrowserTest : public ContentBrowserTest, 33 class ResourceDispatcherHostBrowserTest : public ContentBrowserTest,
34 public DownloadManager::Observer { 34 public DownloadManager::Observer {
35 public: 35 public:
36 ResourceDispatcherHostBrowserTest() : got_downloads_(false) {} 36 ResourceDispatcherHostBrowserTest() : got_downloads_(false) {}
37 37
38 protected: 38 protected:
39 virtual void SetUpOnMainThread() OVERRIDE { 39 virtual void SetUpOnMainThread() OVERRIDE {
40 base::FilePath path = GetTestFilePath("", ""); 40 base::FilePath path = GetTestFilePath("", "");
41 BrowserThread::PostTask( 41 BrowserThread::PostTask(
42 BrowserThread::IO, 42 BrowserThread::IO,
43 FROM_HERE, 43 FROM_HERE,
44 base::Bind( 44 base::Bind(
45 &net::URLRequestMockHTTPJob::AddUrlHandler, 45 &net::URLRequestMockHTTPJob::AddUrlHandler,
46 path, 46 path,
47 make_scoped_refptr(content::BrowserThread::GetBlockingPool()))); 47 make_scoped_refptr(content::BrowserThread::GetBlockingPool())));
48 BrowserThread::PostTask( 48 BrowserThread::PostTask(
49 BrowserThread::IO, FROM_HERE, 49 BrowserThread::IO, FROM_HERE,
50 base::Bind(&URLRequestFailedJob::AddUrlHandler)); 50 base::Bind(&net::URLRequestFailedJob::AddUrlHandler));
51 } 51 }
52 52
53 virtual void OnDownloadCreated( 53 virtual void OnDownloadCreated(
54 DownloadManager* manager, 54 DownloadManager* manager,
55 DownloadItem* item) OVERRIDE { 55 DownloadItem* item) OVERRIDE {
56 if (!got_downloads_) 56 if (!got_downloads_)
57 got_downloads_ = !!manager->InProgressCount(); 57 got_downloads_ = !!manager->InProgressCount();
58 } 58 }
59 59
60 GURL GetMockURL(const std::string& file) { 60 GURL GetMockURL(const std::string& file) {
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 CrossSiteNavigationErrorPage) { 346 CrossSiteNavigationErrorPage) {
347 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 347 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
348 348
349 GURL url(embedded_test_server()->GetURL("/onunload_cookie.html")); 349 GURL url(embedded_test_server()->GetURL("/onunload_cookie.html"));
350 CheckTitleTest(url, "set cookie on unload"); 350 CheckTitleTest(url, "set cookie on unload");
351 351
352 // Navigate to a new cross-site URL that results in an error. 352 // Navigate to a new cross-site URL that results in an error.
353 // TODO(creis): If this causes crashes or hangs, it might be for the same 353 // TODO(creis): If this causes crashes or hangs, it might be for the same
354 // reason as ErrorPageTest::DNSError. See bug 1199491 and 354 // reason as ErrorPageTest::DNSError. See bug 1199491 and
355 // http://crbug.com/22877. 355 // http://crbug.com/22877.
356 GURL failed_url = URLRequestFailedJob::GetMockHttpUrl( 356 GURL failed_url = net::URLRequestFailedJob::GetMockHttpUrl(
357 net::ERR_NAME_NOT_RESOLVED); 357 net::ERR_NAME_NOT_RESOLVED);
358 NavigateToURL(shell(), failed_url); 358 NavigateToURL(shell(), failed_url);
359 359
360 EXPECT_NE(ASCIIToUTF16("set cookie on unload"), 360 EXPECT_NE(ASCIIToUTF16("set cookie on unload"),
361 shell()->web_contents()->GetTitle()); 361 shell()->web_contents()->GetTitle());
362 362
363 // Check that the cookie was set, meaning that the onunload handler ran. 363 // Check that the cookie was set, meaning that the onunload handler ran.
364 EXPECT_EQ("onunloadCookie=foo", GetCookies(url)); 364 EXPECT_EQ("onunloadCookie=foo", GetCookies(url));
365 365
366 // Check that renderer-initiated navigations still work. In a previous bug, 366 // Check that renderer-initiated navigations still work. In a previous bug,
(...skipping 24 matching lines...) Expand all
391 CrossSiteNavigationErrorPage2) { 391 CrossSiteNavigationErrorPage2) {
392 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 392 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
393 393
394 GURL url(embedded_test_server()->GetURL("/title2.html")); 394 GURL url(embedded_test_server()->GetURL("/title2.html"));
395 CheckTitleTest(url, "Title Of Awesomeness"); 395 CheckTitleTest(url, "Title Of Awesomeness");
396 396
397 // Navigate to a new cross-site URL that results in an error. 397 // Navigate to a new cross-site URL that results in an error.
398 // TODO(creis): If this causes crashes or hangs, it might be for the same 398 // TODO(creis): If this causes crashes or hangs, it might be for the same
399 // reason as ErrorPageTest::DNSError. See bug 1199491 and 399 // reason as ErrorPageTest::DNSError. See bug 1199491 and
400 // http://crbug.com/22877. 400 // http://crbug.com/22877.
401 GURL failed_url = URLRequestFailedJob::GetMockHttpUrl( 401 GURL failed_url = net::URLRequestFailedJob::GetMockHttpUrl(
402 net::ERR_NAME_NOT_RESOLVED); 402 net::ERR_NAME_NOT_RESOLVED);
403 403
404 NavigateToURL(shell(), failed_url); 404 NavigateToURL(shell(), failed_url);
405 EXPECT_NE(ASCIIToUTF16("Title Of Awesomeness"), 405 EXPECT_NE(ASCIIToUTF16("Title Of Awesomeness"),
406 shell()->web_contents()->GetTitle()); 406 shell()->web_contents()->GetTitle());
407 407
408 // Repeat navigation. We are testing that this completes. 408 // Repeat navigation. We are testing that this completes.
409 NavigateToURL(shell(), failed_url); 409 NavigateToURL(shell(), failed_url);
410 EXPECT_NE(ASCIIToUTF16("Title Of Awesomeness"), 410 EXPECT_NE(ASCIIToUTF16("Title Of Awesomeness"),
411 shell()->web_contents()->GetTitle()); 411 shell()->web_contents()->GetTitle());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 "http://localhost:%d/set_cookie.html", embedded_test_server()->port())); 466 "http://localhost:%d/set_cookie.html", embedded_test_server()->port()));
467 GURL url(embedded_test_server()->GetURL("/redirect?" + set_cookie_url)); 467 GURL url(embedded_test_server()->GetURL("/redirect?" + set_cookie_url));
468 468
469 ShellContentBrowserClient::SetSwapProcessesForRedirect(true); 469 ShellContentBrowserClient::SetSwapProcessesForRedirect(true);
470 ShellNetworkDelegate::SetAcceptAllCookies(false); 470 ShellNetworkDelegate::SetAcceptAllCookies(false);
471 471
472 CheckTitleTest(url, "cookie set"); 472 CheckTitleTest(url, "cookie set");
473 } 473 }
474 474
475 } // namespace content 475 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/policy/policy_browsertest.cc ('k') | content/content_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698