| 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 "ash/wm/workspace/workspace_window_resizer.h" | 5 #include "ash/wm/workspace/workspace_window_resizer.h" |
| 6 | 6 |
| 7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/display/mouse_cursor_event_filter.h" | 8 #include "ash/display/mouse_cursor_event_filter.h" |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/screen_ash.h" | 10 #include "ash/screen_ash.h" |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 EXPECT_EQ("20,500 100x100", window3_->bounds().ToString()); | 450 EXPECT_EQ("20,500 100x100", window3_->bounds().ToString()); |
| 451 | 451 |
| 452 // 100 up again. | 452 // 100 up again. |
| 453 resizer->Drag(CalculateDragPoint(*resizer, -10, -100), 0); | 453 resizer->Drag(CalculateDragPoint(*resizer, -10, -100), 0); |
| 454 EXPECT_EQ("0,0 200x100", window_->bounds().ToString()); | 454 EXPECT_EQ("0,0 200x100", window_->bounds().ToString()); |
| 455 EXPECT_EQ("10,100 200x266", window2_->bounds().ToString()); | 455 EXPECT_EQ("10,100 200x266", window2_->bounds().ToString()); |
| 456 EXPECT_EQ("20,366 100x134", window3_->bounds().ToString()); | 456 EXPECT_EQ("20,366 100x134", window3_->bounds().ToString()); |
| 457 } | 457 } |
| 458 | 458 |
| 459 // Assertions around dragging to the left/right edge of the screen. | 459 // Assertions around dragging to the left/right edge of the screen. |
| 460 // TODO(phoglund): Re-enable once breakage from | 460 TEST_F(WorkspaceWindowResizerTest, Edge) { |
| 461 // https://chromiumcodereview.appspot.com/11369017 gets fixed. | |
| 462 TEST_F(WorkspaceWindowResizerTest, DISABLED_Edge) { | |
| 463 int bottom = | 461 int bottom = |
| 464 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); | 462 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); |
| 465 window_->SetBounds(gfx::Rect(20, 30, 50, 60)); | 463 window_->SetBounds(gfx::Rect(20, 30, 50, 60)); |
| 466 { | 464 { |
| 467 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 465 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
| 468 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | 466 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); |
| 469 ASSERT_TRUE(resizer.get()); | 467 ASSERT_TRUE(resizer.get()); |
| 470 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0); | 468 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0); |
| 471 resizer->CompleteDrag(0); | 469 resizer->CompleteDrag(0); |
| 472 EXPECT_EQ("0,0 720x" + base::IntToString(bottom), | 470 EXPECT_EQ("0,0 720x" + base::IntToString(bottom), |
| 473 window_->bounds().ToString()); | 471 window_->bounds().ToString()); |
| 474 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get())); | 472 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get())); |
| 475 EXPECT_EQ("20,30 50x60", | 473 EXPECT_EQ("20,30 50x60", |
| 476 GetRestoreBoundsInScreen(window_.get())->ToString()); | 474 GetRestoreBoundsInScreen(window_.get())->ToString()); |
| 477 } | 475 } |
| 478 // Try the same with the right side. | 476 // Try the same with the right side. |
| 479 { | 477 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
| 480 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 478 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); |
| 481 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | 479 ASSERT_TRUE(resizer.get()); |
| 482 ASSERT_TRUE(resizer.get()); | 480 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); |
| 483 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); | 481 resizer->CompleteDrag(0); |
| 484 resizer->CompleteDrag(0); | 482 EXPECT_EQ("80,0 720x" + base::IntToString(bottom), |
| 485 EXPECT_EQ("80,0 720x" + base::IntToString(bottom), | 483 window_->bounds().ToString()); |
| 486 window_->bounds().ToString()); | 484 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get())); |
| 487 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get())); | 485 EXPECT_EQ("20,30 50x60", GetRestoreBoundsInScreen(window_.get())->ToString()); |
| 488 EXPECT_EQ("20,30 50x60", | |
| 489 GetRestoreBoundsInScreen(window_.get())->ToString()); | |
| 490 } | |
| 491 | |
| 492 // Test if the restore bounds is correct in multiple displays. | |
| 493 ClearRestoreBounds(window_.get()); | |
| 494 UpdateDisplay("800x600,200x600"); | |
| 495 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | |
| 496 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | |
| 497 window_->SetBoundsInScreen(gfx::Rect(800, 10, 50, 60), | |
| 498 ScreenAsh::GetSecondaryDisplay()); | |
| 499 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | |
| 500 { | |
| 501 bottom = | |
| 502 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); | |
| 503 EXPECT_EQ("800,10 50x60", window_->GetBoundsInScreen().ToString()); | |
| 504 | |
| 505 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | |
| 506 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | |
| 507 ASSERT_TRUE(resizer.get()); | |
| 508 | |
| 509 resizer->Drag(CalculateDragPoint(*resizer, 199, 00), 0); | |
| 510 resizer->CompleteDrag(0); | |
| 511 EXPECT_EQ("20,0 180x" + base::IntToString(bottom), | |
| 512 window_->bounds().ToString()); | |
| 513 EXPECT_EQ("800,10 50x60", | |
| 514 GetRestoreBoundsInScreen(window_.get())->ToString()); | |
| 515 } | |
| 516 } | 486 } |
| 517 | 487 |
| 518 // Verifies a window can be moved from the primary display to another. | 488 // Verifies a window can be moved from the primary display to another. |
| 519 TEST_F(WorkspaceWindowResizerTest, MAYBE_WindowDragWithMultiDisplays) { | 489 TEST_F(WorkspaceWindowResizerTest, MAYBE_WindowDragWithMultiDisplays) { |
| 520 // The secondary display is logically on the right, but on the system (e.g. X) | 490 // The secondary display is logically on the right, but on the system (e.g. X) |
| 521 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. | 491 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. |
| 522 UpdateDisplay("800x600,800x600"); | 492 UpdateDisplay("800x600,800x600"); |
| 523 shelf_layout_manager()->LayoutShelf(); | 493 shelf_layout_manager()->LayoutShelf(); |
| 524 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 494 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 525 ASSERT_EQ(2U, root_windows.size()); | 495 ASSERT_EQ(2U, root_windows.size()); |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1404 event_filter->WarpMouseCursorIfNecessary(root_windows[1], | 1374 event_filter->WarpMouseCursorIfNecessary(root_windows[1], |
| 1405 gfx::Point(400, 200)); | 1375 gfx::Point(400, 200)); |
| 1406 EXPECT_EQ(1.0f, cursor_test_api.GetDeviceScaleFactor()); | 1376 EXPECT_EQ(1.0f, cursor_test_api.GetDeviceScaleFactor()); |
| 1407 resizer->CompleteDrag(0); | 1377 resizer->CompleteDrag(0); |
| 1408 EXPECT_EQ(1.0f, cursor_test_api.GetDeviceScaleFactor()); | 1378 EXPECT_EQ(1.0f, cursor_test_api.GetDeviceScaleFactor()); |
| 1409 } | 1379 } |
| 1410 } | 1380 } |
| 1411 | 1381 |
| 1412 } // namespace internal | 1382 } // namespace internal |
| 1413 } // namespace ash | 1383 } // namespace ash |
| OLD | NEW |