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/screen_ash.h" | 10 #include "ash/screen_ash.h" |
10 #include "ash/shell.h" | 11 #include "ash/shell.h" |
11 #include "ash/shell_window_ids.h" | 12 #include "ash/shell_window_ids.h" |
12 #include "ash/test/ash_test_base.h" | 13 #include "ash/test/ash_test_base.h" |
13 #include "ash/test/cursor_manager_test_api.h" | 14 #include "ash/test/cursor_manager_test_api.h" |
14 #include "ash/wm/cursor_manager.h" | 15 #include "ash/wm/cursor_manager.h" |
15 #include "ash/wm/property_util.h" | 16 #include "ash/wm/property_util.h" |
16 #include "ash/wm/shelf_layout_manager.h" | 17 #include "ash/wm/shelf_layout_manager.h" |
17 #include "ash/wm/workspace_controller.h" | 18 #include "ash/wm/workspace_controller.h" |
18 #include "ash/wm/workspace/snap_sizer.h" | 19 #include "ash/wm/workspace/snap_sizer.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 gfx::Point location = resizer.initial_location_in_parent(); | 120 gfx::Point location = resizer.initial_location_in_parent(); |
120 location.set_x(location.x() + delta_x); | 121 location.set_x(location.x() + delta_x); |
121 location.set_y(location.y() + delta_y); | 122 location.set_y(location.y() + delta_y); |
122 return location; | 123 return location; |
123 } | 124 } |
124 | 125 |
125 std::vector<aura::Window*> empty_windows() const { | 126 std::vector<aura::Window*> empty_windows() const { |
126 return std::vector<aura::Window*>(); | 127 return std::vector<aura::Window*>(); |
127 } | 128 } |
128 | 129 |
| 130 internal::ShelfLayoutManager* shelf_layout_manager() { |
| 131 return Shell::GetPrimaryRootWindowController()->shelf(); |
| 132 } |
| 133 |
129 TestWindowDelegate delegate_; | 134 TestWindowDelegate delegate_; |
130 TestWindowDelegate delegate2_; | 135 TestWindowDelegate delegate2_; |
131 TestWindowDelegate delegate3_; | 136 TestWindowDelegate delegate3_; |
132 scoped_ptr<aura::Window> window_; | 137 scoped_ptr<aura::Window> window_; |
133 scoped_ptr<aura::Window> window2_; | 138 scoped_ptr<aura::Window> window2_; |
134 scoped_ptr<aura::Window> window3_; | 139 scoped_ptr<aura::Window> window3_; |
135 | 140 |
136 private: | 141 private: |
137 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizerTest); | 142 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizerTest); |
138 }; | 143 }; |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 window_->bounds().ToString()); | 483 window_->bounds().ToString()); |
479 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get())); | 484 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get())); |
480 EXPECT_EQ("20,30 50x60", GetRestoreBoundsInScreen(window_.get())->ToString()); | 485 EXPECT_EQ("20,30 50x60", GetRestoreBoundsInScreen(window_.get())->ToString()); |
481 } | 486 } |
482 | 487 |
483 // 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. |
484 TEST_F(WorkspaceWindowResizerTest, MAYBE_WindowDragWithMultiDisplays) { | 489 TEST_F(WorkspaceWindowResizerTest, MAYBE_WindowDragWithMultiDisplays) { |
485 // 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) |
486 // 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. |
487 UpdateDisplay("800x600,800x600"); | 492 UpdateDisplay("800x600,800x600"); |
488 Shell::GetInstance()->shelf()->LayoutShelf(); | 493 shelf_layout_manager()->LayoutShelf(); |
489 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 494 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
490 ASSERT_EQ(2U, root_windows.size()); | 495 ASSERT_EQ(2U, root_windows.size()); |
491 | 496 |
492 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), | 497 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), |
493 Shell::GetScreen()->GetPrimaryDisplay()); | 498 Shell::GetScreen()->GetPrimaryDisplay()); |
494 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 499 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
495 { | 500 { |
496 // Grab (0, 0) of the window. | 501 // Grab (0, 0) of the window. |
497 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 502 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
498 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | 503 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 // root window's bounds. | 544 // root window's bounds. |
540 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | 545 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); |
541 EXPECT_EQ("-49,10 50x60", window_->bounds().ToString()); | 546 EXPECT_EQ("-49,10 50x60", window_->bounds().ToString()); |
542 } | 547 } |
543 } | 548 } |
544 | 549 |
545 // Verifies a window can be moved from the secondary display to primary. | 550 // Verifies a window can be moved from the secondary display to primary. |
546 TEST_F(WorkspaceWindowResizerTest, | 551 TEST_F(WorkspaceWindowResizerTest, |
547 MAYBE_WindowDragWithMultiDisplaysRightToLeft) { | 552 MAYBE_WindowDragWithMultiDisplaysRightToLeft) { |
548 UpdateDisplay("800x600,800x600"); | 553 UpdateDisplay("800x600,800x600"); |
549 Shell::GetInstance()->shelf()->LayoutShelf(); | 554 shelf_layout_manager()->LayoutShelf(); |
550 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 555 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
551 ASSERT_EQ(2U, root_windows.size()); | 556 ASSERT_EQ(2U, root_windows.size()); |
552 | 557 |
553 window_->SetBoundsInScreen( | 558 window_->SetBoundsInScreen( |
554 gfx::Rect(800, 00, 50, 60), | 559 gfx::Rect(800, 00, 50, 60), |
555 Shell::GetScreen()->GetDisplayNearestWindow(root_windows[1])); | 560 Shell::GetScreen()->GetDisplayNearestWindow(root_windows[1])); |
556 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | 561 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); |
557 { | 562 { |
558 // Grab (0, 0) of the window. | 563 // Grab (0, 0) of the window. |
559 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 564 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 resizer->CompleteDrag(ui::EF_CONTROL_DOWN); | 1002 resizer->CompleteDrag(ui::EF_CONTROL_DOWN); |
998 EXPECT_EQ("106,124 320x160", window_->bounds().ToString()); | 1003 EXPECT_EQ("106,124 320x160", window_->bounds().ToString()); |
999 } | 1004 } |
1000 | 1005 |
1001 // Check that only usable sizes get returned by the resizer. | 1006 // Check that only usable sizes get returned by the resizer. |
1002 TEST_F(WorkspaceWindowResizerTest, TestProperSizerResolutions) { | 1007 TEST_F(WorkspaceWindowResizerTest, TestProperSizerResolutions) { |
1003 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); | 1008 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); |
1004 scoped_ptr<SnapSizer> resizer(new SnapSizer( | 1009 scoped_ptr<SnapSizer> resizer(new SnapSizer( |
1005 window_.get(), gfx::Point(), SnapSizer::LEFT_EDGE)); | 1010 window_.get(), gfx::Point(), SnapSizer::LEFT_EDGE)); |
1006 ASSERT_TRUE(resizer.get()); | 1011 ASSERT_TRUE(resizer.get()); |
1007 Shell::GetInstance()->shelf()->SetAutoHideBehavior( | 1012 shelf_layout_manager()->SetAutoHideBehavior( |
1008 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1013 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
1009 gfx::Rect rect = resizer->GetTargetBoundsForSize(0); | 1014 gfx::Rect rect = resizer->GetTargetBoundsForSize(0); |
1010 EXPECT_EQ("0,0 720x597", rect.ToString()); | 1015 EXPECT_EQ("0,0 720x597", rect.ToString()); |
1011 rect = resizer->GetTargetBoundsForSize(1); | 1016 rect = resizer->GetTargetBoundsForSize(1); |
1012 EXPECT_EQ("0,0 720x597", rect.ToString()); | 1017 EXPECT_EQ("0,0 720x597", rect.ToString()); |
1013 rect = resizer->GetTargetBoundsForSize(2); | 1018 rect = resizer->GetTargetBoundsForSize(2); |
1014 EXPECT_EQ("0,0 720x597", rect.ToString()); | 1019 EXPECT_EQ("0,0 720x597", rect.ToString()); |
1015 rect = resizer->GetTargetBoundsForSize(3); | 1020 rect = resizer->GetTargetBoundsForSize(3); |
1016 EXPECT_EQ("0,0 640x597", rect.ToString()); | 1021 EXPECT_EQ("0,0 640x597", rect.ToString()); |
1017 Shell::GetInstance()->shelf()->SetAutoHideBehavior( | 1022 shelf_layout_manager()->SetAutoHideBehavior( |
1018 SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1023 SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
1019 rect = resizer->GetTargetBoundsForSize(0); | 1024 rect = resizer->GetTargetBoundsForSize(0); |
1020 EXPECT_EQ("0,0 720x552", rect.ToString()); | 1025 EXPECT_EQ("0,0 720x552", rect.ToString()); |
1021 rect = resizer->GetTargetBoundsForSize(1); | 1026 rect = resizer->GetTargetBoundsForSize(1); |
1022 EXPECT_EQ("0,0 720x552", rect.ToString()); | 1027 EXPECT_EQ("0,0 720x552", rect.ToString()); |
1023 rect = resizer->GetTargetBoundsForSize(2); | 1028 rect = resizer->GetTargetBoundsForSize(2); |
1024 EXPECT_EQ("0,0 720x552", rect.ToString()); | 1029 EXPECT_EQ("0,0 720x552", rect.ToString()); |
1025 rect = resizer->GetTargetBoundsForSize(3); | 1030 rect = resizer->GetTargetBoundsForSize(3); |
1026 EXPECT_EQ("0,0 640x552", rect.ToString()); | 1031 EXPECT_EQ("0,0 640x552", rect.ToString()); |
1027 } | 1032 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 resizer->Drag(CalculateDragPoint(*resizer, 142, 169), 0); | 1088 resizer->Drag(CalculateDragPoint(*resizer, 142, 169), 0); |
1084 EXPECT_EQ("152,180 20x30", window_->bounds().ToString()); | 1089 EXPECT_EQ("152,180 20x30", window_->bounds().ToString()); |
1085 } | 1090 } |
1086 | 1091 |
1087 // Verifies cursor's device scale factor is updated whe a window is moved across | 1092 // Verifies cursor's device scale factor is updated whe a window is moved across |
1088 // root windows with different device scale factors (http://crbug.com/154183). | 1093 // root windows with different device scale factors (http://crbug.com/154183). |
1089 TEST_F(WorkspaceWindowResizerTest, MAYBE_CursorDeviceScaleFactor) { | 1094 TEST_F(WorkspaceWindowResizerTest, MAYBE_CursorDeviceScaleFactor) { |
1090 // The secondary display is logically on the right, but on the system (e.g. X) | 1095 // The secondary display is logically on the right, but on the system (e.g. X) |
1091 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. | 1096 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. |
1092 UpdateDisplay("400x400,800x800*2"); | 1097 UpdateDisplay("400x400,800x800*2"); |
1093 Shell::GetInstance()->shelf()->LayoutShelf(); | 1098 shelf_layout_manager()->LayoutShelf(); |
1094 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 1099 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
1095 ASSERT_EQ(2U, root_windows.size()); | 1100 ASSERT_EQ(2U, root_windows.size()); |
1096 | 1101 |
1097 test::CursorManagerTestApi cursor_test_api( | 1102 test::CursorManagerTestApi cursor_test_api( |
1098 Shell::GetInstance()->cursor_manager()); | 1103 Shell::GetInstance()->cursor_manager()); |
1099 MouseCursorEventFilter* event_filter = | 1104 MouseCursorEventFilter* event_filter = |
1100 Shell::GetInstance()->mouse_cursor_filter(); | 1105 Shell::GetInstance()->mouse_cursor_filter(); |
1101 // Move window from the root window with 1.0 device scale factor to the root | 1106 // Move window from the root window with 1.0 device scale factor to the root |
1102 // window with 2.0 device scale factor. | 1107 // window with 2.0 device scale factor. |
1103 { | 1108 { |
(...skipping 29 matching lines...) Expand all Loading... |
1133 event_filter->WarpMouseCursorIfNecessary(root_windows[1], | 1138 event_filter->WarpMouseCursorIfNecessary(root_windows[1], |
1134 gfx::Point(400, 200)); | 1139 gfx::Point(400, 200)); |
1135 EXPECT_EQ(1.0f, cursor_test_api.GetDeviceScaleFactor()); | 1140 EXPECT_EQ(1.0f, cursor_test_api.GetDeviceScaleFactor()); |
1136 resizer->CompleteDrag(0); | 1141 resizer->CompleteDrag(0); |
1137 EXPECT_EQ(1.0f, cursor_test_api.GetDeviceScaleFactor()); | 1142 EXPECT_EQ(1.0f, cursor_test_api.GetDeviceScaleFactor()); |
1138 } | 1143 } |
1139 } | 1144 } |
1140 | 1145 |
1141 } // namespace internal | 1146 } // namespace internal |
1142 } // namespace ash | 1147 } // namespace ash |
OLD | NEW |