OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/root_window_transformers.h" | 5 #include "ash/display/root_window_transformers.h" |
6 | 6 |
7 #include "ash/display/display_info.h" | 7 #include "ash/display/display_info.h" |
8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
9 #include "ash/magnifier/magnification_controller.h" | 9 #include "ash/magnifier/magnification_controller.h" |
10 #include "ash/screen_ash.h" | 10 #include "ash/screen_util.h" |
11 #include "ash/shelf/shelf.h" | 11 #include "ash/shelf/shelf.h" |
12 #include "ash/shelf/shelf_widget.h" | 12 #include "ash/shelf/shelf_widget.h" |
13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
14 #include "ash/test/ash_test_base.h" | 14 #include "ash/test/ash_test_base.h" |
15 #include "ash/test/cursor_manager_test_api.h" | 15 #include "ash/test/cursor_manager_test_api.h" |
16 #include "ash/test/mirror_window_test_api.h" | 16 #include "ash/test/mirror_window_test_api.h" |
17 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
18 #include "ui/aura/env.h" | 18 #include "ui/aura/env.h" |
19 #include "ui/aura/root_window.h" | 19 #include "ui/aura/root_window.h" |
20 #include "ui/aura/root_window_transformer.h" | 20 #include "ui/aura/root_window_transformer.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 TEST_F(RootWindowTransformersTest, MAYBE_RotateAndMagnify) { | 136 TEST_F(RootWindowTransformersTest, MAYBE_RotateAndMagnify) { |
137 MagnificationController* magnifier = | 137 MagnificationController* magnifier = |
138 Shell::GetInstance()->magnification_controller(); | 138 Shell::GetInstance()->magnification_controller(); |
139 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 139 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
140 | 140 |
141 TestEventHandler event_handler; | 141 TestEventHandler event_handler; |
142 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 142 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
143 | 143 |
144 UpdateDisplay("120x200,300x400*2"); | 144 UpdateDisplay("120x200,300x400*2"); |
145 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); | 145 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); |
146 int64 display2_id = ScreenAsh::GetSecondaryDisplay().id(); | 146 int64 display2_id = ScreenUtil::GetSecondaryDisplay().id(); |
147 | 147 |
148 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 148 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
149 aura::test::EventGenerator generator1(root_windows[0]); | 149 aura::test::EventGenerator generator1(root_windows[0]); |
150 aura::test::EventGenerator generator2(root_windows[1]); | 150 aura::test::EventGenerator generator2(root_windows[1]); |
151 | 151 |
152 magnifier->SetEnabled(true); | 152 magnifier->SetEnabled(true); |
153 EXPECT_EQ(2.0f, magnifier->GetScale()); | 153 EXPECT_EQ(2.0f, magnifier->GetScale()); |
154 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); | 154 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); |
155 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); | 155 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); |
156 EXPECT_EQ("120,0 150x200", | 156 EXPECT_EQ("120,0 150x200", |
157 ScreenAsh::GetSecondaryDisplay().bounds().ToString()); | 157 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
158 generator1.MoveMouseToInHost(40, 80); | 158 generator1.MoveMouseToInHost(40, 80); |
159 EXPECT_EQ("50,90", event_handler.GetLocationAndReset()); | 159 EXPECT_EQ("50,90", event_handler.GetLocationAndReset()); |
160 EXPECT_EQ("50,90", | 160 EXPECT_EQ("50,90", |
161 aura::Env::GetInstance()->last_mouse_location().ToString()); | 161 aura::Env::GetInstance()->last_mouse_location().ToString()); |
162 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display1.id())); | 162 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display1.id())); |
163 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); | 163 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); |
164 magnifier->SetEnabled(false); | 164 magnifier->SetEnabled(false); |
165 | 165 |
166 display_manager->SetDisplayRotation(display1.id(), | 166 display_manager->SetDisplayRotation(display1.id(), |
167 gfx::Display::ROTATE_90); | 167 gfx::Display::ROTATE_90); |
168 // Move the cursor to the center of the first root window. | 168 // Move the cursor to the center of the first root window. |
169 generator1.MoveMouseToInHost(59, 100); | 169 generator1.MoveMouseToInHost(59, 100); |
170 | 170 |
171 magnifier->SetEnabled(true); | 171 magnifier->SetEnabled(true); |
172 EXPECT_EQ(2.0f, magnifier->GetScale()); | 172 EXPECT_EQ(2.0f, magnifier->GetScale()); |
173 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); | 173 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); |
174 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); | 174 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); |
175 EXPECT_EQ("200,0 150x200", | 175 EXPECT_EQ("200,0 150x200", |
176 ScreenAsh::GetSecondaryDisplay().bounds().ToString()); | 176 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
177 generator1.MoveMouseToInHost(39, 120); | 177 generator1.MoveMouseToInHost(39, 120); |
178 EXPECT_EQ("110,70", event_handler.GetLocationAndReset()); | 178 EXPECT_EQ("110,70", event_handler.GetLocationAndReset()); |
179 EXPECT_EQ("110,70", | 179 EXPECT_EQ("110,70", |
180 aura::Env::GetInstance()->last_mouse_location().ToString()); | 180 aura::Env::GetInstance()->last_mouse_location().ToString()); |
181 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); | 181 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); |
182 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); | 182 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); |
183 magnifier->SetEnabled(false); | 183 magnifier->SetEnabled(false); |
184 | 184 |
185 DisplayLayout display_layout(DisplayLayout::BOTTOM, 50); | 185 DisplayLayout display_layout(DisplayLayout::BOTTOM, 50); |
186 display_manager->SetLayoutForCurrentDisplays(display_layout); | 186 display_manager->SetLayoutForCurrentDisplays(display_layout); |
187 EXPECT_EQ("50,120 150x200", | 187 EXPECT_EQ("50,120 150x200", |
188 ScreenAsh::GetSecondaryDisplay().bounds().ToString()); | 188 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
189 | 189 |
190 display_manager->SetDisplayRotation(display2_id, | 190 display_manager->SetDisplayRotation(display2_id, |
191 gfx::Display::ROTATE_270); | 191 gfx::Display::ROTATE_270); |
192 // Move the cursor to the center of the second root window. | 192 // Move the cursor to the center of the second root window. |
193 generator2.MoveMouseToInHost(151, 199); | 193 generator2.MoveMouseToInHost(151, 199); |
194 | 194 |
195 magnifier->SetEnabled(true); | 195 magnifier->SetEnabled(true); |
196 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); | 196 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); |
197 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); | 197 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); |
198 EXPECT_EQ("50,120 200x150", | 198 EXPECT_EQ("50,120 200x150", |
199 ScreenAsh::GetSecondaryDisplay().bounds().ToString()); | 199 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
200 generator2.MoveMouseToInHost(172, 219); | 200 generator2.MoveMouseToInHost(172, 219); |
201 EXPECT_EQ("95,80", event_handler.GetLocationAndReset()); | 201 EXPECT_EQ("95,80", event_handler.GetLocationAndReset()); |
202 EXPECT_EQ("145,200", | 202 EXPECT_EQ("145,200", |
203 aura::Env::GetInstance()->last_mouse_location().ToString()); | 203 aura::Env::GetInstance()->last_mouse_location().ToString()); |
204 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); | 204 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); |
205 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); | 205 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); |
206 magnifier->SetEnabled(false); | 206 magnifier->SetEnabled(false); |
207 | 207 |
208 display_manager->SetDisplayRotation(display1.id(), | 208 display_manager->SetDisplayRotation(display1.id(), |
209 gfx::Display::ROTATE_180); | 209 gfx::Display::ROTATE_180); |
210 // Move the cursor to the center of the first root window. | 210 // Move the cursor to the center of the first root window. |
211 generator1.MoveMouseToInHost(59, 99); | 211 generator1.MoveMouseToInHost(59, 99); |
212 | 212 |
213 magnifier->SetEnabled(true); | 213 magnifier->SetEnabled(true); |
214 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); | 214 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); |
215 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); | 215 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); |
216 // Dislay must share at least 100, so the x's offset becomes 20. | 216 // Dislay must share at least 100, so the x's offset becomes 20. |
217 EXPECT_EQ("20,200 200x150", | 217 EXPECT_EQ("20,200 200x150", |
218 ScreenAsh::GetSecondaryDisplay().bounds().ToString()); | 218 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
219 generator1.MoveMouseToInHost(39, 59); | 219 generator1.MoveMouseToInHost(39, 59); |
220 EXPECT_EQ("70,120", event_handler.GetLocationAndReset()); | 220 EXPECT_EQ("70,120", event_handler.GetLocationAndReset()); |
221 EXPECT_EQ(gfx::Display::ROTATE_180, GetStoredRotation(display1.id())); | 221 EXPECT_EQ(gfx::Display::ROTATE_180, GetStoredRotation(display1.id())); |
222 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); | 222 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); |
223 magnifier->SetEnabled(false); | 223 magnifier->SetEnabled(false); |
224 | 224 |
225 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 225 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
226 } | 226 } |
227 | 227 |
228 TEST_F(RootWindowTransformersTest, ScaleAndMagnify) { | 228 TEST_F(RootWindowTransformersTest, ScaleAndMagnify) { |
229 if (!SupportsMultipleDisplays()) | 229 if (!SupportsMultipleDisplays()) |
230 return; | 230 return; |
231 | 231 |
232 TestEventHandler event_handler; | 232 TestEventHandler event_handler; |
233 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 233 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
234 | 234 |
235 UpdateDisplay("600x400*2@1.5,500x300"); | 235 UpdateDisplay("600x400*2@1.5,500x300"); |
236 | 236 |
237 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); | 237 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); |
238 gfx::Display::SetInternalDisplayId(display1.id()); | 238 gfx::Display::SetInternalDisplayId(display1.id()); |
239 gfx::Display display2 = ScreenAsh::GetSecondaryDisplay(); | 239 gfx::Display display2 = ScreenUtil::GetSecondaryDisplay(); |
240 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 240 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
241 MagnificationController* magnifier = | 241 MagnificationController* magnifier = |
242 Shell::GetInstance()->magnification_controller(); | 242 Shell::GetInstance()->magnification_controller(); |
243 | 243 |
244 magnifier->SetEnabled(true); | 244 magnifier->SetEnabled(true); |
245 EXPECT_EQ(2.0f, magnifier->GetScale()); | 245 EXPECT_EQ(2.0f, magnifier->GetScale()); |
246 EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); | 246 EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); |
247 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); | 247 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); |
248 EXPECT_EQ("450,0 500x300", display2.bounds().ToString()); | 248 EXPECT_EQ("450,0 500x300", display2.bounds().ToString()); |
249 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); | 249 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); |
250 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); | 250 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); |
251 | 251 |
252 aura::test::EventGenerator generator(root_windows[0]); | 252 aura::test::EventGenerator generator(root_windows[0]); |
253 generator.MoveMouseToInHost(500, 200); | 253 generator.MoveMouseToInHost(500, 200); |
254 EXPECT_EQ("299,150", event_handler.GetLocationAndReset()); | 254 EXPECT_EQ("299,150", event_handler.GetLocationAndReset()); |
255 magnifier->SetEnabled(false); | 255 magnifier->SetEnabled(false); |
256 | 256 |
257 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 257 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
258 display_manager->SetDisplayUIScale(display1.id(), 1.25); | 258 display_manager->SetDisplayUIScale(display1.id(), 1.25); |
259 display1 = Shell::GetScreen()->GetPrimaryDisplay(); | 259 display1 = Shell::GetScreen()->GetPrimaryDisplay(); |
260 display2 = ScreenAsh::GetSecondaryDisplay(); | 260 display2 = ScreenUtil::GetSecondaryDisplay(); |
261 magnifier->SetEnabled(true); | 261 magnifier->SetEnabled(true); |
262 EXPECT_EQ(2.0f, magnifier->GetScale()); | 262 EXPECT_EQ(2.0f, magnifier->GetScale()); |
263 EXPECT_EQ("0,0 375x250", display1.bounds().ToString()); | 263 EXPECT_EQ("0,0 375x250", display1.bounds().ToString()); |
264 EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString()); | 264 EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString()); |
265 EXPECT_EQ("375,0 500x300", display2.bounds().ToString()); | 265 EXPECT_EQ("375,0 500x300", display2.bounds().ToString()); |
266 EXPECT_EQ(1.25f, GetStoredUIScale(display1.id())); | 266 EXPECT_EQ(1.25f, GetStoredUIScale(display1.id())); |
267 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); | 267 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); |
268 magnifier->SetEnabled(false); | 268 magnifier->SetEnabled(false); |
269 | 269 |
270 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 270 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString()); | 405 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString()); |
406 | 406 |
407 UpdateDisplay("200x400,500x500"); | 407 UpdateDisplay("200x400,500x500"); |
408 // The aspect ratio is flipped, so X margin is now 125. | 408 // The aspect ratio is flipped, so X margin is now 125. |
409 transformer = test_api.CreateCurrentRootWindowTransformer(); | 409 transformer = test_api.CreateCurrentRootWindowTransformer(); |
410 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString()); | 410 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString()); |
411 } | 411 } |
412 | 412 |
413 } // namespace test | 413 } // namespace test |
414 } // namespace ash | 414 } // namespace ash |
OLD | NEW |