| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/display/unified_mouse_warp_controller.h" | 5 #include "ash/display/unified_mouse_warp_controller.h" |
| 6 | 6 |
| 7 #include "ash/display/display_util.h" | 7 #include "ash/display/display_util.h" |
| 8 #include "ash/display/mirror_window_controller.h" | 8 #include "ash/display/mirror_window_controller.h" |
| 9 #include "ash/display/mouse_cursor_event_filter.h" | 9 #include "ash/display/mouse_cursor_event_filter.h" |
| 10 #include "ash/host/ash_window_tree_host.h" | 10 #include "ash/host/ash_window_tree_host.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 // Touch the bottom edge of the second display. | 148 // Touch the bottom edge of the second display. |
| 149 EXPECT_FALSE(TestIfMouseWarpsAt(gfx::Point(610, 499))); | 149 EXPECT_FALSE(TestIfMouseWarpsAt(gfx::Point(610, 499))); |
| 150 } | 150 } |
| 151 | 151 |
| 152 private: | 152 private: |
| 153 DISALLOW_COPY_AND_ASSIGN(UnifiedMouseWarpControllerTest); | 153 DISALLOW_COPY_AND_ASSIGN(UnifiedMouseWarpControllerTest); |
| 154 }; | 154 }; |
| 155 | 155 |
| 156 // Verifies if MouseCursorEventFilter's bounds calculation works correctly. | 156 // Verifies if MouseCursorEventFilter's bounds calculation works correctly. |
| 157 TEST_F(UnifiedMouseWarpControllerTest, BoundaryTest) { | 157 TEST_F(UnifiedMouseWarpControllerTest, BoundaryTest) { |
| 158 if (!SupportsMultipleDisplays()) | |
| 159 return; | |
| 160 | |
| 161 { | 158 { |
| 162 SCOPED_TRACE("1x1"); | 159 SCOPED_TRACE("1x1"); |
| 163 BoundaryTestBody("400x400,0+450-700x400", "400x400,0+450-700x600"); | 160 BoundaryTestBody("400x400,0+450-700x400", "400x400,0+450-700x600"); |
| 164 } | 161 } |
| 165 { | 162 { |
| 166 SCOPED_TRACE("2x1"); | 163 SCOPED_TRACE("2x1"); |
| 167 BoundaryTestBody("400x400*2,0+450-700x400", "400x400*2,0+450-700x600"); | 164 BoundaryTestBody("400x400*2,0+450-700x400", "400x400*2,0+450-700x600"); |
| 168 } | 165 } |
| 169 { | 166 { |
| 170 SCOPED_TRACE("1x2"); | 167 SCOPED_TRACE("1x2"); |
| 171 BoundaryTestBody("400x400,0+450-700x400*2", "400x400,0+450-700x600*2"); | 168 BoundaryTestBody("400x400,0+450-700x400*2", "400x400,0+450-700x600*2"); |
| 172 } | 169 } |
| 173 { | 170 { |
| 174 SCOPED_TRACE("2x2"); | 171 SCOPED_TRACE("2x2"); |
| 175 BoundaryTestBody("400x400*2,0+450-700x400*2", "400x400*2,0+450-700x600*2"); | 172 BoundaryTestBody("400x400*2,0+450-700x400*2", "400x400*2,0+450-700x600*2"); |
| 176 } | 173 } |
| 177 } | 174 } |
| 178 | 175 |
| 179 // Verifies if the mouse pointer correctly moves to another display in | 176 // Verifies if the mouse pointer correctly moves to another display in |
| 180 // unified desktop mode. | 177 // unified desktop mode. |
| 181 TEST_F(UnifiedMouseWarpControllerTest, WarpMouse) { | 178 TEST_F(UnifiedMouseWarpControllerTest, WarpMouse) { |
| 182 if (!SupportsMultipleDisplays()) | |
| 183 return; | |
| 184 UpdateDisplay("500x500,600+0-500x500"); | 179 UpdateDisplay("500x500,600+0-500x500"); |
| 185 ASSERT_EQ(1, display::Screen::GetScreen()->GetNumDisplays()); | 180 ASSERT_EQ(1, display::Screen::GetScreen()->GetNumDisplays()); |
| 186 | 181 |
| 187 EXPECT_FALSE(TestIfMouseWarpsAt(gfx::Point(10, 10))); | 182 EXPECT_FALSE(TestIfMouseWarpsAt(gfx::Point(10, 10))); |
| 188 // Touch the right edge of the first display. Pointer should warp. | 183 // Touch the right edge of the first display. Pointer should warp. |
| 189 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(499, 10))); | 184 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(499, 10))); |
| 190 EXPECT_EQ("501,10", // by 2px. | 185 EXPECT_EQ("501,10", // by 2px. |
| 191 aura::Env::GetInstance()->last_mouse_location().ToString()); | 186 aura::Env::GetInstance()->last_mouse_location().ToString()); |
| 192 | 187 |
| 193 // Touch the left edge of the second display. Pointer should warp. | 188 // Touch the left edge of the second display. Pointer should warp. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(600, 10))); | 247 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(600, 10))); |
| 253 EXPECT_EQ("249,5", // moved to 498 by 2px, divided by 2 (dsf). | 248 EXPECT_EQ("249,5", // moved to 498 by 2px, divided by 2 (dsf). |
| 254 aura::Env::GetInstance()->last_mouse_location().ToString()); | 249 aura::Env::GetInstance()->last_mouse_location().ToString()); |
| 255 { | 250 { |
| 256 SCOPED_TRACE("1x2 NO WARP"); | 251 SCOPED_TRACE("1x2 NO WARP"); |
| 257 NoWarpTestBody(); | 252 NoWarpTestBody(); |
| 258 } | 253 } |
| 259 } | 254 } |
| 260 | 255 |
| 261 } // namespace aura | 256 } // namespace aura |
| OLD | NEW |