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

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

Issue 10105030: TabContents -> WebContentsImpl, part 21. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/browser_navigator_browsertest.h" 5 #include "chrome/browser/ui/browser_navigator_browsertest.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/autocomplete/autocomplete_edit.h" 9 #include "chrome/browser/autocomplete/autocomplete_edit.h"
10 #include "chrome/browser/prefs/incognito_mode_prefs.h" 10 #include "chrome/browser/prefs/incognito_mode_prefs.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 EXPECT_EQ(1, browser()->tab_count()); 173 EXPECT_EQ(1, browser()->tab_count());
174 } 174 }
175 175
176 // This test verifies that a singleton tab is refocused if one is already opened 176 // This test verifies that a singleton tab is refocused if one is already opened
177 // in another or an existing window, or added if it is not. 177 // in another or an existing window, or added if it is not.
178 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SingletonTabExisting) { 178 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SingletonTabExisting) {
179 GURL singleton_url1("http://maps.google.com/"); 179 GURL singleton_url1("http://maps.google.com/");
180 180
181 // Register for a notification if an additional tab_contents was instantiated. 181 // Register for a notification if an additional tab_contents was instantiated.
182 // Opening a Singleton tab that is already opened should not be opening a new 182 // Opening a Singleton tab that is already opened should not be opening a new
183 // tab nor be creating a new TabContents object 183 // tab nor be creating a new TabContentsWrapper object.
184 content::NotificationRegistrar registrar; 184 content::NotificationRegistrar registrar;
185 185
186 // As the registrar object goes out of scope, this will get unregistered 186 // As the registrar object goes out of scope, this will get unregistered
187 registrar.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, 187 registrar.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB,
188 content::NotificationService::AllSources()); 188 content::NotificationService::AllSources());
189 189
190 browser()->AddSelectedTabWithURL( 190 browser()->AddSelectedTabWithURL(
191 singleton_url1, content::PAGE_TRANSITION_LINK); 191 singleton_url1, content::PAGE_TRANSITION_LINK);
192 browser()->AddSelectedTabWithURL( 192 browser()->AddSelectedTabWithURL(
193 GetGoogleURL(), content::PAGE_TRANSITION_LINK); 193 GetGoogleURL(), content::PAGE_TRANSITION_LINK);
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SaveToDisk) { 606 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SaveToDisk) {
607 RunSuppressTest(SAVE_TO_DISK); 607 RunSuppressTest(SAVE_TO_DISK);
608 } 608 }
609 609
610 // This test verifies that no navigation action occurs when 610 // This test verifies that no navigation action occurs when
611 // WindowOpenDisposition = IGNORE_ACTION. 611 // WindowOpenDisposition = IGNORE_ACTION.
612 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_IgnoreAction) { 612 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_IgnoreAction) {
613 RunSuppressTest(IGNORE_ACTION); 613 RunSuppressTest(IGNORE_ACTION);
614 } 614 }
615 615
616 // This tests adding a foreground tab with a predefined TabContents. 616 // This tests adding a foreground tab with a predefined TabContentsWrapper.
617 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, TargetContents_ForegroundTab) { 617 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, TargetContents_ForegroundTab) {
618 browser::NavigateParams p(MakeNavigateParams()); 618 browser::NavigateParams p(MakeNavigateParams());
619 p.disposition = NEW_FOREGROUND_TAB; 619 p.disposition = NEW_FOREGROUND_TAB;
620 p.target_contents = CreateTabContents(); 620 p.target_contents = CreateTabContents();
621 browser::Navigate(&p); 621 browser::Navigate(&p);
622 622
623 // Navigate() should have opened the contents in a new foreground in the 623 // Navigate() should have opened the contents in a new foreground in the
624 // current Browser. 624 // current Browser.
625 EXPECT_EQ(browser(), p.browser); 625 EXPECT_EQ(browser(), p.browser);
626 EXPECT_EQ(browser()->GetSelectedTabContentsWrapper(), p.target_contents); 626 EXPECT_EQ(browser()->GetSelectedTabContentsWrapper(), p.target_contents);
627 627
628 // We should have one window, with two tabs. 628 // We should have one window, with two tabs.
629 EXPECT_EQ(1u, BrowserList::size()); 629 EXPECT_EQ(1u, BrowserList::size());
630 EXPECT_EQ(2, browser()->tab_count()); 630 EXPECT_EQ(2, browser()->tab_count());
631 } 631 }
632 632
633 #if defined(OS_WIN) 633 #if defined(OS_WIN)
634 // This tests adding a popup with a predefined TabContents. 634 // This tests adding a popup with a predefined TabContentsWrapper.
635 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, DISABLED_TargetContents_Popup) { 635 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, DISABLED_TargetContents_Popup) {
636 browser::NavigateParams p(MakeNavigateParams()); 636 browser::NavigateParams p(MakeNavigateParams());
637 p.disposition = NEW_POPUP; 637 p.disposition = NEW_POPUP;
638 p.target_contents = CreateTabContents(); 638 p.target_contents = CreateTabContents();
639 p.window_bounds = gfx::Rect(10, 10, 500, 500); 639 p.window_bounds = gfx::Rect(10, 10, 500, 500);
640 browser::Navigate(&p); 640 browser::Navigate(&p);
641 641
642 // Navigate() should have opened a new popup window. 642 // Navigate() should have opened a new popup window.
643 EXPECT_NE(browser(), p.browser); 643 EXPECT_NE(browser(), p.browser);
644 EXPECT_TRUE(p.browser->is_type_popup()); 644 EXPECT_TRUE(p.browser->is_type_popup());
645 EXPECT_FALSE(p.browser->is_app()); 645 EXPECT_FALSE(p.browser->is_app());
646 646
647 // The web platform is weird. The window bounds specified in 647 // The web platform is weird. The window bounds specified in
648 // |p.window_bounds| are used as follows: 648 // |p.window_bounds| are used as follows:
649 // - the origin is used to position the window 649 // - the origin is used to position the window
650 // - the size is used to size the TabContents of the window. 650 // - the size is used to size the TabContentsWrapper of the window.
651 // As such the position of the resulting window will always match 651 // As such the position of the resulting window will always match
652 // p.window_bounds.origin(), but its size will not. We need to match 652 // p.window_bounds.origin(), but its size will not. We need to match
653 // the size against the selected tab's view's container size. 653 // the size against the selected tab's view's container size.
654 // Only Windows positions the window according to |p.window_bounds.origin()| - 654 // Only Windows positions the window according to |p.window_bounds.origin()| -
655 // on Mac the window is offset from the opener and on Linux it always opens 655 // on Mac the window is offset from the opener and on Linux it always opens
656 // at 0,0. 656 // at 0,0.
657 EXPECT_EQ(p.window_bounds.origin(), 657 EXPECT_EQ(p.window_bounds.origin(),
658 p.browser->window()->GetRestoredBounds().origin()); 658 p.browser->window()->GetRestoredBounds().origin());
659 // All platforms should respect size however provided width > 400 (Mac has a 659 // All platforms should respect size however provided width > 400 (Mac has a
660 // minimum window width of 400). 660 // minimum window width of 400).
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
1323 EXPECT_EQ(browser(), p2.browser); 1323 EXPECT_EQ(browser(), p2.browser);
1324 1324
1325 // We should now have two windows, the browser() provided by the framework and 1325 // We should now have two windows, the browser() provided by the framework and
1326 // the panel window we opened earlier. The tabbed browser window has 2 tabs. 1326 // the panel window we opened earlier. The tabbed browser window has 2 tabs.
1327 EXPECT_EQ(2u, BrowserList::size()); 1327 EXPECT_EQ(2u, BrowserList::size());
1328 EXPECT_EQ(2, browser()->tab_count()); 1328 EXPECT_EQ(2, browser()->tab_count());
1329 EXPECT_EQ(1, panel_browser->tab_count()); 1329 EXPECT_EQ(1, panel_browser->tab_count());
1330 } 1330 }
1331 1331
1332 } // namespace 1332 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_navigator.cc ('k') | chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698