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

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: use golden ratio 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 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 TestCreateSettingsMenuForExtension( 829 TestCreateSettingsMenuForExtension(
830 FILE_PATH_LITERAL("extension1"), Extension::EXTERNAL_POLICY_DOWNLOAD, 830 FILE_PATH_LITERAL("extension1"), Extension::EXTERNAL_POLICY_DOWNLOAD,
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 set_testing_work_area(gfx::Rect(0, 0, 1200, 900));
839 840
840 // Create a test panel with tab contents loaded. 841 // Create a test panel with tab contents loaded.
841 CreatePanelParams params("PanelTest1", gfx::Rect(0, 0, 100, 100), 842 CreatePanelParams params("PanelTest1", gfx::Rect(), SHOW_AS_ACTIVE);
842 SHOW_AS_ACTIVE);
843 params.url = GURL(chrome::kAboutBlankURL);
844 Panel* panel = CreatePanelWithParams(params);
845
846 // Load the test page.
847 GURL url(ui_test_utils::GetTestUrl( 843 GURL url(ui_test_utils::GetTestUrl(
848 FilePath(kTestDir), 844 FilePath(kTestDir),
849 FilePath(FILE_PATH_LITERAL("update-preferred-size.html")))); 845 FilePath(FILE_PATH_LITERAL("update-preferred-size.html"))));
850 ui_test_utils::NavigateToURL(panel->browser(), url); 846 params.url = url;
851 847 Panel* panel = CreatePanelWithParams(params);
852 gfx::Rect initial_bounds = panel->GetBounds();
853 EXPECT_LE(100, initial_bounds.width());
854 EXPECT_LE(100, initial_bounds.height());
855 848
856 // Expand the test page. 849 // Expand the test page.
850 gfx::Rect initial_bounds = panel->GetBounds();
857 ui_test_utils::WindowedNotificationObserver enlarge( 851 ui_test_utils::WindowedNotificationObserver enlarge(
858 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, 852 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED,
859 content::Source<Panel>(panel)); 853 content::Source<Panel>(panel));
860 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( 854 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript(
861 panel->browser()->GetSelectedTabContents()->render_view_host(), 855 panel->browser()->GetSelectedTabContents()->render_view_host(),
862 std::wstring(), 856 std::wstring(),
863 L"changeSize(50);")); 857 L"changeSize(50);"));
864 enlarge.Wait(); 858 enlarge.Wait();
865 gfx::Rect bounds_on_grow = panel->GetBounds(); 859 gfx::Rect bounds_on_grow = panel->GetBounds();
866 EXPECT_GT(bounds_on_grow.width(), initial_bounds.width()); 860 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); 1447 PanelManager::GetInstance()->enable_auto_sizing(true);
1454 1448
1455 // Load contents into regular tabbed browser. 1449 // Load contents into regular tabbed browser.
1456 GURL url(ui_test_utils::GetTestUrl( 1450 GURL url(ui_test_utils::GetTestUrl(
1457 FilePath(kTestDir), 1451 FilePath(kTestDir),
1458 FilePath(FILE_PATH_LITERAL("update-preferred-size.html")))); 1452 FilePath(FILE_PATH_LITERAL("update-preferred-size.html"))));
1459 ui_test_utils::NavigateToURL(browser(), url); 1453 ui_test_utils::NavigateToURL(browser(), url);
1460 EXPECT_EQ(1, browser()->tab_count()); 1454 EXPECT_EQ(1, browser()->tab_count());
1461 1455
1462 Profile* profile = browser()->profile(); 1456 Profile* profile = browser()->profile();
1463 CreatePanelParams params("PanelTest1", gfx::Rect(0, 0, 100, 100), 1457 CreatePanelParams params("PanelTest1", gfx::Rect(), SHOW_AS_ACTIVE);
1464 SHOW_AS_ACTIVE);
1465 Panel* panel = CreatePanelWithParams(params); 1458 Panel* panel = CreatePanelWithParams(params);
1466 Browser* panel_browser = panel->browser(); 1459 Browser* panel_browser = panel->browser();
1467 EXPECT_EQ(2U, BrowserList::size()); 1460 EXPECT_EQ(2U, BrowserList::size());
1468 1461
1469 // Swap tab contents over to the panel from the tabbed browser. 1462 // Swap tab contents over to the panel from the tabbed browser.
1470 TabContentsWrapper* contents = 1463 TabContentsWrapper* contents =
1471 browser()->tabstrip_model()->DetachTabContentsAt(0); 1464 browser()->tabstrip_model()->DetachTabContentsAt(0);
1472 panel_browser->tabstrip_model()->InsertTabContentsAt( 1465 panel_browser->tabstrip_model()->InsertTabContentsAt(
1473 0, contents, TabStripModel::ADD_NONE); 1466 0, contents, TabStripModel::ADD_NONE);
1474 panel_browser->SelectNumberedTab(0); 1467 panel_browser->SelectNumberedTab(0);
1475 EXPECT_EQ(contents, panel_browser->GetSelectedTabContentsWrapper()); 1468 EXPECT_EQ(contents, panel_browser->GetSelectedTabContentsWrapper());
1476 EXPECT_EQ(1, PanelManager::GetInstance()->num_panels()); 1469 EXPECT_EQ(1, PanelManager::GetInstance()->num_panels());
1477 1470
1478 // Ensure that the tab contents were noticed by the panel by 1471 // Ensure that the tab contents were noticed by the panel by
1479 // verifying that the panel auto resizes correctly. (Panel 1472 // verifying that the panel auto resizes correctly. (Panel
1480 // enables auto resizing when tab contents are detected.) 1473 // enables auto resizing when tab contents are detected.)
1481 int initial_width = panel->GetBounds().width(); 1474 int initial_width = panel->GetBounds().width();
1482 EXPECT_LE(100, initial_width);
1483
1484 // Expand the test page.
1485 ui_test_utils::WindowedNotificationObserver enlarge( 1475 ui_test_utils::WindowedNotificationObserver enlarge(
1486 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, 1476 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED,
1487 content::Source<Panel>(panel)); 1477 content::Source<Panel>(panel));
1488 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( 1478 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript(
1489 panel_browser->GetSelectedTabContents()->render_view_host(), 1479 panel_browser->GetSelectedTabContents()->render_view_host(),
1490 std::wstring(), 1480 std::wstring(),
1491 L"changeSize(50);")); 1481 L"changeSize(50);"));
1492 enlarge.Wait(); 1482 enlarge.Wait();
1493 EXPECT_GT(panel->GetBounds().width(), initial_width); 1483 EXPECT_GT(panel->GetBounds().width(), initial_width);
1494 1484
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1832 // position when tall panel brings up its titlebar. 1822 // position when tall panel brings up its titlebar.
1833 CloseWindowAndWait(panel1->browser()); 1823 CloseWindowAndWait(panel1->browser());
1834 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up, 1824 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up,
1835 GetBalloonBottomPosition(balloon)); 1825 GetBalloonBottomPosition(balloon));
1836 1826
1837 // Closing the remaining tall panel should move the notification balloon back 1827 // Closing the remaining tall panel should move the notification balloon back
1838 // to its original position. 1828 // to its original position.
1839 CloseWindowAndWait(panel2->browser()); 1829 CloseWindowAndWait(panel2->browser());
1840 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon)); 1830 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon));
1841 } 1831 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_browser_window_gtk.cc ('k') | chrome/browser/ui/panels/panel_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698