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" |
11 #include "ash/screen_util.h" | 11 #include "ash/screen_util.h" |
12 #include "ash/shelf/shelf.h" | 12 #include "ash/shelf/shelf.h" |
13 #include "ash/shelf/shelf_widget.h" | 13 #include "ash/shelf/shelf_widget.h" |
14 #include "ash/shell.h" | 14 #include "ash/shell.h" |
15 #include "ash/test/ash_test_base.h" | 15 #include "ash/test/ash_test_base.h" |
16 #include "ash/test/ash_test_helper.h" | 16 #include "ash/test/ash_test_helper.h" |
17 #include "ash/test/cursor_manager_test_api.h" | 17 #include "ash/test/cursor_manager_test_api.h" |
18 #include "ash/test/display_manager_test_api.h" | 18 #include "ash/test/display_manager_test_api.h" |
19 #include "ash/test/test_shell_delegate.h" | 19 #include "ash/test/test_shell_delegate.h" |
20 #include "ash/wm/window_state.h" | 20 #include "ash/wm/window_state.h" |
21 #include "ash/wm/wm_event.h" | 21 #include "ash/wm/wm_event.h" |
22 #include "base/command_line.h" | 22 #include "base/command_line.h" |
23 #include "ui/aura/client/focus_change_observer.h" | 23 #include "ui/aura/client/focus_change_observer.h" |
24 #include "ui/aura/client/focus_client.h" | 24 #include "ui/aura/client/focus_client.h" |
25 #include "ui/aura/env.h" | 25 #include "ui/aura/env.h" |
26 #include "ui/aura/test/event_generator.h" | |
27 #include "ui/aura/window_tracker.h" | 26 #include "ui/aura/window_tracker.h" |
28 #include "ui/aura/window_tree_host.h" | 27 #include "ui/aura/window_tree_host.h" |
29 #include "ui/events/event_handler.h" | 28 #include "ui/events/event_handler.h" |
| 29 #include "ui/events/test/event_generator.h" |
30 #include "ui/gfx/display.h" | 30 #include "ui/gfx/display.h" |
31 #include "ui/gfx/screen.h" | 31 #include "ui/gfx/screen.h" |
32 #include "ui/views/widget/widget.h" | 32 #include "ui/views/widget/widget.h" |
33 #include "ui/wm/public/activation_change_observer.h" | 33 #include "ui/wm/public/activation_change_observer.h" |
34 #include "ui/wm/public/activation_client.h" | 34 #include "ui/wm/public/activation_client.h" |
35 | 35 |
36 #if defined(USE_X11) | 36 #if defined(USE_X11) |
37 #include <X11/Xlib.h> | 37 #include <X11/Xlib.h> |
38 #include "ui/gfx/x/x11_types.h" | 38 #include "ui/gfx/x/x11_types.h" |
39 #undef RootWindow | 39 #undef RootWindow |
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); | 1017 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); |
1018 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1018 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
1019 | 1019 |
1020 display_controller->SetOverscanInsets(display1.id(), | 1020 display_controller->SetOverscanInsets(display1.id(), |
1021 gfx::Insets(10, 15, 20, 25)); | 1021 gfx::Insets(10, 15, 20, 25)); |
1022 EXPECT_EQ("0,0 80x170", root_windows[0]->bounds().ToString()); | 1022 EXPECT_EQ("0,0 80x170", root_windows[0]->bounds().ToString()); |
1023 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); | 1023 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); |
1024 EXPECT_EQ("80,0 150x200", | 1024 EXPECT_EQ("80,0 150x200", |
1025 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 1025 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
1026 | 1026 |
1027 aura::test::EventGenerator generator(root_windows[0]); | 1027 ui::test::EventGenerator generator(root_windows[0]); |
1028 generator.MoveMouseToInHost(20, 25); | 1028 generator.MoveMouseToInHost(20, 25); |
1029 EXPECT_EQ("5,15", event_handler.GetLocationAndReset()); | 1029 EXPECT_EQ("5,15", event_handler.GetLocationAndReset()); |
1030 | 1030 |
1031 display_controller->SetOverscanInsets(display1.id(), gfx::Insets()); | 1031 display_controller->SetOverscanInsets(display1.id(), gfx::Insets()); |
1032 EXPECT_EQ("0,0 120x200", root_windows[0]->bounds().ToString()); | 1032 EXPECT_EQ("0,0 120x200", root_windows[0]->bounds().ToString()); |
1033 EXPECT_EQ("120,0 150x200", | 1033 EXPECT_EQ("120,0 150x200", |
1034 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 1034 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
1035 | 1035 |
1036 generator.MoveMouseToInHost(30, 20); | 1036 generator.MoveMouseToInHost(30, 20); |
1037 EXPECT_EQ("30,20", event_handler.GetLocationAndReset()); | 1037 EXPECT_EQ("30,20", event_handler.GetLocationAndReset()); |
(...skipping 21 matching lines...) Expand all Loading... |
1059 return; | 1059 return; |
1060 | 1060 |
1061 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 1061 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
1062 TestEventHandler event_handler; | 1062 TestEventHandler event_handler; |
1063 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 1063 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
1064 | 1064 |
1065 UpdateDisplay("120x200,300x400*2"); | 1065 UpdateDisplay("120x200,300x400*2"); |
1066 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); | 1066 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); |
1067 int64 display2_id = ScreenUtil::GetSecondaryDisplay().id(); | 1067 int64 display2_id = ScreenUtil::GetSecondaryDisplay().id(); |
1068 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1068 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
1069 aura::test::EventGenerator generator1(root_windows[0]); | 1069 ui::test::EventGenerator generator1(root_windows[0]); |
1070 | 1070 |
1071 TestObserver observer; | 1071 TestObserver observer; |
1072 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); | 1072 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); |
1073 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); | 1073 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); |
1074 EXPECT_EQ("120,0 150x200", | 1074 EXPECT_EQ("120,0 150x200", |
1075 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 1075 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
1076 generator1.MoveMouseToInHost(50, 40); | 1076 generator1.MoveMouseToInHost(50, 40); |
1077 EXPECT_EQ("50,40", event_handler.GetLocationAndReset()); | 1077 EXPECT_EQ("50,40", event_handler.GetLocationAndReset()); |
1078 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display1.id())); | 1078 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display1.id())); |
1079 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); | 1079 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); |
(...skipping 20 matching lines...) Expand all Loading... |
1100 gfx::Display::ROTATE_270); | 1100 gfx::Display::ROTATE_270); |
1101 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); | 1101 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); |
1102 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); | 1102 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); |
1103 EXPECT_EQ("50,120 200x150", | 1103 EXPECT_EQ("50,120 200x150", |
1104 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 1104 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
1105 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); | 1105 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); |
1106 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); | 1106 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); |
1107 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); | 1107 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); |
1108 | 1108 |
1109 #if !defined(OS_WIN) | 1109 #if !defined(OS_WIN) |
1110 aura::test::EventGenerator generator2(root_windows[1]); | 1110 ui::test::EventGenerator generator2(root_windows[1]); |
1111 generator2.MoveMouseToInHost(50, 40); | 1111 generator2.MoveMouseToInHost(50, 40); |
1112 EXPECT_EQ("179,25", event_handler.GetLocationAndReset()); | 1112 EXPECT_EQ("179,25", event_handler.GetLocationAndReset()); |
1113 display_manager->SetDisplayRotation(display1.id(), | 1113 display_manager->SetDisplayRotation(display1.id(), |
1114 gfx::Display::ROTATE_180); | 1114 gfx::Display::ROTATE_180); |
1115 | 1115 |
1116 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); | 1116 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); |
1117 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); | 1117 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); |
1118 // Dislay must share at least 100, so the x's offset becomes 20. | 1118 // Dislay must share at least 100, so the x's offset becomes 20. |
1119 EXPECT_EQ("20,200 200x150", | 1119 EXPECT_EQ("20,200 200x150", |
1120 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 1120 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
(...skipping 21 matching lines...) Expand all Loading... |
1142 gfx::Display::SetInternalDisplayId(display1.id()); | 1142 gfx::Display::SetInternalDisplayId(display1.id()); |
1143 | 1143 |
1144 gfx::Display display2 = ScreenUtil::GetSecondaryDisplay(); | 1144 gfx::Display display2 = ScreenUtil::GetSecondaryDisplay(); |
1145 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1145 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
1146 EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); | 1146 EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); |
1147 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); | 1147 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); |
1148 EXPECT_EQ("450,0 500x300", display2.bounds().ToString()); | 1148 EXPECT_EQ("450,0 500x300", display2.bounds().ToString()); |
1149 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); | 1149 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); |
1150 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); | 1150 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); |
1151 | 1151 |
1152 aura::test::EventGenerator generator(root_windows[0]); | 1152 ui::test::EventGenerator generator(root_windows[0]); |
1153 generator.MoveMouseToInHost(599, 200); | 1153 generator.MoveMouseToInHost(599, 200); |
1154 EXPECT_EQ("449,150", event_handler.GetLocationAndReset()); | 1154 EXPECT_EQ("449,150", event_handler.GetLocationAndReset()); |
1155 | 1155 |
1156 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 1156 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
1157 display_manager->SetDisplayUIScale(display1.id(), 1.25f); | 1157 display_manager->SetDisplayUIScale(display1.id(), 1.25f); |
1158 display1 = Shell::GetScreen()->GetPrimaryDisplay(); | 1158 display1 = Shell::GetScreen()->GetPrimaryDisplay(); |
1159 display2 = ScreenUtil::GetSecondaryDisplay(); | 1159 display2 = ScreenUtil::GetSecondaryDisplay(); |
1160 EXPECT_EQ("0,0 375x250", display1.bounds().ToString()); | 1160 EXPECT_EQ("0,0 375x250", display1.bounds().ToString()); |
1161 EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString()); | 1161 EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString()); |
1162 EXPECT_EQ("375,0 500x300", display2.bounds().ToString()); | 1162 EXPECT_EQ("375,0 500x300", display2.bounds().ToString()); |
1163 EXPECT_EQ(1.25f, GetStoredUIScale(display1.id())); | 1163 EXPECT_EQ(1.25f, GetStoredUIScale(display1.id())); |
1164 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); | 1164 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); |
1165 | 1165 |
1166 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 1166 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
1167 } | 1167 } |
1168 | 1168 |
1169 TEST_F(DisplayControllerTest, TouchScale) { | 1169 TEST_F(DisplayControllerTest, TouchScale) { |
1170 if (!SupportsMultipleDisplays()) | 1170 if (!SupportsMultipleDisplays()) |
1171 return; | 1171 return; |
1172 | 1172 |
1173 TestEventHandler event_handler; | 1173 TestEventHandler event_handler; |
1174 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 1174 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
1175 | 1175 |
1176 UpdateDisplay("200x200*2"); | 1176 UpdateDisplay("200x200*2"); |
1177 gfx::Display display = Shell::GetScreen()->GetPrimaryDisplay(); | 1177 gfx::Display display = Shell::GetScreen()->GetPrimaryDisplay(); |
1178 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1178 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
1179 aura::Window* root_window = root_windows[0]; | 1179 aura::Window* root_window = root_windows[0]; |
1180 aura::test::EventGenerator generator(root_window); | 1180 ui::test::EventGenerator generator(root_window); |
1181 | 1181 |
1182 generator.PressMoveAndReleaseTouchTo(50, 50); | 1182 generator.PressMoveAndReleaseTouchTo(50, 50); |
1183 // Default test touches have radius_x/y = 1.0, with device scale | 1183 // Default test touches have radius_x/y = 1.0, with device scale |
1184 // factor = 2, the scaled radius_x/y should be 0.5. | 1184 // factor = 2, the scaled radius_x/y should be 0.5. |
1185 EXPECT_EQ(0.5, event_handler.touch_radius_x()); | 1185 EXPECT_EQ(0.5, event_handler.touch_radius_x()); |
1186 EXPECT_EQ(0.5, event_handler.touch_radius_y()); | 1186 EXPECT_EQ(0.5, event_handler.touch_radius_y()); |
1187 | 1187 |
1188 generator.ScrollSequence(gfx::Point(0,0), | 1188 generator.ScrollSequence(gfx::Point(0,0), |
1189 base::TimeDelta::FromMilliseconds(100), | 1189 base::TimeDelta::FromMilliseconds(100), |
1190 10.0, 1.0, 5, 1); | 1190 10.0, 1.0, 5, 1); |
(...skipping 15 matching lines...) Expand all Loading... |
1206 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 1206 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
1207 | 1207 |
1208 UpdateDisplay("600x400*2/r@1.5"); | 1208 UpdateDisplay("600x400*2/r@1.5"); |
1209 | 1209 |
1210 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); | 1210 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); |
1211 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1211 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
1212 EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); | 1212 EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); |
1213 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); | 1213 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); |
1214 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); | 1214 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); |
1215 | 1215 |
1216 aura::test::EventGenerator generator(root_windows[0]); | 1216 ui::test::EventGenerator generator(root_windows[0]); |
1217 generator.MoveMouseToInHost(0, 0); | 1217 generator.MoveMouseToInHost(0, 0); |
1218 EXPECT_EQ("0,449", event_handler.GetLocationAndReset()); | 1218 EXPECT_EQ("0,449", event_handler.GetLocationAndReset()); |
1219 generator.MoveMouseToInHost(599, 0); | 1219 generator.MoveMouseToInHost(599, 0); |
1220 EXPECT_EQ("0,0", event_handler.GetLocationAndReset()); | 1220 EXPECT_EQ("0,0", event_handler.GetLocationAndReset()); |
1221 generator.MoveMouseToInHost(599, 399); | 1221 generator.MoveMouseToInHost(599, 399); |
1222 EXPECT_EQ("299,0", event_handler.GetLocationAndReset()); | 1222 EXPECT_EQ("299,0", event_handler.GetLocationAndReset()); |
1223 generator.MoveMouseToInHost(0, 399); | 1223 generator.MoveMouseToInHost(0, 399); |
1224 EXPECT_EQ("299,449", event_handler.GetLocationAndReset()); | 1224 EXPECT_EQ("299,449", event_handler.GetLocationAndReset()); |
1225 | 1225 |
1226 UpdateDisplay("600x400*2/u@1.5"); | 1226 UpdateDisplay("600x400*2/u@1.5"); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1334 EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetHost())); | 1334 EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetHost())); |
1335 | 1335 |
1336 // Switching back to single display. | 1336 // Switching back to single display. |
1337 UpdateDisplay("300x400"); | 1337 UpdateDisplay("300x400"); |
1338 EXPECT_EQ("aura_root_0", GetXWindowName( | 1338 EXPECT_EQ("aura_root_0", GetXWindowName( |
1339 Shell::GetPrimaryRootWindow()->GetHost())); | 1339 Shell::GetPrimaryRootWindow()->GetHost())); |
1340 } | 1340 } |
1341 #endif | 1341 #endif |
1342 | 1342 |
1343 } // namespace ash | 1343 } // namespace ash |
OLD | NEW |