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

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: code review fixes 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 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 } 845 }
846 846
847 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, ResizePanel) { 847 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, ResizePanel) {
848 PanelManager* panel_manager = PanelManager::GetInstance(); 848 PanelManager* panel_manager = PanelManager::GetInstance();
849 panel_manager->enable_auto_sizing(true); 849 panel_manager->enable_auto_sizing(true);
850 850
851 Panel* panel = CreatePanel("TestPanel"); 851 Panel* panel = CreatePanel("TestPanel");
852 EXPECT_TRUE(panel->auto_resizable()); 852 EXPECT_TRUE(panel->auto_resizable());
853 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); 853 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state());
854 854
855 // Verify resizing an auto-resizable panel is a no-op for now. 855 // Verify resizing an auto-resizable panel works.
856 // http://crbug.com/109343
857 gfx::Rect original_bounds = panel->GetBounds(); 856 gfx::Rect original_bounds = panel->GetBounds();
858 gfx::Rect original_restored_bounds = panel->GetRestoredBounds(); 857 gfx::Rect original_restored_bounds = panel->GetRestoredBounds();
859 gfx::Size new_size(150, 200); 858 // These should be identical because the panel is expanded.
860 panel_manager->ResizePanel(panel, new_size); 859 EXPECT_EQ(original_bounds.size(), original_restored_bounds.size());
861 EXPECT_EQ(original_bounds, panel->GetBounds()); 860 gfx::Size new_size(original_bounds.size());
862 EXPECT_EQ(original_restored_bounds, panel->GetRestoredBounds()); 861 new_size.Enlarge(5, 5);
863
864 // Verify resizing adjusts bounds correctly when not auto-resizable.
865 panel->SetAutoResizable(false);
866 panel_manager->ResizePanel(panel, new_size); 862 panel_manager->ResizePanel(panel, new_size);
867 EXPECT_FALSE(panel->auto_resizable()); 863 EXPECT_FALSE(panel->auto_resizable());
868 EXPECT_EQ(new_size, panel->GetBounds().size()); 864 EXPECT_EQ(new_size, panel->GetBounds().size());
869 EXPECT_EQ(new_size, panel->GetRestoredBounds().size()); 865 EXPECT_EQ(new_size, panel->GetRestoredBounds().size());
870 866
871 // Verify current height unaffected when panel is not expanded. 867 // Verify current height unaffected when panel is not expanded.
872 panel->SetExpansionState(Panel::MINIMIZED); 868 panel->SetExpansionState(Panel::MINIMIZED);
873 int original_height = panel->GetBounds().height(); 869 int original_height = panel->GetBounds().height();
874 new_size.Enlarge(5, 5); 870 new_size.Enlarge(5, 5);
875 panel_manager->ResizePanel(panel, new_size); 871 panel_manager->ResizePanel(panel, new_size);
876 EXPECT_EQ(new_size.width(), panel->GetBounds().width()); 872 EXPECT_EQ(new_size.width(), panel->GetBounds().width());
877 EXPECT_EQ(original_height, panel->GetBounds().height()); 873 EXPECT_EQ(original_height, panel->GetBounds().height());
878 EXPECT_EQ(new_size, panel->GetRestoredBounds().size()); 874 EXPECT_EQ(new_size, panel->GetRestoredBounds().size());
879 875
876 // Make it autoresized again.
877 panel->SetAutoResizable();
jennb 2012/02/29 00:11:50 takes a param
878 ui_test_utils::WindowedNotificationObserver enlarge(
879 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED,
880 content::Source<Panel>(panel));
881 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript(
882 panel_browser->GetSelectedWebContents()->GetRenderViewHost(),
883 std::wstring(),
884 L"changeSize(50);"));
jennb 2012/02/29 00:11:50 This only applies to the update-preferred-size.htm
885 enlarge.Wait();
886
880 panel->Close(); 887 panel->Close();
881 } 888 }
882 889
883 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, AnimateBounds) { 890 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, AnimateBounds) {
884 Panel* panel = CreatePanelWithBounds("PanelTest", gfx::Rect(0, 0, 100, 100)); 891 Panel* panel = CreatePanelWithBounds("PanelTest", gfx::Rect(0, 0, 100, 100));
885 scoped_ptr<NativePanelTesting> panel_testing( 892 scoped_ptr<NativePanelTesting> panel_testing(
886 NativePanelTesting::Create(panel->native_panel())); 893 NativePanelTesting::Create(panel->native_panel()));
887 894
888 // Set bounds with animation. 895 // Set bounds with animation.
889 gfx::Rect bounds = gfx::Rect(10, 20, 150, 160); 896 gfx::Rect bounds = gfx::Rect(10, 20, 150, 160);
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1997 // position when tall panel brings up its titlebar. 2004 // position when tall panel brings up its titlebar.
1998 CloseWindowAndWait(panel1->browser()); 2005 CloseWindowAndWait(panel1->browser());
1999 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up, 2006 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up,
2000 GetBalloonBottomPosition(balloon)); 2007 GetBalloonBottomPosition(balloon));
2001 2008
2002 // Closing the remaining tall panel should move the notification balloon back 2009 // Closing the remaining tall panel should move the notification balloon back
2003 // to its original position. 2010 // to its original position.
2004 CloseWindowAndWait(panel2->browser()); 2011 CloseWindowAndWait(panel2->browser());
2005 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon)); 2012 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon));
2006 } 2013 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698