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/screen_ash.h" | 9 #include "ash/screen_ash.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
11 #include "ash/shell_window_ids.h" | 11 #include "ash/shell_window_ids.h" |
12 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
| 13 #include "ash/test/cursor_manager_test_api.h" |
| 14 #include "ash/wm/cursor_manager.h" |
13 #include "ash/wm/property_util.h" | 15 #include "ash/wm/property_util.h" |
14 #include "ash/wm/shelf_layout_manager.h" | 16 #include "ash/wm/shelf_layout_manager.h" |
15 #include "ash/wm/workspace_controller.h" | 17 #include "ash/wm/workspace_controller.h" |
16 #include "ash/wm/workspace/snap_sizer.h" | 18 #include "ash/wm/workspace/snap_sizer.h" |
17 #include "ash/wm/workspace/phantom_window_controller.h" | 19 #include "ash/wm/workspace/phantom_window_controller.h" |
18 #include "base/string_number_conversions.h" | 20 #include "base/string_number_conversions.h" |
19 #include "base/stringprintf.h" | 21 #include "base/stringprintf.h" |
20 #include "ui/aura/root_window.h" | 22 #include "ui/aura/root_window.h" |
21 #include "ui/aura/test/test_window_delegate.h" | 23 #include "ui/aura/test/test_window_delegate.h" |
22 #include "ui/base/hit_test.h" | 24 #include "ui/base/hit_test.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 140 |
139 // Fails on win_aura since wm::GetRootWindowRelativeToWindow is not implemented | 141 // Fails on win_aura since wm::GetRootWindowRelativeToWindow is not implemented |
140 // yet for the platform. | 142 // yet for the platform. |
141 #if defined(OS_WIN) | 143 #if defined(OS_WIN) |
142 #define MAYBE_WindowDragWithMultiDisplays \ | 144 #define MAYBE_WindowDragWithMultiDisplays \ |
143 DISABLED_WindowDragWithMultiDisplays | 145 DISABLED_WindowDragWithMultiDisplays |
144 #define MAYBE_WindowDragWithMultiDisplaysRightToLeft \ | 146 #define MAYBE_WindowDragWithMultiDisplaysRightToLeft \ |
145 DISABLED_WindowDragWithMultiDisplaysRightToLeft | 147 DISABLED_WindowDragWithMultiDisplaysRightToLeft |
146 #define MAYBE_PhantomStyle DISABLED_PhantomStyle | 148 #define MAYBE_PhantomStyle DISABLED_PhantomStyle |
147 #define MAYBE_CancelSnapPhantom DISABLED_CancelSnapPhantom | 149 #define MAYBE_CancelSnapPhantom DISABLED_CancelSnapPhantom |
| 150 #define MAYBE_CursorDeviceScaleFactor DISABLED_CursorDeviceScaleFactor |
148 #else | 151 #else |
149 #define MAYBE_WindowDragWithMultiDisplays WindowDragWithMultiDisplays | 152 #define MAYBE_WindowDragWithMultiDisplays WindowDragWithMultiDisplays |
150 #define MAYBE_WindowDragWithMultiDisplaysRightToLeft \ | 153 #define MAYBE_WindowDragWithMultiDisplaysRightToLeft \ |
151 WindowDragWithMultiDisplaysRightToLeft | 154 WindowDragWithMultiDisplaysRightToLeft |
152 #define MAYBE_PhantomStyle PhantomStyle | 155 #define MAYBE_PhantomStyle PhantomStyle |
153 #define MAYBE_CancelSnapPhantom CancelSnapPhantom | 156 #define MAYBE_CancelSnapPhantom CancelSnapPhantom |
| 157 #define MAYBE_CursorDeviceScaleFactor CursorDeviceScaleFactor |
154 #endif | 158 #endif |
155 | 159 |
156 // Assertions around attached window resize dragging from the right with 2 | 160 // Assertions around attached window resize dragging from the right with 2 |
157 // windows. | 161 // windows. |
158 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_2) { | 162 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_2) { |
159 window_->SetBounds(gfx::Rect(0, 300, 400, 300)); | 163 window_->SetBounds(gfx::Rect(0, 300, 400, 300)); |
160 window2_->SetBounds(gfx::Rect(400, 200, 100, 200)); | 164 window2_->SetBounds(gfx::Rect(400, 200, 100, 200)); |
161 | 165 |
162 std::vector<aura::Window*> windows; | 166 std::vector<aura::Window*> windows; |
163 windows.push_back(window2_.get()); | 167 windows.push_back(window2_.get()); |
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 | 1004 |
1001 // Move |window| one pixel above |window2|. | 1005 // Move |window| one pixel above |window2|. |
1002 resizer->Drag(CalculateDragPoint(*resizer, 142, 119), 0); | 1006 resizer->Drag(CalculateDragPoint(*resizer, 142, 119), 0); |
1003 EXPECT_EQ("152,130 20x30", window_->bounds().ToString()); | 1007 EXPECT_EQ("152,130 20x30", window_->bounds().ToString()); |
1004 | 1008 |
1005 // Move |window| one pixel above the bottom of |window2|. | 1009 // Move |window| one pixel above the bottom of |window2|. |
1006 resizer->Drag(CalculateDragPoint(*resizer, 142, 169), 0); | 1010 resizer->Drag(CalculateDragPoint(*resizer, 142, 169), 0); |
1007 EXPECT_EQ("152,180 20x30", window_->bounds().ToString()); | 1011 EXPECT_EQ("152,180 20x30", window_->bounds().ToString()); |
1008 } | 1012 } |
1009 | 1013 |
| 1014 // Verifies cursor's device scale factor is updated whe a window is moved across |
| 1015 // root windows with different device scale factors (http://crbug.com/154183). |
| 1016 TEST_F(WorkspaceWindowResizerTest, MAYBE_CursorDeviceScaleFactor) { |
| 1017 // The secondary display is logically on the right, but on the system (e.g. X) |
| 1018 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. |
| 1019 UpdateDisplay("400x400,800x800*2"); |
| 1020 Shell::GetInstance()->shelf()->LayoutShelf(); |
| 1021 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 1022 ASSERT_EQ(2U, root_windows.size()); |
| 1023 |
| 1024 test::CursorManagerTestApi cursor_test_api( |
| 1025 Shell::GetInstance()->cursor_manager()); |
| 1026 MouseCursorEventFilter* event_filter = |
| 1027 Shell::GetInstance()->mouse_cursor_filter(); |
| 1028 // Move window from the root window with 1.0 device scale factor to the root |
| 1029 // window with 2.0 device scale factor. |
| 1030 { |
| 1031 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), |
| 1032 gfx::Screen::GetPrimaryDisplay()); |
| 1033 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
| 1034 // Grab (0, 0) of the window. |
| 1035 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
| 1036 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); |
| 1037 EXPECT_EQ(1.0f, cursor_test_api.GetDeviceScaleFactor()); |
| 1038 ASSERT_TRUE(resizer.get()); |
| 1039 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); |
| 1040 event_filter->WarpMouseCursorIfNecessary(root_windows[0], |
| 1041 gfx::Point(399, 200)); |
| 1042 EXPECT_EQ(2.0f, cursor_test_api.GetDeviceScaleFactor()); |
| 1043 resizer->CompleteDrag(0); |
| 1044 EXPECT_EQ(2.0f, cursor_test_api.GetDeviceScaleFactor()); |
| 1045 } |
| 1046 |
| 1047 // Move window from the root window with 2.0 device scale factor to the root |
| 1048 // window with 1.0 device scale factor. |
| 1049 { |
| 1050 window_->SetBoundsInScreen( |
| 1051 gfx::Rect(600, 0, 50, 60), |
| 1052 gfx::Screen::GetDisplayNearestWindow(root_windows[1])); |
| 1053 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); |
| 1054 // Grab (0, 0) of the window. |
| 1055 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
| 1056 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); |
| 1057 EXPECT_EQ(2.0f, cursor_test_api.GetDeviceScaleFactor()); |
| 1058 ASSERT_TRUE(resizer.get()); |
| 1059 resizer->Drag(CalculateDragPoint(*resizer, -200, 200), 0); |
| 1060 event_filter->WarpMouseCursorIfNecessary(root_windows[1], |
| 1061 gfx::Point(400, 200)); |
| 1062 EXPECT_EQ(1.0f, cursor_test_api.GetDeviceScaleFactor()); |
| 1063 resizer->CompleteDrag(0); |
| 1064 EXPECT_EQ(1.0f, cursor_test_api.GetDeviceScaleFactor()); |
| 1065 } |
| 1066 } |
| 1067 |
1010 } // namespace internal | 1068 } // namespace internal |
1011 } // namespace ash | 1069 } // namespace ash |
OLD | NEW |