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/display/display_util.h" | 9 #include "ash/display/display_util.h" |
10 #include "ash/host/root_window_transformer.h" | 10 #include "ash/host/root_window_transformer.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 GetEffectiveUIScale(); | 113 GetEffectiveUIScale(); |
114 } | 114 } |
115 | 115 |
116 scoped_ptr<RootWindowTransformer> | 116 scoped_ptr<RootWindowTransformer> |
117 CreateCurrentRootWindowTransformerForMirroring() { | 117 CreateCurrentRootWindowTransformerForMirroring() { |
118 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 118 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
119 DCHECK(display_manager->IsInMirrorMode()); | 119 DCHECK(display_manager->IsInMirrorMode()); |
120 const DisplayInfo& mirror_display_info = | 120 const DisplayInfo& mirror_display_info = |
121 display_manager->GetDisplayInfo(display_manager->mirroring_display_id()); | 121 display_manager->GetDisplayInfo(display_manager->mirroring_display_id()); |
122 const DisplayInfo& source_display_info = display_manager->GetDisplayInfo( | 122 const DisplayInfo& source_display_info = display_manager->GetDisplayInfo( |
123 Shell::GetScreen()->GetPrimaryDisplay().id()); | 123 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); |
124 return scoped_ptr<RootWindowTransformer>( | 124 return scoped_ptr<RootWindowTransformer>( |
125 CreateRootWindowTransformerForMirroredDisplay(source_display_info, | 125 CreateRootWindowTransformerForMirroredDisplay(source_display_info, |
126 mirror_display_info)); | 126 mirror_display_info)); |
127 } | 127 } |
128 | 128 |
129 } // namespace | 129 } // namespace |
130 | 130 |
131 typedef test::AshTestBase RootWindowTransformersTest; | 131 typedef test::AshTestBase RootWindowTransformersTest; |
132 | 132 |
133 #if defined(OS_WIN) | 133 #if defined(OS_WIN) |
(...skipping 10 matching lines...) Expand all Loading... |
144 | 144 |
145 TEST_F(RootWindowTransformersTest, MAYBE_RotateAndMagnify) { | 145 TEST_F(RootWindowTransformersTest, MAYBE_RotateAndMagnify) { |
146 MagnificationController* magnifier = | 146 MagnificationController* magnifier = |
147 Shell::GetInstance()->magnification_controller(); | 147 Shell::GetInstance()->magnification_controller(); |
148 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 148 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
149 | 149 |
150 TestEventHandler event_handler; | 150 TestEventHandler event_handler; |
151 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 151 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
152 | 152 |
153 UpdateDisplay("120x200,300x400*2"); | 153 UpdateDisplay("120x200,300x400*2"); |
154 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); | 154 gfx::Display display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
155 int64_t display2_id = ScreenUtil::GetSecondaryDisplay().id(); | 155 int64_t display2_id = ScreenUtil::GetSecondaryDisplay().id(); |
156 | 156 |
157 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 157 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
158 ui::test::EventGenerator generator1(root_windows[0]); | 158 ui::test::EventGenerator generator1(root_windows[0]); |
159 ui::test::EventGenerator generator2(root_windows[1]); | 159 ui::test::EventGenerator generator2(root_windows[1]); |
160 | 160 |
161 magnifier->SetEnabled(true); | 161 magnifier->SetEnabled(true); |
162 EXPECT_EQ(2.0f, magnifier->GetScale()); | 162 EXPECT_EQ(2.0f, magnifier->GetScale()); |
163 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); | 163 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); |
164 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); | 164 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 236 |
237 TEST_F(RootWindowTransformersTest, ScaleAndMagnify) { | 237 TEST_F(RootWindowTransformersTest, ScaleAndMagnify) { |
238 if (!SupportsMultipleDisplays()) | 238 if (!SupportsMultipleDisplays()) |
239 return; | 239 return; |
240 | 240 |
241 TestEventHandler event_handler; | 241 TestEventHandler event_handler; |
242 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 242 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
243 | 243 |
244 UpdateDisplay("600x400*2@1.5,500x300"); | 244 UpdateDisplay("600x400*2@1.5,500x300"); |
245 | 245 |
246 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); | 246 gfx::Display display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
247 test::ScopedSetInternalDisplayId set_internal(display1.id()); | 247 test::ScopedSetInternalDisplayId set_internal(display1.id()); |
248 gfx::Display display2 = ScreenUtil::GetSecondaryDisplay(); | 248 gfx::Display display2 = ScreenUtil::GetSecondaryDisplay(); |
249 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 249 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
250 MagnificationController* magnifier = | 250 MagnificationController* magnifier = |
251 Shell::GetInstance()->magnification_controller(); | 251 Shell::GetInstance()->magnification_controller(); |
252 | 252 |
253 magnifier->SetEnabled(true); | 253 magnifier->SetEnabled(true); |
254 EXPECT_EQ(2.0f, magnifier->GetScale()); | 254 EXPECT_EQ(2.0f, magnifier->GetScale()); |
255 EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); | 255 EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); |
256 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); | 256 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); |
257 EXPECT_EQ("450,0 500x300", display2.bounds().ToString()); | 257 EXPECT_EQ("450,0 500x300", display2.bounds().ToString()); |
258 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); | 258 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); |
259 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); | 259 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); |
260 | 260 |
261 ui::test::EventGenerator generator(root_windows[0]); | 261 ui::test::EventGenerator generator(root_windows[0]); |
262 generator.MoveMouseToInHost(500, 200); | 262 generator.MoveMouseToInHost(500, 200); |
263 EXPECT_EQ("299,150", event_handler.GetLocationAndReset()); | 263 EXPECT_EQ("299,150", event_handler.GetLocationAndReset()); |
264 magnifier->SetEnabled(false); | 264 magnifier->SetEnabled(false); |
265 | 265 |
266 SetDisplayUIScale(display1.id(), 1.25f); | 266 SetDisplayUIScale(display1.id(), 1.25f); |
267 display1 = Shell::GetScreen()->GetPrimaryDisplay(); | 267 display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
268 display2 = ScreenUtil::GetSecondaryDisplay(); | 268 display2 = ScreenUtil::GetSecondaryDisplay(); |
269 magnifier->SetEnabled(true); | 269 magnifier->SetEnabled(true); |
270 EXPECT_EQ(2.0f, magnifier->GetScale()); | 270 EXPECT_EQ(2.0f, magnifier->GetScale()); |
271 EXPECT_EQ("0,0 375x250", display1.bounds().ToString()); | 271 EXPECT_EQ("0,0 375x250", display1.bounds().ToString()); |
272 EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString()); | 272 EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString()); |
273 EXPECT_EQ("375,0 500x300", display2.bounds().ToString()); | 273 EXPECT_EQ("375,0 500x300", display2.bounds().ToString()); |
274 EXPECT_EQ(1.25f, GetStoredUIScale(display1.id())); | 274 EXPECT_EQ(1.25f, GetStoredUIScale(display1.id())); |
275 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); | 275 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); |
276 magnifier->SetEnabled(false); | 276 magnifier->SetEnabled(false); |
277 | 277 |
278 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 278 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
279 } | 279 } |
280 | 280 |
281 TEST_F(RootWindowTransformersTest, MAYBE_TouchScaleAndMagnify) { | 281 TEST_F(RootWindowTransformersTest, MAYBE_TouchScaleAndMagnify) { |
282 TestEventHandler event_handler; | 282 TestEventHandler event_handler; |
283 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 283 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
284 | 284 |
285 UpdateDisplay("200x200*2"); | 285 UpdateDisplay("200x200*2"); |
286 gfx::Display display = Shell::GetScreen()->GetPrimaryDisplay(); | 286 gfx::Display display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
287 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 287 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
288 aura::Window* root_window = root_windows[0]; | 288 aura::Window* root_window = root_windows[0]; |
289 ui::test::EventGenerator generator(root_window); | 289 ui::test::EventGenerator generator(root_window); |
290 MagnificationController* magnifier = | 290 MagnificationController* magnifier = |
291 Shell::GetInstance()->magnification_controller(); | 291 Shell::GetInstance()->magnification_controller(); |
292 | 292 |
293 magnifier->SetEnabled(true); | 293 magnifier->SetEnabled(true); |
294 EXPECT_FLOAT_EQ(2.0f, magnifier->GetScale()); | 294 EXPECT_FLOAT_EQ(2.0f, magnifier->GetScale()); |
295 magnifier->SetScale(2.5f, false); | 295 magnifier->SetScale(2.5f, false); |
296 EXPECT_FLOAT_EQ(2.5f, magnifier->GetScale()); | 296 EXPECT_FLOAT_EQ(2.5f, magnifier->GetScale()); |
(...skipping 19 matching lines...) Expand all Loading... |
316 | 316 |
317 TEST_F(RootWindowTransformersTest, MAYBE_ConvertHostToRootCoords) { | 317 TEST_F(RootWindowTransformersTest, MAYBE_ConvertHostToRootCoords) { |
318 TestEventHandler event_handler; | 318 TestEventHandler event_handler; |
319 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 319 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
320 MagnificationController* magnifier = | 320 MagnificationController* magnifier = |
321 Shell::GetInstance()->magnification_controller(); | 321 Shell::GetInstance()->magnification_controller(); |
322 | 322 |
323 // Test 1 | 323 // Test 1 |
324 UpdateDisplay("600x400*2/r@1.5"); | 324 UpdateDisplay("600x400*2/r@1.5"); |
325 | 325 |
326 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); | 326 gfx::Display display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
327 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 327 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
328 EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); | 328 EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); |
329 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); | 329 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); |
330 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); | 330 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); |
331 | 331 |
332 ui::test::EventGenerator generator(root_windows[0]); | 332 ui::test::EventGenerator generator(root_windows[0]); |
333 generator.MoveMouseToInHost(300, 200); | 333 generator.MoveMouseToInHost(300, 200); |
334 magnifier->SetEnabled(true); | 334 magnifier->SetEnabled(true); |
335 EXPECT_EQ("150,224", event_handler.GetLocationAndReset()); | 335 EXPECT_EQ("150,224", event_handler.GetLocationAndReset()); |
336 EXPECT_FLOAT_EQ(2.0f, magnifier->GetScale()); | 336 EXPECT_FLOAT_EQ(2.0f, magnifier->GetScale()); |
337 | 337 |
338 generator.MoveMouseToInHost(300, 200); | 338 generator.MoveMouseToInHost(300, 200); |
339 EXPECT_EQ("150,224", event_handler.GetLocationAndReset()); | 339 EXPECT_EQ("150,224", event_handler.GetLocationAndReset()); |
340 generator.MoveMouseToInHost(200, 300); | 340 generator.MoveMouseToInHost(200, 300); |
341 EXPECT_EQ("187,261", event_handler.GetLocationAndReset()); | 341 EXPECT_EQ("187,261", event_handler.GetLocationAndReset()); |
342 generator.MoveMouseToInHost(100, 400); | 342 generator.MoveMouseToInHost(100, 400); |
343 EXPECT_EQ("237,299", event_handler.GetLocationAndReset()); | 343 EXPECT_EQ("237,299", event_handler.GetLocationAndReset()); |
344 generator.MoveMouseToInHost(0, 0); | 344 generator.MoveMouseToInHost(0, 0); |
345 EXPECT_EQ("137,348", event_handler.GetLocationAndReset()); | 345 EXPECT_EQ("137,348", event_handler.GetLocationAndReset()); |
346 | 346 |
347 magnifier->SetEnabled(false); | 347 magnifier->SetEnabled(false); |
348 EXPECT_FLOAT_EQ(1.0f, magnifier->GetScale()); | 348 EXPECT_FLOAT_EQ(1.0f, magnifier->GetScale()); |
349 | 349 |
350 // Test 2 | 350 // Test 2 |
351 UpdateDisplay("600x400*2/u@1.5"); | 351 UpdateDisplay("600x400*2/u@1.5"); |
352 display1 = Shell::GetScreen()->GetPrimaryDisplay(); | 352 display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
353 root_windows = Shell::GetAllRootWindows(); | 353 root_windows = Shell::GetAllRootWindows(); |
354 EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); | 354 EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); |
355 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); | 355 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); |
356 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); | 356 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); |
357 | 357 |
358 generator.MoveMouseToInHost(300, 200); | 358 generator.MoveMouseToInHost(300, 200); |
359 magnifier->SetEnabled(true); | 359 magnifier->SetEnabled(true); |
360 EXPECT_EQ("224,149", event_handler.GetLocationAndReset()); | 360 EXPECT_EQ("224,149", event_handler.GetLocationAndReset()); |
361 EXPECT_FLOAT_EQ(2.0f, magnifier->GetScale()); | 361 EXPECT_FLOAT_EQ(2.0f, magnifier->GetScale()); |
362 | 362 |
363 generator.MoveMouseToInHost(300, 200); | 363 generator.MoveMouseToInHost(300, 200); |
364 EXPECT_EQ("224,148", event_handler.GetLocationAndReset()); | 364 EXPECT_EQ("224,148", event_handler.GetLocationAndReset()); |
365 generator.MoveMouseToInHost(200, 300); | 365 generator.MoveMouseToInHost(200, 300); |
366 EXPECT_EQ("261,111", event_handler.GetLocationAndReset()); | 366 EXPECT_EQ("261,111", event_handler.GetLocationAndReset()); |
367 generator.MoveMouseToInHost(100, 400); | 367 generator.MoveMouseToInHost(100, 400); |
368 EXPECT_EQ("299,60", event_handler.GetLocationAndReset()); | 368 EXPECT_EQ("299,60", event_handler.GetLocationAndReset()); |
369 generator.MoveMouseToInHost(0, 0); | 369 generator.MoveMouseToInHost(0, 0); |
370 EXPECT_EQ("348,159", event_handler.GetLocationAndReset()); | 370 EXPECT_EQ("348,159", event_handler.GetLocationAndReset()); |
371 | 371 |
372 magnifier->SetEnabled(false); | 372 magnifier->SetEnabled(false); |
373 EXPECT_FLOAT_EQ(1.0f, magnifier->GetScale()); | 373 EXPECT_FLOAT_EQ(1.0f, magnifier->GetScale()); |
374 | 374 |
375 // Test 3 | 375 // Test 3 |
376 UpdateDisplay("600x400*2/l@1.5"); | 376 UpdateDisplay("600x400*2/l@1.5"); |
377 display1 = Shell::GetScreen()->GetPrimaryDisplay(); | 377 display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
378 root_windows = Shell::GetAllRootWindows(); | 378 root_windows = Shell::GetAllRootWindows(); |
379 EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); | 379 EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); |
380 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); | 380 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); |
381 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); | 381 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); |
382 | 382 |
383 generator.MoveMouseToInHost(300, 200); | 383 generator.MoveMouseToInHost(300, 200); |
384 magnifier->SetEnabled(true); | 384 magnifier->SetEnabled(true); |
385 EXPECT_EQ("149,225", event_handler.GetLocationAndReset()); | 385 EXPECT_EQ("149,225", event_handler.GetLocationAndReset()); |
386 EXPECT_FLOAT_EQ(2.0f, magnifier->GetScale()); | 386 EXPECT_FLOAT_EQ(2.0f, magnifier->GetScale()); |
387 | 387 |
(...skipping 24 matching lines...) Expand all Loading... |
412 // Y margin must be margin is (500 - 500/400 * 200) / 2 = 125. | 412 // Y margin must be margin is (500 - 500/400 * 200) / 2 = 125. |
413 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString()); | 413 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString()); |
414 | 414 |
415 UpdateDisplay("200x400,500x500"); | 415 UpdateDisplay("200x400,500x500"); |
416 // The aspect ratio is flipped, so X margin is now 125. | 416 // The aspect ratio is flipped, so X margin is now 125. |
417 transformer = CreateCurrentRootWindowTransformerForMirroring(); | 417 transformer = CreateCurrentRootWindowTransformerForMirroring(); |
418 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString()); | 418 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString()); |
419 } | 419 } |
420 | 420 |
421 } // namespace ash | 421 } // namespace ash |
OLD | NEW |