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

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

Issue 4055004: Change window opening behavior for HtmlDialogTabContentsDelegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased from trunk and fixed comments in HtmlDialogTabContentsDelegate Created 10 years, 1 month 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/browser.h" 5 #include "chrome/browser/browser.h"
6 #include "chrome/browser/browser_list.h" 6 #include "chrome/browser/browser_list.h"
7 #include "chrome/browser/browser_navigator.h" 7 #include "chrome/browser/browser_navigator.h"
8 #include "chrome/browser/browser_window.h" 8 #include "chrome/browser/browser_window.h"
9 #include "chrome/browser/profile.h" 9 #include "chrome/browser/profile.h"
10 #include "chrome/browser/tab_contents/tab_contents.h" 10 #include "chrome/browser/tab_contents/tab_contents.h"
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 // Navigate() should have inserted a new tab at slot 0 in the tabstrip. 400 // Navigate() should have inserted a new tab at slot 0 in the tabstrip.
401 EXPECT_EQ(browser(), p.browser); 401 EXPECT_EQ(browser(), p.browser);
402 EXPECT_EQ(0, browser()->tabstrip_model()->GetIndexOfTabContents( 402 EXPECT_EQ(0, browser()->tabstrip_model()->GetIndexOfTabContents(
403 static_cast<const TabContents*>(p.target_contents))); 403 static_cast<const TabContents*>(p.target_contents)));
404 404
405 // We should have one window - the browser() provided by the framework. 405 // We should have one window - the browser() provided by the framework.
406 EXPECT_EQ(1u, BrowserList::size()); 406 EXPECT_EQ(1u, BrowserList::size());
407 EXPECT_EQ(2, browser()->tab_count()); 407 EXPECT_EQ(2, browser()->tab_count());
408 } 408 }
409 409
410 // This test verifies that constructing params with a NULL browser has
411 // the same result as navigating to a new foreground tab in the (only)
412 // active browser. Tests are the same as for Disposition_NewForegroundTab.
413 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_NewForegroundTab) {
414 TabContents* old_contents = browser()->GetSelectedTabContents();
415 // Navigate with a NULL browser.
416 browser::NavigateParams p(MakeNavigateParams(NULL));
417 p.disposition = NEW_FOREGROUND_TAB;
418 p.profile = browser()->profile();
419 browser::Navigate(&p);
420
421 // Navigate() should have found browser() and create a new tab.
422 EXPECT_EQ(browser(), p.browser);
423 EXPECT_NE(old_contents, browser()->GetSelectedTabContents());
424 EXPECT_EQ(browser()->GetSelectedTabContents(), p.target_contents);
425 EXPECT_EQ(2, browser()->tab_count());
426 }
427
428 // This test verifies that constructing params with a NULL browser and
429 // a specific profile matches the specified profile.
430 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_MatchProfile) {
431 // Create a new browser with using the incognito profile.
432 Browser* incognito =
433 Browser::Create(browser()->profile()->GetOffTheRecordProfile());
434
435 // Navigate with a NULL browser and the incognito profile.
436 browser::NavigateParams p(MakeNavigateParams(NULL));
437 p.disposition = NEW_FOREGROUND_TAB;
438 p.profile = incognito->profile();
439 browser::Navigate(&p);
440
441 // Navigate() should have found incognito, not browser().
442 EXPECT_EQ(incognito, p.browser);
443 EXPECT_EQ(incognito->GetSelectedTabContents(), p.target_contents);
444 EXPECT_EQ(1, incognito->tab_count());
445 }
446
447 // This test verifies that constructing params with a NULL browser and
448 // disposition = NEW_WINDOW always opens exactly one new window.
449 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_NewWindow) {
450 browser::NavigateParams p(MakeNavigateParams(NULL));
451 p.disposition = NEW_WINDOW;
452 p.profile = browser()->profile();
453 browser::Navigate(&p);
454
455 // Navigate() should have created a new browser.
456 EXPECT_NE(browser(), p.browser);
457 EXPECT_EQ(Browser::TYPE_NORMAL, p.browser->type());
458
459 // We should now have two windows, the browser() provided by the framework and
460 // the new normal window.
461 EXPECT_EQ(2u, BrowserList::size());
462 EXPECT_EQ(1, browser()->tab_count());
463 EXPECT_EQ(1, p.browser->tab_count());
464 }
465
466
410 } // namespace 467 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/browser_navigator.cc ('k') | chrome/browser/dom_ui/html_dialog_tab_contents_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698