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

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

Issue 10702029: Move tab functions off Browser into browser_tabstrip and browser_tabrestore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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/browser_commands.h" 9 #include "chrome/browser/ui/browser_commands.h"
10 #include "chrome/browser/ui/browser_tabstrip.h"
10 #include "chrome/browser/ui/tab_contents/tab_contents.h" 11 #include "chrome/browser/ui/tab_contents/tab_contents.h"
11 #include "chrome/test/base/in_process_browser_test.h" 12 #include "chrome/test/base/in_process_browser_test.h"
12 #include "chrome/test/base/ui_test_utils.h" 13 #include "chrome/test/base/ui_test_utils.h"
13 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
14 #include "content/public/test/test_navigation_observer.h" 15 #include "content/public/test/test_navigation_observer.h"
15 #include "content/test/net/url_request_failed_job.h" 16 #include "content/test/net/url_request_failed_job.h"
16 #include "content/test/net/url_request_mock_http_job.h" 17 #include "content/test/net/url_request_mock_http_job.h"
17 #include "net/base/net_errors.h" 18 #include "net/base/net_errors.h"
18 19
19 using content::BrowserThread; 20 using content::BrowserThread;
(...skipping 12 matching lines...) Expand all
32 browser(), 33 browser(),
33 URLRequestMockHTTPJob::GetMockUrl(FilePath(file_path))); 34 URLRequestMockHTTPJob::GetMockUrl(FilePath(file_path)));
34 } 35 }
35 36
36 // Navigates to the given URL and waits for |num_navigations| to occur, and 37 // Navigates to the given URL and waits for |num_navigations| to occur, and
37 // the title to change to |expected_title|. 38 // the title to change to |expected_title|.
38 void NavigateToURLAndWaitForTitle(const GURL& url, 39 void NavigateToURLAndWaitForTitle(const GURL& url,
39 const std::string& expected_title, 40 const std::string& expected_title,
40 int num_navigations) { 41 int num_navigations) {
41 ui_test_utils::TitleWatcher title_watcher( 42 ui_test_utils::TitleWatcher title_watcher(
42 browser()->GetActiveWebContents(), 43 chrome::GetActiveWebContents(browser()),
43 ASCIIToUTF16(expected_title)); 44 ASCIIToUTF16(expected_title));
44 45
45 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( 46 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
46 browser(), url, num_navigations); 47 browser(), url, num_navigations);
47 48
48 EXPECT_EQ(title_watcher.WaitAndGetTitle(), ASCIIToUTF16(expected_title)); 49 EXPECT_EQ(title_watcher.WaitAndGetTitle(), ASCIIToUTF16(expected_title));
49 } 50 }
50 51
51 // Navigates back in the history and waits for |num_navigations| to occur, and 52 // Navigates back in the history and waits for |num_navigations| to occur, and
52 // the title to change to |expected_title|. 53 // the title to change to |expected_title|.
(...skipping 25 matching lines...) Expand all
78 return URLRequestFailedJob::GetMockHttpUrl(net::ERR_NAME_NOT_RESOLVED); 79 return URLRequestFailedJob::GetMockHttpUrl(net::ERR_NAME_NOT_RESOLVED);
79 } 80 }
80 81
81 private: 82 private:
82 // Navigates the browser the indicated direction in the history and waits for 83 // Navigates the browser the indicated direction in the history and waits for
83 // |num_navigations| to occur and the title to change to |expected_title|. 84 // |num_navigations| to occur and the title to change to |expected_title|.
84 void NavigateHistoryAndWaitForTitle(const std::string& expected_title, 85 void NavigateHistoryAndWaitForTitle(const std::string& expected_title,
85 int num_navigations, 86 int num_navigations,
86 HistoryNavigationDirection direction) { 87 HistoryNavigationDirection direction) {
87 ui_test_utils::TitleWatcher title_watcher( 88 ui_test_utils::TitleWatcher title_watcher(
88 browser()->GetActiveWebContents(), 89 chrome::GetActiveWebContents(browser()),
89 ASCIIToUTF16(expected_title)); 90 ASCIIToUTF16(expected_title));
90 91
91 content::TestNavigationObserver test_navigation_observer( 92 content::TestNavigationObserver test_navigation_observer(
92 content::Source<NavigationController>( 93 content::Source<NavigationController>(
93 &browser()->GetActiveWebContents()->GetController()), 94 &chrome::GetActiveWebContents(browser())->GetController()),
94 NULL, 95 NULL,
95 num_navigations); 96 num_navigations);
96 if (direction == HISTORY_NAVIGATE_BACK) { 97 if (direction == HISTORY_NAVIGATE_BACK) {
97 chrome::GoBack(browser(), CURRENT_TAB); 98 chrome::GoBack(browser(), CURRENT_TAB);
98 } else if (direction == HISTORY_NAVIGATE_FORWARD) { 99 } else if (direction == HISTORY_NAVIGATE_FORWARD) {
99 chrome::GoForward(browser(), CURRENT_TAB); 100 chrome::GoForward(browser(), CURRENT_TAB);
100 } else { 101 } else {
101 FAIL(); 102 FAIL();
102 } 103 }
103 test_navigation_observer.WaitForObservation( 104 test_navigation_observer.WaitForObservation(
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 229 }
229 230
230 // Checks that the Link Doctor is not loaded when we receive an actual 404 page. 231 // Checks that the Link Doctor is not loaded when we receive an actual 404 page.
231 IN_PROC_BROWSER_TEST_F(ErrorPageTest, Page404) { 232 IN_PROC_BROWSER_TEST_F(ErrorPageTest, Page404) {
232 NavigateToURLAndWaitForTitle( 233 NavigateToURLAndWaitForTitle(
233 URLRequestMockHTTPJob::GetMockUrl( 234 URLRequestMockHTTPJob::GetMockUrl(
234 FilePath(FILE_PATH_LITERAL("page404.html"))), 235 FilePath(FILE_PATH_LITERAL("page404.html"))),
235 "SUCCESS", 236 "SUCCESS",
236 1); 237 1);
237 } 238 }
OLDNEW
« no previous file with comments | « chrome/browser/download/save_page_browsertest.cc ('k') | chrome/browser/extensions/api/downloads/downloads_api_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698