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

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

Issue 10698068: chrome: Put browser_navigator.h into chrome namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: already in chrome namespace Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "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/prefs/incognito_mode_prefs.h" 9 #include "chrome/browser/prefs/incognito_mode_prefs.h"
10 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 GURL GetContentSettingsURL() { 47 GURL GetContentSettingsURL() {
48 return GetSettingsURL().Resolve(chrome::kContentSettingsExceptionsSubPage); 48 return GetSettingsURL().Resolve(chrome::kContentSettingsExceptionsSubPage);
49 } 49 }
50 50
51 GURL GetClearBrowsingDataURL() { 51 GURL GetClearBrowsingDataURL() {
52 return GetSettingsURL().Resolve(chrome::kClearBrowserDataSubPage); 52 return GetSettingsURL().Resolve(chrome::kClearBrowserDataSubPage);
53 } 53 }
54 54
55 } // namespace 55 } // namespace
56 56
57 browser::NavigateParams BrowserNavigatorTest::MakeNavigateParams() const { 57 chrome::NavigateParams BrowserNavigatorTest::MakeNavigateParams() const {
58 return MakeNavigateParams(browser()); 58 return MakeNavigateParams(browser());
59 } 59 }
60 60
61 browser::NavigateParams BrowserNavigatorTest::MakeNavigateParams( 61 chrome::NavigateParams BrowserNavigatorTest::MakeNavigateParams(
62 Browser* browser) const { 62 Browser* browser) const {
63 browser::NavigateParams params(browser, GetGoogleURL(), 63 chrome::NavigateParams params(browser, GetGoogleURL(),
64 content::PAGE_TRANSITION_LINK); 64 content::PAGE_TRANSITION_LINK);
65 params.window_action = browser::NavigateParams::SHOW_WINDOW; 65 params.window_action = chrome::NavigateParams::SHOW_WINDOW;
66 return params; 66 return params;
67 } 67 }
68 68
69 Browser* BrowserNavigatorTest::CreateEmptyBrowserForType(Browser::Type type, 69 Browser* BrowserNavigatorTest::CreateEmptyBrowserForType(Browser::Type type,
70 Profile* profile) { 70 Profile* profile) {
71 Browser* browser = Browser::CreateWithParams( 71 Browser* browser = Browser::CreateWithParams(
72 Browser::CreateParams(type, profile)); 72 Browser::CreateParams(type, profile));
73 browser->AddBlankTab(true); 73 browser->AddBlankTab(true);
74 return browser; 74 return browser;
75 } 75 }
(...skipping 11 matching lines...) Expand all
87 return chrome::TabContentsFactory( 87 return chrome::TabContentsFactory(
88 browser()->profile(), 88 browser()->profile(),
89 NULL, 89 NULL,
90 MSG_ROUTING_NONE, 90 MSG_ROUTING_NONE,
91 chrome::GetActiveWebContents(browser()), 91 chrome::GetActiveWebContents(browser()),
92 NULL); 92 NULL);
93 } 93 }
94 94
95 void BrowserNavigatorTest::RunSuppressTest(WindowOpenDisposition disposition) { 95 void BrowserNavigatorTest::RunSuppressTest(WindowOpenDisposition disposition) {
96 GURL old_url = chrome::GetActiveWebContents(browser())->GetURL(); 96 GURL old_url = chrome::GetActiveWebContents(browser())->GetURL();
97 browser::NavigateParams p(MakeNavigateParams()); 97 chrome::NavigateParams p(MakeNavigateParams());
98 p.disposition = disposition; 98 p.disposition = disposition;
99 browser::Navigate(&p); 99 chrome::Navigate(&p);
100 100
101 // Nothing should have happened as a result of Navigate(); 101 // Nothing should have happened as a result of Navigate();
102 EXPECT_EQ(1, browser()->tab_count()); 102 EXPECT_EQ(1, browser()->tab_count());
103 EXPECT_EQ(1u, BrowserList::size()); 103 EXPECT_EQ(1u, BrowserList::size());
104 EXPECT_EQ(old_url, chrome::GetActiveWebContents(browser())->GetURL()); 104 EXPECT_EQ(old_url, chrome::GetActiveWebContents(browser())->GetURL());
105 } 105 }
106 106
107 void BrowserNavigatorTest::RunUseNonIncognitoWindowTest(const GURL& url) { 107 void BrowserNavigatorTest::RunUseNonIncognitoWindowTest(const GURL& url) {
108 Browser* incognito_browser = CreateIncognitoBrowser(); 108 Browser* incognito_browser = CreateIncognitoBrowser();
109 109
110 EXPECT_EQ(2u, BrowserList::size()); 110 EXPECT_EQ(2u, BrowserList::size());
111 EXPECT_EQ(1, browser()->tab_count()); 111 EXPECT_EQ(1, browser()->tab_count());
112 EXPECT_EQ(1, incognito_browser->tab_count()); 112 EXPECT_EQ(1, incognito_browser->tab_count());
113 113
114 // Navigate to the page. 114 // Navigate to the page.
115 browser::NavigateParams p(MakeNavigateParams(incognito_browser)); 115 chrome::NavigateParams p(MakeNavigateParams(incognito_browser));
116 p.disposition = SINGLETON_TAB; 116 p.disposition = SINGLETON_TAB;
117 p.url = url; 117 p.url = url;
118 p.window_action = browser::NavigateParams::SHOW_WINDOW; 118 p.window_action = chrome::NavigateParams::SHOW_WINDOW;
119 browser::Navigate(&p); 119 chrome::Navigate(&p);
120 120
121 // This page should be opened in browser() window. 121 // This page should be opened in browser() window.
122 EXPECT_NE(incognito_browser, p.browser); 122 EXPECT_NE(incognito_browser, p.browser);
123 EXPECT_EQ(browser(), p.browser); 123 EXPECT_EQ(browser(), p.browser);
124 EXPECT_EQ(2, browser()->tab_count()); 124 EXPECT_EQ(2, browser()->tab_count());
125 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL()); 125 EXPECT_EQ(url, chrome::GetActiveWebContents(browser())->GetURL());
126 } 126 }
127 127
128 void BrowserNavigatorTest::RunDoNothingIfIncognitoIsForcedTest( 128 void BrowserNavigatorTest::RunDoNothingIfIncognitoIsForcedTest(
129 const GURL& url) { 129 const GURL& url) {
130 Browser* browser = CreateIncognitoBrowser(); 130 Browser* browser = CreateIncognitoBrowser();
131 131
132 // Set kIncognitoModeAvailability to FORCED. 132 // Set kIncognitoModeAvailability to FORCED.
133 PrefService* prefs1 = browser->profile()->GetPrefs(); 133 PrefService* prefs1 = browser->profile()->GetPrefs();
134 prefs1->SetInteger(prefs::kIncognitoModeAvailability, 134 prefs1->SetInteger(prefs::kIncognitoModeAvailability,
135 IncognitoModePrefs::FORCED); 135 IncognitoModePrefs::FORCED);
136 PrefService* prefs2 = browser->profile()->GetOriginalProfile()->GetPrefs(); 136 PrefService* prefs2 = browser->profile()->GetOriginalProfile()->GetPrefs();
137 prefs2->SetInteger(prefs::kIncognitoModeAvailability, 137 prefs2->SetInteger(prefs::kIncognitoModeAvailability,
138 IncognitoModePrefs::FORCED); 138 IncognitoModePrefs::FORCED);
139 139
140 // Navigate to the page. 140 // Navigate to the page.
141 browser::NavigateParams p(MakeNavigateParams(browser)); 141 chrome::NavigateParams p(MakeNavigateParams(browser));
142 p.disposition = OFF_THE_RECORD; 142 p.disposition = OFF_THE_RECORD;
143 p.url = url; 143 p.url = url;
144 p.window_action = browser::NavigateParams::SHOW_WINDOW; 144 p.window_action = chrome::NavigateParams::SHOW_WINDOW;
145 browser::Navigate(&p); 145 chrome::Navigate(&p);
146 146
147 // The page should not be opened. 147 // The page should not be opened.
148 EXPECT_EQ(browser, p.browser); 148 EXPECT_EQ(browser, p.browser);
149 EXPECT_EQ(1, browser->tab_count()); 149 EXPECT_EQ(1, browser->tab_count());
150 EXPECT_EQ(GURL(chrome::kAboutBlankURL), 150 EXPECT_EQ(GURL(chrome::kAboutBlankURL),
151 chrome::GetActiveWebContents(browser)->GetURL()); 151 chrome::GetActiveWebContents(browser)->GetURL());
152 } 152 }
153 153
154 void BrowserNavigatorTest::Observe( 154 void BrowserNavigatorTest::Observe(
155 int type, 155 int type,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 content::PAGE_TRANSITION_LINK); 198 content::PAGE_TRANSITION_LINK);
199 199
200 // We should have one browser with 3 tabs, the 3rd selected. 200 // We should have one browser with 3 tabs, the 3rd selected.
201 EXPECT_EQ(1u, BrowserList::size()); 201 EXPECT_EQ(1u, BrowserList::size());
202 EXPECT_EQ(2, browser()->active_index()); 202 EXPECT_EQ(2, browser()->active_index());
203 203
204 unsigned int previous_tab_contents_count = 204 unsigned int previous_tab_contents_count =
205 created_tab_contents_count_ = 0; 205 created_tab_contents_count_ = 0;
206 206
207 // Navigate to singleton_url1. 207 // Navigate to singleton_url1.
208 browser::NavigateParams p(MakeNavigateParams()); 208 chrome::NavigateParams p(MakeNavigateParams());
209 p.disposition = SINGLETON_TAB; 209 p.disposition = SINGLETON_TAB;
210 p.url = singleton_url1; 210 p.url = singleton_url1;
211 browser::Navigate(&p); 211 chrome::Navigate(&p);
212 212
213 // The middle tab should now be selected. 213 // The middle tab should now be selected.
214 EXPECT_EQ(browser(), p.browser); 214 EXPECT_EQ(browser(), p.browser);
215 EXPECT_EQ(1, browser()->active_index()); 215 EXPECT_EQ(1, browser()->active_index());
216 216
217 // No tab contents should have been created 217 // No tab contents should have been created
218 EXPECT_EQ(previous_tab_contents_count, 218 EXPECT_EQ(previous_tab_contents_count,
219 created_tab_contents_count_); 219 created_tab_contents_count_);
220 } 220 }
221 221
222 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 222 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
223 Disposition_SingletonTabRespectingRef) { 223 Disposition_SingletonTabRespectingRef) {
224 GURL singleton_ref_url1("http://maps.google.com/#a"); 224 GURL singleton_ref_url1("http://maps.google.com/#a");
225 GURL singleton_ref_url2("http://maps.google.com/#b"); 225 GURL singleton_ref_url2("http://maps.google.com/#b");
226 GURL singleton_ref_url3("http://maps.google.com/"); 226 GURL singleton_ref_url3("http://maps.google.com/");
227 227
228 chrome::AddSelectedTabWithURL(browser(), singleton_ref_url1, 228 chrome::AddSelectedTabWithURL(browser(), singleton_ref_url1,
229 content::PAGE_TRANSITION_LINK); 229 content::PAGE_TRANSITION_LINK);
230 230
231 // We should have one browser with 2 tabs, 2nd selected. 231 // We should have one browser with 2 tabs, 2nd selected.
232 EXPECT_EQ(1u, BrowserList::size()); 232 EXPECT_EQ(1u, BrowserList::size());
233 EXPECT_EQ(2, browser()->tab_count()); 233 EXPECT_EQ(2, browser()->tab_count());
234 EXPECT_EQ(1, browser()->active_index()); 234 EXPECT_EQ(1, browser()->active_index());
235 235
236 // Navigate to singleton_url2. 236 // Navigate to singleton_url2.
237 browser::NavigateParams p(MakeNavigateParams()); 237 chrome::NavigateParams p(MakeNavigateParams());
238 p.disposition = SINGLETON_TAB; 238 p.disposition = SINGLETON_TAB;
239 p.url = singleton_ref_url2; 239 p.url = singleton_ref_url2;
240 browser::Navigate(&p); 240 chrome::Navigate(&p);
241 241
242 // We should now have 2 tabs, the 2nd one selected. 242 // We should now have 2 tabs, the 2nd one selected.
243 EXPECT_EQ(browser(), p.browser); 243 EXPECT_EQ(browser(), p.browser);
244 EXPECT_EQ(2, browser()->tab_count()); 244 EXPECT_EQ(2, browser()->tab_count());
245 EXPECT_EQ(1, browser()->active_index()); 245 EXPECT_EQ(1, browser()->active_index());
246 246
247 // Navigate to singleton_url2, but with respect ref set. 247 // Navigate to singleton_url2, but with respect ref set.
248 p = MakeNavigateParams(); 248 p = MakeNavigateParams();
249 p.disposition = SINGLETON_TAB; 249 p.disposition = SINGLETON_TAB;
250 p.url = singleton_ref_url2; 250 p.url = singleton_ref_url2;
251 p.ref_behavior = browser::NavigateParams::RESPECT_REF; 251 p.ref_behavior = chrome::NavigateParams::RESPECT_REF;
252 browser::Navigate(&p); 252 chrome::Navigate(&p);
253 253
254 // We should now have 3 tabs, the 3th one selected. 254 // We should now have 3 tabs, the 3th one selected.
255 EXPECT_EQ(browser(), p.browser); 255 EXPECT_EQ(browser(), p.browser);
256 EXPECT_EQ(3, browser()->tab_count()); 256 EXPECT_EQ(3, browser()->tab_count());
257 EXPECT_EQ(2, browser()->active_index()); 257 EXPECT_EQ(2, browser()->active_index());
258 258
259 // Navigate to singleton_url3. 259 // Navigate to singleton_url3.
260 p = MakeNavigateParams(); 260 p = MakeNavigateParams();
261 p.disposition = SINGLETON_TAB; 261 p.disposition = SINGLETON_TAB;
262 p.url = singleton_ref_url3; 262 p.url = singleton_ref_url3;
263 p.ref_behavior = browser::NavigateParams::RESPECT_REF; 263 p.ref_behavior = chrome::NavigateParams::RESPECT_REF;
264 browser::Navigate(&p); 264 chrome::Navigate(&p);
265 265
266 // We should now have 4 tabs, the 4th one selected. 266 // We should now have 4 tabs, the 4th one selected.
267 EXPECT_EQ(browser(), p.browser); 267 EXPECT_EQ(browser(), p.browser);
268 EXPECT_EQ(4, browser()->tab_count()); 268 EXPECT_EQ(4, browser()->tab_count());
269 EXPECT_EQ(3, browser()->active_index()); 269 EXPECT_EQ(3, browser()->active_index());
270 } 270 }
271 271
272 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 272 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
273 Disposition_SingletonTabNoneExisting) { 273 Disposition_SingletonTabNoneExisting) {
274 GURL singleton_url1("http://maps.google.com/"); 274 GURL singleton_url1("http://maps.google.com/");
275 275
276 // We should have one browser with 1 tab. 276 // We should have one browser with 1 tab.
277 EXPECT_EQ(1u, BrowserList::size()); 277 EXPECT_EQ(1u, BrowserList::size());
278 EXPECT_EQ(0, browser()->active_index()); 278 EXPECT_EQ(0, browser()->active_index());
279 279
280 // Navigate to singleton_url1. 280 // Navigate to singleton_url1.
281 browser::NavigateParams p(MakeNavigateParams()); 281 chrome::NavigateParams p(MakeNavigateParams());
282 p.disposition = SINGLETON_TAB; 282 p.disposition = SINGLETON_TAB;
283 p.url = singleton_url1; 283 p.url = singleton_url1;
284 browser::Navigate(&p); 284 chrome::Navigate(&p);
285 285
286 // We should now have 2 tabs, the 2nd one selected. 286 // We should now have 2 tabs, the 2nd one selected.
287 EXPECT_EQ(browser(), p.browser); 287 EXPECT_EQ(browser(), p.browser);
288 EXPECT_EQ(2, browser()->tab_count()); 288 EXPECT_EQ(2, browser()->tab_count());
289 EXPECT_EQ(1, browser()->active_index()); 289 EXPECT_EQ(1, browser()->active_index());
290 } 290 }
291 291
292 // This test verifies that when a navigation results in a foreground tab, the 292 // This test verifies that when a navigation results in a foreground tab, the
293 // tab count of the Browser increases and the selected tab shifts to the new 293 // tab count of the Browser increases and the selected tab shifts to the new
294 // foreground tab. 294 // foreground tab.
295 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewForegroundTab) { 295 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewForegroundTab) {
296 WebContents* old_contents = chrome::GetActiveWebContents(browser()); 296 WebContents* old_contents = chrome::GetActiveWebContents(browser());
297 browser::NavigateParams p(MakeNavigateParams()); 297 chrome::NavigateParams p(MakeNavigateParams());
298 p.disposition = NEW_FOREGROUND_TAB; 298 p.disposition = NEW_FOREGROUND_TAB;
299 browser::Navigate(&p); 299 chrome::Navigate(&p);
300 EXPECT_NE(old_contents, chrome::GetActiveWebContents(browser())); 300 EXPECT_NE(old_contents, chrome::GetActiveWebContents(browser()));
301 EXPECT_EQ(chrome::GetActiveTabContents(browser()), p.target_contents); 301 EXPECT_EQ(chrome::GetActiveTabContents(browser()), p.target_contents);
302 EXPECT_EQ(2, browser()->tab_count()); 302 EXPECT_EQ(2, browser()->tab_count());
303 } 303 }
304 304
305 // This test verifies that when a navigation results in a background tab, the 305 // This test verifies that when a navigation results in a background tab, the
306 // tab count of the Browser increases but the selected tab remains the same. 306 // tab count of the Browser increases but the selected tab remains the same.
307 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewBackgroundTab) { 307 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewBackgroundTab) {
308 WebContents* old_contents = chrome::GetActiveWebContents(browser()); 308 WebContents* old_contents = chrome::GetActiveWebContents(browser());
309 browser::NavigateParams p(MakeNavigateParams()); 309 chrome::NavigateParams p(MakeNavigateParams());
310 p.disposition = NEW_BACKGROUND_TAB; 310 p.disposition = NEW_BACKGROUND_TAB;
311 browser::Navigate(&p); 311 chrome::Navigate(&p);
312 WebContents* new_contents = chrome::GetActiveWebContents(browser()); 312 WebContents* new_contents = chrome::GetActiveWebContents(browser());
313 // The selected tab should have remained unchanged, since the new tab was 313 // The selected tab should have remained unchanged, since the new tab was
314 // opened in the background. 314 // opened in the background.
315 EXPECT_EQ(old_contents, new_contents); 315 EXPECT_EQ(old_contents, new_contents);
316 EXPECT_EQ(2, browser()->tab_count()); 316 EXPECT_EQ(2, browser()->tab_count());
317 } 317 }
318 318
319 // This test verifies that when a navigation requiring a new foreground tab 319 // This test verifies that when a navigation requiring a new foreground tab
320 // occurs in a Browser that cannot host multiple tabs, the new foreground tab 320 // occurs in a Browser that cannot host multiple tabs, the new foreground tab
321 // is created in an existing compatible Browser. 321 // is created in an existing compatible Browser.
322 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 322 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
323 Disposition_IncompatibleWindow_Existing) { 323 Disposition_IncompatibleWindow_Existing) {
324 // Open a foreground tab in a window that cannot open popups when there is an 324 // Open a foreground tab in a window that cannot open popups when there is an
325 // existing compatible window somewhere else that they can be opened within. 325 // existing compatible window somewhere else that they can be opened within.
326 Browser* popup = CreateEmptyBrowserForType(Browser::TYPE_POPUP, 326 Browser* popup = CreateEmptyBrowserForType(Browser::TYPE_POPUP,
327 browser()->profile()); 327 browser()->profile());
328 browser::NavigateParams p(MakeNavigateParams(popup)); 328 chrome::NavigateParams p(MakeNavigateParams(popup));
329 p.disposition = NEW_FOREGROUND_TAB; 329 p.disposition = NEW_FOREGROUND_TAB;
330 browser::Navigate(&p); 330 chrome::Navigate(&p);
331 331
332 // Navigate() should have opened the tab in a different browser since the 332 // Navigate() should have opened the tab in a different browser since the
333 // one we supplied didn't support additional tabs. 333 // one we supplied didn't support additional tabs.
334 EXPECT_NE(popup, p.browser); 334 EXPECT_NE(popup, p.browser);
335 335
336 // Since browser() is an existing compatible tabbed browser, it should have 336 // Since browser() is an existing compatible tabbed browser, it should have
337 // opened the tab there. 337 // opened the tab there.
338 EXPECT_EQ(browser(), p.browser); 338 EXPECT_EQ(browser(), p.browser);
339 339
340 // We should be left with 2 windows, the popup with one tab and the browser() 340 // We should be left with 2 windows, the popup with one tab and the browser()
(...skipping 10 matching lines...) Expand all
351 Disposition_IncompatibleWindow_NoExisting) { 351 Disposition_IncompatibleWindow_NoExisting) {
352 // We want to simulate not being able to find an existing window compatible 352 // We want to simulate not being able to find an existing window compatible
353 // with our non-tabbed browser window so Navigate() is forced to create a 353 // with our non-tabbed browser window so Navigate() is forced to create a
354 // new compatible window. Because browser() supplied by the in-process 354 // new compatible window. Because browser() supplied by the in-process
355 // browser testing framework is compatible with browser()->profile(), we 355 // browser testing framework is compatible with browser()->profile(), we
356 // need a different profile, and creating a popup window with an incognito 356 // need a different profile, and creating a popup window with an incognito
357 // profile is a quick and dirty way of achieving this. 357 // profile is a quick and dirty way of achieving this.
358 Browser* popup = CreateEmptyBrowserForType( 358 Browser* popup = CreateEmptyBrowserForType(
359 Browser::TYPE_POPUP, 359 Browser::TYPE_POPUP,
360 browser()->profile()->GetOffTheRecordProfile()); 360 browser()->profile()->GetOffTheRecordProfile());
361 browser::NavigateParams p(MakeNavigateParams(popup)); 361 chrome::NavigateParams p(MakeNavigateParams(popup));
362 p.disposition = NEW_FOREGROUND_TAB; 362 p.disposition = NEW_FOREGROUND_TAB;
363 browser::Navigate(&p); 363 chrome::Navigate(&p);
364 364
365 // Navigate() should have opened the tab in a different browser since the 365 // Navigate() should have opened the tab in a different browser since the
366 // one we supplied didn't support additional tabs. 366 // one we supplied didn't support additional tabs.
367 EXPECT_NE(popup, p.browser); 367 EXPECT_NE(popup, p.browser);
368 368
369 // This time, browser() is _not_ compatible with popup since it is not an 369 // This time, browser() is _not_ compatible with popup since it is not an
370 // incognito window. 370 // incognito window.
371 EXPECT_NE(browser(), p.browser); 371 EXPECT_NE(browser(), p.browser);
372 372
373 // We should have three windows, each with one tab: 373 // We should have three windows, each with one tab:
374 // 1. the browser() provided by the framework (unchanged in this test) 374 // 1. the browser() provided by the framework (unchanged in this test)
375 // 2. the incognito popup we created originally 375 // 2. the incognito popup we created originally
376 // 3. the new incognito tabbed browser that was created by Navigate(). 376 // 3. the new incognito tabbed browser that was created by Navigate().
377 EXPECT_EQ(3u, BrowserList::size()); 377 EXPECT_EQ(3u, BrowserList::size());
378 EXPECT_EQ(1, browser()->tab_count()); 378 EXPECT_EQ(1, browser()->tab_count());
379 EXPECT_EQ(1, popup->tab_count()); 379 EXPECT_EQ(1, popup->tab_count());
380 EXPECT_EQ(1, p.browser->tab_count()); 380 EXPECT_EQ(1, p.browser->tab_count());
381 EXPECT_TRUE(p.browser->is_type_tabbed()); 381 EXPECT_TRUE(p.browser->is_type_tabbed());
382 } 382 }
383 383
384 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP 384 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
385 // from a normal Browser results in a new Browser with TYPE_POPUP. 385 // from a normal Browser results in a new Browser with TYPE_POPUP.
386 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopup) { 386 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopup) {
387 browser::NavigateParams p(MakeNavigateParams()); 387 chrome::NavigateParams p(MakeNavigateParams());
388 p.disposition = NEW_POPUP; 388 p.disposition = NEW_POPUP;
389 p.window_bounds = gfx::Rect(0, 0, 200, 200); 389 p.window_bounds = gfx::Rect(0, 0, 200, 200);
390 // Wait for new popup to to load and gain focus. 390 // Wait for new popup to to load and gain focus.
391 ui_test_utils::NavigateToURL(&p); 391 ui_test_utils::NavigateToURL(&p);
392 392
393 // Navigate() should have opened a new, focused popup window. 393 // Navigate() should have opened a new, focused popup window.
394 EXPECT_NE(browser(), p.browser); 394 EXPECT_NE(browser(), p.browser);
395 #if 0 395 #if 0
396 // TODO(stevenjb): Enable this test. See: crbug.com/79493 396 // TODO(stevenjb): Enable this test. See: crbug.com/79493
397 EXPECT_TRUE(p.browser->window()->IsActive()); 397 EXPECT_TRUE(p.browser->window()->IsActive());
398 #endif 398 #endif
399 EXPECT_TRUE(p.browser->is_type_popup()); 399 EXPECT_TRUE(p.browser->is_type_popup());
400 EXPECT_FALSE(p.browser->is_app()); 400 EXPECT_FALSE(p.browser->is_app());
401 401
402 // We should have two windows, the browser() provided by the framework and the 402 // We should have two windows, the browser() provided by the framework and the
403 // new popup window. 403 // new popup window.
404 EXPECT_EQ(2u, BrowserList::size()); 404 EXPECT_EQ(2u, BrowserList::size());
405 EXPECT_EQ(1, browser()->tab_count()); 405 EXPECT_EQ(1, browser()->tab_count());
406 EXPECT_EQ(1, p.browser->tab_count()); 406 EXPECT_EQ(1, p.browser->tab_count());
407 } 407 }
408 408
409 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP 409 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
410 // from a normal Browser results in a new Browser with is_app() true. 410 // from a normal Browser results in a new Browser with is_app() true.
411 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopup_ExtensionId) { 411 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopup_ExtensionId) {
412 browser::NavigateParams p(MakeNavigateParams()); 412 chrome::NavigateParams p(MakeNavigateParams());
413 p.disposition = NEW_POPUP; 413 p.disposition = NEW_POPUP;
414 p.extension_app_id = "extensionappid"; 414 p.extension_app_id = "extensionappid";
415 p.window_bounds = gfx::Rect(0, 0, 200, 200); 415 p.window_bounds = gfx::Rect(0, 0, 200, 200);
416 // Wait for new popup to to load and gain focus. 416 // Wait for new popup to to load and gain focus.
417 ui_test_utils::NavigateToURL(&p); 417 ui_test_utils::NavigateToURL(&p);
418 418
419 // Navigate() should have opened a new, focused popup window. 419 // Navigate() should have opened a new, focused popup window.
420 EXPECT_NE(browser(), p.browser); 420 EXPECT_NE(browser(), p.browser);
421 EXPECT_TRUE(p.browser->is_type_popup()); 421 EXPECT_TRUE(p.browser->is_type_popup());
422 EXPECT_TRUE(p.browser->is_app()); 422 EXPECT_TRUE(p.browser->is_app());
423 423
424 // We should have two windows, the browser() provided by the framework and the 424 // We should have two windows, the browser() provided by the framework and the
425 // new popup window. 425 // new popup window.
426 EXPECT_EQ(2u, BrowserList::size()); 426 EXPECT_EQ(2u, BrowserList::size());
427 EXPECT_EQ(1, browser()->tab_count()); 427 EXPECT_EQ(1, browser()->tab_count());
428 EXPECT_EQ(1, p.browser->tab_count()); 428 EXPECT_EQ(1, p.browser->tab_count());
429 } 429 }
430 430
431 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP 431 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
432 // from a normal popup results in a new Browser with TYPE_POPUP. 432 // from a normal popup results in a new Browser with TYPE_POPUP.
433 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupFromPopup) { 433 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupFromPopup) {
434 // Open a popup. 434 // Open a popup.
435 browser::NavigateParams p1(MakeNavigateParams()); 435 chrome::NavigateParams p1(MakeNavigateParams());
436 p1.disposition = NEW_POPUP; 436 p1.disposition = NEW_POPUP;
437 p1.window_bounds = gfx::Rect(0, 0, 200, 200); 437 p1.window_bounds = gfx::Rect(0, 0, 200, 200);
438 browser::Navigate(&p1); 438 chrome::Navigate(&p1);
439 // Open another popup. 439 // Open another popup.
440 browser::NavigateParams p2(MakeNavigateParams(p1.browser)); 440 chrome::NavigateParams p2(MakeNavigateParams(p1.browser));
441 p2.disposition = NEW_POPUP; 441 p2.disposition = NEW_POPUP;
442 p2.window_bounds = gfx::Rect(0, 0, 200, 200); 442 p2.window_bounds = gfx::Rect(0, 0, 200, 200);
443 browser::Navigate(&p2); 443 chrome::Navigate(&p2);
444 444
445 // Navigate() should have opened a new normal popup window. 445 // Navigate() should have opened a new normal popup window.
446 EXPECT_NE(p1.browser, p2.browser); 446 EXPECT_NE(p1.browser, p2.browser);
447 EXPECT_TRUE(p2.browser->is_type_popup()); 447 EXPECT_TRUE(p2.browser->is_type_popup());
448 EXPECT_FALSE(p2.browser->is_app()); 448 EXPECT_FALSE(p2.browser->is_app());
449 449
450 // We should have three windows, the browser() provided by the framework, 450 // We should have three windows, the browser() provided by the framework,
451 // the first popup window, and the second popup window. 451 // the first popup window, and the second popup window.
452 EXPECT_EQ(3u, BrowserList::size()); 452 EXPECT_EQ(3u, BrowserList::size());
453 EXPECT_EQ(1, browser()->tab_count()); 453 EXPECT_EQ(1, browser()->tab_count());
454 EXPECT_EQ(1, p1.browser->tab_count()); 454 EXPECT_EQ(1, p1.browser->tab_count());
455 EXPECT_EQ(1, p2.browser->tab_count()); 455 EXPECT_EQ(1, p2.browser->tab_count());
456 } 456 }
457 457
458 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP 458 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
459 // from an app frame results in a new Browser with TYPE_APP_POPUP. 459 // from an app frame results in a new Browser with TYPE_APP_POPUP.
460 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 460 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
461 Disposition_NewPopupFromAppWindow) { 461 Disposition_NewPopupFromAppWindow) {
462 Browser* app_browser = CreateEmptyBrowserForApp(Browser::TYPE_TABBED, 462 Browser* app_browser = CreateEmptyBrowserForApp(Browser::TYPE_TABBED,
463 browser()->profile()); 463 browser()->profile());
464 browser::NavigateParams p(MakeNavigateParams(app_browser)); 464 chrome::NavigateParams p(MakeNavigateParams(app_browser));
465 p.disposition = NEW_POPUP; 465 p.disposition = NEW_POPUP;
466 p.window_bounds = gfx::Rect(0, 0, 200, 200); 466 p.window_bounds = gfx::Rect(0, 0, 200, 200);
467 browser::Navigate(&p); 467 chrome::Navigate(&p);
468 468
469 // Navigate() should have opened a new popup app window. 469 // Navigate() should have opened a new popup app window.
470 EXPECT_NE(app_browser, p.browser); 470 EXPECT_NE(app_browser, p.browser);
471 EXPECT_NE(browser(), p.browser); 471 EXPECT_NE(browser(), p.browser);
472 EXPECT_TRUE(p.browser->is_type_popup()); 472 EXPECT_TRUE(p.browser->is_type_popup());
473 EXPECT_TRUE(p.browser->is_app()); 473 EXPECT_TRUE(p.browser->is_app());
474 474
475 // We should now have three windows, the app window, the app popup it created, 475 // We should now have three windows, the app window, the app popup it created,
476 // and the original browser() provided by the framework. 476 // and the original browser() provided by the framework.
477 EXPECT_EQ(3u, BrowserList::size()); 477 EXPECT_EQ(3u, BrowserList::size());
478 EXPECT_EQ(1, browser()->tab_count()); 478 EXPECT_EQ(1, browser()->tab_count());
479 EXPECT_EQ(1, app_browser->tab_count()); 479 EXPECT_EQ(1, app_browser->tab_count());
480 EXPECT_EQ(1, p.browser->tab_count()); 480 EXPECT_EQ(1, p.browser->tab_count());
481 } 481 }
482 482
483 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP 483 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
484 // from an app popup results in a new Browser also of TYPE_APP_POPUP. 484 // from an app popup results in a new Browser also of TYPE_APP_POPUP.
485 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 485 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
486 Disposition_NewPopupFromAppPopup) { 486 Disposition_NewPopupFromAppPopup) {
487 Browser* app_browser = CreateEmptyBrowserForApp(Browser::TYPE_TABBED, 487 Browser* app_browser = CreateEmptyBrowserForApp(Browser::TYPE_TABBED,
488 browser()->profile()); 488 browser()->profile());
489 // Open an app popup. 489 // Open an app popup.
490 browser::NavigateParams p1(MakeNavigateParams(app_browser)); 490 chrome::NavigateParams p1(MakeNavigateParams(app_browser));
491 p1.disposition = NEW_POPUP; 491 p1.disposition = NEW_POPUP;
492 p1.window_bounds = gfx::Rect(0, 0, 200, 200); 492 p1.window_bounds = gfx::Rect(0, 0, 200, 200);
493 browser::Navigate(&p1); 493 chrome::Navigate(&p1);
494 // Now open another app popup. 494 // Now open another app popup.
495 browser::NavigateParams p2(MakeNavigateParams(p1.browser)); 495 chrome::NavigateParams p2(MakeNavigateParams(p1.browser));
496 p2.disposition = NEW_POPUP; 496 p2.disposition = NEW_POPUP;
497 p2.window_bounds = gfx::Rect(0, 0, 200, 200); 497 p2.window_bounds = gfx::Rect(0, 0, 200, 200);
498 browser::Navigate(&p2); 498 chrome::Navigate(&p2);
499 499
500 // Navigate() should have opened a new popup app window. 500 // Navigate() should have opened a new popup app window.
501 EXPECT_NE(browser(), p1.browser); 501 EXPECT_NE(browser(), p1.browser);
502 EXPECT_NE(p1.browser, p2.browser); 502 EXPECT_NE(p1.browser, p2.browser);
503 EXPECT_TRUE(p2.browser->is_type_popup()); 503 EXPECT_TRUE(p2.browser->is_type_popup());
504 EXPECT_TRUE(p2.browser->is_app()); 504 EXPECT_TRUE(p2.browser->is_app());
505 505
506 // We should now have four windows, the app window, the first app popup, 506 // We should now have four windows, the app window, the first app popup,
507 // the second app popup, and the original browser() provided by the framework. 507 // the second app popup, and the original browser() provided by the framework.
508 EXPECT_EQ(4u, BrowserList::size()); 508 EXPECT_EQ(4u, BrowserList::size());
509 EXPECT_EQ(1, browser()->tab_count()); 509 EXPECT_EQ(1, browser()->tab_count());
510 EXPECT_EQ(1, app_browser->tab_count()); 510 EXPECT_EQ(1, app_browser->tab_count());
511 EXPECT_EQ(1, p1.browser->tab_count()); 511 EXPECT_EQ(1, p1.browser->tab_count());
512 EXPECT_EQ(1, p2.browser->tab_count()); 512 EXPECT_EQ(1, p2.browser->tab_count());
513 } 513 }
514 514
515 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP 515 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
516 // from an extension app tab results in a new Browser with TYPE_APP_POPUP. 516 // from an extension app tab results in a new Browser with TYPE_APP_POPUP.
517 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 517 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
518 Disposition_NewPopupFromExtensionApp) { 518 Disposition_NewPopupFromExtensionApp) {
519 // TODO(beng): TBD. 519 // TODO(beng): TBD.
520 } 520 }
521 521
522 // This test verifies that navigating with window_action = SHOW_WINDOW_INACTIVE 522 // This test verifies that navigating with window_action = SHOW_WINDOW_INACTIVE
523 // does not focus a new new popup window. 523 // does not focus a new new popup window.
524 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupUnfocused) { 524 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupUnfocused) {
525 browser::NavigateParams p(MakeNavigateParams()); 525 chrome::NavigateParams p(MakeNavigateParams());
526 p.disposition = NEW_POPUP; 526 p.disposition = NEW_POPUP;
527 p.window_bounds = gfx::Rect(0, 0, 200, 200); 527 p.window_bounds = gfx::Rect(0, 0, 200, 200);
528 p.window_action = browser::NavigateParams::SHOW_WINDOW_INACTIVE; 528 p.window_action = chrome::NavigateParams::SHOW_WINDOW_INACTIVE;
529 // Wait for new popup to load (and gain focus if the test fails). 529 // Wait for new popup to load (and gain focus if the test fails).
530 ui_test_utils::NavigateToURL(&p); 530 ui_test_utils::NavigateToURL(&p);
531 531
532 // Navigate() should have opened a new, unfocused, popup window. 532 // Navigate() should have opened a new, unfocused, popup window.
533 EXPECT_NE(browser(), p.browser); 533 EXPECT_NE(browser(), p.browser);
534 EXPECT_EQ(Browser::TYPE_POPUP, p.browser->type()); 534 EXPECT_EQ(Browser::TYPE_POPUP, p.browser->type());
535 #if 0 535 #if 0
536 // TODO(stevenjb): Enable this test. See: crbug.com/79493 536 // TODO(stevenjb): Enable this test. See: crbug.com/79493
537 EXPECT_FALSE(p.browser->window()->IsActive()); 537 EXPECT_FALSE(p.browser->window()->IsActive());
538 #endif 538 #endif
539 } 539 }
540 540
541 // This test verifies that navigating with WindowOpenDisposition = NEW_WINDOW 541 // This test verifies that navigating with WindowOpenDisposition = NEW_WINDOW
542 // always opens a new window. 542 // always opens a new window.
543 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewWindow) { 543 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewWindow) {
544 browser::NavigateParams p(MakeNavigateParams()); 544 chrome::NavigateParams p(MakeNavigateParams());
545 p.disposition = NEW_WINDOW; 545 p.disposition = NEW_WINDOW;
546 browser::Navigate(&p); 546 chrome::Navigate(&p);
547 547
548 // Navigate() should have opened a new toplevel window. 548 // Navigate() should have opened a new toplevel window.
549 EXPECT_NE(browser(), p.browser); 549 EXPECT_NE(browser(), p.browser);
550 EXPECT_TRUE(p.browser->is_type_tabbed()); 550 EXPECT_TRUE(p.browser->is_type_tabbed());
551 551
552 // We should now have two windows, the browser() provided by the framework and 552 // We should now have two windows, the browser() provided by the framework and
553 // the new normal window. 553 // the new normal window.
554 EXPECT_EQ(2u, BrowserList::size()); 554 EXPECT_EQ(2u, BrowserList::size());
555 EXPECT_EQ(1, browser()->tab_count()); 555 EXPECT_EQ(1, browser()->tab_count());
556 EXPECT_EQ(1, p.browser->tab_count()); 556 EXPECT_EQ(1, p.browser->tab_count());
557 } 557 }
558 558
559 // This test verifies that navigating with WindowOpenDisposition = INCOGNITO 559 // This test verifies that navigating with WindowOpenDisposition = INCOGNITO
560 // opens a new incognito window if no existing incognito window is present. 560 // opens a new incognito window if no existing incognito window is present.
561 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_Incognito) { 561 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_Incognito) {
562 browser::NavigateParams p(MakeNavigateParams()); 562 chrome::NavigateParams p(MakeNavigateParams());
563 p.disposition = OFF_THE_RECORD; 563 p.disposition = OFF_THE_RECORD;
564 browser::Navigate(&p); 564 chrome::Navigate(&p);
565 565
566 // Navigate() should have opened a new toplevel incognito window. 566 // Navigate() should have opened a new toplevel incognito window.
567 EXPECT_NE(browser(), p.browser); 567 EXPECT_NE(browser(), p.browser);
568 EXPECT_EQ(browser()->profile()->GetOffTheRecordProfile(), 568 EXPECT_EQ(browser()->profile()->GetOffTheRecordProfile(),
569 p.browser->profile()); 569 p.browser->profile());
570 570
571 // |source_contents| should be set to NULL because the profile for the new 571 // |source_contents| should be set to NULL because the profile for the new
572 // page is different from the originating page. 572 // page is different from the originating page.
573 EXPECT_EQ(NULL, p.source_contents); 573 EXPECT_EQ(NULL, p.source_contents);
574 574
575 // We should now have two windows, the browser() provided by the framework and 575 // We should now have two windows, the browser() provided by the framework and
576 // the new incognito window. 576 // the new incognito window.
577 EXPECT_EQ(2u, BrowserList::size()); 577 EXPECT_EQ(2u, BrowserList::size());
578 EXPECT_EQ(1, browser()->tab_count()); 578 EXPECT_EQ(1, browser()->tab_count());
579 EXPECT_EQ(1, p.browser->tab_count()); 579 EXPECT_EQ(1, p.browser->tab_count());
580 } 580 }
581 581
582 // This test verifies that navigating with WindowOpenDisposition = INCOGNITO 582 // This test verifies that navigating with WindowOpenDisposition = INCOGNITO
583 // reuses an existing incognito window when possible. 583 // reuses an existing incognito window when possible.
584 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_IncognitoRefocus) { 584 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_IncognitoRefocus) {
585 Browser* incognito_browser = 585 Browser* incognito_browser =
586 CreateEmptyBrowserForType(Browser::TYPE_TABBED, 586 CreateEmptyBrowserForType(Browser::TYPE_TABBED,
587 browser()->profile()->GetOffTheRecordProfile()); 587 browser()->profile()->GetOffTheRecordProfile());
588 browser::NavigateParams p(MakeNavigateParams()); 588 chrome::NavigateParams p(MakeNavigateParams());
589 p.disposition = OFF_THE_RECORD; 589 p.disposition = OFF_THE_RECORD;
590 browser::Navigate(&p); 590 chrome::Navigate(&p);
591 591
592 // Navigate() should have opened a new tab in the existing incognito window. 592 // Navigate() should have opened a new tab in the existing incognito window.
593 EXPECT_NE(browser(), p.browser); 593 EXPECT_NE(browser(), p.browser);
594 EXPECT_EQ(p.browser, incognito_browser); 594 EXPECT_EQ(p.browser, incognito_browser);
595 595
596 // We should now have two windows, the browser() provided by the framework and 596 // We should now have two windows, the browser() provided by the framework and
597 // the incognito window we opened earlier. 597 // the incognito window we opened earlier.
598 EXPECT_EQ(2u, BrowserList::size()); 598 EXPECT_EQ(2u, BrowserList::size());
599 EXPECT_EQ(1, browser()->tab_count()); 599 EXPECT_EQ(1, browser()->tab_count());
600 EXPECT_EQ(2, incognito_browser->tab_count()); 600 EXPECT_EQ(2, incognito_browser->tab_count());
(...skipping 12 matching lines...) Expand all
613 } 613 }
614 614
615 // This test verifies that no navigation action occurs when 615 // This test verifies that no navigation action occurs when
616 // WindowOpenDisposition = IGNORE_ACTION. 616 // WindowOpenDisposition = IGNORE_ACTION.
617 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_IgnoreAction) { 617 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_IgnoreAction) {
618 RunSuppressTest(IGNORE_ACTION); 618 RunSuppressTest(IGNORE_ACTION);
619 } 619 }
620 620
621 // This tests adding a foreground tab with a predefined TabContents. 621 // This tests adding a foreground tab with a predefined TabContents.
622 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, TargetContents_ForegroundTab) { 622 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, TargetContents_ForegroundTab) {
623 browser::NavigateParams p(MakeNavigateParams()); 623 chrome::NavigateParams p(MakeNavigateParams());
624 p.disposition = NEW_FOREGROUND_TAB; 624 p.disposition = NEW_FOREGROUND_TAB;
625 p.target_contents = CreateTabContents(); 625 p.target_contents = CreateTabContents();
626 browser::Navigate(&p); 626 chrome::Navigate(&p);
627 627
628 // Navigate() should have opened the contents in a new foreground in the 628 // Navigate() should have opened the contents in a new foreground in the
629 // current Browser. 629 // current Browser.
630 EXPECT_EQ(browser(), p.browser); 630 EXPECT_EQ(browser(), p.browser);
631 EXPECT_EQ(chrome::GetActiveTabContents(browser()), p.target_contents); 631 EXPECT_EQ(chrome::GetActiveTabContents(browser()), p.target_contents);
632 632
633 // We should have one window, with two tabs. 633 // We should have one window, with two tabs.
634 EXPECT_EQ(1u, BrowserList::size()); 634 EXPECT_EQ(1u, BrowserList::size());
635 EXPECT_EQ(2, browser()->tab_count()); 635 EXPECT_EQ(2, browser()->tab_count());
636 } 636 }
637 637
638 #if defined(OS_WIN) 638 #if defined(OS_WIN)
639 // This tests adding a popup with a predefined TabContents. 639 // This tests adding a popup with a predefined TabContents.
640 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, DISABLED_TargetContents_Popup) { 640 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, DISABLED_TargetContents_Popup) {
641 browser::NavigateParams p(MakeNavigateParams()); 641 chrome::NavigateParams p(MakeNavigateParams());
642 p.disposition = NEW_POPUP; 642 p.disposition = NEW_POPUP;
643 p.target_contents = CreateTabContents(); 643 p.target_contents = CreateTabContents();
644 p.window_bounds = gfx::Rect(10, 10, 500, 500); 644 p.window_bounds = gfx::Rect(10, 10, 500, 500);
645 browser::Navigate(&p); 645 chrome::Navigate(&p);
646 646
647 // Navigate() should have opened a new popup window. 647 // Navigate() should have opened a new popup window.
648 EXPECT_NE(browser(), p.browser); 648 EXPECT_NE(browser(), p.browser);
649 EXPECT_TRUE(p.browser->is_type_popup()); 649 EXPECT_TRUE(p.browser->is_type_popup());
650 EXPECT_FALSE(p.browser->is_app()); 650 EXPECT_FALSE(p.browser->is_app());
651 651
652 // The web platform is weird. The window bounds specified in 652 // The web platform is weird. The window bounds specified in
653 // |p.window_bounds| are used as follows: 653 // |p.window_bounds| are used as follows:
654 // - the origin is used to position the window 654 // - the origin is used to position the window
655 // - the size is used to size the TabContents of the window. 655 // - the size is used to size the TabContents of the window.
(...skipping 17 matching lines...) Expand all
673 EXPECT_EQ(1, p.browser->tab_count()); 673 EXPECT_EQ(1, p.browser->tab_count());
674 } 674 }
675 #endif 675 #endif
676 676
677 // This tests adding a tab at a specific index. 677 // This tests adding a tab at a specific index.
678 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Tabstrip_InsertAtIndex) { 678 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Tabstrip_InsertAtIndex) {
679 // This is not meant to be a comprehensive test of whether or not the tab 679 // This is not meant to be a comprehensive test of whether or not the tab
680 // implementation of the browser observes the insertion index. That is 680 // implementation of the browser observes the insertion index. That is
681 // covered by the unit tests for TabStripModel. This merely verifies that 681 // covered by the unit tests for TabStripModel. This merely verifies that
682 // insertion index preference is reflected in common cases. 682 // insertion index preference is reflected in common cases.
683 browser::NavigateParams p(MakeNavigateParams()); 683 chrome::NavigateParams p(MakeNavigateParams());
684 p.disposition = NEW_FOREGROUND_TAB; 684 p.disposition = NEW_FOREGROUND_TAB;
685 p.tabstrip_index = 0; 685 p.tabstrip_index = 0;
686 p.tabstrip_add_types = TabStripModel::ADD_FORCE_INDEX; 686 p.tabstrip_add_types = TabStripModel::ADD_FORCE_INDEX;
687 browser::Navigate(&p); 687 chrome::Navigate(&p);
688 688
689 // Navigate() should have inserted a new tab at slot 0 in the tabstrip. 689 // Navigate() should have inserted a new tab at slot 0 in the tabstrip.
690 EXPECT_EQ(browser(), p.browser); 690 EXPECT_EQ(browser(), p.browser);
691 EXPECT_EQ(0, browser()->tab_strip_model()->GetIndexOfTabContents( 691 EXPECT_EQ(0, browser()->tab_strip_model()->GetIndexOfTabContents(
692 static_cast<const TabContents*>(p.target_contents))); 692 static_cast<const TabContents*>(p.target_contents)));
693 693
694 // We should have one window - the browser() provided by the framework. 694 // We should have one window - the browser() provided by the framework.
695 EXPECT_EQ(1u, BrowserList::size()); 695 EXPECT_EQ(1u, BrowserList::size());
696 EXPECT_EQ(2, browser()->tab_count()); 696 EXPECT_EQ(2, browser()->tab_count());
697 } 697 }
698 698
699 // This test verifies that constructing params with a NULL browser has 699 // This test verifies that constructing params with a NULL browser has
700 // the same result as navigating to a new foreground tab in the (only) 700 // the same result as navigating to a new foreground tab in the (only)
701 // active browser. Tests are the same as for Disposition_NewForegroundTab. 701 // active browser. Tests are the same as for Disposition_NewForegroundTab.
702 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_NewForegroundTab) { 702 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_NewForegroundTab) {
703 WebContents* old_contents = chrome::GetActiveWebContents(browser()); 703 WebContents* old_contents = chrome::GetActiveWebContents(browser());
704 // Navigate with a NULL browser. 704 // Navigate with a NULL browser.
705 browser::NavigateParams p(MakeNavigateParams(NULL)); 705 chrome::NavigateParams p(MakeNavigateParams(NULL));
706 p.disposition = NEW_FOREGROUND_TAB; 706 p.disposition = NEW_FOREGROUND_TAB;
707 p.profile = browser()->profile(); 707 p.profile = browser()->profile();
708 browser::Navigate(&p); 708 chrome::Navigate(&p);
709 709
710 // Navigate() should have found browser() and create a new tab. 710 // Navigate() should have found browser() and create a new tab.
711 EXPECT_EQ(browser(), p.browser); 711 EXPECT_EQ(browser(), p.browser);
712 EXPECT_NE(old_contents, chrome::GetActiveWebContents(browser())); 712 EXPECT_NE(old_contents, chrome::GetActiveWebContents(browser()));
713 EXPECT_EQ(chrome::GetActiveTabContents(browser()), p.target_contents); 713 EXPECT_EQ(chrome::GetActiveTabContents(browser()), p.target_contents);
714 EXPECT_EQ(2, browser()->tab_count()); 714 EXPECT_EQ(2, browser()->tab_count());
715 } 715 }
716 716
717 // This test verifies that constructing params with a NULL browser and 717 // This test verifies that constructing params with a NULL browser and
718 // a specific profile matches the specified profile. 718 // a specific profile matches the specified profile.
719 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_MatchProfile) { 719 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_MatchProfile) {
720 // Create a new browser with using the incognito profile. 720 // Create a new browser with using the incognito profile.
721 Browser* incognito = 721 Browser* incognito =
722 Browser::Create(browser()->profile()->GetOffTheRecordProfile()); 722 Browser::Create(browser()->profile()->GetOffTheRecordProfile());
723 723
724 // Navigate with a NULL browser and the incognito profile. 724 // Navigate with a NULL browser and the incognito profile.
725 browser::NavigateParams p(MakeNavigateParams(NULL)); 725 chrome::NavigateParams p(MakeNavigateParams(NULL));
726 p.disposition = NEW_FOREGROUND_TAB; 726 p.disposition = NEW_FOREGROUND_TAB;
727 p.profile = incognito->profile(); 727 p.profile = incognito->profile();
728 browser::Navigate(&p); 728 chrome::Navigate(&p);
729 729
730 // Navigate() should have found incognito, not browser(). 730 // Navigate() should have found incognito, not browser().
731 EXPECT_EQ(incognito, p.browser); 731 EXPECT_EQ(incognito, p.browser);
732 EXPECT_EQ(chrome::GetActiveTabContents(incognito), p.target_contents); 732 EXPECT_EQ(chrome::GetActiveTabContents(incognito), p.target_contents);
733 EXPECT_EQ(1, incognito->tab_count()); 733 EXPECT_EQ(1, incognito->tab_count());
734 } 734 }
735 735
736 // This test verifies that constructing params with a NULL browser and 736 // This test verifies that constructing params with a NULL browser and
737 // disposition = NEW_WINDOW always opens exactly one new window. 737 // disposition = NEW_WINDOW always opens exactly one new window.
738 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_NewWindow) { 738 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_NewWindow) {
739 browser::NavigateParams p(MakeNavigateParams(NULL)); 739 chrome::NavigateParams p(MakeNavigateParams(NULL));
740 p.disposition = NEW_WINDOW; 740 p.disposition = NEW_WINDOW;
741 p.profile = browser()->profile(); 741 p.profile = browser()->profile();
742 browser::Navigate(&p); 742 chrome::Navigate(&p);
743 743
744 // Navigate() should have created a new browser. 744 // Navigate() should have created a new browser.
745 EXPECT_NE(browser(), p.browser); 745 EXPECT_NE(browser(), p.browser);
746 EXPECT_TRUE( p.browser->is_type_tabbed()); 746 EXPECT_TRUE( p.browser->is_type_tabbed());
747 747
748 // We should now have two windows, the browser() provided by the framework and 748 // We should now have two windows, the browser() provided by the framework and
749 // the new normal window. 749 // the new normal window.
750 EXPECT_EQ(2u, BrowserList::size()); 750 EXPECT_EQ(2u, BrowserList::size());
751 EXPECT_EQ(1, browser()->tab_count()); 751 EXPECT_EQ(1, browser()->tab_count());
752 EXPECT_EQ(1, p.browser->tab_count()); 752 EXPECT_EQ(1, p.browser->tab_count());
753 } 753 }
754 754
755 // This test verifies that constructing params with disposition = SINGLETON_TAB 755 // This test verifies that constructing params with disposition = SINGLETON_TAB
756 // and IGNORE_AND_NAVIGATE opens a new tab navigated to the specified URL if 756 // and IGNORE_AND_NAVIGATE opens a new tab navigated to the specified URL if
757 // no previous tab with that URL (minus the path) exists. 757 // no previous tab with that URL (minus the path) exists.
758 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 758 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
759 Disposition_SingletonTabNew_IgnorePath) { 759 Disposition_SingletonTabNew_IgnorePath) {
760 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), 760 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(),
761 content::PAGE_TRANSITION_LINK); 761 content::PAGE_TRANSITION_LINK);
762 762
763 // We should have one browser with 2 tabs, the 2nd selected. 763 // We should have one browser with 2 tabs, the 2nd selected.
764 EXPECT_EQ(1u, BrowserList::size()); 764 EXPECT_EQ(1u, BrowserList::size());
765 EXPECT_EQ(2, browser()->tab_count()); 765 EXPECT_EQ(2, browser()->tab_count());
766 EXPECT_EQ(1, browser()->active_index()); 766 EXPECT_EQ(1, browser()->active_index());
767 767
768 // Navigate to a new singleton tab with a sub-page. 768 // Navigate to a new singleton tab with a sub-page.
769 browser::NavigateParams p(MakeNavigateParams()); 769 chrome::NavigateParams p(MakeNavigateParams());
770 p.disposition = SINGLETON_TAB; 770 p.disposition = SINGLETON_TAB;
771 p.url = GetContentSettingsURL(); 771 p.url = GetContentSettingsURL();
772 p.window_action = browser::NavigateParams::SHOW_WINDOW; 772 p.window_action = chrome::NavigateParams::SHOW_WINDOW;
773 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; 773 p.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE;
774 browser::Navigate(&p); 774 chrome::Navigate(&p);
775 775
776 // The last tab should now be selected and navigated to the sub-page of the 776 // The last tab should now be selected and navigated to the sub-page of the
777 // URL. 777 // URL.
778 EXPECT_EQ(browser(), p.browser); 778 EXPECT_EQ(browser(), p.browser);
779 EXPECT_EQ(3, browser()->tab_count()); 779 EXPECT_EQ(3, browser()->tab_count());
780 EXPECT_EQ(2, browser()->active_index()); 780 EXPECT_EQ(2, browser()->active_index());
781 EXPECT_EQ(GetContentSettingsURL(), 781 EXPECT_EQ(GetContentSettingsURL(),
782 chrome::GetActiveWebContents(browser())->GetURL()); 782 chrome::GetActiveWebContents(browser())->GetURL());
783 } 783 }
784 784
785 // This test verifies that constructing params with disposition = SINGLETON_TAB 785 // This test verifies that constructing params with disposition = SINGLETON_TAB
786 // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus 786 // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus
787 // the path) which is navigated to the specified URL. 787 // the path) which is navigated to the specified URL.
788 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 788 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
789 Disposition_SingletonTabExisting_IgnorePath) { 789 Disposition_SingletonTabExisting_IgnorePath) {
790 GURL singleton_url1(GetSettingsURL()); 790 GURL singleton_url1(GetSettingsURL());
791 chrome::AddSelectedTabWithURL(browser(), singleton_url1, 791 chrome::AddSelectedTabWithURL(browser(), singleton_url1,
792 content::PAGE_TRANSITION_LINK); 792 content::PAGE_TRANSITION_LINK);
793 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), 793 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(),
794 content::PAGE_TRANSITION_LINK); 794 content::PAGE_TRANSITION_LINK);
795 795
796 // We should have one browser with 3 tabs, the 3rd selected. 796 // We should have one browser with 3 tabs, the 3rd selected.
797 EXPECT_EQ(1u, BrowserList::size()); 797 EXPECT_EQ(1u, BrowserList::size());
798 EXPECT_EQ(3, browser()->tab_count()); 798 EXPECT_EQ(3, browser()->tab_count());
799 EXPECT_EQ(2, browser()->active_index()); 799 EXPECT_EQ(2, browser()->active_index());
800 800
801 // Navigate to singleton_url1. 801 // Navigate to singleton_url1.
802 browser::NavigateParams p(MakeNavigateParams()); 802 chrome::NavigateParams p(MakeNavigateParams());
803 p.disposition = SINGLETON_TAB; 803 p.disposition = SINGLETON_TAB;
804 p.url = GetContentSettingsURL(); 804 p.url = GetContentSettingsURL();
805 p.window_action = browser::NavigateParams::SHOW_WINDOW; 805 p.window_action = chrome::NavigateParams::SHOW_WINDOW;
806 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; 806 p.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE;
807 browser::Navigate(&p); 807 chrome::Navigate(&p);
808 808
809 // The middle tab should now be selected and navigated to the sub-page of the 809 // The middle tab should now be selected and navigated to the sub-page of the
810 // URL. 810 // URL.
811 EXPECT_EQ(browser(), p.browser); 811 EXPECT_EQ(browser(), p.browser);
812 EXPECT_EQ(3, browser()->tab_count()); 812 EXPECT_EQ(3, browser()->tab_count());
813 EXPECT_EQ(1, browser()->active_index()); 813 EXPECT_EQ(1, browser()->active_index());
814 EXPECT_EQ(GetContentSettingsURL(), 814 EXPECT_EQ(GetContentSettingsURL(),
815 chrome::GetActiveWebContents(browser())->GetURL()); 815 chrome::GetActiveWebContents(browser())->GetURL());
816 } 816 }
817 817
818 // This test verifies that constructing params with disposition = SINGLETON_TAB 818 // This test verifies that constructing params with disposition = SINGLETON_TAB
819 // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus 819 // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus
820 // the path) which is navigated to the specified URL. 820 // the path) which is navigated to the specified URL.
821 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 821 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
822 Disposition_SingletonTabExistingSubPath_IgnorePath) { 822 Disposition_SingletonTabExistingSubPath_IgnorePath) {
823 GURL singleton_url1(GetContentSettingsURL()); 823 GURL singleton_url1(GetContentSettingsURL());
824 chrome::AddSelectedTabWithURL(browser(), singleton_url1, 824 chrome::AddSelectedTabWithURL(browser(), singleton_url1,
825 content::PAGE_TRANSITION_LINK); 825 content::PAGE_TRANSITION_LINK);
826 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), 826 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(),
827 content::PAGE_TRANSITION_LINK); 827 content::PAGE_TRANSITION_LINK);
828 828
829 // We should have one browser with 3 tabs, the 3rd selected. 829 // We should have one browser with 3 tabs, the 3rd selected.
830 EXPECT_EQ(1u, BrowserList::size()); 830 EXPECT_EQ(1u, BrowserList::size());
831 EXPECT_EQ(3, browser()->tab_count()); 831 EXPECT_EQ(3, browser()->tab_count());
832 EXPECT_EQ(2, browser()->active_index()); 832 EXPECT_EQ(2, browser()->active_index());
833 833
834 // Navigate to singleton_url1. 834 // Navigate to singleton_url1.
835 browser::NavigateParams p(MakeNavigateParams()); 835 chrome::NavigateParams p(MakeNavigateParams());
836 p.disposition = SINGLETON_TAB; 836 p.disposition = SINGLETON_TAB;
837 p.url = GetClearBrowsingDataURL(); 837 p.url = GetClearBrowsingDataURL();
838 p.window_action = browser::NavigateParams::SHOW_WINDOW; 838 p.window_action = chrome::NavigateParams::SHOW_WINDOW;
839 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; 839 p.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE;
840 browser::Navigate(&p); 840 chrome::Navigate(&p);
841 841
842 // The middle tab should now be selected and navigated to the sub-page of the 842 // The middle tab should now be selected and navigated to the sub-page of the
843 // URL. 843 // URL.
844 EXPECT_EQ(browser(), p.browser); 844 EXPECT_EQ(browser(), p.browser);
845 EXPECT_EQ(3, browser()->tab_count()); 845 EXPECT_EQ(3, browser()->tab_count());
846 EXPECT_EQ(1, browser()->active_index()); 846 EXPECT_EQ(1, browser()->active_index());
847 EXPECT_EQ(GetClearBrowsingDataURL(), 847 EXPECT_EQ(GetClearBrowsingDataURL(),
848 chrome::GetActiveWebContents(browser())->GetURL()); 848 chrome::GetActiveWebContents(browser())->GetURL());
849 } 849 }
850 850
851 // This test verifies that constructing params with disposition = SINGLETON_TAB 851 // This test verifies that constructing params with disposition = SINGLETON_TAB
852 // and IGNORE_AND_STAY_PUT opens an existing tab with the matching URL (minus 852 // and IGNORE_AND_STAY_PUT opens an existing tab with the matching URL (minus
853 // the path). 853 // the path).
854 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 854 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
855 Disposition_SingletonTabExistingSubPath_IgnorePath2) { 855 Disposition_SingletonTabExistingSubPath_IgnorePath2) {
856 GURL singleton_url1(GetContentSettingsURL()); 856 GURL singleton_url1(GetContentSettingsURL());
857 chrome::AddSelectedTabWithURL(browser(), singleton_url1, 857 chrome::AddSelectedTabWithURL(browser(), singleton_url1,
858 content::PAGE_TRANSITION_LINK); 858 content::PAGE_TRANSITION_LINK);
859 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), 859 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(),
860 content::PAGE_TRANSITION_LINK); 860 content::PAGE_TRANSITION_LINK);
861 861
862 // We should have one browser with 3 tabs, the 3rd selected. 862 // We should have one browser with 3 tabs, the 3rd selected.
863 EXPECT_EQ(1u, BrowserList::size()); 863 EXPECT_EQ(1u, BrowserList::size());
864 EXPECT_EQ(3, browser()->tab_count()); 864 EXPECT_EQ(3, browser()->tab_count());
865 EXPECT_EQ(2, browser()->active_index()); 865 EXPECT_EQ(2, browser()->active_index());
866 866
867 // Navigate to singleton_url1. 867 // Navigate to singleton_url1.
868 browser::NavigateParams p(MakeNavigateParams()); 868 chrome::NavigateParams p(MakeNavigateParams());
869 p.disposition = SINGLETON_TAB; 869 p.disposition = SINGLETON_TAB;
870 p.url = GetClearBrowsingDataURL(); 870 p.url = GetClearBrowsingDataURL();
871 p.window_action = browser::NavigateParams::SHOW_WINDOW; 871 p.window_action = chrome::NavigateParams::SHOW_WINDOW;
872 p.path_behavior = browser::NavigateParams::IGNORE_AND_STAY_PUT; 872 p.path_behavior = chrome::NavigateParams::IGNORE_AND_STAY_PUT;
873 browser::Navigate(&p); 873 chrome::Navigate(&p);
874 874
875 // The middle tab should now be selected. 875 // The middle tab should now be selected.
876 EXPECT_EQ(browser(), p.browser); 876 EXPECT_EQ(browser(), p.browser);
877 EXPECT_EQ(3, browser()->tab_count()); 877 EXPECT_EQ(3, browser()->tab_count());
878 EXPECT_EQ(1, browser()->active_index()); 878 EXPECT_EQ(1, browser()->active_index());
879 EXPECT_EQ(singleton_url1, 879 EXPECT_EQ(singleton_url1,
880 chrome::GetActiveWebContents(browser())->GetURL()); 880 chrome::GetActiveWebContents(browser())->GetURL());
881 } 881 }
882 882
883 // This test verifies that constructing params with disposition = SINGLETON_TAB 883 // This test verifies that constructing params with disposition = SINGLETON_TAB
884 // and IGNORE_AND_NAVIGATE will update the current tab's URL if the currently 884 // and IGNORE_AND_NAVIGATE will update the current tab's URL if the currently
885 // selected tab is a match but has a different path. 885 // selected tab is a match but has a different path.
886 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 886 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
887 Disposition_SingletonTabFocused_IgnorePath) { 887 Disposition_SingletonTabFocused_IgnorePath) {
888 GURL singleton_url_current(GetContentSettingsURL()); 888 GURL singleton_url_current(GetContentSettingsURL());
889 chrome::AddSelectedTabWithURL(browser(), singleton_url_current, 889 chrome::AddSelectedTabWithURL(browser(), singleton_url_current,
890 content::PAGE_TRANSITION_LINK); 890 content::PAGE_TRANSITION_LINK);
891 891
892 // We should have one browser with 2 tabs, the 2nd selected. 892 // We should have one browser with 2 tabs, the 2nd selected.
893 EXPECT_EQ(1u, BrowserList::size()); 893 EXPECT_EQ(1u, BrowserList::size());
894 EXPECT_EQ(2, browser()->tab_count()); 894 EXPECT_EQ(2, browser()->tab_count());
895 EXPECT_EQ(1, browser()->active_index()); 895 EXPECT_EQ(1, browser()->active_index());
896 896
897 // Navigate to a different settings path. 897 // Navigate to a different settings path.
898 GURL singleton_url_target(GetClearBrowsingDataURL()); 898 GURL singleton_url_target(GetClearBrowsingDataURL());
899 browser::NavigateParams p(MakeNavigateParams()); 899 chrome::NavigateParams p(MakeNavigateParams());
900 p.disposition = SINGLETON_TAB; 900 p.disposition = SINGLETON_TAB;
901 p.url = singleton_url_target; 901 p.url = singleton_url_target;
902 p.window_action = browser::NavigateParams::SHOW_WINDOW; 902 p.window_action = chrome::NavigateParams::SHOW_WINDOW;
903 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; 903 p.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE;
904 browser::Navigate(&p); 904 chrome::Navigate(&p);
905 905
906 // The second tab should still be selected, but navigated to the new path. 906 // The second tab should still be selected, but navigated to the new path.
907 EXPECT_EQ(browser(), p.browser); 907 EXPECT_EQ(browser(), p.browser);
908 EXPECT_EQ(2, browser()->tab_count()); 908 EXPECT_EQ(2, browser()->tab_count());
909 EXPECT_EQ(1, browser()->active_index()); 909 EXPECT_EQ(1, browser()->active_index());
910 EXPECT_EQ(singleton_url_target, 910 EXPECT_EQ(singleton_url_target,
911 chrome::GetActiveWebContents(browser())->GetURL()); 911 chrome::GetActiveWebContents(browser())->GetURL());
912 } 912 }
913 913
914 // This test verifies that constructing params with disposition = SINGLETON_TAB 914 // This test verifies that constructing params with disposition = SINGLETON_TAB
915 // and IGNORE_AND_NAVIGATE will open an existing matching tab with a different 915 // and IGNORE_AND_NAVIGATE will open an existing matching tab with a different
916 // query. 916 // query.
917 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 917 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
918 Disposition_SingletonTabExisting_IgnoreQuery) { 918 Disposition_SingletonTabExisting_IgnoreQuery) {
919 int initial_tab_count = browser()->tab_count(); 919 int initial_tab_count = browser()->tab_count();
920 GURL singleton_url_current("chrome://settings/internet"); 920 GURL singleton_url_current("chrome://settings/internet");
921 chrome::AddSelectedTabWithURL(browser(), singleton_url_current, 921 chrome::AddSelectedTabWithURL(browser(), singleton_url_current,
922 content::PAGE_TRANSITION_LINK); 922 content::PAGE_TRANSITION_LINK);
923 923
924 EXPECT_EQ(initial_tab_count + 1, browser()->tab_count()); 924 EXPECT_EQ(initial_tab_count + 1, browser()->tab_count());
925 EXPECT_EQ(initial_tab_count, browser()->active_index()); 925 EXPECT_EQ(initial_tab_count, browser()->active_index());
926 926
927 // Navigate to a different settings path. 927 // Navigate to a different settings path.
928 GURL singleton_url_target( 928 GURL singleton_url_target(
929 "chrome://settings/internet?" 929 "chrome://settings/internet?"
930 "servicePath=/profile/ethernet_00aa00aa00aa&networkType=1"); 930 "servicePath=/profile/ethernet_00aa00aa00aa&networkType=1");
931 browser::NavigateParams p(MakeNavigateParams()); 931 chrome::NavigateParams p(MakeNavigateParams());
932 p.disposition = SINGLETON_TAB; 932 p.disposition = SINGLETON_TAB;
933 p.url = singleton_url_target; 933 p.url = singleton_url_target;
934 p.window_action = browser::NavigateParams::SHOW_WINDOW; 934 p.window_action = chrome::NavigateParams::SHOW_WINDOW;
935 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; 935 p.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE;
936 browser::Navigate(&p); 936 chrome::Navigate(&p);
937 937
938 // Last tab should still be selected. 938 // Last tab should still be selected.
939 EXPECT_EQ(browser(), p.browser); 939 EXPECT_EQ(browser(), p.browser);
940 EXPECT_EQ(initial_tab_count + 1, browser()->tab_count()); 940 EXPECT_EQ(initial_tab_count + 1, browser()->tab_count());
941 EXPECT_EQ(initial_tab_count, browser()->active_index()); 941 EXPECT_EQ(initial_tab_count, browser()->active_index());
942 } 942 }
943 943
944 // This test verifies that the settings page isn't opened in the incognito 944 // This test verifies that the settings page isn't opened in the incognito
945 // window. 945 // window.
946 // Disabled until fixed for uber settings: http://crbug.com/111243 946 // Disabled until fixed for uber settings: http://crbug.com/111243
947 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 947 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
948 DISABLED_Disposition_Settings_UseNonIncognitoWindow) { 948 DISABLED_Disposition_Settings_UseNonIncognitoWindow) {
949 RunUseNonIncognitoWindowTest(GetSettingsURL()); 949 RunUseNonIncognitoWindowTest(GetSettingsURL());
950 } 950 }
951 951
952 // This test verifies that the settings page isn't opened in the incognito 952 // This test verifies that the settings page isn't opened in the incognito
953 // window from a non-incognito window (bookmark open-in-incognito trigger). 953 // window from a non-incognito window (bookmark open-in-incognito trigger).
954 // Disabled until fixed for uber settings: http://crbug.com/111243 954 // Disabled until fixed for uber settings: http://crbug.com/111243
955 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 955 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
956 DISABLED_Disposition_Settings_UseNonIncognitoWindowForBookmark) { 956 DISABLED_Disposition_Settings_UseNonIncognitoWindowForBookmark) {
957 browser::NavigateParams params(browser(), GetSettingsURL(), 957 chrome::NavigateParams params(browser(), GetSettingsURL(),
958 content::PAGE_TRANSITION_AUTO_BOOKMARK); 958 content::PAGE_TRANSITION_AUTO_BOOKMARK);
959 params.disposition = OFF_THE_RECORD; 959 params.disposition = OFF_THE_RECORD;
960 { 960 {
961 ui_test_utils::WindowedNotificationObserver observer( 961 ui_test_utils::WindowedNotificationObserver observer(
962 content::NOTIFICATION_LOAD_STOP, 962 content::NOTIFICATION_LOAD_STOP,
963 content::NotificationService::AllSources()); 963 content::NotificationService::AllSources());
964 browser::Navigate(&params); 964 chrome::Navigate(&params);
965 observer.Wait(); 965 observer.Wait();
966 } 966 }
967 967
968 EXPECT_EQ(1u, BrowserList::size()); 968 EXPECT_EQ(1u, BrowserList::size());
969 EXPECT_EQ(GetSettingsURL(), 969 EXPECT_EQ(GetSettingsURL(),
970 chrome::GetActiveWebContents(browser())->GetURL()); 970 chrome::GetActiveWebContents(browser())->GetURL());
971 } 971 }
972 972
973 // Settings page is expected to always open in normal mode regardless 973 // Settings page is expected to always open in normal mode regardless
974 // of whether the user is trying to open it in incognito mode or not. 974 // of whether the user is trying to open it in incognito mode or not.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 1022
1023 // We should have one browser with 2 tabs, the 2nd selected. 1023 // We should have one browser with 2 tabs, the 2nd selected.
1024 EXPECT_EQ(1u, BrowserList::size()); 1024 EXPECT_EQ(1u, BrowserList::size());
1025 EXPECT_EQ(2, browser()->tab_count()); 1025 EXPECT_EQ(2, browser()->tab_count());
1026 EXPECT_EQ(1, browser()->active_index()); 1026 EXPECT_EQ(1, browser()->active_index());
1027 1027
1028 // Kill the singleton tab. 1028 // Kill the singleton tab.
1029 web_contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); 1029 web_contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1);
1030 EXPECT_TRUE(web_contents->IsCrashed()); 1030 EXPECT_TRUE(web_contents->IsCrashed());
1031 1031
1032 browser::NavigateParams p(MakeNavigateParams()); 1032 chrome::NavigateParams p(MakeNavigateParams());
1033 p.disposition = SINGLETON_TAB; 1033 p.disposition = SINGLETON_TAB;
1034 p.url = singleton_url; 1034 p.url = singleton_url;
1035 p.window_action = browser::NavigateParams::SHOW_WINDOW; 1035 p.window_action = chrome::NavigateParams::SHOW_WINDOW;
1036 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; 1036 p.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE;
1037 ui_test_utils::NavigateToURL(&p); 1037 ui_test_utils::NavigateToURL(&p);
1038 1038
1039 // The tab should not be sad anymore. 1039 // The tab should not be sad anymore.
1040 EXPECT_FALSE(web_contents->IsCrashed()); 1040 EXPECT_FALSE(web_contents->IsCrashed());
1041 } 1041 }
1042 1042
1043 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1043 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1044 NavigateFromDefaultToOptionsInSameTab) { 1044 NavigateFromDefaultToOptionsInSameTab) {
1045 { 1045 {
1046 ui_test_utils::WindowedNotificationObserver observer( 1046 ui_test_utils::WindowedNotificationObserver observer(
1047 content::NOTIFICATION_LOAD_STOP, 1047 content::NOTIFICATION_LOAD_STOP,
1048 content::NotificationService::AllSources()); 1048 content::NotificationService::AllSources());
1049 chrome::ShowSettings(browser()); 1049 chrome::ShowSettings(browser());
1050 observer.Wait(); 1050 observer.Wait();
1051 } 1051 }
1052 EXPECT_EQ(1, browser()->tab_count()); 1052 EXPECT_EQ(1, browser()->tab_count());
1053 EXPECT_EQ(GetSettingsURL(), 1053 EXPECT_EQ(GetSettingsURL(),
1054 chrome::GetActiveWebContents(browser())->GetURL()); 1054 chrome::GetActiveWebContents(browser())->GetURL());
1055 } 1055 }
1056 1056
1057 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1057 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1058 NavigateFromBlankToOptionsInSameTab) { 1058 NavigateFromBlankToOptionsInSameTab) {
1059 browser::NavigateParams p(MakeNavigateParams()); 1059 chrome::NavigateParams p(MakeNavigateParams());
1060 p.url = GURL(chrome::kAboutBlankURL); 1060 p.url = GURL(chrome::kAboutBlankURL);
1061 ui_test_utils::NavigateToURL(&p); 1061 ui_test_utils::NavigateToURL(&p);
1062 1062
1063 { 1063 {
1064 ui_test_utils::WindowedNotificationObserver observer( 1064 ui_test_utils::WindowedNotificationObserver observer(
1065 content::NOTIFICATION_LOAD_STOP, 1065 content::NOTIFICATION_LOAD_STOP,
1066 content::NotificationService::AllSources()); 1066 content::NotificationService::AllSources());
1067 chrome::ShowSettings(browser()); 1067 chrome::ShowSettings(browser());
1068 observer.Wait(); 1068 observer.Wait();
1069 } 1069 }
1070 EXPECT_EQ(1, browser()->tab_count()); 1070 EXPECT_EQ(1, browser()->tab_count());
1071 EXPECT_EQ(GetSettingsURL(), 1071 EXPECT_EQ(GetSettingsURL(),
1072 chrome::GetActiveWebContents(browser())->GetURL()); 1072 chrome::GetActiveWebContents(browser())->GetURL());
1073 } 1073 }
1074 1074
1075 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1075 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1076 NavigateFromNTPToOptionsInSameTab) { 1076 NavigateFromNTPToOptionsInSameTab) {
1077 browser::NavigateParams p(MakeNavigateParams()); 1077 chrome::NavigateParams p(MakeNavigateParams());
1078 p.url = GURL(chrome::kChromeUINewTabURL); 1078 p.url = GURL(chrome::kChromeUINewTabURL);
1079 ui_test_utils::NavigateToURL(&p); 1079 ui_test_utils::NavigateToURL(&p);
1080 EXPECT_EQ(1, browser()->tab_count()); 1080 EXPECT_EQ(1, browser()->tab_count());
1081 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), 1081 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL),
1082 chrome::GetActiveWebContents(browser())->GetURL()); 1082 chrome::GetActiveWebContents(browser())->GetURL());
1083 1083
1084 { 1084 {
1085 ui_test_utils::WindowedNotificationObserver observer( 1085 ui_test_utils::WindowedNotificationObserver observer(
1086 content::NOTIFICATION_LOAD_STOP, 1086 content::NOTIFICATION_LOAD_STOP,
1087 content::NotificationService::AllSources()); 1087 content::NotificationService::AllSources());
1088 chrome::ShowSettings(browser()); 1088 chrome::ShowSettings(browser());
1089 observer.Wait(); 1089 observer.Wait();
1090 } 1090 }
1091 EXPECT_EQ(1, browser()->tab_count()); 1091 EXPECT_EQ(1, browser()->tab_count());
1092 EXPECT_EQ(GetSettingsURL(), 1092 EXPECT_EQ(GetSettingsURL(),
1093 chrome::GetActiveWebContents(browser())->GetURL()); 1093 chrome::GetActiveWebContents(browser())->GetURL());
1094 } 1094 }
1095 1095
1096 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1096 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1097 NavigateFromPageToOptionsInNewTab) { 1097 NavigateFromPageToOptionsInNewTab) {
1098 browser::NavigateParams p(MakeNavigateParams()); 1098 chrome::NavigateParams p(MakeNavigateParams());
1099 ui_test_utils::NavigateToURL(&p); 1099 ui_test_utils::NavigateToURL(&p);
1100 EXPECT_EQ(GetGoogleURL(), chrome::GetActiveWebContents(browser())->GetURL()); 1100 EXPECT_EQ(GetGoogleURL(), chrome::GetActiveWebContents(browser())->GetURL());
1101 EXPECT_EQ(1u, BrowserList::size()); 1101 EXPECT_EQ(1u, BrowserList::size());
1102 EXPECT_EQ(1, browser()->tab_count()); 1102 EXPECT_EQ(1, browser()->tab_count());
1103 1103
1104 { 1104 {
1105 ui_test_utils::WindowedNotificationObserver observer( 1105 ui_test_utils::WindowedNotificationObserver observer(
1106 content::NOTIFICATION_LOAD_STOP, 1106 content::NOTIFICATION_LOAD_STOP,
1107 content::NotificationService::AllSources()); 1107 content::NotificationService::AllSources());
1108 chrome::ShowSettings(browser()); 1108 chrome::ShowSettings(browser());
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 } 1205 }
1206 1206
1207 // Tests that when a new tab is opened from the omnibox, the focus is moved from 1207 // Tests that when a new tab is opened from the omnibox, the focus is moved from
1208 // the omnibox for the current tab. 1208 // the omnibox for the current tab.
1209 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1209 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1210 NavigateFromOmniboxIntoNewTab) { 1210 NavigateFromOmniboxIntoNewTab) {
1211 GURL url("http://www.google.com/"); 1211 GURL url("http://www.google.com/");
1212 GURL url2("http://maps.google.com/"); 1212 GURL url2("http://maps.google.com/");
1213 1213
1214 // Navigate to url. 1214 // Navigate to url.
1215 browser::NavigateParams p(MakeNavigateParams()); 1215 chrome::NavigateParams p(MakeNavigateParams());
1216 p.disposition = CURRENT_TAB; 1216 p.disposition = CURRENT_TAB;
1217 p.url = url; 1217 p.url = url;
1218 browser::Navigate(&p); 1218 chrome::Navigate(&p);
1219 1219
1220 // Focus the omnibox. 1220 // Focus the omnibox.
1221 chrome::FocusLocationBar(browser()); 1221 chrome::FocusLocationBar(browser());
1222 1222
1223 OmniboxEditController* controller = 1223 OmniboxEditController* controller =
1224 browser()->window()->GetLocationBar()->GetLocationEntry()->model()-> 1224 browser()->window()->GetLocationBar()->GetLocationEntry()->model()->
1225 controller(); 1225 controller();
1226 1226
1227 // Simulate an alt-enter. 1227 // Simulate an alt-enter.
1228 controller->OnAutocompleteAccept(url2, NEW_FOREGROUND_TAB, 1228 controller->OnAutocompleteAccept(url2, NEW_FOREGROUND_TAB,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 GURL url("http://maps.google.com/#a"); 1297 GURL url("http://maps.google.com/#a");
1298 GURL url2("http://maps.google.com/#b"); 1298 GURL url2("http://maps.google.com/#b");
1299 1299
1300 // Create a panel. 1300 // Create a panel.
1301 Browser* panel_browser = Browser::CreateWithParams( 1301 Browser* panel_browser = Browser::CreateWithParams(
1302 Browser::CreateParams::CreateForApp( 1302 Browser::CreateParams::CreateForApp(
1303 Browser::TYPE_PANEL, "Test", gfx::Rect(100, 100), 1303 Browser::TYPE_PANEL, "Test", gfx::Rect(100, 100),
1304 browser()->profile())); 1304 browser()->profile()));
1305 1305
1306 // Navigate to the page. 1306 // Navigate to the page.
1307 browser::NavigateParams p(MakeNavigateParams(panel_browser)); 1307 chrome::NavigateParams p(MakeNavigateParams(panel_browser));
1308 p.url = url; 1308 p.url = url;
1309 p.disposition = CURRENT_TAB; 1309 p.disposition = CURRENT_TAB;
1310 browser::Navigate(&p); 1310 chrome::Navigate(&p);
1311 1311
1312 // Navigate() should have navigated in the existing panel window. 1312 // Navigate() should have navigated in the existing panel window.
1313 EXPECT_EQ(panel_browser, p.browser); 1313 EXPECT_EQ(panel_browser, p.browser);
1314 1314
1315 // We should now have two windows, the browser() provided by the framework and 1315 // We should now have two windows, the browser() provided by the framework and
1316 // the panel window we opened earlier. The tabbed browser window has 1 tab. 1316 // the panel window we opened earlier. The tabbed browser window has 1 tab.
1317 EXPECT_EQ(2u, BrowserList::size()); 1317 EXPECT_EQ(2u, BrowserList::size());
1318 EXPECT_EQ(1, browser()->tab_count()); 1318 EXPECT_EQ(1, browser()->tab_count());
1319 EXPECT_EQ(1, panel_browser->tab_count()); 1319 EXPECT_EQ(1, panel_browser->tab_count());
1320 1320
1321 // Kill the panel page. 1321 // Kill the panel page.
1322 WebContents* web_contents = chrome::GetActiveWebContents(panel_browser); 1322 WebContents* web_contents = chrome::GetActiveWebContents(panel_browser);
1323 web_contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); 1323 web_contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1);
1324 EXPECT_TRUE(web_contents->IsCrashed()); 1324 EXPECT_TRUE(web_contents->IsCrashed());
1325 1325
1326 // Navigate to the page. 1326 // Navigate to the page.
1327 browser::NavigateParams p2(MakeNavigateParams(panel_browser)); 1327 chrome::NavigateParams p2(MakeNavigateParams(panel_browser));
1328 p2.source_contents = chrome::GetActiveTabContents(panel_browser); 1328 p2.source_contents = chrome::GetActiveTabContents(panel_browser);
1329 p2.url = url2; 1329 p2.url = url2;
1330 p2.disposition = CURRENT_TAB; 1330 p2.disposition = CURRENT_TAB;
1331 browser::Navigate(&p2); 1331 chrome::Navigate(&p2);
1332 1332
1333 // Navigate() should have opened a new tab in the existing tabbed window. 1333 // Navigate() should have opened a new tab in the existing tabbed window.
1334 EXPECT_EQ(browser(), p2.browser); 1334 EXPECT_EQ(browser(), p2.browser);
1335 1335
1336 // We should now have two windows, the browser() provided by the framework and 1336 // We should now have two windows, the browser() provided by the framework and
1337 // the panel window we opened earlier. The tabbed browser window has 2 tabs. 1337 // the panel window we opened earlier. The tabbed browser window has 2 tabs.
1338 EXPECT_EQ(2u, BrowserList::size()); 1338 EXPECT_EQ(2u, BrowserList::size());
1339 EXPECT_EQ(2, browser()->tab_count()); 1339 EXPECT_EQ(2, browser()->tab_count());
1340 EXPECT_EQ(1, panel_browser->tab_count()); 1340 EXPECT_EQ(1, panel_browser->tab_count());
1341 } 1341 }
1342 1342
1343 } // namespace 1343 } // 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