[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 5 | #include "chrome/browser/ui/browser_navigator_browsertest.h" |
| 6 | |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 7 | #include "base/command_line.h" |
[email protected] | 26c53e66 | 2011-07-09 02:21:02 | [diff] [blame] | 8 | #include "chrome/app/chrome_command_ids.h" |
| 9 | #include "chrome/browser/autocomplete/autocomplete_edit.h" |
[email protected] | 8ecad5e | 2010-12-02 21:18:33 | [diff] [blame] | 10 | #include "chrome/browser/profiles/profile.h" |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 11 | #include "chrome/browser/tabs/tab_strip_model.h" |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 12 | #include "chrome/browser/ui/browser_list.h" |
[email protected] | 339d6dd | 2010-11-12 00:41:58 | [diff] [blame] | 13 | #include "chrome/browser/ui/browser_navigator.h" |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 14 | #include "chrome/browser/ui/browser_window.h" |
[email protected] | 26c53e66 | 2011-07-09 02:21:02 | [diff] [blame] | 15 | #include "chrome/browser/ui/omnibox/location_bar.h" |
| 16 | #include "chrome/browser/ui/omnibox/omnibox_view.h" |
[email protected] | 6a3ec231 | 2010-12-02 19:30:19 | [diff] [blame] | 17 | #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 18 | #include "chrome/common/chrome_switches.h" |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 19 | #include "chrome/common/url_constants.h" |
[email protected] | af44e7fb | 2011-07-29 18:32:32 | [diff] [blame] | 20 | #include "chrome/test/base/ui_test_utils.h" |
[email protected] | 299425b | 2011-03-02 07:45:20 | [diff] [blame] | 21 | #include "content/browser/tab_contents/tab_contents.h" |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 22 | #include "content/browser/tab_contents/tab_contents_view.h" |
[email protected] | 0d6e9bd | 2011-10-18 04:29:16 | [diff] [blame^] | 23 | #include "content/public/browser/notification_types.h" |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 24 | |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 25 | namespace { |
| 26 | |
| 27 | GURL GetGoogleURL() { |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 28 | return GURL("http://www.google.com/"); |
| 29 | } |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 30 | |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 31 | GURL GetSettingsURL() { |
| 32 | return GURL(chrome::kChromeUISettingsURL); |
| 33 | } |
| 34 | |
| 35 | GURL GetSettingsAdvancedURL() { |
| 36 | return GURL(chrome::kChromeUISettingsURL).Resolve( |
| 37 | chrome::kAdvancedOptionsSubPage); |
| 38 | } |
| 39 | |
| 40 | GURL GetSettingsBrowserURL() { |
| 41 | return GURL(chrome::kChromeUISettingsURL).Resolve( |
| 42 | chrome::kBrowserOptionsSubPage); |
| 43 | } |
| 44 | |
| 45 | GURL GetSettingsPersonalURL() { |
| 46 | return GURL(chrome::kChromeUISettingsURL).Resolve( |
| 47 | chrome::kPersonalOptionsSubPage); |
| 48 | } |
| 49 | |
| 50 | } // namespace |
| 51 | |
| 52 | |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 53 | browser::NavigateParams BrowserNavigatorTest::MakeNavigateParams() const { |
| 54 | return MakeNavigateParams(browser()); |
| 55 | } |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 56 | |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 57 | browser::NavigateParams BrowserNavigatorTest::MakeNavigateParams( |
| 58 | Browser* browser) const { |
| 59 | browser::NavigateParams params(browser, GetGoogleURL(), |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 60 | content::PAGE_TRANSITION_LINK); |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 61 | params.window_action = browser::NavigateParams::SHOW_WINDOW; |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 62 | return params; |
| 63 | } |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 64 | |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 65 | Browser* BrowserNavigatorTest::CreateEmptyBrowserForType(Browser::Type type, |
| 66 | Profile* profile) { |
| 67 | Browser* browser = Browser::CreateForType(type, profile); |
| 68 | browser->AddBlankTab(true); |
| 69 | return browser; |
| 70 | } |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 71 | |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 72 | Browser* BrowserNavigatorTest::CreateEmptyBrowserForApp(Browser::Type type, |
| 73 | Profile* profile) { |
| 74 | Browser* browser = Browser::CreateForApp(Browser::TYPE_POPUP, "Test", |
[email protected] | 5c20924 | 2011-06-06 20:36:17 | [diff] [blame] | 75 | gfx::Rect(), profile); |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 76 | browser->AddBlankTab(true); |
| 77 | return browser; |
| 78 | } |
| 79 | |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 80 | TabContentsWrapper* BrowserNavigatorTest::CreateTabContents() { |
| 81 | return Browser::TabContentsFactory( |
| 82 | browser()->profile(), |
| 83 | NULL, |
| 84 | MSG_ROUTING_NONE, |
| 85 | browser()->GetSelectedTabContents(), |
| 86 | NULL); |
| 87 | } |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 88 | |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 89 | void BrowserNavigatorTest::RunSuppressTest(WindowOpenDisposition disposition) { |
| 90 | GURL old_url = browser()->GetSelectedTabContents()->GetURL(); |
| 91 | browser::NavigateParams p(MakeNavigateParams()); |
| 92 | p.disposition = disposition; |
| 93 | browser::Navigate(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 94 | |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 95 | // Nothing should have happened as a result of Navigate(); |
| 96 | EXPECT_EQ(1, browser()->tab_count()); |
| 97 | EXPECT_EQ(1u, BrowserList::size()); |
| 98 | EXPECT_EQ(old_url, browser()->GetSelectedTabContents()->GetURL()); |
| 99 | } |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 100 | |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 101 | void BrowserNavigatorTest::Observe(int type, |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 102 | const NotificationSource& source, |
| 103 | const NotificationDetails& details) { |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 104 | switch (type) { |
| 105 | case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB: { |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 106 | ++this->created_tab_contents_count_; |
| 107 | break; |
[email protected] | fa7ebe0 | 2010-11-29 23:04:57 | [diff] [blame] | 108 | } |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 109 | default: |
| 110 | break; |
[email protected] | fa7ebe0 | 2010-11-29 23:04:57 | [diff] [blame] | 111 | } |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 112 | } |
[email protected] | fa7ebe0 | 2010-11-29 23:04:57 | [diff] [blame] | 113 | |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 114 | |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 115 | namespace { |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 116 | |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 117 | // This test verifies that when a navigation occurs within a tab, the tab count |
| 118 | // of the Browser remains the same and the current tab bears the loaded URL. |
| 119 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_CurrentTab) { |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 120 | ui_test_utils::NavigateToURL(browser(), GetGoogleURL()); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 121 | EXPECT_EQ(GetGoogleURL(), browser()->GetSelectedTabContents()->GetURL()); |
| 122 | // We should have one window with one tab. |
| 123 | EXPECT_EQ(1u, BrowserList::size()); |
| 124 | EXPECT_EQ(1, browser()->tab_count()); |
| 125 | } |
| 126 | |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 127 | // This test verifies that a singleton tab is refocused if one is already opened |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 128 | // in another or an existing window, or added if it is not. |
| 129 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SingletonTabExisting) { |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 130 | GURL singleton_url1("http://maps.google.com/"); |
[email protected] | fa7ebe0 | 2010-11-29 23:04:57 | [diff] [blame] | 131 | |
| 132 | // Register for a notification if an additional tab_contents was instantiated. |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 133 | // Opening a Singleton tab that is already opened should not be opening a new |
[email protected] | fa7ebe0 | 2010-11-29 23:04:57 | [diff] [blame] | 134 | // tab nor be creating a new TabContents object |
| 135 | NotificationRegistrar registrar; |
| 136 | |
| 137 | // As the registrar object goes out of scope, this will get unregistered |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 138 | registrar.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, |
[email protected] | fa7ebe0 | 2010-11-29 23:04:57 | [diff] [blame] | 139 | NotificationService::AllSources()); |
| 140 | |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 141 | browser()->AddSelectedTabWithURL( |
| 142 | singleton_url1, content::PAGE_TRANSITION_LINK); |
| 143 | browser()->AddSelectedTabWithURL( |
| 144 | GetGoogleURL(), content::PAGE_TRANSITION_LINK); |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 145 | |
| 146 | // We should have one browser with 3 tabs, the 3rd selected. |
| 147 | EXPECT_EQ(1u, BrowserList::size()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 148 | EXPECT_EQ(2, browser()->active_index()); |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 149 | |
[email protected] | fa7ebe0 | 2010-11-29 23:04:57 | [diff] [blame] | 150 | unsigned int previous_tab_contents_count = |
| 151 | created_tab_contents_count_ = 0; |
| 152 | |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 153 | // Navigate to singleton_url1. |
| 154 | browser::NavigateParams p(MakeNavigateParams()); |
| 155 | p.disposition = SINGLETON_TAB; |
| 156 | p.url = singleton_url1; |
| 157 | browser::Navigate(&p); |
| 158 | |
| 159 | // The middle tab should now be selected. |
| 160 | EXPECT_EQ(browser(), p.browser); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 161 | EXPECT_EQ(1, browser()->active_index()); |
[email protected] | fa7ebe0 | 2010-11-29 23:04:57 | [diff] [blame] | 162 | |
| 163 | // No tab contents should have been created |
| 164 | EXPECT_EQ(previous_tab_contents_count, |
| 165 | created_tab_contents_count_); |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
[email protected] | 578c696 | 2011-08-24 22:06:40 | [diff] [blame] | 169 | Disposition_SingletonTabRespectingRef) { |
| 170 | GURL singleton_ref_url1("http://maps.google.com/#a"); |
| 171 | GURL singleton_ref_url2("http://maps.google.com/#b"); |
| 172 | GURL singleton_ref_url3("http://maps.google.com/"); |
| 173 | |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 174 | browser()->AddSelectedTabWithURL( |
| 175 | singleton_ref_url1, content::PAGE_TRANSITION_LINK); |
[email protected] | 578c696 | 2011-08-24 22:06:40 | [diff] [blame] | 176 | |
| 177 | // We should have one browser with 2 tabs, 2nd selected. |
| 178 | EXPECT_EQ(1u, BrowserList::size()); |
| 179 | EXPECT_EQ(2, browser()->tab_count()); |
| 180 | EXPECT_EQ(1, browser()->active_index()); |
| 181 | |
| 182 | // Navigate to singleton_url2. |
| 183 | browser::NavigateParams p(MakeNavigateParams()); |
| 184 | p.disposition = SINGLETON_TAB; |
| 185 | p.url = singleton_ref_url2; |
| 186 | browser::Navigate(&p); |
| 187 | |
| 188 | // We should now have 2 tabs, the 2nd one selected. |
| 189 | EXPECT_EQ(browser(), p.browser); |
| 190 | EXPECT_EQ(2, browser()->tab_count()); |
| 191 | EXPECT_EQ(1, browser()->active_index()); |
| 192 | |
| 193 | // Navigate to singleton_url2, but with respect ref set. |
| 194 | p = MakeNavigateParams(); |
| 195 | p.disposition = SINGLETON_TAB; |
| 196 | p.url = singleton_ref_url2; |
| 197 | p.ref_behavior = browser::NavigateParams::RESPECT_REF; |
| 198 | browser::Navigate(&p); |
| 199 | |
| 200 | // We should now have 3 tabs, the 3th one selected. |
| 201 | EXPECT_EQ(browser(), p.browser); |
| 202 | EXPECT_EQ(3, browser()->tab_count()); |
| 203 | EXPECT_EQ(2, browser()->active_index()); |
| 204 | |
| 205 | // Navigate to singleton_url3. |
| 206 | p = MakeNavigateParams(); |
| 207 | p.disposition = SINGLETON_TAB; |
| 208 | p.url = singleton_ref_url3; |
| 209 | p.ref_behavior = browser::NavigateParams::RESPECT_REF; |
| 210 | browser::Navigate(&p); |
| 211 | |
| 212 | // We should now have 4 tabs, the 4th one selected. |
| 213 | EXPECT_EQ(browser(), p.browser); |
| 214 | EXPECT_EQ(4, browser()->tab_count()); |
| 215 | EXPECT_EQ(3, browser()->active_index()); |
| 216 | } |
| 217 | |
| 218 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 219 | Disposition_SingletonTabNoneExisting) { |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 220 | GURL singleton_url1("http://maps.google.com/"); |
| 221 | |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 222 | // We should have one browser with 1 tab. |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 223 | EXPECT_EQ(1u, BrowserList::size()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 224 | EXPECT_EQ(0, browser()->active_index()); |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 225 | |
| 226 | // Navigate to singleton_url1. |
| 227 | browser::NavigateParams p(MakeNavigateParams()); |
| 228 | p.disposition = SINGLETON_TAB; |
| 229 | p.url = singleton_url1; |
| 230 | browser::Navigate(&p); |
| 231 | |
| 232 | // We should now have 2 tabs, the 2nd one selected. |
| 233 | EXPECT_EQ(browser(), p.browser); |
| 234 | EXPECT_EQ(2, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 235 | EXPECT_EQ(1, browser()->active_index()); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | // This test verifies that when a navigation results in a foreground tab, the |
| 239 | // tab count of the Browser increases and the selected tab shifts to the new |
| 240 | // foreground tab. |
| 241 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewForegroundTab) { |
| 242 | TabContents* old_contents = browser()->GetSelectedTabContents(); |
| 243 | browser::NavigateParams p(MakeNavigateParams()); |
| 244 | p.disposition = NEW_FOREGROUND_TAB; |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 245 | browser::Navigate(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 246 | EXPECT_NE(old_contents, browser()->GetSelectedTabContents()); |
[email protected] | 3c9e187 | 2010-11-18 16:17:49 | [diff] [blame] | 247 | EXPECT_EQ(browser()->GetSelectedTabContentsWrapper(), p.target_contents); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 248 | EXPECT_EQ(2, browser()->tab_count()); |
| 249 | } |
| 250 | |
| 251 | // This test verifies that when a navigation results in a background tab, the |
| 252 | // tab count of the Browser increases but the selected tab remains the same. |
| 253 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewBackgroundTab) { |
| 254 | TabContents* old_contents = browser()->GetSelectedTabContents(); |
| 255 | browser::NavigateParams p(MakeNavigateParams()); |
| 256 | p.disposition = NEW_BACKGROUND_TAB; |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 257 | browser::Navigate(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 258 | TabContents* new_contents = browser()->GetSelectedTabContents(); |
| 259 | // The selected tab should have remained unchanged, since the new tab was |
| 260 | // opened in the background. |
| 261 | EXPECT_EQ(old_contents, new_contents); |
| 262 | EXPECT_EQ(2, browser()->tab_count()); |
| 263 | } |
| 264 | |
| 265 | // This test verifies that when a navigation requiring a new foreground tab |
| 266 | // occurs in a Browser that cannot host multiple tabs, the new foreground tab |
| 267 | // is created in an existing compatible Browser. |
| 268 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 269 | Disposition_IncompatibleWindow_Existing) { |
| 270 | // Open a foreground tab in a window that cannot open popups when there is an |
| 271 | // existing compatible window somewhere else that they can be opened within. |
| 272 | Browser* popup = CreateEmptyBrowserForType(Browser::TYPE_POPUP, |
| 273 | browser()->profile()); |
| 274 | browser::NavigateParams p(MakeNavigateParams(popup)); |
| 275 | p.disposition = NEW_FOREGROUND_TAB; |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 276 | browser::Navigate(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 277 | |
| 278 | // Navigate() should have opened the tab in a different browser since the |
| 279 | // one we supplied didn't support additional tabs. |
| 280 | EXPECT_NE(popup, p.browser); |
| 281 | |
| 282 | // Since browser() is an existing compatible tabbed browser, it should have |
| 283 | // opened the tab there. |
| 284 | EXPECT_EQ(browser(), p.browser); |
| 285 | |
| 286 | // We should be left with 2 windows, the popup with one tab and the browser() |
| 287 | // provided by the framework with two. |
| 288 | EXPECT_EQ(2u, BrowserList::size()); |
| 289 | EXPECT_EQ(1, popup->tab_count()); |
| 290 | EXPECT_EQ(2, browser()->tab_count()); |
| 291 | } |
| 292 | |
| 293 | // This test verifies that when a navigation requiring a new foreground tab |
| 294 | // occurs in a Browser that cannot host multiple tabs and no compatible Browser |
| 295 | // that can is open, a compatible Browser is created. |
| 296 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 297 | Disposition_IncompatibleWindow_NoExisting) { |
| 298 | // We want to simulate not being able to find an existing window compatible |
| 299 | // with our non-tabbed browser window so Navigate() is forced to create a |
| 300 | // new compatible window. Because browser() supplied by the in-process |
| 301 | // browser testing framework is compatible with browser()->profile(), we |
| 302 | // need a different profile, and creating a popup window with an incognito |
| 303 | // profile is a quick and dirty way of achieving this. |
| 304 | Browser* popup = CreateEmptyBrowserForType( |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 305 | Browser::TYPE_POPUP, |
| 306 | browser()->profile()->GetOffTheRecordProfile()); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 307 | browser::NavigateParams p(MakeNavigateParams(popup)); |
| 308 | p.disposition = NEW_FOREGROUND_TAB; |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 309 | browser::Navigate(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 310 | |
| 311 | // Navigate() should have opened the tab in a different browser since the |
| 312 | // one we supplied didn't support additional tabs. |
| 313 | EXPECT_NE(popup, p.browser); |
| 314 | |
| 315 | // This time, browser() is _not_ compatible with popup since it is not an |
| 316 | // incognito window. |
| 317 | EXPECT_NE(browser(), p.browser); |
| 318 | |
| 319 | // We should have three windows, each with one tab: |
| 320 | // 1. the browser() provided by the framework (unchanged in this test) |
| 321 | // 2. the incognito popup we created originally |
| 322 | // 3. the new incognito tabbed browser that was created by Navigate(). |
| 323 | EXPECT_EQ(3u, BrowserList::size()); |
| 324 | EXPECT_EQ(1, browser()->tab_count()); |
| 325 | EXPECT_EQ(1, popup->tab_count()); |
| 326 | EXPECT_EQ(1, p.browser->tab_count()); |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 327 | EXPECT_TRUE(p.browser->is_type_tabbed()); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP |
| 331 | // from a normal Browser results in a new Browser with TYPE_POPUP. |
| 332 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopup) { |
| 333 | browser::NavigateParams p(MakeNavigateParams()); |
| 334 | p.disposition = NEW_POPUP; |
[email protected] | 588300d | 2011-04-28 21:06:35 | [diff] [blame] | 335 | p.window_bounds = gfx::Rect(0, 0, 200, 200); |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 336 | // Wait for new popup to to load and gain focus. |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 337 | ui_test_utils::NavigateToURL(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 338 | |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 339 | // Navigate() should have opened a new, focused popup window. |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 340 | EXPECT_NE(browser(), p.browser); |
[email protected] | 9db263a | 2011-04-15 20:53:47 | [diff] [blame] | 341 | #if 0 |
| 342 | // TODO(stevenjb): Enable this test. See: crbug.com/79493 |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 343 | EXPECT_TRUE(p.browser->window()->IsActive()); |
| 344 | #endif |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 345 | EXPECT_TRUE(p.browser->is_type_popup()); |
| 346 | EXPECT_FALSE(p.browser->is_app()); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 347 | |
| 348 | // We should have two windows, the browser() provided by the framework and the |
| 349 | // new popup window. |
| 350 | EXPECT_EQ(2u, BrowserList::size()); |
| 351 | EXPECT_EQ(1, browser()->tab_count()); |
| 352 | EXPECT_EQ(1, p.browser->tab_count()); |
| 353 | } |
| 354 | |
| 355 | // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP |
[email protected] | f112b0f | 2011-05-26 01:53:52 | [diff] [blame] | 356 | // from a normal Browser results in a new Browser with is_app() true. |
| 357 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopup_ExtensionId) { |
| 358 | browser::NavigateParams p(MakeNavigateParams()); |
| 359 | p.disposition = NEW_POPUP; |
| 360 | p.extension_app_id = "extensionappid"; |
| 361 | p.window_bounds = gfx::Rect(0, 0, 200, 200); |
[email protected] | f112b0f | 2011-05-26 01:53:52 | [diff] [blame] | 362 | // Wait for new popup to to load and gain focus. |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 363 | ui_test_utils::NavigateToURL(&p); |
[email protected] | f112b0f | 2011-05-26 01:53:52 | [diff] [blame] | 364 | |
| 365 | // Navigate() should have opened a new, focused popup window. |
| 366 | EXPECT_NE(browser(), p.browser); |
| 367 | EXPECT_TRUE(p.browser->is_type_popup()); |
| 368 | EXPECT_TRUE(p.browser->is_app()); |
| 369 | |
| 370 | // We should have two windows, the browser() provided by the framework and the |
| 371 | // new popup window. |
| 372 | EXPECT_EQ(2u, BrowserList::size()); |
| 373 | EXPECT_EQ(1, browser()->tab_count()); |
| 374 | EXPECT_EQ(1, p.browser->tab_count()); |
| 375 | } |
| 376 | |
| 377 | // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP |
[email protected] | 300d1e5 | 2011-01-19 23:57:57 | [diff] [blame] | 378 | // from a normal popup results in a new Browser with TYPE_POPUP. |
| 379 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupFromPopup) { |
| 380 | // Open a popup. |
| 381 | browser::NavigateParams p1(MakeNavigateParams()); |
| 382 | p1.disposition = NEW_POPUP; |
[email protected] | 588300d | 2011-04-28 21:06:35 | [diff] [blame] | 383 | p1.window_bounds = gfx::Rect(0, 0, 200, 200); |
[email protected] | 300d1e5 | 2011-01-19 23:57:57 | [diff] [blame] | 384 | browser::Navigate(&p1); |
| 385 | // Open another popup. |
| 386 | browser::NavigateParams p2(MakeNavigateParams(p1.browser)); |
| 387 | p2.disposition = NEW_POPUP; |
[email protected] | 588300d | 2011-04-28 21:06:35 | [diff] [blame] | 388 | p2.window_bounds = gfx::Rect(0, 0, 200, 200); |
[email protected] | 300d1e5 | 2011-01-19 23:57:57 | [diff] [blame] | 389 | browser::Navigate(&p2); |
| 390 | |
| 391 | // Navigate() should have opened a new normal popup window. |
| 392 | EXPECT_NE(p1.browser, p2.browser); |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 393 | EXPECT_TRUE(p2.browser->is_type_popup()); |
| 394 | EXPECT_FALSE(p2.browser->is_app()); |
[email protected] | 300d1e5 | 2011-01-19 23:57:57 | [diff] [blame] | 395 | |
| 396 | // We should have three windows, the browser() provided by the framework, |
| 397 | // the first popup window, and the second popup window. |
| 398 | EXPECT_EQ(3u, BrowserList::size()); |
| 399 | EXPECT_EQ(1, browser()->tab_count()); |
| 400 | EXPECT_EQ(1, p1.browser->tab_count()); |
| 401 | EXPECT_EQ(1, p2.browser->tab_count()); |
| 402 | } |
| 403 | |
| 404 | // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 405 | // from an app frame results in a new Browser with TYPE_APP_POPUP. |
| 406 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 407 | Disposition_NewPopupFromAppWindow) { |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 408 | Browser* app_browser = CreateEmptyBrowserForApp(Browser::TYPE_TABBED, |
| 409 | browser()->profile()); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 410 | browser::NavigateParams p(MakeNavigateParams(app_browser)); |
| 411 | p.disposition = NEW_POPUP; |
[email protected] | 588300d | 2011-04-28 21:06:35 | [diff] [blame] | 412 | p.window_bounds = gfx::Rect(0, 0, 200, 200); |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 413 | browser::Navigate(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 414 | |
| 415 | // Navigate() should have opened a new popup app window. |
| 416 | EXPECT_NE(app_browser, p.browser); |
| 417 | EXPECT_NE(browser(), p.browser); |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 418 | EXPECT_TRUE(p.browser->is_type_popup()); |
| 419 | EXPECT_TRUE(p.browser->is_app()); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 420 | |
| 421 | // We should now have three windows, the app window, the app popup it created, |
| 422 | // and the original browser() provided by the framework. |
| 423 | EXPECT_EQ(3u, BrowserList::size()); |
| 424 | EXPECT_EQ(1, browser()->tab_count()); |
| 425 | EXPECT_EQ(1, app_browser->tab_count()); |
| 426 | EXPECT_EQ(1, p.browser->tab_count()); |
| 427 | } |
| 428 | |
| 429 | // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP |
[email protected] | 300d1e5 | 2011-01-19 23:57:57 | [diff] [blame] | 430 | // from an app popup results in a new Browser also of TYPE_APP_POPUP. |
| 431 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 432 | Disposition_NewPopupFromAppPopup) { |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 433 | Browser* app_browser = CreateEmptyBrowserForApp(Browser::TYPE_TABBED, |
| 434 | browser()->profile()); |
[email protected] | 300d1e5 | 2011-01-19 23:57:57 | [diff] [blame] | 435 | // Open an app popup. |
| 436 | browser::NavigateParams p1(MakeNavigateParams(app_browser)); |
| 437 | p1.disposition = NEW_POPUP; |
[email protected] | 588300d | 2011-04-28 21:06:35 | [diff] [blame] | 438 | p1.window_bounds = gfx::Rect(0, 0, 200, 200); |
[email protected] | 300d1e5 | 2011-01-19 23:57:57 | [diff] [blame] | 439 | browser::Navigate(&p1); |
| 440 | // Now open another app popup. |
| 441 | browser::NavigateParams p2(MakeNavigateParams(p1.browser)); |
| 442 | p2.disposition = NEW_POPUP; |
[email protected] | 588300d | 2011-04-28 21:06:35 | [diff] [blame] | 443 | p2.window_bounds = gfx::Rect(0, 0, 200, 200); |
[email protected] | 300d1e5 | 2011-01-19 23:57:57 | [diff] [blame] | 444 | browser::Navigate(&p2); |
| 445 | |
| 446 | // Navigate() should have opened a new popup app window. |
| 447 | EXPECT_NE(browser(), p1.browser); |
| 448 | EXPECT_NE(p1.browser, p2.browser); |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 449 | EXPECT_TRUE(p2.browser->is_type_popup()); |
| 450 | EXPECT_TRUE(p2.browser->is_app()); |
[email protected] | 300d1e5 | 2011-01-19 23:57:57 | [diff] [blame] | 451 | |
| 452 | // We should now have four windows, the app window, the first app popup, |
| 453 | // the second app popup, and the original browser() provided by the framework. |
| 454 | EXPECT_EQ(4u, BrowserList::size()); |
| 455 | EXPECT_EQ(1, browser()->tab_count()); |
| 456 | EXPECT_EQ(1, app_browser->tab_count()); |
| 457 | EXPECT_EQ(1, p1.browser->tab_count()); |
| 458 | EXPECT_EQ(1, p2.browser->tab_count()); |
| 459 | } |
| 460 | |
| 461 | // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 462 | // from an extension app tab results in a new Browser with TYPE_APP_POPUP. |
| 463 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 464 | Disposition_NewPopupFromExtensionApp) { |
| 465 | // TODO(beng): TBD. |
| 466 | } |
| 467 | |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 468 | // This test verifies that navigating with window_action = SHOW_WINDOW_INACTIVE |
| 469 | // does not focus a new new popup window. |
| 470 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupUnfocused) { |
| 471 | browser::NavigateParams p(MakeNavigateParams()); |
| 472 | p.disposition = NEW_POPUP; |
[email protected] | 588300d | 2011-04-28 21:06:35 | [diff] [blame] | 473 | p.window_bounds = gfx::Rect(0, 0, 200, 200); |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 474 | p.window_action = browser::NavigateParams::SHOW_WINDOW_INACTIVE; |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 475 | // Wait for new popup to load (and gain focus if the test fails). |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 476 | ui_test_utils::NavigateToURL(&p); |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 477 | |
| 478 | // Navigate() should have opened a new, unfocused, popup window. |
| 479 | EXPECT_NE(browser(), p.browser); |
| 480 | EXPECT_EQ(Browser::TYPE_POPUP, p.browser->type()); |
[email protected] | 9db263a | 2011-04-15 20:53:47 | [diff] [blame] | 481 | #if 0 |
| 482 | // TODO(stevenjb): Enable this test. See: crbug.com/79493 |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 483 | EXPECT_FALSE(p.browser->window()->IsActive()); |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 484 | #endif |
[email protected] | 9db263a | 2011-04-15 20:53:47 | [diff] [blame] | 485 | } |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 486 | |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 487 | // This test verifies that navigating with WindowOpenDisposition = NEW_WINDOW |
| 488 | // always opens a new window. |
| 489 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewWindow) { |
| 490 | browser::NavigateParams p(MakeNavigateParams()); |
| 491 | p.disposition = NEW_WINDOW; |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 492 | browser::Navigate(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 493 | |
| 494 | // Navigate() should have opened a new toplevel window. |
| 495 | EXPECT_NE(browser(), p.browser); |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 496 | EXPECT_TRUE(p.browser->is_type_tabbed()); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 497 | |
| 498 | // We should now have two windows, the browser() provided by the framework and |
| 499 | // the new normal window. |
| 500 | EXPECT_EQ(2u, BrowserList::size()); |
| 501 | EXPECT_EQ(1, browser()->tab_count()); |
| 502 | EXPECT_EQ(1, p.browser->tab_count()); |
| 503 | } |
| 504 | |
| 505 | // This test verifies that navigating with WindowOpenDisposition = INCOGNITO |
| 506 | // opens a new incognito window if no existing incognito window is present. |
| 507 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_Incognito) { |
| 508 | browser::NavigateParams p(MakeNavigateParams()); |
| 509 | p.disposition = OFF_THE_RECORD; |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 510 | browser::Navigate(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 511 | |
| 512 | // Navigate() should have opened a new toplevel incognito window. |
| 513 | EXPECT_NE(browser(), p.browser); |
| 514 | EXPECT_EQ(browser()->profile()->GetOffTheRecordProfile(), |
| 515 | p.browser->profile()); |
| 516 | |
[email protected] | d7ff359 | 2010-11-30 21:50:46 | [diff] [blame] | 517 | // |source_contents| should be set to NULL because the profile for the new |
| 518 | // page is different from the originating page. |
| 519 | EXPECT_EQ(NULL, p.source_contents); |
| 520 | |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 521 | // We should now have two windows, the browser() provided by the framework and |
| 522 | // the new incognito window. |
| 523 | EXPECT_EQ(2u, BrowserList::size()); |
| 524 | EXPECT_EQ(1, browser()->tab_count()); |
| 525 | EXPECT_EQ(1, p.browser->tab_count()); |
| 526 | } |
| 527 | |
| 528 | // This test verifies that navigating with WindowOpenDisposition = INCOGNITO |
| 529 | // reuses an existing incognito window when possible. |
| 530 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_IncognitoRefocus) { |
| 531 | Browser* incognito_browser = |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 532 | CreateEmptyBrowserForType(Browser::TYPE_TABBED, |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 533 | browser()->profile()->GetOffTheRecordProfile()); |
| 534 | browser::NavigateParams p(MakeNavigateParams()); |
| 535 | p.disposition = OFF_THE_RECORD; |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 536 | browser::Navigate(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 537 | |
| 538 | // Navigate() should have opened a new tab in the existing incognito window. |
| 539 | EXPECT_NE(browser(), p.browser); |
| 540 | EXPECT_EQ(p.browser, incognito_browser); |
| 541 | |
| 542 | // We should now have two windows, the browser() provided by the framework and |
| 543 | // the incognito window we opened earlier. |
| 544 | EXPECT_EQ(2u, BrowserList::size()); |
| 545 | EXPECT_EQ(1, browser()->tab_count()); |
| 546 | EXPECT_EQ(2, incognito_browser->tab_count()); |
| 547 | } |
| 548 | |
| 549 | // This test verifies that no navigation action occurs when |
| 550 | // WindowOpenDisposition = SUPPRESS_OPEN. |
| 551 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SuppressOpen) { |
| 552 | RunSuppressTest(SUPPRESS_OPEN); |
| 553 | } |
| 554 | |
| 555 | // This test verifies that no navigation action occurs when |
| 556 | // WindowOpenDisposition = SAVE_TO_DISK. |
| 557 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SaveToDisk) { |
| 558 | RunSuppressTest(SAVE_TO_DISK); |
| 559 | } |
| 560 | |
| 561 | // This test verifies that no navigation action occurs when |
| 562 | // WindowOpenDisposition = IGNORE_ACTION. |
| 563 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_IgnoreAction) { |
| 564 | RunSuppressTest(IGNORE_ACTION); |
| 565 | } |
| 566 | |
| 567 | // This tests adding a foreground tab with a predefined TabContents. |
| 568 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, TargetContents_ForegroundTab) { |
| 569 | browser::NavigateParams p(MakeNavigateParams()); |
| 570 | p.disposition = NEW_FOREGROUND_TAB; |
| 571 | p.target_contents = CreateTabContents(); |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 572 | browser::Navigate(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 573 | |
| 574 | // Navigate() should have opened the contents in a new foreground in the |
| 575 | // current Browser. |
| 576 | EXPECT_EQ(browser(), p.browser); |
[email protected] | 3c9e187 | 2010-11-18 16:17:49 | [diff] [blame] | 577 | EXPECT_EQ(browser()->GetSelectedTabContentsWrapper(), p.target_contents); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 578 | |
| 579 | // We should have one window, with two tabs. |
| 580 | EXPECT_EQ(1u, BrowserList::size()); |
| 581 | EXPECT_EQ(2, browser()->tab_count()); |
| 582 | } |
| 583 | |
| 584 | #if defined(OS_WIN) |
| 585 | // This tests adding a popup with a predefined TabContents. |
[email protected] | 76edb67 | 2011-03-04 21:48:39 | [diff] [blame] | 586 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, DISABLED_TargetContents_Popup) { |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 587 | browser::NavigateParams p(MakeNavigateParams()); |
| 588 | p.disposition = NEW_POPUP; |
| 589 | p.target_contents = CreateTabContents(); |
| 590 | p.window_bounds = gfx::Rect(10, 10, 500, 500); |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 591 | browser::Navigate(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 592 | |
| 593 | // Navigate() should have opened a new popup window. |
| 594 | EXPECT_NE(browser(), p.browser); |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 595 | EXPECT_TRUE(p.browser->is_type_popup()); |
| 596 | EXPECT_FALSE(p.browser->is_app()); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 597 | |
| 598 | // The web platform is weird. The window bounds specified in |
| 599 | // |p.window_bounds| are used as follows: |
| 600 | // - the origin is used to position the window |
| 601 | // - the size is used to size the TabContents of the window. |
| 602 | // As such the position of the resulting window will always match |
| 603 | // p.window_bounds.origin(), but its size will not. We need to match |
| 604 | // the size against the selected tab's view's container size. |
| 605 | // Only Windows positions the window according to |p.window_bounds.origin()| - |
| 606 | // on Mac the window is offset from the opener and on Linux it always opens |
| 607 | // at 0,0. |
| 608 | EXPECT_EQ(p.window_bounds.origin(), |
| 609 | p.browser->window()->GetRestoredBounds().origin()); |
| 610 | // All platforms should respect size however provided width > 400 (Mac has a |
| 611 | // minimum window width of 400). |
| 612 | EXPECT_EQ(p.window_bounds.size(), |
[email protected] | 3c9e187 | 2010-11-18 16:17:49 | [diff] [blame] | 613 | p.target_contents->tab_contents()->view()->GetContainerSize()); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 614 | |
| 615 | // We should have two windows, the new popup and the browser() provided by the |
| 616 | // framework. |
| 617 | EXPECT_EQ(2u, BrowserList::size()); |
| 618 | EXPECT_EQ(1, browser()->tab_count()); |
| 619 | EXPECT_EQ(1, p.browser->tab_count()); |
| 620 | } |
| 621 | #endif |
| 622 | |
| 623 | // This tests adding a tab at a specific index. |
| 624 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Tabstrip_InsertAtIndex) { |
| 625 | // This is not meant to be a comprehensive test of whether or not the tab |
| 626 | // implementation of the browser observes the insertion index. That is |
| 627 | // covered by the unit tests for TabStripModel. This merely verifies that |
| 628 | // insertion index preference is reflected in common cases. |
| 629 | browser::NavigateParams p(MakeNavigateParams()); |
| 630 | p.disposition = NEW_FOREGROUND_TAB; |
| 631 | p.tabstrip_index = 0; |
| 632 | p.tabstrip_add_types = TabStripModel::ADD_FORCE_INDEX; |
[email protected] | 19d9f3a | 2010-10-14 21:49:36 | [diff] [blame] | 633 | browser::Navigate(&p); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 634 | |
| 635 | // Navigate() should have inserted a new tab at slot 0 in the tabstrip. |
| 636 | EXPECT_EQ(browser(), p.browser); |
| 637 | EXPECT_EQ(0, browser()->tabstrip_model()->GetIndexOfTabContents( |
[email protected] | 3c9e187 | 2010-11-18 16:17:49 | [diff] [blame] | 638 | static_cast<const TabContentsWrapper*>(p.target_contents))); |
[email protected] | a1feae5 | 2010-10-11 22:14:45 | [diff] [blame] | 639 | |
| 640 | // We should have one window - the browser() provided by the framework. |
| 641 | EXPECT_EQ(1u, BrowserList::size()); |
| 642 | EXPECT_EQ(2, browser()->tab_count()); |
| 643 | } |
| 644 | |
[email protected] | 2dd8548 | 2010-11-06 01:56:47 | [diff] [blame] | 645 | // This test verifies that constructing params with a NULL browser has |
| 646 | // the same result as navigating to a new foreground tab in the (only) |
| 647 | // active browser. Tests are the same as for Disposition_NewForegroundTab. |
| 648 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_NewForegroundTab) { |
| 649 | TabContents* old_contents = browser()->GetSelectedTabContents(); |
| 650 | // Navigate with a NULL browser. |
| 651 | browser::NavigateParams p(MakeNavigateParams(NULL)); |
| 652 | p.disposition = NEW_FOREGROUND_TAB; |
| 653 | p.profile = browser()->profile(); |
| 654 | browser::Navigate(&p); |
| 655 | |
| 656 | // Navigate() should have found browser() and create a new tab. |
| 657 | EXPECT_EQ(browser(), p.browser); |
| 658 | EXPECT_NE(old_contents, browser()->GetSelectedTabContents()); |
[email protected] | 3c9e187 | 2010-11-18 16:17:49 | [diff] [blame] | 659 | EXPECT_EQ(browser()->GetSelectedTabContentsWrapper(), p.target_contents); |
[email protected] | 2dd8548 | 2010-11-06 01:56:47 | [diff] [blame] | 660 | EXPECT_EQ(2, browser()->tab_count()); |
| 661 | } |
| 662 | |
| 663 | // This test verifies that constructing params with a NULL browser and |
| 664 | // a specific profile matches the specified profile. |
[email protected] | c8a31a7 | 2011-09-30 01:53:32 | [diff] [blame] | 665 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_MatchProfile) { |
[email protected] | 2dd8548 | 2010-11-06 01:56:47 | [diff] [blame] | 666 | // Create a new browser with using the incognito profile. |
| 667 | Browser* incognito = |
| 668 | Browser::Create(browser()->profile()->GetOffTheRecordProfile()); |
| 669 | |
| 670 | // Navigate with a NULL browser and the incognito profile. |
| 671 | browser::NavigateParams p(MakeNavigateParams(NULL)); |
| 672 | p.disposition = NEW_FOREGROUND_TAB; |
| 673 | p.profile = incognito->profile(); |
| 674 | browser::Navigate(&p); |
| 675 | |
| 676 | // Navigate() should have found incognito, not browser(). |
| 677 | EXPECT_EQ(incognito, p.browser); |
[email protected] | 3c9e187 | 2010-11-18 16:17:49 | [diff] [blame] | 678 | EXPECT_EQ(incognito->GetSelectedTabContentsWrapper(), p.target_contents); |
[email protected] | 2dd8548 | 2010-11-06 01:56:47 | [diff] [blame] | 679 | EXPECT_EQ(1, incognito->tab_count()); |
| 680 | } |
| 681 | |
| 682 | // This test verifies that constructing params with a NULL browser and |
| 683 | // disposition = NEW_WINDOW always opens exactly one new window. |
| 684 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_NewWindow) { |
| 685 | browser::NavigateParams p(MakeNavigateParams(NULL)); |
| 686 | p.disposition = NEW_WINDOW; |
| 687 | p.profile = browser()->profile(); |
| 688 | browser::Navigate(&p); |
| 689 | |
| 690 | // Navigate() should have created a new browser. |
| 691 | EXPECT_NE(browser(), p.browser); |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 692 | EXPECT_TRUE( p.browser->is_type_tabbed()); |
[email protected] | 2dd8548 | 2010-11-06 01:56:47 | [diff] [blame] | 693 | |
| 694 | // We should now have two windows, the browser() provided by the framework and |
| 695 | // the new normal window. |
| 696 | EXPECT_EQ(2u, BrowserList::size()); |
| 697 | EXPECT_EQ(1, browser()->tab_count()); |
| 698 | EXPECT_EQ(1, p.browser->tab_count()); |
| 699 | } |
| 700 | |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 701 | // This test verifies that constructing params with disposition = SINGLETON_TAB |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 702 | // and IGNORE_AND_NAVIGATE opens a new tab navigated to the specified URL if |
[email protected] | 67ed83e | 2011-01-07 22:54:00 | [diff] [blame] | 703 | // no previous tab with that URL (minus the path) exists. |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 704 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 705 | Disposition_SingletonTabNew_IgnorePath) { |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 706 | browser()->AddSelectedTabWithURL( |
| 707 | GetGoogleURL(), content::PAGE_TRANSITION_LINK); |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 708 | |
| 709 | // We should have one browser with 2 tabs, the 2nd selected. |
| 710 | EXPECT_EQ(1u, BrowserList::size()); |
| 711 | EXPECT_EQ(2, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 712 | EXPECT_EQ(1, browser()->active_index()); |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 713 | |
| 714 | // Navigate to a new singleton tab with a sub-page. |
| 715 | browser::NavigateParams p(MakeNavigateParams()); |
| 716 | p.disposition = SINGLETON_TAB; |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 717 | p.url = GetSettingsAdvancedURL(); |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 718 | p.window_action = browser::NavigateParams::SHOW_WINDOW; |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 719 | p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 720 | browser::Navigate(&p); |
| 721 | |
| 722 | // The last tab should now be selected and navigated to the sub-page of the |
| 723 | // URL. |
| 724 | EXPECT_EQ(browser(), p.browser); |
| 725 | EXPECT_EQ(3, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 726 | EXPECT_EQ(2, browser()->active_index()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 727 | EXPECT_EQ(GetSettingsAdvancedURL(), |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 728 | browser()->GetSelectedTabContents()->GetURL()); |
| 729 | } |
| 730 | |
| 731 | // This test verifies that constructing params with disposition = SINGLETON_TAB |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 732 | // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 733 | // the path) which is navigated to the specified URL. |
| 734 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 735 | Disposition_SingletonTabExisting_IgnorePath) { |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 736 | GURL singleton_url1(GetSettingsURL()); |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 737 | browser()->AddSelectedTabWithURL( |
| 738 | singleton_url1, content::PAGE_TRANSITION_LINK); |
| 739 | browser()->AddSelectedTabWithURL( |
| 740 | GetGoogleURL(), content::PAGE_TRANSITION_LINK); |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 741 | |
| 742 | // We should have one browser with 3 tabs, the 3rd selected. |
| 743 | EXPECT_EQ(1u, BrowserList::size()); |
| 744 | EXPECT_EQ(3, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 745 | EXPECT_EQ(2, browser()->active_index()); |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 746 | |
| 747 | // Navigate to singleton_url1. |
| 748 | browser::NavigateParams p(MakeNavigateParams()); |
| 749 | p.disposition = SINGLETON_TAB; |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 750 | p.url = GetSettingsAdvancedURL(); |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 751 | p.window_action = browser::NavigateParams::SHOW_WINDOW; |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 752 | p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 753 | browser::Navigate(&p); |
| 754 | |
| 755 | // The middle tab should now be selected and navigated to the sub-page of the |
| 756 | // URL. |
| 757 | EXPECT_EQ(browser(), p.browser); |
| 758 | EXPECT_EQ(3, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 759 | EXPECT_EQ(1, browser()->active_index()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 760 | EXPECT_EQ(GetSettingsAdvancedURL(), |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 761 | browser()->GetSelectedTabContents()->GetURL()); |
| 762 | } |
| 763 | |
| 764 | // This test verifies that constructing params with disposition = SINGLETON_TAB |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 765 | // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 766 | // the path) which is navigated to the specified URL. |
| 767 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 768 | Disposition_SingletonTabExistingSubPath_IgnorePath) { |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 769 | GURL singleton_url1(GetSettingsAdvancedURL()); |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 770 | browser()->AddSelectedTabWithURL( |
| 771 | singleton_url1, content::PAGE_TRANSITION_LINK); |
| 772 | browser()->AddSelectedTabWithURL( |
| 773 | GetGoogleURL(), content::PAGE_TRANSITION_LINK); |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 774 | |
| 775 | // We should have one browser with 3 tabs, the 3rd selected. |
| 776 | EXPECT_EQ(1u, BrowserList::size()); |
| 777 | EXPECT_EQ(3, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 778 | EXPECT_EQ(2, browser()->active_index()); |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 779 | |
| 780 | // Navigate to singleton_url1. |
| 781 | browser::NavigateParams p(MakeNavigateParams()); |
| 782 | p.disposition = SINGLETON_TAB; |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 783 | p.url = GetSettingsPersonalURL(); |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 784 | p.window_action = browser::NavigateParams::SHOW_WINDOW; |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 785 | p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 786 | browser::Navigate(&p); |
| 787 | |
| 788 | // The middle tab should now be selected and navigated to the sub-page of the |
| 789 | // URL. |
| 790 | EXPECT_EQ(browser(), p.browser); |
| 791 | EXPECT_EQ(3, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 792 | EXPECT_EQ(1, browser()->active_index()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 793 | EXPECT_EQ(GetSettingsPersonalURL(), |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 794 | browser()->GetSelectedTabContents()->GetURL()); |
| 795 | } |
[email protected] | 2dd8548 | 2010-11-06 01:56:47 | [diff] [blame] | 796 | |
[email protected] | 637b344 | 2011-01-10 23:31:48 | [diff] [blame] | 797 | // This test verifies that constructing params with disposition = SINGLETON_TAB |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 798 | // and IGNORE_AND_STAY_PUT opens an existing tab with the matching URL (minus |
| 799 | // the path). |
| 800 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 801 | Disposition_SingletonTabExistingSubPath_IgnorePath2) { |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 802 | GURL singleton_url1(GetSettingsAdvancedURL()); |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 803 | browser()->AddSelectedTabWithURL( |
| 804 | singleton_url1, content::PAGE_TRANSITION_LINK); |
| 805 | browser()->AddSelectedTabWithURL( |
| 806 | GetGoogleURL(), content::PAGE_TRANSITION_LINK); |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 807 | |
| 808 | // We should have one browser with 3 tabs, the 3rd selected. |
| 809 | EXPECT_EQ(1u, BrowserList::size()); |
| 810 | EXPECT_EQ(3, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 811 | EXPECT_EQ(2, browser()->active_index()); |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 812 | |
| 813 | // Navigate to singleton_url1. |
| 814 | browser::NavigateParams p(MakeNavigateParams()); |
| 815 | p.disposition = SINGLETON_TAB; |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 816 | p.url = GetSettingsPersonalURL(); |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 817 | p.window_action = browser::NavigateParams::SHOW_WINDOW; |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 818 | p.path_behavior = browser::NavigateParams::IGNORE_AND_STAY_PUT; |
| 819 | browser::Navigate(&p); |
| 820 | |
| 821 | // The middle tab should now be selected. |
| 822 | EXPECT_EQ(browser(), p.browser); |
| 823 | EXPECT_EQ(3, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 824 | EXPECT_EQ(1, browser()->active_index()); |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 825 | EXPECT_EQ(singleton_url1, |
| 826 | browser()->GetSelectedTabContents()->GetURL()); |
| 827 | } |
| 828 | |
| 829 | // This test verifies that constructing params with disposition = SINGLETON_TAB |
| 830 | // and IGNORE_AND_NAVIGATE will update the current tab's URL if the currently |
[email protected] | 637b344 | 2011-01-10 23:31:48 | [diff] [blame] | 831 | // selected tab is a match but has a different path. |
| 832 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 833 | Disposition_SingletonTabFocused_IgnorePath) { |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 834 | GURL singleton_url_current(GetSettingsAdvancedURL()); |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 835 | browser()->AddSelectedTabWithURL( |
| 836 | singleton_url_current, content::PAGE_TRANSITION_LINK); |
[email protected] | 637b344 | 2011-01-10 23:31:48 | [diff] [blame] | 837 | |
| 838 | // We should have one browser with 2 tabs, the 2nd selected. |
| 839 | EXPECT_EQ(1u, BrowserList::size()); |
| 840 | EXPECT_EQ(2, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 841 | EXPECT_EQ(1, browser()->active_index()); |
[email protected] | 637b344 | 2011-01-10 23:31:48 | [diff] [blame] | 842 | |
| 843 | // Navigate to a different settings path. |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 844 | GURL singleton_url_target(GetSettingsPersonalURL()); |
[email protected] | 637b344 | 2011-01-10 23:31:48 | [diff] [blame] | 845 | browser::NavigateParams p(MakeNavigateParams()); |
| 846 | p.disposition = SINGLETON_TAB; |
| 847 | p.url = singleton_url_target; |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 848 | p.window_action = browser::NavigateParams::SHOW_WINDOW; |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 849 | p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
[email protected] | 637b344 | 2011-01-10 23:31:48 | [diff] [blame] | 850 | browser::Navigate(&p); |
| 851 | |
| 852 | // The second tab should still be selected, but navigated to the new path. |
| 853 | EXPECT_EQ(browser(), p.browser); |
| 854 | EXPECT_EQ(2, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 855 | EXPECT_EQ(1, browser()->active_index()); |
[email protected] | 637b344 | 2011-01-10 23:31:48 | [diff] [blame] | 856 | EXPECT_EQ(singleton_url_target, |
| 857 | browser()->GetSelectedTabContents()->GetURL()); |
| 858 | } |
| 859 | |
[email protected] | 07afd7c | 2011-02-17 10:07:11 | [diff] [blame] | 860 | // This test verifies that constructing params with disposition = SINGLETON_TAB |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 861 | // and IGNORE_AND_NAVIGATE will open an existing matching tab with a different |
| 862 | // query. |
[email protected] | 07afd7c | 2011-02-17 10:07:11 | [diff] [blame] | 863 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 864 | Disposition_SingletonTabExisting_IgnoreQuery) { |
| 865 | int initial_tab_count = browser()->tab_count(); |
| 866 | GURL singleton_url_current("chrome://settings/internet"); |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 867 | browser()->AddSelectedTabWithURL( |
| 868 | singleton_url_current, content::PAGE_TRANSITION_LINK); |
[email protected] | 07afd7c | 2011-02-17 10:07:11 | [diff] [blame] | 869 | |
| 870 | EXPECT_EQ(initial_tab_count + 1, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 871 | EXPECT_EQ(initial_tab_count, browser()->active_index()); |
[email protected] | 07afd7c | 2011-02-17 10:07:11 | [diff] [blame] | 872 | |
| 873 | // Navigate to a different settings path. |
| 874 | GURL singleton_url_target( |
| 875 | "chrome://settings/internet?" |
| 876 | "servicePath=/profile/ethernet_00aa00aa00aa&networkType=1"); |
| 877 | browser::NavigateParams p(MakeNavigateParams()); |
| 878 | p.disposition = SINGLETON_TAB; |
| 879 | p.url = singleton_url_target; |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 880 | p.window_action = browser::NavigateParams::SHOW_WINDOW; |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 881 | p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
[email protected] | 07afd7c | 2011-02-17 10:07:11 | [diff] [blame] | 882 | browser::Navigate(&p); |
| 883 | |
| 884 | // Last tab should still be selected. |
| 885 | EXPECT_EQ(browser(), p.browser); |
| 886 | EXPECT_EQ(initial_tab_count + 1, browser()->tab_count()); |
[email protected] | 1ea49d5 | 2011-04-12 17:44:44 | [diff] [blame] | 887 | EXPECT_EQ(initial_tab_count, browser()->active_index()); |
[email protected] | 07afd7c | 2011-02-17 10:07:11 | [diff] [blame] | 888 | } |
| 889 | |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 890 | // This test verifies that the settings page isn't opened in the incognito |
| 891 | // window. |
| 892 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 893 | Disposition_Settings_UseNonIncognitoWindow) { |
| 894 | Browser* incognito_browser = CreateIncognitoBrowser(); |
| 895 | |
| 896 | EXPECT_EQ(2u, BrowserList::size()); |
| 897 | EXPECT_EQ(1, browser()->tab_count()); |
| 898 | EXPECT_EQ(1, incognito_browser->tab_count()); |
| 899 | |
| 900 | // Navigate to the settings page. |
| 901 | browser::NavigateParams p(MakeNavigateParams(incognito_browser)); |
| 902 | p.disposition = SINGLETON_TAB; |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 903 | p.url = GetSettingsURL(); |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 904 | p.window_action = browser::NavigateParams::SHOW_WINDOW; |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 905 | browser::Navigate(&p); |
| 906 | |
| 907 | // The settings page should be opened in browser() window. |
| 908 | EXPECT_NE(incognito_browser, p.browser); |
| 909 | EXPECT_EQ(browser(), p.browser); |
| 910 | EXPECT_EQ(2, browser()->tab_count()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 911 | EXPECT_EQ(GetSettingsURL(), |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 912 | browser()->GetSelectedTabContents()->GetURL()); |
| 913 | } |
| 914 | |
[email protected] | 82404cd | 2011-07-12 19:55:14 | [diff] [blame] | 915 | // This test verifies that the settings page isn't opened in the incognito |
| 916 | // window from a non-incognito window (bookmark open-in-incognito trigger). |
| 917 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 918 | Disposition_Settings_UseNonIncognitoWindowForBookmark) { |
| 919 | browser::NavigateParams params(browser(), GURL("chrome://settings"), |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 920 | content::PAGE_TRANSITION_AUTO_BOOKMARK); |
[email protected] | 82404cd | 2011-07-12 19:55:14 | [diff] [blame] | 921 | params.disposition = OFF_THE_RECORD; |
| 922 | { |
| 923 | ui_test_utils::WindowedNotificationObserver observer( |
| 924 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 925 | browser::Navigate(¶ms); |
| 926 | observer.Wait(); |
| 927 | } |
| 928 | |
| 929 | EXPECT_EQ(1u, BrowserList::size()); |
| 930 | EXPECT_EQ(GURL("chrome://settings"), |
| 931 | browser()->GetSelectedTabContents()->GetURL().GetOrigin()); |
| 932 | } |
| 933 | |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 934 | // This test verifies that the bookmarks page isn't opened in the incognito |
| 935 | // window. |
| 936 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 937 | Disposition_Bookmarks_UseNonIncognitoWindow) { |
| 938 | Browser* incognito_browser = CreateIncognitoBrowser(); |
| 939 | |
| 940 | EXPECT_EQ(2u, BrowserList::size()); |
| 941 | EXPECT_EQ(1, browser()->tab_count()); |
| 942 | EXPECT_EQ(1, incognito_browser->tab_count()); |
| 943 | |
| 944 | // Navigate to the settings page. |
| 945 | browser::NavigateParams p(MakeNavigateParams(incognito_browser)); |
| 946 | p.disposition = SINGLETON_TAB; |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 947 | p.url = GURL(chrome::kChromeUIBookmarksURL); |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 948 | p.window_action = browser::NavigateParams::SHOW_WINDOW; |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 949 | browser::Navigate(&p); |
| 950 | |
| 951 | // The bookmarks page should be opened in browser() window. |
| 952 | EXPECT_NE(incognito_browser, p.browser); |
| 953 | EXPECT_EQ(browser(), p.browser); |
| 954 | EXPECT_EQ(2, browser()->tab_count()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 955 | EXPECT_EQ(GURL(chrome::kChromeUIBookmarksURL), |
[email protected] | bd817c2 | 2011-02-09 08:16:46 | [diff] [blame] | 956 | browser()->GetSelectedTabContents()->GetURL()); |
| 957 | } |
| 958 | |
[email protected] | 7de53c6 | 2011-05-13 06:44:16 | [diff] [blame] | 959 | // This test makes sure a crashed singleton tab reloads from a new navigation. |
| 960 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 961 | NavigateToCrashedSingletonTab) { |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 962 | GURL singleton_url(GetSettingsAdvancedURL()); |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 963 | TabContentsWrapper* wrapper = browser()->AddSelectedTabWithURL( |
| 964 | singleton_url, content::PAGE_TRANSITION_LINK); |
[email protected] | 7de53c6 | 2011-05-13 06:44:16 | [diff] [blame] | 965 | TabContents* tab_contents = wrapper->tab_contents(); |
| 966 | |
| 967 | // We should have one browser with 2 tabs, the 2nd selected. |
| 968 | EXPECT_EQ(1u, BrowserList::size()); |
| 969 | EXPECT_EQ(2, browser()->tab_count()); |
| 970 | EXPECT_EQ(1, browser()->active_index()); |
| 971 | |
| 972 | // Kill the singleton tab. |
| 973 | tab_contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); |
| 974 | EXPECT_TRUE(tab_contents->is_crashed()); |
| 975 | |
| 976 | browser::NavigateParams p(MakeNavigateParams()); |
| 977 | p.disposition = SINGLETON_TAB; |
| 978 | p.url = singleton_url; |
| 979 | p.window_action = browser::NavigateParams::SHOW_WINDOW; |
| 980 | p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 981 | ui_test_utils::NavigateToURL(&p); |
[email protected] | 7de53c6 | 2011-05-13 06:44:16 | [diff] [blame] | 982 | |
| 983 | // The tab should not be sad anymore. |
| 984 | EXPECT_FALSE(tab_contents->is_crashed()); |
| 985 | } |
| 986 | |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 987 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 988 | NavigateFromDefaultToOptionsInSameTab) { |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 989 | { |
| 990 | ui_test_utils::WindowedNotificationObserver observer( |
| 991 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 992 | browser()->OpenOptionsDialog(); |
| 993 | observer.Wait(); |
| 994 | } |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 995 | EXPECT_EQ(1, browser()->tab_count()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 996 | EXPECT_EQ(GetSettingsURL(), |
| 997 | browser()->GetSelectedTabContents()->GetURL().GetOrigin()); |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 998 | } |
| 999 | |
| 1000 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 1001 | NavigateFromBlankToOptionsInSameTab) { |
| 1002 | browser::NavigateParams p(MakeNavigateParams()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1003 | p.url = GURL(chrome::kAboutBlankURL); |
| 1004 | ui_test_utils::NavigateToURL(&p); |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1005 | |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1006 | { |
| 1007 | ui_test_utils::WindowedNotificationObserver observer( |
| 1008 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 1009 | browser()->OpenOptionsDialog(); |
| 1010 | observer.Wait(); |
| 1011 | } |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1012 | EXPECT_EQ(1, browser()->tab_count()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1013 | EXPECT_EQ(GetSettingsURL(), |
| 1014 | browser()->GetSelectedTabContents()->GetURL().GetOrigin()); |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1015 | } |
| 1016 | |
| 1017 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 1018 | NavigateFromNTPToOptionsInSameTab) { |
| 1019 | browser::NavigateParams p(MakeNavigateParams()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1020 | p.url = GURL(chrome::kChromeUINewTabURL); |
| 1021 | ui_test_utils::NavigateToURL(&p); |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1022 | EXPECT_EQ(1, browser()->tab_count()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1023 | EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1024 | browser()->GetSelectedTabContents()->GetURL()); |
| 1025 | |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1026 | { |
| 1027 | ui_test_utils::WindowedNotificationObserver observer( |
| 1028 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 1029 | browser()->OpenOptionsDialog(); |
| 1030 | observer.Wait(); |
| 1031 | } |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1032 | EXPECT_EQ(1, browser()->tab_count()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1033 | EXPECT_EQ(GetSettingsURL(), |
| 1034 | browser()->GetSelectedTabContents()->GetURL().GetOrigin()); |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1035 | } |
| 1036 | |
| 1037 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 1038 | NavigateFromPageToOptionsInNewTab) { |
| 1039 | browser::NavigateParams p(MakeNavigateParams()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1040 | ui_test_utils::NavigateToURL(&p); |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1041 | EXPECT_EQ(GetGoogleURL(), browser()->GetSelectedTabContents()->GetURL()); |
| 1042 | EXPECT_EQ(1u, BrowserList::size()); |
| 1043 | EXPECT_EQ(1, browser()->tab_count()); |
| 1044 | |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1045 | { |
| 1046 | ui_test_utils::WindowedNotificationObserver observer( |
| 1047 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 1048 | browser()->OpenOptionsDialog(); |
| 1049 | observer.Wait(); |
| 1050 | } |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1051 | EXPECT_EQ(2, browser()->tab_count()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1052 | EXPECT_EQ(GetSettingsURL(), |
| 1053 | browser()->GetSelectedTabContents()->GetURL().GetOrigin()); |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1054 | } |
| 1055 | |
| 1056 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 1057 | NavigateFromNTPToOptionsSingleton) { |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1058 | { |
| 1059 | ui_test_utils::WindowedNotificationObserver observer( |
| 1060 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 1061 | browser()->OpenOptionsDialog(); |
| 1062 | observer.Wait(); |
| 1063 | } |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1064 | EXPECT_EQ(1, browser()->tab_count()); |
| 1065 | |
| 1066 | browser()->NewTab(); |
| 1067 | EXPECT_EQ(2, browser()->tab_count()); |
| 1068 | |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1069 | { |
| 1070 | ui_test_utils::WindowedNotificationObserver observer( |
| 1071 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 1072 | browser()->OpenOptionsDialog(); |
| 1073 | observer.Wait(); |
| 1074 | } |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1075 | EXPECT_EQ(2, browser()->tab_count()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1076 | EXPECT_EQ(GetSettingsURL(), |
| 1077 | browser()->GetSelectedTabContents()->GetURL().GetOrigin()); |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1078 | } |
| 1079 | |
| 1080 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 1081 | NavigateFromNTPToOptionsPageInSameTab) { |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1082 | { |
| 1083 | ui_test_utils::WindowedNotificationObserver observer( |
| 1084 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 1085 | browser()->ShowOptionsTab(chrome::kPersonalOptionsSubPage); |
| 1086 | observer.Wait(); |
| 1087 | } |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1088 | EXPECT_EQ(1, browser()->tab_count()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1089 | EXPECT_EQ(GetSettingsPersonalURL(), |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1090 | browser()->GetSelectedTabContents()->GetURL()); |
| 1091 | |
| 1092 | browser()->NewTab(); |
| 1093 | EXPECT_EQ(2, browser()->tab_count()); |
| 1094 | |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1095 | { |
| 1096 | ui_test_utils::WindowedNotificationObserver observer( |
| 1097 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 1098 | browser()->ShowOptionsTab(chrome::kPersonalOptionsSubPage); |
| 1099 | observer.Wait(); |
| 1100 | } |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1101 | EXPECT_EQ(2, browser()->tab_count()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1102 | EXPECT_EQ(GetSettingsPersonalURL(), |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1103 | browser()->GetSelectedTabContents()->GetURL()); |
| 1104 | } |
| 1105 | |
| 1106 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 1107 | NavigateFromOtherTabToSingletonOptions) { |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1108 | { |
| 1109 | ui_test_utils::WindowedNotificationObserver observer( |
| 1110 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 1111 | browser()->OpenOptionsDialog(); |
| 1112 | observer.Wait(); |
| 1113 | } |
| 1114 | { |
| 1115 | ui_test_utils::WindowedNotificationObserver observer( |
| 1116 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 1117 | browser()->AddSelectedTabWithURL( |
| 1118 | GetGoogleURL(), content::PAGE_TRANSITION_LINK); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1119 | observer.Wait(); |
| 1120 | } |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1121 | |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1122 | { |
| 1123 | ui_test_utils::WindowedNotificationObserver observer( |
| 1124 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 1125 | browser()->OpenOptionsDialog(); |
| 1126 | observer.Wait(); |
| 1127 | } |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1128 | EXPECT_EQ(2, browser()->tab_count()); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1129 | EXPECT_EQ(GetSettingsURL(), |
| 1130 | browser()->GetSelectedTabContents()->GetURL().GetOrigin()); |
[email protected] | fcca741b | 2011-06-17 22:46:37 | [diff] [blame] | 1131 | } |
| 1132 | |
[email protected] | 26c53e66 | 2011-07-09 02:21:02 | [diff] [blame] | 1133 | // Tests that when a new tab is opened from the omnibox, the focus is moved from |
| 1134 | // the omnibox for the current tab. |
| 1135 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 1136 | NavigateFromOmniboxIntoNewTab) { |
| 1137 | GURL url("http://www.google.com/"); |
| 1138 | GURL url2("http://maps.google.com/"); |
| 1139 | |
| 1140 | // Navigate to url. |
| 1141 | browser::NavigateParams p(MakeNavigateParams()); |
| 1142 | p.disposition = CURRENT_TAB; |
| 1143 | p.url = url; |
| 1144 | browser::Navigate(&p); |
| 1145 | |
| 1146 | // Focus the omnibox. |
| 1147 | browser()->FocusLocationBar(); |
| 1148 | |
| 1149 | AutocompleteEditController* controller = |
| 1150 | browser()->window()->GetLocationBar()->location_entry()->model()-> |
| 1151 | controller(); |
| 1152 | |
| 1153 | // Simulate an alt-enter. |
| 1154 | controller->OnAutocompleteAccept(url2, NEW_FOREGROUND_TAB, |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 1155 | content::PAGE_TRANSITION_TYPED, GURL()); |
[email protected] | 26c53e66 | 2011-07-09 02:21:02 | [diff] [blame] | 1156 | |
| 1157 | // Make sure the second tab is selected. |
| 1158 | EXPECT_EQ(1, browser()->active_index()); |
| 1159 | |
| 1160 | // The tab contents should have the focus in the second tab. |
| 1161 | EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), |
| 1162 | VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
| 1163 | |
| 1164 | // Go back to the first tab. The focus should not be in the omnibox. |
| 1165 | browser()->SelectPreviousTab(); |
| 1166 | EXPECT_EQ(0, browser()->active_index()); |
| 1167 | EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), |
| 1168 | VIEW_ID_LOCATION_BAR)); |
| 1169 | } |
| 1170 | |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1171 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 1172 | NavigateFromDefaultToHistoryInSameTab) { |
| 1173 | { |
| 1174 | ui_test_utils::WindowedNotificationObserver observer( |
| 1175 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 1176 | browser()->ShowHistoryTab(); |
| 1177 | observer.Wait(); |
| 1178 | } |
| 1179 | EXPECT_EQ(1, browser()->tab_count()); |
| 1180 | EXPECT_EQ(GURL(chrome::kChromeUIHistoryURL), |
| 1181 | browser()->GetSelectedTabContents()->GetURL()); |
| 1182 | } |
| 1183 | |
| 1184 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 1185 | NavigateFromDefaultToBookmarksInSameTab) { |
| 1186 | { |
| 1187 | ui_test_utils::WindowedNotificationObserver observer( |
| 1188 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
[email protected] | 0af8f13 | 2011-07-16 01:37:02 | [diff] [blame] | 1189 | browser()->OpenBookmarkManager(); |
[email protected] | ddddfda | 2011-07-14 23:19:39 | [diff] [blame] | 1190 | observer.Wait(); |
| 1191 | } |
| 1192 | EXPECT_EQ(1, browser()->tab_count()); |
| 1193 | EXPECT_EQ(GURL(chrome::kChromeUIBookmarksURL), |
| 1194 | browser()->GetSelectedTabContents()->GetURL()); |
| 1195 | } |
| 1196 | |
| 1197 | IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
| 1198 | NavigateFromDefaultToDownloadsInSameTab) { |
| 1199 | { |
| 1200 | ui_test_utils::WindowedNotificationObserver observer( |
| 1201 | content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
| 1202 | browser()->ShowDownloadsTab(); |
| 1203 | observer.Wait(); |
| 1204 | } |
| 1205 | EXPECT_EQ(1, browser()->tab_count()); |
| 1206 | EXPECT_EQ(GURL(chrome::kChromeUIDownloadsURL), |
| 1207 | browser()->GetSelectedTabContents()->GetURL()); |
| 1208 | } |
| 1209 | |
| 1210 | } // namespace |