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

Side by Side Diff: chrome/browser/ui/panels/panel_browsertest.cc

Issue 8602007: Panels: Disable auto-resize if initial size is specified during creation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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) 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/string_number_conversions.h" 6 #include "base/string_number_conversions.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/download/download_service.h" 9 #include "chrome/browser/download/download_service.h"
10 #include "chrome/browser/download/download_service_factory.h" 10 #include "chrome/browser/download/download_service_factory.h"
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 "", ""); 831 "", "");
832 TestCreateSettingsMenuForExtension( 832 TestCreateSettingsMenuForExtension(
833 FILE_PATH_LITERAL("extension2"), Extension::INVALID, 833 FILE_PATH_LITERAL("extension2"), Extension::INVALID,
834 "http://home", "options.html"); 834 "http://home", "options.html");
835 } 835 }
836 836
837 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, AutoResize) { 837 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, AutoResize) {
838 PanelManager::GetInstance()->enable_auto_sizing(true); 838 PanelManager::GetInstance()->enable_auto_sizing(true);
839 839
840 // Create a test panel with tab contents loaded. 840 // Create a test panel with tab contents loaded.
841 CreatePanelParams params("PanelTest1", gfx::Rect(0, 0, 100, 100), 841 CreatePanelParams params("PanelTest1", gfx::Rect(), SHOW_AS_ACTIVE);
842 SHOW_AS_ACTIVE);
843 params.url = GURL(chrome::kAboutBlankURL); 842 params.url = GURL(chrome::kAboutBlankURL);
844 Panel* panel = CreatePanelWithParams(params); 843 Panel* panel = CreatePanelWithParams(params);
845 844
846 // Load the test page. 845 // Load the test page.
847 GURL url(ui_test_utils::GetTestUrl( 846 GURL url(ui_test_utils::GetTestUrl(
848 FilePath(kTestDir), 847 FilePath(kTestDir),
849 FilePath(FILE_PATH_LITERAL("update-preferred-size.html")))); 848 FilePath(FILE_PATH_LITERAL("update-preferred-size.html"))));
850 ui_test_utils::NavigateToURL(panel->browser(), url); 849 ui_test_utils::NavigateToURL(panel->browser(), url);
851 850
851 // Expand the test page.
852 gfx::Rect initial_bounds = panel->GetBounds(); 852 gfx::Rect initial_bounds = panel->GetBounds();
853 EXPECT_LE(100, initial_bounds.width());
854 EXPECT_LE(100, initial_bounds.height());
855
856 // Expand the test page.
857 ui_test_utils::WindowedNotificationObserver enlarge( 853 ui_test_utils::WindowedNotificationObserver enlarge(
858 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, 854 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED,
859 content::Source<Panel>(panel)); 855 content::Source<Panel>(panel));
860 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( 856 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript(
861 panel->browser()->GetSelectedTabContents()->render_view_host(), 857 panel->browser()->GetSelectedTabContents()->render_view_host(),
862 std::wstring(), 858 std::wstring(),
863 L"changeSize(50);")); 859 L"changeSize(50);"));
864 enlarge.Wait(); 860 enlarge.Wait();
865 gfx::Rect bounds_on_grow = panel->GetBounds(); 861 gfx::Rect bounds_on_grow = panel->GetBounds();
866 EXPECT_GT(bounds_on_grow.width(), initial_bounds.width()); 862 EXPECT_GT(bounds_on_grow.width(), initial_bounds.width());
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 PanelManager::GetInstance()->enable_auto_sizing(true); 1449 PanelManager::GetInstance()->enable_auto_sizing(true);
1454 1450
1455 // Load contents into regular tabbed browser. 1451 // Load contents into regular tabbed browser.
1456 GURL url(ui_test_utils::GetTestUrl( 1452 GURL url(ui_test_utils::GetTestUrl(
1457 FilePath(kTestDir), 1453 FilePath(kTestDir),
1458 FilePath(FILE_PATH_LITERAL("update-preferred-size.html")))); 1454 FilePath(FILE_PATH_LITERAL("update-preferred-size.html"))));
1459 ui_test_utils::NavigateToURL(browser(), url); 1455 ui_test_utils::NavigateToURL(browser(), url);
1460 EXPECT_EQ(1, browser()->tab_count()); 1456 EXPECT_EQ(1, browser()->tab_count());
1461 1457
1462 Profile* profile = browser()->profile(); 1458 Profile* profile = browser()->profile();
1463 CreatePanelParams params("PanelTest1", gfx::Rect(0, 0, 100, 100), 1459 CreatePanelParams params("PanelTest1", gfx::Rect(), SHOW_AS_ACTIVE);
1464 SHOW_AS_ACTIVE);
1465 Panel* panel = CreatePanelWithParams(params); 1460 Panel* panel = CreatePanelWithParams(params);
1466 Browser* panel_browser = panel->browser(); 1461 Browser* panel_browser = panel->browser();
1467 EXPECT_EQ(2U, BrowserList::size()); 1462 EXPECT_EQ(2U, BrowserList::size());
1468 1463
1469 // Swap tab contents over to the panel from the tabbed browser. 1464 // Swap tab contents over to the panel from the tabbed browser.
1470 TabContentsWrapper* contents = 1465 TabContentsWrapper* contents =
1471 browser()->tabstrip_model()->DetachTabContentsAt(0); 1466 browser()->tabstrip_model()->DetachTabContentsAt(0);
1472 panel_browser->tabstrip_model()->InsertTabContentsAt( 1467 panel_browser->tabstrip_model()->InsertTabContentsAt(
1473 0, contents, TabStripModel::ADD_NONE); 1468 0, contents, TabStripModel::ADD_NONE);
1474 panel_browser->SelectNumberedTab(0); 1469 panel_browser->SelectNumberedTab(0);
1475 EXPECT_EQ(contents, panel_browser->GetSelectedTabContentsWrapper()); 1470 EXPECT_EQ(contents, panel_browser->GetSelectedTabContentsWrapper());
1476 EXPECT_EQ(1, PanelManager::GetInstance()->num_panels()); 1471 EXPECT_EQ(1, PanelManager::GetInstance()->num_panels());
1477 1472
1478 // Ensure that the tab contents were noticed by the panel by 1473 // Ensure that the tab contents were noticed by the panel by
1479 // verifying that the panel auto resizes correctly. (Panel 1474 // verifying that the panel auto resizes correctly. (Panel
1480 // enables auto resizing when tab contents are detected.) 1475 // enables auto resizing when tab contents are detected.)
1481 int initial_width = panel->GetBounds().width(); 1476 int initial_width = panel->GetBounds().width();
1482 EXPECT_LE(100, initial_width);
1483
1484 // Expand the test page.
1485 ui_test_utils::WindowedNotificationObserver enlarge( 1477 ui_test_utils::WindowedNotificationObserver enlarge(
1486 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, 1478 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED,
1487 content::Source<Panel>(panel)); 1479 content::Source<Panel>(panel));
1488 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( 1480 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript(
1489 panel_browser->GetSelectedTabContents()->render_view_host(), 1481 panel_browser->GetSelectedTabContents()->render_view_host(),
1490 std::wstring(), 1482 std::wstring(),
1491 L"changeSize(50);")); 1483 L"changeSize(50);"));
1492 enlarge.Wait(); 1484 enlarge.Wait();
1493 EXPECT_GT(panel->GetBounds().width(), initial_width); 1485 EXPECT_GT(panel->GetBounds().width(), initial_width);
1494 1486
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1832 // position when tall panel brings up its titlebar. 1824 // position when tall panel brings up its titlebar.
1833 CloseWindowAndWait(panel1->browser()); 1825 CloseWindowAndWait(panel1->browser());
1834 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up, 1826 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up,
1835 GetBalloonBottomPosition(balloon)); 1827 GetBalloonBottomPosition(balloon));
1836 1828
1837 // Closing the remaining tall panel should move the notification balloon back 1829 // Closing the remaining tall panel should move the notification balloon back
1838 // to its original position. 1830 // to its original position.
1839 CloseWindowAndWait(panel2->browser()); 1831 CloseWindowAndWait(panel2->browser());
1840 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon)); 1832 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon));
1841 } 1833 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698