Chromium Code Reviews| 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/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/display/display_controller.h" | 8 #include "ash/display/display_controller.h" |
| 9 #include "ash/display/display_info.h" | 9 #include "ash/display/display_info.h" |
| 10 #include "ash/display/display_layout_store.h" | 10 #include "ash/display/display_layout_store.h" |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 693 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); | 693 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); |
| 694 display_info_list.push_back(external_display_info); | 694 display_info_list.push_back(external_display_info); |
| 695 display_manager()->OnNativeDisplaysChanged(display_info_list); | 695 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 696 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 696 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
| 697 EXPECT_EQ("1,1 100x100", | 697 EXPECT_EQ("1,1 100x100", |
| 698 GetDisplayInfoForId(10).bounds_in_native().ToString()); | 698 GetDisplayInfoForId(10).bounds_in_native().ToString()); |
| 699 EXPECT_EQ("100x100", ash::Shell::GetPrimaryRootWindow()->GetHost()-> | 699 EXPECT_EQ("100x100", ash::Shell::GetPrimaryRootWindow()->GetHost()-> |
| 700 GetBounds().size().ToString()); | 700 GetBounds().size().ToString()); |
| 701 } | 701 } |
| 702 | 702 |
| 703 #if defined(OS_WIN) | |
| 704 // Tests that rely on the actual host size/location does not work on windows. | |
|
pkotwicz
2015/02/24 18:38:08
I moved these to display_controller_unittests.cc
| |
| 705 #define MAYBE_EnsurePointerInDisplays DISABLED_EnsurePointerInDisplays | |
| 706 #define MAYBE_EnsurePointerInDisplays_2ndOnLeft DISABLED_EnsurePointerInDisplays _2ndOnLeft | |
| 707 #else | |
| 708 #define MAYBE_EnsurePointerInDisplays EnsurePointerInDisplays | |
| 709 #define MAYBE_EnsurePointerInDisplays_2ndOnLeft EnsurePointerInDisplays_2ndOnLef t | |
| 710 #endif | |
| 711 | |
| 712 TEST_F(DisplayManagerTest, MAYBE_EnsurePointerInDisplays) { | |
| 713 UpdateDisplay("200x200,300x300"); | |
| 714 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | |
| 715 | |
| 716 aura::Env* env = aura::Env::GetInstance(); | |
| 717 | |
| 718 ui::test::EventGenerator generator(root_windows[0]); | |
| 719 | |
| 720 // Set the initial position. | |
| 721 generator.MoveMouseToInHost(350, 150); | |
| 722 EXPECT_EQ("350,150", env->last_mouse_location().ToString()); | |
| 723 | |
| 724 // A mouse pointer will stay in the 2nd display. | |
| 725 UpdateDisplay("300x300,200x200"); | |
| 726 EXPECT_EQ("450,50", env->last_mouse_location().ToString()); | |
| 727 | |
| 728 // A mouse pointer will be outside of displays and move to the | |
| 729 // center of 2nd display. | |
| 730 UpdateDisplay("300x300,100x100"); | |
| 731 EXPECT_EQ("350,50", env->last_mouse_location().ToString()); | |
| 732 | |
| 733 // 2nd display was disconnected, and the cursor is | |
| 734 // now in the 1st display. | |
| 735 UpdateDisplay("400x400"); | |
| 736 EXPECT_EQ("50,350", env->last_mouse_location().ToString()); | |
| 737 | |
| 738 // 1st display's resolution has changed, and the mouse pointer is | |
| 739 // now outside. Move the mouse pointer to the center of 1st display. | |
| 740 UpdateDisplay("300x300"); | |
| 741 EXPECT_EQ("150,150", env->last_mouse_location().ToString()); | |
| 742 | |
| 743 // Move the mouse pointer to the bottom of 1st display. | |
| 744 generator.MoveMouseToInHost(150, 290); | |
| 745 EXPECT_EQ("150,290", env->last_mouse_location().ToString()); | |
| 746 | |
| 747 // The mouse pointer is now on 2nd display. | |
| 748 UpdateDisplay("300x280,200x200"); | |
| 749 EXPECT_EQ("450,10", env->last_mouse_location().ToString()); | |
| 750 } | |
| 751 | |
| 752 TEST_F(DisplayManagerTest, MAYBE_EnsurePointerInDisplays_2ndOnLeft) { | |
| 753 // Set the 2nd display on the left. | |
| 754 DisplayLayoutStore* layout_store = | |
| 755 Shell::GetInstance()->display_manager()->layout_store(); | |
| 756 DisplayLayout layout = layout_store->default_display_layout(); | |
| 757 layout.position = DisplayLayout::LEFT; | |
| 758 layout_store->SetDefaultDisplayLayout(layout); | |
| 759 | |
| 760 UpdateDisplay("200x200,300x300"); | |
| 761 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | |
| 762 | |
| 763 EXPECT_EQ("-300,0 300x300", | |
| 764 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | |
| 765 | |
| 766 aura::Env* env = aura::Env::GetInstance(); | |
| 767 | |
| 768 // Set the initial position. | |
| 769 root_windows[0]->MoveCursorTo(gfx::Point(-150, 250)); | |
| 770 EXPECT_EQ("-150,250", env->last_mouse_location().ToString()); | |
| 771 | |
| 772 // A mouse pointer will stay in 2nd display. | |
| 773 UpdateDisplay("300x300,200x300"); | |
| 774 EXPECT_EQ("-50,150", env->last_mouse_location().ToString()); | |
| 775 | |
| 776 // A mouse pointer will be outside of displays and move to the | |
| 777 // center of 2nd display. | |
| 778 UpdateDisplay("300x300,200x100"); | |
| 779 EXPECT_EQ("-100,50", env->last_mouse_location().ToString()); | |
| 780 | |
| 781 // 2nd display was disconnected. Mouse pointer should move to | |
| 782 // 1st display. | |
| 783 UpdateDisplay("300x300"); | |
| 784 EXPECT_EQ("150,150", env->last_mouse_location().ToString()); | |
| 785 } | |
| 786 | |
| 787 TEST_F(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) { | 703 TEST_F(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) { |
| 788 if (!SupportsMultipleDisplays()) | 704 if (!SupportsMultipleDisplays()) |
| 789 return; | 705 return; |
| 790 | 706 |
| 791 const int64 internal_display_id = | 707 const int64 internal_display_id = |
| 792 test::DisplayManagerTestApi(display_manager()). | 708 test::DisplayManagerTestApi(display_manager()). |
| 793 SetFirstDisplayAsInternalDisplay(); | 709 SetFirstDisplayAsInternalDisplay(); |
| 794 const DisplayInfo native_display_info = | 710 const DisplayInfo native_display_info = |
| 795 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); | 711 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); |
| 796 const DisplayInfo secondary_display_info = | 712 const DisplayInfo secondary_display_info = |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1674 1.25f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 1590 1.25f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 1675 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); | 1591 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); |
| 1676 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); | 1592 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); |
| 1677 | 1593 |
| 1678 DisplayInfo::SetUse125DSFForUIScaling(false); | 1594 DisplayInfo::SetUse125DSFForUIScaling(false); |
| 1679 } | 1595 } |
| 1680 | 1596 |
| 1681 #endif // OS_CHROMEOS | 1597 #endif // OS_CHROMEOS |
| 1682 | 1598 |
| 1683 } // namespace ash | 1599 } // namespace ash |
| OLD | NEW |