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/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/browser/net/url_request_failed_dns_job.h" | 12 #include "content/browser/net/url_request_failed_dns_job.h" |
13 #include "content/browser/net/url_request_mock_http_job.h" | 13 #include "content/browser/net/url_request_mock_http_job.h" |
14 #include "content/browser/tab_contents/tab_contents.h" | 14 #include "content/browser/tab_contents/tab_contents.h" |
15 #include "content/test/test_navigation_observer.h" | 15 #include "content/test/test_navigation_observer.h" |
16 | 16 |
17 using content::BrowserThread; | 17 using content::BrowserThread; |
| 18 using content::NavigationController; |
18 | 19 |
19 class ErrorPageTest : public InProcessBrowserTest { | 20 class ErrorPageTest : public InProcessBrowserTest { |
20 public: | 21 public: |
21 enum HistoryNavigationDirection { | 22 enum HistoryNavigationDirection { |
22 HISTORY_NAVIGATE_BACK, | 23 HISTORY_NAVIGATE_BACK, |
23 HISTORY_NAVIGATE_FORWARD, | 24 HISTORY_NAVIGATE_FORWARD, |
24 }; | 25 }; |
25 | 26 |
26 // Navigates the active tab to a mock url created for the file at |file_path|. | 27 // Navigates the active tab to a mock url created for the file at |file_path|. |
27 void NavigateToFileURL(const FilePath::StringType& file_path) { | 28 void NavigateToFileURL(const FilePath::StringType& file_path) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // Navigates the browser the indicated direction in the history and waits for | 75 // Navigates the browser the indicated direction in the history and waits for |
75 // |num_navigations| to occur and the title to change to |expected_title|. | 76 // |num_navigations| to occur and the title to change to |expected_title|. |
76 void NavigateHistoryAndWaitForTitle(const std::string& expected_title, | 77 void NavigateHistoryAndWaitForTitle(const std::string& expected_title, |
77 int num_navigations, | 78 int num_navigations, |
78 HistoryNavigationDirection direction) { | 79 HistoryNavigationDirection direction) { |
79 ui_test_utils::TitleWatcher title_watcher( | 80 ui_test_utils::TitleWatcher title_watcher( |
80 browser()->GetSelectedWebContents(), | 81 browser()->GetSelectedWebContents(), |
81 ASCIIToUTF16(expected_title)); | 82 ASCIIToUTF16(expected_title)); |
82 | 83 |
83 TestNavigationObserver test_navigation_observer( | 84 TestNavigationObserver test_navigation_observer( |
84 content::Source<content::NavigationController>( | 85 content::Source<NavigationController>( |
85 &browser()->GetSelectedTabContentsWrapper()->tab_contents()-> | 86 &browser()->GetSelectedTabContentsWrapper()->tab_contents()-> |
86 GetController()), | 87 GetController()), |
87 NULL, | 88 NULL, |
88 num_navigations); | 89 num_navigations); |
89 if (direction == HISTORY_NAVIGATE_BACK) { | 90 if (direction == HISTORY_NAVIGATE_BACK) { |
90 browser()->GoBack(CURRENT_TAB); | 91 browser()->GoBack(CURRENT_TAB); |
91 } else if (direction == HISTORY_NAVIGATE_FORWARD) { | 92 } else if (direction == HISTORY_NAVIGATE_FORWARD) { |
92 browser()->GoForward(CURRENT_TAB); | 93 browser()->GoForward(CURRENT_TAB); |
93 } else { | 94 } else { |
94 FAIL(); | 95 FAIL(); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 } | 191 } |
191 | 192 |
192 // Checks that the Link Doctor is not loaded when we receive an actual 404 page. | 193 // Checks that the Link Doctor is not loaded when we receive an actual 404 page. |
193 IN_PROC_BROWSER_TEST_F(ErrorPageTest, Page404) { | 194 IN_PROC_BROWSER_TEST_F(ErrorPageTest, Page404) { |
194 NavigateToURLAndWaitForTitle( | 195 NavigateToURLAndWaitForTitle( |
195 URLRequestMockHTTPJob::GetMockUrl( | 196 URLRequestMockHTTPJob::GetMockUrl( |
196 FilePath(FILE_PATH_LITERAL("page404.html"))), | 197 FilePath(FILE_PATH_LITERAL("page404.html"))), |
197 "SUCCESS", | 198 "SUCCESS", |
198 1); | 199 1); |
199 } | 200 } |
OLD | NEW |