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

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

Issue 9704023: Replace URLRequestFailedDnsJob with URLRequestFailedJob (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix includes Created 8 years, 9 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "chrome/browser/net/url_request_mock_util.h" 7 #include "chrome/browser/net/url_request_mock_util.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
10 #include "chrome/test/base/in_process_browser_test.h" 10 #include "chrome/test/base/in_process_browser_test.h"
11 #include "chrome/test/base/ui_test_utils.h" 11 #include "chrome/test/base/ui_test_utils.h"
12 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
13 #include "content/test/net/url_request_failed_dns_job.h" 13 #include "content/test/net/url_request_failed_job.h"
14 #include "content/test/net/url_request_mock_http_job.h" 14 #include "content/test/net/url_request_mock_http_job.h"
15 #include "content/test/test_navigation_observer.h" 15 #include "content/test/test_navigation_observer.h"
16 #include "net/base/net_errors.h"
16 17
17 using content::BrowserThread; 18 using content::BrowserThread;
18 using content::NavigationController; 19 using content::NavigationController;
19 20
20 class ErrorPageTest : public InProcessBrowserTest { 21 class ErrorPageTest : public InProcessBrowserTest {
21 public: 22 public:
22 enum HistoryNavigationDirection { 23 enum HistoryNavigationDirection {
23 HISTORY_NAVIGATE_BACK, 24 HISTORY_NAVIGATE_BACK,
24 HISTORY_NAVIGATE_FORWARD, 25 HISTORY_NAVIGATE_FORWARD,
25 }; 26 };
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 HISTORY_NAVIGATE_FORWARD); 65 HISTORY_NAVIGATE_FORWARD);
65 } 66 }
66 67
67 protected: 68 protected:
68 void SetUpOnMainThread() OVERRIDE { 69 void SetUpOnMainThread() OVERRIDE {
69 BrowserThread::PostTask( 70 BrowserThread::PostTask(
70 BrowserThread::IO, FROM_HERE, 71 BrowserThread::IO, FROM_HERE,
71 base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true)); 72 base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true));
72 } 73 }
73 74
75 // Returns a GURL that results in a DNS error.
76 GURL GetDnsErrorURL() {
willchan no longer on Chromium 2012/03/15 22:42:28 Make the function const?
mmenke 2012/03/15 22:55:46 Done.
77 return URLRequestFailedJob::GetMockHttpUrl(net::ERR_NAME_NOT_RESOLVED);
78 }
79
74 private: 80 private:
75 // Navigates the browser the indicated direction in the history and waits for 81 // Navigates the browser the indicated direction in the history and waits for
76 // |num_navigations| to occur and the title to change to |expected_title|. 82 // |num_navigations| to occur and the title to change to |expected_title|.
77 void NavigateHistoryAndWaitForTitle(const std::string& expected_title, 83 void NavigateHistoryAndWaitForTitle(const std::string& expected_title,
78 int num_navigations, 84 int num_navigations,
79 HistoryNavigationDirection direction) { 85 HistoryNavigationDirection direction) {
80 ui_test_utils::TitleWatcher title_watcher( 86 ui_test_utils::TitleWatcher title_watcher(
81 browser()->GetSelectedWebContents(), 87 browser()->GetSelectedWebContents(),
82 ASCIIToUTF16(expected_title)); 88 ASCIIToUTF16(expected_title));
83 89
(...skipping 20 matching lines...) Expand all
104 }; 110 };
105 111
106 // See crbug.com/109669 112 // See crbug.com/109669
107 #if defined(USE_AURA) 113 #if defined(USE_AURA)
108 #define MAYBE_DNSError_Basic DISABLED_DNSError_Basic 114 #define MAYBE_DNSError_Basic DISABLED_DNSError_Basic
109 #else 115 #else
110 #define MAYBE_DNSError_Basic DNSError_Basic 116 #define MAYBE_DNSError_Basic DNSError_Basic
111 #endif 117 #endif
112 // Test that a DNS error occuring in the main frame redirects to an error page. 118 // Test that a DNS error occuring in the main frame redirects to an error page.
113 IN_PROC_BROWSER_TEST_F(ErrorPageTest, MAYBE_DNSError_Basic) { 119 IN_PROC_BROWSER_TEST_F(ErrorPageTest, MAYBE_DNSError_Basic) {
114 GURL test_url(URLRequestFailedDnsJob::kTestUrl);
115 // The first navigation should fail, and the second one should be the error 120 // The first navigation should fail, and the second one should be the error
116 // page. 121 // page.
117 NavigateToURLAndWaitForTitle(test_url, "Mock Link Doctor", 2); 122 NavigateToURLAndWaitForTitle(GetDnsErrorURL(), "Mock Link Doctor", 2);
118 } 123 }
119 124
120 // Test that a DNS error occuring in the main frame does not result in an 125 // Test that a DNS error occuring in the main frame does not result in an
121 // additional session history entry. 126 // additional session history entry.
122 IN_PROC_BROWSER_TEST_F(ErrorPageTest, DNSError_GoBack1) { 127 IN_PROC_BROWSER_TEST_F(ErrorPageTest, DNSError_GoBack1) {
123 GURL test_url(URLRequestFailedDnsJob::kTestUrl);
124 NavigateToFileURL(FILE_PATH_LITERAL("title2.html")); 128 NavigateToFileURL(FILE_PATH_LITERAL("title2.html"));
125 NavigateToURLAndWaitForTitle(test_url, "Mock Link Doctor", 2); 129 NavigateToURLAndWaitForTitle(GetDnsErrorURL(), "Mock Link Doctor", 2);
126 GoBackAndWaitForTitle("Title Of Awesomeness", 1); 130 GoBackAndWaitForTitle("Title Of Awesomeness", 1);
127 } 131 }
128 132
129 // See crbug.com/109669 133 // See crbug.com/109669
130 #if defined(USE_AURA) 134 #if defined(USE_AURA)
131 #define MAYBE_DNSError_GoBack2 DISABLED_DNSError_GoBack2 135 #define MAYBE_DNSError_GoBack2 DISABLED_DNSError_GoBack2
132 #else 136 #else
133 #define MAYBE_DNSError_GoBack2 DNSError_GoBack2 137 #define MAYBE_DNSError_GoBack2 DNSError_GoBack2
134 #endif 138 #endif
135 // Test that a DNS error occuring in the main frame does not result in an 139 // Test that a DNS error occuring in the main frame does not result in an
136 // additional session history entry. 140 // additional session history entry.
137 IN_PROC_BROWSER_TEST_F(ErrorPageTest, MAYBE_DNSError_GoBack2) { 141 IN_PROC_BROWSER_TEST_F(ErrorPageTest, MAYBE_DNSError_GoBack2) {
138 GURL test_url(URLRequestFailedDnsJob::kTestUrl);
139 NavigateToFileURL(FILE_PATH_LITERAL("title2.html")); 142 NavigateToFileURL(FILE_PATH_LITERAL("title2.html"));
140 143
141 NavigateToURLAndWaitForTitle(test_url, "Mock Link Doctor", 2); 144 NavigateToURLAndWaitForTitle(GetDnsErrorURL(), "Mock Link Doctor", 2);
142 NavigateToFileURL(FILE_PATH_LITERAL("title3.html")); 145 NavigateToFileURL(FILE_PATH_LITERAL("title3.html"));
143 146
144 GoBackAndWaitForTitle("Mock Link Doctor", 2); 147 GoBackAndWaitForTitle("Mock Link Doctor", 2);
145 GoBackAndWaitForTitle("Title Of Awesomeness", 1); 148 GoBackAndWaitForTitle("Title Of Awesomeness", 1);
146 } 149 }
147 150
148 // See crbug.com/109669 151 // See crbug.com/109669
149 #if defined(USE_AURA) 152 #if defined(USE_AURA)
150 #define MAYBE_DNSError_GoBack2AndForward DISABLED_DNSError_GoBack2AndForward 153 #define MAYBE_DNSError_GoBack2AndForward DISABLED_DNSError_GoBack2AndForward
151 #else 154 #else
152 #define MAYBE_DNSError_GoBack2AndForward DNSError_GoBack2AndForward 155 #define MAYBE_DNSError_GoBack2AndForward DNSError_GoBack2AndForward
153 #endif 156 #endif
154 // Test that a DNS error occuring in the main frame does not result in an 157 // Test that a DNS error occuring in the main frame does not result in an
155 // additional session history entry. 158 // additional session history entry.
156 IN_PROC_BROWSER_TEST_F(ErrorPageTest, MAYBE_DNSError_GoBack2AndForward) { 159 IN_PROC_BROWSER_TEST_F(ErrorPageTest, MAYBE_DNSError_GoBack2AndForward) {
157 GURL test_url(URLRequestFailedDnsJob::kTestUrl);
158 NavigateToFileURL(FILE_PATH_LITERAL("title2.html")); 160 NavigateToFileURL(FILE_PATH_LITERAL("title2.html"));
159 161
160 NavigateToURLAndWaitForTitle(test_url, "Mock Link Doctor", 2); 162 NavigateToURLAndWaitForTitle(GetDnsErrorURL(), "Mock Link Doctor", 2);
161 NavigateToFileURL(FILE_PATH_LITERAL("title3.html")); 163 NavigateToFileURL(FILE_PATH_LITERAL("title3.html"));
162 164
163 GoBackAndWaitForTitle("Mock Link Doctor", 2); 165 GoBackAndWaitForTitle("Mock Link Doctor", 2);
164 GoBackAndWaitForTitle("Title Of Awesomeness", 1); 166 GoBackAndWaitForTitle("Title Of Awesomeness", 1);
165 167
166 GoForwardAndWaitForTitle("Mock Link Doctor", 2); 168 GoForwardAndWaitForTitle("Mock Link Doctor", 2);
167 } 169 }
168 170
169 // See crbug.com/109669 171 // See crbug.com/109669
170 #if defined(USE_AURA) 172 #if defined(USE_AURA)
171 #define MAYBE_DNSError_GoBack2Forward2 DISABLED_DNSError_GoBack2Forward2 173 #define MAYBE_DNSError_GoBack2Forward2 DISABLED_DNSError_GoBack2Forward2
172 #else 174 #else
173 #define MAYBE_DNSError_GoBack2Forward2 DNSError_GoBack2Forward2 175 #define MAYBE_DNSError_GoBack2Forward2 DNSError_GoBack2Forward2
174 #endif 176 #endif
175 // Test that a DNS error occuring in the main frame does not result in an 177 // Test that a DNS error occuring in the main frame does not result in an
176 // additional session history entry. 178 // additional session history entry.
177 IN_PROC_BROWSER_TEST_F(ErrorPageTest, MAYBE_DNSError_GoBack2Forward2) { 179 IN_PROC_BROWSER_TEST_F(ErrorPageTest, MAYBE_DNSError_GoBack2Forward2) {
178 GURL test_url(URLRequestFailedDnsJob::kTestUrl);
179 NavigateToFileURL(FILE_PATH_LITERAL("title3.html")); 180 NavigateToFileURL(FILE_PATH_LITERAL("title3.html"));
180 181
181 NavigateToURLAndWaitForTitle(test_url, "Mock Link Doctor", 2); 182 NavigateToURLAndWaitForTitle(GetDnsErrorURL(), "Mock Link Doctor", 2);
182 NavigateToFileURL(FILE_PATH_LITERAL("title2.html")); 183 NavigateToFileURL(FILE_PATH_LITERAL("title2.html"));
183 184
184 GoBackAndWaitForTitle("Mock Link Doctor", 2); 185 GoBackAndWaitForTitle("Mock Link Doctor", 2);
185 GoBackAndWaitForTitle("Title Of More Awesomeness", 1); 186 GoBackAndWaitForTitle("Title Of More Awesomeness", 1);
186 187
187 GoForwardAndWaitForTitle("Mock Link Doctor", 2); 188 GoForwardAndWaitForTitle("Mock Link Doctor", 2);
188 GoForwardAndWaitForTitle("Title Of Awesomeness", 1); 189 GoForwardAndWaitForTitle("Title Of Awesomeness", 1);
189 } 190 }
190 191
191 // Test that a DNS error occuring in an iframe. 192 // Test that a DNS error occuring in an iframe.
(...skipping 23 matching lines...) Expand all
215 } 216 }
216 217
217 // Checks that the Link Doctor is not loaded when we receive an actual 404 page. 218 // Checks that the Link Doctor is not loaded when we receive an actual 404 page.
218 IN_PROC_BROWSER_TEST_F(ErrorPageTest, Page404) { 219 IN_PROC_BROWSER_TEST_F(ErrorPageTest, Page404) {
219 NavigateToURLAndWaitForTitle( 220 NavigateToURLAndWaitForTitle(
220 URLRequestMockHTTPJob::GetMockUrl( 221 URLRequestMockHTTPJob::GetMockUrl(
221 FilePath(FILE_PATH_LITERAL("page404.html"))), 222 FilePath(FILE_PATH_LITERAL("page404.html"))),
222 "SUCCESS", 223 "SUCCESS",
223 1); 224 1);
224 } 225 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/net/url_request_mock_util.cc » ('j') | chrome/test/data/iframe_dns_error.html » ('J')

Powered by Google App Engine
This is Rietveld 408576698