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/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/display/display_controller.h" | 8 #include "ash/display/display_controller.h" |
9 #include "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
10 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 #define MAYBE_DockMode DockMode | 70 #define MAYBE_DockMode DockMode |
71 #define MAYBE_MirrorOnBoot MirrorOnBoot | 71 #define MAYBE_MirrorOnBoot MirrorOnBoot |
72 #endif | 72 #endif |
73 | 73 |
74 TEST_F(MirrorWindowControllerTest, MAYBE_MirrorCursorBasic) { | 74 TEST_F(MirrorWindowControllerTest, MAYBE_MirrorCursorBasic) { |
75 test::MirrorWindowTestApi test_api; | 75 test::MirrorWindowTestApi test_api; |
76 aura::test::TestWindowDelegate test_window_delegate; | 76 aura::test::TestWindowDelegate test_window_delegate; |
77 test_window_delegate.set_window_component(HTTOP); | 77 test_window_delegate.set_window_component(HTTOP); |
78 | 78 |
79 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 79 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
80 display_manager->SetSecondDisplayMode(DisplayManager::MIRRORING); | 80 display_manager->SetMultiDisplayMode(DisplayManager::MIRRORING); |
81 UpdateDisplay("400x400,400x400"); | 81 UpdateDisplay("400x400,400x400"); |
82 aura::Window* root = Shell::GetInstance()->GetPrimaryRootWindow(); | 82 aura::Window* root = Shell::GetInstance()->GetPrimaryRootWindow(); |
83 scoped_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate( | 83 scoped_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate( |
84 &test_window_delegate, | 84 &test_window_delegate, |
85 0, | 85 0, |
86 gfx::Rect(50, 50, 100, 100), | 86 gfx::Rect(50, 50, 100, 100), |
87 root)); | 87 root)); |
88 window->Show(); | 88 window->Show(); |
89 window->SetName("foo"); | 89 window->SetName("foo"); |
90 | 90 |
(...skipping 29 matching lines...) Expand all Loading... |
120 EXPECT_EQ(ui::kCursorNull, test_api.GetCurrentCursorType()); | 120 EXPECT_EQ(ui::kCursorNull, test_api.GetCurrentCursorType()); |
121 EXPECT_TRUE(test_api.GetCursorWindow()->IsVisible()); | 121 EXPECT_TRUE(test_api.GetCursorWindow()->IsVisible()); |
122 } | 122 } |
123 | 123 |
124 TEST_F(MirrorWindowControllerTest, MAYBE_MirrorCursorRotate) { | 124 TEST_F(MirrorWindowControllerTest, MAYBE_MirrorCursorRotate) { |
125 test::MirrorWindowTestApi test_api; | 125 test::MirrorWindowTestApi test_api; |
126 aura::test::TestWindowDelegate test_window_delegate; | 126 aura::test::TestWindowDelegate test_window_delegate; |
127 test_window_delegate.set_window_component(HTTOP); | 127 test_window_delegate.set_window_component(HTTOP); |
128 | 128 |
129 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 129 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
130 display_manager->SetSecondDisplayMode(DisplayManager::MIRRORING); | 130 display_manager->SetMultiDisplayMode(DisplayManager::MIRRORING); |
131 UpdateDisplay("400x400,400x400"); | 131 UpdateDisplay("400x400,400x400"); |
132 aura::Window* root = Shell::GetInstance()->GetPrimaryRootWindow(); | 132 aura::Window* root = Shell::GetInstance()->GetPrimaryRootWindow(); |
133 scoped_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate( | 133 scoped_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate( |
134 &test_window_delegate, | 134 &test_window_delegate, |
135 0, | 135 0, |
136 gfx::Rect(50, 50, 100, 100), | 136 gfx::Rect(50, 50, 100, 100), |
137 root)); | 137 root)); |
138 window->Show(); | 138 window->Show(); |
139 window->SetName("foo"); | 139 window->SetName("foo"); |
140 | 140 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 EXPECT_EQ("100,300", | 175 EXPECT_EQ("100,300", |
176 test_api.GetCursorHotPointLocationInRootWindow().ToString()); | 176 test_api.GetCursorHotPointLocationInRootWindow().ToString()); |
177 } | 177 } |
178 | 178 |
179 // Make sure that the mirror cursor's location is same as | 179 // Make sure that the mirror cursor's location is same as |
180 // the source display's host location in the mirror root window's | 180 // the source display's host location in the mirror root window's |
181 // coordinates. | 181 // coordinates. |
182 TEST_F(MirrorWindowControllerTest, MAYBE_MirrorCursorLocations) { | 182 TEST_F(MirrorWindowControllerTest, MAYBE_MirrorCursorLocations) { |
183 test::MirrorWindowTestApi test_api; | 183 test::MirrorWindowTestApi test_api; |
184 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 184 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
185 display_manager->SetSecondDisplayMode(DisplayManager::MIRRORING); | 185 display_manager->SetMultiDisplayMode(DisplayManager::MIRRORING); |
186 | 186 |
187 // Test with device scale factor. | 187 // Test with device scale factor. |
188 UpdateDisplay("400x600*2,400x600"); | 188 UpdateDisplay("400x600*2,400x600"); |
189 | 189 |
190 aura::Window* root = Shell::GetInstance()->GetPrimaryRootWindow(); | 190 aura::Window* root = Shell::GetInstance()->GetPrimaryRootWindow(); |
191 ui::test::EventGenerator generator(root); | 191 ui::test::EventGenerator generator(root); |
192 generator.MoveMouseToInHost(10, 20); | 192 generator.MoveMouseToInHost(10, 20); |
193 | 193 |
194 EXPECT_EQ("8,9", test_api.GetCursorHotPoint().ToString()); | 194 EXPECT_EQ("8,9", test_api.GetCursorHotPoint().ToString()); |
195 EXPECT_EQ("10,20", | 195 EXPECT_EQ("10,20", |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 // Chrome uses the internal display as the source display for software mirror | 229 // Chrome uses the internal display as the source display for software mirror |
230 // mode. Move the cursor to the external display. | 230 // mode. Move the cursor to the external display. |
231 aura::Window* secondary_root_window = | 231 aura::Window* secondary_root_window = |
232 display_controller->GetRootWindowForDisplayId(secondary_display_id); | 232 display_controller->GetRootWindowForDisplayId(secondary_display_id); |
233 secondary_root_window->MoveCursorTo(gfx::Point(100, 200)); | 233 secondary_root_window->MoveCursorTo(gfx::Point(100, 200)); |
234 EXPECT_EQ("300,200", env->last_mouse_location().ToString()); | 234 EXPECT_EQ("300,200", env->last_mouse_location().ToString()); |
235 test::CursorManagerTestApi cursor_test_api(shell->cursor_manager()); | 235 test::CursorManagerTestApi cursor_test_api(shell->cursor_manager()); |
236 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); | 236 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); |
237 EXPECT_EQ(gfx::Display::ROTATE_0, cursor_test_api.GetCurrentCursorRotation()); | 237 EXPECT_EQ(gfx::Display::ROTATE_0, cursor_test_api.GetCurrentCursorRotation()); |
238 | 238 |
239 display_manager->SetSecondDisplayMode(DisplayManager::MIRRORING); | 239 display_manager->SetMultiDisplayMode(DisplayManager::MIRRORING); |
240 UpdateDisplay("400x400*2/r,400x400"); | 240 UpdateDisplay("400x400*2/r,400x400"); |
241 | 241 |
242 // Entering mirror mode should have centered the cursor on the primary display | 242 // Entering mirror mode should have centered the cursor on the primary display |
243 // because the cursor's previous position is out of bounds. | 243 // because the cursor's previous position is out of bounds. |
244 // Check real cursor's position and properties. | 244 // Check real cursor's position and properties. |
245 EXPECT_EQ("100,100", env->last_mouse_location().ToString()); | 245 EXPECT_EQ("100,100", env->last_mouse_location().ToString()); |
246 EXPECT_EQ(2.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); | 246 EXPECT_EQ(2.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); |
247 EXPECT_EQ(gfx::Display::ROTATE_90, | 247 EXPECT_EQ(gfx::Display::ROTATE_90, |
248 cursor_test_api.GetCurrentCursorRotation()); | 248 cursor_test_api.GetCurrentCursorRotation()); |
249 | 249 |
(...skipping 14 matching lines...) Expand all Loading... |
264 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 264 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
265 const int64 internal_id = 1; | 265 const int64 internal_id = 1; |
266 const int64 external_id = 2; | 266 const int64 external_id = 2; |
267 | 267 |
268 const DisplayInfo internal_display_info = | 268 const DisplayInfo internal_display_info = |
269 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500)); | 269 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500)); |
270 const DisplayInfo external_display_info = | 270 const DisplayInfo external_display_info = |
271 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); | 271 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); |
272 std::vector<DisplayInfo> display_info_list; | 272 std::vector<DisplayInfo> display_info_list; |
273 | 273 |
274 display_manager->SetSecondDisplayMode(DisplayManager::MIRRORING); | 274 display_manager->SetMultiDisplayMode(DisplayManager::MIRRORING); |
275 | 275 |
276 // software mirroring. | 276 // software mirroring. |
277 display_info_list.push_back(internal_display_info); | 277 display_info_list.push_back(internal_display_info); |
278 display_info_list.push_back(external_display_info); | 278 display_info_list.push_back(external_display_info); |
279 display_manager->OnNativeDisplaysChanged(display_info_list); | 279 display_manager->OnNativeDisplaysChanged(display_info_list); |
280 const int64 internal_display_id = | 280 const int64 internal_display_id = |
281 test::DisplayManagerTestApi(display_manager). | 281 test::DisplayManagerTestApi(display_manager). |
282 SetFirstDisplayAsInternalDisplay(); | 282 SetFirstDisplayAsInternalDisplay(); |
283 EXPECT_EQ(internal_id, internal_display_id); | 283 EXPECT_EQ(internal_id, internal_display_id); |
284 | 284 |
285 EXPECT_EQ(1U, display_manager->GetNumDisplays()); | 285 EXPECT_EQ(1U, display_manager->GetNumDisplays()); |
286 EXPECT_TRUE(display_manager->IsInMirrorMode()); | 286 EXPECT_TRUE(display_manager->IsInMirrorMode()); |
287 EXPECT_EQ(external_id, display_manager->mirroring_display_id()); | 287 EXPECT_EQ(external_id, display_manager->mirroring_display_id()); |
288 | 288 |
289 // dock mode. | 289 // dock mode. |
290 display_info_list.clear(); | 290 display_info_list.clear(); |
291 display_info_list.push_back(external_display_info); | 291 display_info_list.push_back(external_display_info); |
292 display_manager->SetSecondDisplayMode(DisplayManager::MIRRORING); | 292 display_manager->SetMultiDisplayMode(DisplayManager::MIRRORING); |
293 display_manager->OnNativeDisplaysChanged(display_info_list); | 293 display_manager->OnNativeDisplaysChanged(display_info_list); |
294 EXPECT_EQ(1U, display_manager->GetNumDisplays()); | 294 EXPECT_EQ(1U, display_manager->GetNumDisplays()); |
295 EXPECT_FALSE(display_manager->IsInMirrorMode()); | 295 EXPECT_FALSE(display_manager->IsInMirrorMode()); |
296 | 296 |
297 // back to software mirroring. | 297 // back to software mirroring. |
298 display_info_list.clear(); | 298 display_info_list.clear(); |
299 display_info_list.push_back(internal_display_info); | 299 display_info_list.push_back(internal_display_info); |
300 display_info_list.push_back(external_display_info); | 300 display_info_list.push_back(external_display_info); |
301 display_manager->SetSecondDisplayMode(DisplayManager::MIRRORING); | 301 display_manager->SetMultiDisplayMode(DisplayManager::MIRRORING); |
302 display_manager->OnNativeDisplaysChanged(display_info_list); | 302 display_manager->OnNativeDisplaysChanged(display_info_list); |
303 EXPECT_EQ(1U, display_manager->GetNumDisplays()); | 303 EXPECT_EQ(1U, display_manager->GetNumDisplays()); |
304 EXPECT_TRUE(display_manager->IsInMirrorMode()); | 304 EXPECT_TRUE(display_manager->IsInMirrorMode()); |
305 EXPECT_EQ(external_id, display_manager->mirroring_display_id()); | 305 EXPECT_EQ(external_id, display_manager->mirroring_display_id()); |
306 } | 306 } |
307 | 307 |
308 TEST_F(MirrorOnBootTest, MAYBE_MirrorOnBoot) { | 308 TEST_F(MirrorOnBootTest, MAYBE_MirrorOnBoot) { |
309 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 309 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
310 EXPECT_TRUE(display_manager->IsInMirrorMode()); | 310 EXPECT_TRUE(display_manager->IsInMirrorMode()); |
311 RunAllPendingInMessageLoop(); | 311 RunAllPendingInMessageLoop(); |
312 test::MirrorWindowTestApi test_api; | 312 test::MirrorWindowTestApi test_api; |
313 EXPECT_TRUE(test_api.GetHost()); | 313 EXPECT_TRUE(test_api.GetHost()); |
314 } | 314 } |
315 | 315 |
316 } // namespace ash | 316 } // namespace ash |
OLD | NEW |