| 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_collection.h" | 6 #include "chrome/browser/ui/panels/detached_panel_collection.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 10 matching lines...) Expand all Loading... |
| 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(PanelResizeBrowserTest, DockedPanelResizability) { | 31 // http://crbug.com/175760 |
| 32 #if defined(OS_MAC) |
| 33 #define MAYBE_DockedPanelResizability DISABLED_DockedPanelResizability |
| 34 #else |
| 35 #define MAYBE_DockedPanelResizability DockedPanelResizability |
| 36 #endif |
| 37 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, MAYBE_DockedPanelResizability) { |
| 32 PanelManager* panel_manager = PanelManager::GetInstance(); | 38 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 33 Panel* panel = CreatePanel("Panel"); | 39 Panel* panel = CreatePanel("Panel"); |
| 34 | 40 |
| 35 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES_EXCEPT_BOTTOM, | 41 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES_EXCEPT_BOTTOM, |
| 36 panel->CanResizeByMouse()); | 42 panel->CanResizeByMouse()); |
| 37 | 43 |
| 38 gfx::Rect bounds = panel->GetBounds(); | 44 gfx::Rect bounds = panel->GetBounds(); |
| 39 | 45 |
| 40 // Try resizing by the top left corner. | 46 // Try resizing by the top left corner. |
| 41 gfx::Point mouse_location = bounds.origin(); | 47 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); | 146 mouse_location.Offset(20, 10); |
| 141 panel_manager->ResizeByMouse(mouse_location); | 147 panel_manager->ResizeByMouse(mouse_location); |
| 142 EXPECT_EQ(bounds, panel->GetBounds()); | 148 EXPECT_EQ(bounds, panel->GetBounds()); |
| 143 | 149 |
| 144 panel_manager->EndResizingByMouse(false); | 150 panel_manager->EndResizingByMouse(false); |
| 145 EXPECT_EQ(bounds, panel->GetBounds()); | 151 EXPECT_EQ(bounds, panel->GetBounds()); |
| 146 | 152 |
| 147 panel->Close(); | 153 panel->Close(); |
| 148 } | 154 } |
| 149 | 155 |
| 150 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeDetachedPanel) { | 156 // http://crbug.com/175760 |
| 157 #if defined(OS_MAC) |
| 158 #define MAYBE_ResizeDetachedPanel DISABLED_ResizeDetachedPanel |
| 159 #else |
| 160 #define MAYBE_ResizeDetachedPanel ResizeDetachedPanel |
| 161 #endif |
| 162 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, MAYBE_ResizeDetachedPanel) { |
| 151 PanelManager* panel_manager = PanelManager::GetInstance(); | 163 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 152 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100)); | 164 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100)); |
| 153 | 165 |
| 154 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES, panel->CanResizeByMouse()); | 166 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES, panel->CanResizeByMouse()); |
| 155 | 167 |
| 156 gfx::Rect bounds = panel->GetBounds(); | 168 gfx::Rect bounds = panel->GetBounds(); |
| 157 | 169 |
| 158 // Try resizing by the right side; verify resize will change width only. | 170 // Try resizing by the right side; verify resize will change width only. |
| 159 gfx::Point mouse_location = bounds.origin() + | 171 gfx::Point mouse_location = bounds.origin() + |
| 160 gfx::Vector2d(bounds.width() - 1, 30); | 172 gfx::Vector2d(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)); | 219 bounds.set_size(gfx::Size(bounds.width() + 20, bounds.height() + 10)); |
| 208 bounds.Offset(-20, -10); | 220 bounds.Offset(-20, -10); |
| 209 EXPECT_EQ(bounds, panel->GetBounds()); | 221 EXPECT_EQ(bounds, panel->GetBounds()); |
| 210 | 222 |
| 211 panel_manager->EndResizingByMouse(false); | 223 panel_manager->EndResizingByMouse(false); |
| 212 EXPECT_EQ(bounds, panel->GetBounds()); | 224 EXPECT_EQ(bounds, panel->GetBounds()); |
| 213 | 225 |
| 214 PanelManager::GetInstance()->CloseAll(); | 226 PanelManager::GetInstance()->CloseAll(); |
| 215 } | 227 } |
| 216 | 228 |
| 217 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeDetachedPanelToClampSize) { | 229 // http://crbug.com/175760 |
| 230 #if defined(OS_MAC) |
| 231 #define MAYBE_ResizeDetachedPanelToClampSize \ |
| 232 DISABLED_ResizeDetachedPanelToClampSize |
| 233 #else |
| 234 #define MAYBE_ResizeDetachedPanelToClampSize ResizeDetachedPanelToClampSize |
| 235 #endif |
| 236 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, |
| 237 MAYBE_ResizeDetachedPanelToClampSize) { |
| 218 PanelManager* panel_manager = PanelManager::GetInstance(); | 238 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 219 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100)); | 239 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100)); |
| 220 | 240 |
| 221 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES, panel->CanResizeByMouse()); | 241 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES, panel->CanResizeByMouse()); |
| 222 | 242 |
| 223 gfx::Rect bounds = panel->GetBounds(); | 243 gfx::Rect bounds = panel->GetBounds(); |
| 224 | 244 |
| 225 // Make sure the panel does not resize smaller than its min size. | 245 // Make sure the panel does not resize smaller than its min size. |
| 226 gfx::Point mouse_location = bounds.origin() + | 246 gfx::Point mouse_location = bounds.origin() + |
| 227 gfx::Vector2d(30, bounds.height() - 2); | 247 gfx::Vector2d(30, bounds.height() - 2); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 252 bounds.set_size(gfx::Size(bounds.width() + delta_x, | 272 bounds.set_size(gfx::Size(bounds.width() + delta_x, |
| 253 bounds.height() + delta_y)); | 273 bounds.height() + delta_y)); |
| 254 EXPECT_EQ(bounds, panel->GetBounds()); | 274 EXPECT_EQ(bounds, panel->GetBounds()); |
| 255 | 275 |
| 256 panel_manager->EndResizingByMouse(false); | 276 panel_manager->EndResizingByMouse(false); |
| 257 EXPECT_EQ(bounds, panel->GetBounds()); | 277 EXPECT_EQ(bounds, panel->GetBounds()); |
| 258 | 278 |
| 259 PanelManager::GetInstance()->CloseAll(); | 279 PanelManager::GetInstance()->CloseAll(); |
| 260 } | 280 } |
| 261 | 281 |
| 262 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, CloseDetachedPanelOnResize) { | 282 // http://crbug.com/175760 |
| 283 #if defined(OS_MAC) |
| 284 #define MAYBE_CloseDetachedPanelOnResize DISABLED_CloseDetachedPanelOnResize |
| 285 #else |
| 286 #define MAYBE_CloseDetachedPanelOnResize CloseDetachedPanelOnResize |
| 287 #endif |
| 288 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, |
| 289 MAYBE_CloseDetachedPanelOnResize) { |
| 263 PanelManager* panel_manager = PanelManager::GetInstance(); | 290 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 264 PanelResizeController* resize_controller = panel_manager->resize_controller(); | 291 PanelResizeController* resize_controller = panel_manager->resize_controller(); |
| 265 DetachedPanelCollection* detached_collection = | 292 DetachedPanelCollection* detached_collection = |
| 266 panel_manager->detached_collection(); | 293 panel_manager->detached_collection(); |
| 267 | 294 |
| 268 // Create 3 detached panels. | 295 // Create 3 detached panels. |
| 269 Panel* panel1 = CreateDetachedPanel("1", gfx::Rect(100, 200, 100, 100)); | 296 Panel* panel1 = CreateDetachedPanel("1", gfx::Rect(100, 200, 100, 100)); |
| 270 Panel* panel2 = CreateDetachedPanel("2", gfx::Rect(200, 210, 110, 110)); | 297 Panel* panel2 = CreateDetachedPanel("2", gfx::Rect(200, 210, 110, 110)); |
| 271 Panel* panel3 = CreateDetachedPanel("3", gfx::Rect(300, 220, 120, 120)); | 298 Panel* panel3 = CreateDetachedPanel("3", gfx::Rect(300, 220, 120, 120)); |
| 272 ASSERT_EQ(3, detached_collection->num_panels()); | 299 ASSERT_EQ(3, detached_collection->num_panels()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 // resizing mode by now. | 342 // resizing mode by now. |
| 316 EXPECT_FALSE(resize_controller->IsResizing()); | 343 EXPECT_FALSE(resize_controller->IsResizing()); |
| 317 | 344 |
| 318 panel_manager->EndResizingByMouse(false); | 345 panel_manager->EndResizingByMouse(false); |
| 319 EXPECT_FALSE(resize_controller->IsResizing()); | 346 EXPECT_FALSE(resize_controller->IsResizing()); |
| 320 EXPECT_EQ(panel1_bounds, panel1->GetBounds()); | 347 EXPECT_EQ(panel1_bounds, panel1->GetBounds()); |
| 321 | 348 |
| 322 panel_manager->CloseAll(); | 349 panel_manager->CloseAll(); |
| 323 } | 350 } |
| 324 | 351 |
| 325 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeAndCancel) { | 352 // http://crbug.com/175760 |
| 353 #if defined(OS_MAC) |
| 354 #define MAYBE_ResizeAndCancel DISABLED_ResizeAndCancel |
| 355 #else |
| 356 #define MAYBE_ResizeAndCancel ResizeAndCancel |
| 357 #endif |
| 358 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, MAYBE_ResizeAndCancel) { |
| 326 PanelManager* panel_manager = PanelManager::GetInstance(); | 359 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 327 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100)); | 360 Panel* panel = CreateDetachedPanel("Panel", gfx::Rect(300, 200, 150, 100)); |
| 328 PanelResizeController* resize_controller = panel_manager->resize_controller(); | 361 PanelResizeController* resize_controller = panel_manager->resize_controller(); |
| 329 | 362 |
| 330 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES, panel->CanResizeByMouse()); | 363 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES, panel->CanResizeByMouse()); |
| 331 | 364 |
| 332 gfx::Rect original_bounds = panel->GetBounds(); | 365 gfx::Rect original_bounds = panel->GetBounds(); |
| 333 | 366 |
| 334 // Resizing the panel, then cancelling should return it to the original state. | 367 // Resizing the panel, then cancelling should return it to the original state. |
| 335 // Try resizing by the top right side. | 368 // Try resizing by the top right side. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 360 bounds.Offset(-10, 0); | 393 bounds.Offset(-10, 0); |
| 361 EXPECT_EQ(bounds, panel->GetBounds()); | 394 EXPECT_EQ(bounds, panel->GetBounds()); |
| 362 | 395 |
| 363 panel_manager->EndResizingByMouse(true); | 396 panel_manager->EndResizingByMouse(true); |
| 364 EXPECT_EQ(original_bounds, panel->GetBounds()); | 397 EXPECT_EQ(original_bounds, panel->GetBounds()); |
| 365 EXPECT_FALSE(resize_controller->IsResizing()); | 398 EXPECT_FALSE(resize_controller->IsResizing()); |
| 366 | 399 |
| 367 panel_manager->CloseAll(); | 400 panel_manager->CloseAll(); |
| 368 } | 401 } |
| 369 | 402 |
| 370 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, ResizeDetachedPanelToTop) { | 403 // http://crbug.com/175760 |
| 404 #if defined(OS_MAC) |
| 405 #define MAYBE_ResizeDetachedPanelToTop DISABLED_ResizeDetachedPanelToTop |
| 406 #else |
| 407 #define MAYBE_ResizeDetachedPanelToTop ResizeDetachedPanelToTop |
| 408 #endif |
| 409 IN_PROC_BROWSER_TEST_F(PanelResizeBrowserTest, MAYBE_ResizeDetachedPanelToTop) { |
| 371 // Setup the test areas to have top-aligned bar excluded from work area. | 410 // Setup the test areas to have top-aligned bar excluded from work area. |
| 372 const gfx::Rect primary_scren_area(0, 0, 800, 600); | 411 const gfx::Rect primary_scren_area(0, 0, 800, 600); |
| 373 const gfx::Rect work_area(0, 10, 800, 590); | 412 const gfx::Rect work_area(0, 10, 800, 590); |
| 374 SetTestingAreas(primary_scren_area, work_area); | 413 SetTestingAreas(primary_scren_area, work_area); |
| 375 | 414 |
| 376 PanelManager* panel_manager = PanelManager::GetInstance(); | 415 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 377 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); | 416 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); |
| 378 gfx::Rect bounds = panel->GetBounds(); | 417 gfx::Rect bounds = panel->GetBounds(); |
| 379 | 418 |
| 380 // Try resizing by the top left corner. | 419 // Try resizing by the top left corner. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 403 bounds.set_height(bounds.height() + bounds.y() - mouse_location.y()); | 442 bounds.set_height(bounds.height() + bounds.y() - mouse_location.y()); |
| 404 bounds.set_x(mouse_location.x()); | 443 bounds.set_x(mouse_location.x()); |
| 405 bounds.set_y(mouse_location.y()); | 444 bounds.set_y(mouse_location.y()); |
| 406 EXPECT_EQ(bounds, panel->GetBounds()); | 445 EXPECT_EQ(bounds, panel->GetBounds()); |
| 407 | 446 |
| 408 panel_manager->EndResizingByMouse(false); | 447 panel_manager->EndResizingByMouse(false); |
| 409 EXPECT_EQ(bounds, panel->GetBounds()); | 448 EXPECT_EQ(bounds, panel->GetBounds()); |
| 410 | 449 |
| 411 panel_manager->CloseAll(); | 450 panel_manager->CloseAll(); |
| 412 } | 451 } |
| OLD | NEW |