OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/mirror_window_controller.h" | 5 #include "ash/display/mirror_window_controller.h" |
6 | 6 |
7 #include "ash/display/window_tree_host_manager.h" | 7 #include "ash/display/window_tree_host_manager.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
10 #include "ash/test/cursor_manager_test_api.h" | 10 #include "ash/test/cursor_manager_test_api.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 } | 47 } |
48 void TearDown() override { test::AshTestBase::TearDown(); } | 48 void TearDown() override { test::AshTestBase::TearDown(); } |
49 | 49 |
50 private: | 50 private: |
51 DISALLOW_COPY_AND_ASSIGN(MirrorOnBootTest); | 51 DISALLOW_COPY_AND_ASSIGN(MirrorOnBootTest); |
52 }; | 52 }; |
53 } | 53 } |
54 | 54 |
55 typedef test::AshTestBase MirrorWindowControllerTest; | 55 typedef test::AshTestBase MirrorWindowControllerTest; |
56 | 56 |
57 #if defined(OS_WIN) | 57 TEST_F(MirrorWindowControllerTest, MirrorCursorBasic) { |
58 // Software mirroring does not work on win. | |
59 #define MAYBE_MirrorCursorBasic DISABLED_MirrorCursorBasic | |
60 #define MAYBE_MirrorCursorLocations DISABLED_MirrorCursorLocations | |
61 #define MAYBE_MirrorCursorMoveOnEnter DISABLED_MirrorCursorMoveOnEnter | |
62 #define MAYBE_MirrorCursorRotate DISABLED_MirrorCursorRotate | |
63 #define MAYBE_DockMode DISABLED_DockMode | |
64 #define MAYBE_MirrorOnBoot DISABLED_MirrorOnBoot | |
65 #else | |
66 #define MAYBE_MirrorCursorBasic MirrorCursorBasic | |
67 #define MAYBE_MirrorCursorLocations MirrorCursorLocations | |
68 #define MAYBE_MirrorCursorMoveOnEnter MirrorCursorMoveOnEnter | |
69 #define MAYBE_MirrorCursorRotate MirrorCursorRotate | |
70 #define MAYBE_DockMode DockMode | |
71 #define MAYBE_MirrorOnBoot MirrorOnBoot | |
72 #endif | |
73 | |
74 TEST_F(MirrorWindowControllerTest, MAYBE_MirrorCursorBasic) { | |
75 test::MirrorWindowTestApi test_api; | 58 test::MirrorWindowTestApi test_api; |
76 aura::test::TestWindowDelegate test_window_delegate; | 59 aura::test::TestWindowDelegate test_window_delegate; |
77 test_window_delegate.set_window_component(HTTOP); | 60 test_window_delegate.set_window_component(HTTOP); |
78 | 61 |
79 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING); | 62 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING); |
80 UpdateDisplay("400x400,400x400"); | 63 UpdateDisplay("400x400,400x400"); |
81 aura::Window* root = Shell::Get()->GetPrimaryRootWindow(); | 64 aura::Window* root = Shell::Get()->GetPrimaryRootWindow(); |
82 std::unique_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate( | 65 std::unique_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate( |
83 &test_window_delegate, 0, gfx::Rect(50, 50, 100, 100), root)); | 66 &test_window_delegate, 0, gfx::Rect(50, 50, 100, 100), root)); |
84 window->Show(); | 67 window->Show(); |
(...skipping 25 matching lines...) Expand all Loading... |
110 EXPECT_FALSE(test_api.GetCursorWindow()->IsVisible()); | 93 EXPECT_FALSE(test_api.GetCursorWindow()->IsVisible()); |
111 | 94 |
112 // Mouse event makes it visible again. | 95 // Mouse event makes it visible again. |
113 generator.MoveMouseTo(300, 300); | 96 generator.MoveMouseTo(300, 300); |
114 EXPECT_EQ("300,300", | 97 EXPECT_EQ("300,300", |
115 test_api.GetCursorHotPointLocationInRootWindow().ToString()); | 98 test_api.GetCursorHotPointLocationInRootWindow().ToString()); |
116 EXPECT_EQ(ui::kCursorNull, test_api.GetCurrentCursorType()); | 99 EXPECT_EQ(ui::kCursorNull, test_api.GetCurrentCursorType()); |
117 EXPECT_TRUE(test_api.GetCursorWindow()->IsVisible()); | 100 EXPECT_TRUE(test_api.GetCursorWindow()->IsVisible()); |
118 } | 101 } |
119 | 102 |
120 TEST_F(MirrorWindowControllerTest, MAYBE_MirrorCursorRotate) { | 103 TEST_F(MirrorWindowControllerTest, MirrorCursorRotate) { |
121 test::MirrorWindowTestApi test_api; | 104 test::MirrorWindowTestApi test_api; |
122 aura::test::TestWindowDelegate test_window_delegate; | 105 aura::test::TestWindowDelegate test_window_delegate; |
123 test_window_delegate.set_window_component(HTTOP); | 106 test_window_delegate.set_window_component(HTTOP); |
124 | 107 |
125 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING); | 108 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING); |
126 UpdateDisplay("400x400,400x400"); | 109 UpdateDisplay("400x400,400x400"); |
127 aura::Window* root = Shell::Get()->GetPrimaryRootWindow(); | 110 aura::Window* root = Shell::Get()->GetPrimaryRootWindow(); |
128 std::unique_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate( | 111 std::unique_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate( |
129 &test_window_delegate, 0, gfx::Rect(50, 50, 100, 100), root)); | 112 &test_window_delegate, 0, gfx::Rect(50, 50, 100, 100), root)); |
130 window->Show(); | 113 window->Show(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 EXPECT_EQ(ui::kCursorNorthResize, test_api.GetCurrentCursorType()); | 147 EXPECT_EQ(ui::kCursorNorthResize, test_api.GetCurrentCursorType()); |
165 // Rotated hot point must be (12, 25-11). | 148 // Rotated hot point must be (12, 25-11). |
166 EXPECT_EQ("12,14", test_api.GetCursorHotPoint().ToString()); | 149 EXPECT_EQ("12,14", test_api.GetCursorHotPoint().ToString()); |
167 EXPECT_EQ("100,300", | 150 EXPECT_EQ("100,300", |
168 test_api.GetCursorHotPointLocationInRootWindow().ToString()); | 151 test_api.GetCursorHotPointLocationInRootWindow().ToString()); |
169 } | 152 } |
170 | 153 |
171 // Make sure that the mirror cursor's location is same as | 154 // Make sure that the mirror cursor's location is same as |
172 // the source display's host location in the mirror root window's | 155 // the source display's host location in the mirror root window's |
173 // coordinates. | 156 // coordinates. |
174 TEST_F(MirrorWindowControllerTest, MAYBE_MirrorCursorLocations) { | 157 TEST_F(MirrorWindowControllerTest, MirrorCursorLocations) { |
175 test::MirrorWindowTestApi test_api; | 158 test::MirrorWindowTestApi test_api; |
176 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING); | 159 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING); |
177 | 160 |
178 // Test with device scale factor. | 161 // Test with device scale factor. |
179 UpdateDisplay("400x600*2,400x600"); | 162 UpdateDisplay("400x600*2,400x600"); |
180 | 163 |
181 aura::Window* root = Shell::Get()->GetPrimaryRootWindow(); | 164 aura::Window* root = Shell::Get()->GetPrimaryRootWindow(); |
182 ui::test::EventGenerator generator(root); | 165 ui::test::EventGenerator generator(root); |
183 generator.MoveMouseToInHost(10, 20); | 166 generator.MoveMouseToInHost(10, 20); |
184 | 167 |
(...skipping 13 matching lines...) Expand all Loading... |
198 UpdateDisplay("400x600/r,400x600"); | 181 UpdateDisplay("400x600/r,400x600"); |
199 generator.MoveMouseToInHost(30, 40); | 182 generator.MoveMouseToInHost(30, 40); |
200 | 183 |
201 EXPECT_EQ("21,4", test_api.GetCursorHotPoint().ToString()); | 184 EXPECT_EQ("21,4", test_api.GetCursorHotPoint().ToString()); |
202 EXPECT_EQ("30,40", | 185 EXPECT_EQ("30,40", |
203 test_api.GetCursorHotPointLocationInRootWindow().ToString()); | 186 test_api.GetCursorHotPointLocationInRootWindow().ToString()); |
204 } | 187 } |
205 | 188 |
206 // Test the behavior of the cursor when entering software mirror mode swaps the | 189 // Test the behavior of the cursor when entering software mirror mode swaps the |
207 // cursor's display. | 190 // cursor's display. |
208 TEST_F(MirrorWindowControllerTest, MAYBE_MirrorCursorMoveOnEnter) { | 191 TEST_F(MirrorWindowControllerTest, MirrorCursorMoveOnEnter) { |
209 aura::Env* env = aura::Env::GetInstance(); | 192 aura::Env* env = aura::Env::GetInstance(); |
210 Shell* shell = Shell::Get(); | 193 Shell* shell = Shell::Get(); |
211 WindowTreeHostManager* window_tree_host_manager = | 194 WindowTreeHostManager* window_tree_host_manager = |
212 shell->window_tree_host_manager(); | 195 shell->window_tree_host_manager(); |
213 | 196 |
214 UpdateDisplay("400x400*2/r,400x400"); | 197 UpdateDisplay("400x400*2/r,400x400"); |
215 int64_t primary_display_id = window_tree_host_manager->GetPrimaryDisplayId(); | 198 int64_t primary_display_id = window_tree_host_manager->GetPrimaryDisplayId(); |
216 int64_t secondary_display_id = display_manager()->GetSecondaryDisplay().id(); | 199 int64_t secondary_display_id = display_manager()->GetSecondaryDisplay().id(); |
217 display::test::ScopedSetInternalDisplayId set_internal(display_manager(), | 200 display::test::ScopedSetInternalDisplayId set_internal(display_manager(), |
218 primary_display_id); | 201 primary_display_id); |
(...skipping 27 matching lines...) Expand all Loading... |
246 // Rotated hot point must be (25-7, 7). | 229 // Rotated hot point must be (25-7, 7). |
247 EXPECT_EQ("18,7", test_api.GetCursorHotPoint().ToString()); | 230 EXPECT_EQ("18,7", test_api.GetCursorHotPoint().ToString()); |
248 // New coordinates are not (200,200) because (200,200) is not the center of | 231 // New coordinates are not (200,200) because (200,200) is not the center of |
249 // the display. | 232 // the display. |
250 EXPECT_EQ("199,200", | 233 EXPECT_EQ("199,200", |
251 test_api.GetCursorHotPointLocationInRootWindow().ToString()); | 234 test_api.GetCursorHotPointLocationInRootWindow().ToString()); |
252 } | 235 } |
253 | 236 |
254 // Make sure that the compositor based mirroring can switch | 237 // Make sure that the compositor based mirroring can switch |
255 // from/to dock mode. | 238 // from/to dock mode. |
256 TEST_F(MirrorWindowControllerTest, MAYBE_DockMode) { | 239 TEST_F(MirrorWindowControllerTest, DockMode) { |
257 const int64_t internal_id = 1; | 240 const int64_t internal_id = 1; |
258 const int64_t external_id = 2; | 241 const int64_t external_id = 2; |
259 | 242 |
260 const display::ManagedDisplayInfo internal_display_info = | 243 const display::ManagedDisplayInfo internal_display_info = |
261 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500)); | 244 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500)); |
262 const display::ManagedDisplayInfo external_display_info = | 245 const display::ManagedDisplayInfo external_display_info = |
263 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); | 246 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); |
264 std::vector<display::ManagedDisplayInfo> display_info_list; | 247 std::vector<display::ManagedDisplayInfo> display_info_list; |
265 | 248 |
266 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING); | 249 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING); |
(...skipping 23 matching lines...) Expand all Loading... |
290 display_info_list.clear(); | 273 display_info_list.clear(); |
291 display_info_list.push_back(internal_display_info); | 274 display_info_list.push_back(internal_display_info); |
292 display_info_list.push_back(external_display_info); | 275 display_info_list.push_back(external_display_info); |
293 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING); | 276 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING); |
294 display_manager()->OnNativeDisplaysChanged(display_info_list); | 277 display_manager()->OnNativeDisplaysChanged(display_info_list); |
295 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 278 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
296 EXPECT_TRUE(display_manager()->IsInMirrorMode()); | 279 EXPECT_TRUE(display_manager()->IsInMirrorMode()); |
297 EXPECT_EQ(external_id, display_manager()->mirroring_display_id()); | 280 EXPECT_EQ(external_id, display_manager()->mirroring_display_id()); |
298 } | 281 } |
299 | 282 |
300 TEST_F(MirrorOnBootTest, MAYBE_MirrorOnBoot) { | 283 TEST_F(MirrorOnBootTest, MirrorOnBoot) { |
301 EXPECT_TRUE(display_manager()->IsInMirrorMode()); | 284 EXPECT_TRUE(display_manager()->IsInMirrorMode()); |
302 RunAllPendingInMessageLoop(); | 285 RunAllPendingInMessageLoop(); |
303 test::MirrorWindowTestApi test_api; | 286 test::MirrorWindowTestApi test_api; |
304 EXPECT_TRUE(test_api.GetHost()); | 287 EXPECT_TRUE(test_api.GetHost()); |
305 } | 288 } |
306 | 289 |
307 } // namespace ash | 290 } // namespace ash |
OLD | NEW |