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/cursor_window_controller.h" | 5 #include "ash/display/cursor_window_controller.h" |
6 | 6 |
7 #include "ash/display/display_util.h" | 7 #include "ash/display/display_util.h" |
8 #include "ash/display/window_tree_host_manager.h" | 8 #include "ash/display/window_tree_host_manager.h" |
9 #include "ash/screen_util.h" | |
10 #include "ash/shell.h" | 9 #include "ash/shell.h" |
11 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
12 #include "ash/test/display_manager_test_api.h" | 11 #include "ash/test/display_manager_test_api.h" |
13 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
14 #include "ui/aura/window_tree_host.h" | 13 #include "ui/aura/window_tree_host.h" |
15 #include "ui/base/cursor/cursor.h" | 14 #include "ui/base/cursor/cursor.h" |
16 #include "ui/display/display.h" | 15 #include "ui/display/display.h" |
17 #include "ui/display/screen.h" | 16 #include "ui/display/screen.h" |
18 #include "ui/events/test/event_generator.h" | 17 #include "ui/events/test/event_generator.h" |
19 #include "ui/wm/core/coordinate_conversion.h" | 18 #include "ui/wm/core/coordinate_conversion.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 // moves to another display. | 66 // moves to another display. |
68 TEST_F(CursorWindowControllerTest, MoveToDifferentDisplay) { | 67 TEST_F(CursorWindowControllerTest, MoveToDifferentDisplay) { |
69 if (!SupportsMultipleDisplays()) | 68 if (!SupportsMultipleDisplays()) |
70 return; | 69 return; |
71 | 70 |
72 UpdateDisplay("200x200,200x200*2/r"); | 71 UpdateDisplay("200x200,200x200*2/r"); |
73 | 72 |
74 WindowTreeHostManager* window_tree_host_manager = | 73 WindowTreeHostManager* window_tree_host_manager = |
75 Shell::GetInstance()->window_tree_host_manager(); | 74 Shell::GetInstance()->window_tree_host_manager(); |
76 int64_t primary_display_id = window_tree_host_manager->GetPrimaryDisplayId(); | 75 int64_t primary_display_id = window_tree_host_manager->GetPrimaryDisplayId(); |
77 int64_t secondary_display_id = ScreenUtil::GetSecondaryDisplay().id(); | 76 int64_t secondary_display_id = display_manager()->GetSecondaryDisplay().id(); |
78 aura::Window* primary_root = | 77 aura::Window* primary_root = |
79 window_tree_host_manager->GetRootWindowForDisplayId(primary_display_id); | 78 window_tree_host_manager->GetRootWindowForDisplayId(primary_display_id); |
80 aura::Window* secondary_root = | 79 aura::Window* secondary_root = |
81 window_tree_host_manager->GetRootWindowForDisplayId(secondary_display_id); | 80 window_tree_host_manager->GetRootWindowForDisplayId(secondary_display_id); |
82 | 81 |
83 ui::test::EventGenerator primary_generator(primary_root); | 82 ui::test::EventGenerator primary_generator(primary_root); |
84 primary_generator.MoveMouseToInHost(20, 50); | 83 primary_generator.MoveMouseToInHost(20, 50); |
85 | 84 |
86 EXPECT_TRUE(primary_root->Contains(GetCursorWindow())); | 85 EXPECT_TRUE(primary_root->Contains(GetCursorWindow())); |
87 EXPECT_EQ(primary_display_id, GetCursorDisplayId()); | 86 EXPECT_EQ(primary_display_id, GetCursorDisplayId()); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 ASSERT_TRUE(GetCursorWindow()); | 149 ASSERT_TRUE(GetCursorWindow()); |
151 EXPECT_TRUE(GetCursorWindow()->IsVisible()); | 150 EXPECT_TRUE(GetCursorWindow()->IsVisible()); |
152 } | 151 } |
153 | 152 |
154 // Make sure that composition cursor stays big even when | 153 // Make sure that composition cursor stays big even when |
155 // the DSF becomes 1x as a result of zooming out. | 154 // the DSF becomes 1x as a result of zooming out. |
156 TEST_F(CursorWindowControllerTest, DSF) { | 155 TEST_F(CursorWindowControllerTest, DSF) { |
157 UpdateDisplay("1000x500*2"); | 156 UpdateDisplay("1000x500*2"); |
158 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 157 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
159 | 158 |
160 test::ScopedSetInternalDisplayId set_internal(primary_id); | 159 test::ScopedSetInternalDisplayId set_internal(display_manager(), primary_id); |
161 SetCursorCompositionEnabled(true); | 160 SetCursorCompositionEnabled(true); |
162 ASSERT_EQ( | 161 ASSERT_EQ( |
163 2.0f, | 162 2.0f, |
164 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 163 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
165 EXPECT_TRUE(GetCursorImage().HasRepresentation(2.0f)); | 164 EXPECT_TRUE(GetCursorImage().HasRepresentation(2.0f)); |
166 | 165 |
167 ASSERT_TRUE(Shell::GetInstance()->display_manager()->SetDisplayUIScale( | 166 ASSERT_TRUE(display_manager()->SetDisplayUIScale(primary_id, 2.0f)); |
168 primary_id, 2.0f)); | |
169 ASSERT_EQ( | 167 ASSERT_EQ( |
170 1.0f, | 168 1.0f, |
171 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 169 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
172 EXPECT_TRUE(GetCursorImage().HasRepresentation(2.0f)); | 170 EXPECT_TRUE(GetCursorImage().HasRepresentation(2.0f)); |
173 } | 171 } |
174 #endif | 172 #endif |
175 | 173 |
176 } // namespace ash | 174 } // namespace ash |
OLD | NEW |