| 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_manager.h" | 5 #include "ash/display/display_manager.h" |
| 6 | 6 |
| 7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/screen_ash.h" | 8 #include "ash/screen_ash.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 private: | 112 private: |
| 113 vector<gfx::Display> changed_; | 113 vector<gfx::Display> changed_; |
| 114 vector<gfx::Display> added_; | 114 vector<gfx::Display> added_; |
| 115 size_t removed_count_; | 115 size_t removed_count_; |
| 116 bool root_window_destroyed_; | 116 bool root_window_destroyed_; |
| 117 | 117 |
| 118 DISALLOW_COPY_AND_ASSIGN(DisplayManagerTest); | 118 DISALLOW_COPY_AND_ASSIGN(DisplayManagerTest); |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 TEST_F(DisplayManagerTest, NativeDisplayTest) { | 121 TEST_F(DisplayManagerTest, NativeDisplayTest) { |
| 122 if (!SupportsMultipleDisplays()) |
| 123 return; |
| 124 |
| 122 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 125 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
| 123 | 126 |
| 124 // Update primary and add seconary. | 127 // Update primary and add seconary. |
| 125 UpdateDisplay("100+0-500x500,0+501-400x400"); | 128 UpdateDisplay("100+0-500x500,0+501-400x400"); |
| 126 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); | 129 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); |
| 127 EXPECT_EQ("0,0 500x500", | 130 EXPECT_EQ("0,0 500x500", |
| 128 display_manager()->GetDisplayAt(0)->bounds().ToString()); | 131 display_manager()->GetDisplayAt(0)->bounds().ToString()); |
| 129 | 132 |
| 130 EXPECT_EQ("1 1 0", GetCountSummary()); | 133 EXPECT_EQ("1 1 0", GetCountSummary()); |
| 131 EXPECT_EQ(display_manager()->GetDisplayAt(0)->id(), changed()[0].id()); | 134 EXPECT_EQ(display_manager()->GetDisplayAt(0)->id(), changed()[0].id()); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 // Secondary display is on right. | 206 // Secondary display is on right. |
| 204 EXPECT_EQ("1000,0 600x400", | 207 EXPECT_EQ("1000,0 600x400", |
| 205 display_manager()->GetDisplayAt(1)->bounds().ToString()); | 208 display_manager()->GetDisplayAt(1)->bounds().ToString()); |
| 206 EXPECT_EQ("1000,1000 600x400", | 209 EXPECT_EQ("1000,1000 600x400", |
| 207 GetDisplayInfoAt(1).bounds_in_pixel().ToString()); | 210 GetDisplayInfoAt(1).bounds_in_pixel().ToString()); |
| 208 reset(); | 211 reset(); |
| 209 } | 212 } |
| 210 | 213 |
| 211 // Test in emulation mode (use_fullscreen_host_window=false) | 214 // Test in emulation mode (use_fullscreen_host_window=false) |
| 212 TEST_F(DisplayManagerTest, EmulatorTest) { | 215 TEST_F(DisplayManagerTest, EmulatorTest) { |
| 216 if (!SupportsMultipleDisplays()) |
| 217 return; |
| 218 |
| 213 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 219 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
| 214 | 220 |
| 215 display_manager()->AddRemoveDisplay(); | 221 display_manager()->AddRemoveDisplay(); |
| 216 // Update primary and add seconary. | 222 // Update primary and add seconary. |
| 217 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); | 223 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); |
| 218 EXPECT_EQ("0 1 0", GetCountSummary()); | 224 EXPECT_EQ("0 1 0", GetCountSummary()); |
| 219 reset(); | 225 reset(); |
| 220 | 226 |
| 221 display_manager()->AddRemoveDisplay(); | 227 display_manager()->AddRemoveDisplay(); |
| 222 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 228 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
| 223 EXPECT_EQ("0 0 1", GetCountSummary()); | 229 EXPECT_EQ("0 0 1", GetCountSummary()); |
| 224 reset(); | 230 reset(); |
| 225 | 231 |
| 226 display_manager()->AddRemoveDisplay(); | 232 display_manager()->AddRemoveDisplay(); |
| 227 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); | 233 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); |
| 228 EXPECT_EQ("0 1 0", GetCountSummary()); | 234 EXPECT_EQ("0 1 0", GetCountSummary()); |
| 229 reset(); | 235 reset(); |
| 230 } | 236 } |
| 231 | 237 |
| 232 TEST_F(DisplayManagerTest, OverscanInsetsTest) { | 238 TEST_F(DisplayManagerTest, OverscanInsetsTest) { |
| 239 if (!SupportsMultipleDisplays()) |
| 240 return; |
| 241 |
| 233 UpdateDisplay("0+0-500x500,0+501-400x400"); | 242 UpdateDisplay("0+0-500x500,0+501-400x400"); |
| 234 reset(); | 243 reset(); |
| 235 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); | 244 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); |
| 236 const DisplayInfo& display_info1 = GetDisplayInfoAt(0); | 245 const DisplayInfo& display_info1 = GetDisplayInfoAt(0); |
| 237 const DisplayInfo& display_info2 = GetDisplayInfoAt(1); | 246 const DisplayInfo& display_info2 = GetDisplayInfoAt(1); |
| 238 display_manager()->SetOverscanInsets( | 247 display_manager()->SetOverscanInsets( |
| 239 display_info2.id(), gfx::Insets(13, 12, 11, 10)); | 248 display_info2.id(), gfx::Insets(13, 12, 11, 10)); |
| 240 | 249 |
| 241 std::vector<gfx::Display> changed_displays = changed(); | 250 std::vector<gfx::Display> changed_displays = changed(); |
| 242 EXPECT_EQ(1u, changed_displays.size()); | 251 EXPECT_EQ(1u, changed_displays.size()); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 GetDisplayInfo(ScreenAsh::GetSecondaryDisplay()). | 334 GetDisplayInfo(ScreenAsh::GetSecondaryDisplay()). |
| 326 bounds_in_pixel().ToString()); | 335 bounds_in_pixel().ToString()); |
| 327 EXPECT_EQ("0,501 400x400", | 336 EXPECT_EQ("0,501 400x400", |
| 328 GetDisplayInfo(Shell::GetScreen()->GetPrimaryDisplay()). | 337 GetDisplayInfo(Shell::GetScreen()->GetPrimaryDisplay()). |
| 329 bounds_in_pixel().ToString()); | 338 bounds_in_pixel().ToString()); |
| 330 EXPECT_EQ("0,0 188x190", | 339 EXPECT_EQ("0,0 188x190", |
| 331 Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString()); | 340 Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString()); |
| 332 } | 341 } |
| 333 | 342 |
| 334 TEST_F(DisplayManagerTest, ZeroOverscanInsets) { | 343 TEST_F(DisplayManagerTest, ZeroOverscanInsets) { |
| 344 if (!SupportsMultipleDisplays()) |
| 345 return; |
| 346 |
| 335 // Make sure the display change events is emitted for overscan inset changes. | 347 // Make sure the display change events is emitted for overscan inset changes. |
| 336 UpdateDisplay("0+0-500x500,0+501-400x400"); | 348 UpdateDisplay("0+0-500x500,0+501-400x400"); |
| 337 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); | 349 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); |
| 338 int64 display2_id = display_manager()->GetDisplayAt(1)->id(); | 350 int64 display2_id = display_manager()->GetDisplayAt(1)->id(); |
| 339 | 351 |
| 340 reset(); | 352 reset(); |
| 341 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0)); | 353 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0)); |
| 342 EXPECT_EQ(0u, changed().size()); | 354 EXPECT_EQ(0u, changed().size()); |
| 343 | 355 |
| 344 reset(); | 356 reset(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 364 EXPECT_EQ("500x300", | 376 EXPECT_EQ("500x300", |
| 365 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); | 377 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); |
| 366 } | 378 } |
| 367 | 379 |
| 368 DisplayInfo CreateDisplayInfo(int64 id, const gfx::Rect& bounds) { | 380 DisplayInfo CreateDisplayInfo(int64 id, const gfx::Rect& bounds) { |
| 369 DisplayInfo info(id, StringPrintf("x-%d", static_cast<int>(id)), false); | 381 DisplayInfo info(id, StringPrintf("x-%d", static_cast<int>(id)), false); |
| 370 info.SetBounds(bounds); | 382 info.SetBounds(bounds); |
| 371 return info; | 383 return info; |
| 372 } | 384 } |
| 373 | 385 |
| 374 #if defined(OS_WIN) | 386 TEST_F(DisplayManagerTest, TestNativeDisplaysChanged) { |
| 375 // Crashes flakily on Win8 Aura: http://crbug.com/246109. | |
| 376 #define MAYBE_TestNativeDisplaysChanged DISABLED_TestNativeDisplaysChanged | |
| 377 #else | |
| 378 #define MAYBE_TestNativeDisplaysChanged TestNativeDisplaysChanged | |
| 379 #endif | |
| 380 TEST_F(DisplayManagerTest, MAYBE_TestNativeDisplaysChanged) { | |
| 381 const int internal_display_id = | 387 const int internal_display_id = |
| 382 test::DisplayManagerTestApi(display_manager()). | 388 test::DisplayManagerTestApi(display_manager()). |
| 383 SetFirstDisplayAsInternalDisplay(); | 389 SetFirstDisplayAsInternalDisplay(); |
| 384 const int external_id = 10; | 390 const int external_id = 10; |
| 385 const int mirror_id = 11; | 391 const int mirror_id = 11; |
| 386 const int64 invalid_id = gfx::Display::kInvalidDisplayID; | 392 const int64 invalid_id = gfx::Display::kInvalidDisplayID; |
| 387 const DisplayInfo internal_display_info = | 393 const DisplayInfo internal_display_info = |
| 388 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); | 394 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); |
| 389 const DisplayInfo external_display_info = | 395 const DisplayInfo external_display_info = |
| 390 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); | 396 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); |
| 391 const DisplayInfo mirrored_display_info = | 397 const DisplayInfo mirrored_display_info = |
| 392 CreateDisplayInfo(mirror_id, gfx::Rect(0, 0, 500, 500)); | 398 CreateDisplayInfo(mirror_id, gfx::Rect(0, 0, 500, 500)); |
| 393 | 399 |
| 394 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 400 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
| 395 EXPECT_EQ(1U, display_manager()->num_connected_displays()); | 401 EXPECT_EQ(1U, display_manager()->num_connected_displays()); |
| 396 std::string default_bounds = | 402 std::string default_bounds = |
| 397 display_manager()->GetDisplayAt(0)->bounds().ToString(); | 403 display_manager()->GetDisplayAt(0)->bounds().ToString(); |
| 398 | 404 |
| 399 std::vector<DisplayInfo> display_info_list; | 405 std::vector<DisplayInfo> display_info_list; |
| 400 // Primary disconnected. | 406 // Primary disconnected. |
| 401 display_manager()->OnNativeDisplaysChanged(display_info_list); | 407 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 402 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 408 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
| 403 EXPECT_EQ(default_bounds, | 409 EXPECT_EQ(default_bounds, |
| 404 display_manager()->GetDisplayAt(0)->bounds().ToString()); | 410 display_manager()->GetDisplayAt(0)->bounds().ToString()); |
| 405 EXPECT_EQ(1U, display_manager()->num_connected_displays()); | 411 EXPECT_EQ(1U, display_manager()->num_connected_displays()); |
| 406 EXPECT_FALSE(display_manager()->mirrored_display().is_valid()); | 412 EXPECT_FALSE(display_manager()->mirrored_display().is_valid()); |
| 407 | 413 |
| 414 if (!SupportsMultipleDisplays()) |
| 415 return; |
| 416 |
| 408 // External connected while primary was disconnected. | 417 // External connected while primary was disconnected. |
| 409 display_info_list.push_back(external_display_info); | 418 display_info_list.push_back(external_display_info); |
| 410 display_manager()->OnNativeDisplaysChanged(display_info_list); | 419 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 411 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 420 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
| 412 | 421 |
| 413 EXPECT_EQ(invalid_id, FindDisplayForId(internal_display_id).id()); | 422 EXPECT_EQ(invalid_id, FindDisplayForId(internal_display_id).id()); |
| 414 EXPECT_EQ("1,1 100x100", | 423 EXPECT_EQ("1,1 100x100", |
| 415 FindDisplayInfoForId(external_id).bounds_in_pixel().ToString()); | 424 FindDisplayInfoForId(external_id).bounds_in_pixel().ToString()); |
| 416 EXPECT_EQ(1U, display_manager()->num_connected_displays()); | 425 EXPECT_EQ(1U, display_manager()->num_connected_displays()); |
| 417 EXPECT_FALSE(display_manager()->mirrored_display().is_valid()); | 426 EXPECT_FALSE(display_manager()->mirrored_display().is_valid()); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 display_manager()->OnNativeDisplaysChanged(display_info_list); | 538 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 530 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 539 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
| 531 EXPECT_EQ( | 540 EXPECT_EQ( |
| 532 "0,0 500x500", | 541 "0,0 500x500", |
| 533 FindDisplayInfoForId(internal_display_id).bounds_in_pixel().ToString()); | 542 FindDisplayInfoForId(internal_display_id).bounds_in_pixel().ToString()); |
| 534 EXPECT_EQ(1U, display_manager()->num_connected_displays()); | 543 EXPECT_EQ(1U, display_manager()->num_connected_displays()); |
| 535 EXPECT_FALSE(display_manager()->mirrored_display().is_valid()); | 544 EXPECT_FALSE(display_manager()->mirrored_display().is_valid()); |
| 536 } | 545 } |
| 537 | 546 |
| 538 #if defined(OS_WIN) | 547 #if defined(OS_WIN) |
| 539 // This test currently fails on Win8/Metro as it picks up the actual | 548 // TODO(scottmg): RootWindow doesn't get resized on Windows |
| 540 // display size. http://crbug.com/154081 | 549 // Ash. http://crbug.com/247916. |
| 541 #define MAYBE_TestNativeDisplaysChangedNoInternal \ | 550 #define MAYBE_TestNativeDisplaysChangedNoInternal \ |
| 542 DISABLED_TestNativeDisplaysChangedNoInternal | 551 DISABLED_TestNativeDisplaysChangedNoInternal |
| 543 #else | 552 #else |
| 544 #define MAYBE_TestNativeDisplaysChangedNoInternal \ | 553 #define MAYBE_TestNativeDisplaysChangedNoInternal \ |
| 545 TestNativeDisplaysChangedNoInternal | 554 TestNativeDisplaysChangedNoInternal |
| 546 #endif | 555 #endif |
| 547 | 556 |
| 548 TEST_F(DisplayManagerTest, MAYBE_TestNativeDisplaysChangedNoInternal) { | 557 TEST_F(DisplayManagerTest, MAYBE_TestNativeDisplaysChangedNoInternal) { |
| 549 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 558 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
| 550 | 559 |
| 551 // Don't change the display info if all displays are disconnected. | 560 // Don't change the display info if all displays are disconnected. |
| 552 std::vector<DisplayInfo> display_info_list; | 561 std::vector<DisplayInfo> display_info_list; |
| 553 display_manager()->OnNativeDisplaysChanged(display_info_list); | 562 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 554 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 563 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
| 555 | 564 |
| 556 // Connect another display which will become primary. | 565 // Connect another display which will become primary. |
| 557 const DisplayInfo external_display_info = | 566 const DisplayInfo external_display_info = |
| 558 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); | 567 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); |
| 559 display_info_list.push_back(external_display_info); | 568 display_info_list.push_back(external_display_info); |
| 560 display_manager()->OnNativeDisplaysChanged(display_info_list); | 569 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 561 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 570 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
| 562 EXPECT_EQ("1,1 100x100", | 571 EXPECT_EQ("1,1 100x100", |
| 563 FindDisplayInfoForId(10).bounds_in_pixel().ToString()); | 572 FindDisplayInfoForId(10).bounds_in_pixel().ToString()); |
| 564 EXPECT_EQ("100x100", | 573 EXPECT_EQ("100x100", |
| 565 ash::Shell::GetPrimaryRootWindow()->GetHostSize().ToString()); | 574 ash::Shell::GetPrimaryRootWindow()->GetHostSize().ToString()); |
| 566 } | 575 } |
| 567 | 576 |
| 568 TEST_F(DisplayManagerTest, EnsurePointerInDisplays) { | 577 TEST_F(DisplayManagerTest, EnsurePointerInDisplays) { |
| 578 if (!SupportsMultipleDisplays()) |
| 579 return; |
| 580 |
| 569 UpdateDisplay("200x200,300x300"); | 581 UpdateDisplay("200x200,300x300"); |
| 570 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 582 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 571 | 583 |
| 572 aura::Env* env = aura::Env::GetInstance(); | 584 aura::Env* env = aura::Env::GetInstance(); |
| 573 | 585 |
| 574 aura::test::EventGenerator generator(root_windows[0]); | 586 aura::test::EventGenerator generator(root_windows[0]); |
| 575 | 587 |
| 576 // Set the initial position. | 588 // Set the initial position. |
| 577 generator.MoveMouseToInHost(350, 150); | 589 generator.MoveMouseToInHost(350, 150); |
| 578 EXPECT_EQ("350,150", env->last_mouse_location().ToString()); | 590 EXPECT_EQ("350,150", env->last_mouse_location().ToString()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 598 | 610 |
| 599 // Move the mouse pointer to the bottom of 1st display. | 611 // Move the mouse pointer to the bottom of 1st display. |
| 600 generator.MoveMouseToInHost(150, 290); | 612 generator.MoveMouseToInHost(150, 290); |
| 601 EXPECT_EQ("150,290", env->last_mouse_location().ToString()); | 613 EXPECT_EQ("150,290", env->last_mouse_location().ToString()); |
| 602 | 614 |
| 603 // The mouse pointer is outside and closest display is 1st one. | 615 // The mouse pointer is outside and closest display is 1st one. |
| 604 UpdateDisplay("300x280,200x200"); | 616 UpdateDisplay("300x280,200x200"); |
| 605 EXPECT_EQ("150,140", env->last_mouse_location().ToString()); | 617 EXPECT_EQ("150,140", env->last_mouse_location().ToString()); |
| 606 } | 618 } |
| 607 | 619 |
| 608 #if defined(OS_WIN) | 620 TEST_F(DisplayManagerTest, EnsurePointerInDisplays_2ndOnLeft) { |
| 609 // Flaky failures on Win8 due to window activation messages. crbug.com/239539 | 621 if (!SupportsMultipleDisplays()) |
| 610 #define MAYBE_EnsurePointerInDisplays_2ndOnLeft \ | 622 return; |
| 611 DISABLED_EnsurePointerInDisplays_2ndOnLeft | 623 |
| 612 #else | |
| 613 #define MAYBE_EnsurePointerInDisplays_2ndOnLeft \ | |
| 614 EnsurePointerInDisplays_2ndOnLeft | |
| 615 #endif | |
| 616 TEST_F(DisplayManagerTest, MAYBE_EnsurePointerInDisplays_2ndOnLeft) { | |
| 617 // Set the 2nd display on the left. | 624 // Set the 2nd display on the left. |
| 618 DisplayController* display_controller = | 625 DisplayController* display_controller = |
| 619 Shell::GetInstance()->display_controller(); | 626 Shell::GetInstance()->display_controller(); |
| 620 DisplayLayout layout = display_controller->default_display_layout(); | 627 DisplayLayout layout = display_controller->default_display_layout(); |
| 621 layout.position = DisplayLayout::LEFT; | 628 layout.position = DisplayLayout::LEFT; |
| 622 display_controller->SetDefaultDisplayLayout(layout); | 629 display_controller->SetDefaultDisplayLayout(layout); |
| 623 | 630 |
| 624 UpdateDisplay("200x200,300x300"); | 631 UpdateDisplay("200x200,300x300"); |
| 625 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 632 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 626 | 633 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 642 UpdateDisplay("300x300,200x100"); | 649 UpdateDisplay("300x300,200x100"); |
| 643 EXPECT_EQ("-100,50", env->last_mouse_location().ToString()); | 650 EXPECT_EQ("-100,50", env->last_mouse_location().ToString()); |
| 644 | 651 |
| 645 // 2nd display was disconnected. Mouse pointer should move to | 652 // 2nd display was disconnected. Mouse pointer should move to |
| 646 // 1st display. | 653 // 1st display. |
| 647 UpdateDisplay("300x300"); | 654 UpdateDisplay("300x300"); |
| 648 EXPECT_EQ("150,150", env->last_mouse_location().ToString()); | 655 EXPECT_EQ("150,150", env->last_mouse_location().ToString()); |
| 649 } | 656 } |
| 650 | 657 |
| 651 TEST_F(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) { | 658 TEST_F(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) { |
| 659 if (!SupportsMultipleDisplays()) |
| 660 return; |
| 661 |
| 652 const int64 internal_display_id = | 662 const int64 internal_display_id = |
| 653 test::DisplayManagerTestApi(display_manager()). | 663 test::DisplayManagerTestApi(display_manager()). |
| 654 SetFirstDisplayAsInternalDisplay(); | 664 SetFirstDisplayAsInternalDisplay(); |
| 655 const DisplayInfo native_display_info = | 665 const DisplayInfo native_display_info = |
| 656 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); | 666 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); |
| 657 const DisplayInfo secondary_display_info = | 667 const DisplayInfo secondary_display_info = |
| 658 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); | 668 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); |
| 659 | 669 |
| 660 std::vector<DisplayInfo> display_info_list; | 670 std::vector<DisplayInfo> display_info_list; |
| 661 display_info_list.push_back(native_display_info); | 671 display_info_list.push_back(native_display_info); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 674 | 684 |
| 675 // OnNativeDisplaysChanged may change the display bounds. Here makes sure | 685 // OnNativeDisplaysChanged may change the display bounds. Here makes sure |
| 676 // nothing changed if the exactly same displays are specified. | 686 // nothing changed if the exactly same displays are specified. |
| 677 display_manager()->OnNativeDisplaysChanged(display_info_list); | 687 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 678 EXPECT_EQ("-500,0 500x500", | 688 EXPECT_EQ("-500,0 500x500", |
| 679 FindDisplayForId(internal_display_id).bounds().ToString()); | 689 FindDisplayForId(internal_display_id).bounds().ToString()); |
| 680 EXPECT_EQ("0,0 100x100", FindDisplayForId(10).bounds().ToString()); | 690 EXPECT_EQ("0,0 100x100", FindDisplayForId(10).bounds().ToString()); |
| 681 } | 691 } |
| 682 | 692 |
| 683 TEST_F(DisplayManagerTest, AutomaticOverscanInsets) { | 693 TEST_F(DisplayManagerTest, AutomaticOverscanInsets) { |
| 694 if (!SupportsMultipleDisplays()) |
| 695 return; |
| 696 |
| 684 UpdateDisplay("200x200,400x400"); | 697 UpdateDisplay("200x200,400x400"); |
| 685 | 698 |
| 686 std::vector<DisplayInfo> display_info_list; | 699 std::vector<DisplayInfo> display_info_list; |
| 687 display_info_list.push_back(GetDisplayInfoAt(0)); | 700 display_info_list.push_back(GetDisplayInfoAt(0)); |
| 688 display_info_list.push_back(GetDisplayInfoAt(1)); | 701 display_info_list.push_back(GetDisplayInfoAt(1)); |
| 689 display_info_list[1].set_has_overscan_for_test(true); | 702 display_info_list[1].set_has_overscan_for_test(true); |
| 690 int64 id = display_info_list[1].id(); | 703 int64 id = display_info_list[1].id(); |
| 691 // SetDefaultOverscanInsets(&display_info_list[1]); | 704 // SetDefaultOverscanInsets(&display_info_list[1]); |
| 692 display_manager()->OnNativeDisplaysChanged(display_info_list); | 705 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 693 // It has overscan insets, although SetOverscanInsets() isn't called. | 706 // It has overscan insets, although SetOverscanInsets() isn't called. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 707 EXPECT_EQ("400x400", | 720 EXPECT_EQ("400x400", |
| 708 GetDisplayInfoAt(1).size_in_pixel().ToString()); | 721 GetDisplayInfoAt(1).size_in_pixel().ToString()); |
| 709 | 722 |
| 710 // Clearing the custom overscan should set the bounds to | 723 // Clearing the custom overscan should set the bounds to |
| 711 // original. | 724 // original. |
| 712 display_manager()->ClearCustomOverscanInsets(id); | 725 display_manager()->ClearCustomOverscanInsets(id); |
| 713 EXPECT_EQ("380x380", | 726 EXPECT_EQ("380x380", |
| 714 GetDisplayInfoAt(1).size_in_pixel().ToString()); | 727 GetDisplayInfoAt(1).size_in_pixel().ToString()); |
| 715 } | 728 } |
| 716 | 729 |
| 717 #if defined(OS_WIN) | 730 TEST_F(DisplayManagerTest, Rotate) { |
| 718 // Flaky on Win8 Aura: http://crbug.com/244466 | 731 if (!SupportsMultipleDisplays()) |
| 719 #define MAYBE_Rotate DISABLED_Rotate | 732 return; |
| 720 #else | 733 |
| 721 #define MAYBE_Rotate Rotate | |
| 722 #endif | |
| 723 TEST_F(DisplayManagerTest, MAYBE_Rotate) { | |
| 724 UpdateDisplay("100x200/r,300x400/l"); | 734 UpdateDisplay("100x200/r,300x400/l"); |
| 725 EXPECT_EQ("1,1 100x200", | 735 EXPECT_EQ("1,1 100x200", |
| 726 GetDisplayInfoAt(0).bounds_in_pixel().ToString()); | 736 GetDisplayInfoAt(0).bounds_in_pixel().ToString()); |
| 727 EXPECT_EQ("200x100", | 737 EXPECT_EQ("200x100", |
| 728 GetDisplayInfoAt(0).size_in_pixel().ToString()); | 738 GetDisplayInfoAt(0).size_in_pixel().ToString()); |
| 729 | 739 |
| 730 EXPECT_EQ("1,201 300x400", | 740 EXPECT_EQ("1,201 300x400", |
| 731 GetDisplayInfoAt(1).bounds_in_pixel().ToString()); | 741 GetDisplayInfoAt(1).bounds_in_pixel().ToString()); |
| 732 EXPECT_EQ("400x300", | 742 EXPECT_EQ("400x300", |
| 733 GetDisplayInfoAt(1).size_in_pixel().ToString()); | 743 GetDisplayInfoAt(1).size_in_pixel().ToString()); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 display_manager()->SetDisplayUIScale(display_id, 0.625f); | 828 display_manager()->SetDisplayUIScale(display_id, 0.625f); |
| 819 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).ui_scale()); | 829 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).ui_scale()); |
| 820 display_manager()->SetDisplayUIScale(display_id, 0.6f); | 830 display_manager()->SetDisplayUIScale(display_id, 0.6f); |
| 821 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).ui_scale()); | 831 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).ui_scale()); |
| 822 display_manager()->SetDisplayUIScale(display_id, 0.5f); | 832 display_manager()->SetDisplayUIScale(display_id, 0.5f); |
| 823 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).ui_scale()); | 833 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).ui_scale()); |
| 824 } | 834 } |
| 825 | 835 |
| 826 | 836 |
| 827 #if defined(OS_WIN) | 837 #if defined(OS_WIN) |
| 828 // TODO(oshima): On Windows, we don't update the origin/size right away. | 838 // TODO(scottmg): RootWindow doesn't get resized on Windows |
| 839 // Ash. http://crbug.com/247916. |
| 829 #define MAYBE_UpdateMouseCursorAfterRotateZoom DISABLED_UpdateMouseCursorAfterRo
tateZoom | 840 #define MAYBE_UpdateMouseCursorAfterRotateZoom DISABLED_UpdateMouseCursorAfterRo
tateZoom |
| 830 #else | 841 #else |
| 831 #define MAYBE_UpdateMouseCursorAfterRotateZoom UpdateMouseCursorAfterRotateZoom | 842 #define MAYBE_UpdateMouseCursorAfterRotateZoom UpdateMouseCursorAfterRotateZoom |
| 832 #endif | 843 #endif |
| 833 | 844 |
| 834 TEST_F(DisplayManagerTest, MAYBE_UpdateMouseCursorAfterRotateZoom) { | 845 TEST_F(DisplayManagerTest, MAYBE_UpdateMouseCursorAfterRotateZoom) { |
| 835 // Make sure just rotating will not change native location. | 846 // Make sure just rotating will not change native location. |
| 836 UpdateDisplay("300x200,200x150"); | 847 UpdateDisplay("300x200,200x150"); |
| 837 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 848 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 838 aura::Env* env = aura::Env::GetInstance(); | 849 aura::Env* env = aura::Env::GetInstance(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 862 EXPECT_EQ("150,225", env->last_mouse_location().ToString()); | 873 EXPECT_EQ("150,225", env->last_mouse_location().ToString()); |
| 863 | 874 |
| 864 // Test on 2nd display. | 875 // Test on 2nd display. |
| 865 UpdateDisplay("600x400,400x300*2"); | 876 UpdateDisplay("600x400,400x300*2"); |
| 866 generator2.MoveMouseToInHost(200, 100); | 877 generator2.MoveMouseToInHost(200, 100); |
| 867 EXPECT_EQ("700,50", env->last_mouse_location().ToString()); | 878 EXPECT_EQ("700,50", env->last_mouse_location().ToString()); |
| 868 UpdateDisplay("600x400,400x300*2@1.5"); | 879 UpdateDisplay("600x400,400x300*2@1.5"); |
| 869 EXPECT_EQ("750,75", env->last_mouse_location().ToString()); | 880 EXPECT_EQ("750,75", env->last_mouse_location().ToString()); |
| 870 } | 881 } |
| 871 | 882 |
| 872 #if defined(OS_WIN) | |
| 873 // This does not work on metro. | |
| 874 #define MAYBE_SoftwareMirroring DISABLED_SoftwareMirroring | |
| 875 #else | |
| 876 #define MAYBE_SoftwareMirroring SoftwareMirroring | |
| 877 #endif | |
| 878 | |
| 879 class TestDisplayObserver : public gfx::DisplayObserver { | 883 class TestDisplayObserver : public gfx::DisplayObserver { |
| 880 public: | 884 public: |
| 881 TestDisplayObserver() : changed_(false) {} | 885 TestDisplayObserver() : changed_(false) {} |
| 882 virtual ~TestDisplayObserver() {} | 886 virtual ~TestDisplayObserver() {} |
| 883 | 887 |
| 884 // gfx::DisplayObserver overrides: | 888 // gfx::DisplayObserver overrides: |
| 885 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE { | 889 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE { |
| 886 } | 890 } |
| 887 virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE { | 891 virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE { |
| 888 // Mirror window should already be delete before restoring | 892 // Mirror window should already be delete before restoring |
| (...skipping 14 matching lines...) Expand all Loading... |
| 903 return changed; | 907 return changed; |
| 904 } | 908 } |
| 905 | 909 |
| 906 private: | 910 private: |
| 907 test::MirrorWindowTestApi test_api; | 911 test::MirrorWindowTestApi test_api; |
| 908 bool changed_; | 912 bool changed_; |
| 909 | 913 |
| 910 DISALLOW_COPY_AND_ASSIGN(TestDisplayObserver); | 914 DISALLOW_COPY_AND_ASSIGN(TestDisplayObserver); |
| 911 }; | 915 }; |
| 912 | 916 |
| 913 TEST_F(DisplayManagerTest, MAYBE_SoftwareMirroring) { | 917 TEST_F(DisplayManagerTest, SoftwareMirroring) { |
| 918 if (!SupportsMultipleDisplays()) |
| 919 return; |
| 920 |
| 914 UpdateDisplay("300x400,400x500"); | 921 UpdateDisplay("300x400,400x500"); |
| 915 | 922 |
| 916 test::MirrorWindowTestApi test_api; | 923 test::MirrorWindowTestApi test_api; |
| 917 EXPECT_EQ(NULL, test_api.GetRootWindow()); | 924 EXPECT_EQ(NULL, test_api.GetRootWindow()); |
| 918 | 925 |
| 919 TestDisplayObserver display_observer; | 926 TestDisplayObserver display_observer; |
| 920 Shell::GetScreen()->AddObserver(&display_observer); | 927 Shell::GetScreen()->AddObserver(&display_observer); |
| 921 | 928 |
| 922 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 929 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 923 display_manager->SetSoftwareMirroring(true); | 930 display_manager->SetSoftwareMirroring(true); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 UpdateDisplay("400x600/o,600x800/o"); | 972 UpdateDisplay("400x600/o,600x800/o"); |
| 966 EXPECT_FALSE(display_observer.changed_and_reset()); | 973 EXPECT_FALSE(display_observer.changed_and_reset()); |
| 967 EXPECT_EQ("400x600", test_api.GetRootWindow()->bounds().size().ToString()); | 974 EXPECT_EQ("400x600", test_api.GetRootWindow()->bounds().size().ToString()); |
| 968 EXPECT_EQ("600x800", GetMirroredDisplay().size().ToString()); | 975 EXPECT_EQ("600x800", GetMirroredDisplay().size().ToString()); |
| 969 | 976 |
| 970 Shell::GetScreen()->RemoveObserver(&display_observer); | 977 Shell::GetScreen()->RemoveObserver(&display_observer); |
| 971 } | 978 } |
| 972 | 979 |
| 973 } // namespace internal | 980 } // namespace internal |
| 974 } // namespace ash | 981 } // namespace ash |
| OLD | NEW |