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/screen_ash.h" | 8 #include "ash/screen_ash.h" |
8 #include "ash/shell.h" | 9 #include "ash/shell.h" |
9 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
10 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
11 #include "ash/wm/property_util.h" | 12 #include "ash/wm/property_util.h" |
12 #include "ash/wm/workspace_controller.h" | 13 #include "ash/wm/workspace_controller.h" |
13 #include "ash/wm/workspace/phantom_window_controller.h" | 14 #include "ash/wm/workspace/phantom_window_controller.h" |
14 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
15 #include "ui/aura/root_window.h" | 16 #include "ui/aura/root_window.h" |
16 #include "ui/aura/test/test_window_delegate.h" | 17 #include "ui/aura/test/test_window_delegate.h" |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 EXPECT_FALSE(resizer->snap_phantom_window_controller_.get()); | 640 EXPECT_FALSE(resizer->snap_phantom_window_controller_.get()); |
640 EXPECT_FALSE(resizer->drag_phantom_window_controller_.get()); | 641 EXPECT_FALSE(resizer->drag_phantom_window_controller_.get()); |
641 | 642 |
642 resizer->Drag(CalculateDragPoint(*resizer, 0, 610), 0); | 643 resizer->Drag(CalculateDragPoint(*resizer, 0, 610), 0); |
643 resizer->RevertDrag(); | 644 resizer->RevertDrag(); |
644 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 645 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
645 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); | 646 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); |
646 } | 647 } |
647 } | 648 } |
648 | 649 |
| 650 // Verifies if the resizer sets and resets DisplayController::dont_warp_mouse_ |
| 651 // as expected. |
| 652 TEST_F(WorkspaceWindowResizerTest, WarpMousePointer) { |
| 653 DisplayController* controller = Shell::GetInstance()->display_controller(); |
| 654 ASSERT_TRUE(controller); |
| 655 window_->SetBounds(gfx::Rect(0, 0, 50, 60)); |
| 656 |
| 657 EXPECT_FALSE(controller->dont_warp_mouse_); |
| 658 { |
| 659 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
| 660 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); |
| 661 // While dragging a window, warp should be allowed. |
| 662 EXPECT_FALSE(controller->dont_warp_mouse_); |
| 663 resizer->CompleteDrag(0); |
| 664 } |
| 665 EXPECT_FALSE(controller->dont_warp_mouse_); |
| 666 |
| 667 { |
| 668 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
| 669 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); |
| 670 EXPECT_FALSE(controller->dont_warp_mouse_); |
| 671 resizer->RevertDrag(); |
| 672 } |
| 673 EXPECT_FALSE(controller->dont_warp_mouse_); |
| 674 |
| 675 { |
| 676 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
| 677 window_.get(), gfx::Point(), HTRIGHT, empty_windows())); |
| 678 // While resizing a window, warp should NOT be allowed. |
| 679 EXPECT_TRUE(controller->dont_warp_mouse_); |
| 680 resizer->CompleteDrag(0); |
| 681 } |
| 682 EXPECT_FALSE(controller->dont_warp_mouse_); |
| 683 |
| 684 { |
| 685 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
| 686 window_.get(), gfx::Point(), HTRIGHT, empty_windows())); |
| 687 EXPECT_TRUE(controller->dont_warp_mouse_); |
| 688 resizer->RevertDrag(); |
| 689 } |
| 690 EXPECT_FALSE(controller->dont_warp_mouse_); |
| 691 } |
| 692 |
649 // Verifies windows are correctly restacked when reordering multiple windows. | 693 // Verifies windows are correctly restacked when reordering multiple windows. |
650 TEST_F(WorkspaceWindowResizerTest, RestackAttached) { | 694 TEST_F(WorkspaceWindowResizerTest, RestackAttached) { |
651 window_->SetBounds(gfx::Rect( 0, 0, 200, 300)); | 695 window_->SetBounds(gfx::Rect( 0, 0, 200, 300)); |
652 window2_->SetBounds(gfx::Rect(200, 0, 100, 200)); | 696 window2_->SetBounds(gfx::Rect(200, 0, 100, 200)); |
653 window3_->SetBounds(gfx::Rect(300, 0, 100, 100)); | 697 window3_->SetBounds(gfx::Rect(300, 0, 100, 100)); |
654 | 698 |
655 { | 699 { |
656 std::vector<aura::Window*> windows; | 700 std::vector<aura::Window*> windows; |
657 windows.push_back(window2_.get()); | 701 windows.push_back(window2_.get()); |
658 SetGridSize(10); | 702 SetGridSize(10); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 ASSERT_TRUE(resizer.get()); | 881 ASSERT_TRUE(resizer.get()); |
838 // Ctrl + drag the window to new poistion by adding (10, 12) to its origin, | 882 // Ctrl + drag the window to new poistion by adding (10, 12) to its origin, |
839 // the window should move to the exact position. | 883 // the window should move to the exact position. |
840 resizer->Drag(CalculateDragPoint(*resizer, 10, 12), 0); | 884 resizer->Drag(CalculateDragPoint(*resizer, 10, 12), 0); |
841 resizer->CompleteDrag(ui::EF_CONTROL_DOWN); | 885 resizer->CompleteDrag(ui::EF_CONTROL_DOWN); |
842 EXPECT_EQ("106,124 320x160", window_->bounds().ToString()); | 886 EXPECT_EQ("106,124 320x160", window_->bounds().ToString()); |
843 } | 887 } |
844 | 888 |
845 } // namespace test | 889 } // namespace test |
846 } // namespace ash | 890 } // namespace ash |
OLD | NEW |