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

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: fix assert at the end of RenderWidget::Resize which fixes the tests on OSX. 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
« no previous file with comments | « chrome/browser/ui/panels/panel.cc ('k') | chrome/browser/ui/panels/panel_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 942 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 TestCreateSettingsMenuForExtension( 953 TestCreateSettingsMenuForExtension(
954 FILE_PATH_LITERAL("extension1"), Extension::EXTERNAL_POLICY_DOWNLOAD, 954 FILE_PATH_LITERAL("extension1"), Extension::EXTERNAL_POLICY_DOWNLOAD,
955 "", ""); 955 "", "");
956 TestCreateSettingsMenuForExtension( 956 TestCreateSettingsMenuForExtension(
957 FILE_PATH_LITERAL("extension2"), Extension::INVALID, 957 FILE_PATH_LITERAL("extension2"), Extension::INVALID,
958 "http://home", "options.html"); 958 "http://home", "options.html");
959 } 959 }
960 960
961 // Flaky: http://crbug.com/105445 961 // Flaky: http://crbug.com/105445
962 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DISABLED_AutoResize) { 962 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DISABLED_AutoResize) {
963 PanelManager::GetInstance()->enable_auto_sizing(true); 963 PanelManager* panel_manager = PanelManager::GetInstance();
964 PanelManager::GetInstance()->SetWorkAreaForTesting( 964 panel_manager->enable_auto_sizing(true);
965 gfx::Rect(0, 0, 1200, 900)); // bigger space is needed by this test 965 // Bigger space is needed by this test.
966 panel_manager->SetWorkAreaForTesting(gfx::Rect(0, 0, 1200, 900));
966 967
967 // Create a test panel with tab contents loaded. 968 // Create a test panel with tab contents loaded.
968 CreatePanelParams params("PanelTest1", gfx::Rect(), SHOW_AS_ACTIVE); 969 CreatePanelParams params("PanelTest1", gfx::Rect(), SHOW_AS_ACTIVE);
969 GURL url(ui_test_utils::GetTestUrl( 970 GURL url(ui_test_utils::GetTestUrl(
970 FilePath(kTestDir), 971 FilePath(kTestDir),
971 FilePath(FILE_PATH_LITERAL("update-preferred-size.html")))); 972 FilePath(FILE_PATH_LITERAL("update-preferred-size.html"))));
972 params.url = url; 973 params.url = url;
973 Panel* panel = CreatePanelWithParams(params); 974 Panel* panel = CreatePanelWithParams(params);
974 975
975 // Expand the test page. 976 // Expand the test page.
(...skipping 17 matching lines...) Expand all
993 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( 994 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript(
994 panel->browser()->GetSelectedWebContents()->GetRenderViewHost(), 995 panel->browser()->GetSelectedWebContents()->GetRenderViewHost(),
995 std::wstring(), 996 std::wstring(),
996 L"changeSize(-30);")); 997 L"changeSize(-30);"));
997 shrink.Wait(); 998 shrink.Wait();
998 gfx::Rect bounds_on_shrink = panel->GetBounds(); 999 gfx::Rect bounds_on_shrink = panel->GetBounds();
999 EXPECT_LT(bounds_on_shrink.width(), bounds_on_grow.width()); 1000 EXPECT_LT(bounds_on_shrink.width(), bounds_on_grow.width());
1000 EXPECT_GT(bounds_on_shrink.width(), initial_bounds.width()); 1001 EXPECT_GT(bounds_on_shrink.width(), initial_bounds.width());
1001 EXPECT_EQ(bounds_on_shrink.height(), initial_bounds.height()); 1002 EXPECT_EQ(bounds_on_shrink.height(), initial_bounds.height());
1002 1003
1004 // Verify resizing turns off auto-resizing and that it works.
1005 gfx::Rect previous_bounds = panel->GetBounds();
1006 // These should be identical because the panel is expanded.
1007 EXPECT_EQ(previous_bounds.size(), panel->GetRestoredBounds().size());
1008 gfx::Size new_size(previous_bounds.size());
1009 new_size.Enlarge(5, 5);
1010 panel_manager->ResizePanel(panel, new_size);
1011 EXPECT_FALSE(panel->auto_resizable());
1012 EXPECT_EQ(new_size, panel->GetBounds().size());
1013 EXPECT_EQ(new_size, panel->GetRestoredBounds().size());
1014
1015 // Turn back on auto-resize and verify that it works.
1016 ui_test_utils::WindowedNotificationObserver auto_resize_enabled(
1017 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED,
1018 content::Source<Panel>(panel));
1019 panel->SetAutoResizable(true);
1020 auto_resize_enabled.Wait();
1021 gfx::Rect bounds_auto_resize_enabled = panel->GetBounds();
1022 EXPECT_EQ(bounds_on_shrink.width(), bounds_auto_resize_enabled.width());
1023 EXPECT_EQ(bounds_on_shrink.height(), bounds_auto_resize_enabled.height());
1024
1003 panel->Close(); 1025 panel->Close();
1004 } 1026 }
1005 1027
1006 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, ResizePanel) { 1028 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, ResizePanel) {
1007 PanelManager* panel_manager = PanelManager::GetInstance(); 1029 PanelManager* panel_manager = PanelManager::GetInstance();
1008 panel_manager->enable_auto_sizing(true); 1030 panel_manager->enable_auto_sizing(true);
1009 1031
1010 Panel* panel = CreatePanel("TestPanel"); 1032 Panel* panel = CreatePanel("TestPanel");
1011 EXPECT_TRUE(panel->auto_resizable()); 1033 EXPECT_TRUE(panel->auto_resizable());
1012 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); 1034 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state());
1013 1035
1014 // Verify resizing an auto-resizable panel is a no-op for now. 1036 // Verify resizing turns off auto-resizing and that it works.
1015 // http://crbug.com/109343
1016 gfx::Rect original_bounds = panel->GetBounds(); 1037 gfx::Rect original_bounds = panel->GetBounds();
1017 gfx::Rect original_restored_bounds = panel->GetRestoredBounds(); 1038 // These should be identical because the panel is expanded.
1018 gfx::Size new_size(150, 200); 1039 EXPECT_EQ(original_bounds.size(), panel->GetRestoredBounds().size());
1019 panel_manager->ResizePanel(panel, new_size); 1040 gfx::Size new_size(original_bounds.size());
1020 EXPECT_EQ(original_bounds, panel->GetBounds()); 1041 new_size.Enlarge(5, 5);
1021 EXPECT_EQ(original_restored_bounds, panel->GetRestoredBounds());
1022
1023 // Verify resizing adjusts bounds correctly when not auto-resizable.
1024 panel->SetAutoResizable(false);
1025 panel_manager->ResizePanel(panel, new_size); 1042 panel_manager->ResizePanel(panel, new_size);
1026 EXPECT_FALSE(panel->auto_resizable()); 1043 EXPECT_FALSE(panel->auto_resizable());
1027 EXPECT_EQ(new_size, panel->GetBounds().size()); 1044 EXPECT_EQ(new_size, panel->GetBounds().size());
1028 EXPECT_EQ(new_size, panel->GetRestoredBounds().size()); 1045 EXPECT_EQ(new_size, panel->GetRestoredBounds().size());
1029 1046
1030 // Verify current height unaffected when panel is not expanded. 1047 // Verify current height unaffected when panel is not expanded.
1031 panel->SetExpansionState(Panel::MINIMIZED); 1048 panel->SetExpansionState(Panel::MINIMIZED);
1032 int original_height = panel->GetBounds().height(); 1049 int original_height = panel->GetBounds().height();
1033 new_size.Enlarge(5, 5); 1050 new_size.Enlarge(5, 5);
1034 panel_manager->ResizePanel(panel, new_size); 1051 panel_manager->ResizePanel(panel, new_size);
(...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2156 // position when tall panel brings up its titlebar. 2173 // position when tall panel brings up its titlebar.
2157 CloseWindowAndWait(panel1->browser()); 2174 CloseWindowAndWait(panel1->browser());
2158 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up, 2175 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up,
2159 GetBalloonBottomPosition(balloon)); 2176 GetBalloonBottomPosition(balloon));
2160 2177
2161 // Closing the remaining tall panel should move the notification balloon back 2178 // Closing the remaining tall panel should move the notification balloon back
2162 // to its original position. 2179 // to its original position.
2163 CloseWindowAndWait(panel2->browser()); 2180 CloseWindowAndWait(panel2->browser());
2164 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon)); 2181 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon));
2165 } 2182 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel.cc ('k') | chrome/browser/ui/panels/panel_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698