| 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/display_controller.h" | 5 #include "ash/display/display_controller.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 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); | 957 gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); |
| 958 | 958 |
| 959 aura::Window* primary_root = | 959 aura::Window* primary_root = |
| 960 display_controller->GetRootWindowForDisplayId(primary_display.id()); | 960 display_controller->GetRootWindowForDisplayId(primary_display.id()); |
| 961 aura::Window* secondary_root = | 961 aura::Window* secondary_root = |
| 962 display_controller->GetRootWindowForDisplayId(secondary_display.id()); | 962 display_controller->GetRootWindowForDisplayId(secondary_display.id()); |
| 963 EXPECT_NE(primary_root, secondary_root); | 963 EXPECT_NE(primary_root, secondary_root); |
| 964 | 964 |
| 965 test::CursorManagerTestApi test_api(Shell::GetInstance()->cursor_manager()); | 965 test::CursorManagerTestApi test_api(Shell::GetInstance()->cursor_manager()); |
| 966 | 966 |
| 967 EXPECT_EQ(1.0f, primary_root->GetDispatcher()->host()->compositor()-> | 967 EXPECT_EQ(1.0f, primary_root->GetHost()->compositor()-> |
| 968 device_scale_factor()); | 968 device_scale_factor()); |
| 969 primary_root->MoveCursorTo(gfx::Point(50, 50)); | 969 primary_root->MoveCursorTo(gfx::Point(50, 50)); |
| 970 EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor()); | 970 EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor()); |
| 971 EXPECT_EQ(2.0f, secondary_root->GetDispatcher()->host()->compositor()-> | 971 EXPECT_EQ(2.0f, secondary_root->GetHost()->compositor()-> |
| 972 device_scale_factor()); | 972 device_scale_factor()); |
| 973 secondary_root->MoveCursorTo(gfx::Point(50, 50)); | 973 secondary_root->MoveCursorTo(gfx::Point(50, 50)); |
| 974 EXPECT_EQ(2.0f, test_api.GetDisplay().device_scale_factor()); | 974 EXPECT_EQ(2.0f, test_api.GetDisplay().device_scale_factor()); |
| 975 | 975 |
| 976 // Switch primary and secondary | 976 // Switch primary and secondary |
| 977 display_controller->SetPrimaryDisplay(secondary_display); | 977 display_controller->SetPrimaryDisplay(secondary_display); |
| 978 | 978 |
| 979 // Cursor's device scale factor should be updated accroding to the swap of | 979 // Cursor's device scale factor should be updated accroding to the swap of |
| 980 // primary and secondary. | 980 // primary and secondary. |
| 981 EXPECT_EQ(1.0f, secondary_root->GetDispatcher()->host()->compositor()-> | 981 EXPECT_EQ(1.0f, secondary_root->GetHost()->compositor()-> |
| 982 device_scale_factor()); | 982 device_scale_factor()); |
| 983 secondary_root->MoveCursorTo(gfx::Point(50, 50)); | 983 secondary_root->MoveCursorTo(gfx::Point(50, 50)); |
| 984 EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor()); | 984 EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor()); |
| 985 primary_root->MoveCursorTo(gfx::Point(50, 50)); | 985 primary_root->MoveCursorTo(gfx::Point(50, 50)); |
| 986 EXPECT_EQ(2.0f, primary_root->GetDispatcher()->host()->compositor()-> | 986 EXPECT_EQ(2.0f, primary_root->GetHost()->compositor()-> |
| 987 device_scale_factor()); | 987 device_scale_factor()); |
| 988 EXPECT_EQ(2.0f, test_api.GetDisplay().device_scale_factor()); | 988 EXPECT_EQ(2.0f, test_api.GetDisplay().device_scale_factor()); |
| 989 | 989 |
| 990 // Deleting 2nd display. | 990 // Deleting 2nd display. |
| 991 UpdateDisplay("200x200"); | 991 UpdateDisplay("200x200"); |
| 992 RunAllPendingInMessageLoop(); // RootWindow is deleted in a posted task. | 992 RunAllPendingInMessageLoop(); // RootWindow is deleted in a posted task. |
| 993 | 993 |
| 994 // Cursor's device scale factor should be updated even without moving cursor. | 994 // Cursor's device scale factor should be updated even without moving cursor. |
| 995 EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor()); | 995 EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor()); |
| 996 | 996 |
| 997 primary_root->MoveCursorTo(gfx::Point(50, 50)); | 997 primary_root->MoveCursorTo(gfx::Point(50, 50)); |
| 998 EXPECT_EQ(1.0f, primary_root->GetDispatcher()->host()->compositor()-> | 998 EXPECT_EQ(1.0f, primary_root->GetHost()->compositor()-> |
| 999 device_scale_factor()); | 999 device_scale_factor()); |
| 1000 EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor()); | 1000 EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor()); |
| 1001 } | 1001 } |
| 1002 | 1002 |
| 1003 TEST_F(DisplayControllerTest, OverscanInsets) { | 1003 TEST_F(DisplayControllerTest, OverscanInsets) { |
| 1004 if (!SupportsMultipleDisplays()) | 1004 if (!SupportsMultipleDisplays()) |
| 1005 return; | 1005 return; |
| 1006 | 1006 |
| 1007 DisplayController* display_controller = | 1007 DisplayController* display_controller = |
| 1008 Shell::GetInstance()->display_controller(); | 1008 Shell::GetInstance()->display_controller(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1030 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 1030 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
| 1031 | 1031 |
| 1032 generator.MoveMouseToInHost(30, 20); | 1032 generator.MoveMouseToInHost(30, 20); |
| 1033 EXPECT_EQ("30,20", event_handler.GetLocationAndReset()); | 1033 EXPECT_EQ("30,20", event_handler.GetLocationAndReset()); |
| 1034 | 1034 |
| 1035 // Make sure the root window transformer uses correct scale | 1035 // Make sure the root window transformer uses correct scale |
| 1036 // factor when swapping display. Test crbug.com/253690. | 1036 // factor when swapping display. Test crbug.com/253690. |
| 1037 UpdateDisplay("400x300*2,600x400/o"); | 1037 UpdateDisplay("400x300*2,600x400/o"); |
| 1038 root_windows = Shell::GetAllRootWindows(); | 1038 root_windows = Shell::GetAllRootWindows(); |
| 1039 gfx::Point point; | 1039 gfx::Point point; |
| 1040 Shell::GetAllRootWindows()[1]->GetDispatcher()->host()-> | 1040 Shell::GetAllRootWindows()[1]->GetHost()-> |
| 1041 GetRootTransform().TransformPoint(&point); | 1041 GetRootTransform().TransformPoint(&point); |
| 1042 EXPECT_EQ("15,10", point.ToString()); | 1042 EXPECT_EQ("15,10", point.ToString()); |
| 1043 | 1043 |
| 1044 display_controller->SwapPrimaryDisplay(); | 1044 display_controller->SwapPrimaryDisplay(); |
| 1045 point.SetPoint(0, 0); | 1045 point.SetPoint(0, 0); |
| 1046 Shell::GetAllRootWindows()[1]->GetDispatcher()->host()-> | 1046 Shell::GetAllRootWindows()[1]->GetHost()-> |
| 1047 GetRootTransform().TransformPoint(&point); | 1047 GetRootTransform().TransformPoint(&point); |
| 1048 EXPECT_EQ("15,10", point.ToString()); | 1048 EXPECT_EQ("15,10", point.ToString()); |
| 1049 | 1049 |
| 1050 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 1050 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
| 1051 } | 1051 } |
| 1052 | 1052 |
| 1053 TEST_F(DisplayControllerTest, Rotate) { | 1053 TEST_F(DisplayControllerTest, Rotate) { |
| 1054 if (!SupportsMultipleDisplays()) | 1054 if (!SupportsMultipleDisplays()) |
| 1055 return; | 1055 return; |
| 1056 | 1056 |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1289 test::DisplayManagerTestApi(display_manager). | 1289 test::DisplayManagerTestApi(display_manager). |
| 1290 SetFirstDisplayAsInternalDisplay(); | 1290 SetFirstDisplayAsInternalDisplay(); |
| 1291 EXPECT_EQ(internal_id, internal_display_id); | 1291 EXPECT_EQ(internal_id, internal_display_id); |
| 1292 EXPECT_EQ(2U, display_manager->GetNumDisplays()); | 1292 EXPECT_EQ(2U, display_manager->GetNumDisplays()); |
| 1293 | 1293 |
| 1294 // Dock mode. | 1294 // Dock mode. |
| 1295 display_info_list.clear(); | 1295 display_info_list.clear(); |
| 1296 display_info_list.push_back(external_display_info); | 1296 display_info_list.push_back(external_display_info); |
| 1297 display_manager->OnNativeDisplaysChanged(display_info_list); | 1297 display_manager->OnNativeDisplaysChanged(display_info_list); |
| 1298 EXPECT_EQ(1U, display_manager->GetNumDisplays()); | 1298 EXPECT_EQ(1U, display_manager->GetNumDisplays()); |
| 1299 EXPECT_FALSE(Shell::GetPrimaryRootWindow()->GetDispatcher()->host()-> | 1299 EXPECT_FALSE(Shell::GetPrimaryRootWindow()->GetHost()-> |
| 1300 GetRootTransform().IsIdentityOrIntegerTranslation()); | 1300 GetRootTransform().IsIdentityOrIntegerTranslation()); |
| 1301 | 1301 |
| 1302 // Switch to single mode and make sure the transform is the one | 1302 // Switch to single mode and make sure the transform is the one |
| 1303 // for the internal display. | 1303 // for the internal display. |
| 1304 display_info_list.clear(); | 1304 display_info_list.clear(); |
| 1305 display_info_list.push_back(internal_display_info); | 1305 display_info_list.push_back(internal_display_info); |
| 1306 display_manager->OnNativeDisplaysChanged(display_info_list); | 1306 display_manager->OnNativeDisplaysChanged(display_info_list); |
| 1307 EXPECT_TRUE(Shell::GetPrimaryRootWindow()->GetDispatcher()->host()-> | 1307 EXPECT_TRUE(Shell::GetPrimaryRootWindow()->GetHost()-> |
| 1308 GetRootTransform().IsIdentityOrIntegerTranslation()); | 1308 GetRootTransform().IsIdentityOrIntegerTranslation()); |
| 1309 } | 1309 } |
| 1310 | 1310 |
| 1311 #if defined(USE_X11) | 1311 #if defined(USE_X11) |
| 1312 TEST_F(DisplayControllerTest, XWidowNameForRootWindow) { | 1312 TEST_F(DisplayControllerTest, XWidowNameForRootWindow) { |
| 1313 EXPECT_EQ("aura_root_0", GetXWindowName( | 1313 EXPECT_EQ("aura_root_0", GetXWindowName( |
| 1314 Shell::GetPrimaryRootWindow()->GetDispatcher()->host())); | 1314 Shell::GetPrimaryRootWindow()->GetHost())); |
| 1315 | 1315 |
| 1316 // Multiple display. | 1316 // Multiple display. |
| 1317 UpdateDisplay("200x200,300x300"); | 1317 UpdateDisplay("200x200,300x300"); |
| 1318 aura::Window* primary, *secondary; | 1318 aura::Window* primary, *secondary; |
| 1319 GetPrimaryAndSeconary(&primary, &secondary); | 1319 GetPrimaryAndSeconary(&primary, &secondary); |
| 1320 EXPECT_EQ("aura_root_0", GetXWindowName(primary->GetDispatcher()->host())); | 1320 EXPECT_EQ("aura_root_0", GetXWindowName(primary->GetHost())); |
| 1321 EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetDispatcher()->host())); | 1321 EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetHost())); |
| 1322 | 1322 |
| 1323 // Swap primary. | 1323 // Swap primary. |
| 1324 primary = secondary = NULL; | 1324 primary = secondary = NULL; |
| 1325 Shell::GetInstance()->display_controller()->SwapPrimaryDisplay(); | 1325 Shell::GetInstance()->display_controller()->SwapPrimaryDisplay(); |
| 1326 GetPrimaryAndSeconary(&primary, &secondary); | 1326 GetPrimaryAndSeconary(&primary, &secondary); |
| 1327 EXPECT_EQ("aura_root_0", GetXWindowName(primary->GetDispatcher()->host())); | 1327 EXPECT_EQ("aura_root_0", GetXWindowName(primary->GetHost())); |
| 1328 EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetDispatcher()->host())); | 1328 EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetHost())); |
| 1329 | 1329 |
| 1330 // Switching back to single display. | 1330 // Switching back to single display. |
| 1331 UpdateDisplay("300x400"); | 1331 UpdateDisplay("300x400"); |
| 1332 EXPECT_EQ("aura_root_0", GetXWindowName( | 1332 EXPECT_EQ("aura_root_0", GetXWindowName( |
| 1333 Shell::GetPrimaryRootWindow()->GetDispatcher()->host())); | 1333 Shell::GetPrimaryRootWindow()->GetHost())); |
| 1334 } | 1334 } |
| 1335 #endif | 1335 #endif |
| 1336 | 1336 |
| 1337 } // namespace ash | 1337 } // namespace ash |
| OLD | NEW |