Index: chrome/browser/ui/browser_browsertest.cc |
=================================================================== |
--- chrome/browser/ui/browser_browsertest.cc (revision 145001) |
+++ chrome/browser/ui/browser_browsertest.cc (working copy) |
@@ -33,6 +33,7 @@ |
#include "chrome/browser/ui/browser_finder.h" |
#include "chrome/browser/ui/browser_list.h" |
#include "chrome/browser/ui/browser_navigator.h" |
+#include "chrome/browser/ui/browser_tabstrip.h" |
#include "chrome/browser/ui/browser_ui_prefs.h" |
#include "chrome/browser/ui/browser_window.h" |
#include "chrome/browser/ui/extensions/application_launch.h" |
@@ -256,7 +257,7 @@ |
AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); |
EXPECT_EQ(2, browser()->tab_count()); |
EXPECT_EQ(0, browser()->active_index()); |
- WebContents* second_tab = browser()->GetWebContentsAt(1); |
+ WebContents* second_tab = chrome::GetWebContentsAt(browser(), 1); |
ASSERT_TRUE(second_tab); |
second_tab->GetRenderViewHost()->ExecuteJavascriptInWebFrame( |
string16(), |
@@ -287,8 +288,10 @@ |
// There is one initial tab. |
const int kTabCount = 34; |
- for (int ix = 0; ix != (kTabCount - 1); ++ix) |
- browser()->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED); |
+ for (int ix = 0; ix != (kTabCount - 1); ++ix) { |
+ chrome::AddSelectedTabWithURL(browser(), url, |
+ content::PAGE_TRANSITION_TYPED); |
+ } |
EXPECT_EQ(kTabCount, browser()->tab_count()); |
// See GetMaxRendererProcessCount() in |
@@ -318,10 +321,10 @@ |
chrome::Reload(browser(), CURRENT_TAB); |
AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); |
alert->CloseModalDialog(); |
- EXPECT_FALSE(browser()->GetActiveWebContents()->IsLoading()); |
+ EXPECT_FALSE(chrome::GetActiveWebContents(browser())->IsLoading()); |
// Clear the beforeunload handler so the test can easily exit. |
- browser()->GetActiveWebContents()->GetRenderViewHost()-> |
+ chrome::GetActiveWebContents(browser())->GetRenderViewHost()-> |
ExecuteJavascriptInWebFrame(string16(), |
ASCIIToUTF16("onbeforeunload=null;")); |
} |
@@ -346,7 +349,7 @@ |
// Cancel the dialog. |
AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); |
alert->CloseModalDialog(); |
- EXPECT_FALSE(browser()->GetActiveWebContents()->IsLoading()); |
+ EXPECT_FALSE(chrome::GetActiveWebContents(browser())->IsLoading()); |
// Wait for the ShouldClose_ACK to arrive. We can detect it by waiting for |
// the pending RVH to be destroyed. |
@@ -354,7 +357,7 @@ |
EXPECT_EQ(url.spec(), UTF16ToUTF8(browser()->toolbar_model()->GetText())); |
// Clear the beforeunload handler so the test can easily exit. |
- browser()->GetActiveWebContents()->GetRenderViewHost()-> |
+ chrome::GetActiveWebContents(browser())->GetRenderViewHost()-> |
ExecuteJavascriptInWebFrame(string16(), |
ASCIIToUTF16("onbeforeunload=null;")); |
} |
@@ -371,14 +374,14 @@ |
// Test for crbug.com/11647. A page closed with window.close() should not have |
// two beforeunload dialogs shown. |
IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_SingleBeforeUnloadAfterWindowClose) { |
- browser()->GetActiveWebContents()->GetRenderViewHost()-> |
+ chrome::GetActiveWebContents(browser())->GetRenderViewHost()-> |
ExecuteJavascriptInWebFrame(string16(), |
ASCIIToUTF16(kOpenNewBeforeUnloadPage)); |
// Close the new window with JavaScript, which should show a single |
// beforeunload dialog. Then show another alert, to make it easy to verify |
// that a second beforeunload dialog isn't shown. |
- browser()->GetWebContentsAt(0)->GetRenderViewHost()-> |
+ chrome::GetWebContentsAt(browser(), 0)->GetRenderViewHost()-> |
ExecuteJavascriptInWebFrame(string16(), |
ASCIIToUTF16("w.close(); alert('bar');")); |
AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); |
@@ -444,7 +447,7 @@ |
// Start with an http URL. |
ui_test_utils::NavigateToURL(browser(), http_url); |
- WebContents* oldtab = browser()->GetActiveWebContents(); |
+ WebContents* oldtab = chrome::GetActiveWebContents(browser()); |
content::RenderProcessHost* process = oldtab->GetRenderProcessHost(); |
// Now open a tab to a blank page, set its opener to null, and redirect it |
@@ -467,7 +470,7 @@ |
// Wait for popup window to appear and finish navigating. |
popup_observer.Wait(); |
ASSERT_EQ(2, browser()->tab_count()); |
- WebContents* newtab = browser()->GetActiveWebContents(); |
+ WebContents* newtab = chrome::GetActiveWebContents(browser()); |
EXPECT_TRUE(newtab); |
EXPECT_NE(oldtab, newtab); |
nav_observer.Wait(); |
@@ -501,7 +504,7 @@ |
// Wait for popup window to appear and finish navigating. |
popup_observer2.Wait(); |
ASSERT_EQ(3, browser()->tab_count()); |
- WebContents* newtab2 = browser()->GetActiveWebContents(); |
+ WebContents* newtab2 = chrome::GetActiveWebContents(browser()); |
EXPECT_TRUE(newtab2); |
EXPECT_NE(oldtab, newtab2); |
nav_observer2.Wait(); |
@@ -533,7 +536,7 @@ |
// Start with an http URL. |
ui_test_utils::NavigateToURL(browser(), http_url); |
- WebContents* oldtab = browser()->GetActiveWebContents(); |
+ WebContents* oldtab = chrome::GetActiveWebContents(browser()); |
content::RenderProcessHost* process = oldtab->GetRenderProcessHost(); |
// Now open a tab to a blank page, set its opener to null, and redirect it |
@@ -555,7 +558,7 @@ |
// Wait for popup window to appear and finish navigating. |
popup_observer.Wait(); |
ASSERT_EQ(2, browser()->tab_count()); |
- WebContents* newtab = browser()->GetActiveWebContents(); |
+ WebContents* newtab = chrome::GetActiveWebContents(browser()); |
EXPECT_TRUE(newtab); |
EXPECT_NE(oldtab, newtab); |
nav_observer.Wait(); |
@@ -691,9 +694,9 @@ |
ASSERT_TRUE(http_url.SchemeIs(chrome::kHttpScheme)); |
ASSERT_EQ(1, browser()->tab_count()); |
- WebContents* initial_tab = browser()->GetWebContentsAt(0); |
- WebContents* app_tab = browser()->AddSelectedTabWithURL( |
- http_url, content::PAGE_TRANSITION_TYPED)->web_contents(); |
+ WebContents* initial_tab = chrome::GetWebContentsAt(browser(), 0); |
+ WebContents* app_tab = chrome::AddSelectedTabWithURL( |
+ browser(), http_url, content::PAGE_TRANSITION_TYPED)->web_contents(); |
ASSERT_EQ(2, browser()->tab_count()); |
ASSERT_EQ(1u, browser::GetBrowserCount(browser()->profile())); |
@@ -718,12 +721,12 @@ |
// Check that the tab contents is in the new browser, and not in the old. |
ASSERT_EQ(1, browser()->tab_count()); |
- ASSERT_EQ(initial_tab, browser()->GetWebContentsAt(0)); |
+ ASSERT_EQ(initial_tab, chrome::GetWebContentsAt(browser(), 0)); |
// Check that the appliaction browser has a single tab, and that tab contains |
// the content that we app-ified. |
ASSERT_EQ(1, app_browser->tab_count()); |
- ASSERT_EQ(app_tab, app_browser->GetWebContentsAt(0)); |
+ ASSERT_EQ(app_tab, chrome::GetWebContentsAt(app_browser, 0)); |
// Normal tabs should accept load drops. |
EXPECT_TRUE(initial_tab->GetMutableRendererPrefs()->can_accept_load_drops); |
@@ -744,7 +747,7 @@ |
ui_test_utils::NavigateToURL(browser(), url); |
- NavigationEntry* entry = browser()->GetActiveWebContents()-> |
+ NavigationEntry* entry = chrome::GetActiveWebContents(browser())-> |
GetController().GetActiveEntry(); |
EXPECT_EQ(expected_favicon_url.spec(), entry->GetFavicon().url.spec()); |
} |
@@ -764,7 +767,7 @@ |
ASSERT_TRUE(file_url.SchemeIs(chrome::kFileScheme)); |
ui_test_utils::NavigateToURL(browser(), file_url); |
- NavigationEntry* entry = browser()->GetActiveWebContents()-> |
+ NavigationEntry* entry = chrome::GetActiveWebContents(browser())-> |
GetController().GetActiveEntry(); |
static const FilePath::CharType* kIcon = |
FILE_PATH_LITERAL("test1.png"); |
@@ -788,9 +791,8 @@ |
ui_test_utils::NavigateToURL(browser(), url); |
- TabContents* app_contents = |
- Browser::TabContentsFactory(browser()->profile(), NULL, |
- MSG_ROUTING_NONE, NULL, NULL); |
+ TabContents* app_contents = chrome::TabContentsFactory( |
+ browser()->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); |
app_contents->extension_tab_helper()->SetExtensionApp(extension_app); |
model->AddTabContents(app_contents, 0, content::PageTransitionFromInt(0), |
@@ -862,8 +864,8 @@ |
AddTabAtIndex(0, GURL(test_server()->GetURL("files/english_page.html")), |
content::PAGE_TRANSITION_TYPED); |
- WebContents* current_web_contents = browser()->GetActiveWebContents(); |
- TabContents* current_tab_contents = browser()->GetActiveTabContents(); |
+ WebContents* current_web_contents = chrome::GetActiveWebContents(browser()); |
+ TabContents* current_tab_contents = chrome::GetActiveTabContents(browser()); |
TranslateTabHelper* helper = current_tab_contents->translate_tab_helper(); |
content::Source<WebContents> source(current_web_contents); |
@@ -909,9 +911,8 @@ |
ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); |
const Extension* extension_app = GetExtension(); |
ui_test_utils::NavigateToURL(browser(), url); |
- TabContents* app_contents = |
- Browser::TabContentsFactory(browser()->profile(), NULL, |
- MSG_ROUTING_NONE, NULL, NULL); |
+ TabContents* app_contents = chrome::TabContentsFactory( |
+ browser()->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); |
app_contents->extension_tab_helper()->SetExtensionApp(extension_app); |
model->AddTabContents(app_contents, 0, content::PageTransitionFromInt(0), |
TabStripModel::ADD_NONE); |
@@ -1078,7 +1079,7 @@ |
ui_test_utils::WindowedNotificationObserver back_nav_load_observer( |
content::NOTIFICATION_LOAD_STOP, |
content::Source<NavigationController>( |
- &browser()->GetActiveWebContents()->GetController())); |
+ &chrome::GetActiveWebContents(browser())->GetController())); |
chrome::GoBack(browser(), CURRENT_TAB); |
back_nav_load_observer.Wait(); |
CommandUpdater* command_updater = |
@@ -1088,7 +1089,7 @@ |
ui_test_utils::WindowedNotificationObserver forward_nav_load_observer( |
content::NOTIFICATION_LOAD_STOP, |
content::Source<NavigationController>( |
- &browser()->GetActiveWebContents()->GetController())); |
+ &chrome::GetActiveWebContents(browser())->GetController())); |
chrome::GoForward(browser(), CURRENT_TAB); |
// This check will happen before the navigation completes, since the browser |
// won't process the renderer's response until the Wait() call below. |
@@ -1223,7 +1224,7 @@ |
} |
IN_PROC_BROWSER_TEST_F(BrowserTest, PageZoom) { |
- WebContents* contents = browser()->GetActiveWebContents(); |
+ WebContents* contents = chrome::GetActiveWebContents(browser()); |
bool enable_plus, enable_minus; |
ui_test_utils::WindowedNotificationObserver zoom_in_observer( |
@@ -1269,7 +1270,7 @@ |
EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SAVE_PAGE)); |
EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_ENCODING_MENU)); |
- WebContents* contents = browser()->GetActiveWebContents(); |
+ WebContents* contents = chrome::GetActiveWebContents(browser()); |
TestInterstitialPage* interstitial = new TestInterstitialPage( |
contents, false, GURL()); |
@@ -1327,7 +1328,7 @@ |
// Regression test for http://crbug.com/110707. Also tests that a user |
// gesture is sent when a normal navigation (via e.g. the omnibox) is |
// performed. |
- WebContents* web_contents = browser()->GetActiveWebContents(); |
+ WebContents* web_contents = chrome::GetActiveWebContents(browser()); |
MockWebContentsObserver mock_observer(web_contents); |
ASSERT_TRUE(test_server()->Start()); |
@@ -1422,9 +1423,9 @@ |
EXPECT_EQ(4, browser()->tab_count()); |
// Close the additional browsers. |
- popup_browser->CloseAllTabs(); |
- app_browser->CloseAllTabs(); |
- app_popup_browser->CloseAllTabs(); |
+ chrome::CloseAllTabs(popup_browser); |
+ chrome::CloseAllTabs(app_browser); |
+ chrome::CloseAllTabs(app_popup_browser); |
} |
#endif |
@@ -1434,7 +1435,7 @@ |
string16 title = ASCIIToUTF16("Title Of Awesomeness"); |
ui_test_utils::TitleWatcher title_watcher( |
- browser()->GetActiveWebContents(), title); |
+ chrome::GetActiveWebContents(browser()), title); |
ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), url, 2); |
EXPECT_EQ(title, title_watcher.WaitAndGetTitle()); |
} |
@@ -1456,7 +1457,7 @@ |
string16 expected_title(ASCIIToUTF16("SUCCESS")); |
ui_test_utils::TitleWatcher title_watcher( |
- browser()->GetActiveWebContents(), expected_title); |
+ chrome::GetActiveWebContents(browser()), expected_title); |
ui_test_utils::NavigateToURL(browser(), url); |
// Verify that we set a mark on successful dialog show. |
@@ -1469,7 +1470,7 @@ |
string16 expected_title(ASCIIToUTF16("Disallowed")); |
ui_test_utils::TitleWatcher title_watcher( |
- browser()->GetActiveWebContents(), expected_title); |
+ chrome::GetActiveWebContents(browser()), expected_title); |
title_watcher.AlsoWaitForTitle(ASCIIToUTF16("Allowed")); |
ui_test_utils::NavigateToURL(browser(), url); |
ASSERT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |