| 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_manager.h" | 8 #include "ash/display/display_manager.h" |
| 9 #include "ash/display/window_tree_host_manager.h" | 9 #include "ash/display/window_tree_host_manager.h" |
| 10 #include "ash/screen_util.h" | 10 #include "ash/screen_util.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 "ash/test/cursor_manager_test_api.h" | 13 #include "ash/test/cursor_manager_test_api.h" |
| 14 #include "ash/test/display_manager_test_api.h" | 14 #include "ash/test/display_manager_test_api.h" |
| 15 #include "ash/test/mirror_window_test_api.h" | 15 #include "ash/test/mirror_window_test_api.h" |
| 16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 18 #include "ui/aura/env.h" | 18 #include "ui/aura/env.h" |
| 19 #include "ui/aura/test/test_window_delegate.h" | 19 #include "ui/aura/test/test_window_delegate.h" |
| 20 #include "ui/aura/test/test_windows.h" | 20 #include "ui/aura/test/test_windows.h" |
| 21 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
| 22 #include "ui/aura/window_event_dispatcher.h" | 22 #include "ui/aura/window_event_dispatcher.h" |
| 23 #include "ui/base/hit_test.h" | 23 #include "ui/base/hit_test.h" |
| 24 #include "ui/events/test/event_generator.h" | 24 #include "ui/events/test/event_generator.h" |
| 25 | 25 |
| 26 namespace ash { | 26 namespace ash { |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 DisplayInfo CreateDisplayInfo(int64 id, const gfx::Rect& bounds) { | 29 DisplayInfo CreateDisplayInfo(int64_t id, const gfx::Rect& bounds) { |
| 30 DisplayInfo info(id, base::StringPrintf("x-%d", static_cast<int>(id)), false); | 30 DisplayInfo info(id, base::StringPrintf("x-%d", static_cast<int>(id)), false); |
| 31 info.SetBounds(bounds); | 31 info.SetBounds(bounds); |
| 32 return info; | 32 return info; |
| 33 } | 33 } |
| 34 | 34 |
| 35 class MirrorOnBootTest : public test::AshTestBase { | 35 class MirrorOnBootTest : public test::AshTestBase { |
| 36 public: | 36 public: |
| 37 MirrorOnBootTest() {} | 37 MirrorOnBootTest() {} |
| 38 ~MirrorOnBootTest() override {} | 38 ~MirrorOnBootTest() override {} |
| 39 | 39 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 | 214 |
| 215 // Test the behavior of the cursor when entering software mirror mode swaps the | 215 // Test the behavior of the cursor when entering software mirror mode swaps the |
| 216 // cursor's display. | 216 // cursor's display. |
| 217 TEST_F(MirrorWindowControllerTest, MAYBE_MirrorCursorMoveOnEnter) { | 217 TEST_F(MirrorWindowControllerTest, MAYBE_MirrorCursorMoveOnEnter) { |
| 218 aura::Env* env = aura::Env::GetInstance(); | 218 aura::Env* env = aura::Env::GetInstance(); |
| 219 Shell* shell = Shell::GetInstance(); | 219 Shell* shell = Shell::GetInstance(); |
| 220 WindowTreeHostManager* window_tree_host_manager = | 220 WindowTreeHostManager* window_tree_host_manager = |
| 221 shell->window_tree_host_manager(); | 221 shell->window_tree_host_manager(); |
| 222 | 222 |
| 223 UpdateDisplay("400x400*2/r,400x400"); | 223 UpdateDisplay("400x400*2/r,400x400"); |
| 224 int64 primary_display_id = window_tree_host_manager->GetPrimaryDisplayId(); | 224 int64_t primary_display_id = window_tree_host_manager->GetPrimaryDisplayId(); |
| 225 int64 secondary_display_id = ScreenUtil::GetSecondaryDisplay().id(); | 225 int64_t secondary_display_id = ScreenUtil::GetSecondaryDisplay().id(); |
| 226 test::ScopedSetInternalDisplayId set_internal(primary_display_id); | 226 test::ScopedSetInternalDisplayId set_internal(primary_display_id); |
| 227 | 227 |
| 228 // Chrome uses the internal display as the source display for software mirror | 228 // Chrome uses the internal display as the source display for software mirror |
| 229 // mode. Move the cursor to the external display. | 229 // mode. Move the cursor to the external display. |
| 230 aura::Window* secondary_root_window = | 230 aura::Window* secondary_root_window = |
| 231 window_tree_host_manager->GetRootWindowForDisplayId(secondary_display_id); | 231 window_tree_host_manager->GetRootWindowForDisplayId(secondary_display_id); |
| 232 secondary_root_window->MoveCursorTo(gfx::Point(100, 200)); | 232 secondary_root_window->MoveCursorTo(gfx::Point(100, 200)); |
| 233 EXPECT_EQ("300,200", env->last_mouse_location().ToString()); | 233 EXPECT_EQ("300,200", env->last_mouse_location().ToString()); |
| 234 test::CursorManagerTestApi cursor_test_api(shell->cursor_manager()); | 234 test::CursorManagerTestApi cursor_test_api(shell->cursor_manager()); |
| 235 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); | 235 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 254 // New coordinates are not (200,200) because (200,200) is not the center of | 254 // New coordinates are not (200,200) because (200,200) is not the center of |
| 255 // the display. | 255 // the display. |
| 256 EXPECT_EQ("199,200", | 256 EXPECT_EQ("199,200", |
| 257 test_api.GetCursorHotPointLocationInRootWindow().ToString()); | 257 test_api.GetCursorHotPointLocationInRootWindow().ToString()); |
| 258 } | 258 } |
| 259 | 259 |
| 260 // Make sure that the compositor based mirroring can switch | 260 // Make sure that the compositor based mirroring can switch |
| 261 // from/to dock mode. | 261 // from/to dock mode. |
| 262 TEST_F(MirrorWindowControllerTest, MAYBE_DockMode) { | 262 TEST_F(MirrorWindowControllerTest, MAYBE_DockMode) { |
| 263 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 263 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 264 const int64 internal_id = 1; | 264 const int64_t internal_id = 1; |
| 265 const int64 external_id = 2; | 265 const int64_t external_id = 2; |
| 266 | 266 |
| 267 const DisplayInfo internal_display_info = | 267 const DisplayInfo internal_display_info = |
| 268 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500)); | 268 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500)); |
| 269 const DisplayInfo external_display_info = | 269 const DisplayInfo external_display_info = |
| 270 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); | 270 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); |
| 271 std::vector<DisplayInfo> display_info_list; | 271 std::vector<DisplayInfo> display_info_list; |
| 272 | 272 |
| 273 display_manager->SetMultiDisplayMode(DisplayManager::MIRRORING); | 273 display_manager->SetMultiDisplayMode(DisplayManager::MIRRORING); |
| 274 | 274 |
| 275 // software mirroring. | 275 // software mirroring. |
| 276 display_info_list.push_back(internal_display_info); | 276 display_info_list.push_back(internal_display_info); |
| 277 display_info_list.push_back(external_display_info); | 277 display_info_list.push_back(external_display_info); |
| 278 display_manager->OnNativeDisplaysChanged(display_info_list); | 278 display_manager->OnNativeDisplaysChanged(display_info_list); |
| 279 const int64 internal_display_id = | 279 const int64_t internal_display_id = |
| 280 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); | 280 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); |
| 281 EXPECT_EQ(internal_id, internal_display_id); | 281 EXPECT_EQ(internal_id, internal_display_id); |
| 282 | 282 |
| 283 EXPECT_EQ(1U, display_manager->GetNumDisplays()); | 283 EXPECT_EQ(1U, display_manager->GetNumDisplays()); |
| 284 EXPECT_TRUE(display_manager->IsInMirrorMode()); | 284 EXPECT_TRUE(display_manager->IsInMirrorMode()); |
| 285 EXPECT_EQ(external_id, display_manager->mirroring_display_id()); | 285 EXPECT_EQ(external_id, display_manager->mirroring_display_id()); |
| 286 | 286 |
| 287 // dock mode. | 287 // dock mode. |
| 288 display_info_list.clear(); | 288 display_info_list.clear(); |
| 289 display_info_list.push_back(external_display_info); | 289 display_info_list.push_back(external_display_info); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 305 | 305 |
| 306 TEST_F(MirrorOnBootTest, MAYBE_MirrorOnBoot) { | 306 TEST_F(MirrorOnBootTest, MAYBE_MirrorOnBoot) { |
| 307 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 307 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 308 EXPECT_TRUE(display_manager->IsInMirrorMode()); | 308 EXPECT_TRUE(display_manager->IsInMirrorMode()); |
| 309 RunAllPendingInMessageLoop(); | 309 RunAllPendingInMessageLoop(); |
| 310 test::MirrorWindowTestApi test_api; | 310 test::MirrorWindowTestApi test_api; |
| 311 EXPECT_TRUE(test_api.GetHost()); | 311 EXPECT_TRUE(test_api.GetHost()); |
| 312 } | 312 } |
| 313 | 313 |
| 314 } // namespace ash | 314 } // namespace ash |
| OLD | NEW |