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

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

Issue 10066032: Enable user resizing for docked Panels (GTK and Mac). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: minor cleanup Created 8 years, 8 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 "chrome/browser/ui/panels/base_panel_browser_test.h" 5 #include "chrome/browser/ui/panels/base_panel_browser_test.h"
6 #include "chrome/browser/ui/panels/detached_panel_strip.h" 6 #include "chrome/browser/ui/panels/detached_panel_strip.h"
7 #include "chrome/browser/ui/panels/panel.h" 7 #include "chrome/browser/ui/panels/panel.h"
8 #include "chrome/browser/ui/panels/panel_manager.h" 8 #include "chrome/browser/ui/panels/panel_manager.h"
9 #include "chrome/browser/ui/panels/panel_resize_controller.h" 9 #include "chrome/browser/ui/panels/panel_resize_controller.h"
10 10
11 class PanelResizeBrowserTest : public BasePanelBrowserTest { 11 class PanelResizeBrowserTest : public BasePanelBrowserTest {
12 public: 12 public:
13 PanelResizeBrowserTest() : BasePanelBrowserTest() { 13 PanelResizeBrowserTest() : BasePanelBrowserTest() {
14 } 14 }
15 15
16 virtual ~PanelResizeBrowserTest() { 16 virtual ~PanelResizeBrowserTest() {
17 } 17 }
18 18
19 virtual void SetUpOnMainThread() OVERRIDE { 19 virtual void SetUpOnMainThread() OVERRIDE {
20 BasePanelBrowserTest::SetUpOnMainThread(); 20 BasePanelBrowserTest::SetUpOnMainThread();
21 21
22 // All the tests here assume 800x600 work area. Do the check now. 22 // All the tests here assume 800x600 work area. Do the check now.
23 gfx::Rect display_area = PanelManager::GetInstance()-> 23 gfx::Rect display_area = PanelManager::GetInstance()->
24 display_settings_provider()->GetDisplayArea(); 24 display_settings_provider()->GetDisplayArea();
25 DCHECK(display_area.width() == 800); 25 DCHECK(display_area.width() == 800);
26 DCHECK(display_area.height() == 600); 26 DCHECK(display_area.height() == 600);
27 } 27 }
28 }; 28 };
29 29
30 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, DockedPanelsAreNotResizable) { 30 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, DockedPanelResizability) {
31 PanelManager* panel_manager = PanelManager::GetInstance(); 31 PanelManager* panel_manager = PanelManager::GetInstance();
32 Panel* panel = CreatePanel("Panel"); 32 Panel* panel = CreatePanel("Panel");
33 33
34 EXPECT_FALSE(panel->CanResizeByMouse()); 34 EXPECT_EQ(panel::ALL_SIDES_EXCEPT_BOTTOM, panel->CanResizeByMouse());
35 35
36 gfx::Rect bounds = panel->GetBounds(); 36 gfx::Rect bounds = panel->GetBounds();
37 37
38 // Try resizing by the top left corner; verify resize won't work. 38 // Try resizing by the top left corner; verify resize works.
jianli 2012/04/13 00:52:36 I think it would be better to test all other edges
jennb 2012/04/13 19:48:04 Done.
39 gfx::Point mouse_location = bounds.origin(); 39 gfx::Point mouse_location = bounds.origin();
40 panel_manager->StartResizingByMouse(panel, mouse_location, 40 panel_manager->StartResizingByMouse(panel, mouse_location,
41 panel::RESIZE_TOP_LEFT); 41 panel::RESIZE_TOP_LEFT);
42 mouse_location.Offset(-20, -20); 42 mouse_location.Offset(-20, -20);
43 panel_manager->ResizeByMouse(mouse_location); 43 panel_manager->ResizeByMouse(mouse_location);
44 bounds.Offset(-20, -20);
44 EXPECT_EQ(bounds, panel->GetBounds()); 45 EXPECT_EQ(bounds, panel->GetBounds());
45 46
46 panel_manager->EndResizingByMouse(false); 47 panel_manager->EndResizingByMouse(false);
47 EXPECT_EQ(bounds, panel->GetBounds()); 48 EXPECT_EQ(bounds, panel->GetBounds());
48 49
49 // Try resizing by the bottom side; verify resize won't work. 50 // Try resizing by the bottom side; verify resize won't work.
50 mouse_location = bounds.origin().Add(gfx::Point(10, bounds.height() - 1)); 51 mouse_location = bounds.origin().Add(gfx::Point(10, bounds.height() - 1));
51 panel_manager->StartResizingByMouse(panel, mouse_location, 52 panel_manager->StartResizingByMouse(panel, mouse_location,
52 panel::RESIZE_BOTTOM); 53 panel::RESIZE_BOTTOM);
53 mouse_location.Offset(30, -10); 54 mouse_location.Offset(30, -10);
(...skipping 15 matching lines...) Expand all
69 panel_manager->EndResizingByMouse(false); 70 panel_manager->EndResizingByMouse(false);
70 EXPECT_EQ(bounds, panel->GetBounds()); 71 EXPECT_EQ(bounds, panel->GetBounds());
71 72
72 panel->Close(); 73 panel->Close();
73 } 74 }
74 75
75 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeDetachedPanel) { 76 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeDetachedPanel) {
76 PanelManager* panel_manager = PanelManager::GetInstance(); 77 PanelManager* panel_manager = PanelManager::GetInstance();
77 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100)); 78 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100));
78 79
79 EXPECT_TRUE(panel->CanResizeByMouse()); 80 EXPECT_EQ(panel::ALL_SIDES, panel->CanResizeByMouse());
80 81
81 gfx::Rect bounds = panel->GetBounds(); 82 gfx::Rect bounds = panel->GetBounds();
82 83
83 // Try resizing by the right side; verify resize will change width only. 84 // Try resizing by the right side; verify resize will change width only.
84 gfx::Point mouse_location = bounds.origin().Add( 85 gfx::Point mouse_location = bounds.origin().Add(
85 gfx::Point(bounds.width() - 1, 30)); 86 gfx::Point(bounds.width() - 1, 30));
86 panel_manager->StartResizingByMouse(panel, mouse_location, 87 panel_manager->StartResizingByMouse(panel, mouse_location,
87 panel::RESIZE_RIGHT); 88 panel::RESIZE_RIGHT);
88 mouse_location.Offset(5, 25); 89 mouse_location.Offset(5, 25);
89 panel_manager->ResizeByMouse(mouse_location); 90 panel_manager->ResizeByMouse(mouse_location);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 panel_manager->EndResizingByMouse(false); 137 panel_manager->EndResizingByMouse(false);
137 EXPECT_EQ(bounds, panel->GetBounds()); 138 EXPECT_EQ(bounds, panel->GetBounds());
138 139
139 PanelManager::GetInstance()->CloseAll(); 140 PanelManager::GetInstance()->CloseAll();
140 } 141 }
141 142
142 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeDetachedPanelToClampSize) { 143 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeDetachedPanelToClampSize) {
143 PanelManager* panel_manager = PanelManager::GetInstance(); 144 PanelManager* panel_manager = PanelManager::GetInstance();
144 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100)); 145 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100));
145 146
146 EXPECT_TRUE(panel->CanResizeByMouse()); 147 EXPECT_EQ(panel::ALL_SIDES, panel->CanResizeByMouse());
147 148
148 gfx::Rect bounds = panel->GetBounds(); 149 gfx::Rect bounds = panel->GetBounds();
149 150
150 // Make sure the panel does not resize smaller than its min size. 151 // Make sure the panel does not resize smaller than its min size.
151 gfx::Point mouse_location = bounds.origin().Add( 152 gfx::Point mouse_location = bounds.origin().Add(
152 gfx::Point(30, bounds.height() - 2)); 153 gfx::Point(30, bounds.height() - 2));
153 panel_manager->StartResizingByMouse(panel, mouse_location, 154 panel_manager->StartResizingByMouse(panel, mouse_location,
154 panel::RESIZE_BOTTOM); 155 panel::RESIZE_BOTTOM);
155 mouse_location.Offset(-20, -500); 156 mouse_location.Offset(-20, -500);
156 panel_manager->ResizeByMouse(mouse_location); 157 panel_manager->ResizeByMouse(mouse_location);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 EXPECT_EQ(panel1_bounds, panel1->GetBounds()); 239 EXPECT_EQ(panel1_bounds, panel1->GetBounds());
239 240
240 panel_manager->CloseAll(); 241 panel_manager->CloseAll();
241 } 242 }
242 243
243 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeAndCancel) { 244 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeAndCancel) {
244 PanelManager* panel_manager = PanelManager::GetInstance(); 245 PanelManager* panel_manager = PanelManager::GetInstance();
245 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100)); 246 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100));
246 PanelResizeController* resize_controller = panel_manager->resize_controller(); 247 PanelResizeController* resize_controller = panel_manager->resize_controller();
247 248
248 EXPECT_TRUE(panel->CanResizeByMouse()); 249 EXPECT_EQ(panel::ALL_SIDES, panel->CanResizeByMouse());
249 250
250 gfx::Rect original_bounds = panel->GetBounds(); 251 gfx::Rect original_bounds = panel->GetBounds();
251 252
252 // Resizing the panel, then cancelling should return it to the original state. 253 // Resizing the panel, then cancelling should return it to the original state.
253 // Try resizing by the top right side. 254 // Try resizing by the top right side.
254 gfx::Rect bounds = panel->GetBounds(); 255 gfx::Rect bounds = panel->GetBounds();
255 gfx::Point mouse_location = bounds.origin().Add( 256 gfx::Point mouse_location = bounds.origin().Add(
256 gfx::Point(bounds.width() - 1, 1)); 257 gfx::Point(bounds.width() - 1, 1));
257 panel_manager->StartResizingByMouse(panel, mouse_location, 258 panel_manager->StartResizingByMouse(panel, mouse_location,
258 panel::RESIZE_TOP_RIGHT); 259 panel::RESIZE_TOP_RIGHT);
(...skipping 19 matching lines...) Expand all
278 bounds.set_size(gfx::Size(bounds.width() + 10, bounds.height() + 15)); 279 bounds.set_size(gfx::Size(bounds.width() + 10, bounds.height() + 15));
279 bounds.Offset(-10, 0); 280 bounds.Offset(-10, 0);
280 EXPECT_EQ(bounds, panel->GetBounds()); 281 EXPECT_EQ(bounds, panel->GetBounds());
281 282
282 panel_manager->EndResizingByMouse(true); 283 panel_manager->EndResizingByMouse(true);
283 EXPECT_EQ(original_bounds, panel->GetBounds()); 284 EXPECT_EQ(original_bounds, panel->GetBounds());
284 EXPECT_FALSE(resize_controller->IsResizing()); 285 EXPECT_FALSE(resize_controller->IsResizing());
285 286
286 panel_manager->CloseAll(); 287 panel_manager->CloseAll();
287 } 288 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698