| 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" |
| 11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 12 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
| 13 #include "ui/aura/env.h" | 13 #include "ui/aura/env.h" |
| 14 #include "ui/aura/window_tree_host.h" | 14 #include "ui/aura/window_tree_host.h" |
| 15 #include "ui/display/display.h" | 15 #include "ui/display/display.h" |
| 16 #include "ui/display/display_finder.h" |
| 16 #include "ui/display/manager/display_manager.h" | 17 #include "ui/display/manager/display_manager.h" |
| 17 #include "ui/display/manager/display_manager_utilities.h" | |
| 18 #include "ui/display/screen.h" | 18 #include "ui/display/screen.h" |
| 19 #include "ui/events/test/event_generator.h" | 19 #include "ui/events/test/event_generator.h" |
| 20 #include "ui/wm/core/coordinate_conversion.h" | 20 #include "ui/wm/core/coordinate_conversion.h" |
| 21 | 21 |
| 22 namespace ash { | 22 namespace ash { |
| 23 | 23 |
| 24 class UnifiedMouseWarpControllerTest : public test::AshTestBase { | 24 class UnifiedMouseWarpControllerTest : public test::AshTestBase { |
| 25 public: | 25 public: |
| 26 UnifiedMouseWarpControllerTest() {} | 26 UnifiedMouseWarpControllerTest() {} |
| 27 ~UnifiedMouseWarpControllerTest() override {} | 27 ~UnifiedMouseWarpControllerTest() override {} |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 #else | 81 #else |
| 82 GetEventGenerator().MoveMouseToWithNative(point_in_unified_host, | 82 GetEventGenerator().MoveMouseToWithNative(point_in_unified_host, |
| 83 point_in_native); | 83 point_in_native); |
| 84 #endif | 84 #endif |
| 85 aura::Window* root = Shell::GetPrimaryRootWindow(); | 85 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 86 gfx::Point new_location_in_unified_host = | 86 gfx::Point new_location_in_unified_host = |
| 87 aura::Env::GetInstance()->last_mouse_location(); | 87 aura::Env::GetInstance()->last_mouse_location(); |
| 88 // Convert screen to the host. | 88 // Convert screen to the host. |
| 89 root->GetHost()->ConvertDIPToPixels(&new_location_in_unified_host); | 89 root->GetHost()->ConvertDIPToPixels(&new_location_in_unified_host); |
| 90 | 90 |
| 91 int new_index = display::FindDisplayIndexContainingPoint( | 91 auto iter = display::FindDisplayContainingPoint( |
| 92 display_manager()->software_mirroring_display_list(), | 92 display_manager()->software_mirroring_display_list(), |
| 93 new_location_in_unified_host); | 93 new_location_in_unified_host); |
| 94 if (new_index < 0) | 94 if (iter == display_manager()->software_mirroring_display_list().end()) |
| 95 return false; | 95 return false; |
| 96 return orig_mirroring_display_id != | 96 return orig_mirroring_display_id != iter->id(); |
| 97 display_manager()->software_mirroring_display_list()[new_index].id(); | |
| 98 } | 97 } |
| 99 | 98 |
| 100 MouseCursorEventFilter* event_filter() { | 99 MouseCursorEventFilter* event_filter() { |
| 101 return Shell::GetInstance()->mouse_cursor_filter(); | 100 return Shell::GetInstance()->mouse_cursor_filter(); |
| 102 } | 101 } |
| 103 | 102 |
| 104 UnifiedMouseWarpController* mouse_warp_controller() { | 103 UnifiedMouseWarpController* mouse_warp_controller() { |
| 105 return static_cast<UnifiedMouseWarpController*>( | 104 return static_cast<UnifiedMouseWarpController*>( |
| 106 event_filter()->mouse_warp_controller_for_test()); | 105 event_filter()->mouse_warp_controller_for_test()); |
| 107 } | 106 } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(600, 10))); | 246 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(600, 10))); |
| 248 EXPECT_EQ("249,5", // moved to 498 by 2px, divided by 2 (dsf). | 247 EXPECT_EQ("249,5", // moved to 498 by 2px, divided by 2 (dsf). |
| 249 aura::Env::GetInstance()->last_mouse_location().ToString()); | 248 aura::Env::GetInstance()->last_mouse_location().ToString()); |
| 250 { | 249 { |
| 251 SCOPED_TRACE("1x2 NO WARP"); | 250 SCOPED_TRACE("1x2 NO WARP"); |
| 252 NoWarpTestBody(); | 251 NoWarpTestBody(); |
| 253 } | 252 } |
| 254 } | 253 } |
| 255 | 254 |
| 256 } // namespace aura | 255 } // namespace aura |
| OLD | NEW |