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

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

Issue 6881073: Cleanup popup related browser navigation code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and merge with avi's popup block changes. Created 9 years, 7 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/tabs/tab_strip_model.h" 9 #include "chrome/browser/tabs/tab_strip_model.h"
10 #include "chrome/browser/ui/browser_list.h" 10 #include "chrome/browser/ui/browser_list.h"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 EXPECT_EQ(1, popup->tab_count()); 237 EXPECT_EQ(1, popup->tab_count());
238 EXPECT_EQ(1, p.browser->tab_count()); 238 EXPECT_EQ(1, p.browser->tab_count());
239 EXPECT_EQ(Browser::TYPE_NORMAL, p.browser->type()); 239 EXPECT_EQ(Browser::TYPE_NORMAL, p.browser->type());
240 } 240 }
241 241
242 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP 242 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
243 // from a normal Browser results in a new Browser with TYPE_POPUP. 243 // from a normal Browser results in a new Browser with TYPE_POPUP.
244 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopup) { 244 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopup) {
245 browser::NavigateParams p(MakeNavigateParams()); 245 browser::NavigateParams p(MakeNavigateParams());
246 p.disposition = NEW_POPUP; 246 p.disposition = NEW_POPUP;
247 p.window_bounds = gfx::Rect(0, 0, 200, 200);
247 browser::Navigate(&p); 248 browser::Navigate(&p);
248 // Wait for new popup to to load and gain focus. 249 // Wait for new popup to to load and gain focus.
249 ui_test_utils::WaitForNavigationInCurrentTab(p.browser); 250 ui_test_utils::WaitForNavigationInCurrentTab(p.browser);
250 251
251 // Navigate() should have opened a new, focused popup window. 252 // Navigate() should have opened a new, focused popup window.
252 EXPECT_NE(browser(), p.browser); 253 EXPECT_NE(browser(), p.browser);
253 #if 0 254 #if 0
254 // TODO(stevenjb): Enable this test. See: crbug.com/79493 255 // TODO(stevenjb): Enable this test. See: crbug.com/79493
255 EXPECT_TRUE(p.browser->window()->IsActive()); 256 EXPECT_TRUE(p.browser->window()->IsActive());
256 #endif 257 #endif
257 EXPECT_EQ(Browser::TYPE_POPUP, p.browser->type()); 258 EXPECT_EQ(Browser::TYPE_POPUP, p.browser->type());
258 259
259 // We should have two windows, the browser() provided by the framework and the 260 // We should have two windows, the browser() provided by the framework and the
260 // new popup window. 261 // new popup window.
261 EXPECT_EQ(2u, BrowserList::size()); 262 EXPECT_EQ(2u, BrowserList::size());
262 EXPECT_EQ(1, browser()->tab_count()); 263 EXPECT_EQ(1, browser()->tab_count());
263 EXPECT_EQ(1, p.browser->tab_count()); 264 EXPECT_EQ(1, p.browser->tab_count());
264 } 265 }
265 266
266 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP 267 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
267 // from a normal popup results in a new Browser with TYPE_POPUP. 268 // from a normal popup results in a new Browser with TYPE_POPUP.
268 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupFromPopup) { 269 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupFromPopup) {
269 // Open a popup. 270 // Open a popup.
270 browser::NavigateParams p1(MakeNavigateParams()); 271 browser::NavigateParams p1(MakeNavigateParams());
271 p1.disposition = NEW_POPUP; 272 p1.disposition = NEW_POPUP;
273 p1.window_bounds = gfx::Rect(0, 0, 200, 200);
272 browser::Navigate(&p1); 274 browser::Navigate(&p1);
273 // Open another popup. 275 // Open another popup.
274 browser::NavigateParams p2(MakeNavigateParams(p1.browser)); 276 browser::NavigateParams p2(MakeNavigateParams(p1.browser));
275 p2.disposition = NEW_POPUP; 277 p2.disposition = NEW_POPUP;
278 p2.window_bounds = gfx::Rect(0, 0, 200, 200);
276 browser::Navigate(&p2); 279 browser::Navigate(&p2);
277 280
278 // Navigate() should have opened a new normal popup window. 281 // Navigate() should have opened a new normal popup window.
279 EXPECT_NE(p1.browser, p2.browser); 282 EXPECT_NE(p1.browser, p2.browser);
280 EXPECT_EQ(Browser::TYPE_POPUP, p2.browser->type()); 283 EXPECT_EQ(Browser::TYPE_POPUP, p2.browser->type());
281 284
282 // We should have three windows, the browser() provided by the framework, 285 // We should have three windows, the browser() provided by the framework,
283 // the first popup window, and the second popup window. 286 // the first popup window, and the second popup window.
284 EXPECT_EQ(3u, BrowserList::size()); 287 EXPECT_EQ(3u, BrowserList::size());
285 EXPECT_EQ(1, browser()->tab_count()); 288 EXPECT_EQ(1, browser()->tab_count());
286 EXPECT_EQ(1, p1.browser->tab_count()); 289 EXPECT_EQ(1, p1.browser->tab_count());
287 EXPECT_EQ(1, p2.browser->tab_count()); 290 EXPECT_EQ(1, p2.browser->tab_count());
288 } 291 }
289 292
290 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP 293 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
291 // from an app frame results in a new Browser with TYPE_APP_POPUP. 294 // from an app frame results in a new Browser with TYPE_APP_POPUP.
292 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 295 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
293 Disposition_NewPopupFromAppWindow) { 296 Disposition_NewPopupFromAppWindow) {
294 Browser* app_browser = CreateEmptyBrowserForType(Browser::TYPE_APP, 297 Browser* app_browser = CreateEmptyBrowserForType(Browser::TYPE_APP,
295 browser()->profile()); 298 browser()->profile());
296 browser::NavigateParams p(MakeNavigateParams(app_browser)); 299 browser::NavigateParams p(MakeNavigateParams(app_browser));
297 p.disposition = NEW_POPUP; 300 p.disposition = NEW_POPUP;
301 p.window_bounds = gfx::Rect(0, 0, 200, 200);
298 browser::Navigate(&p); 302 browser::Navigate(&p);
299 303
300 // Navigate() should have opened a new popup app window. 304 // Navigate() should have opened a new popup app window.
301 EXPECT_NE(app_browser, p.browser); 305 EXPECT_NE(app_browser, p.browser);
302 EXPECT_NE(browser(), p.browser); 306 EXPECT_NE(browser(), p.browser);
303 EXPECT_EQ(Browser::TYPE_APP_POPUP, p.browser->type()); 307 EXPECT_EQ(Browser::TYPE_APP_POPUP, p.browser->type());
304 308
305 // We should now have three windows, the app window, the app popup it created, 309 // We should now have three windows, the app window, the app popup it created,
306 // and the original browser() provided by the framework. 310 // and the original browser() provided by the framework.
307 EXPECT_EQ(3u, BrowserList::size()); 311 EXPECT_EQ(3u, BrowserList::size());
308 EXPECT_EQ(1, browser()->tab_count()); 312 EXPECT_EQ(1, browser()->tab_count());
309 EXPECT_EQ(1, app_browser->tab_count()); 313 EXPECT_EQ(1, app_browser->tab_count());
310 EXPECT_EQ(1, p.browser->tab_count()); 314 EXPECT_EQ(1, p.browser->tab_count());
311 } 315 }
312 316
313 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP 317 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
314 // from an app popup results in a new Browser also of TYPE_APP_POPUP. 318 // from an app popup results in a new Browser also of TYPE_APP_POPUP.
315 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 319 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
316 Disposition_NewPopupFromAppPopup) { 320 Disposition_NewPopupFromAppPopup) {
317 Browser* app_browser = CreateEmptyBrowserForType(Browser::TYPE_APP, 321 Browser* app_browser = CreateEmptyBrowserForType(Browser::TYPE_APP,
318 browser()->profile()); 322 browser()->profile());
319 // Open an app popup. 323 // Open an app popup.
320 browser::NavigateParams p1(MakeNavigateParams(app_browser)); 324 browser::NavigateParams p1(MakeNavigateParams(app_browser));
321 p1.disposition = NEW_POPUP; 325 p1.disposition = NEW_POPUP;
326 p1.window_bounds = gfx::Rect(0, 0, 200, 200);
322 browser::Navigate(&p1); 327 browser::Navigate(&p1);
323 // Now open another app popup. 328 // Now open another app popup.
324 browser::NavigateParams p2(MakeNavigateParams(p1.browser)); 329 browser::NavigateParams p2(MakeNavigateParams(p1.browser));
325 p2.disposition = NEW_POPUP; 330 p2.disposition = NEW_POPUP;
331 p2.window_bounds = gfx::Rect(0, 0, 200, 200);
326 browser::Navigate(&p2); 332 browser::Navigate(&p2);
327 333
328 // Navigate() should have opened a new popup app window. 334 // Navigate() should have opened a new popup app window.
329 EXPECT_NE(browser(), p1.browser); 335 EXPECT_NE(browser(), p1.browser);
330 EXPECT_NE(p1.browser, p2.browser); 336 EXPECT_NE(p1.browser, p2.browser);
331 EXPECT_EQ(Browser::TYPE_APP_POPUP, p2.browser->type()); 337 EXPECT_EQ(Browser::TYPE_APP_POPUP, p2.browser->type());
332 338
333 // We should now have four windows, the app window, the first app popup, 339 // We should now have four windows, the app window, the first app popup,
334 // the second app popup, and the original browser() provided by the framework. 340 // the second app popup, and the original browser() provided by the framework.
335 EXPECT_EQ(4u, BrowserList::size()); 341 EXPECT_EQ(4u, BrowserList::size());
336 EXPECT_EQ(1, browser()->tab_count()); 342 EXPECT_EQ(1, browser()->tab_count());
337 EXPECT_EQ(1, app_browser->tab_count()); 343 EXPECT_EQ(1, app_browser->tab_count());
338 EXPECT_EQ(1, p1.browser->tab_count()); 344 EXPECT_EQ(1, p1.browser->tab_count());
339 EXPECT_EQ(1, p2.browser->tab_count()); 345 EXPECT_EQ(1, p2.browser->tab_count());
340 } 346 }
341 347
342 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP 348 // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP
343 // from an extension app tab results in a new Browser with TYPE_APP_POPUP. 349 // from an extension app tab results in a new Browser with TYPE_APP_POPUP.
344 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 350 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
345 Disposition_NewPopupFromExtensionApp) { 351 Disposition_NewPopupFromExtensionApp) {
346 // TODO(beng): TBD. 352 // TODO(beng): TBD.
347 } 353 }
348 354
349 // This test verifies that navigating with window_action = SHOW_WINDOW_INACTIVE 355 // This test verifies that navigating with window_action = SHOW_WINDOW_INACTIVE
350 // does not focus a new new popup window. 356 // does not focus a new new popup window.
351 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupUnfocused) { 357 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupUnfocused) {
352 browser::NavigateParams p(MakeNavigateParams()); 358 browser::NavigateParams p(MakeNavigateParams());
353 p.disposition = NEW_POPUP; 359 p.disposition = NEW_POPUP;
360 p.window_bounds = gfx::Rect(0, 0, 200, 200);
354 p.window_action = browser::NavigateParams::SHOW_WINDOW_INACTIVE; 361 p.window_action = browser::NavigateParams::SHOW_WINDOW_INACTIVE;
355 browser::Navigate(&p); 362 browser::Navigate(&p);
356 // Wait for new popup to load (and gain focus if the test fails). 363 // Wait for new popup to load (and gain focus if the test fails).
357 ui_test_utils::WaitForNavigationInCurrentTab(p.browser); 364 ui_test_utils::WaitForNavigationInCurrentTab(p.browser);
358 365
359 // Navigate() should have opened a new, unfocused, popup window. 366 // Navigate() should have opened a new, unfocused, popup window.
360 EXPECT_NE(browser(), p.browser); 367 EXPECT_NE(browser(), p.browser);
361 EXPECT_EQ(Browser::TYPE_POPUP, p.browser->type()); 368 EXPECT_EQ(Browser::TYPE_POPUP, p.browser->type());
362 #if 0 369 #if 0
363 // TODO(stevenjb): Enable this test. See: crbug.com/79493 370 // TODO(stevenjb): Enable this test. See: crbug.com/79493
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 814
808 // The bookmarks page should be opened in browser() window. 815 // The bookmarks page should be opened in browser() window.
809 EXPECT_NE(incognito_browser, p.browser); 816 EXPECT_NE(incognito_browser, p.browser);
810 EXPECT_EQ(browser(), p.browser); 817 EXPECT_EQ(browser(), p.browser);
811 EXPECT_EQ(2, browser()->tab_count()); 818 EXPECT_EQ(2, browser()->tab_count());
812 EXPECT_EQ(GURL("chrome://bookmarks"), 819 EXPECT_EQ(GURL("chrome://bookmarks"),
813 browser()->GetSelectedTabContents()->GetURL()); 820 browser()->GetSelectedTabContents()->GetURL());
814 } 821 }
815 822
816 } // namespace 823 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698