OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "chrome/browser/net/url_request_mock_util.h" |
6 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
7 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
8 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
9 #include "chrome/test/base/ui_test_utils.h" | 11 #include "chrome/test/base/ui_test_utils.h" |
10 #include "chrome/test/test_navigation_observer.h" | 12 #include "chrome/test/test_navigation_observer.h" |
11 #include "content/browser/net/url_request_failed_dns_job.h" | 13 #include "content/browser/net/url_request_failed_dns_job.h" |
12 #include "content/browser/net/url_request_mock_http_job.h" | 14 #include "content/browser/net/url_request_mock_http_job.h" |
13 | 15 |
14 class ErrorPageTest : public InProcessBrowserTest { | 16 class ErrorPageTest : public InProcessBrowserTest { |
15 public: | 17 public: |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 53 |
52 // Navigates forward in the history and waits for |num_navigations| to occur, | 54 // Navigates forward in the history and waits for |num_navigations| to occur, |
53 // and the title to change to |expected_title|. | 55 // and the title to change to |expected_title|. |
54 void GoForwardAndWaitForTitle(const std::string& expected_title, | 56 void GoForwardAndWaitForTitle(const std::string& expected_title, |
55 int num_navigations) { | 57 int num_navigations) { |
56 NavigateHistoryAndWaitForTitle(expected_title, | 58 NavigateHistoryAndWaitForTitle(expected_title, |
57 num_navigations, | 59 num_navigations, |
58 HISTORY_NAVIGATE_FORWARD); | 60 HISTORY_NAVIGATE_FORWARD); |
59 } | 61 } |
60 | 62 |
| 63 protected: |
| 64 void SetUpOnMainThread() OVERRIDE { |
| 65 BrowserThread::PostTask( |
| 66 BrowserThread::IO, FROM_HERE, |
| 67 base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true)); |
| 68 } |
| 69 |
61 private: | 70 private: |
62 // Navigates the browser the indicated direction in the history and waits for | 71 // Navigates the browser the indicated direction in the history and waits for |
63 // |num_navigations| to occur and the title to change to |expected_title|. | 72 // |num_navigations| to occur and the title to change to |expected_title|. |
64 void NavigateHistoryAndWaitForTitle(const std::string& expected_title, | 73 void NavigateHistoryAndWaitForTitle(const std::string& expected_title, |
65 int num_navigations, | 74 int num_navigations, |
66 HistoryNavigationDirection direction) { | 75 HistoryNavigationDirection direction) { |
67 ui_test_utils::TitleWatcher title_watcher( | 76 ui_test_utils::TitleWatcher title_watcher( |
68 browser()->GetSelectedTabContents(), | 77 browser()->GetSelectedTabContents(), |
69 ASCIIToUTF16(expected_title)); | 78 ASCIIToUTF16(expected_title)); |
70 | 79 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 } | 183 } |
175 | 184 |
176 // Checks that the Link Doctor is not loaded when we receive an actual 404 page. | 185 // Checks that the Link Doctor is not loaded when we receive an actual 404 page. |
177 IN_PROC_BROWSER_TEST_F(ErrorPageTest, Page404) { | 186 IN_PROC_BROWSER_TEST_F(ErrorPageTest, Page404) { |
178 NavigateToURLAndWaitForTitle( | 187 NavigateToURLAndWaitForTitle( |
179 URLRequestMockHTTPJob::GetMockUrl( | 188 URLRequestMockHTTPJob::GetMockUrl( |
180 FilePath(FILE_PATH_LITERAL("page404.html"))), | 189 FilePath(FILE_PATH_LITERAL("page404.html"))), |
181 "SUCCESS", | 190 "SUCCESS", |
182 1); | 191 1); |
183 } | 192 } |
OLD | NEW |