OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/window_tree_host_manager.h" | 5 #include "ash/display/window_tree_host_manager.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/display/display_info.h" | 8 #include "ash/display/display_info.h" |
9 #include "ash/display/display_layout_store.h" | 9 #include "ash/display/display_layout_store.h" |
10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 | 995 |
996 // Make sure the root window transformer uses correct scale | 996 // Make sure the root window transformer uses correct scale |
997 // factor when swapping display. Test crbug.com/253690. | 997 // factor when swapping display. Test crbug.com/253690. |
998 UpdateDisplay("400x300*2,600x400/o"); | 998 UpdateDisplay("400x300*2,600x400/o"); |
999 root_windows = Shell::GetAllRootWindows(); | 999 root_windows = Shell::GetAllRootWindows(); |
1000 gfx::Point point; | 1000 gfx::Point point; |
1001 Shell::GetAllRootWindows()[1]->GetHost()->GetRootTransform().TransformPoint( | 1001 Shell::GetAllRootWindows()[1]->GetHost()->GetRootTransform().TransformPoint( |
1002 &point); | 1002 &point); |
1003 EXPECT_EQ("15,10", point.ToString()); | 1003 EXPECT_EQ("15,10", point.ToString()); |
1004 | 1004 |
1005 window_tree_host_manager->SwapPrimaryDisplay(); | 1005 window_tree_host_manager->SwapPrimaryDisplayForTest(); |
1006 point.SetPoint(0, 0); | 1006 point.SetPoint(0, 0); |
1007 Shell::GetAllRootWindows()[1]->GetHost()->GetRootTransform().TransformPoint( | 1007 Shell::GetAllRootWindows()[1]->GetHost()->GetRootTransform().TransformPoint( |
1008 &point); | 1008 &point); |
1009 EXPECT_EQ("15,10", point.ToString()); | 1009 EXPECT_EQ("15,10", point.ToString()); |
1010 | 1010 |
1011 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 1011 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
1012 } | 1012 } |
1013 | 1013 |
1014 TEST_F(WindowTreeHostManagerTest, Rotate) { | 1014 TEST_F(WindowTreeHostManagerTest, Rotate) { |
1015 if (!SupportsMultipleDisplays()) | 1015 if (!SupportsMultipleDisplays()) |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 CreateDisplayInfo(10, 0, gfx::Display::ROTATE_0); | 1271 CreateDisplayInfo(10, 0, gfx::Display::ROTATE_0); |
1272 const DisplayInfo second_display_info = | 1272 const DisplayInfo second_display_info = |
1273 CreateDisplayInfo(11, 1, gfx::Display::ROTATE_0); | 1273 CreateDisplayInfo(11, 1, gfx::Display::ROTATE_0); |
1274 | 1274 |
1275 std::vector<DisplayInfo> display_info_list; | 1275 std::vector<DisplayInfo> display_info_list; |
1276 // Extended | 1276 // Extended |
1277 display_info_list.push_back(first_display_info); | 1277 display_info_list.push_back(first_display_info); |
1278 display_info_list.push_back(second_display_info); | 1278 display_info_list.push_back(second_display_info); |
1279 display_manager->OnNativeDisplaysChanged(display_info_list); | 1279 display_manager->OnNativeDisplaysChanged(display_info_list); |
1280 | 1280 |
1281 Shell::GetInstance()->window_tree_host_manager()->SwapPrimaryDisplay(); | 1281 Shell::GetInstance()->window_tree_host_manager()->SwapPrimaryDisplayForTest(); |
1282 | 1282 |
1283 EXPECT_EQ(11, Shell::GetScreen()->GetPrimaryDisplay().id()); | 1283 EXPECT_EQ(11, Shell::GetScreen()->GetPrimaryDisplay().id()); |
1284 | 1284 |
1285 display_info_list.clear(); | 1285 display_info_list.clear(); |
1286 const DisplayInfo new_first_display_info = | 1286 const DisplayInfo new_first_display_info = |
1287 CreateDisplayInfo(20, 0, gfx::Display::ROTATE_0); | 1287 CreateDisplayInfo(20, 0, gfx::Display::ROTATE_0); |
1288 const DisplayInfo new_second_display_info = | 1288 const DisplayInfo new_second_display_info = |
1289 CreateDisplayInfo(21, 1, gfx::Display::ROTATE_0); | 1289 CreateDisplayInfo(21, 1, gfx::Display::ROTATE_0); |
1290 display_info_list.push_back(new_first_display_info); | 1290 display_info_list.push_back(new_first_display_info); |
1291 display_info_list.push_back(new_second_display_info); | 1291 display_info_list.push_back(new_second_display_info); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1454 shell->window_tree_host_manager(); | 1454 shell->window_tree_host_manager(); |
1455 test::CursorManagerTestApi test_api(shell->cursor_manager()); | 1455 test::CursorManagerTestApi test_api(shell->cursor_manager()); |
1456 | 1456 |
1457 window_tree_host_manager->GetPrimaryRootWindow()->MoveCursorTo( | 1457 window_tree_host_manager->GetPrimaryRootWindow()->MoveCursorTo( |
1458 gfx::Point(20, 50)); | 1458 gfx::Point(20, 50)); |
1459 | 1459 |
1460 EXPECT_EQ("20,50", env->last_mouse_location().ToString()); | 1460 EXPECT_EQ("20,50", env->last_mouse_location().ToString()); |
1461 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); | 1461 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); |
1462 EXPECT_EQ(gfx::Display::ROTATE_0, test_api.GetCurrentCursorRotation()); | 1462 EXPECT_EQ(gfx::Display::ROTATE_0, test_api.GetCurrentCursorRotation()); |
1463 | 1463 |
1464 window_tree_host_manager->SwapPrimaryDisplay(); | 1464 window_tree_host_manager->SwapPrimaryDisplayForTest(); |
1465 | 1465 |
1466 EXPECT_EQ("20,50", env->last_mouse_location().ToString()); | 1466 EXPECT_EQ("20,50", env->last_mouse_location().ToString()); |
1467 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); | 1467 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); |
1468 EXPECT_EQ(gfx::Display::ROTATE_90, test_api.GetCurrentCursorRotation()); | 1468 EXPECT_EQ(gfx::Display::ROTATE_90, test_api.GetCurrentCursorRotation()); |
1469 } | 1469 } |
1470 | 1470 |
1471 // Test that the cursor moves to the other display and that its scale factor | 1471 // Test that the cursor moves to the other display and that its scale factor |
1472 // and rotation are updated when the primary display is disconnected. | 1472 // and rotation are updated when the primary display is disconnected. |
1473 TEST_F(WindowTreeHostManagerTest, | 1473 TEST_F(WindowTreeHostManagerTest, |
1474 UpdateMouseLocationAfterDisplayChange_PrimaryDisconnected) { | 1474 UpdateMouseLocationAfterDisplayChange_PrimaryDisconnected) { |
1475 if (!SupportsMultipleDisplays()) | 1475 if (!SupportsMultipleDisplays()) |
1476 return; | 1476 return; |
1477 | 1477 |
1478 aura::Env* env = aura::Env::GetInstance(); | 1478 aura::Env* env = aura::Env::GetInstance(); |
1479 Shell* shell = Shell::GetInstance(); | 1479 Shell* shell = Shell::GetInstance(); |
1480 WindowTreeHostManager* window_tree_host_manager = | 1480 WindowTreeHostManager* window_tree_host_manager = |
1481 shell->window_tree_host_manager(); | 1481 shell->window_tree_host_manager(); |
1482 test::CursorManagerTestApi test_api(shell->cursor_manager()); | 1482 test::CursorManagerTestApi test_api(shell->cursor_manager()); |
1483 | 1483 |
1484 UpdateDisplay("300x300*2/r,200x200"); | 1484 UpdateDisplay("300x300*2/r,200x200"); |
1485 // Swap the primary display to make it possible to remove the primary display | 1485 // Swap the primary display to make it possible to remove the primary display |
1486 // via UpdateDisplay(). | 1486 // via UpdateDisplay(). |
1487 window_tree_host_manager->SwapPrimaryDisplay(); | 1487 window_tree_host_manager->SwapPrimaryDisplayForTest(); |
1488 int primary_display_id = window_tree_host_manager->GetPrimaryDisplayId(); | 1488 int primary_display_id = window_tree_host_manager->GetPrimaryDisplayId(); |
1489 | 1489 |
1490 window_tree_host_manager->GetPrimaryRootWindow()->MoveCursorTo( | 1490 window_tree_host_manager->GetPrimaryRootWindow()->MoveCursorTo( |
1491 gfx::Point(20, 50)); | 1491 gfx::Point(20, 50)); |
1492 | 1492 |
1493 EXPECT_EQ("20,50", env->last_mouse_location().ToString()); | 1493 EXPECT_EQ("20,50", env->last_mouse_location().ToString()); |
1494 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); | 1494 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); |
1495 EXPECT_EQ(gfx::Display::ROTATE_0, test_api.GetCurrentCursorRotation()); | 1495 EXPECT_EQ(gfx::Display::ROTATE_0, test_api.GetCurrentCursorRotation()); |
1496 | 1496 |
1497 UpdateDisplay("300x300*2/r"); | 1497 UpdateDisplay("300x300*2/r"); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1532 widget->GetNativeWindow()->GetRootWindow()); | 1532 widget->GetNativeWindow()->GetRootWindow()); |
1533 event_generator.MoveMouseToCenterOf(widget->GetNativeWindow()); | 1533 event_generator.MoveMouseToCenterOf(widget->GetNativeWindow()); |
1534 | 1534 |
1535 UpdateDisplay("300x300"); | 1535 UpdateDisplay("300x300"); |
1536 watcher.Stop(); | 1536 watcher.Stop(); |
1537 | 1537 |
1538 widget->CloseNow(); | 1538 widget->CloseNow(); |
1539 } | 1539 } |
1540 | 1540 |
1541 } // namespace ash | 1541 } // namespace ash |
OLD | NEW |