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

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: fix tests 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::RESIZABLE_ALL_SIDES_EXCEPT_BOTTOM,
35 panel->CanResizeByMouse());
35 36
36 gfx::Rect bounds = panel->GetBounds(); 37 gfx::Rect bounds = panel->GetBounds();
37 38
38 // Try resizing by the top left corner; verify resize won't work. 39 // Try resizing by the top left corner.
39 gfx::Point mouse_location = bounds.origin(); 40 gfx::Point mouse_location = bounds.origin();
40 panel_manager->StartResizingByMouse(panel, mouse_location, 41 panel_manager->StartResizingByMouse(panel, mouse_location,
41 panel::RESIZE_TOP_LEFT); 42 panel::RESIZE_TOP_LEFT);
42 mouse_location.Offset(-20, -20); 43 mouse_location.Offset(-20, -10);
43 panel_manager->ResizeByMouse(mouse_location); 44 panel_manager->ResizeByMouse(mouse_location);
45
46 bounds.set_size(gfx::Size(bounds.width() + 20, bounds.height() + 10));
47 bounds.Offset(-20, -10);
44 EXPECT_EQ(bounds, panel->GetBounds()); 48 EXPECT_EQ(bounds, panel->GetBounds());
45 49
46 panel_manager->EndResizingByMouse(false); 50 panel_manager->EndResizingByMouse(false);
47 EXPECT_EQ(bounds, panel->GetBounds()); 51 EXPECT_EQ(bounds, panel->GetBounds());
48 52
53 // Try resizing by the top.
54 mouse_location = bounds.origin().Add(gfx::Point(10, 1));
55 panel_manager->StartResizingByMouse(panel, mouse_location,
56 panel::RESIZE_TOP);
57 mouse_location.Offset(5, -10);
58 panel_manager->ResizeByMouse(mouse_location);
59
60 bounds.set_height(bounds.height() + 10);
61 bounds.Offset(0, -10);
62 EXPECT_EQ(bounds, panel->GetBounds());
63
64 panel_manager->EndResizingByMouse(false);
65 EXPECT_EQ(bounds, panel->GetBounds());
66
67 // Try resizing by the left side.
68 mouse_location = bounds.origin().Add(gfx::Point(1, 30));
69 panel_manager->StartResizingByMouse(panel, mouse_location,
70 panel::RESIZE_LEFT);
71 mouse_location.Offset(-5, 25);
72 panel_manager->ResizeByMouse(mouse_location);
73
74 bounds.set_width(bounds.width() + 5);
75 bounds.Offset(-5, 0);
76 EXPECT_EQ(bounds, panel->GetBounds());
77
78 panel_manager->EndResizingByMouse(false);
79 EXPECT_EQ(bounds, panel->GetBounds());
80
81 // Try resizing by the top right side.
82 mouse_location = bounds.origin().Add(gfx::Point(bounds.width() - 1, 2));
83 panel_manager->StartResizingByMouse(panel, mouse_location,
84 panel::RESIZE_TOP_RIGHT);
85 mouse_location.Offset(30, 20);
86 panel_manager->ResizeByMouse(mouse_location);
87
88 bounds.set_size(gfx::Size(bounds.width() + 30, bounds.height() - 20));
89 bounds.Offset(0, 20);
90 EXPECT_EQ(bounds, panel->GetBounds());
91
92 panel_manager->EndResizingByMouse(false);
93 WaitForBoundsAnimationFinished(panel);
94 bounds.Offset(-30, 0); // Layout of panel adjusted in docked strip.
95 EXPECT_EQ(bounds, panel->GetBounds());
96
97 // Try resizing by the right side.
98 mouse_location = bounds.origin().Add(gfx::Point(bounds.width() - 1, 30));
99 panel_manager->StartResizingByMouse(panel, mouse_location,
100 panel::RESIZE_RIGHT);
101 mouse_location.Offset(5, 25);
102 panel_manager->ResizeByMouse(mouse_location);
103
104 bounds.set_width(bounds.width() + 5);
105 EXPECT_EQ(bounds, panel->GetBounds());
106
107 panel_manager->EndResizingByMouse(false);
108 WaitForBoundsAnimationFinished(panel);
109 bounds.Offset(-5, 0); // Layout of panel adjusted in docked strip.
110 EXPECT_EQ(bounds, panel->GetBounds());
111
49 // Try resizing by the bottom side; verify resize won't work. 112 // Try resizing by the bottom side; verify resize won't work.
50 mouse_location = bounds.origin().Add(gfx::Point(10, bounds.height() - 1)); 113 mouse_location = bounds.origin().Add(gfx::Point(10, bounds.height() - 1));
51 panel_manager->StartResizingByMouse(panel, mouse_location, 114 panel_manager->StartResizingByMouse(panel, mouse_location,
52 panel::RESIZE_BOTTOM); 115 panel::RESIZE_BOTTOM);
53 mouse_location.Offset(30, -10); 116 mouse_location.Offset(30, -10);
54 panel_manager->ResizeByMouse(mouse_location); 117 panel_manager->ResizeByMouse(mouse_location);
55 EXPECT_EQ(bounds, panel->GetBounds()); 118 EXPECT_EQ(bounds, panel->GetBounds());
56 119
57 panel_manager->EndResizingByMouse(false); 120 panel_manager->EndResizingByMouse(false);
58 EXPECT_EQ(bounds, panel->GetBounds()); 121 EXPECT_EQ(bounds, panel->GetBounds());
59 122
123 // Try resizing by the bottom left corner; verify resize won't work.
124 mouse_location = bounds.origin().Add(gfx::Point(1, bounds.height() - 1));
125 panel_manager->StartResizingByMouse(panel, mouse_location,
126 panel::RESIZE_BOTTOM_LEFT);
127 mouse_location.Offset(-10, 15);
128 panel_manager->ResizeByMouse(mouse_location);
129 EXPECT_EQ(bounds, panel->GetBounds());
130
131 panel_manager->EndResizingByMouse(false);
132 EXPECT_EQ(bounds, panel->GetBounds());
133
60 // Try resizing by the bottom right corner; verify resize won't work. 134 // Try resizing by the bottom right corner; verify resize won't work.
61 mouse_location = bounds.origin().Add( 135 mouse_location = bounds.origin().Add(
62 gfx::Point(bounds.width() - 2, bounds.height())); 136 gfx::Point(bounds.width() - 2, bounds.height()));
63 panel_manager->StartResizingByMouse(panel, mouse_location, 137 panel_manager->StartResizingByMouse(panel, mouse_location,
64 panel::RESIZE_BOTTOM_RIGHT); 138 panel::RESIZE_BOTTOM_RIGHT);
65 mouse_location.Offset(20, 10); 139 mouse_location.Offset(20, 10);
66 panel_manager->ResizeByMouse(mouse_location); 140 panel_manager->ResizeByMouse(mouse_location);
67 EXPECT_EQ(bounds, panel->GetBounds()); 141 EXPECT_EQ(bounds, panel->GetBounds());
68 142
69 panel_manager->EndResizingByMouse(false); 143 panel_manager->EndResizingByMouse(false);
70 EXPECT_EQ(bounds, panel->GetBounds()); 144 EXPECT_EQ(bounds, panel->GetBounds());
71 145
72 panel->Close(); 146 panel->Close();
73 } 147 }
74 148
75 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeDetachedPanel) { 149 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeDetachedPanel) {
76 PanelManager* panel_manager = PanelManager::GetInstance(); 150 PanelManager* panel_manager = PanelManager::GetInstance();
77 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100)); 151 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100));
78 152
79 EXPECT_TRUE(panel->CanResizeByMouse()); 153 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES, panel->CanResizeByMouse());
80 154
81 gfx::Rect bounds = panel->GetBounds(); 155 gfx::Rect bounds = panel->GetBounds();
82 156
83 // Try resizing by the right side; verify resize will change width only. 157 // Try resizing by the right side; verify resize will change width only.
84 gfx::Point mouse_location = bounds.origin().Add( 158 gfx::Point mouse_location = bounds.origin().Add(
85 gfx::Point(bounds.width() - 1, 30)); 159 gfx::Point(bounds.width() - 1, 30));
86 panel_manager->StartResizingByMouse(panel, mouse_location, 160 panel_manager->StartResizingByMouse(panel, mouse_location,
87 panel::RESIZE_RIGHT); 161 panel::RESIZE_RIGHT);
88 mouse_location.Offset(5, 25); 162 mouse_location.Offset(5, 25);
89 panel_manager->ResizeByMouse(mouse_location); 163 panel_manager->ResizeByMouse(mouse_location);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 panel_manager->EndResizingByMouse(false); 210 panel_manager->EndResizingByMouse(false);
137 EXPECT_EQ(bounds, panel->GetBounds()); 211 EXPECT_EQ(bounds, panel->GetBounds());
138 212
139 PanelManager::GetInstance()->CloseAll(); 213 PanelManager::GetInstance()->CloseAll();
140 } 214 }
141 215
142 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeDetachedPanelToClampSize) { 216 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeDetachedPanelToClampSize) {
143 PanelManager* panel_manager = PanelManager::GetInstance(); 217 PanelManager* panel_manager = PanelManager::GetInstance();
144 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100)); 218 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100));
145 219
146 EXPECT_TRUE(panel->CanResizeByMouse()); 220 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES, panel->CanResizeByMouse());
147 221
148 gfx::Rect bounds = panel->GetBounds(); 222 gfx::Rect bounds = panel->GetBounds();
149 223
150 // Make sure the panel does not resize smaller than its min size. 224 // Make sure the panel does not resize smaller than its min size.
151 gfx::Point mouse_location = bounds.origin().Add( 225 gfx::Point mouse_location = bounds.origin().Add(
152 gfx::Point(30, bounds.height() - 2)); 226 gfx::Point(30, bounds.height() - 2));
153 panel_manager->StartResizingByMouse(panel, mouse_location, 227 panel_manager->StartResizingByMouse(panel, mouse_location,
154 panel::RESIZE_BOTTOM); 228 panel::RESIZE_BOTTOM);
155 mouse_location.Offset(-20, -500); 229 mouse_location.Offset(-20, -500);
156 panel_manager->ResizeByMouse(mouse_location); 230 panel_manager->ResizeByMouse(mouse_location);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 EXPECT_EQ(panel1_bounds, panel1->GetBounds()); 312 EXPECT_EQ(panel1_bounds, panel1->GetBounds());
239 313
240 panel_manager->CloseAll(); 314 panel_manager->CloseAll();
241 } 315 }
242 316
243 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeAndCancel) { 317 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeAndCancel) {
244 PanelManager* panel_manager = PanelManager::GetInstance(); 318 PanelManager* panel_manager = PanelManager::GetInstance();
245 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100)); 319 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100));
246 PanelResizeController* resize_controller = panel_manager->resize_controller(); 320 PanelResizeController* resize_controller = panel_manager->resize_controller();
247 321
248 EXPECT_TRUE(panel->CanResizeByMouse()); 322 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES, panel->CanResizeByMouse());
249 323
250 gfx::Rect original_bounds = panel->GetBounds(); 324 gfx::Rect original_bounds = panel->GetBounds();
251 325
252 // Resizing the panel, then cancelling should return it to the original state. 326 // Resizing the panel, then cancelling should return it to the original state.
253 // Try resizing by the top right side. 327 // Try resizing by the top right side.
254 gfx::Rect bounds = panel->GetBounds(); 328 gfx::Rect bounds = panel->GetBounds();
255 gfx::Point mouse_location = bounds.origin().Add( 329 gfx::Point mouse_location = bounds.origin().Add(
256 gfx::Point(bounds.width() - 1, 1)); 330 gfx::Point(bounds.width() - 1, 1));
257 panel_manager->StartResizingByMouse(panel, mouse_location, 331 panel_manager->StartResizingByMouse(panel, mouse_location,
258 panel::RESIZE_TOP_RIGHT); 332 panel::RESIZE_TOP_RIGHT);
(...skipping 19 matching lines...) Expand all
278 bounds.set_size(gfx::Size(bounds.width() + 10, bounds.height() + 15)); 352 bounds.set_size(gfx::Size(bounds.width() + 10, bounds.height() + 15));
279 bounds.Offset(-10, 0); 353 bounds.Offset(-10, 0);
280 EXPECT_EQ(bounds, panel->GetBounds()); 354 EXPECT_EQ(bounds, panel->GetBounds());
281 355
282 panel_manager->EndResizingByMouse(true); 356 panel_manager->EndResizingByMouse(true);
283 EXPECT_EQ(original_bounds, panel->GetBounds()); 357 EXPECT_EQ(original_bounds, panel->GetBounds());
284 EXPECT_FALSE(resize_controller->IsResizing()); 358 EXPECT_FALSE(resize_controller->IsResizing());
285 359
286 panel_manager->CloseAll(); 360 panel_manager->CloseAll();
287 } 361 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_overflow_browsertest.cc ('k') | chrome/browser/ui/panels/panel_resize_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698