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

Side by Side Diff: chrome/browser/errorpage_browsertest.cc

Issue 1409163006: Migrating tests to use EmbeddedTestServer (/chrome/browser misc) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix rebase bug. Created 5 years, 1 month 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/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 26 matching lines...) Expand all
37 #include "content/public/browser/render_view_host.h" 37 #include "content/public/browser/render_view_host.h"
38 #include "content/public/browser/web_contents.h" 38 #include "content/public/browser/web_contents.h"
39 #include "content/public/browser/web_contents_observer.h" 39 #include "content/public/browser/web_contents_observer.h"
40 #include "content/public/test/browser_test_utils.h" 40 #include "content/public/test/browser_test_utils.h"
41 #include "content/public/test/test_navigation_observer.h" 41 #include "content/public/test/test_navigation_observer.h"
42 #include "net/base/filename_util.h" 42 #include "net/base/filename_util.h"
43 #include "net/base/net_errors.h" 43 #include "net/base/net_errors.h"
44 #include "net/base/net_util.h" 44 #include "net/base/net_util.h"
45 #include "net/http/failing_http_transaction_factory.h" 45 #include "net/http/failing_http_transaction_factory.h"
46 #include "net/http/http_cache.h" 46 #include "net/http/http_cache.h"
47 #include "net/test/spawned_test_server/spawned_test_server.h" 47 #include "net/test/embedded_test_server/embedded_test_server.h"
48 #include "net/test/url_request/url_request_failed_job.h" 48 #include "net/test/url_request/url_request_failed_job.h"
49 #include "net/test/url_request/url_request_mock_http_job.h" 49 #include "net/test/url_request/url_request_mock_http_job.h"
50 #include "net/url_request/url_request_context.h" 50 #include "net/url_request/url_request_context.h"
51 #include "net/url_request/url_request_context_getter.h" 51 #include "net/url_request/url_request_context_getter.h"
52 #include "net/url_request/url_request_filter.h" 52 #include "net/url_request/url_request_filter.h"
53 #include "net/url_request/url_request_interceptor.h" 53 #include "net/url_request/url_request_interceptor.h"
54 #include "net/url_request/url_request_job.h" 54 #include "net/url_request/url_request_job.h"
55 #include "net/url_request/url_request_test_job.h" 55 #include "net/url_request/url_request_test_job.h"
56 #include "net/url_request/url_request_test_util.h" 56 #include "net/url_request/url_request_test_util.h"
57 #include "policy/policy_constants.h" 57 #include "policy/policy_constants.h"
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 IN_PROC_BROWSER_TEST_F(ErrorPageTest, Page404) { 895 IN_PROC_BROWSER_TEST_F(ErrorPageTest, Page404) {
896 NavigateToURLAndWaitForTitle( 896 NavigateToURLAndWaitForTitle(
897 net::URLRequestMockHTTPJob::GetMockUrl("page404.html"), "SUCCESS", 1); 897 net::URLRequestMockHTTPJob::GetMockUrl("page404.html"), "SUCCESS", 1);
898 EXPECT_EQ(0, link_doctor_interceptor()->num_requests()); 898 EXPECT_EQ(0, link_doctor_interceptor()->num_requests());
899 } 899 }
900 900
901 // Checks that when an error occurs, the stale cache status of the page 901 // Checks that when an error occurs, the stale cache status of the page
902 // is correctly transferred, and that stale cached copied can be loaded 902 // is correctly transferred, and that stale cached copied can be loaded
903 // from the javascript. 903 // from the javascript.
904 IN_PROC_BROWSER_TEST_F(ErrorPageTest, StaleCacheStatus) { 904 IN_PROC_BROWSER_TEST_F(ErrorPageTest, StaleCacheStatus) {
905 ASSERT_TRUE(test_server()->Start()); 905 ASSERT_TRUE(embedded_test_server()->Start());
906 // Load cache with entry with "nocache" set, to create stale 906 // Load cache with entry with "nocache" set, to create stale
907 // cache. 907 // cache.
908 GURL test_url(test_server()->GetURL("files/nocache.html")); 908 GURL test_url(embedded_test_server()->GetURL("/nocache.html"));
909 NavigateToURLAndWaitForTitle(test_url, "Nocache Test Page", 1); 909 NavigateToURLAndWaitForTitle(test_url, "Nocache Test Page", 1);
910 910
911 // Reload same URL after forcing an error from the the network layer; 911 // Reload same URL after forcing an error from the the network layer;
912 // confirm that the error page is told the cached copy exists. 912 // confirm that the error page is told the cached copy exists.
913 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter = 913 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter =
914 browser()->profile()->GetRequestContext(); 914 browser()->profile()->GetRequestContext();
915 BrowserThread::PostTask( 915 BrowserThread::PostTask(
916 BrowserThread::IO, FROM_HERE, 916 BrowserThread::IO, FROM_HERE,
917 base::Bind(&InterceptNetworkTransactions, url_request_context_getter, 917 base::Bind(&InterceptNetworkTransactions, url_request_context_getter,
918 net::ERR_FAILED)); 918 net::ERR_FAILED));
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 EXPECT_EQ(PlatformSupportsDiagnosticsTool(), 1138 EXPECT_EQ(PlatformSupportsDiagnosticsTool(),
1139 IsDisplayingDiagnosticsButton(browser())); 1139 IsDisplayingDiagnosticsButton(browser()));
1140 } 1140 }
1141 1141
1142 // Checks that when an error occurs and a corrections fail to load, the stale 1142 // Checks that when an error occurs and a corrections fail to load, the stale
1143 // cache status of the page is correctly transferred, and we can load the 1143 // cache status of the page is correctly transferred, and we can load the
1144 // stale copy from the javascript. Most logic copied from StaleCacheStatus 1144 // stale copy from the javascript. Most logic copied from StaleCacheStatus
1145 // above. 1145 // above.
1146 IN_PROC_BROWSER_TEST_F(ErrorPageNavigationCorrectionsFailTest, 1146 IN_PROC_BROWSER_TEST_F(ErrorPageNavigationCorrectionsFailTest,
1147 StaleCacheStatusFailedCorrections) { 1147 StaleCacheStatusFailedCorrections) {
1148 ASSERT_TRUE(test_server()->Start()); 1148 ASSERT_TRUE(embedded_test_server()->Start());
1149 // Load cache with entry with "nocache" set, to create stale 1149 // Load cache with entry with "nocache" set, to create stale
1150 // cache. 1150 // cache.
1151 GURL test_url(test_server()->GetURL("files/nocache.html")); 1151 GURL test_url(embedded_test_server()->GetURL("/nocache.html"));
1152 NavigateToURLAndWaitForTitle(test_url, "Nocache Test Page", 1); 1152 NavigateToURLAndWaitForTitle(test_url, "Nocache Test Page", 1);
1153 1153
1154 // Reload same URL after forcing an error from the the network layer; 1154 // Reload same URL after forcing an error from the the network layer;
1155 // confirm that the error page is told the cached copy exists. 1155 // confirm that the error page is told the cached copy exists.
1156 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter = 1156 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter =
1157 browser()->profile()->GetRequestContext(); 1157 browser()->profile()->GetRequestContext();
1158 BrowserThread::PostTask( 1158 BrowserThread::PostTask(
1159 BrowserThread::IO, FROM_HERE, 1159 BrowserThread::IO, FROM_HERE,
1160 base::Bind(&InterceptNetworkTransactions, url_request_context_getter, 1160 base::Bind(&InterceptNetworkTransactions, url_request_context_getter,
1161 net::ERR_CONNECTION_FAILED)); 1161 net::ERR_CONNECTION_FAILED));
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 ui_test_utils::NavigateToURL( 1386 ui_test_utils::NavigateToURL(
1387 browser(), 1387 browser(),
1388 URLRequestFailedJob::GetMockHttpUrlForHostname(net::ERR_UNSAFE_PORT, 1388 URLRequestFailedJob::GetMockHttpUrlForHostname(net::ERR_UNSAFE_PORT,
1389 kHostname)); 1389 kHostname));
1390 1390
1391 ToggleHelpBox(browser()); 1391 ToggleHelpBox(browser());
1392 EXPECT_TRUE(IsDisplayingText(browser(), kHostnameJSUnicode)); 1392 EXPECT_TRUE(IsDisplayingText(browser(), kHostnameJSUnicode));
1393 } 1393 }
1394 1394
1395 } // namespace 1395 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698