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