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

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

Issue 9517010: Change panels to be able to turn off autoresize. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ensure that the latest version is uploaded. Created 8 years, 9 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/download/download_service.h" 8 #include "chrome/browser/download/download_service.h"
9 #include "chrome/browser/download/download_service_factory.h" 9 #include "chrome/browser/download/download_service_factory.h"
10 #include "chrome/browser/net/url_request_mock_util.h" 10 #include "chrome/browser/net/url_request_mock_util.h"
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CreateSettingsMenu) { 793 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CreateSettingsMenu) {
794 TestCreateSettingsMenuForExtension( 794 TestCreateSettingsMenuForExtension(
795 FILE_PATH_LITERAL("extension1"), Extension::EXTERNAL_POLICY_DOWNLOAD, 795 FILE_PATH_LITERAL("extension1"), Extension::EXTERNAL_POLICY_DOWNLOAD,
796 "", ""); 796 "", "");
797 TestCreateSettingsMenuForExtension( 797 TestCreateSettingsMenuForExtension(
798 FILE_PATH_LITERAL("extension2"), Extension::INVALID, 798 FILE_PATH_LITERAL("extension2"), Extension::INVALID,
799 "http://home", "options.html"); 799 "http://home", "options.html");
800 } 800 }
801 801
802 // Flaky: http://crbug.com/105445 802 // Flaky: http://crbug.com/105445
803 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DISABLED_AutoResize) { 803 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, AutoResize) {
jennb 2012/02/29 19:46:00 Remember to leave this DISABLED before commit as i
levin 2012/02/29 23:48:28 Done. Thanks!
804 PanelManager::GetInstance()->enable_auto_sizing(true); 804 PanelManager* panel_manager = PanelManager::GetInstance();
805 PanelManager::GetInstance()->SetWorkAreaForTesting( 805 panel_manager->enable_auto_sizing(true);
806 gfx::Rect(0, 0, 1200, 900)); // bigger space is needed by this test 806 // Bigger space is needed by this test.
807 panel_manager->SetWorkAreaForTesting(gfx::Rect(0, 0, 1200, 900));
807 808
808 // Create a test panel with tab contents loaded. 809 // Create a test panel with tab contents loaded.
809 CreatePanelParams params("PanelTest1", gfx::Rect(), SHOW_AS_ACTIVE); 810 CreatePanelParams params("PanelTest1", gfx::Rect(), SHOW_AS_ACTIVE);
810 GURL url(ui_test_utils::GetTestUrl( 811 GURL url(ui_test_utils::GetTestUrl(
811 FilePath(kTestDir), 812 FilePath(kTestDir),
812 FilePath(FILE_PATH_LITERAL("update-preferred-size.html")))); 813 FilePath(FILE_PATH_LITERAL("update-preferred-size.html"))));
813 params.url = url; 814 params.url = url;
814 Panel* panel = CreatePanelWithParams(params); 815 Panel* panel = CreatePanelWithParams(params);
815 816
816 // Expand the test page. 817 // Expand the test page.
(...skipping 17 matching lines...) Expand all
834 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( 835 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript(
835 panel->browser()->GetSelectedWebContents()->GetRenderViewHost(), 836 panel->browser()->GetSelectedWebContents()->GetRenderViewHost(),
836 std::wstring(), 837 std::wstring(),
837 L"changeSize(-30);")); 838 L"changeSize(-30);"));
838 shrink.Wait(); 839 shrink.Wait();
839 gfx::Rect bounds_on_shrink = panel->GetBounds(); 840 gfx::Rect bounds_on_shrink = panel->GetBounds();
840 EXPECT_LT(bounds_on_shrink.width(), bounds_on_grow.width()); 841 EXPECT_LT(bounds_on_shrink.width(), bounds_on_grow.width());
841 EXPECT_GT(bounds_on_shrink.width(), initial_bounds.width()); 842 EXPECT_GT(bounds_on_shrink.width(), initial_bounds.width());
842 EXPECT_EQ(bounds_on_shrink.height(), initial_bounds.height()); 843 EXPECT_EQ(bounds_on_shrink.height(), initial_bounds.height());
843 844
845 // Verify resizing turns off auto-resizing and that it works.
846 gfx::Rect previous_bounds = panel->GetBounds();
847 // These should be identical because the panel is expanded.
848 EXPECT_EQ(previous_bounds.size(), panel->GetRestoredBounds().size());
849 gfx::Size new_size(previous_bounds.size());
850 new_size.Enlarge(5, 5);
851 panel_manager->ResizePanel(panel, new_size);
852 EXPECT_FALSE(panel->auto_resizable());
853 EXPECT_EQ(new_size, panel->GetBounds().size());
854 EXPECT_EQ(new_size, panel->GetRestoredBounds().size());
855
856 // Turn back on auto-resize and verify that it works.
857 ui_test_utils::WindowedNotificationObserver auto_resize_enabled(
858 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED,
859 content::Source<Panel>(panel));
860 panel->SetAutoResizable(true);
861 auto_resize_enabled.Wait();
862 gfx::Rect bounds_auto_resize_enabled = panel->GetBounds();
863 EXPECT_EQ(bounds_on_shrink.width(), bounds_auto_resize_enabled.width());
864 EXPECT_EQ(bounds_on_shrink.height(), bounds_auto_resize_enabled.height());
865
844 panel->Close(); 866 panel->Close();
845 } 867 }
846 868
847 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, ResizePanel) { 869 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, ResizePanel) {
848 PanelManager* panel_manager = PanelManager::GetInstance(); 870 PanelManager* panel_manager = PanelManager::GetInstance();
849 panel_manager->enable_auto_sizing(true); 871 panel_manager->enable_auto_sizing(true);
850 872
851 Panel* panel = CreatePanel("TestPanel"); 873 Panel* panel = CreatePanel("TestPanel");
852 EXPECT_TRUE(panel->auto_resizable()); 874 EXPECT_TRUE(panel->auto_resizable());
853 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); 875 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state());
854 876
855 // Verify resizing an auto-resizable panel is a no-op for now. 877 // Verify resizing turns off auto-resizing and that it works.
856 // http://crbug.com/109343
857 gfx::Rect original_bounds = panel->GetBounds(); 878 gfx::Rect original_bounds = panel->GetBounds();
858 gfx::Rect original_restored_bounds = panel->GetRestoredBounds(); 879 // These should be identical because the panel is expanded.
859 gfx::Size new_size(150, 200); 880 EXPECT_EQ(original_bounds.size(), panel->GetRestoredBounds().size());
860 panel_manager->ResizePanel(panel, new_size); 881 gfx::Size new_size(original_bounds.size());
861 EXPECT_EQ(original_bounds, panel->GetBounds()); 882 new_size.Enlarge(5, 5);
862 EXPECT_EQ(original_restored_bounds, panel->GetRestoredBounds());
863
864 // Verify resizing adjusts bounds correctly when not auto-resizable.
865 panel->SetAutoResizable(false);
866 panel_manager->ResizePanel(panel, new_size); 883 panel_manager->ResizePanel(panel, new_size);
867 EXPECT_FALSE(panel->auto_resizable()); 884 EXPECT_FALSE(panel->auto_resizable());
868 EXPECT_EQ(new_size, panel->GetBounds().size()); 885 EXPECT_EQ(new_size, panel->GetBounds().size());
869 EXPECT_EQ(new_size, panel->GetRestoredBounds().size()); 886 EXPECT_EQ(new_size, panel->GetRestoredBounds().size());
870 887
871 // Verify current height unaffected when panel is not expanded. 888 // Verify current height unaffected when panel is not expanded.
872 panel->SetExpansionState(Panel::MINIMIZED); 889 panel->SetExpansionState(Panel::MINIMIZED);
873 int original_height = panel->GetBounds().height(); 890 int original_height = panel->GetBounds().height();
874 new_size.Enlarge(5, 5); 891 new_size.Enlarge(5, 5);
875 panel_manager->ResizePanel(panel, new_size); 892 panel_manager->ResizePanel(panel, new_size);
(...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1997 // position when tall panel brings up its titlebar. 2014 // position when tall panel brings up its titlebar.
1998 CloseWindowAndWait(panel1->browser()); 2015 CloseWindowAndWait(panel1->browser());
1999 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up, 2016 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up,
2000 GetBalloonBottomPosition(balloon)); 2017 GetBalloonBottomPosition(balloon));
2001 2018
2002 // Closing the remaining tall panel should move the notification balloon back 2019 // Closing the remaining tall panel should move the notification balloon back
2003 // to its original position. 2020 // to its original position.
2004 CloseWindowAndWait(panel2->browser()); 2021 CloseWindowAndWait(panel2->browser());
2005 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon)); 2022 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon));
2006 } 2023 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698