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/window_tree_host_manager.h" | 5 #include "ash/display/window_tree_host_manager.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/display/display_info.h" | 8 #include "ash/display/display_info.h" |
9 #include "ash/display/display_layout_store.h" | 9 #include "ash/display/display_layout_store.h" |
10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 : changing_count_(0), | 64 : changing_count_(0), |
65 changed_count_(0), | 65 changed_count_(0), |
66 bounds_changed_count_(0), | 66 bounds_changed_count_(0), |
67 rotation_changed_count_(0), | 67 rotation_changed_count_(0), |
68 workarea_changed_count_(0), | 68 workarea_changed_count_(0), |
69 primary_changed_count_(0), | 69 primary_changed_count_(0), |
70 changed_display_id_(0), | 70 changed_display_id_(0), |
71 focus_changed_count_(0), | 71 focus_changed_count_(0), |
72 activation_changed_count_(0) { | 72 activation_changed_count_(0) { |
73 Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); | 73 Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); |
74 Shell::GetScreen()->AddObserver(this); | 74 gfx::Screen::GetScreen()->AddObserver(this); |
75 aura::client::GetFocusClient(Shell::GetPrimaryRootWindow()) | 75 aura::client::GetFocusClient(Shell::GetPrimaryRootWindow()) |
76 ->AddObserver(this); | 76 ->AddObserver(this); |
77 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow()) | 77 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow()) |
78 ->AddObserver(this); | 78 ->AddObserver(this); |
79 } | 79 } |
80 | 80 |
81 ~TestObserver() override { | 81 ~TestObserver() override { |
82 Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); | 82 Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); |
83 Shell::GetScreen()->RemoveObserver(this); | 83 gfx::Screen::GetScreen()->RemoveObserver(this); |
84 aura::client::GetFocusClient(Shell::GetPrimaryRootWindow()) | 84 aura::client::GetFocusClient(Shell::GetPrimaryRootWindow()) |
85 ->RemoveObserver(this); | 85 ->RemoveObserver(this); |
86 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow()) | 86 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow()) |
87 ->RemoveObserver(this); | 87 ->RemoveObserver(this); |
88 } | 88 } |
89 | 89 |
90 // Overridden from WindowTreeHostManager::Observer | 90 // Overridden from WindowTreeHostManager::Observer |
91 void OnDisplayConfigurationChanging() override { ++changing_count_; } | 91 void OnDisplayConfigurationChanging() override { ++changing_count_; } |
92 void OnDisplayConfigurationChanged() override { ++changed_count_; } | 92 void OnDisplayConfigurationChanged() override { ++changed_count_; } |
93 | 93 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 int primary_changed_count_; | 167 int primary_changed_count_; |
168 int64_t changed_display_id_; | 168 int64_t changed_display_id_; |
169 | 169 |
170 int focus_changed_count_; | 170 int focus_changed_count_; |
171 int activation_changed_count_; | 171 int activation_changed_count_; |
172 | 172 |
173 DISALLOW_COPY_AND_ASSIGN(TestObserver); | 173 DISALLOW_COPY_AND_ASSIGN(TestObserver); |
174 }; | 174 }; |
175 | 175 |
176 gfx::Display GetPrimaryDisplay() { | 176 gfx::Display GetPrimaryDisplay() { |
177 return Shell::GetScreen()->GetDisplayNearestWindow( | 177 return gfx::Screen::GetScreen()->GetDisplayNearestWindow( |
178 Shell::GetAllRootWindows()[0]); | 178 Shell::GetAllRootWindows()[0]); |
179 } | 179 } |
180 | 180 |
181 gfx::Display GetSecondaryDisplay() { | 181 gfx::Display GetSecondaryDisplay() { |
182 return Shell::GetScreen()->GetDisplayNearestWindow( | 182 return gfx::Screen::GetScreen()->GetDisplayNearestWindow( |
183 Shell::GetAllRootWindows()[1]); | 183 Shell::GetAllRootWindows()[1]); |
184 } | 184 } |
185 | 185 |
186 void SetSecondaryDisplayLayoutAndOffset(DisplayLayout::Position position, | 186 void SetSecondaryDisplayLayoutAndOffset(DisplayLayout::Position position, |
187 int offset) { | 187 int offset) { |
188 DisplayLayout layout(position, offset); | 188 DisplayLayout layout(position, offset); |
189 ASSERT_GT(Shell::GetScreen()->GetNumDisplays(), 1); | 189 ASSERT_GT(gfx::Screen::GetScreen()->GetNumDisplays(), 1); |
190 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays(layout); | 190 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays(layout); |
191 } | 191 } |
192 | 192 |
193 void SetSecondaryDisplayLayout(DisplayLayout::Position position) { | 193 void SetSecondaryDisplayLayout(DisplayLayout::Position position) { |
194 SetSecondaryDisplayLayoutAndOffset(position, 0); | 194 SetSecondaryDisplayLayoutAndOffset(position, 0); |
195 } | 195 } |
196 | 196 |
197 void SetDefaultDisplayLayout(DisplayLayout::Position position) { | 197 void SetDefaultDisplayLayout(DisplayLayout::Position position) { |
198 Shell::GetInstance() | 198 Shell::GetInstance() |
199 ->display_manager() | 199 ->display_manager() |
200 ->layout_store() | 200 ->layout_store() |
201 ->SetDefaultDisplayLayout(DisplayLayout(position, 0)); | 201 ->SetDefaultDisplayLayout(DisplayLayout(position, 0)); |
202 } | 202 } |
203 | 203 |
204 class WindowTreeHostManagerShutdownTest : public test::AshTestBase { | 204 class WindowTreeHostManagerShutdownTest : public test::AshTestBase { |
205 public: | 205 public: |
206 WindowTreeHostManagerShutdownTest() {} | 206 WindowTreeHostManagerShutdownTest() {} |
207 ~WindowTreeHostManagerShutdownTest() override {} | 207 ~WindowTreeHostManagerShutdownTest() override {} |
208 | 208 |
209 void TearDown() override { | 209 void TearDown() override { |
210 test::AshTestBase::TearDown(); | 210 test::AshTestBase::TearDown(); |
211 if (!SupportsMultipleDisplays()) | 211 if (!SupportsMultipleDisplays()) |
212 return; | 212 return; |
213 | 213 |
214 // Make sure that primary display is accessible after shutdown. | 214 // Make sure that primary display is accessible after shutdown. |
215 gfx::Display primary = Shell::GetScreen()->GetPrimaryDisplay(); | 215 gfx::Display primary = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
216 EXPECT_EQ("0,0 444x333", primary.bounds().ToString()); | 216 EXPECT_EQ("0,0 444x333", primary.bounds().ToString()); |
217 EXPECT_EQ(2, Shell::GetScreen()->GetNumDisplays()); | 217 EXPECT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays()); |
218 } | 218 } |
219 | 219 |
220 private: | 220 private: |
221 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostManagerShutdownTest); | 221 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostManagerShutdownTest); |
222 }; | 222 }; |
223 | 223 |
224 class StartupHelper : public test::TestShellDelegate, | 224 class StartupHelper : public test::TestShellDelegate, |
225 public WindowTreeHostManager::Observer { | 225 public WindowTreeHostManager::Observer { |
226 public: | 226 public: |
227 StartupHelper() : displays_initialized_(false) {} | 227 StartupHelper() : displays_initialized_(false) {} |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 633 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
634 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 634 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
635 EXPECT_EQ("0,0 400x400", GetPrimaryDisplay().bounds().ToString()); | 635 EXPECT_EQ("0,0 400x400", GetPrimaryDisplay().bounds().ToString()); |
636 EXPECT_EQ("0,400 300x300", GetSecondaryDisplay().bounds().ToString()); | 636 EXPECT_EQ("0,400 300x300", GetSecondaryDisplay().bounds().ToString()); |
637 | 637 |
638 UpdateDisplay("400x400"); | 638 UpdateDisplay("400x400"); |
639 EXPECT_EQ(1, observer.CountAndReset()); | 639 EXPECT_EQ(1, observer.CountAndReset()); |
640 EXPECT_LE(1, observer.GetFocusChangedCountAndReset()); | 640 EXPECT_LE(1, observer.GetFocusChangedCountAndReset()); |
641 EXPECT_LE(1, observer.GetActivationChangedCountAndReset()); | 641 EXPECT_LE(1, observer.GetActivationChangedCountAndReset()); |
642 EXPECT_EQ("0,0 400x400", GetPrimaryDisplay().bounds().ToString()); | 642 EXPECT_EQ("0,0 400x400", GetPrimaryDisplay().bounds().ToString()); |
643 EXPECT_EQ(1, Shell::GetScreen()->GetNumDisplays()); | 643 EXPECT_EQ(1, gfx::Screen::GetScreen()->GetNumDisplays()); |
644 | 644 |
645 UpdateDisplay("400x500*2,300x300"); | 645 UpdateDisplay("400x500*2,300x300"); |
646 EXPECT_EQ(1, observer.CountAndReset()); | 646 EXPECT_EQ(1, observer.CountAndReset()); |
647 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 647 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
648 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 648 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
649 ASSERT_EQ(2, Shell::GetScreen()->GetNumDisplays()); | 649 ASSERT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays()); |
650 EXPECT_EQ("0,0 200x250", GetPrimaryDisplay().bounds().ToString()); | 650 EXPECT_EQ("0,0 200x250", GetPrimaryDisplay().bounds().ToString()); |
651 EXPECT_EQ("0,250 300x300", GetSecondaryDisplay().bounds().ToString()); | 651 EXPECT_EQ("0,250 300x300", GetSecondaryDisplay().bounds().ToString()); |
652 | 652 |
653 // No change | 653 // No change |
654 UpdateDisplay("400x500*2,300x300"); | 654 UpdateDisplay("400x500*2,300x300"); |
655 // We still call into Pre/PostDisplayConfigurationChange(). | 655 // We still call into Pre/PostDisplayConfigurationChange(). |
656 EXPECT_EQ(1, observer.CountAndReset()); | 656 EXPECT_EQ(1, observer.CountAndReset()); |
657 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 657 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
658 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 658 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
659 | 659 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 | 706 |
707 TEST_F(WindowTreeHostManagerTest, SwapPrimary) { | 707 TEST_F(WindowTreeHostManagerTest, SwapPrimary) { |
708 if (!SupportsMultipleDisplays()) | 708 if (!SupportsMultipleDisplays()) |
709 return; | 709 return; |
710 | 710 |
711 WindowTreeHostManager* window_tree_host_manager = | 711 WindowTreeHostManager* window_tree_host_manager = |
712 Shell::GetInstance()->window_tree_host_manager(); | 712 Shell::GetInstance()->window_tree_host_manager(); |
713 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 713 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
714 | 714 |
715 UpdateDisplay("200x200,300x300"); | 715 UpdateDisplay("200x200,300x300"); |
716 gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay(); | 716 gfx::Display primary_display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
717 gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); | 717 gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); |
718 | 718 |
719 DisplayLayout display_layout(DisplayLayout::RIGHT, 50); | 719 DisplayLayout display_layout(DisplayLayout::RIGHT, 50); |
720 display_manager->SetLayoutForCurrentDisplays(display_layout); | 720 display_manager->SetLayoutForCurrentDisplays(display_layout); |
721 | 721 |
722 EXPECT_NE(primary_display.id(), secondary_display.id()); | 722 EXPECT_NE(primary_display.id(), secondary_display.id()); |
723 aura::Window* primary_root = | 723 aura::Window* primary_root = |
724 window_tree_host_manager->GetRootWindowForDisplayId(primary_display.id()); | 724 window_tree_host_manager->GetRootWindowForDisplayId(primary_display.id()); |
725 aura::Window* secondary_root = | 725 aura::Window* secondary_root = |
726 window_tree_host_manager->GetRootWindowForDisplayId( | 726 window_tree_host_manager->GetRootWindowForDisplayId( |
727 secondary_display.id()); | 727 secondary_display.id()); |
728 EXPECT_NE(primary_root, secondary_root); | 728 EXPECT_NE(primary_root, secondary_root); |
729 aura::Window* shelf_window = | 729 aura::Window* shelf_window = |
730 Shelf::ForPrimaryDisplay()->shelf_widget()->GetNativeView(); | 730 Shelf::ForPrimaryDisplay()->shelf_widget()->GetNativeView(); |
731 EXPECT_TRUE(primary_root->Contains(shelf_window)); | 731 EXPECT_TRUE(primary_root->Contains(shelf_window)); |
732 EXPECT_FALSE(secondary_root->Contains(shelf_window)); | 732 EXPECT_FALSE(secondary_root->Contains(shelf_window)); |
733 EXPECT_EQ( | |
734 primary_display.id(), | |
735 Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(-100, -100)).id()); | |
736 EXPECT_EQ(primary_display.id(), | 733 EXPECT_EQ(primary_display.id(), |
737 Shell::GetScreen()->GetDisplayNearestWindow(NULL).id()); | 734 gfx::Screen::GetScreen() |
| 735 ->GetDisplayNearestPoint(gfx::Point(-100, -100)) |
| 736 .id()); |
| 737 EXPECT_EQ(primary_display.id(), |
| 738 gfx::Screen::GetScreen()->GetDisplayNearestWindow(NULL).id()); |
738 | 739 |
739 EXPECT_EQ("0,0 200x200", primary_display.bounds().ToString()); | 740 EXPECT_EQ("0,0 200x200", primary_display.bounds().ToString()); |
740 EXPECT_EQ("0,0 200x153", primary_display.work_area().ToString()); | 741 EXPECT_EQ("0,0 200x153", primary_display.work_area().ToString()); |
741 EXPECT_EQ("200,0 300x300", secondary_display.bounds().ToString()); | 742 EXPECT_EQ("200,0 300x300", secondary_display.bounds().ToString()); |
742 EXPECT_EQ("200,0 300x253", secondary_display.work_area().ToString()); | 743 EXPECT_EQ("200,0 300x253", secondary_display.work_area().ToString()); |
743 EXPECT_EQ("right, 50", display_manager->GetCurrentDisplayLayout().ToString()); | 744 EXPECT_EQ("right, 50", display_manager->GetCurrentDisplayLayout().ToString()); |
744 | 745 |
745 // Switch primary and secondary | 746 // Switch primary and secondary |
746 window_tree_host_manager->SetPrimaryDisplay(secondary_display); | 747 window_tree_host_manager->SetPrimaryDisplay(secondary_display); |
747 const DisplayLayout& inverted_layout = | 748 const DisplayLayout& inverted_layout = |
748 display_manager->GetCurrentDisplayLayout(); | 749 display_manager->GetCurrentDisplayLayout(); |
749 EXPECT_EQ("left, -50", inverted_layout.ToString()); | 750 EXPECT_EQ("left, -50", inverted_layout.ToString()); |
750 | 751 |
751 EXPECT_EQ(secondary_display.id(), | 752 EXPECT_EQ(secondary_display.id(), |
752 Shell::GetScreen()->GetPrimaryDisplay().id()); | 753 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); |
753 EXPECT_EQ(primary_display.id(), ScreenUtil::GetSecondaryDisplay().id()); | 754 EXPECT_EQ(primary_display.id(), ScreenUtil::GetSecondaryDisplay().id()); |
754 EXPECT_EQ( | 755 EXPECT_EQ(primary_display.id(), |
755 primary_display.id(), | 756 gfx::Screen::GetScreen() |
756 Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(-100, -100)).id()); | 757 ->GetDisplayNearestPoint(gfx::Point(-100, -100)) |
| 758 .id()); |
757 EXPECT_EQ(secondary_display.id(), | 759 EXPECT_EQ(secondary_display.id(), |
758 Shell::GetScreen()->GetDisplayNearestWindow(NULL).id()); | 760 gfx::Screen::GetScreen()->GetDisplayNearestWindow(NULL).id()); |
759 | 761 |
760 EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( | 762 EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( |
761 secondary_display.id())); | 763 secondary_display.id())); |
762 EXPECT_EQ(secondary_root, window_tree_host_manager->GetRootWindowForDisplayId( | 764 EXPECT_EQ(secondary_root, window_tree_host_manager->GetRootWindowForDisplayId( |
763 primary_display.id())); | 765 primary_display.id())); |
764 EXPECT_TRUE(primary_root->Contains(shelf_window)); | 766 EXPECT_TRUE(primary_root->Contains(shelf_window)); |
765 EXPECT_FALSE(secondary_root->Contains(shelf_window)); | 767 EXPECT_FALSE(secondary_root->Contains(shelf_window)); |
766 | 768 |
767 // Test if the bounds are correctly swapped. | 769 // Test if the bounds are correctly swapped. |
768 gfx::Display swapped_primary = Shell::GetScreen()->GetPrimaryDisplay(); | 770 gfx::Display swapped_primary = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
769 gfx::Display swapped_secondary = ScreenUtil::GetSecondaryDisplay(); | 771 gfx::Display swapped_secondary = ScreenUtil::GetSecondaryDisplay(); |
770 EXPECT_EQ("0,0 300x300", swapped_primary.bounds().ToString()); | 772 EXPECT_EQ("0,0 300x300", swapped_primary.bounds().ToString()); |
771 EXPECT_EQ("0,0 300x253", swapped_primary.work_area().ToString()); | 773 EXPECT_EQ("0,0 300x253", swapped_primary.work_area().ToString()); |
772 EXPECT_EQ("-200,-50 200x200", swapped_secondary.bounds().ToString()); | 774 EXPECT_EQ("-200,-50 200x200", swapped_secondary.bounds().ToString()); |
773 | 775 |
774 EXPECT_EQ("-200,-50 200x153", swapped_secondary.work_area().ToString()); | 776 EXPECT_EQ("-200,-50 200x153", swapped_secondary.work_area().ToString()); |
775 | 777 |
776 aura::WindowTracker tracker; | 778 aura::WindowTracker tracker; |
777 tracker.Add(primary_root); | 779 tracker.Add(primary_root); |
778 tracker.Add(secondary_root); | 780 tracker.Add(secondary_root); |
779 | 781 |
780 // Deleting 2nd display should move the primary to original primary display. | 782 // Deleting 2nd display should move the primary to original primary display. |
781 UpdateDisplay("200x200"); | 783 UpdateDisplay("200x200"); |
782 RunAllPendingInMessageLoop(); // RootWindow is deleted in a posted task. | 784 RunAllPendingInMessageLoop(); // RootWindow is deleted in a posted task. |
783 EXPECT_EQ(1, Shell::GetScreen()->GetNumDisplays()); | 785 EXPECT_EQ(1, gfx::Screen::GetScreen()->GetNumDisplays()); |
784 EXPECT_EQ(primary_display.id(), Shell::GetScreen()->GetPrimaryDisplay().id()); | |
785 EXPECT_EQ( | |
786 primary_display.id(), | |
787 Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(-100, -100)).id()); | |
788 EXPECT_EQ(primary_display.id(), | 786 EXPECT_EQ(primary_display.id(), |
789 Shell::GetScreen()->GetDisplayNearestWindow(NULL).id()); | 787 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); |
| 788 EXPECT_EQ(primary_display.id(), |
| 789 gfx::Screen::GetScreen() |
| 790 ->GetDisplayNearestPoint(gfx::Point(-100, -100)) |
| 791 .id()); |
| 792 EXPECT_EQ(primary_display.id(), |
| 793 gfx::Screen::GetScreen()->GetDisplayNearestWindow(NULL).id()); |
790 EXPECT_TRUE(tracker.Contains(primary_root)); | 794 EXPECT_TRUE(tracker.Contains(primary_root)); |
791 EXPECT_FALSE(tracker.Contains(secondary_root)); | 795 EXPECT_FALSE(tracker.Contains(secondary_root)); |
792 EXPECT_TRUE(primary_root->Contains(shelf_window)); | 796 EXPECT_TRUE(primary_root->Contains(shelf_window)); |
793 } | 797 } |
794 | 798 |
795 TEST_F(WindowTreeHostManagerTest, FindNearestDisplay) { | 799 TEST_F(WindowTreeHostManagerTest, FindNearestDisplay) { |
796 if (!SupportsMultipleDisplays()) | 800 if (!SupportsMultipleDisplays()) |
797 return; | 801 return; |
798 | 802 |
799 WindowTreeHostManager* window_tree_host_manager = | 803 WindowTreeHostManager* window_tree_host_manager = |
800 Shell::GetInstance()->window_tree_host_manager(); | 804 Shell::GetInstance()->window_tree_host_manager(); |
801 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 805 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
802 | 806 |
803 UpdateDisplay("200x200,300x300"); | 807 UpdateDisplay("200x200,300x300"); |
804 DisplayLayout display_layout(DisplayLayout::RIGHT, 50); | 808 DisplayLayout display_layout(DisplayLayout::RIGHT, 50); |
805 display_manager->SetLayoutForCurrentDisplays(display_layout); | 809 display_manager->SetLayoutForCurrentDisplays(display_layout); |
806 | 810 |
807 gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay(); | 811 gfx::Display primary_display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
808 gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); | 812 gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); |
809 EXPECT_NE(primary_display.id(), secondary_display.id()); | 813 EXPECT_NE(primary_display.id(), secondary_display.id()); |
810 aura::Window* primary_root = | 814 aura::Window* primary_root = |
811 window_tree_host_manager->GetRootWindowForDisplayId(primary_display.id()); | 815 window_tree_host_manager->GetRootWindowForDisplayId(primary_display.id()); |
812 aura::Window* secondary_root = | 816 aura::Window* secondary_root = |
813 window_tree_host_manager->GetRootWindowForDisplayId( | 817 window_tree_host_manager->GetRootWindowForDisplayId( |
814 secondary_display.id()); | 818 secondary_display.id()); |
815 EXPECT_NE(primary_root, secondary_root); | 819 EXPECT_NE(primary_root, secondary_root); |
816 | 820 |
817 // Test that points outside of any display return the nearest display. | 821 // Test that points outside of any display return the nearest display. |
818 EXPECT_EQ( | 822 EXPECT_EQ(primary_display.id(), |
819 primary_display.id(), | 823 gfx::Screen::GetScreen() |
820 Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(-100, 0)).id()); | 824 ->GetDisplayNearestPoint(gfx::Point(-100, 0)) |
821 EXPECT_EQ( | 825 .id()); |
822 primary_display.id(), | 826 EXPECT_EQ(primary_display.id(), |
823 Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(0, -100)).id()); | 827 gfx::Screen::GetScreen() |
824 EXPECT_EQ( | 828 ->GetDisplayNearestPoint(gfx::Point(0, -100)) |
825 primary_display.id(), | 829 .id()); |
826 Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(100, 100)).id()); | 830 EXPECT_EQ(primary_display.id(), |
827 EXPECT_EQ( | 831 gfx::Screen::GetScreen() |
828 primary_display.id(), | 832 ->GetDisplayNearestPoint(gfx::Point(100, 100)) |
829 Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(224, 25)).id()); | 833 .id()); |
830 EXPECT_EQ( | 834 EXPECT_EQ(primary_display.id(), |
831 secondary_display.id(), | 835 gfx::Screen::GetScreen() |
832 Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(226, 25)).id()); | 836 ->GetDisplayNearestPoint(gfx::Point(224, 25)) |
833 EXPECT_EQ( | 837 .id()); |
834 secondary_display.id(), | 838 EXPECT_EQ(secondary_display.id(), |
835 Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(600, 100)).id()); | 839 gfx::Screen::GetScreen() |
836 EXPECT_EQ( | 840 ->GetDisplayNearestPoint(gfx::Point(226, 25)) |
837 primary_display.id(), | 841 .id()); |
838 Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(174, 225)).id()); | 842 EXPECT_EQ(secondary_display.id(), |
839 EXPECT_EQ( | 843 gfx::Screen::GetScreen() |
840 secondary_display.id(), | 844 ->GetDisplayNearestPoint(gfx::Point(600, 100)) |
841 Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(176, 225)).id()); | 845 .id()); |
842 EXPECT_EQ( | 846 EXPECT_EQ(primary_display.id(), |
843 secondary_display.id(), | 847 gfx::Screen::GetScreen() |
844 Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(300, 400)).id()); | 848 ->GetDisplayNearestPoint(gfx::Point(174, 225)) |
| 849 .id()); |
| 850 EXPECT_EQ(secondary_display.id(), |
| 851 gfx::Screen::GetScreen() |
| 852 ->GetDisplayNearestPoint(gfx::Point(176, 225)) |
| 853 .id()); |
| 854 EXPECT_EQ(secondary_display.id(), |
| 855 gfx::Screen::GetScreen() |
| 856 ->GetDisplayNearestPoint(gfx::Point(300, 400)) |
| 857 .id()); |
845 } | 858 } |
846 | 859 |
847 TEST_F(WindowTreeHostManagerTest, SwapPrimaryById) { | 860 TEST_F(WindowTreeHostManagerTest, SwapPrimaryById) { |
848 if (!SupportsMultipleDisplays()) | 861 if (!SupportsMultipleDisplays()) |
849 return; | 862 return; |
850 | 863 |
851 WindowTreeHostManager* window_tree_host_manager = | 864 WindowTreeHostManager* window_tree_host_manager = |
852 Shell::GetInstance()->window_tree_host_manager(); | 865 Shell::GetInstance()->window_tree_host_manager(); |
853 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 866 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
854 | 867 |
855 UpdateDisplay("200x200,300x300"); | 868 UpdateDisplay("200x200,300x300"); |
856 gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay(); | 869 gfx::Display primary_display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
857 gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); | 870 gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); |
858 | 871 |
859 DisplayLayout display_layout(DisplayLayout::RIGHT, 50); | 872 DisplayLayout display_layout(DisplayLayout::RIGHT, 50); |
860 display_manager->SetLayoutForCurrentDisplays(display_layout); | 873 display_manager->SetLayoutForCurrentDisplays(display_layout); |
861 | 874 |
862 EXPECT_NE(primary_display.id(), secondary_display.id()); | 875 EXPECT_NE(primary_display.id(), secondary_display.id()); |
863 aura::Window* primary_root = | 876 aura::Window* primary_root = |
864 window_tree_host_manager->GetRootWindowForDisplayId(primary_display.id()); | 877 window_tree_host_manager->GetRootWindowForDisplayId(primary_display.id()); |
865 aura::Window* secondary_root = | 878 aura::Window* secondary_root = |
866 window_tree_host_manager->GetRootWindowForDisplayId( | 879 window_tree_host_manager->GetRootWindowForDisplayId( |
867 secondary_display.id()); | 880 secondary_display.id()); |
868 aura::Window* shelf_window = | 881 aura::Window* shelf_window = |
869 Shelf::ForPrimaryDisplay()->shelf_widget()->GetNativeView(); | 882 Shelf::ForPrimaryDisplay()->shelf_widget()->GetNativeView(); |
870 EXPECT_TRUE(primary_root->Contains(shelf_window)); | 883 EXPECT_TRUE(primary_root->Contains(shelf_window)); |
871 EXPECT_FALSE(secondary_root->Contains(shelf_window)); | 884 EXPECT_FALSE(secondary_root->Contains(shelf_window)); |
872 EXPECT_NE(primary_root, secondary_root); | 885 EXPECT_NE(primary_root, secondary_root); |
873 EXPECT_EQ( | |
874 primary_display.id(), | |
875 Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(-100, -100)).id()); | |
876 EXPECT_EQ(primary_display.id(), | 886 EXPECT_EQ(primary_display.id(), |
877 Shell::GetScreen()->GetDisplayNearestWindow(NULL).id()); | 887 gfx::Screen::GetScreen() |
| 888 ->GetDisplayNearestPoint(gfx::Point(-100, -100)) |
| 889 .id()); |
| 890 EXPECT_EQ(primary_display.id(), |
| 891 gfx::Screen::GetScreen()->GetDisplayNearestWindow(NULL).id()); |
878 | 892 |
879 // Switch primary and secondary by display ID. | 893 // Switch primary and secondary by display ID. |
880 TestObserver observer; | 894 TestObserver observer; |
881 window_tree_host_manager->SetPrimaryDisplayId(secondary_display.id()); | 895 window_tree_host_manager->SetPrimaryDisplayId(secondary_display.id()); |
882 EXPECT_EQ(secondary_display.id(), | 896 EXPECT_EQ(secondary_display.id(), |
883 Shell::GetScreen()->GetPrimaryDisplay().id()); | 897 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); |
884 EXPECT_EQ(primary_display.id(), ScreenUtil::GetSecondaryDisplay().id()); | 898 EXPECT_EQ(primary_display.id(), ScreenUtil::GetSecondaryDisplay().id()); |
885 EXPECT_LT(0, observer.CountAndReset()); | 899 EXPECT_LT(0, observer.CountAndReset()); |
886 | 900 |
887 EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( | 901 EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( |
888 secondary_display.id())); | 902 secondary_display.id())); |
889 EXPECT_EQ(secondary_root, window_tree_host_manager->GetRootWindowForDisplayId( | 903 EXPECT_EQ(secondary_root, window_tree_host_manager->GetRootWindowForDisplayId( |
890 primary_display.id())); | 904 primary_display.id())); |
891 EXPECT_TRUE(primary_root->Contains(shelf_window)); | 905 EXPECT_TRUE(primary_root->Contains(shelf_window)); |
892 EXPECT_FALSE(secondary_root->Contains(shelf_window)); | 906 EXPECT_FALSE(secondary_root->Contains(shelf_window)); |
893 | 907 |
894 const DisplayLayout& inverted_layout = | 908 const DisplayLayout& inverted_layout = |
895 display_manager->GetCurrentDisplayLayout(); | 909 display_manager->GetCurrentDisplayLayout(); |
896 | 910 |
897 EXPECT_EQ("left, -50", inverted_layout.ToString()); | 911 EXPECT_EQ("left, -50", inverted_layout.ToString()); |
898 | 912 |
899 // Calling the same ID don't do anything. | 913 // Calling the same ID don't do anything. |
900 window_tree_host_manager->SetPrimaryDisplayId(secondary_display.id()); | 914 window_tree_host_manager->SetPrimaryDisplayId(secondary_display.id()); |
901 EXPECT_EQ(0, observer.CountAndReset()); | 915 EXPECT_EQ(0, observer.CountAndReset()); |
902 | 916 |
903 aura::WindowTracker tracker; | 917 aura::WindowTracker tracker; |
904 tracker.Add(primary_root); | 918 tracker.Add(primary_root); |
905 tracker.Add(secondary_root); | 919 tracker.Add(secondary_root); |
906 | 920 |
907 // Deleting 2nd display should move the primary to original primary display. | 921 // Deleting 2nd display should move the primary to original primary display. |
908 UpdateDisplay("200x200"); | 922 UpdateDisplay("200x200"); |
909 RunAllPendingInMessageLoop(); // RootWindow is deleted in a posted task. | 923 RunAllPendingInMessageLoop(); // RootWindow is deleted in a posted task. |
910 EXPECT_EQ(1, Shell::GetScreen()->GetNumDisplays()); | 924 EXPECT_EQ(1, gfx::Screen::GetScreen()->GetNumDisplays()); |
911 EXPECT_EQ(primary_display.id(), Shell::GetScreen()->GetPrimaryDisplay().id()); | |
912 EXPECT_EQ( | |
913 primary_display.id(), | |
914 Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(-100, -100)).id()); | |
915 EXPECT_EQ(primary_display.id(), | 925 EXPECT_EQ(primary_display.id(), |
916 Shell::GetScreen()->GetDisplayNearestWindow(NULL).id()); | 926 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); |
| 927 EXPECT_EQ(primary_display.id(), |
| 928 gfx::Screen::GetScreen() |
| 929 ->GetDisplayNearestPoint(gfx::Point(-100, -100)) |
| 930 .id()); |
| 931 EXPECT_EQ(primary_display.id(), |
| 932 gfx::Screen::GetScreen()->GetDisplayNearestWindow(NULL).id()); |
917 EXPECT_TRUE(tracker.Contains(primary_root)); | 933 EXPECT_TRUE(tracker.Contains(primary_root)); |
918 EXPECT_FALSE(tracker.Contains(secondary_root)); | 934 EXPECT_FALSE(tracker.Contains(secondary_root)); |
919 EXPECT_TRUE(primary_root->Contains(shelf_window)); | 935 EXPECT_TRUE(primary_root->Contains(shelf_window)); |
920 | 936 |
921 // Adding 2nd display with the same ID. The 2nd display should become primary | 937 // Adding 2nd display with the same ID. The 2nd display should become primary |
922 // since secondary id is still stored as desirable_primary_id. | 938 // since secondary id is still stored as desirable_primary_id. |
923 std::vector<DisplayInfo> display_info_list; | 939 std::vector<DisplayInfo> display_info_list; |
924 display_info_list.push_back( | 940 display_info_list.push_back( |
925 display_manager->GetDisplayInfo(primary_display.id())); | 941 display_manager->GetDisplayInfo(primary_display.id())); |
926 display_info_list.push_back( | 942 display_info_list.push_back( |
927 display_manager->GetDisplayInfo(secondary_display.id())); | 943 display_manager->GetDisplayInfo(secondary_display.id())); |
928 display_manager->OnNativeDisplaysChanged(display_info_list); | 944 display_manager->OnNativeDisplaysChanged(display_info_list); |
929 | 945 |
930 EXPECT_EQ(2, Shell::GetScreen()->GetNumDisplays()); | 946 EXPECT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays()); |
931 EXPECT_EQ(secondary_display.id(), | 947 EXPECT_EQ(secondary_display.id(), |
932 Shell::GetScreen()->GetPrimaryDisplay().id()); | 948 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); |
933 EXPECT_EQ(primary_display.id(), ScreenUtil::GetSecondaryDisplay().id()); | 949 EXPECT_EQ(primary_display.id(), ScreenUtil::GetSecondaryDisplay().id()); |
934 EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( | 950 EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( |
935 secondary_display.id())); | 951 secondary_display.id())); |
936 EXPECT_NE(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( | 952 EXPECT_NE(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( |
937 primary_display.id())); | 953 primary_display.id())); |
938 EXPECT_TRUE(primary_root->Contains(shelf_window)); | 954 EXPECT_TRUE(primary_root->Contains(shelf_window)); |
939 | 955 |
940 // Deleting 2nd display and adding 2nd display with a different ID. The 2nd | 956 // Deleting 2nd display and adding 2nd display with a different ID. The 2nd |
941 // display shouldn't become primary. | 957 // display shouldn't become primary. |
942 UpdateDisplay("200x200"); | 958 UpdateDisplay("200x200"); |
943 DisplayInfo third_display_info(secondary_display.id() + 1, std::string(), | 959 DisplayInfo third_display_info(secondary_display.id() + 1, std::string(), |
944 false); | 960 false); |
945 third_display_info.SetBounds(secondary_display.bounds()); | 961 third_display_info.SetBounds(secondary_display.bounds()); |
946 ASSERT_NE(primary_display.id(), third_display_info.id()); | 962 ASSERT_NE(primary_display.id(), third_display_info.id()); |
947 | 963 |
948 const DisplayInfo& primary_display_info = | 964 const DisplayInfo& primary_display_info = |
949 display_manager->GetDisplayInfo(primary_display.id()); | 965 display_manager->GetDisplayInfo(primary_display.id()); |
950 std::vector<DisplayInfo> display_info_list2; | 966 std::vector<DisplayInfo> display_info_list2; |
951 display_info_list2.push_back(primary_display_info); | 967 display_info_list2.push_back(primary_display_info); |
952 display_info_list2.push_back(third_display_info); | 968 display_info_list2.push_back(third_display_info); |
953 display_manager->OnNativeDisplaysChanged(display_info_list2); | 969 display_manager->OnNativeDisplaysChanged(display_info_list2); |
954 EXPECT_EQ(2, Shell::GetScreen()->GetNumDisplays()); | 970 EXPECT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays()); |
955 EXPECT_EQ(primary_display.id(), Shell::GetScreen()->GetPrimaryDisplay().id()); | 971 EXPECT_EQ(primary_display.id(), |
| 972 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); |
956 EXPECT_EQ(third_display_info.id(), ScreenUtil::GetSecondaryDisplay().id()); | 973 EXPECT_EQ(third_display_info.id(), ScreenUtil::GetSecondaryDisplay().id()); |
957 EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( | 974 EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( |
958 primary_display.id())); | 975 primary_display.id())); |
959 EXPECT_NE(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( | 976 EXPECT_NE(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( |
960 third_display_info.id())); | 977 third_display_info.id())); |
961 EXPECT_TRUE(primary_root->Contains(shelf_window)); | 978 EXPECT_TRUE(primary_root->Contains(shelf_window)); |
962 } | 979 } |
963 | 980 |
964 TEST_F(WindowTreeHostManagerTest, OverscanInsets) { | 981 TEST_F(WindowTreeHostManagerTest, OverscanInsets) { |
965 if (!SupportsMultipleDisplays()) | 982 if (!SupportsMultipleDisplays()) |
966 return; | 983 return; |
967 | 984 |
968 WindowTreeHostManager* window_tree_host_manager = | 985 WindowTreeHostManager* window_tree_host_manager = |
969 Shell::GetInstance()->window_tree_host_manager(); | 986 Shell::GetInstance()->window_tree_host_manager(); |
970 TestEventHandler event_handler; | 987 TestEventHandler event_handler; |
971 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 988 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
972 | 989 |
973 UpdateDisplay("120x200,300x400*2"); | 990 UpdateDisplay("120x200,300x400*2"); |
974 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); | 991 gfx::Display display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
975 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 992 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
976 | 993 |
977 window_tree_host_manager->SetOverscanInsets(display1.id(), | 994 window_tree_host_manager->SetOverscanInsets(display1.id(), |
978 gfx::Insets(10, 15, 20, 25)); | 995 gfx::Insets(10, 15, 20, 25)); |
979 EXPECT_EQ("0,0 80x170", root_windows[0]->bounds().ToString()); | 996 EXPECT_EQ("0,0 80x170", root_windows[0]->bounds().ToString()); |
980 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); | 997 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); |
981 EXPECT_EQ("80,0 150x200", | 998 EXPECT_EQ("80,0 150x200", |
982 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 999 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
983 | 1000 |
984 ui::test::EventGenerator generator(root_windows[0]); | 1001 ui::test::EventGenerator generator(root_windows[0]); |
(...skipping 28 matching lines...) Expand all Loading... |
1013 | 1030 |
1014 TEST_F(WindowTreeHostManagerTest, Rotate) { | 1031 TEST_F(WindowTreeHostManagerTest, Rotate) { |
1015 if (!SupportsMultipleDisplays()) | 1032 if (!SupportsMultipleDisplays()) |
1016 return; | 1033 return; |
1017 | 1034 |
1018 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 1035 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
1019 TestEventHandler event_handler; | 1036 TestEventHandler event_handler; |
1020 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 1037 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
1021 | 1038 |
1022 UpdateDisplay("120x200,300x400*2"); | 1039 UpdateDisplay("120x200,300x400*2"); |
1023 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); | 1040 gfx::Display display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
1024 int64_t display2_id = ScreenUtil::GetSecondaryDisplay().id(); | 1041 int64_t display2_id = ScreenUtil::GetSecondaryDisplay().id(); |
1025 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1042 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
1026 ui::test::EventGenerator generator1(root_windows[0]); | 1043 ui::test::EventGenerator generator1(root_windows[0]); |
1027 | 1044 |
1028 TestObserver observer; | 1045 TestObserver observer; |
1029 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); | 1046 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); |
1030 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); | 1047 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); |
1031 EXPECT_EQ("120,0 150x200", | 1048 EXPECT_EQ("120,0 150x200", |
1032 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 1049 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
1033 generator1.MoveMouseToInHost(50, 40); | 1050 generator1.MoveMouseToInHost(50, 40); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1088 | 1105 |
1089 TEST_F(WindowTreeHostManagerTest, ScaleRootWindow) { | 1106 TEST_F(WindowTreeHostManagerTest, ScaleRootWindow) { |
1090 if (!SupportsMultipleDisplays()) | 1107 if (!SupportsMultipleDisplays()) |
1091 return; | 1108 return; |
1092 | 1109 |
1093 TestEventHandler event_handler; | 1110 TestEventHandler event_handler; |
1094 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 1111 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
1095 | 1112 |
1096 UpdateDisplay("600x400*2@1.5,500x300"); | 1113 UpdateDisplay("600x400*2@1.5,500x300"); |
1097 | 1114 |
1098 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); | 1115 gfx::Display display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
1099 test::ScopedSetInternalDisplayId set_internal(display1.id()); | 1116 test::ScopedSetInternalDisplayId set_internal(display1.id()); |
1100 | 1117 |
1101 gfx::Display display2 = ScreenUtil::GetSecondaryDisplay(); | 1118 gfx::Display display2 = ScreenUtil::GetSecondaryDisplay(); |
1102 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1119 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
1103 EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); | 1120 EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); |
1104 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); | 1121 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); |
1105 EXPECT_EQ("450,0 500x300", display2.bounds().ToString()); | 1122 EXPECT_EQ("450,0 500x300", display2.bounds().ToString()); |
1106 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); | 1123 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); |
1107 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); | 1124 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); |
1108 | 1125 |
1109 ui::test::EventGenerator generator(root_windows[0]); | 1126 ui::test::EventGenerator generator(root_windows[0]); |
1110 generator.MoveMouseToInHost(599, 200); | 1127 generator.MoveMouseToInHost(599, 200); |
1111 EXPECT_EQ("449,150", event_handler.GetLocationAndReset()); | 1128 EXPECT_EQ("449,150", event_handler.GetLocationAndReset()); |
1112 | 1129 |
1113 SetDisplayUIScale(display1.id(), 1.25f); | 1130 SetDisplayUIScale(display1.id(), 1.25f); |
1114 display1 = Shell::GetScreen()->GetPrimaryDisplay(); | 1131 display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
1115 display2 = ScreenUtil::GetSecondaryDisplay(); | 1132 display2 = ScreenUtil::GetSecondaryDisplay(); |
1116 EXPECT_EQ("0,0 375x250", display1.bounds().ToString()); | 1133 EXPECT_EQ("0,0 375x250", display1.bounds().ToString()); |
1117 EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString()); | 1134 EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString()); |
1118 EXPECT_EQ("375,0 500x300", display2.bounds().ToString()); | 1135 EXPECT_EQ("375,0 500x300", display2.bounds().ToString()); |
1119 EXPECT_EQ(1.25f, GetStoredUIScale(display1.id())); | 1136 EXPECT_EQ(1.25f, GetStoredUIScale(display1.id())); |
1120 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); | 1137 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); |
1121 | 1138 |
1122 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 1139 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
1123 } | 1140 } |
1124 | 1141 |
1125 TEST_F(WindowTreeHostManagerTest, TouchScale) { | 1142 TEST_F(WindowTreeHostManagerTest, TouchScale) { |
1126 if (!SupportsMultipleDisplays()) | 1143 if (!SupportsMultipleDisplays()) |
1127 return; | 1144 return; |
1128 | 1145 |
1129 TestEventHandler event_handler; | 1146 TestEventHandler event_handler; |
1130 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 1147 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
1131 | 1148 |
1132 UpdateDisplay("200x200*2"); | 1149 UpdateDisplay("200x200*2"); |
1133 gfx::Display display = Shell::GetScreen()->GetPrimaryDisplay(); | 1150 gfx::Display display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
1134 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1151 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
1135 aura::Window* root_window = root_windows[0]; | 1152 aura::Window* root_window = root_windows[0]; |
1136 ui::test::EventGenerator generator(root_window); | 1153 ui::test::EventGenerator generator(root_window); |
1137 | 1154 |
1138 generator.PressMoveAndReleaseTouchTo(50, 50); | 1155 generator.PressMoveAndReleaseTouchTo(50, 50); |
1139 // Default test touches have radius_x/y = 1.0, with device scale | 1156 // Default test touches have radius_x/y = 1.0, with device scale |
1140 // factor = 2, the scaled radius_x/y should be 0.5. | 1157 // factor = 2, the scaled radius_x/y should be 0.5. |
1141 EXPECT_EQ(0.5, event_handler.touch_radius_x()); | 1158 EXPECT_EQ(0.5, event_handler.touch_radius_x()); |
1142 EXPECT_EQ(0.5, event_handler.touch_radius_y()); | 1159 EXPECT_EQ(0.5, event_handler.touch_radius_y()); |
1143 | 1160 |
(...skipping 12 matching lines...) Expand all Loading... |
1156 | 1173 |
1157 TEST_F(WindowTreeHostManagerTest, ConvertHostToRootCoords) { | 1174 TEST_F(WindowTreeHostManagerTest, ConvertHostToRootCoords) { |
1158 if (!SupportsMultipleDisplays()) | 1175 if (!SupportsMultipleDisplays()) |
1159 return; | 1176 return; |
1160 | 1177 |
1161 TestEventHandler event_handler; | 1178 TestEventHandler event_handler; |
1162 Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 1179 Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
1163 | 1180 |
1164 UpdateDisplay("600x400*2/r@1.5"); | 1181 UpdateDisplay("600x400*2/r@1.5"); |
1165 | 1182 |
1166 gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); | 1183 gfx::Display display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
1167 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1184 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
1168 EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); | 1185 EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); |
1169 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); | 1186 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); |
1170 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); | 1187 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); |
1171 | 1188 |
1172 ui::test::EventGenerator generator(root_windows[0]); | 1189 ui::test::EventGenerator generator(root_windows[0]); |
1173 generator.MoveMouseToInHost(0, 0); | 1190 generator.MoveMouseToInHost(0, 0); |
1174 EXPECT_EQ("0,449", event_handler.GetLocationAndReset()); | 1191 EXPECT_EQ("0,449", event_handler.GetLocationAndReset()); |
1175 generator.MoveMouseToInHost(599, 0); | 1192 generator.MoveMouseToInHost(599, 0); |
1176 EXPECT_EQ("0,0", event_handler.GetLocationAndReset()); | 1193 EXPECT_EQ("0,0", event_handler.GetLocationAndReset()); |
1177 generator.MoveMouseToInHost(599, 399); | 1194 generator.MoveMouseToInHost(599, 399); |
1178 EXPECT_EQ("299,0", event_handler.GetLocationAndReset()); | 1195 EXPECT_EQ("299,0", event_handler.GetLocationAndReset()); |
1179 generator.MoveMouseToInHost(0, 399); | 1196 generator.MoveMouseToInHost(0, 399); |
1180 EXPECT_EQ("299,449", event_handler.GetLocationAndReset()); | 1197 EXPECT_EQ("299,449", event_handler.GetLocationAndReset()); |
1181 | 1198 |
1182 UpdateDisplay("600x400*2/u@1.5"); | 1199 UpdateDisplay("600x400*2/u@1.5"); |
1183 display1 = Shell::GetScreen()->GetPrimaryDisplay(); | 1200 display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
1184 root_windows = Shell::GetAllRootWindows(); | 1201 root_windows = Shell::GetAllRootWindows(); |
1185 EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); | 1202 EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); |
1186 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); | 1203 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); |
1187 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); | 1204 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); |
1188 | 1205 |
1189 generator.MoveMouseToInHost(0, 0); | 1206 generator.MoveMouseToInHost(0, 0); |
1190 EXPECT_EQ("449,299", event_handler.GetLocationAndReset()); | 1207 EXPECT_EQ("449,299", event_handler.GetLocationAndReset()); |
1191 generator.MoveMouseToInHost(599, 0); | 1208 generator.MoveMouseToInHost(599, 0); |
1192 EXPECT_EQ("0,299", event_handler.GetLocationAndReset()); | 1209 EXPECT_EQ("0,299", event_handler.GetLocationAndReset()); |
1193 generator.MoveMouseToInHost(599, 399); | 1210 generator.MoveMouseToInHost(599, 399); |
1194 EXPECT_EQ("0,0", event_handler.GetLocationAndReset()); | 1211 EXPECT_EQ("0,0", event_handler.GetLocationAndReset()); |
1195 generator.MoveMouseToInHost(0, 399); | 1212 generator.MoveMouseToInHost(0, 399); |
1196 EXPECT_EQ("449,0", event_handler.GetLocationAndReset()); | 1213 EXPECT_EQ("449,0", event_handler.GetLocationAndReset()); |
1197 | 1214 |
1198 UpdateDisplay("600x400*2/l@1.5"); | 1215 UpdateDisplay("600x400*2/l@1.5"); |
1199 display1 = Shell::GetScreen()->GetPrimaryDisplay(); | 1216 display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); |
1200 root_windows = Shell::GetAllRootWindows(); | 1217 root_windows = Shell::GetAllRootWindows(); |
1201 EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); | 1218 EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); |
1202 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); | 1219 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); |
1203 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); | 1220 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); |
1204 | 1221 |
1205 generator.MoveMouseToInHost(0, 0); | 1222 generator.MoveMouseToInHost(0, 0); |
1206 EXPECT_EQ("299,0", event_handler.GetLocationAndReset()); | 1223 EXPECT_EQ("299,0", event_handler.GetLocationAndReset()); |
1207 generator.MoveMouseToInHost(599, 0); | 1224 generator.MoveMouseToInHost(599, 0); |
1208 EXPECT_EQ("299,449", event_handler.GetLocationAndReset()); | 1225 EXPECT_EQ("299,449", event_handler.GetLocationAndReset()); |
1209 generator.MoveMouseToInHost(599, 399); | 1226 generator.MoveMouseToInHost(599, 399); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1273 CreateDisplayInfo(11, 1, gfx::Display::ROTATE_0); | 1290 CreateDisplayInfo(11, 1, gfx::Display::ROTATE_0); |
1274 | 1291 |
1275 std::vector<DisplayInfo> display_info_list; | 1292 std::vector<DisplayInfo> display_info_list; |
1276 // Extended | 1293 // Extended |
1277 display_info_list.push_back(first_display_info); | 1294 display_info_list.push_back(first_display_info); |
1278 display_info_list.push_back(second_display_info); | 1295 display_info_list.push_back(second_display_info); |
1279 display_manager->OnNativeDisplaysChanged(display_info_list); | 1296 display_manager->OnNativeDisplaysChanged(display_info_list); |
1280 | 1297 |
1281 Shell::GetInstance()->window_tree_host_manager()->SwapPrimaryDisplay(); | 1298 Shell::GetInstance()->window_tree_host_manager()->SwapPrimaryDisplay(); |
1282 | 1299 |
1283 EXPECT_EQ(11, Shell::GetScreen()->GetPrimaryDisplay().id()); | 1300 EXPECT_EQ(11, gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); |
1284 | 1301 |
1285 display_info_list.clear(); | 1302 display_info_list.clear(); |
1286 const DisplayInfo new_first_display_info = | 1303 const DisplayInfo new_first_display_info = |
1287 CreateDisplayInfo(20, 0, gfx::Display::ROTATE_0); | 1304 CreateDisplayInfo(20, 0, gfx::Display::ROTATE_0); |
1288 const DisplayInfo new_second_display_info = | 1305 const DisplayInfo new_second_display_info = |
1289 CreateDisplayInfo(21, 1, gfx::Display::ROTATE_0); | 1306 CreateDisplayInfo(21, 1, gfx::Display::ROTATE_0); |
1290 display_info_list.push_back(new_first_display_info); | 1307 display_info_list.push_back(new_first_display_info); |
1291 display_info_list.push_back(new_second_display_info); | 1308 display_info_list.push_back(new_second_display_info); |
1292 display_manager->OnNativeDisplaysChanged(display_info_list); | 1309 display_manager->OnNativeDisplaysChanged(display_info_list); |
1293 | 1310 |
1294 EXPECT_EQ(20, Shell::GetScreen()->GetPrimaryDisplay().id()); | 1311 EXPECT_EQ(20, gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); |
1295 } | 1312 } |
1296 | 1313 |
1297 namespace { | 1314 namespace { |
1298 | 1315 |
1299 class RootWindowTestObserver : public aura::WindowObserver { | 1316 class RootWindowTestObserver : public aura::WindowObserver { |
1300 public: | 1317 public: |
1301 RootWindowTestObserver() {} | 1318 RootWindowTestObserver() {} |
1302 ~RootWindowTestObserver() override {} | 1319 ~RootWindowTestObserver() override {} |
1303 | 1320 |
1304 void OnWindowBoundsChanged(aura::Window* window, | 1321 void OnWindowBoundsChanged(aura::Window* window, |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1532 widget->GetNativeWindow()->GetRootWindow()); | 1549 widget->GetNativeWindow()->GetRootWindow()); |
1533 event_generator.MoveMouseToCenterOf(widget->GetNativeWindow()); | 1550 event_generator.MoveMouseToCenterOf(widget->GetNativeWindow()); |
1534 | 1551 |
1535 UpdateDisplay("300x300"); | 1552 UpdateDisplay("300x300"); |
1536 watcher.Stop(); | 1553 watcher.Stop(); |
1537 | 1554 |
1538 widget->CloseNow(); | 1555 widget->CloseNow(); |
1539 } | 1556 } |
1540 | 1557 |
1541 } // namespace ash | 1558 } // namespace ash |
OLD | NEW |