OLD | NEW |
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 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 panel_manager->ResizeByMouse(mouse_location); | 45 panel_manager->ResizeByMouse(mouse_location); |
46 | 46 |
47 bounds.set_size(gfx::Size(bounds.width() + 20, bounds.height() + 10)); | 47 bounds.set_size(gfx::Size(bounds.width() + 20, bounds.height() + 10)); |
48 bounds.Offset(-20, -10); | 48 bounds.Offset(-20, -10); |
49 EXPECT_EQ(bounds, panel->GetBounds()); | 49 EXPECT_EQ(bounds, panel->GetBounds()); |
50 | 50 |
51 panel_manager->EndResizingByMouse(false); | 51 panel_manager->EndResizingByMouse(false); |
52 EXPECT_EQ(bounds, panel->GetBounds()); | 52 EXPECT_EQ(bounds, panel->GetBounds()); |
53 | 53 |
54 // Try resizing by the top. | 54 // Try resizing by the top. |
55 mouse_location = bounds.origin().Add(gfx::Point(10, 1)); | 55 mouse_location = bounds.origin().Add(gfx::Vector2d(10, 1)); |
56 panel_manager->StartResizingByMouse(panel, mouse_location, | 56 panel_manager->StartResizingByMouse(panel, mouse_location, |
57 panel::RESIZE_TOP); | 57 panel::RESIZE_TOP); |
58 mouse_location.Offset(5, -10); | 58 mouse_location.Offset(5, -10); |
59 panel_manager->ResizeByMouse(mouse_location); | 59 panel_manager->ResizeByMouse(mouse_location); |
60 | 60 |
61 bounds.set_height(bounds.height() + 10); | 61 bounds.set_height(bounds.height() + 10); |
62 bounds.Offset(0, -10); | 62 bounds.Offset(0, -10); |
63 EXPECT_EQ(bounds, panel->GetBounds()); | 63 EXPECT_EQ(bounds, panel->GetBounds()); |
64 | 64 |
65 panel_manager->EndResizingByMouse(false); | 65 panel_manager->EndResizingByMouse(false); |
66 EXPECT_EQ(bounds, panel->GetBounds()); | 66 EXPECT_EQ(bounds, panel->GetBounds()); |
67 | 67 |
68 // Try resizing by the left side. | 68 // Try resizing by the left side. |
69 mouse_location = bounds.origin().Add(gfx::Point(1, 30)); | 69 mouse_location = bounds.origin().Add(gfx::Vector2d(1, 30)); |
70 panel_manager->StartResizingByMouse(panel, mouse_location, | 70 panel_manager->StartResizingByMouse(panel, mouse_location, |
71 panel::RESIZE_LEFT); | 71 panel::RESIZE_LEFT); |
72 mouse_location.Offset(-5, 25); | 72 mouse_location.Offset(-5, 25); |
73 panel_manager->ResizeByMouse(mouse_location); | 73 panel_manager->ResizeByMouse(mouse_location); |
74 | 74 |
75 bounds.set_width(bounds.width() + 5); | 75 bounds.set_width(bounds.width() + 5); |
76 bounds.Offset(-5, 0); | 76 bounds.Offset(-5, 0); |
77 EXPECT_EQ(bounds, panel->GetBounds()); | 77 EXPECT_EQ(bounds, panel->GetBounds()); |
78 | 78 |
79 panel_manager->EndResizingByMouse(false); | 79 panel_manager->EndResizingByMouse(false); |
80 EXPECT_EQ(bounds, panel->GetBounds()); | 80 EXPECT_EQ(bounds, panel->GetBounds()); |
81 | 81 |
82 // Try resizing by the top right side. | 82 // Try resizing by the top right side. |
83 mouse_location = bounds.origin().Add(gfx::Point(bounds.width() - 1, 2)); | 83 mouse_location = bounds.origin().Add(gfx::Vector2d(bounds.width() - 1, 2)); |
84 panel_manager->StartResizingByMouse(panel, mouse_location, | 84 panel_manager->StartResizingByMouse(panel, mouse_location, |
85 panel::RESIZE_TOP_RIGHT); | 85 panel::RESIZE_TOP_RIGHT); |
86 mouse_location.Offset(30, 20); | 86 mouse_location.Offset(30, 20); |
87 panel_manager->ResizeByMouse(mouse_location); | 87 panel_manager->ResizeByMouse(mouse_location); |
88 | 88 |
89 bounds.set_size(gfx::Size(bounds.width() + 30, bounds.height() - 20)); | 89 bounds.set_size(gfx::Size(bounds.width() + 30, bounds.height() - 20)); |
90 bounds.Offset(0, 20); | 90 bounds.Offset(0, 20); |
91 EXPECT_EQ(bounds, panel->GetBounds()); | 91 EXPECT_EQ(bounds, panel->GetBounds()); |
92 | 92 |
93 panel_manager->EndResizingByMouse(false); | 93 panel_manager->EndResizingByMouse(false); |
94 WaitForBoundsAnimationFinished(panel); | 94 WaitForBoundsAnimationFinished(panel); |
95 bounds.Offset(-30, 0); // Layout of panel adjusted in docked strip. | 95 bounds.Offset(-30, 0); // Layout of panel adjusted in docked strip. |
96 EXPECT_EQ(bounds, panel->GetBounds()); | 96 EXPECT_EQ(bounds, panel->GetBounds()); |
97 | 97 |
98 // Try resizing by the right side. | 98 // Try resizing by the right side. |
99 mouse_location = bounds.origin().Add(gfx::Point(bounds.width() - 1, 30)); | 99 mouse_location = bounds.origin().Add(gfx::Vector2d(bounds.width() - 1, 30)); |
100 panel_manager->StartResizingByMouse(panel, mouse_location, | 100 panel_manager->StartResizingByMouse(panel, mouse_location, |
101 panel::RESIZE_RIGHT); | 101 panel::RESIZE_RIGHT); |
102 mouse_location.Offset(5, 25); | 102 mouse_location.Offset(5, 25); |
103 panel_manager->ResizeByMouse(mouse_location); | 103 panel_manager->ResizeByMouse(mouse_location); |
104 | 104 |
105 bounds.set_width(bounds.width() + 5); | 105 bounds.set_width(bounds.width() + 5); |
106 EXPECT_EQ(bounds, panel->GetBounds()); | 106 EXPECT_EQ(bounds, panel->GetBounds()); |
107 | 107 |
108 panel_manager->EndResizingByMouse(false); | 108 panel_manager->EndResizingByMouse(false); |
109 WaitForBoundsAnimationFinished(panel); | 109 WaitForBoundsAnimationFinished(panel); |
110 bounds.Offset(-5, 0); // Layout of panel adjusted in docked strip. | 110 bounds.Offset(-5, 0); // Layout of panel adjusted in docked strip. |
111 EXPECT_EQ(bounds, panel->GetBounds()); | 111 EXPECT_EQ(bounds, panel->GetBounds()); |
112 | 112 |
113 // Try resizing by the bottom side; verify resize won't work. | 113 // Try resizing by the bottom side; verify resize won't work. |
114 mouse_location = bounds.origin().Add(gfx::Point(10, bounds.height() - 1)); | 114 mouse_location = bounds.origin().Add(gfx::Vector2d(10, bounds.height() - 1)); |
115 panel_manager->StartResizingByMouse(panel, mouse_location, | 115 panel_manager->StartResizingByMouse(panel, mouse_location, |
116 panel::RESIZE_BOTTOM); | 116 panel::RESIZE_BOTTOM); |
117 mouse_location.Offset(30, -10); | 117 mouse_location.Offset(30, -10); |
118 panel_manager->ResizeByMouse(mouse_location); | 118 panel_manager->ResizeByMouse(mouse_location); |
119 EXPECT_EQ(bounds, panel->GetBounds()); | 119 EXPECT_EQ(bounds, panel->GetBounds()); |
120 | 120 |
121 panel_manager->EndResizingByMouse(false); | 121 panel_manager->EndResizingByMouse(false); |
122 EXPECT_EQ(bounds, panel->GetBounds()); | 122 EXPECT_EQ(bounds, panel->GetBounds()); |
123 | 123 |
124 // Try resizing by the bottom left corner; verify resize won't work. | 124 // Try resizing by the bottom left corner; verify resize won't work. |
125 mouse_location = bounds.origin().Add(gfx::Point(1, bounds.height() - 1)); | 125 mouse_location = bounds.origin().Add(gfx::Vector2d(1, bounds.height() - 1)); |
126 panel_manager->StartResizingByMouse(panel, mouse_location, | 126 panel_manager->StartResizingByMouse(panel, mouse_location, |
127 panel::RESIZE_BOTTOM_LEFT); | 127 panel::RESIZE_BOTTOM_LEFT); |
128 mouse_location.Offset(-10, 15); | 128 mouse_location.Offset(-10, 15); |
129 panel_manager->ResizeByMouse(mouse_location); | 129 panel_manager->ResizeByMouse(mouse_location); |
130 EXPECT_EQ(bounds, panel->GetBounds()); | 130 EXPECT_EQ(bounds, panel->GetBounds()); |
131 | 131 |
132 panel_manager->EndResizingByMouse(false); | 132 panel_manager->EndResizingByMouse(false); |
133 EXPECT_EQ(bounds, panel->GetBounds()); | 133 EXPECT_EQ(bounds, panel->GetBounds()); |
134 | 134 |
135 // Try resizing by the bottom right corner; verify resize won't work. | 135 // Try resizing by the bottom right corner; verify resize won't work. |
136 mouse_location = bounds.origin().Add( | 136 mouse_location = bounds.origin().Add( |
137 gfx::Point(bounds.width() - 2, bounds.height())); | 137 gfx::Vector2d(bounds.width() - 2, bounds.height())); |
138 panel_manager->StartResizingByMouse(panel, mouse_location, | 138 panel_manager->StartResizingByMouse(panel, mouse_location, |
139 panel::RESIZE_BOTTOM_RIGHT); | 139 panel::RESIZE_BOTTOM_RIGHT); |
140 mouse_location.Offset(20, 10); | 140 mouse_location.Offset(20, 10); |
141 panel_manager->ResizeByMouse(mouse_location); | 141 panel_manager->ResizeByMouse(mouse_location); |
142 EXPECT_EQ(bounds, panel->GetBounds()); | 142 EXPECT_EQ(bounds, panel->GetBounds()); |
143 | 143 |
144 panel_manager->EndResizingByMouse(false); | 144 panel_manager->EndResizingByMouse(false); |
145 EXPECT_EQ(bounds, panel->GetBounds()); | 145 EXPECT_EQ(bounds, panel->GetBounds()); |
146 | 146 |
147 panel->Close(); | 147 panel->Close(); |
148 } | 148 } |
149 | 149 |
150 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeDetachedPanel) { | 150 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeDetachedPanel) { |
151 PanelManager* panel_manager = PanelManager::GetInstance(); | 151 PanelManager* panel_manager = PanelManager::GetInstance(); |
152 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100)); | 152 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100)); |
153 | 153 |
154 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES, panel->CanResizeByMouse()); | 154 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES, panel->CanResizeByMouse()); |
155 | 155 |
156 gfx::Rect bounds = panel->GetBounds(); | 156 gfx::Rect bounds = panel->GetBounds(); |
157 | 157 |
158 // Try resizing by the right side; verify resize will change width only. | 158 // Try resizing by the right side; verify resize will change width only. |
159 gfx::Point mouse_location = bounds.origin().Add( | 159 gfx::Point mouse_location = bounds.origin().Add( |
160 gfx::Point(bounds.width() - 1, 30)); | 160 gfx::Vector2d(bounds.width() - 1, 30)); |
161 panel_manager->StartResizingByMouse(panel, mouse_location, | 161 panel_manager->StartResizingByMouse(panel, mouse_location, |
162 panel::RESIZE_RIGHT); | 162 panel::RESIZE_RIGHT); |
163 mouse_location.Offset(5, 25); | 163 mouse_location.Offset(5, 25); |
164 panel_manager->ResizeByMouse(mouse_location); | 164 panel_manager->ResizeByMouse(mouse_location); |
165 | 165 |
166 bounds.set_width(bounds.width() + 5); | 166 bounds.set_width(bounds.width() + 5); |
167 EXPECT_EQ(bounds, panel->GetBounds()); | 167 EXPECT_EQ(bounds, panel->GetBounds()); |
168 | 168 |
169 panel_manager->EndResizingByMouse(false); | 169 panel_manager->EndResizingByMouse(false); |
170 EXPECT_EQ(bounds, panel->GetBounds()); | 170 EXPECT_EQ(bounds, panel->GetBounds()); |
171 | 171 |
172 // Try resizing by the bottom left side. | 172 // Try resizing by the bottom left side. |
173 mouse_location = bounds.origin().Add(gfx::Point(1, bounds.height() - 1)); | 173 mouse_location = bounds.origin().Add(gfx::Vector2d(1, bounds.height() - 1)); |
174 panel_manager->StartResizingByMouse(panel, mouse_location, | 174 panel_manager->StartResizingByMouse(panel, mouse_location, |
175 panel::RESIZE_BOTTOM_LEFT); | 175 panel::RESIZE_BOTTOM_LEFT); |
176 mouse_location.Offset(-10, 15); | 176 mouse_location.Offset(-10, 15); |
177 panel_manager->ResizeByMouse(mouse_location); | 177 panel_manager->ResizeByMouse(mouse_location); |
178 | 178 |
179 bounds.set_size(gfx::Size(bounds.width() + 10, bounds.height() + 15)); | 179 bounds.set_size(gfx::Size(bounds.width() + 10, bounds.height() + 15)); |
180 bounds.Offset(-10, 0); | 180 bounds.Offset(-10, 0); |
181 EXPECT_EQ(bounds, panel->GetBounds()); | 181 EXPECT_EQ(bounds, panel->GetBounds()); |
182 | 182 |
183 panel_manager->EndResizingByMouse(false); | 183 panel_manager->EndResizingByMouse(false); |
184 EXPECT_EQ(bounds, panel->GetBounds()); | 184 EXPECT_EQ(bounds, panel->GetBounds()); |
185 | 185 |
186 // Try resizing by the top right side. | 186 // Try resizing by the top right side. |
187 mouse_location = bounds.origin().Add(gfx::Point(bounds.width() - 1, 2)); | 187 mouse_location = bounds.origin().Add(gfx::Vector2d(bounds.width() - 1, 2)); |
188 panel_manager->StartResizingByMouse(panel, mouse_location, | 188 panel_manager->StartResizingByMouse(panel, mouse_location, |
189 panel::RESIZE_TOP_RIGHT); | 189 panel::RESIZE_TOP_RIGHT); |
190 mouse_location.Offset(30, 20); | 190 mouse_location.Offset(30, 20); |
191 panel_manager->ResizeByMouse(mouse_location); | 191 panel_manager->ResizeByMouse(mouse_location); |
192 | 192 |
193 bounds.set_size(gfx::Size(bounds.width() + 30, bounds.height() - 20)); | 193 bounds.set_size(gfx::Size(bounds.width() + 30, bounds.height() - 20)); |
194 bounds.Offset(0, 20); | 194 bounds.Offset(0, 20); |
195 EXPECT_EQ(bounds, panel->GetBounds()); | 195 EXPECT_EQ(bounds, panel->GetBounds()); |
196 | 196 |
197 panel_manager->EndResizingByMouse(false); | 197 panel_manager->EndResizingByMouse(false); |
198 EXPECT_EQ(bounds, panel->GetBounds()); | 198 EXPECT_EQ(bounds, panel->GetBounds()); |
199 | 199 |
200 // Try resizing by the top left side. | 200 // Try resizing by the top left side. |
201 mouse_location = bounds.origin().Add(gfx::Point(1, 0)); | 201 mouse_location = bounds.origin().Add(gfx::Vector2d(1, 0)); |
202 panel_manager->StartResizingByMouse(panel, mouse_location, | 202 panel_manager->StartResizingByMouse(panel, mouse_location, |
203 panel::RESIZE_TOP_LEFT); | 203 panel::RESIZE_TOP_LEFT); |
204 mouse_location.Offset(-20, -10); | 204 mouse_location.Offset(-20, -10); |
205 panel_manager->ResizeByMouse(mouse_location); | 205 panel_manager->ResizeByMouse(mouse_location); |
206 | 206 |
207 bounds.set_size(gfx::Size(bounds.width() + 20, bounds.height() + 10)); | 207 bounds.set_size(gfx::Size(bounds.width() + 20, bounds.height() + 10)); |
208 bounds.Offset(-20, -10); | 208 bounds.Offset(-20, -10); |
209 EXPECT_EQ(bounds, panel->GetBounds()); | 209 EXPECT_EQ(bounds, panel->GetBounds()); |
210 | 210 |
211 panel_manager->EndResizingByMouse(false); | 211 panel_manager->EndResizingByMouse(false); |
212 EXPECT_EQ(bounds, panel->GetBounds()); | 212 EXPECT_EQ(bounds, panel->GetBounds()); |
213 | 213 |
214 PanelManager::GetInstance()->CloseAll(); | 214 PanelManager::GetInstance()->CloseAll(); |
215 } | 215 } |
216 | 216 |
217 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeDetachedPanelToClampSize) { | 217 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeDetachedPanelToClampSize) { |
218 PanelManager* panel_manager = PanelManager::GetInstance(); | 218 PanelManager* panel_manager = PanelManager::GetInstance(); |
219 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100)); | 219 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100)); |
220 | 220 |
221 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES, panel->CanResizeByMouse()); | 221 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES, panel->CanResizeByMouse()); |
222 | 222 |
223 gfx::Rect bounds = panel->GetBounds(); | 223 gfx::Rect bounds = panel->GetBounds(); |
224 | 224 |
225 // Make sure the panel does not resize smaller than its min size. | 225 // Make sure the panel does not resize smaller than its min size. |
226 gfx::Point mouse_location = bounds.origin().Add( | 226 gfx::Point mouse_location = bounds.origin().Add( |
227 gfx::Point(30, bounds.height() - 2)); | 227 gfx::Vector2d(30, bounds.height() - 2)); |
228 panel_manager->StartResizingByMouse(panel, mouse_location, | 228 panel_manager->StartResizingByMouse(panel, mouse_location, |
229 panel::RESIZE_BOTTOM); | 229 panel::RESIZE_BOTTOM); |
230 mouse_location.Offset(-20, -500); | 230 mouse_location.Offset(-20, -500); |
231 panel_manager->ResizeByMouse(mouse_location); | 231 panel_manager->ResizeByMouse(mouse_location); |
232 | 232 |
233 bounds.set_height(panel->min_size().height()); | 233 bounds.set_height(panel->min_size().height()); |
234 EXPECT_EQ(bounds, panel->GetBounds()); | 234 EXPECT_EQ(bounds, panel->GetBounds()); |
235 | 235 |
236 panel_manager->EndResizingByMouse(false); | 236 panel_manager->EndResizingByMouse(false); |
237 EXPECT_EQ(bounds, panel->GetBounds()); | 237 EXPECT_EQ(bounds, panel->GetBounds()); |
238 | 238 |
239 // Make sure the panel can resize larger than its size. User is in control. | 239 // Make sure the panel can resize larger than its size. User is in control. |
240 mouse_location = bounds.origin().Add( | 240 mouse_location = bounds.origin().Add( |
241 gfx::Point(bounds.width(), bounds.height() - 2)); | 241 gfx::Vector2d(bounds.width(), bounds.height() - 2)); |
242 panel_manager->StartResizingByMouse(panel, mouse_location, | 242 panel_manager->StartResizingByMouse(panel, mouse_location, |
243 panel::RESIZE_BOTTOM_RIGHT); | 243 panel::RESIZE_BOTTOM_RIGHT); |
244 | 244 |
245 // This drag would take us beyond max size. | 245 // This drag would take us beyond max size. |
246 int delta_x = panel->max_size().width() + 10 - panel->GetBounds().width(); | 246 int delta_x = panel->max_size().width() + 10 - panel->GetBounds().width(); |
247 int delta_y = panel->max_size().height() + 10 - panel->GetBounds().height(); | 247 int delta_y = panel->max_size().height() + 10 - panel->GetBounds().height(); |
248 mouse_location.Offset(delta_x, delta_y); | 248 mouse_location.Offset(delta_x, delta_y); |
249 panel_manager->ResizeByMouse(mouse_location); | 249 panel_manager->ResizeByMouse(mouse_location); |
250 | 250 |
251 // The bounds if the max_size does not limit the resize. | 251 // The bounds if the max_size does not limit the resize. |
(...skipping 18 matching lines...) Expand all Loading... |
270 Panel* panel3 = CreateDetachedPanel("3", gfx::Rect(300, 220, 120, 120)); | 270 Panel* panel3 = CreateDetachedPanel("3", gfx::Rect(300, 220, 120, 120)); |
271 ASSERT_EQ(3, detached_strip->num_panels()); | 271 ASSERT_EQ(3, detached_strip->num_panels()); |
272 | 272 |
273 gfx::Rect panel1_bounds = panel1->GetBounds(); | 273 gfx::Rect panel1_bounds = panel1->GetBounds(); |
274 gfx::Rect panel2_bounds = panel2->GetBounds(); | 274 gfx::Rect panel2_bounds = panel2->GetBounds(); |
275 gfx::Rect panel3_bounds = panel3->GetBounds(); | 275 gfx::Rect panel3_bounds = panel3->GetBounds(); |
276 | 276 |
277 // Start resizing panel1, and close panel2 in the process. | 277 // Start resizing panel1, and close panel2 in the process. |
278 // Panel1 is not affected. | 278 // Panel1 is not affected. |
279 gfx::Point mouse_location = panel1_bounds.origin().Add( | 279 gfx::Point mouse_location = panel1_bounds.origin().Add( |
280 gfx::Point(1, panel1_bounds.height() - 1)); | 280 gfx::Vector2d(1, panel1_bounds.height() - 1)); |
281 panel_manager->StartResizingByMouse(panel1, mouse_location, | 281 panel_manager->StartResizingByMouse(panel1, mouse_location, |
282 panel::RESIZE_BOTTOM_LEFT); | 282 panel::RESIZE_BOTTOM_LEFT); |
283 mouse_location.Offset(-10, 15); | 283 mouse_location.Offset(-10, 15); |
284 panel_manager->ResizeByMouse(mouse_location); | 284 panel_manager->ResizeByMouse(mouse_location); |
285 | 285 |
286 panel1_bounds.set_size(gfx::Size(panel1_bounds.width() + 10, | 286 panel1_bounds.set_size(gfx::Size(panel1_bounds.width() + 10, |
287 panel1_bounds.height() + 15)); | 287 panel1_bounds.height() + 15)); |
288 panel1_bounds.Offset(-10, 0); | 288 panel1_bounds.Offset(-10, 0); |
289 EXPECT_EQ(panel1_bounds, panel1->GetBounds()); | 289 EXPECT_EQ(panel1_bounds, panel1->GetBounds()); |
290 | 290 |
291 CloseWindowAndWait(panel2); | 291 CloseWindowAndWait(panel2); |
292 EXPECT_TRUE(resize_controller->IsResizing()); | 292 EXPECT_TRUE(resize_controller->IsResizing()); |
293 EXPECT_EQ(2, detached_strip->num_panels()); | 293 EXPECT_EQ(2, detached_strip->num_panels()); |
294 | 294 |
295 panel_manager->EndResizingByMouse(false); | 295 panel_manager->EndResizingByMouse(false); |
296 EXPECT_EQ(panel1_bounds, panel1->GetBounds()); | 296 EXPECT_EQ(panel1_bounds, panel1->GetBounds()); |
297 | 297 |
298 // Start resizing panel3, and close it in the process. | 298 // Start resizing panel3, and close it in the process. |
299 // Resize should abort, panel1 will not be affected. | 299 // Resize should abort, panel1 will not be affected. |
300 mouse_location = panel3_bounds.origin().Add( | 300 mouse_location = panel3_bounds.origin().Add( |
301 gfx::Point(panel3_bounds.width() - 1, panel3_bounds.height() - 2)); | 301 gfx::Vector2d(panel3_bounds.width() - 1, panel3_bounds.height() - 2)); |
302 panel_manager->StartResizingByMouse(panel3, mouse_location, | 302 panel_manager->StartResizingByMouse(panel3, mouse_location, |
303 panel::RESIZE_BOTTOM_RIGHT); | 303 panel::RESIZE_BOTTOM_RIGHT); |
304 mouse_location.Offset(7, -12); | 304 mouse_location.Offset(7, -12); |
305 panel_manager->ResizeByMouse(mouse_location); | 305 panel_manager->ResizeByMouse(mouse_location); |
306 | 306 |
307 panel3_bounds.set_size(gfx::Size(panel3_bounds.width() + 7, | 307 panel3_bounds.set_size(gfx::Size(panel3_bounds.width() + 7, |
308 panel3_bounds.height() - 12)); | 308 panel3_bounds.height() - 12)); |
309 EXPECT_EQ(panel3_bounds, panel3->GetBounds()); | 309 EXPECT_EQ(panel3_bounds, panel3->GetBounds()); |
310 | 310 |
311 CloseWindowAndWait(panel3); | 311 CloseWindowAndWait(panel3); |
(...skipping 15 matching lines...) Expand all Loading... |
327 PanelResizeController* resize_controller = panel_manager->resize_controller(); | 327 PanelResizeController* resize_controller = panel_manager->resize_controller(); |
328 | 328 |
329 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES, panel->CanResizeByMouse()); | 329 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES, panel->CanResizeByMouse()); |
330 | 330 |
331 gfx::Rect original_bounds = panel->GetBounds(); | 331 gfx::Rect original_bounds = panel->GetBounds(); |
332 | 332 |
333 // Resizing the panel, then cancelling should return it to the original state. | 333 // Resizing the panel, then cancelling should return it to the original state. |
334 // Try resizing by the top right side. | 334 // Try resizing by the top right side. |
335 gfx::Rect bounds = panel->GetBounds(); | 335 gfx::Rect bounds = panel->GetBounds(); |
336 gfx::Point mouse_location = bounds.origin().Add( | 336 gfx::Point mouse_location = bounds.origin().Add( |
337 gfx::Point(bounds.width() - 1, 1)); | 337 gfx::Vector2d(bounds.width() - 1, 1)); |
338 panel_manager->StartResizingByMouse(panel, mouse_location, | 338 panel_manager->StartResizingByMouse(panel, mouse_location, |
339 panel::RESIZE_TOP_RIGHT); | 339 panel::RESIZE_TOP_RIGHT); |
340 mouse_location.Offset(5, 25); | 340 mouse_location.Offset(5, 25); |
341 panel_manager->ResizeByMouse(mouse_location); | 341 panel_manager->ResizeByMouse(mouse_location); |
342 | 342 |
343 bounds.set_size(gfx::Size(bounds.width() + 5, bounds.height() - 25)); | 343 bounds.set_size(gfx::Size(bounds.width() + 5, bounds.height() - 25)); |
344 bounds.Offset(0, 25); | 344 bounds.Offset(0, 25); |
345 EXPECT_EQ(bounds, panel->GetBounds()); | 345 EXPECT_EQ(bounds, panel->GetBounds()); |
346 | 346 |
347 panel_manager->EndResizingByMouse(true); | 347 panel_manager->EndResizingByMouse(true); |
348 EXPECT_EQ(original_bounds, panel->GetBounds()); | 348 EXPECT_EQ(original_bounds, panel->GetBounds()); |
349 | 349 |
350 // Try resizing by the bottom left side. | 350 // Try resizing by the bottom left side. |
351 bounds = panel->GetBounds(); | 351 bounds = panel->GetBounds(); |
352 mouse_location = bounds.origin().Add( | 352 mouse_location = bounds.origin().Add( |
353 gfx::Point(1, bounds.height() - 1)); | 353 gfx::Vector2d(1, bounds.height() - 1)); |
354 panel_manager->StartResizingByMouse(panel, mouse_location, | 354 panel_manager->StartResizingByMouse(panel, mouse_location, |
355 panel::RESIZE_BOTTOM_LEFT); | 355 panel::RESIZE_BOTTOM_LEFT); |
356 mouse_location.Offset(-10, 15); | 356 mouse_location.Offset(-10, 15); |
357 panel_manager->ResizeByMouse(mouse_location); | 357 panel_manager->ResizeByMouse(mouse_location); |
358 | 358 |
359 bounds.set_size(gfx::Size(bounds.width() + 10, bounds.height() + 15)); | 359 bounds.set_size(gfx::Size(bounds.width() + 10, bounds.height() + 15)); |
360 bounds.Offset(-10, 0); | 360 bounds.Offset(-10, 0); |
361 EXPECT_EQ(bounds, panel->GetBounds()); | 361 EXPECT_EQ(bounds, panel->GetBounds()); |
362 | 362 |
363 panel_manager->EndResizingByMouse(true); | 363 panel_manager->EndResizingByMouse(true); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 bounds.set_height(bounds.height() + bounds.y() - mouse_location.y()); | 403 bounds.set_height(bounds.height() + bounds.y() - mouse_location.y()); |
404 bounds.set_x(mouse_location.x()); | 404 bounds.set_x(mouse_location.x()); |
405 bounds.set_y(mouse_location.y()); | 405 bounds.set_y(mouse_location.y()); |
406 EXPECT_EQ(bounds, panel->GetBounds()); | 406 EXPECT_EQ(bounds, panel->GetBounds()); |
407 | 407 |
408 panel_manager->EndResizingByMouse(false); | 408 panel_manager->EndResizingByMouse(false); |
409 EXPECT_EQ(bounds, panel->GetBounds()); | 409 EXPECT_EQ(bounds, panel->GetBounds()); |
410 | 410 |
411 panel_manager->CloseAll(); | 411 panel_manager->CloseAll(); |
412 } | 412 } |
OLD | NEW |