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

Side by Side Diff: chrome/browser/ui/browser_navigator_browsertest.cc

Issue 10546106: TabContentsWrapper -> TabContents, part 53. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 "chrome/browser/ui/browser_navigator_browsertest.h" 5 #include "chrome/browser/ui/browser_navigator_browsertest.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/autocomplete/autocomplete_edit.h" 9 #include "chrome/browser/autocomplete/autocomplete_edit.h"
10 #include "chrome/browser/prefs/incognito_mode_prefs.h" 10 #include "chrome/browser/prefs/incognito_mode_prefs.h"
11 #include "chrome/browser/prefs/pref_service.h" 11 #include "chrome/browser/prefs/pref_service.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/browser_list.h" 13 #include "chrome/browser/ui/browser_list.h"
14 #include "chrome/browser/ui/browser_navigator.h" 14 #include "chrome/browser/ui/browser_navigator.h"
15 #include "chrome/browser/ui/browser_window.h" 15 #include "chrome/browser/ui/browser_window.h"
16 #include "chrome/browser/ui/omnibox/location_bar.h" 16 #include "chrome/browser/ui/omnibox/location_bar.h"
17 #include "chrome/browser/ui/omnibox/omnibox_view.h" 17 #include "chrome/browser/ui/omnibox/omnibox_view.h"
18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 18 #include "chrome/browser/ui/tab_contents/tab_contents.h"
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" 19 #include "chrome/browser/ui/tabs/tab_strip_model.h"
20 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
21 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
22 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
23 #include "chrome/test/base/ui_test_utils.h" 23 #include "chrome/test/base/ui_test_utils.h"
24 #include "content/public/browser/notification_service.h" 24 #include "content/public/browser/notification_service.h"
25 #include "content/public/browser/notification_types.h" 25 #include "content/public/browser/notification_types.h"
26 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
27 #include "content/public/browser/web_contents_view.h" 27 #include "content/public/browser/web_contents_view.h"
28 28
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 Browser* BrowserNavigatorTest::CreateEmptyBrowserForApp(Browser::Type type, 72 Browser* BrowserNavigatorTest::CreateEmptyBrowserForApp(Browser::Type type,
73 Profile* profile) { 73 Profile* profile) {
74 Browser* browser = Browser::CreateWithParams( 74 Browser* browser = Browser::CreateWithParams(
75 Browser::CreateParams::CreateForApp( 75 Browser::CreateParams::CreateForApp(
76 Browser::TYPE_POPUP, "Test", gfx::Rect(), profile)); 76 Browser::TYPE_POPUP, "Test", gfx::Rect(), profile));
77 browser->AddBlankTab(true); 77 browser->AddBlankTab(true);
78 return browser; 78 return browser;
79 } 79 }
80 80
81 TabContentsWrapper* BrowserNavigatorTest::CreateTabContents() { 81 TabContents* BrowserNavigatorTest::CreateTabContents() {
82 return Browser::TabContentsFactory( 82 return Browser::TabContentsFactory(
83 browser()->profile(), 83 browser()->profile(),
84 NULL, 84 NULL,
85 MSG_ROUTING_NONE, 85 MSG_ROUTING_NONE,
86 browser()->GetSelectedWebContents(), 86 browser()->GetActiveWebContents(),
87 NULL); 87 NULL);
88 } 88 }
89 89
90 void BrowserNavigatorTest::RunSuppressTest(WindowOpenDisposition disposition) { 90 void BrowserNavigatorTest::RunSuppressTest(WindowOpenDisposition disposition) {
91 GURL old_url = browser()->GetSelectedWebContents()->GetURL(); 91 GURL old_url = browser()->GetActiveWebContents()->GetURL();
92 browser::NavigateParams p(MakeNavigateParams()); 92 browser::NavigateParams p(MakeNavigateParams());
93 p.disposition = disposition; 93 p.disposition = disposition;
94 browser::Navigate(&p); 94 browser::Navigate(&p);
95 95
96 // Nothing should have happened as a result of Navigate(); 96 // Nothing should have happened as a result of Navigate();
97 EXPECT_EQ(1, browser()->tab_count()); 97 EXPECT_EQ(1, browser()->tab_count());
98 EXPECT_EQ(1u, BrowserList::size()); 98 EXPECT_EQ(1u, BrowserList::size());
99 EXPECT_EQ(old_url, browser()->GetSelectedWebContents()->GetURL()); 99 EXPECT_EQ(old_url, browser()->GetActiveWebContents()->GetURL());
100 } 100 }
101 101
102 void BrowserNavigatorTest::RunUseNonIncognitoWindowTest(const GURL& url) { 102 void BrowserNavigatorTest::RunUseNonIncognitoWindowTest(const GURL& url) {
103 Browser* incognito_browser = CreateIncognitoBrowser(); 103 Browser* incognito_browser = CreateIncognitoBrowser();
104 104
105 EXPECT_EQ(2u, BrowserList::size()); 105 EXPECT_EQ(2u, BrowserList::size());
106 EXPECT_EQ(1, browser()->tab_count()); 106 EXPECT_EQ(1, browser()->tab_count());
107 EXPECT_EQ(1, incognito_browser->tab_count()); 107 EXPECT_EQ(1, incognito_browser->tab_count());
108 108
109 // Navigate to the page. 109 // Navigate to the page.
110 browser::NavigateParams p(MakeNavigateParams(incognito_browser)); 110 browser::NavigateParams p(MakeNavigateParams(incognito_browser));
111 p.disposition = SINGLETON_TAB; 111 p.disposition = SINGLETON_TAB;
112 p.url = url; 112 p.url = url;
113 p.window_action = browser::NavigateParams::SHOW_WINDOW; 113 p.window_action = browser::NavigateParams::SHOW_WINDOW;
114 browser::Navigate(&p); 114 browser::Navigate(&p);
115 115
116 // This page should be opened in browser() window. 116 // This page should be opened in browser() window.
117 EXPECT_NE(incognito_browser, p.browser); 117 EXPECT_NE(incognito_browser, p.browser);
118 EXPECT_EQ(browser(), p.browser); 118 EXPECT_EQ(browser(), p.browser);
119 EXPECT_EQ(2, browser()->tab_count()); 119 EXPECT_EQ(2, browser()->tab_count());
120 EXPECT_EQ(url, browser()->GetSelectedWebContents()->GetURL()); 120 EXPECT_EQ(url, browser()->GetActiveWebContents()->GetURL());
121 } 121 }
122 122
123 void BrowserNavigatorTest::RunDoNothingIfIncognitoIsForcedTest( 123 void BrowserNavigatorTest::RunDoNothingIfIncognitoIsForcedTest(
124 const GURL& url) { 124 const GURL& url) {
125 Browser* browser = CreateIncognitoBrowser(); 125 Browser* browser = CreateIncognitoBrowser();
126 126
127 // Set kIncognitoModeAvailability to FORCED. 127 // Set kIncognitoModeAvailability to FORCED.
128 PrefService* prefs1 = browser->profile()->GetPrefs(); 128 PrefService* prefs1 = browser->profile()->GetPrefs();
129 prefs1->SetInteger(prefs::kIncognitoModeAvailability, 129 prefs1->SetInteger(prefs::kIncognitoModeAvailability,
130 IncognitoModePrefs::FORCED); 130 IncognitoModePrefs::FORCED);
131 PrefService* prefs2 = browser->profile()->GetOriginalProfile()->GetPrefs(); 131 PrefService* prefs2 = browser->profile()->GetOriginalProfile()->GetPrefs();
132 prefs2->SetInteger(prefs::kIncognitoModeAvailability, 132 prefs2->SetInteger(prefs::kIncognitoModeAvailability,
133 IncognitoModePrefs::FORCED); 133 IncognitoModePrefs::FORCED);
134 134
135 // Navigate to the page. 135 // Navigate to the page.
136 browser::NavigateParams p(MakeNavigateParams(browser)); 136 browser::NavigateParams p(MakeNavigateParams(browser));
137 p.disposition = OFF_THE_RECORD; 137 p.disposition = OFF_THE_RECORD;
138 p.url = url; 138 p.url = url;
139 p.window_action = browser::NavigateParams::SHOW_WINDOW; 139 p.window_action = browser::NavigateParams::SHOW_WINDOW;
140 browser::Navigate(&p); 140 browser::Navigate(&p);
141 141
142 // The page should not be opened. 142 // The page should not be opened.
143 EXPECT_EQ(browser, p.browser); 143 EXPECT_EQ(browser, p.browser);
144 EXPECT_EQ(1, browser->tab_count()); 144 EXPECT_EQ(1, browser->tab_count());
145 EXPECT_EQ(GURL(chrome::kAboutBlankURL), 145 EXPECT_EQ(GURL(chrome::kAboutBlankURL),
146 browser->GetSelectedWebContents()->GetURL()); 146 browser->GetActiveWebContents()->GetURL());
147 } 147 }
148 148
149 void BrowserNavigatorTest::Observe( 149 void BrowserNavigatorTest::Observe(
150 int type, 150 int type,
151 const content::NotificationSource& source, 151 const content::NotificationSource& source,
152 const content::NotificationDetails& details) { 152 const content::NotificationDetails& details) {
153 switch (type) { 153 switch (type) {
154 case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB: { 154 case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB: {
155 ++this->created_tab_contents_count_; 155 ++this->created_tab_contents_count_;
156 break; 156 break;
157 } 157 }
158 default: 158 default:
159 break; 159 break;
160 } 160 }
161 } 161 }
162 162
163 163
164 namespace { 164 namespace {
165 165
166 // This test verifies that when a navigation occurs within a tab, the tab count 166 // This test verifies that when a navigation occurs within a tab, the tab count
167 // of the Browser remains the same and the current tab bears the loaded URL. 167 // of the Browser remains the same and the current tab bears the loaded URL.
168 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_CurrentTab) { 168 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_CurrentTab) {
169 ui_test_utils::NavigateToURL(browser(), GetGoogleURL()); 169 ui_test_utils::NavigateToURL(browser(), GetGoogleURL());
170 EXPECT_EQ(GetGoogleURL(), browser()->GetSelectedWebContents()->GetURL()); 170 EXPECT_EQ(GetGoogleURL(), browser()->GetActiveWebContents()->GetURL());
171 // We should have one window with one tab. 171 // We should have one window with one tab.
172 EXPECT_EQ(1u, BrowserList::size()); 172 EXPECT_EQ(1u, BrowserList::size());
173 EXPECT_EQ(1, browser()->tab_count()); 173 EXPECT_EQ(1, browser()->tab_count());
174 } 174 }
175 175
176 // This test verifies that a singleton tab is refocused if one is already opened 176 // This test verifies that a singleton tab is refocused if one is already opened
177 // in another or an existing window, or added if it is not. 177 // in another or an existing window, or added if it is not.
178 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SingletonTabExisting) { 178 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SingletonTabExisting) {
179 GURL singleton_url1("http://maps.google.com/"); 179 GURL singleton_url1("http://maps.google.com/");
180 180
181 // Register for a notification if an additional tab_contents was instantiated. 181 // Register for a notification if an additional tab_contents was instantiated.
182 // Opening a Singleton tab that is already opened should not be opening a new 182 // Opening a Singleton tab that is already opened should not be opening a new
183 // tab nor be creating a new TabContentsWrapper object. 183 // tab nor be creating a new TabContents object.
184 content::NotificationRegistrar registrar; 184 content::NotificationRegistrar registrar;
185 185
186 // As the registrar object goes out of scope, this will get unregistered 186 // As the registrar object goes out of scope, this will get unregistered
187 registrar.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, 187 registrar.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB,
188 content::NotificationService::AllSources()); 188 content::NotificationService::AllSources());
189 189
190 browser()->AddSelectedTabWithURL( 190 browser()->AddSelectedTabWithURL(
191 singleton_url1, content::PAGE_TRANSITION_LINK); 191 singleton_url1, content::PAGE_TRANSITION_LINK);
192 browser()->AddSelectedTabWithURL( 192 browser()->AddSelectedTabWithURL(
193 GetGoogleURL(), content::PAGE_TRANSITION_LINK); 193 GetGoogleURL(), content::PAGE_TRANSITION_LINK);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 // We should now have 2 tabs, the 2nd one selected. 281 // We should now have 2 tabs, the 2nd one selected.
282 EXPECT_EQ(browser(), p.browser); 282 EXPECT_EQ(browser(), p.browser);
283 EXPECT_EQ(2, browser()->tab_count()); 283 EXPECT_EQ(2, browser()->tab_count());
284 EXPECT_EQ(1, browser()->active_index()); 284 EXPECT_EQ(1, browser()->active_index());
285 } 285 }
286 286
287 // This test verifies that when a navigation results in a foreground tab, the 287 // This test verifies that when a navigation results in a foreground tab, the
288 // tab count of the Browser increases and the selected tab shifts to the new 288 // tab count of the Browser increases and the selected tab shifts to the new
289 // foreground tab. 289 // foreground tab.
290 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewForegroundTab) { 290 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewForegroundTab) {
291 WebContents* old_contents = browser()->GetSelectedWebContents(); 291 WebContents* old_contents = browser()->GetActiveWebContents();
292 browser::NavigateParams p(MakeNavigateParams()); 292 browser::NavigateParams p(MakeNavigateParams());
293 p.disposition = NEW_FOREGROUND_TAB; 293 p.disposition = NEW_FOREGROUND_TAB;
294 browser::Navigate(&p); 294 browser::Navigate(&p);
295 EXPECT_NE(old_contents, browser()->GetSelectedWebContents()); 295 EXPECT_NE(old_contents, browser()->GetActiveWebContents());
296 EXPECT_EQ(browser()->GetSelectedTabContentsWrapper(), p.target_contents); 296 EXPECT_EQ(browser()->GetActiveTabContents(), p.target_contents);
297 EXPECT_EQ(2, browser()->tab_count()); 297 EXPECT_EQ(2, browser()->tab_count());
298 } 298 }
299 299
300 // This test verifies that when a navigation results in a background tab, the 300 // This test verifies that when a navigation results in a background tab, the
301 // tab count of the Browser increases but the selected tab remains the same. 301 // tab count of the Browser increases but the selected tab remains the same.
302 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewBackgroundTab) { 302 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewBackgroundTab) {
303 WebContents* old_contents = browser()->GetSelectedWebContents(); 303 WebContents* old_contents = browser()->GetActiveWebContents();
304 browser::NavigateParams p(MakeNavigateParams()); 304 browser::NavigateParams p(MakeNavigateParams());
305 p.disposition = NEW_BACKGROUND_TAB; 305 p.disposition = NEW_BACKGROUND_TAB;
306 browser::Navigate(&p); 306 browser::Navigate(&p);
307 WebContents* new_contents = browser()->GetSelectedWebContents(); 307 WebContents* new_contents = browser()->GetActiveWebContents();
308 // The selected tab should have remained unchanged, since the new tab was 308 // The selected tab should have remained unchanged, since the new tab was
309 // opened in the background. 309 // opened in the background.
310 EXPECT_EQ(old_contents, new_contents); 310 EXPECT_EQ(old_contents, new_contents);
311 EXPECT_EQ(2, browser()->tab_count()); 311 EXPECT_EQ(2, browser()->tab_count());
312 } 312 }
313 313
314 // This test verifies that when a navigation requiring a new foreground tab 314 // This test verifies that when a navigation requiring a new foreground tab
315 // occurs in a Browser that cannot host multiple tabs, the new foreground tab 315 // occurs in a Browser that cannot host multiple tabs, the new foreground tab
316 // is created in an existing compatible Browser. 316 // is created in an existing compatible Browser.
317 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 317 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SaveToDisk) { 606 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SaveToDisk) {
607 RunSuppressTest(SAVE_TO_DISK); 607 RunSuppressTest(SAVE_TO_DISK);
608 } 608 }
609 609
610 // This test verifies that no navigation action occurs when 610 // This test verifies that no navigation action occurs when
611 // WindowOpenDisposition = IGNORE_ACTION. 611 // WindowOpenDisposition = IGNORE_ACTION.
612 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_IgnoreAction) { 612 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_IgnoreAction) {
613 RunSuppressTest(IGNORE_ACTION); 613 RunSuppressTest(IGNORE_ACTION);
614 } 614 }
615 615
616 // This tests adding a foreground tab with a predefined TabContentsWrapper. 616 // This tests adding a foreground tab with a predefined TabContents.
617 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, TargetContents_ForegroundTab) { 617 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, TargetContents_ForegroundTab) {
618 browser::NavigateParams p(MakeNavigateParams()); 618 browser::NavigateParams p(MakeNavigateParams());
619 p.disposition = NEW_FOREGROUND_TAB; 619 p.disposition = NEW_FOREGROUND_TAB;
620 p.target_contents = CreateTabContents(); 620 p.target_contents = CreateTabContents();
621 browser::Navigate(&p); 621 browser::Navigate(&p);
622 622
623 // Navigate() should have opened the contents in a new foreground in the 623 // Navigate() should have opened the contents in a new foreground in the
624 // current Browser. 624 // current Browser.
625 EXPECT_EQ(browser(), p.browser); 625 EXPECT_EQ(browser(), p.browser);
626 EXPECT_EQ(browser()->GetSelectedTabContentsWrapper(), p.target_contents); 626 EXPECT_EQ(browser()->GetActiveTabContents(), p.target_contents);
627 627
628 // We should have one window, with two tabs. 628 // We should have one window, with two tabs.
629 EXPECT_EQ(1u, BrowserList::size()); 629 EXPECT_EQ(1u, BrowserList::size());
630 EXPECT_EQ(2, browser()->tab_count()); 630 EXPECT_EQ(2, browser()->tab_count());
631 } 631 }
632 632
633 #if defined(OS_WIN) 633 #if defined(OS_WIN)
634 // This tests adding a popup with a predefined TabContentsWrapper. 634 // This tests adding a popup with a predefined TabContents.
635 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, DISABLED_TargetContents_Popup) { 635 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, DISABLED_TargetContents_Popup) {
636 browser::NavigateParams p(MakeNavigateParams()); 636 browser::NavigateParams p(MakeNavigateParams());
637 p.disposition = NEW_POPUP; 637 p.disposition = NEW_POPUP;
638 p.target_contents = CreateTabContents(); 638 p.target_contents = CreateTabContents();
639 p.window_bounds = gfx::Rect(10, 10, 500, 500); 639 p.window_bounds = gfx::Rect(10, 10, 500, 500);
640 browser::Navigate(&p); 640 browser::Navigate(&p);
641 641
642 // Navigate() should have opened a new popup window. 642 // Navigate() should have opened a new popup window.
643 EXPECT_NE(browser(), p.browser); 643 EXPECT_NE(browser(), p.browser);
644 EXPECT_TRUE(p.browser->is_type_popup()); 644 EXPECT_TRUE(p.browser->is_type_popup());
645 EXPECT_FALSE(p.browser->is_app()); 645 EXPECT_FALSE(p.browser->is_app());
646 646
647 // The web platform is weird. The window bounds specified in 647 // The web platform is weird. The window bounds specified in
648 // |p.window_bounds| are used as follows: 648 // |p.window_bounds| are used as follows:
649 // - the origin is used to position the window 649 // - the origin is used to position the window
650 // - the size is used to size the TabContentsWrapper of the window. 650 // - the size is used to size the TabContents of the window.
651 // As such the position of the resulting window will always match 651 // As such the position of the resulting window will always match
652 // p.window_bounds.origin(), but its size will not. We need to match 652 // p.window_bounds.origin(), but its size will not. We need to match
653 // the size against the selected tab's view's container size. 653 // the size against the selected tab's view's container size.
654 // Only Windows positions the window according to |p.window_bounds.origin()| - 654 // Only Windows positions the window according to |p.window_bounds.origin()| -
655 // on Mac the window is offset from the opener and on Linux it always opens 655 // on Mac the window is offset from the opener and on Linux it always opens
656 // at 0,0. 656 // at 0,0.
657 EXPECT_EQ(p.window_bounds.origin(), 657 EXPECT_EQ(p.window_bounds.origin(),
658 p.browser->window()->GetRestoredBounds().origin()); 658 p.browser->window()->GetRestoredBounds().origin());
659 // All platforms should respect size however provided width > 400 (Mac has a 659 // All platforms should respect size however provided width > 400 (Mac has a
660 // minimum window width of 400). 660 // minimum window width of 400).
(...skipping 16 matching lines...) Expand all
677 // insertion index preference is reflected in common cases. 677 // insertion index preference is reflected in common cases.
678 browser::NavigateParams p(MakeNavigateParams()); 678 browser::NavigateParams p(MakeNavigateParams());
679 p.disposition = NEW_FOREGROUND_TAB; 679 p.disposition = NEW_FOREGROUND_TAB;
680 p.tabstrip_index = 0; 680 p.tabstrip_index = 0;
681 p.tabstrip_add_types = TabStripModel::ADD_FORCE_INDEX; 681 p.tabstrip_add_types = TabStripModel::ADD_FORCE_INDEX;
682 browser::Navigate(&p); 682 browser::Navigate(&p);
683 683
684 // Navigate() should have inserted a new tab at slot 0 in the tabstrip. 684 // Navigate() should have inserted a new tab at slot 0 in the tabstrip.
685 EXPECT_EQ(browser(), p.browser); 685 EXPECT_EQ(browser(), p.browser);
686 EXPECT_EQ(0, browser()->tab_strip_model()->GetIndexOfTabContents( 686 EXPECT_EQ(0, browser()->tab_strip_model()->GetIndexOfTabContents(
687 static_cast<const TabContentsWrapper*>(p.target_contents))); 687 static_cast<const TabContents*>(p.target_contents)));
688 688
689 // We should have one window - the browser() provided by the framework. 689 // We should have one window - the browser() provided by the framework.
690 EXPECT_EQ(1u, BrowserList::size()); 690 EXPECT_EQ(1u, BrowserList::size());
691 EXPECT_EQ(2, browser()->tab_count()); 691 EXPECT_EQ(2, browser()->tab_count());
692 } 692 }
693 693
694 // This test verifies that constructing params with a NULL browser has 694 // This test verifies that constructing params with a NULL browser has
695 // the same result as navigating to a new foreground tab in the (only) 695 // the same result as navigating to a new foreground tab in the (only)
696 // active browser. Tests are the same as for Disposition_NewForegroundTab. 696 // active browser. Tests are the same as for Disposition_NewForegroundTab.
697 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_NewForegroundTab) { 697 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_NewForegroundTab) {
698 WebContents* old_contents = browser()->GetSelectedWebContents(); 698 WebContents* old_contents = browser()->GetActiveWebContents();
699 // Navigate with a NULL browser. 699 // Navigate with a NULL browser.
700 browser::NavigateParams p(MakeNavigateParams(NULL)); 700 browser::NavigateParams p(MakeNavigateParams(NULL));
701 p.disposition = NEW_FOREGROUND_TAB; 701 p.disposition = NEW_FOREGROUND_TAB;
702 p.profile = browser()->profile(); 702 p.profile = browser()->profile();
703 browser::Navigate(&p); 703 browser::Navigate(&p);
704 704
705 // Navigate() should have found browser() and create a new tab. 705 // Navigate() should have found browser() and create a new tab.
706 EXPECT_EQ(browser(), p.browser); 706 EXPECT_EQ(browser(), p.browser);
707 EXPECT_NE(old_contents, browser()->GetSelectedWebContents()); 707 EXPECT_NE(old_contents, browser()->GetActiveWebContents());
708 EXPECT_EQ(browser()->GetSelectedTabContentsWrapper(), p.target_contents); 708 EXPECT_EQ(browser()->GetActiveTabContents(), p.target_contents);
709 EXPECT_EQ(2, browser()->tab_count()); 709 EXPECT_EQ(2, browser()->tab_count());
710 } 710 }
711 711
712 // This test verifies that constructing params with a NULL browser and 712 // This test verifies that constructing params with a NULL browser and
713 // a specific profile matches the specified profile. 713 // a specific profile matches the specified profile.
714 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_MatchProfile) { 714 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_MatchProfile) {
715 // Create a new browser with using the incognito profile. 715 // Create a new browser with using the incognito profile.
716 Browser* incognito = 716 Browser* incognito =
717 Browser::Create(browser()->profile()->GetOffTheRecordProfile()); 717 Browser::Create(browser()->profile()->GetOffTheRecordProfile());
718 718
719 // Navigate with a NULL browser and the incognito profile. 719 // Navigate with a NULL browser and the incognito profile.
720 browser::NavigateParams p(MakeNavigateParams(NULL)); 720 browser::NavigateParams p(MakeNavigateParams(NULL));
721 p.disposition = NEW_FOREGROUND_TAB; 721 p.disposition = NEW_FOREGROUND_TAB;
722 p.profile = incognito->profile(); 722 p.profile = incognito->profile();
723 browser::Navigate(&p); 723 browser::Navigate(&p);
724 724
725 // Navigate() should have found incognito, not browser(). 725 // Navigate() should have found incognito, not browser().
726 EXPECT_EQ(incognito, p.browser); 726 EXPECT_EQ(incognito, p.browser);
727 EXPECT_EQ(incognito->GetSelectedTabContentsWrapper(), p.target_contents); 727 EXPECT_EQ(incognito->GetActiveTabContents(), p.target_contents);
728 EXPECT_EQ(1, incognito->tab_count()); 728 EXPECT_EQ(1, incognito->tab_count());
729 } 729 }
730 730
731 // This test verifies that constructing params with a NULL browser and 731 // This test verifies that constructing params with a NULL browser and
732 // disposition = NEW_WINDOW always opens exactly one new window. 732 // disposition = NEW_WINDOW always opens exactly one new window.
733 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_NewWindow) { 733 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_NewWindow) {
734 browser::NavigateParams p(MakeNavigateParams(NULL)); 734 browser::NavigateParams p(MakeNavigateParams(NULL));
735 p.disposition = NEW_WINDOW; 735 p.disposition = NEW_WINDOW;
736 p.profile = browser()->profile(); 736 p.profile = browser()->profile();
737 browser::Navigate(&p); 737 browser::Navigate(&p);
(...skipping 29 matching lines...) Expand all
767 p.window_action = browser::NavigateParams::SHOW_WINDOW; 767 p.window_action = browser::NavigateParams::SHOW_WINDOW;
768 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; 768 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE;
769 browser::Navigate(&p); 769 browser::Navigate(&p);
770 770
771 // The last tab should now be selected and navigated to the sub-page of the 771 // The last tab should now be selected and navigated to the sub-page of the
772 // URL. 772 // URL.
773 EXPECT_EQ(browser(), p.browser); 773 EXPECT_EQ(browser(), p.browser);
774 EXPECT_EQ(3, browser()->tab_count()); 774 EXPECT_EQ(3, browser()->tab_count());
775 EXPECT_EQ(2, browser()->active_index()); 775 EXPECT_EQ(2, browser()->active_index());
776 EXPECT_EQ(GetContentSettingsURL(), 776 EXPECT_EQ(GetContentSettingsURL(),
777 browser()->GetSelectedWebContents()->GetURL()); 777 browser()->GetActiveWebContents()->GetURL());
778 } 778 }
779 779
780 // This test verifies that constructing params with disposition = SINGLETON_TAB 780 // This test verifies that constructing params with disposition = SINGLETON_TAB
781 // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus 781 // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus
782 // the path) which is navigated to the specified URL. 782 // the path) which is navigated to the specified URL.
783 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 783 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
784 Disposition_SingletonTabExisting_IgnorePath) { 784 Disposition_SingletonTabExisting_IgnorePath) {
785 GURL singleton_url1(GetSettingsURL()); 785 GURL singleton_url1(GetSettingsURL());
786 browser()->AddSelectedTabWithURL( 786 browser()->AddSelectedTabWithURL(
787 singleton_url1, content::PAGE_TRANSITION_LINK); 787 singleton_url1, content::PAGE_TRANSITION_LINK);
(...skipping 12 matching lines...) Expand all
800 p.window_action = browser::NavigateParams::SHOW_WINDOW; 800 p.window_action = browser::NavigateParams::SHOW_WINDOW;
801 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; 801 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE;
802 browser::Navigate(&p); 802 browser::Navigate(&p);
803 803
804 // The middle tab should now be selected and navigated to the sub-page of the 804 // The middle tab should now be selected and navigated to the sub-page of the
805 // URL. 805 // URL.
806 EXPECT_EQ(browser(), p.browser); 806 EXPECT_EQ(browser(), p.browser);
807 EXPECT_EQ(3, browser()->tab_count()); 807 EXPECT_EQ(3, browser()->tab_count());
808 EXPECT_EQ(1, browser()->active_index()); 808 EXPECT_EQ(1, browser()->active_index());
809 EXPECT_EQ(GetContentSettingsURL(), 809 EXPECT_EQ(GetContentSettingsURL(),
810 browser()->GetSelectedWebContents()->GetURL()); 810 browser()->GetActiveWebContents()->GetURL());
811 } 811 }
812 812
813 // This test verifies that constructing params with disposition = SINGLETON_TAB 813 // This test verifies that constructing params with disposition = SINGLETON_TAB
814 // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus 814 // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus
815 // the path) which is navigated to the specified URL. 815 // the path) which is navigated to the specified URL.
816 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 816 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
817 Disposition_SingletonTabExistingSubPath_IgnorePath) { 817 Disposition_SingletonTabExistingSubPath_IgnorePath) {
818 GURL singleton_url1(GetContentSettingsURL()); 818 GURL singleton_url1(GetContentSettingsURL());
819 browser()->AddSelectedTabWithURL( 819 browser()->AddSelectedTabWithURL(
820 singleton_url1, content::PAGE_TRANSITION_LINK); 820 singleton_url1, content::PAGE_TRANSITION_LINK);
(...skipping 12 matching lines...) Expand all
833 p.window_action = browser::NavigateParams::SHOW_WINDOW; 833 p.window_action = browser::NavigateParams::SHOW_WINDOW;
834 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; 834 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE;
835 browser::Navigate(&p); 835 browser::Navigate(&p);
836 836
837 // The middle tab should now be selected and navigated to the sub-page of the 837 // The middle tab should now be selected and navigated to the sub-page of the
838 // URL. 838 // URL.
839 EXPECT_EQ(browser(), p.browser); 839 EXPECT_EQ(browser(), p.browser);
840 EXPECT_EQ(3, browser()->tab_count()); 840 EXPECT_EQ(3, browser()->tab_count());
841 EXPECT_EQ(1, browser()->active_index()); 841 EXPECT_EQ(1, browser()->active_index());
842 EXPECT_EQ(GetClearBrowsingDataURL(), 842 EXPECT_EQ(GetClearBrowsingDataURL(),
843 browser()->GetSelectedWebContents()->GetURL()); 843 browser()->GetActiveWebContents()->GetURL());
844 } 844 }
845 845
846 // This test verifies that constructing params with disposition = SINGLETON_TAB 846 // This test verifies that constructing params with disposition = SINGLETON_TAB
847 // and IGNORE_AND_STAY_PUT opens an existing tab with the matching URL (minus 847 // and IGNORE_AND_STAY_PUT opens an existing tab with the matching URL (minus
848 // the path). 848 // the path).
849 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 849 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
850 Disposition_SingletonTabExistingSubPath_IgnorePath2) { 850 Disposition_SingletonTabExistingSubPath_IgnorePath2) {
851 GURL singleton_url1(GetContentSettingsURL()); 851 GURL singleton_url1(GetContentSettingsURL());
852 browser()->AddSelectedTabWithURL( 852 browser()->AddSelectedTabWithURL(
853 singleton_url1, content::PAGE_TRANSITION_LINK); 853 singleton_url1, content::PAGE_TRANSITION_LINK);
(...skipping 11 matching lines...) Expand all
865 p.url = GetClearBrowsingDataURL(); 865 p.url = GetClearBrowsingDataURL();
866 p.window_action = browser::NavigateParams::SHOW_WINDOW; 866 p.window_action = browser::NavigateParams::SHOW_WINDOW;
867 p.path_behavior = browser::NavigateParams::IGNORE_AND_STAY_PUT; 867 p.path_behavior = browser::NavigateParams::IGNORE_AND_STAY_PUT;
868 browser::Navigate(&p); 868 browser::Navigate(&p);
869 869
870 // The middle tab should now be selected. 870 // The middle tab should now be selected.
871 EXPECT_EQ(browser(), p.browser); 871 EXPECT_EQ(browser(), p.browser);
872 EXPECT_EQ(3, browser()->tab_count()); 872 EXPECT_EQ(3, browser()->tab_count());
873 EXPECT_EQ(1, browser()->active_index()); 873 EXPECT_EQ(1, browser()->active_index());
874 EXPECT_EQ(singleton_url1, 874 EXPECT_EQ(singleton_url1,
875 browser()->GetSelectedWebContents()->GetURL()); 875 browser()->GetActiveWebContents()->GetURL());
876 } 876 }
877 877
878 // This test verifies that constructing params with disposition = SINGLETON_TAB 878 // This test verifies that constructing params with disposition = SINGLETON_TAB
879 // and IGNORE_AND_NAVIGATE will update the current tab's URL if the currently 879 // and IGNORE_AND_NAVIGATE will update the current tab's URL if the currently
880 // selected tab is a match but has a different path. 880 // selected tab is a match but has a different path.
881 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 881 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
882 Disposition_SingletonTabFocused_IgnorePath) { 882 Disposition_SingletonTabFocused_IgnorePath) {
883 GURL singleton_url_current(GetContentSettingsURL()); 883 GURL singleton_url_current(GetContentSettingsURL());
884 browser()->AddSelectedTabWithURL( 884 browser()->AddSelectedTabWithURL(
885 singleton_url_current, content::PAGE_TRANSITION_LINK); 885 singleton_url_current, content::PAGE_TRANSITION_LINK);
(...skipping 10 matching lines...) Expand all
896 p.url = singleton_url_target; 896 p.url = singleton_url_target;
897 p.window_action = browser::NavigateParams::SHOW_WINDOW; 897 p.window_action = browser::NavigateParams::SHOW_WINDOW;
898 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; 898 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE;
899 browser::Navigate(&p); 899 browser::Navigate(&p);
900 900
901 // The second tab should still be selected, but navigated to the new path. 901 // The second tab should still be selected, but navigated to the new path.
902 EXPECT_EQ(browser(), p.browser); 902 EXPECT_EQ(browser(), p.browser);
903 EXPECT_EQ(2, browser()->tab_count()); 903 EXPECT_EQ(2, browser()->tab_count());
904 EXPECT_EQ(1, browser()->active_index()); 904 EXPECT_EQ(1, browser()->active_index());
905 EXPECT_EQ(singleton_url_target, 905 EXPECT_EQ(singleton_url_target,
906 browser()->GetSelectedWebContents()->GetURL()); 906 browser()->GetActiveWebContents()->GetURL());
907 } 907 }
908 908
909 // This test verifies that constructing params with disposition = SINGLETON_TAB 909 // This test verifies that constructing params with disposition = SINGLETON_TAB
910 // and IGNORE_AND_NAVIGATE will open an existing matching tab with a different 910 // and IGNORE_AND_NAVIGATE will open an existing matching tab with a different
911 // query. 911 // query.
912 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 912 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
913 Disposition_SingletonTabExisting_IgnoreQuery) { 913 Disposition_SingletonTabExisting_IgnoreQuery) {
914 int initial_tab_count = browser()->tab_count(); 914 int initial_tab_count = browser()->tab_count();
915 GURL singleton_url_current("chrome://settings/internet"); 915 GURL singleton_url_current("chrome://settings/internet");
916 browser()->AddSelectedTabWithURL( 916 browser()->AddSelectedTabWithURL(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 params.disposition = OFF_THE_RECORD; 954 params.disposition = OFF_THE_RECORD;
955 { 955 {
956 ui_test_utils::WindowedNotificationObserver observer( 956 ui_test_utils::WindowedNotificationObserver observer(
957 content::NOTIFICATION_LOAD_STOP, 957 content::NOTIFICATION_LOAD_STOP,
958 content::NotificationService::AllSources()); 958 content::NotificationService::AllSources());
959 browser::Navigate(&params); 959 browser::Navigate(&params);
960 observer.Wait(); 960 observer.Wait();
961 } 961 }
962 962
963 EXPECT_EQ(1u, BrowserList::size()); 963 EXPECT_EQ(1u, BrowserList::size());
964 EXPECT_EQ(GetSettingsURL(), browser()->GetSelectedWebContents()->GetURL()); 964 EXPECT_EQ(GetSettingsURL(), browser()->GetActiveWebContents()->GetURL());
965 } 965 }
966 966
967 // Settings page is expected to always open in normal mode regardless 967 // Settings page is expected to always open in normal mode regardless
968 // of whether the user is trying to open it in incognito mode or not. 968 // of whether the user is trying to open it in incognito mode or not.
969 // This test verifies that if incognito mode is forced (by policy), settings 969 // This test verifies that if incognito mode is forced (by policy), settings
970 // page doesn't open at all. 970 // page doesn't open at all.
971 // Disabled until fixed for uber settings: http://crbug.com/111243 971 // Disabled until fixed for uber settings: http://crbug.com/111243
972 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 972 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
973 DISABLED_Disposition_Settings_DoNothingIfIncognitoIsForced) { 973 DISABLED_Disposition_Settings_DoNothingIfIncognitoIsForced) {
974 RunDoNothingIfIncognitoIsForcedTest(GetSettingsURL()); 974 RunDoNothingIfIncognitoIsForcedTest(GetSettingsURL());
(...skipping 28 matching lines...) Expand all
1003 // doesn't open at all. 1003 // doesn't open at all.
1004 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1004 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1005 Disposition_SyncPromo_DoNothingIfIncognitoIsForced) { 1005 Disposition_SyncPromo_DoNothingIfIncognitoIsForced) {
1006 RunDoNothingIfIncognitoIsForcedTest(GURL(chrome::kChromeUISyncPromoURL)); 1006 RunDoNothingIfIncognitoIsForcedTest(GURL(chrome::kChromeUISyncPromoURL));
1007 } 1007 }
1008 1008
1009 // This test makes sure a crashed singleton tab reloads from a new navigation. 1009 // This test makes sure a crashed singleton tab reloads from a new navigation.
1010 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1010 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1011 NavigateToCrashedSingletonTab) { 1011 NavigateToCrashedSingletonTab) {
1012 GURL singleton_url(GetContentSettingsURL()); 1012 GURL singleton_url(GetContentSettingsURL());
1013 TabContentsWrapper* wrapper = browser()->AddSelectedTabWithURL( 1013 TabContents* tab_contents = browser()->AddSelectedTabWithURL(
1014 singleton_url, content::PAGE_TRANSITION_LINK); 1014 singleton_url, content::PAGE_TRANSITION_LINK);
1015 WebContents* web_contents = wrapper->web_contents(); 1015 WebContents* web_contents = tab_contents->web_contents();
1016 1016
1017 // We should have one browser with 2 tabs, the 2nd selected. 1017 // We should have one browser with 2 tabs, the 2nd selected.
1018 EXPECT_EQ(1u, BrowserList::size()); 1018 EXPECT_EQ(1u, BrowserList::size());
1019 EXPECT_EQ(2, browser()->tab_count()); 1019 EXPECT_EQ(2, browser()->tab_count());
1020 EXPECT_EQ(1, browser()->active_index()); 1020 EXPECT_EQ(1, browser()->active_index());
1021 1021
1022 // Kill the singleton tab. 1022 // Kill the singleton tab.
1023 web_contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); 1023 web_contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1);
1024 EXPECT_TRUE(web_contents->IsCrashed()); 1024 EXPECT_TRUE(web_contents->IsCrashed());
1025 1025
(...skipping 11 matching lines...) Expand all
1037 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1037 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1038 NavigateFromDefaultToOptionsInSameTab) { 1038 NavigateFromDefaultToOptionsInSameTab) {
1039 { 1039 {
1040 ui_test_utils::WindowedNotificationObserver observer( 1040 ui_test_utils::WindowedNotificationObserver observer(
1041 content::NOTIFICATION_LOAD_STOP, 1041 content::NOTIFICATION_LOAD_STOP,
1042 content::NotificationService::AllSources()); 1042 content::NotificationService::AllSources());
1043 browser()->OpenOptionsDialog(); 1043 browser()->OpenOptionsDialog();
1044 observer.Wait(); 1044 observer.Wait();
1045 } 1045 }
1046 EXPECT_EQ(1, browser()->tab_count()); 1046 EXPECT_EQ(1, browser()->tab_count());
1047 EXPECT_EQ(GetSettingsURL(), browser()->GetSelectedWebContents()->GetURL()); 1047 EXPECT_EQ(GetSettingsURL(), browser()->GetActiveWebContents()->GetURL());
1048 } 1048 }
1049 1049
1050 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1050 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1051 NavigateFromBlankToOptionsInSameTab) { 1051 NavigateFromBlankToOptionsInSameTab) {
1052 browser::NavigateParams p(MakeNavigateParams()); 1052 browser::NavigateParams p(MakeNavigateParams());
1053 p.url = GURL(chrome::kAboutBlankURL); 1053 p.url = GURL(chrome::kAboutBlankURL);
1054 ui_test_utils::NavigateToURL(&p); 1054 ui_test_utils::NavigateToURL(&p);
1055 1055
1056 { 1056 {
1057 ui_test_utils::WindowedNotificationObserver observer( 1057 ui_test_utils::WindowedNotificationObserver observer(
1058 content::NOTIFICATION_LOAD_STOP, 1058 content::NOTIFICATION_LOAD_STOP,
1059 content::NotificationService::AllSources()); 1059 content::NotificationService::AllSources());
1060 browser()->OpenOptionsDialog(); 1060 browser()->OpenOptionsDialog();
1061 observer.Wait(); 1061 observer.Wait();
1062 } 1062 }
1063 EXPECT_EQ(1, browser()->tab_count()); 1063 EXPECT_EQ(1, browser()->tab_count());
1064 EXPECT_EQ(GetSettingsURL(), browser()->GetSelectedWebContents()->GetURL()); 1064 EXPECT_EQ(GetSettingsURL(), browser()->GetActiveWebContents()->GetURL());
1065 } 1065 }
1066 1066
1067 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1067 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1068 NavigateFromNTPToOptionsInSameTab) { 1068 NavigateFromNTPToOptionsInSameTab) {
1069 browser::NavigateParams p(MakeNavigateParams()); 1069 browser::NavigateParams p(MakeNavigateParams());
1070 p.url = GURL(chrome::kChromeUINewTabURL); 1070 p.url = GURL(chrome::kChromeUINewTabURL);
1071 ui_test_utils::NavigateToURL(&p); 1071 ui_test_utils::NavigateToURL(&p);
1072 EXPECT_EQ(1, browser()->tab_count()); 1072 EXPECT_EQ(1, browser()->tab_count());
1073 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), 1073 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL),
1074 browser()->GetSelectedWebContents()->GetURL()); 1074 browser()->GetActiveWebContents()->GetURL());
1075 1075
1076 { 1076 {
1077 ui_test_utils::WindowedNotificationObserver observer( 1077 ui_test_utils::WindowedNotificationObserver observer(
1078 content::NOTIFICATION_LOAD_STOP, 1078 content::NOTIFICATION_LOAD_STOP,
1079 content::NotificationService::AllSources()); 1079 content::NotificationService::AllSources());
1080 browser()->OpenOptionsDialog(); 1080 browser()->OpenOptionsDialog();
1081 observer.Wait(); 1081 observer.Wait();
1082 } 1082 }
1083 EXPECT_EQ(1, browser()->tab_count()); 1083 EXPECT_EQ(1, browser()->tab_count());
1084 EXPECT_EQ(GetSettingsURL(), browser()->GetSelectedWebContents()->GetURL()); 1084 EXPECT_EQ(GetSettingsURL(), browser()->GetActiveWebContents()->GetURL());
1085 } 1085 }
1086 1086
1087 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1087 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1088 NavigateFromPageToOptionsInNewTab) { 1088 NavigateFromPageToOptionsInNewTab) {
1089 browser::NavigateParams p(MakeNavigateParams()); 1089 browser::NavigateParams p(MakeNavigateParams());
1090 ui_test_utils::NavigateToURL(&p); 1090 ui_test_utils::NavigateToURL(&p);
1091 EXPECT_EQ(GetGoogleURL(), browser()->GetSelectedWebContents()->GetURL()); 1091 EXPECT_EQ(GetGoogleURL(), browser()->GetActiveWebContents()->GetURL());
1092 EXPECT_EQ(1u, BrowserList::size()); 1092 EXPECT_EQ(1u, BrowserList::size());
1093 EXPECT_EQ(1, browser()->tab_count()); 1093 EXPECT_EQ(1, browser()->tab_count());
1094 1094
1095 { 1095 {
1096 ui_test_utils::WindowedNotificationObserver observer( 1096 ui_test_utils::WindowedNotificationObserver observer(
1097 content::NOTIFICATION_LOAD_STOP, 1097 content::NOTIFICATION_LOAD_STOP,
1098 content::NotificationService::AllSources()); 1098 content::NotificationService::AllSources());
1099 browser()->OpenOptionsDialog(); 1099 browser()->OpenOptionsDialog();
1100 observer.Wait(); 1100 observer.Wait();
1101 } 1101 }
1102 EXPECT_EQ(2, browser()->tab_count()); 1102 EXPECT_EQ(2, browser()->tab_count());
1103 EXPECT_EQ(GetSettingsURL(), browser()->GetSelectedWebContents()->GetURL()); 1103 EXPECT_EQ(GetSettingsURL(), browser()->GetActiveWebContents()->GetURL());
1104 } 1104 }
1105 1105
1106 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1106 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1107 NavigateFromNTPToOptionsSingleton) { 1107 NavigateFromNTPToOptionsSingleton) {
1108 { 1108 {
1109 ui_test_utils::WindowedNotificationObserver observer( 1109 ui_test_utils::WindowedNotificationObserver observer(
1110 content::NOTIFICATION_LOAD_STOP, 1110 content::NOTIFICATION_LOAD_STOP,
1111 content::NotificationService::AllSources()); 1111 content::NotificationService::AllSources());
1112 browser()->OpenOptionsDialog(); 1112 browser()->OpenOptionsDialog();
1113 observer.Wait(); 1113 observer.Wait();
1114 } 1114 }
1115 EXPECT_EQ(1, browser()->tab_count()); 1115 EXPECT_EQ(1, browser()->tab_count());
1116 1116
1117 browser()->NewTab(); 1117 browser()->NewTab();
1118 EXPECT_EQ(2, browser()->tab_count()); 1118 EXPECT_EQ(2, browser()->tab_count());
1119 1119
1120 { 1120 {
1121 ui_test_utils::WindowedNotificationObserver observer( 1121 ui_test_utils::WindowedNotificationObserver observer(
1122 content::NOTIFICATION_LOAD_STOP, 1122 content::NOTIFICATION_LOAD_STOP,
1123 content::NotificationService::AllSources()); 1123 content::NotificationService::AllSources());
1124 browser()->OpenOptionsDialog(); 1124 browser()->OpenOptionsDialog();
1125 observer.Wait(); 1125 observer.Wait();
1126 } 1126 }
1127 EXPECT_EQ(2, browser()->tab_count()); 1127 EXPECT_EQ(2, browser()->tab_count());
1128 EXPECT_EQ(GetSettingsURL(), browser()->GetSelectedWebContents()->GetURL()); 1128 EXPECT_EQ(GetSettingsURL(), browser()->GetActiveWebContents()->GetURL());
1129 } 1129 }
1130 1130
1131 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1131 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1132 NavigateFromNTPToOptionsPageInSameTab) { 1132 NavigateFromNTPToOptionsPageInSameTab) {
1133 { 1133 {
1134 ui_test_utils::WindowedNotificationObserver observer( 1134 ui_test_utils::WindowedNotificationObserver observer(
1135 content::NOTIFICATION_LOAD_STOP, 1135 content::NOTIFICATION_LOAD_STOP,
1136 content::NotificationService::AllSources()); 1136 content::NotificationService::AllSources());
1137 browser()->OpenClearBrowsingDataDialog(); 1137 browser()->OpenClearBrowsingDataDialog();
1138 observer.Wait(); 1138 observer.Wait();
1139 } 1139 }
1140 EXPECT_EQ(1, browser()->tab_count()); 1140 EXPECT_EQ(1, browser()->tab_count());
1141 EXPECT_EQ(GetClearBrowsingDataURL(), 1141 EXPECT_EQ(GetClearBrowsingDataURL(),
1142 browser()->GetSelectedWebContents()->GetURL()); 1142 browser()->GetActiveWebContents()->GetURL());
1143 1143
1144 browser()->NewTab(); 1144 browser()->NewTab();
1145 EXPECT_EQ(2, browser()->tab_count()); 1145 EXPECT_EQ(2, browser()->tab_count());
1146 1146
1147 { 1147 {
1148 ui_test_utils::WindowedNotificationObserver observer( 1148 ui_test_utils::WindowedNotificationObserver observer(
1149 content::NOTIFICATION_LOAD_STOP, 1149 content::NOTIFICATION_LOAD_STOP,
1150 content::NotificationService::AllSources()); 1150 content::NotificationService::AllSources());
1151 browser()->OpenClearBrowsingDataDialog(); 1151 browser()->OpenClearBrowsingDataDialog();
1152 observer.Wait(); 1152 observer.Wait();
1153 } 1153 }
1154 EXPECT_EQ(2, browser()->tab_count()); 1154 EXPECT_EQ(2, browser()->tab_count());
1155 EXPECT_EQ(GetClearBrowsingDataURL(), 1155 EXPECT_EQ(GetClearBrowsingDataURL(),
1156 browser()->GetSelectedWebContents()->GetURL()); 1156 browser()->GetActiveWebContents()->GetURL());
1157 } 1157 }
1158 1158
1159 // Times out on mac, fails on linux. 1159 // Times out on mac, fails on linux.
1160 // http://crbug.com/119779 1160 // http://crbug.com/119779
1161 #if defined(OS_MACOSX) || defined(OS_LINUX) 1161 #if defined(OS_MACOSX) || defined(OS_LINUX)
1162 #define MAYBE_NavigateFromOtherTabToSingletonOptions DISABLED_NavigateFromOtherT abToSingletonOptions 1162 #define MAYBE_NavigateFromOtherTabToSingletonOptions DISABLED_NavigateFromOtherT abToSingletonOptions
1163 #else 1163 #else
1164 #define MAYBE_NavigateFromOtherTabToSingletonOptions NavigatorFrameOtherTabToSin gletonOptions 1164 #define MAYBE_NavigateFromOtherTabToSingletonOptions NavigatorFrameOtherTabToSin gletonOptions
1165 #endif 1165 #endif
1166 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1166 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
(...skipping 16 matching lines...) Expand all
1183 1183
1184 { 1184 {
1185 ui_test_utils::WindowedNotificationObserver observer( 1185 ui_test_utils::WindowedNotificationObserver observer(
1186 content::NOTIFICATION_LOAD_STOP, 1186 content::NOTIFICATION_LOAD_STOP,
1187 content::NotificationService::AllSources()); 1187 content::NotificationService::AllSources());
1188 browser()->OpenOptionsDialog(); 1188 browser()->OpenOptionsDialog();
1189 observer.Wait(); 1189 observer.Wait();
1190 } 1190 }
1191 EXPECT_EQ(2, browser()->tab_count()); 1191 EXPECT_EQ(2, browser()->tab_count());
1192 EXPECT_EQ(GetSettingsURL(), 1192 EXPECT_EQ(GetSettingsURL(),
1193 browser()->GetSelectedWebContents()->GetURL()); 1193 browser()->GetActiveWebContents()->GetURL());
1194 } 1194 }
1195 1195
1196 // Tests that when a new tab is opened from the omnibox, the focus is moved from 1196 // Tests that when a new tab is opened from the omnibox, the focus is moved from
1197 // the omnibox for the current tab. 1197 // the omnibox for the current tab.
1198 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1198 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1199 NavigateFromOmniboxIntoNewTab) { 1199 NavigateFromOmniboxIntoNewTab) {
1200 GURL url("http://www.google.com/"); 1200 GURL url("http://www.google.com/");
1201 GURL url2("http://maps.google.com/"); 1201 GURL url2("http://maps.google.com/");
1202 1202
1203 // Navigate to url. 1203 // Navigate to url.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 DISABLED_NavigateFromDefaultToHistoryInSameTab) { 1235 DISABLED_NavigateFromDefaultToHistoryInSameTab) {
1236 { 1236 {
1237 ui_test_utils::WindowedNotificationObserver observer( 1237 ui_test_utils::WindowedNotificationObserver observer(
1238 content::NOTIFICATION_LOAD_STOP, 1238 content::NOTIFICATION_LOAD_STOP,
1239 content::NotificationService::AllSources()); 1239 content::NotificationService::AllSources());
1240 browser()->ShowHistoryTab(); 1240 browser()->ShowHistoryTab();
1241 observer.Wait(); 1241 observer.Wait();
1242 } 1242 }
1243 EXPECT_EQ(1, browser()->tab_count()); 1243 EXPECT_EQ(1, browser()->tab_count());
1244 EXPECT_EQ(GURL(chrome::kChromeUIHistoryFrameURL), 1244 EXPECT_EQ(GURL(chrome::kChromeUIHistoryFrameURL),
1245 browser()->GetSelectedWebContents()->GetURL()); 1245 browser()->GetActiveWebContents()->GetURL());
1246 } 1246 }
1247 1247
1248 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1248 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1249 NavigateFromDefaultToBookmarksInSameTab) { 1249 NavigateFromDefaultToBookmarksInSameTab) {
1250 { 1250 {
1251 ui_test_utils::WindowedNotificationObserver observer( 1251 ui_test_utils::WindowedNotificationObserver observer(
1252 content::NOTIFICATION_LOAD_STOP, 1252 content::NOTIFICATION_LOAD_STOP,
1253 content::NotificationService::AllSources()); 1253 content::NotificationService::AllSources());
1254 browser()->OpenBookmarkManager(); 1254 browser()->OpenBookmarkManager();
1255 observer.Wait(); 1255 observer.Wait();
1256 } 1256 }
1257 EXPECT_EQ(1, browser()->tab_count()); 1257 EXPECT_EQ(1, browser()->tab_count());
1258 EXPECT_EQ(GURL(chrome::kChromeUIBookmarksURL), 1258 EXPECT_EQ(GURL(chrome::kChromeUIBookmarksURL),
1259 browser()->GetSelectedWebContents()->GetURL()); 1259 browser()->GetActiveWebContents()->GetURL());
1260 } 1260 }
1261 1261
1262 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1262 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1263 NavigateFromDefaultToDownloadsInSameTab) { 1263 NavigateFromDefaultToDownloadsInSameTab) {
1264 { 1264 {
1265 ui_test_utils::WindowedNotificationObserver observer( 1265 ui_test_utils::WindowedNotificationObserver observer(
1266 content::NOTIFICATION_LOAD_STOP, 1266 content::NOTIFICATION_LOAD_STOP,
1267 content::NotificationService::AllSources()); 1267 content::NotificationService::AllSources());
1268 browser()->ShowDownloadsTab(); 1268 browser()->ShowDownloadsTab();
1269 observer.Wait(); 1269 observer.Wait();
1270 } 1270 }
1271 EXPECT_EQ(1, browser()->tab_count()); 1271 EXPECT_EQ(1, browser()->tab_count());
1272 EXPECT_EQ(GURL(chrome::kChromeUIDownloadsURL), 1272 EXPECT_EQ(GURL(chrome::kChromeUIDownloadsURL),
1273 browser()->GetSelectedWebContents()->GetURL()); 1273 browser()->GetActiveWebContents()->GetURL());
1274 } 1274 }
1275 1275
1276 // This test makes sure any link in a crashed panel page navigates to a tabbed 1276 // This test makes sure any link in a crashed panel page navigates to a tabbed
1277 // window. 1277 // window.
1278 class PanelBrowserNavigatorTest : public BrowserNavigatorTest { 1278 class PanelBrowserNavigatorTest : public BrowserNavigatorTest {
1279 protected: 1279 protected:
1280 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 1280 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
1281 command_line->AppendSwitch(switches::kEnablePanels); 1281 command_line->AppendSwitch(switches::kEnablePanels);
1282 } 1282 }
1283 }; 1283 };
(...skipping 17 matching lines...) Expand all
1301 // Navigate() should have navigated in the existing panel window. 1301 // Navigate() should have navigated in the existing panel window.
1302 EXPECT_EQ(panel_browser, p.browser); 1302 EXPECT_EQ(panel_browser, p.browser);
1303 1303
1304 // We should now have two windows, the browser() provided by the framework and 1304 // We should now have two windows, the browser() provided by the framework and
1305 // the panel window we opened earlier. The tabbed browser window has 1 tab. 1305 // the panel window we opened earlier. The tabbed browser window has 1 tab.
1306 EXPECT_EQ(2u, BrowserList::size()); 1306 EXPECT_EQ(2u, BrowserList::size());
1307 EXPECT_EQ(1, browser()->tab_count()); 1307 EXPECT_EQ(1, browser()->tab_count());
1308 EXPECT_EQ(1, panel_browser->tab_count()); 1308 EXPECT_EQ(1, panel_browser->tab_count());
1309 1309
1310 // Kill the panel page. 1310 // Kill the panel page.
1311 WebContents* web_contents = panel_browser->GetSelectedWebContents(); 1311 WebContents* web_contents = panel_browser->GetActiveWebContents();
1312 web_contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); 1312 web_contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1);
1313 EXPECT_TRUE(web_contents->IsCrashed()); 1313 EXPECT_TRUE(web_contents->IsCrashed());
1314 1314
1315 // Navigate to the page. 1315 // Navigate to the page.
1316 browser::NavigateParams p2(MakeNavigateParams(panel_browser)); 1316 browser::NavigateParams p2(MakeNavigateParams(panel_browser));
1317 p2.source_contents = panel_browser->GetSelectedTabContentsWrapper(); 1317 p2.source_contents = panel_browser->GetActiveTabContents();
1318 p2.url = url2; 1318 p2.url = url2;
1319 p2.disposition = CURRENT_TAB; 1319 p2.disposition = CURRENT_TAB;
1320 browser::Navigate(&p2); 1320 browser::Navigate(&p2);
1321 1321
1322 // Navigate() should have opened a new tab in the existing tabbed window. 1322 // Navigate() should have opened a new tab in the existing tabbed window.
1323 EXPECT_EQ(browser(), p2.browser); 1323 EXPECT_EQ(browser(), p2.browser);
1324 1324
1325 // We should now have two windows, the browser() provided by the framework and 1325 // We should now have two windows, the browser() provided by the framework and
1326 // the panel window we opened earlier. The tabbed browser window has 2 tabs. 1326 // the panel window we opened earlier. The tabbed browser window has 2 tabs.
1327 EXPECT_EQ(2u, BrowserList::size()); 1327 EXPECT_EQ(2u, BrowserList::size());
1328 EXPECT_EQ(2, browser()->tab_count()); 1328 EXPECT_EQ(2, browser()->tab_count());
1329 EXPECT_EQ(1, panel_browser->tab_count()); 1329 EXPECT_EQ(1, panel_browser->tab_count());
1330 } 1330 }
1331 1331
1332 } // namespace 1332 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_navigator_browsertest.h ('k') | chrome/browser/ui/browser_navigator_browsertest_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698