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/old_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 OldPanelResizeBrowserTest : public OldBasePanelBrowserTest { | 11 class PanelResizeBrowserTest : public BasePanelBrowserTest { |
12 public: | 12 public: |
13 OldPanelResizeBrowserTest() : OldBasePanelBrowserTest() { | 13 PanelResizeBrowserTest() : BasePanelBrowserTest() { |
14 } | 14 } |
15 | 15 |
16 virtual ~OldPanelResizeBrowserTest() { | 16 virtual ~PanelResizeBrowserTest() { |
17 } | 17 } |
18 | 18 |
19 virtual void SetUpOnMainThread() OVERRIDE { | 19 virtual void SetUpOnMainThread() OVERRIDE { |
20 OldBasePanelBrowserTest::SetUpOnMainThread(); | 20 BasePanelBrowserTest::SetUpOnMainThread(); |
21 | 21 |
22 // All the tests here assume using mocked 800x600 screen area for the | 22 // All the tests here assume using mocked 800x600 screen area for the |
23 // primary monitor. Do the check now. | 23 // primary monitor. Do the check now. |
24 gfx::Rect primary_screen_area = PanelManager::GetInstance()-> | 24 gfx::Rect primary_screen_area = PanelManager::GetInstance()-> |
25 display_settings_provider()->GetPrimaryScreenArea(); | 25 display_settings_provider()->GetPrimaryScreenArea(); |
26 DCHECK(primary_screen_area.width() == 800); | 26 DCHECK(primary_screen_area.width() == 800); |
27 DCHECK(primary_screen_area.height() == 600); | 27 DCHECK(primary_screen_area.height() == 600); |
28 } | 28 } |
29 }; | 29 }; |
30 | 30 |
31 IN_PROC_BROWSER_TEST_F(OldPanelResizeBrowserTest, DockedPanelResizability) { | 31 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, DockedPanelResizability) { |
32 PanelManager* panel_manager = PanelManager::GetInstance(); | 32 PanelManager* panel_manager = PanelManager::GetInstance(); |
33 Panel* panel = CreatePanel("Panel"); | 33 Panel* panel = CreatePanel("Panel"); |
34 | 34 |
35 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES_EXCEPT_BOTTOM, | 35 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES_EXCEPT_BOTTOM, |
36 panel->CanResizeByMouse()); | 36 panel->CanResizeByMouse()); |
37 | 37 |
38 gfx::Rect bounds = panel->GetBounds(); | 38 gfx::Rect bounds = panel->GetBounds(); |
39 | 39 |
40 // Try resizing by the top left corner. | 40 // Try resizing by the top left corner. |
41 gfx::Point mouse_location = bounds.origin(); | 41 gfx::Point mouse_location = bounds.origin(); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(OldPanelResizeBrowserTest, 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::Point(bounds.width() - 1, 30)); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(OldPanelResizeBrowserTest, | 217 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeDetachedPanelToClampSize) { |
218 ResizeDetachedPanelToClampSize) { | |
219 PanelManager* panel_manager = PanelManager::GetInstance(); | 218 PanelManager* panel_manager = PanelManager::GetInstance(); |
220 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100)); | 219 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100)); |
221 | 220 |
222 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES, panel->CanResizeByMouse()); | 221 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES, panel->CanResizeByMouse()); |
223 | 222 |
224 gfx::Rect bounds = panel->GetBounds(); | 223 gfx::Rect bounds = panel->GetBounds(); |
225 | 224 |
226 // 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. |
227 gfx::Point mouse_location = bounds.origin().Add( | 226 gfx::Point mouse_location = bounds.origin().Add( |
228 gfx::Point(30, bounds.height() - 2)); | 227 gfx::Point(30, bounds.height() - 2)); |
(...skipping 24 matching lines...) Expand all Loading... |
253 bounds.set_size(gfx::Size(bounds.width() + delta_x, | 252 bounds.set_size(gfx::Size(bounds.width() + delta_x, |
254 bounds.height() + delta_y)); | 253 bounds.height() + delta_y)); |
255 EXPECT_EQ(bounds, panel->GetBounds()); | 254 EXPECT_EQ(bounds, panel->GetBounds()); |
256 | 255 |
257 panel_manager->EndResizingByMouse(false); | 256 panel_manager->EndResizingByMouse(false); |
258 EXPECT_EQ(bounds, panel->GetBounds()); | 257 EXPECT_EQ(bounds, panel->GetBounds()); |
259 | 258 |
260 PanelManager::GetInstance()->CloseAll(); | 259 PanelManager::GetInstance()->CloseAll(); |
261 } | 260 } |
262 | 261 |
263 IN_PROC_BROWSER_TEST_F(OldPanelResizeBrowserTest, | 262 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, CloseDetachedPanelOnResize) { |
264 CloseDetachedPanelOnResize) { | |
265 PanelManager* panel_manager = PanelManager::GetInstance(); | 263 PanelManager* panel_manager = PanelManager::GetInstance(); |
266 PanelResizeController* resize_controller = panel_manager->resize_controller(); | 264 PanelResizeController* resize_controller = panel_manager->resize_controller(); |
267 DetachedPanelStrip* detached_strip = panel_manager->detached_strip(); | 265 DetachedPanelStrip* detached_strip = panel_manager->detached_strip(); |
268 | 266 |
269 // Create 3 detached panels. | 267 // Create 3 detached panels. |
270 Panel* panel1 = CreateDetachedPanel("1", gfx::Rect(100, 200, 100, 100)); | 268 Panel* panel1 = CreateDetachedPanel("1", gfx::Rect(100, 200, 100, 100)); |
271 Panel* panel2 = CreateDetachedPanel("2", gfx::Rect(200, 210, 110, 110)); | 269 Panel* panel2 = CreateDetachedPanel("2", gfx::Rect(200, 210, 110, 110)); |
272 Panel* panel3 = CreateDetachedPanel("3", gfx::Rect(300, 220, 120, 120)); | 270 Panel* panel3 = CreateDetachedPanel("3", gfx::Rect(300, 220, 120, 120)); |
273 ASSERT_EQ(3, detached_strip->num_panels()); | 271 ASSERT_EQ(3, detached_strip->num_panels()); |
274 | 272 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 // resizing mode by now. | 314 // resizing mode by now. |
317 EXPECT_FALSE(resize_controller->IsResizing()); | 315 EXPECT_FALSE(resize_controller->IsResizing()); |
318 | 316 |
319 panel_manager->EndResizingByMouse(false); | 317 panel_manager->EndResizingByMouse(false); |
320 EXPECT_FALSE(resize_controller->IsResizing()); | 318 EXPECT_FALSE(resize_controller->IsResizing()); |
321 EXPECT_EQ(panel1_bounds, panel1->GetBounds()); | 319 EXPECT_EQ(panel1_bounds, panel1->GetBounds()); |
322 | 320 |
323 panel_manager->CloseAll(); | 321 panel_manager->CloseAll(); |
324 } | 322 } |
325 | 323 |
326 IN_PROC_BROWSER_TEST_F(OldPanelResizeBrowserTest, ResizeAndCancel) { | 324 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeAndCancel) { |
327 PanelManager* panel_manager = PanelManager::GetInstance(); | 325 PanelManager* panel_manager = PanelManager::GetInstance(); |
328 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100)); | 326 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100)); |
329 PanelResizeController* resize_controller = panel_manager->resize_controller(); | 327 PanelResizeController* resize_controller = panel_manager->resize_controller(); |
330 | 328 |
331 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES, panel->CanResizeByMouse()); | 329 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES, panel->CanResizeByMouse()); |
332 | 330 |
333 gfx::Rect original_bounds = panel->GetBounds(); | 331 gfx::Rect original_bounds = panel->GetBounds(); |
334 | 332 |
335 // 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. |
336 // Try resizing by the top right side. | 334 // Try resizing by the top right side. |
(...skipping 25 matching lines...) Expand all Loading... |
362 bounds.Offset(-10, 0); | 360 bounds.Offset(-10, 0); |
363 EXPECT_EQ(bounds, panel->GetBounds()); | 361 EXPECT_EQ(bounds, panel->GetBounds()); |
364 | 362 |
365 panel_manager->EndResizingByMouse(true); | 363 panel_manager->EndResizingByMouse(true); |
366 EXPECT_EQ(original_bounds, panel->GetBounds()); | 364 EXPECT_EQ(original_bounds, panel->GetBounds()); |
367 EXPECT_FALSE(resize_controller->IsResizing()); | 365 EXPECT_FALSE(resize_controller->IsResizing()); |
368 | 366 |
369 panel_manager->CloseAll(); | 367 panel_manager->CloseAll(); |
370 } | 368 } |
371 | 369 |
372 IN_PROC_BROWSER_TEST_F(OldPanelResizeBrowserTest, ResizeDetachedPanelToTop) { | 370 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeDetachedPanelToTop) { |
373 // Setup the test areas to have top-aligned bar excluded from work area. | 371 // Setup the test areas to have top-aligned bar excluded from work area. |
374 const gfx::Rect primary_scren_area(0, 0, 800, 600); | 372 const gfx::Rect primary_scren_area(0, 0, 800, 600); |
375 const gfx::Rect work_area(0, 10, 800, 590); | 373 const gfx::Rect work_area(0, 10, 800, 590); |
376 SetTestingAreas(primary_scren_area, work_area); | 374 SetTestingAreas(primary_scren_area, work_area); |
377 | 375 |
378 PanelManager* panel_manager = PanelManager::GetInstance(); | 376 PanelManager* panel_manager = PanelManager::GetInstance(); |
379 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); | 377 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); |
380 gfx::Rect bounds = panel->GetBounds(); | 378 gfx::Rect bounds = panel->GetBounds(); |
381 | 379 |
382 // Try resizing by the top left corner. | 380 // Try resizing by the top left corner. |
(...skipping 22 matching lines...) Expand all Loading... |
405 bounds.set_height(bounds.height() + bounds.y() - mouse_location.y()); | 403 bounds.set_height(bounds.height() + bounds.y() - mouse_location.y()); |
406 bounds.set_x(mouse_location.x()); | 404 bounds.set_x(mouse_location.x()); |
407 bounds.set_y(mouse_location.y()); | 405 bounds.set_y(mouse_location.y()); |
408 EXPECT_EQ(bounds, panel->GetBounds()); | 406 EXPECT_EQ(bounds, panel->GetBounds()); |
409 | 407 |
410 panel_manager->EndResizingByMouse(false); | 408 panel_manager->EndResizingByMouse(false); |
411 EXPECT_EQ(bounds, panel->GetBounds()); | 409 EXPECT_EQ(bounds, panel->GetBounds()); |
412 | 410 |
413 panel_manager->CloseAll(); | 411 panel_manager->CloseAll(); |
414 } | 412 } |
OLD | NEW |