Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: ash/display/window_tree_host_manager_unittest.cc

Issue 1924703002: Rename gfx::Display/Screen to display::Display/Screen in ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/display/window_tree_host_manager.cc ('k') | ash/drag_drop/drag_drop_tracker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory> 7 #include <memory>
8 8
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/display/display_info.h" 10 #include "ash/display/display_info.h"
(...skipping 12 matching lines...) Expand all
23 #include "ash/wm/common/window_state.h" 23 #include "ash/wm/common/window_state.h"
24 #include "ash/wm/common/wm_event.h" 24 #include "ash/wm/common/wm_event.h"
25 #include "ash/wm/window_state_aura.h" 25 #include "ash/wm/window_state_aura.h"
26 #include "base/command_line.h" 26 #include "base/command_line.h"
27 #include "ui/aura/client/focus_change_observer.h" 27 #include "ui/aura/client/focus_change_observer.h"
28 #include "ui/aura/client/focus_client.h" 28 #include "ui/aura/client/focus_client.h"
29 #include "ui/aura/env.h" 29 #include "ui/aura/env.h"
30 #include "ui/aura/window_observer.h" 30 #include "ui/aura/window_observer.h"
31 #include "ui/aura/window_tracker.h" 31 #include "ui/aura/window_tracker.h"
32 #include "ui/aura/window_tree_host.h" 32 #include "ui/aura/window_tree_host.h"
33 #include "ui/display/display.h"
34 #include "ui/display/display_observer.h"
33 #include "ui/display/manager/display_layout.h" 35 #include "ui/display/manager/display_layout.h"
36 #include "ui/display/screen.h"
34 #include "ui/events/event_handler.h" 37 #include "ui/events/event_handler.h"
35 #include "ui/events/test/event_generator.h" 38 #include "ui/events/test/event_generator.h"
36 #include "ui/gfx/display.h"
37 #include "ui/gfx/screen.h"
38 #include "ui/views/mouse_watcher.h" 39 #include "ui/views/mouse_watcher.h"
39 #include "ui/views/mouse_watcher_view_host.h" 40 #include "ui/views/mouse_watcher_view_host.h"
40 #include "ui/views/view.h" 41 #include "ui/views/view.h"
41 #include "ui/views/widget/widget.h" 42 #include "ui/views/widget/widget.h"
42 #include "ui/wm/public/activation_change_observer.h" 43 #include "ui/wm/public/activation_change_observer.h"
43 #include "ui/wm/public/activation_client.h" 44 #include "ui/wm/public/activation_client.h"
44 45
45 namespace ash { 46 namespace ash {
46 namespace { 47 namespace {
47 48
48 const char kDesktopBackgroundView[] = "DesktopBackgroundView"; 49 const char kDesktopBackgroundView[] = "DesktopBackgroundView";
49 50
50 template <typename T> 51 template <typename T>
51 class Resetter { 52 class Resetter {
52 public: 53 public:
53 explicit Resetter(T* value) : value_(*value) { *value = 0; } 54 explicit Resetter(T* value) : value_(*value) { *value = 0; }
54 ~Resetter() {} 55 ~Resetter() {}
55 T value() { return value_; } 56 T value() { return value_; }
56 57
57 private: 58 private:
58 T value_; 59 T value_;
59 DISALLOW_COPY_AND_ASSIGN(Resetter); 60 DISALLOW_COPY_AND_ASSIGN(Resetter);
60 }; 61 };
61 62
62 class TestObserver : public WindowTreeHostManager::Observer, 63 class TestObserver : public WindowTreeHostManager::Observer,
63 public gfx::DisplayObserver, 64 public display::DisplayObserver,
64 public aura::client::FocusChangeObserver, 65 public aura::client::FocusChangeObserver,
65 public aura::client::ActivationChangeObserver { 66 public aura::client::ActivationChangeObserver {
66 public: 67 public:
67 TestObserver() 68 TestObserver()
68 : changing_count_(0), 69 : changing_count_(0),
69 changed_count_(0), 70 changed_count_(0),
70 bounds_changed_count_(0), 71 bounds_changed_count_(0),
71 rotation_changed_count_(0), 72 rotation_changed_count_(0),
72 workarea_changed_count_(0), 73 workarea_changed_count_(0),
73 primary_changed_count_(0), 74 primary_changed_count_(0),
74 changed_display_id_(0), 75 changed_display_id_(0),
75 focus_changed_count_(0), 76 focus_changed_count_(0),
76 activation_changed_count_(0) { 77 activation_changed_count_(0) {
77 Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); 78 Shell::GetInstance()->window_tree_host_manager()->AddObserver(this);
78 gfx::Screen::GetScreen()->AddObserver(this); 79 display::Screen::GetScreen()->AddObserver(this);
79 aura::client::GetFocusClient(Shell::GetPrimaryRootWindow()) 80 aura::client::GetFocusClient(Shell::GetPrimaryRootWindow())
80 ->AddObserver(this); 81 ->AddObserver(this);
81 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow()) 82 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())
82 ->AddObserver(this); 83 ->AddObserver(this);
83 } 84 }
84 85
85 ~TestObserver() override { 86 ~TestObserver() override {
86 Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); 87 Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this);
87 gfx::Screen::GetScreen()->RemoveObserver(this); 88 display::Screen::GetScreen()->RemoveObserver(this);
88 aura::client::GetFocusClient(Shell::GetPrimaryRootWindow()) 89 aura::client::GetFocusClient(Shell::GetPrimaryRootWindow())
89 ->RemoveObserver(this); 90 ->RemoveObserver(this);
90 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow()) 91 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())
91 ->RemoveObserver(this); 92 ->RemoveObserver(this);
92 } 93 }
93 94
94 // Overridden from WindowTreeHostManager::Observer 95 // Overridden from WindowTreeHostManager::Observer
95 void OnDisplayConfigurationChanging() override { ++changing_count_; } 96 void OnDisplayConfigurationChanging() override { ++changing_count_; }
96 void OnDisplayConfigurationChanged() override { ++changed_count_; } 97 void OnDisplayConfigurationChanged() override { ++changed_count_; }
97 98
98 // Overrideen from gfx::DisplayObserver 99 // Overrideen from display::DisplayObserver
99 void OnDisplayMetricsChanged(const gfx::Display& display, 100 void OnDisplayMetricsChanged(const display::Display& display,
100 uint32_t metrics) override { 101 uint32_t metrics) override {
101 changed_display_id_ = display.id(); 102 changed_display_id_ = display.id();
102 if (metrics & DISPLAY_METRIC_BOUNDS) 103 if (metrics & DISPLAY_METRIC_BOUNDS)
103 ++bounds_changed_count_; 104 ++bounds_changed_count_;
104 if (metrics & DISPLAY_METRIC_ROTATION) 105 if (metrics & DISPLAY_METRIC_ROTATION)
105 ++rotation_changed_count_; 106 ++rotation_changed_count_;
106 if (metrics & DISPLAY_METRIC_WORK_AREA) 107 if (metrics & DISPLAY_METRIC_WORK_AREA)
107 ++workarea_changed_count_; 108 ++workarea_changed_count_;
108 if (metrics & DISPLAY_METRIC_PRIMARY) 109 if (metrics & DISPLAY_METRIC_PRIMARY)
109 ++primary_changed_count_; 110 ++primary_changed_count_;
110 } 111 }
111 void OnDisplayAdded(const gfx::Display& new_display) override {} 112 void OnDisplayAdded(const display::Display& new_display) override {}
112 void OnDisplayRemoved(const gfx::Display& old_display) override {} 113 void OnDisplayRemoved(const display::Display& old_display) override {}
113 114
114 // Overridden from aura::client::FocusChangeObserver 115 // Overridden from aura::client::FocusChangeObserver
115 void OnWindowFocused(aura::Window* gained_focus, 116 void OnWindowFocused(aura::Window* gained_focus,
116 aura::Window* lost_focus) override { 117 aura::Window* lost_focus) override {
117 focus_changed_count_++; 118 focus_changed_count_++;
118 } 119 }
119 120
120 // Overridden from aura::client::ActivationChangeObserver 121 // Overridden from aura::client::ActivationChangeObserver
121 void OnWindowActivated( 122 void OnWindowActivated(
122 aura::client::ActivationChangeObserver::ActivationReason reason, 123 aura::client::ActivationChangeObserver::ActivationReason reason,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 int workarea_changed_count_; 171 int workarea_changed_count_;
171 int primary_changed_count_; 172 int primary_changed_count_;
172 int64_t changed_display_id_; 173 int64_t changed_display_id_;
173 174
174 int focus_changed_count_; 175 int focus_changed_count_;
175 int activation_changed_count_; 176 int activation_changed_count_;
176 177
177 DISALLOW_COPY_AND_ASSIGN(TestObserver); 178 DISALLOW_COPY_AND_ASSIGN(TestObserver);
178 }; 179 };
179 180
180 gfx::Display GetPrimaryDisplay() { 181 display::Display GetPrimaryDisplay() {
181 return gfx::Screen::GetScreen()->GetDisplayNearestWindow( 182 return display::Screen::GetScreen()->GetDisplayNearestWindow(
182 Shell::GetAllRootWindows()[0]); 183 Shell::GetAllRootWindows()[0]);
183 } 184 }
184 185
185 gfx::Display GetSecondaryDisplay() { 186 display::Display GetSecondaryDisplay() {
186 return gfx::Screen::GetScreen()->GetDisplayNearestWindow( 187 return display::Screen::GetScreen()->GetDisplayNearestWindow(
187 Shell::GetAllRootWindows()[1]); 188 Shell::GetAllRootWindows()[1]);
188 } 189 }
189 190
190 void SetSecondaryDisplayLayoutAndOffset( 191 void SetSecondaryDisplayLayoutAndOffset(
191 display::DisplayPlacement::Position position, 192 display::DisplayPlacement::Position position,
192 int offset) { 193 int offset) {
193 std::unique_ptr<display::DisplayLayout> layout( 194 std::unique_ptr<display::DisplayLayout> layout(
194 test::CreateDisplayLayout(position, offset)); 195 test::CreateDisplayLayout(position, offset));
195 ASSERT_GT(gfx::Screen::GetScreen()->GetNumDisplays(), 1); 196 ASSERT_GT(display::Screen::GetScreen()->GetNumDisplays(), 1);
196 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( 197 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays(
197 std::move(layout)); 198 std::move(layout));
198 } 199 }
199 200
200 void SetSecondaryDisplayLayout(display::DisplayPlacement::Position position) { 201 void SetSecondaryDisplayLayout(display::DisplayPlacement::Position position) {
201 SetSecondaryDisplayLayoutAndOffset(position, 0); 202 SetSecondaryDisplayLayoutAndOffset(position, 0);
202 } 203 }
203 204
204 void SetDefaultDisplayLayout(display::DisplayPlacement::Position position) { 205 void SetDefaultDisplayLayout(display::DisplayPlacement::Position position) {
205 display::DisplayPlacement default_placement(position, 0); 206 display::DisplayPlacement default_placement(position, 0);
206 207
207 Shell::GetInstance() 208 Shell::GetInstance()
208 ->display_manager() 209 ->display_manager()
209 ->layout_store() 210 ->layout_store()
210 ->SetDefaultDisplayPlacement(default_placement); 211 ->SetDefaultDisplayPlacement(default_placement);
211 } 212 }
212 213
213 class WindowTreeHostManagerShutdownTest : public test::AshTestBase { 214 class WindowTreeHostManagerShutdownTest : public test::AshTestBase {
214 public: 215 public:
215 WindowTreeHostManagerShutdownTest() {} 216 WindowTreeHostManagerShutdownTest() {}
216 ~WindowTreeHostManagerShutdownTest() override {} 217 ~WindowTreeHostManagerShutdownTest() override {}
217 218
218 void TearDown() override { 219 void TearDown() override {
219 test::AshTestBase::TearDown(); 220 test::AshTestBase::TearDown();
220 if (!SupportsMultipleDisplays()) 221 if (!SupportsMultipleDisplays())
221 return; 222 return;
222 223
223 // Make sure that primary display is accessible after shutdown. 224 // Make sure that primary display is accessible after shutdown.
224 gfx::Display primary = gfx::Screen::GetScreen()->GetPrimaryDisplay(); 225 display::Display primary =
226 display::Screen::GetScreen()->GetPrimaryDisplay();
225 EXPECT_EQ("0,0 444x333", primary.bounds().ToString()); 227 EXPECT_EQ("0,0 444x333", primary.bounds().ToString());
226 EXPECT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays()); 228 EXPECT_EQ(2, display::Screen::GetScreen()->GetNumDisplays());
227 } 229 }
228 230
229 private: 231 private:
230 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostManagerShutdownTest); 232 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostManagerShutdownTest);
231 }; 233 };
232 234
233 class StartupHelper : public test::TestShellDelegate, 235 class StartupHelper : public test::TestShellDelegate,
234 public WindowTreeHostManager::Observer { 236 public WindowTreeHostManager::Observer {
235 public: 237 public:
236 StartupHelper() : displays_initialized_(false) {} 238 StartupHelper() : displays_initialized_(false) {}
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 536
535 UpdateDisplay("500x500"); 537 UpdateDisplay("500x500");
536 EXPECT_LE(1, observer.GetFocusChangedCountAndReset()); 538 EXPECT_LE(1, observer.GetFocusChangedCountAndReset());
537 EXPECT_LE(1, observer.GetActivationChangedCountAndReset()); 539 EXPECT_LE(1, observer.GetActivationChangedCountAndReset());
538 } 540 }
539 541
540 namespace { 542 namespace {
541 543
542 DisplayInfo CreateDisplayInfo(int64_t id, 544 DisplayInfo CreateDisplayInfo(int64_t id,
543 int y, 545 int y,
544 gfx::Display::Rotation rotation) { 546 display::Display::Rotation rotation) {
545 DisplayInfo info(id, "", false); 547 DisplayInfo info(id, "", false);
546 info.SetBounds(gfx::Rect(0, y, 500, 500)); 548 info.SetBounds(gfx::Rect(0, y, 500, 500));
547 info.SetRotation(rotation, gfx::Display::ROTATION_SOURCE_ACTIVE); 549 info.SetRotation(rotation, display::Display::ROTATION_SOURCE_ACTIVE);
548 return info; 550 return info;
549 } 551 }
550 552
551 DisplayInfo CreateMirroredDisplayInfo(int64_t id, float device_scale_factor) { 553 DisplayInfo CreateMirroredDisplayInfo(int64_t id, float device_scale_factor) {
552 DisplayInfo info = CreateDisplayInfo(id, 0, gfx::Display::ROTATE_0); 554 DisplayInfo info = CreateDisplayInfo(id, 0, display::Display::ROTATE_0);
553 info.set_device_scale_factor(device_scale_factor); 555 info.set_device_scale_factor(device_scale_factor);
554 return info; 556 return info;
555 } 557 }
556 558
557 } // namespace 559 } // namespace
558 560
559 TEST_F(WindowTreeHostManagerTest, MirrorToDockedWithFullscreen) { 561 TEST_F(WindowTreeHostManagerTest, MirrorToDockedWithFullscreen) {
560 if (!SupportsMultipleDisplays()) 562 if (!SupportsMultipleDisplays())
561 return; 563 return;
562 564
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); 644 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
643 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); 645 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
644 EXPECT_EQ("0,0 400x400", GetPrimaryDisplay().bounds().ToString()); 646 EXPECT_EQ("0,0 400x400", GetPrimaryDisplay().bounds().ToString());
645 EXPECT_EQ("0,400 300x300", GetSecondaryDisplay().bounds().ToString()); 647 EXPECT_EQ("0,400 300x300", GetSecondaryDisplay().bounds().ToString());
646 648
647 UpdateDisplay("400x400"); 649 UpdateDisplay("400x400");
648 EXPECT_EQ(1, observer.CountAndReset()); 650 EXPECT_EQ(1, observer.CountAndReset());
649 EXPECT_LE(1, observer.GetFocusChangedCountAndReset()); 651 EXPECT_LE(1, observer.GetFocusChangedCountAndReset());
650 EXPECT_LE(1, observer.GetActivationChangedCountAndReset()); 652 EXPECT_LE(1, observer.GetActivationChangedCountAndReset());
651 EXPECT_EQ("0,0 400x400", GetPrimaryDisplay().bounds().ToString()); 653 EXPECT_EQ("0,0 400x400", GetPrimaryDisplay().bounds().ToString());
652 EXPECT_EQ(1, gfx::Screen::GetScreen()->GetNumDisplays()); 654 EXPECT_EQ(1, display::Screen::GetScreen()->GetNumDisplays());
653 655
654 UpdateDisplay("400x500*2,300x300"); 656 UpdateDisplay("400x500*2,300x300");
655 EXPECT_EQ(1, observer.CountAndReset()); 657 EXPECT_EQ(1, observer.CountAndReset());
656 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); 658 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
657 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); 659 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
658 ASSERT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays()); 660 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays());
659 EXPECT_EQ("0,0 200x250", GetPrimaryDisplay().bounds().ToString()); 661 EXPECT_EQ("0,0 200x250", GetPrimaryDisplay().bounds().ToString());
660 EXPECT_EQ("0,250 300x300", GetSecondaryDisplay().bounds().ToString()); 662 EXPECT_EQ("0,250 300x300", GetSecondaryDisplay().bounds().ToString());
661 663
662 // No change 664 // No change
663 UpdateDisplay("400x500*2,300x300"); 665 UpdateDisplay("400x500*2,300x300");
664 // We still call into Pre/PostDisplayConfigurationChange(). 666 // We still call into Pre/PostDisplayConfigurationChange().
665 EXPECT_EQ(1, observer.CountAndReset()); 667 EXPECT_EQ(1, observer.CountAndReset());
666 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); 668 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
667 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); 669 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
668 670
669 // Rotation 671 // Rotation
670 observer.GetRotationChangedCountAndReset(); // we only want to reset. 672 observer.GetRotationChangedCountAndReset(); // we only want to reset.
671 int64_t primary_id = GetPrimaryDisplay().id(); 673 int64_t primary_id = GetPrimaryDisplay().id();
672 display_manager->SetDisplayRotation(primary_id, gfx::Display::ROTATE_90, 674 display_manager->SetDisplayRotation(primary_id, display::Display::ROTATE_90,
673 gfx::Display::ROTATION_SOURCE_ACTIVE); 675 display::Display::ROTATION_SOURCE_ACTIVE);
674 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); 676 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset());
675 EXPECT_EQ(1, observer.CountAndReset()); 677 EXPECT_EQ(1, observer.CountAndReset());
676 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); 678 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
677 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); 679 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
678 display_manager->SetDisplayRotation(primary_id, gfx::Display::ROTATE_90, 680 display_manager->SetDisplayRotation(primary_id, display::Display::ROTATE_90,
679 gfx::Display::ROTATION_SOURCE_ACTIVE); 681 display::Display::ROTATION_SOURCE_ACTIVE);
680 EXPECT_EQ(0, observer.GetRotationChangedCountAndReset()); 682 EXPECT_EQ(0, observer.GetRotationChangedCountAndReset());
681 EXPECT_EQ(0, observer.CountAndReset()); 683 EXPECT_EQ(0, observer.CountAndReset());
682 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); 684 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
683 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); 685 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
684 686
685 // UI scale is eanbled only on internal display. 687 // UI scale is eanbled only on internal display.
686 int64_t secondary_id = GetSecondaryDisplay().id(); 688 int64_t secondary_id = GetSecondaryDisplay().id();
687 test::ScopedSetInternalDisplayId set_internal(secondary_id); 689 test::ScopedSetInternalDisplayId set_internal(secondary_id);
688 // Changing internal ID display changes the DisplayIdPair (it comes 690 // Changing internal ID display changes the DisplayIdPair (it comes
689 // first), which also changes the primary display candidate. Update 691 // first), which also changes the primary display candidate. Update
(...skipping 28 matching lines...) Expand all
718 return; 720 return;
719 721
720 WindowTreeHostManager* window_tree_host_manager = 722 WindowTreeHostManager* window_tree_host_manager =
721 Shell::GetInstance()->window_tree_host_manager(); 723 Shell::GetInstance()->window_tree_host_manager();
722 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 724 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
723 725
724 UpdateDisplay("200x200,300x300"); 726 UpdateDisplay("200x200,300x300");
725 display_manager->SetLayoutForCurrentDisplays( 727 display_manager->SetLayoutForCurrentDisplays(
726 test::CreateDisplayLayout(display::DisplayPlacement::RIGHT, 50)); 728 test::CreateDisplayLayout(display::DisplayPlacement::RIGHT, 50));
727 729
728 gfx::Display primary_display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); 730 display::Display primary_display =
729 gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); 731 display::Screen::GetScreen()->GetPrimaryDisplay();
732 display::Display secondary_display = ScreenUtil::GetSecondaryDisplay();
730 EXPECT_NE(primary_display.id(), secondary_display.id()); 733 EXPECT_NE(primary_display.id(), secondary_display.id());
731 aura::Window* primary_root = 734 aura::Window* primary_root =
732 window_tree_host_manager->GetRootWindowForDisplayId(primary_display.id()); 735 window_tree_host_manager->GetRootWindowForDisplayId(primary_display.id());
733 aura::Window* secondary_root = 736 aura::Window* secondary_root =
734 window_tree_host_manager->GetRootWindowForDisplayId( 737 window_tree_host_manager->GetRootWindowForDisplayId(
735 secondary_display.id()); 738 secondary_display.id());
736 EXPECT_NE(primary_root, secondary_root); 739 EXPECT_NE(primary_root, secondary_root);
737 740
738 // Test that points outside of any display return the nearest display. 741 // Test that points outside of any display return the nearest display.
739 EXPECT_EQ(primary_display.id(), 742 EXPECT_EQ(primary_display.id(),
740 gfx::Screen::GetScreen() 743 display::Screen::GetScreen()
741 ->GetDisplayNearestPoint(gfx::Point(-100, 0)) 744 ->GetDisplayNearestPoint(gfx::Point(-100, 0))
742 .id()); 745 .id());
743 EXPECT_EQ(primary_display.id(), 746 EXPECT_EQ(primary_display.id(),
744 gfx::Screen::GetScreen() 747 display::Screen::GetScreen()
745 ->GetDisplayNearestPoint(gfx::Point(0, -100)) 748 ->GetDisplayNearestPoint(gfx::Point(0, -100))
746 .id()); 749 .id());
747 EXPECT_EQ(primary_display.id(), 750 EXPECT_EQ(primary_display.id(),
748 gfx::Screen::GetScreen() 751 display::Screen::GetScreen()
749 ->GetDisplayNearestPoint(gfx::Point(100, 100)) 752 ->GetDisplayNearestPoint(gfx::Point(100, 100))
750 .id()); 753 .id());
751 EXPECT_EQ(primary_display.id(), 754 EXPECT_EQ(primary_display.id(),
752 gfx::Screen::GetScreen() 755 display::Screen::GetScreen()
753 ->GetDisplayNearestPoint(gfx::Point(224, 25)) 756 ->GetDisplayNearestPoint(gfx::Point(224, 25))
754 .id()); 757 .id());
755 EXPECT_EQ(secondary_display.id(), 758 EXPECT_EQ(secondary_display.id(),
756 gfx::Screen::GetScreen() 759 display::Screen::GetScreen()
757 ->GetDisplayNearestPoint(gfx::Point(226, 25)) 760 ->GetDisplayNearestPoint(gfx::Point(226, 25))
758 .id()); 761 .id());
759 EXPECT_EQ(secondary_display.id(), 762 EXPECT_EQ(secondary_display.id(),
760 gfx::Screen::GetScreen() 763 display::Screen::GetScreen()
761 ->GetDisplayNearestPoint(gfx::Point(600, 100)) 764 ->GetDisplayNearestPoint(gfx::Point(600, 100))
762 .id()); 765 .id());
763 EXPECT_EQ(primary_display.id(), 766 EXPECT_EQ(primary_display.id(),
764 gfx::Screen::GetScreen() 767 display::Screen::GetScreen()
765 ->GetDisplayNearestPoint(gfx::Point(174, 225)) 768 ->GetDisplayNearestPoint(gfx::Point(174, 225))
766 .id()); 769 .id());
767 EXPECT_EQ(secondary_display.id(), 770 EXPECT_EQ(secondary_display.id(),
768 gfx::Screen::GetScreen() 771 display::Screen::GetScreen()
769 ->GetDisplayNearestPoint(gfx::Point(176, 225)) 772 ->GetDisplayNearestPoint(gfx::Point(176, 225))
770 .id()); 773 .id());
771 EXPECT_EQ(secondary_display.id(), 774 EXPECT_EQ(secondary_display.id(),
772 gfx::Screen::GetScreen() 775 display::Screen::GetScreen()
773 ->GetDisplayNearestPoint(gfx::Point(300, 400)) 776 ->GetDisplayNearestPoint(gfx::Point(300, 400))
774 .id()); 777 .id());
775 } 778 }
776 779
777 TEST_F(WindowTreeHostManagerTest, SwapPrimaryById) { 780 TEST_F(WindowTreeHostManagerTest, SwapPrimaryById) {
778 if (!SupportsMultipleDisplays()) 781 if (!SupportsMultipleDisplays())
779 return; 782 return;
780 783
781 WindowTreeHostManager* window_tree_host_manager = 784 WindowTreeHostManager* window_tree_host_manager =
782 Shell::GetInstance()->window_tree_host_manager(); 785 Shell::GetInstance()->window_tree_host_manager();
783 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 786 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
784 787
785 UpdateDisplay("200x200,300x300"); 788 UpdateDisplay("200x200,300x300");
786 gfx::Display primary_display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); 789 display::Display primary_display =
787 gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); 790 display::Screen::GetScreen()->GetPrimaryDisplay();
791 display::Display secondary_display = ScreenUtil::GetSecondaryDisplay();
788 792
789 display_manager->SetLayoutForCurrentDisplays( 793 display_manager->SetLayoutForCurrentDisplays(
790 test::CreateDisplayLayout(display::DisplayPlacement::RIGHT, 50)); 794 test::CreateDisplayLayout(display::DisplayPlacement::RIGHT, 50));
791 795
792 EXPECT_NE(primary_display.id(), secondary_display.id()); 796 EXPECT_NE(primary_display.id(), secondary_display.id());
793 aura::Window* primary_root = 797 aura::Window* primary_root =
794 window_tree_host_manager->GetRootWindowForDisplayId(primary_display.id()); 798 window_tree_host_manager->GetRootWindowForDisplayId(primary_display.id());
795 aura::Window* secondary_root = 799 aura::Window* secondary_root =
796 window_tree_host_manager->GetRootWindowForDisplayId( 800 window_tree_host_manager->GetRootWindowForDisplayId(
797 secondary_display.id()); 801 secondary_display.id());
798 aura::Window* shelf_window = 802 aura::Window* shelf_window =
799 Shelf::ForPrimaryDisplay()->shelf_widget()->GetNativeView(); 803 Shelf::ForPrimaryDisplay()->shelf_widget()->GetNativeView();
800 EXPECT_TRUE(primary_root->Contains(shelf_window)); 804 EXPECT_TRUE(primary_root->Contains(shelf_window));
801 EXPECT_FALSE(secondary_root->Contains(shelf_window)); 805 EXPECT_FALSE(secondary_root->Contains(shelf_window));
802 EXPECT_NE(primary_root, secondary_root); 806 EXPECT_NE(primary_root, secondary_root);
803 EXPECT_EQ(primary_display.id(), 807 EXPECT_EQ(primary_display.id(),
804 gfx::Screen::GetScreen() 808 display::Screen::GetScreen()
805 ->GetDisplayNearestPoint(gfx::Point(-100, -100)) 809 ->GetDisplayNearestPoint(gfx::Point(-100, -100))
806 .id()); 810 .id());
807 EXPECT_EQ(primary_display.id(), 811 EXPECT_EQ(
808 gfx::Screen::GetScreen()->GetDisplayNearestWindow(nullptr).id()); 812 primary_display.id(),
813 display::Screen::GetScreen()->GetDisplayNearestWindow(nullptr).id());
809 814
810 EXPECT_EQ("0,0 200x200", primary_display.bounds().ToString()); 815 EXPECT_EQ("0,0 200x200", primary_display.bounds().ToString());
811 EXPECT_EQ("0,0 200x153", primary_display.work_area().ToString()); 816 EXPECT_EQ("0,0 200x153", primary_display.work_area().ToString());
812 EXPECT_EQ("200,0 300x300", secondary_display.bounds().ToString()); 817 EXPECT_EQ("200,0 300x300", secondary_display.bounds().ToString());
813 EXPECT_EQ("200,0 300x253", secondary_display.work_area().ToString()); 818 EXPECT_EQ("200,0 300x253", secondary_display.work_area().ToString());
814 EXPECT_EQ( 819 EXPECT_EQ(
815 "id=2200000001, parent=2200000000, right, 50", 820 "id=2200000001, parent=2200000000, right, 50",
816 display_manager->GetCurrentDisplayLayout().placement_list[0].ToString()); 821 display_manager->GetCurrentDisplayLayout().placement_list[0].ToString());
817 822
818 // Switch primary and secondary by display ID. 823 // Switch primary and secondary by display ID.
819 TestObserver observer; 824 TestObserver observer;
820 window_tree_host_manager->SetPrimaryDisplayId(secondary_display.id()); 825 window_tree_host_manager->SetPrimaryDisplayId(secondary_display.id());
821 EXPECT_EQ(secondary_display.id(), 826 EXPECT_EQ(secondary_display.id(),
822 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); 827 display::Screen::GetScreen()->GetPrimaryDisplay().id());
823 EXPECT_EQ(primary_display.id(), ScreenUtil::GetSecondaryDisplay().id()); 828 EXPECT_EQ(primary_display.id(), ScreenUtil::GetSecondaryDisplay().id());
824 EXPECT_LT(0, observer.CountAndReset()); 829 EXPECT_LT(0, observer.CountAndReset());
825 830
826 EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( 831 EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId(
827 secondary_display.id())); 832 secondary_display.id()));
828 EXPECT_EQ(secondary_root, window_tree_host_manager->GetRootWindowForDisplayId( 833 EXPECT_EQ(secondary_root, window_tree_host_manager->GetRootWindowForDisplayId(
829 primary_display.id())); 834 primary_display.id()));
830 EXPECT_TRUE(primary_root->Contains(shelf_window)); 835 EXPECT_TRUE(primary_root->Contains(shelf_window));
831 EXPECT_FALSE(secondary_root->Contains(shelf_window)); 836 EXPECT_FALSE(secondary_root->Contains(shelf_window));
832 837
833 const display::DisplayLayout& inverted_layout = 838 const display::DisplayLayout& inverted_layout =
834 display_manager->GetCurrentDisplayLayout(); 839 display_manager->GetCurrentDisplayLayout();
835 840
836 EXPECT_EQ("id=2200000000, parent=2200000001, left, -50", 841 EXPECT_EQ("id=2200000000, parent=2200000001, left, -50",
837 inverted_layout.placement_list[0].ToString()); 842 inverted_layout.placement_list[0].ToString());
838 // Test if the bounds are correctly swapped. 843 // Test if the bounds are correctly swapped.
839 gfx::Display swapped_primary = gfx::Screen::GetScreen()->GetPrimaryDisplay(); 844 display::Display swapped_primary =
840 gfx::Display swapped_secondary = ScreenUtil::GetSecondaryDisplay(); 845 display::Screen::GetScreen()->GetPrimaryDisplay();
846 display::Display swapped_secondary = ScreenUtil::GetSecondaryDisplay();
841 EXPECT_EQ("0,0 300x300", swapped_primary.bounds().ToString()); 847 EXPECT_EQ("0,0 300x300", swapped_primary.bounds().ToString());
842 EXPECT_EQ("0,0 300x253", swapped_primary.work_area().ToString()); 848 EXPECT_EQ("0,0 300x253", swapped_primary.work_area().ToString());
843 EXPECT_EQ("-200,-50 200x200", swapped_secondary.bounds().ToString()); 849 EXPECT_EQ("-200,-50 200x200", swapped_secondary.bounds().ToString());
844 EXPECT_EQ("-200,-50 200x153", swapped_secondary.work_area().ToString()); 850 EXPECT_EQ("-200,-50 200x153", swapped_secondary.work_area().ToString());
845 851
846 // Calling the same ID don't do anything. 852 // Calling the same ID don't do anything.
847 window_tree_host_manager->SetPrimaryDisplayId(secondary_display.id()); 853 window_tree_host_manager->SetPrimaryDisplayId(secondary_display.id());
848 EXPECT_EQ(0, observer.CountAndReset()); 854 EXPECT_EQ(0, observer.CountAndReset());
849 855
850 aura::WindowTracker tracker; 856 aura::WindowTracker tracker;
851 tracker.Add(primary_root); 857 tracker.Add(primary_root);
852 tracker.Add(secondary_root); 858 tracker.Add(secondary_root);
853 859
854 // Deleting 2nd display should move the primary to original primary display. 860 // Deleting 2nd display should move the primary to original primary display.
855 UpdateDisplay("200x200"); 861 UpdateDisplay("200x200");
856 RunAllPendingInMessageLoop(); // RootWindow is deleted in a posted task. 862 RunAllPendingInMessageLoop(); // RootWindow is deleted in a posted task.
857 EXPECT_EQ(1, gfx::Screen::GetScreen()->GetNumDisplays()); 863 EXPECT_EQ(1, display::Screen::GetScreen()->GetNumDisplays());
858 EXPECT_EQ(primary_display.id(), 864 EXPECT_EQ(primary_display.id(),
859 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); 865 display::Screen::GetScreen()->GetPrimaryDisplay().id());
860 EXPECT_EQ(primary_display.id(), 866 EXPECT_EQ(primary_display.id(),
861 gfx::Screen::GetScreen() 867 display::Screen::GetScreen()
862 ->GetDisplayNearestPoint(gfx::Point(-100, -100)) 868 ->GetDisplayNearestPoint(gfx::Point(-100, -100))
863 .id()); 869 .id());
864 EXPECT_EQ(primary_display.id(), 870 EXPECT_EQ(
865 gfx::Screen::GetScreen()->GetDisplayNearestWindow(nullptr).id()); 871 primary_display.id(),
872 display::Screen::GetScreen()->GetDisplayNearestWindow(nullptr).id());
866 EXPECT_TRUE(tracker.Contains(primary_root)); 873 EXPECT_TRUE(tracker.Contains(primary_root));
867 EXPECT_FALSE(tracker.Contains(secondary_root)); 874 EXPECT_FALSE(tracker.Contains(secondary_root));
868 EXPECT_TRUE(primary_root->Contains(shelf_window)); 875 EXPECT_TRUE(primary_root->Contains(shelf_window));
869 876
870 // Adding 2nd display with the same ID. The 2nd display should become primary 877 // Adding 2nd display with the same ID. The 2nd display should become primary
871 // since secondary id is still stored as desirable_primary_id. 878 // since secondary id is still stored as desirable_primary_id.
872 std::vector<DisplayInfo> display_info_list; 879 std::vector<DisplayInfo> display_info_list;
873 display_info_list.push_back( 880 display_info_list.push_back(
874 display_manager->GetDisplayInfo(primary_display.id())); 881 display_manager->GetDisplayInfo(primary_display.id()));
875 display_info_list.push_back( 882 display_info_list.push_back(
876 display_manager->GetDisplayInfo(secondary_display.id())); 883 display_manager->GetDisplayInfo(secondary_display.id()));
877 884
878 display_manager->OnNativeDisplaysChanged(display_info_list); 885 display_manager->OnNativeDisplaysChanged(display_info_list);
879 886
880 EXPECT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays()); 887 EXPECT_EQ(2, display::Screen::GetScreen()->GetNumDisplays());
881 EXPECT_EQ(secondary_display.id(), 888 EXPECT_EQ(secondary_display.id(),
882 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); 889 display::Screen::GetScreen()->GetPrimaryDisplay().id());
883 EXPECT_EQ(primary_display.id(), ScreenUtil::GetSecondaryDisplay().id()); 890 EXPECT_EQ(primary_display.id(), ScreenUtil::GetSecondaryDisplay().id());
884 EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( 891 EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId(
885 secondary_display.id())); 892 secondary_display.id()));
886 EXPECT_NE(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( 893 EXPECT_NE(primary_root, window_tree_host_manager->GetRootWindowForDisplayId(
887 primary_display.id())); 894 primary_display.id()));
888 EXPECT_TRUE(primary_root->Contains(shelf_window)); 895 EXPECT_TRUE(primary_root->Contains(shelf_window));
889 896
890 // Deleting 2nd display and adding 2nd display with a different ID. The 2nd 897 // Deleting 2nd display and adding 2nd display with a different ID. The 2nd
891 // display shouldn't become primary. 898 // display shouldn't become primary.
892 UpdateDisplay("200x200"); 899 UpdateDisplay("200x200");
893 DisplayInfo third_display_info(secondary_display.id() + 1, std::string(), 900 DisplayInfo third_display_info(secondary_display.id() + 1, std::string(),
894 false); 901 false);
895 third_display_info.SetBounds(secondary_display.bounds()); 902 third_display_info.SetBounds(secondary_display.bounds());
896 ASSERT_NE(primary_display.id(), third_display_info.id()); 903 ASSERT_NE(primary_display.id(), third_display_info.id());
897 904
898 const DisplayInfo& primary_display_info = 905 const DisplayInfo& primary_display_info =
899 display_manager->GetDisplayInfo(primary_display.id()); 906 display_manager->GetDisplayInfo(primary_display.id());
900 std::vector<DisplayInfo> display_info_list2; 907 std::vector<DisplayInfo> display_info_list2;
901 display_info_list2.push_back(primary_display_info); 908 display_info_list2.push_back(primary_display_info);
902 display_info_list2.push_back(third_display_info); 909 display_info_list2.push_back(third_display_info);
903 display_manager->OnNativeDisplaysChanged(display_info_list2); 910 display_manager->OnNativeDisplaysChanged(display_info_list2);
904 EXPECT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays()); 911 EXPECT_EQ(2, display::Screen::GetScreen()->GetNumDisplays());
905 EXPECT_EQ(primary_display.id(), 912 EXPECT_EQ(primary_display.id(),
906 gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); 913 display::Screen::GetScreen()->GetPrimaryDisplay().id());
907 EXPECT_EQ(third_display_info.id(), ScreenUtil::GetSecondaryDisplay().id()); 914 EXPECT_EQ(third_display_info.id(), ScreenUtil::GetSecondaryDisplay().id());
908 EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( 915 EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId(
909 primary_display.id())); 916 primary_display.id()));
910 EXPECT_NE(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( 917 EXPECT_NE(primary_root, window_tree_host_manager->GetRootWindowForDisplayId(
911 third_display_info.id())); 918 third_display_info.id()));
912 EXPECT_TRUE(primary_root->Contains(shelf_window)); 919 EXPECT_TRUE(primary_root->Contains(shelf_window));
913 } 920 }
914 921
915 TEST_F(WindowTreeHostManagerTest, NoSwapPrimaryWithThreeDisplays) { 922 TEST_F(WindowTreeHostManagerTest, NoSwapPrimaryWithThreeDisplays) {
916 if (!SupportsMultipleDisplays()) 923 if (!SupportsMultipleDisplays())
917 return; 924 return;
918 int64_t primary = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); 925 int64_t primary = display::Screen::GetScreen()->GetPrimaryDisplay().id();
919 UpdateDisplay("500x400,400x300,300x200"); 926 UpdateDisplay("500x400,400x300,300x200");
920 EXPECT_EQ(primary, gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); 927 EXPECT_EQ(primary, display::Screen::GetScreen()->GetPrimaryDisplay().id());
921 Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId( 928 Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId(
922 ScreenUtil::GetSecondaryDisplay().id()); 929 ScreenUtil::GetSecondaryDisplay().id());
923 EXPECT_EQ(primary, gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); 930 EXPECT_EQ(primary, display::Screen::GetScreen()->GetPrimaryDisplay().id());
924 } 931 }
925 932
926 TEST_F(WindowTreeHostManagerTest, OverscanInsets) { 933 TEST_F(WindowTreeHostManagerTest, OverscanInsets) {
927 if (!SupportsMultipleDisplays()) 934 if (!SupportsMultipleDisplays())
928 return; 935 return;
929 936
930 WindowTreeHostManager* window_tree_host_manager = 937 WindowTreeHostManager* window_tree_host_manager =
931 Shell::GetInstance()->window_tree_host_manager(); 938 Shell::GetInstance()->window_tree_host_manager();
932 TestEventHandler event_handler; 939 TestEventHandler event_handler;
933 Shell::GetInstance()->AddPreTargetHandler(&event_handler); 940 Shell::GetInstance()->AddPreTargetHandler(&event_handler);
934 941
935 UpdateDisplay("120x200,300x400*2"); 942 UpdateDisplay("120x200,300x400*2");
936 gfx::Display display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); 943 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay();
937 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 944 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
938 945
939 window_tree_host_manager->SetOverscanInsets(display1.id(), 946 window_tree_host_manager->SetOverscanInsets(display1.id(),
940 gfx::Insets(10, 15, 20, 25)); 947 gfx::Insets(10, 15, 20, 25));
941 EXPECT_EQ("0,0 80x170", root_windows[0]->bounds().ToString()); 948 EXPECT_EQ("0,0 80x170", root_windows[0]->bounds().ToString());
942 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); 949 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString());
943 EXPECT_EQ("80,0 150x200", 950 EXPECT_EQ("80,0 150x200",
944 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); 951 ScreenUtil::GetSecondaryDisplay().bounds().ToString());
945 952
946 ui::test::EventGenerator generator(root_windows[0]); 953 ui::test::EventGenerator generator(root_windows[0]);
(...skipping 28 matching lines...) Expand all
975 982
976 TEST_F(WindowTreeHostManagerTest, Rotate) { 983 TEST_F(WindowTreeHostManagerTest, Rotate) {
977 if (!SupportsMultipleDisplays()) 984 if (!SupportsMultipleDisplays())
978 return; 985 return;
979 986
980 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 987 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
981 TestEventHandler event_handler; 988 TestEventHandler event_handler;
982 Shell::GetInstance()->AddPreTargetHandler(&event_handler); 989 Shell::GetInstance()->AddPreTargetHandler(&event_handler);
983 990
984 UpdateDisplay("120x200,300x400*2"); 991 UpdateDisplay("120x200,300x400*2");
985 gfx::Display display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); 992 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay();
986 int64_t display2_id = ScreenUtil::GetSecondaryDisplay().id(); 993 int64_t display2_id = ScreenUtil::GetSecondaryDisplay().id();
987 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 994 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
988 ui::test::EventGenerator generator1(root_windows[0]); 995 ui::test::EventGenerator generator1(root_windows[0]);
989 996
990 TestObserver observer; 997 TestObserver observer;
991 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); 998 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString());
992 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); 999 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString());
993 EXPECT_EQ("120,0 150x200", 1000 EXPECT_EQ("120,0 150x200",
994 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); 1001 ScreenUtil::GetSecondaryDisplay().bounds().ToString());
995 generator1.MoveMouseToInHost(50, 40); 1002 generator1.MoveMouseToInHost(50, 40);
996 EXPECT_EQ("50,40", event_handler.GetLocationAndReset()); 1003 EXPECT_EQ("50,40", event_handler.GetLocationAndReset());
997 EXPECT_EQ(gfx::Display::ROTATE_0, GetActiveDisplayRotation(display1.id())); 1004 EXPECT_EQ(display::Display::ROTATE_0,
998 EXPECT_EQ(gfx::Display::ROTATE_0, GetActiveDisplayRotation(display2_id)); 1005 GetActiveDisplayRotation(display1.id()));
1006 EXPECT_EQ(display::Display::ROTATE_0, GetActiveDisplayRotation(display2_id));
999 EXPECT_EQ(0, observer.GetRotationChangedCountAndReset()); 1007 EXPECT_EQ(0, observer.GetRotationChangedCountAndReset());
1000 1008
1001 display_manager->SetDisplayRotation(display1.id(), gfx::Display::ROTATE_90, 1009 display_manager->SetDisplayRotation(display1.id(),
1002 gfx::Display::ROTATION_SOURCE_ACTIVE); 1010 display::Display::ROTATE_90,
1011 display::Display::ROTATION_SOURCE_ACTIVE);
1003 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); 1012 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString());
1004 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); 1013 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString());
1005 EXPECT_EQ("200,0 150x200", 1014 EXPECT_EQ("200,0 150x200",
1006 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); 1015 ScreenUtil::GetSecondaryDisplay().bounds().ToString());
1007 generator1.MoveMouseToInHost(50, 40); 1016 generator1.MoveMouseToInHost(50, 40);
1008 EXPECT_EQ("40,69", event_handler.GetLocationAndReset()); 1017 EXPECT_EQ("40,69", event_handler.GetLocationAndReset());
1009 EXPECT_EQ(gfx::Display::ROTATE_90, GetActiveDisplayRotation(display1.id())); 1018 EXPECT_EQ(display::Display::ROTATE_90,
1010 EXPECT_EQ(gfx::Display::ROTATE_0, GetActiveDisplayRotation(display2_id)); 1019 GetActiveDisplayRotation(display1.id()));
1020 EXPECT_EQ(display::Display::ROTATE_0, GetActiveDisplayRotation(display2_id));
1011 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); 1021 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset());
1012 1022
1013 display_manager->SetLayoutForCurrentDisplays( 1023 display_manager->SetLayoutForCurrentDisplays(
1014 test::CreateDisplayLayout(display::DisplayPlacement::BOTTOM, 50)); 1024 test::CreateDisplayLayout(display::DisplayPlacement::BOTTOM, 50));
1015 EXPECT_EQ("50,120 150x200", 1025 EXPECT_EQ("50,120 150x200",
1016 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); 1026 ScreenUtil::GetSecondaryDisplay().bounds().ToString());
1017 1027
1018 display_manager->SetDisplayRotation(display2_id, gfx::Display::ROTATE_270, 1028 display_manager->SetDisplayRotation(display2_id, display::Display::ROTATE_270,
1019 gfx::Display::ROTATION_SOURCE_ACTIVE); 1029 display::Display::ROTATION_SOURCE_ACTIVE);
1020 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); 1030 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString());
1021 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); 1031 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString());
1022 EXPECT_EQ("50,120 200x150", 1032 EXPECT_EQ("50,120 200x150",
1023 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); 1033 ScreenUtil::GetSecondaryDisplay().bounds().ToString());
1024 EXPECT_EQ(gfx::Display::ROTATE_90, GetActiveDisplayRotation(display1.id())); 1034 EXPECT_EQ(display::Display::ROTATE_90,
1025 EXPECT_EQ(gfx::Display::ROTATE_270, GetActiveDisplayRotation(display2_id)); 1035 GetActiveDisplayRotation(display1.id()));
1036 EXPECT_EQ(display::Display::ROTATE_270,
1037 GetActiveDisplayRotation(display2_id));
1026 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); 1038 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset());
1027 1039
1028 #if !defined(OS_WIN) 1040 #if !defined(OS_WIN)
1029 ui::test::EventGenerator generator2(root_windows[1]); 1041 ui::test::EventGenerator generator2(root_windows[1]);
1030 generator2.MoveMouseToInHost(50, 40); 1042 generator2.MoveMouseToInHost(50, 40);
1031 EXPECT_EQ("179,25", event_handler.GetLocationAndReset()); 1043 EXPECT_EQ("179,25", event_handler.GetLocationAndReset());
1032 display_manager->SetDisplayRotation(display1.id(), gfx::Display::ROTATE_180, 1044 display_manager->SetDisplayRotation(display1.id(),
1033 gfx::Display::ROTATION_SOURCE_ACTIVE); 1045 display::Display::ROTATE_180,
1046 display::Display::ROTATION_SOURCE_ACTIVE);
1034 1047
1035 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); 1048 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString());
1036 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); 1049 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString());
1037 // Dislay must share at least 100, so the x's offset becomes 20. 1050 // Dislay must share at least 100, so the x's offset becomes 20.
1038 EXPECT_EQ("20,200 200x150", 1051 EXPECT_EQ("20,200 200x150",
1039 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); 1052 ScreenUtil::GetSecondaryDisplay().bounds().ToString());
1040 EXPECT_EQ(gfx::Display::ROTATE_180, GetActiveDisplayRotation(display1.id())); 1053 EXPECT_EQ(display::Display::ROTATE_180,
1041 EXPECT_EQ(gfx::Display::ROTATE_270, GetActiveDisplayRotation(display2_id)); 1054 GetActiveDisplayRotation(display1.id()));
1055 EXPECT_EQ(display::Display::ROTATE_270,
1056 GetActiveDisplayRotation(display2_id));
1042 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); 1057 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset());
1043 1058
1044 generator1.MoveMouseToInHost(50, 40); 1059 generator1.MoveMouseToInHost(50, 40);
1045 EXPECT_EQ("69,159", event_handler.GetLocationAndReset()); 1060 EXPECT_EQ("69,159", event_handler.GetLocationAndReset());
1046 #endif 1061 #endif
1047 1062
1048 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); 1063 Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
1049 } 1064 }
1050 1065
1051 TEST_F(WindowTreeHostManagerTest, ScaleRootWindow) { 1066 TEST_F(WindowTreeHostManagerTest, ScaleRootWindow) {
1052 if (!SupportsMultipleDisplays()) 1067 if (!SupportsMultipleDisplays())
1053 return; 1068 return;
1054 1069
1055 TestEventHandler event_handler; 1070 TestEventHandler event_handler;
1056 Shell::GetInstance()->AddPreTargetHandler(&event_handler); 1071 Shell::GetInstance()->AddPreTargetHandler(&event_handler);
1057 1072
1058 UpdateDisplay("600x400*2@1.5,500x300"); 1073 UpdateDisplay("600x400*2@1.5,500x300");
1059 1074
1060 gfx::Display display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); 1075 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay();
1061 test::ScopedSetInternalDisplayId set_internal(display1.id()); 1076 test::ScopedSetInternalDisplayId set_internal(display1.id());
1062 1077
1063 gfx::Display display2 = ScreenUtil::GetSecondaryDisplay(); 1078 display::Display display2 = ScreenUtil::GetSecondaryDisplay();
1064 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1079 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1065 EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); 1080 EXPECT_EQ("0,0 450x300", display1.bounds().ToString());
1066 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); 1081 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString());
1067 EXPECT_EQ("450,0 500x300", display2.bounds().ToString()); 1082 EXPECT_EQ("450,0 500x300", display2.bounds().ToString());
1068 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); 1083 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id()));
1069 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); 1084 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id()));
1070 1085
1071 ui::test::EventGenerator generator(root_windows[0]); 1086 ui::test::EventGenerator generator(root_windows[0]);
1072 generator.MoveMouseToInHost(599, 200); 1087 generator.MoveMouseToInHost(599, 200);
1073 EXPECT_EQ("449,150", event_handler.GetLocationAndReset()); 1088 EXPECT_EQ("449,150", event_handler.GetLocationAndReset());
1074 1089
1075 SetDisplayUIScale(display1.id(), 1.25f); 1090 SetDisplayUIScale(display1.id(), 1.25f);
1076 display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); 1091 display1 = display::Screen::GetScreen()->GetPrimaryDisplay();
1077 display2 = ScreenUtil::GetSecondaryDisplay(); 1092 display2 = ScreenUtil::GetSecondaryDisplay();
1078 EXPECT_EQ("0,0 375x250", display1.bounds().ToString()); 1093 EXPECT_EQ("0,0 375x250", display1.bounds().ToString());
1079 EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString()); 1094 EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString());
1080 EXPECT_EQ("375,0 500x300", display2.bounds().ToString()); 1095 EXPECT_EQ("375,0 500x300", display2.bounds().ToString());
1081 EXPECT_EQ(1.25f, GetStoredUIScale(display1.id())); 1096 EXPECT_EQ(1.25f, GetStoredUIScale(display1.id()));
1082 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id())); 1097 EXPECT_EQ(1.0f, GetStoredUIScale(display2.id()));
1083 1098
1084 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); 1099 Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
1085 } 1100 }
1086 1101
1087 TEST_F(WindowTreeHostManagerTest, TouchScale) { 1102 TEST_F(WindowTreeHostManagerTest, TouchScale) {
1088 if (!SupportsMultipleDisplays()) 1103 if (!SupportsMultipleDisplays())
1089 return; 1104 return;
1090 1105
1091 TestEventHandler event_handler; 1106 TestEventHandler event_handler;
1092 Shell::GetInstance()->AddPreTargetHandler(&event_handler); 1107 Shell::GetInstance()->AddPreTargetHandler(&event_handler);
1093 1108
1094 UpdateDisplay("200x200*2"); 1109 UpdateDisplay("200x200*2");
1095 gfx::Display display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); 1110 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay();
1096 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1111 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1097 aura::Window* root_window = root_windows[0]; 1112 aura::Window* root_window = root_windows[0];
1098 ui::test::EventGenerator generator(root_window); 1113 ui::test::EventGenerator generator(root_window);
1099 1114
1100 generator.PressMoveAndReleaseTouchTo(50, 50); 1115 generator.PressMoveAndReleaseTouchTo(50, 50);
1101 // Default test touches have radius_x/y = 1.0, with device scale 1116 // Default test touches have radius_x/y = 1.0, with device scale
1102 // factor = 2, the scaled radius_x/y should be 0.5. 1117 // factor = 2, the scaled radius_x/y should be 0.5.
1103 EXPECT_EQ(0.5, event_handler.touch_radius_x()); 1118 EXPECT_EQ(0.5, event_handler.touch_radius_x());
1104 EXPECT_EQ(0.5, event_handler.touch_radius_y()); 1119 EXPECT_EQ(0.5, event_handler.touch_radius_y());
1105 1120
(...skipping 12 matching lines...) Expand all
1118 1133
1119 TEST_F(WindowTreeHostManagerTest, ConvertHostToRootCoords) { 1134 TEST_F(WindowTreeHostManagerTest, ConvertHostToRootCoords) {
1120 if (!SupportsMultipleDisplays()) 1135 if (!SupportsMultipleDisplays())
1121 return; 1136 return;
1122 1137
1123 TestEventHandler event_handler; 1138 TestEventHandler event_handler;
1124 Shell::GetInstance()->AddPreTargetHandler(&event_handler); 1139 Shell::GetInstance()->AddPreTargetHandler(&event_handler);
1125 1140
1126 UpdateDisplay("600x400*2/r@1.5"); 1141 UpdateDisplay("600x400*2/r@1.5");
1127 1142
1128 gfx::Display display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); 1143 display::Display display1 = display::Screen::GetScreen()->GetPrimaryDisplay();
1129 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1144 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1130 EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); 1145 EXPECT_EQ("0,0 300x450", display1.bounds().ToString());
1131 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); 1146 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString());
1132 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); 1147 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id()));
1133 1148
1134 ui::test::EventGenerator generator(root_windows[0]); 1149 ui::test::EventGenerator generator(root_windows[0]);
1135 generator.MoveMouseToInHost(0, 0); 1150 generator.MoveMouseToInHost(0, 0);
1136 EXPECT_EQ("0,449", event_handler.GetLocationAndReset()); 1151 EXPECT_EQ("0,449", event_handler.GetLocationAndReset());
1137 generator.MoveMouseToInHost(599, 0); 1152 generator.MoveMouseToInHost(599, 0);
1138 EXPECT_EQ("0,0", event_handler.GetLocationAndReset()); 1153 EXPECT_EQ("0,0", event_handler.GetLocationAndReset());
1139 generator.MoveMouseToInHost(599, 399); 1154 generator.MoveMouseToInHost(599, 399);
1140 EXPECT_EQ("299,0", event_handler.GetLocationAndReset()); 1155 EXPECT_EQ("299,0", event_handler.GetLocationAndReset());
1141 generator.MoveMouseToInHost(0, 399); 1156 generator.MoveMouseToInHost(0, 399);
1142 EXPECT_EQ("299,449", event_handler.GetLocationAndReset()); 1157 EXPECT_EQ("299,449", event_handler.GetLocationAndReset());
1143 1158
1144 UpdateDisplay("600x400*2/u@1.5"); 1159 UpdateDisplay("600x400*2/u@1.5");
1145 display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); 1160 display1 = display::Screen::GetScreen()->GetPrimaryDisplay();
1146 root_windows = Shell::GetAllRootWindows(); 1161 root_windows = Shell::GetAllRootWindows();
1147 EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); 1162 EXPECT_EQ("0,0 450x300", display1.bounds().ToString());
1148 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); 1163 EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString());
1149 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); 1164 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id()));
1150 1165
1151 generator.MoveMouseToInHost(0, 0); 1166 generator.MoveMouseToInHost(0, 0);
1152 EXPECT_EQ("449,299", event_handler.GetLocationAndReset()); 1167 EXPECT_EQ("449,299", event_handler.GetLocationAndReset());
1153 generator.MoveMouseToInHost(599, 0); 1168 generator.MoveMouseToInHost(599, 0);
1154 EXPECT_EQ("0,299", event_handler.GetLocationAndReset()); 1169 EXPECT_EQ("0,299", event_handler.GetLocationAndReset());
1155 generator.MoveMouseToInHost(599, 399); 1170 generator.MoveMouseToInHost(599, 399);
1156 EXPECT_EQ("0,0", event_handler.GetLocationAndReset()); 1171 EXPECT_EQ("0,0", event_handler.GetLocationAndReset());
1157 generator.MoveMouseToInHost(0, 399); 1172 generator.MoveMouseToInHost(0, 399);
1158 EXPECT_EQ("449,0", event_handler.GetLocationAndReset()); 1173 EXPECT_EQ("449,0", event_handler.GetLocationAndReset());
1159 1174
1160 UpdateDisplay("600x400*2/l@1.5"); 1175 UpdateDisplay("600x400*2/l@1.5");
1161 display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); 1176 display1 = display::Screen::GetScreen()->GetPrimaryDisplay();
1162 root_windows = Shell::GetAllRootWindows(); 1177 root_windows = Shell::GetAllRootWindows();
1163 EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); 1178 EXPECT_EQ("0,0 300x450", display1.bounds().ToString());
1164 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); 1179 EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString());
1165 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id())); 1180 EXPECT_EQ(1.5f, GetStoredUIScale(display1.id()));
1166 1181
1167 generator.MoveMouseToInHost(0, 0); 1182 generator.MoveMouseToInHost(0, 0);
1168 EXPECT_EQ("299,0", event_handler.GetLocationAndReset()); 1183 EXPECT_EQ("299,0", event_handler.GetLocationAndReset());
1169 generator.MoveMouseToInHost(599, 0); 1184 generator.MoveMouseToInHost(599, 0);
1170 EXPECT_EQ("299,449", event_handler.GetLocationAndReset()); 1185 EXPECT_EQ("299,449", event_handler.GetLocationAndReset());
1171 generator.MoveMouseToInHost(599, 399); 1186 generator.MoveMouseToInHost(599, 399);
1172 EXPECT_EQ("0,449", event_handler.GetLocationAndReset()); 1187 EXPECT_EQ("0,449", event_handler.GetLocationAndReset());
1173 generator.MoveMouseToInHost(0, 399); 1188 generator.MoveMouseToInHost(0, 399);
1174 EXPECT_EQ("0,0", event_handler.GetLocationAndReset()); 1189 EXPECT_EQ("0,0", event_handler.GetLocationAndReset());
1175 1190
1176 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); 1191 Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
1177 } 1192 }
1178 1193
1179 // Make sure that the compositor based mirroring can switch 1194 // Make sure that the compositor based mirroring can switch
1180 // from/to dock mode. 1195 // from/to dock mode.
1181 TEST_F(WindowTreeHostManagerTest, DockToSingle) { 1196 TEST_F(WindowTreeHostManagerTest, DockToSingle) {
1182 if (!SupportsMultipleDisplays()) 1197 if (!SupportsMultipleDisplays())
1183 return; 1198 return;
1184 1199
1185 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 1200 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
1186 1201
1187 const int64_t internal_id = 1; 1202 const int64_t internal_id = 1;
1188 1203
1189 const DisplayInfo internal_display_info = 1204 const DisplayInfo internal_display_info =
1190 CreateDisplayInfo(internal_id, 0, gfx::Display::ROTATE_0); 1205 CreateDisplayInfo(internal_id, 0, display::Display::ROTATE_0);
1191 const DisplayInfo external_display_info = 1206 const DisplayInfo external_display_info =
1192 CreateDisplayInfo(2, 1, gfx::Display::ROTATE_90); 1207 CreateDisplayInfo(2, 1, display::Display::ROTATE_90);
1193 1208
1194 std::vector<DisplayInfo> display_info_list; 1209 std::vector<DisplayInfo> display_info_list;
1195 // Extended 1210 // Extended
1196 display_info_list.push_back(internal_display_info); 1211 display_info_list.push_back(internal_display_info);
1197 display_info_list.push_back(external_display_info); 1212 display_info_list.push_back(external_display_info);
1198 display_manager->OnNativeDisplaysChanged(display_info_list); 1213 display_manager->OnNativeDisplaysChanged(display_info_list);
1199 const int64_t internal_display_id = 1214 const int64_t internal_display_id =
1200 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); 1215 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay();
1201 EXPECT_EQ(internal_id, internal_display_id); 1216 EXPECT_EQ(internal_id, internal_display_id);
1202 EXPECT_EQ(2U, display_manager->GetNumDisplays()); 1217 EXPECT_EQ(2U, display_manager->GetNumDisplays());
(...skipping 20 matching lines...) Expand all
1223 } 1238 }
1224 1239
1225 // Tests if switching two displays at the same time while the primary display 1240 // Tests if switching two displays at the same time while the primary display
1226 // is swapped should not cause a crash. (crbug.com/426292) 1241 // is swapped should not cause a crash. (crbug.com/426292)
1227 TEST_F(WindowTreeHostManagerTest, ReplaceSwappedPrimary) { 1242 TEST_F(WindowTreeHostManagerTest, ReplaceSwappedPrimary) {
1228 if (!SupportsMultipleDisplays()) 1243 if (!SupportsMultipleDisplays())
1229 return; 1244 return;
1230 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 1245 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
1231 1246
1232 const DisplayInfo first_display_info = 1247 const DisplayInfo first_display_info =
1233 CreateDisplayInfo(10, 0, gfx::Display::ROTATE_0); 1248 CreateDisplayInfo(10, 0, display::Display::ROTATE_0);
1234 const DisplayInfo second_display_info = 1249 const DisplayInfo second_display_info =
1235 CreateDisplayInfo(11, 1, gfx::Display::ROTATE_0); 1250 CreateDisplayInfo(11, 1, display::Display::ROTATE_0);
1236 1251
1237 std::vector<DisplayInfo> display_info_list; 1252 std::vector<DisplayInfo> display_info_list;
1238 // Extended 1253 // Extended
1239 display_info_list.push_back(first_display_info); 1254 display_info_list.push_back(first_display_info);
1240 display_info_list.push_back(second_display_info); 1255 display_info_list.push_back(second_display_info);
1241 display_manager->OnNativeDisplaysChanged(display_info_list); 1256 display_manager->OnNativeDisplaysChanged(display_info_list);
1242 1257
1243 test::SwapPrimaryDisplay(); 1258 test::SwapPrimaryDisplay();
1244 1259
1245 EXPECT_EQ(11, gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); 1260 EXPECT_EQ(11, display::Screen::GetScreen()->GetPrimaryDisplay().id());
1246 1261
1247 display_info_list.clear(); 1262 display_info_list.clear();
1248 const DisplayInfo new_first_display_info = 1263 const DisplayInfo new_first_display_info =
1249 CreateDisplayInfo(20, 0, gfx::Display::ROTATE_0); 1264 CreateDisplayInfo(20, 0, display::Display::ROTATE_0);
1250 const DisplayInfo new_second_display_info = 1265 const DisplayInfo new_second_display_info =
1251 CreateDisplayInfo(21, 1, gfx::Display::ROTATE_0); 1266 CreateDisplayInfo(21, 1, display::Display::ROTATE_0);
1252 display_info_list.push_back(new_first_display_info); 1267 display_info_list.push_back(new_first_display_info);
1253 display_info_list.push_back(new_second_display_info); 1268 display_info_list.push_back(new_second_display_info);
1254 display_manager->OnNativeDisplaysChanged(display_info_list); 1269 display_manager->OnNativeDisplaysChanged(display_info_list);
1255 1270
1256 EXPECT_EQ(20, gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); 1271 EXPECT_EQ(20, display::Screen::GetScreen()->GetPrimaryDisplay().id());
1257 } 1272 }
1258 1273
1259 namespace { 1274 namespace {
1260 1275
1261 class RootWindowTestObserver : public aura::WindowObserver { 1276 class RootWindowTestObserver : public aura::WindowObserver {
1262 public: 1277 public:
1263 RootWindowTestObserver() {} 1278 RootWindowTestObserver() {}
1264 ~RootWindowTestObserver() override {} 1279 ~RootWindowTestObserver() override {}
1265 1280
1266 void OnWindowBoundsChanged(aura::Window* window, 1281 void OnWindowBoundsChanged(aura::Window* window,
(...skipping 19 matching lines...) Expand all
1286 // 1) Two displays connected: a) b) 1301 // 1) Two displays connected: a) b)
1287 // 2) both are disconnected and new one with the same size as b) is connected 1302 // 2) both are disconnected and new one with the same size as b) is connected
1288 // in one configuration event. 1303 // in one configuration event.
1289 // See crbug.com/547280. 1304 // See crbug.com/547280.
1290 TEST_F(WindowTreeHostManagerTest, ReplacePrimary) { 1305 TEST_F(WindowTreeHostManagerTest, ReplacePrimary) {
1291 if (!SupportsMultipleDisplays()) 1306 if (!SupportsMultipleDisplays())
1292 return; 1307 return;
1293 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 1308 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
1294 1309
1295 DisplayInfo first_display_info = 1310 DisplayInfo first_display_info =
1296 CreateDisplayInfo(10, 0, gfx::Display::ROTATE_0); 1311 CreateDisplayInfo(10, 0, display::Display::ROTATE_0);
1297 first_display_info.SetBounds(gfx::Rect(0, 0, 400, 400)); 1312 first_display_info.SetBounds(gfx::Rect(0, 0, 400, 400));
1298 const DisplayInfo second_display_info = 1313 const DisplayInfo second_display_info =
1299 CreateDisplayInfo(11, 500, gfx::Display::ROTATE_0); 1314 CreateDisplayInfo(11, 500, display::Display::ROTATE_0);
1300 1315
1301 std::vector<DisplayInfo> display_info_list; 1316 std::vector<DisplayInfo> display_info_list;
1302 // Extended 1317 // Extended
1303 display_info_list.push_back(first_display_info); 1318 display_info_list.push_back(first_display_info);
1304 display_info_list.push_back(second_display_info); 1319 display_info_list.push_back(second_display_info);
1305 display_manager->OnNativeDisplaysChanged(display_info_list); 1320 display_manager->OnNativeDisplaysChanged(display_info_list);
1306 aura::Window* primary_root = Shell::GetAllRootWindows()[0]; 1321 aura::Window* primary_root = Shell::GetAllRootWindows()[0];
1307 1322
1308 int64_t new_display_id = 20; 1323 int64_t new_display_id = 20;
1309 RootWindowTestObserver test_observer; 1324 RootWindowTestObserver test_observer;
1310 primary_root->AddObserver(&test_observer); 1325 primary_root->AddObserver(&test_observer);
1311 1326
1312 display_info_list.clear(); 1327 display_info_list.clear();
1313 const DisplayInfo new_first_display_info = 1328 const DisplayInfo new_first_display_info =
1314 CreateDisplayInfo(new_display_id, 0, gfx::Display::ROTATE_0); 1329 CreateDisplayInfo(new_display_id, 0, display::Display::ROTATE_0);
1315 1330
1316 display_info_list.push_back(new_first_display_info); 1331 display_info_list.push_back(new_first_display_info);
1317 display_manager->OnNativeDisplaysChanged(display_info_list); 1332 display_manager->OnNativeDisplaysChanged(display_info_list);
1318 EXPECT_EQ("0,0 500x500", test_observer.shelf_display_bounds().ToString()); 1333 EXPECT_EQ("0,0 500x500", test_observer.shelf_display_bounds().ToString());
1319 primary_root->RemoveObserver(&test_observer); 1334 primary_root->RemoveObserver(&test_observer);
1320 } 1335 }
1321 1336
1322 TEST_F(WindowTreeHostManagerTest, UpdateMouseLocationAfterDisplayChange) { 1337 TEST_F(WindowTreeHostManagerTest, UpdateMouseLocationAfterDisplayChange) {
1323 if (!SupportsMultipleDisplays()) 1338 if (!SupportsMultipleDisplays())
1324 return; 1339 return;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 Shell* shell = Shell::GetInstance(); 1428 Shell* shell = Shell::GetInstance();
1414 WindowTreeHostManager* window_tree_host_manager = 1429 WindowTreeHostManager* window_tree_host_manager =
1415 shell->window_tree_host_manager(); 1430 shell->window_tree_host_manager();
1416 test::CursorManagerTestApi test_api(shell->cursor_manager()); 1431 test::CursorManagerTestApi test_api(shell->cursor_manager());
1417 1432
1418 window_tree_host_manager->GetPrimaryRootWindow()->MoveCursorTo( 1433 window_tree_host_manager->GetPrimaryRootWindow()->MoveCursorTo(
1419 gfx::Point(20, 50)); 1434 gfx::Point(20, 50));
1420 1435
1421 EXPECT_EQ("20,50", env->last_mouse_location().ToString()); 1436 EXPECT_EQ("20,50", env->last_mouse_location().ToString());
1422 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); 1437 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor());
1423 EXPECT_EQ(gfx::Display::ROTATE_0, test_api.GetCurrentCursorRotation()); 1438 EXPECT_EQ(display::Display::ROTATE_0, test_api.GetCurrentCursorRotation());
1424 1439
1425 test::SwapPrimaryDisplay(); 1440 test::SwapPrimaryDisplay();
1426 1441
1427 EXPECT_EQ("20,50", env->last_mouse_location().ToString()); 1442 EXPECT_EQ("20,50", env->last_mouse_location().ToString());
1428 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); 1443 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor());
1429 EXPECT_EQ(gfx::Display::ROTATE_90, test_api.GetCurrentCursorRotation()); 1444 EXPECT_EQ(display::Display::ROTATE_90, test_api.GetCurrentCursorRotation());
1430 } 1445 }
1431 1446
1432 // Test that the cursor moves to the other display and that its scale factor 1447 // Test that the cursor moves to the other display and that its scale factor
1433 // and rotation are updated when the primary display is disconnected. 1448 // and rotation are updated when the primary display is disconnected.
1434 TEST_F(WindowTreeHostManagerTest, 1449 TEST_F(WindowTreeHostManagerTest,
1435 UpdateMouseLocationAfterDisplayChange_PrimaryDisconnected) { 1450 UpdateMouseLocationAfterDisplayChange_PrimaryDisconnected) {
1436 if (!SupportsMultipleDisplays()) 1451 if (!SupportsMultipleDisplays())
1437 return; 1452 return;
1438 1453
1439 aura::Env* env = aura::Env::GetInstance(); 1454 aura::Env* env = aura::Env::GetInstance();
1440 Shell* shell = Shell::GetInstance(); 1455 Shell* shell = Shell::GetInstance();
1441 WindowTreeHostManager* window_tree_host_manager = 1456 WindowTreeHostManager* window_tree_host_manager =
1442 shell->window_tree_host_manager(); 1457 shell->window_tree_host_manager();
1443 test::CursorManagerTestApi test_api(shell->cursor_manager()); 1458 test::CursorManagerTestApi test_api(shell->cursor_manager());
1444 1459
1445 UpdateDisplay("300x300*2/r,200x200"); 1460 UpdateDisplay("300x300*2/r,200x200");
1446 // Swap the primary display to make it possible to remove the primary display 1461 // Swap the primary display to make it possible to remove the primary display
1447 // via UpdateDisplay(). 1462 // via UpdateDisplay().
1448 test::SwapPrimaryDisplay(); 1463 test::SwapPrimaryDisplay();
1449 int primary_display_id = window_tree_host_manager->GetPrimaryDisplayId(); 1464 int primary_display_id = window_tree_host_manager->GetPrimaryDisplayId();
1450 1465
1451 window_tree_host_manager->GetPrimaryRootWindow()->MoveCursorTo( 1466 window_tree_host_manager->GetPrimaryRootWindow()->MoveCursorTo(
1452 gfx::Point(20, 50)); 1467 gfx::Point(20, 50));
1453 1468
1454 EXPECT_EQ("20,50", env->last_mouse_location().ToString()); 1469 EXPECT_EQ("20,50", env->last_mouse_location().ToString());
1455 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); 1470 EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor());
1456 EXPECT_EQ(gfx::Display::ROTATE_0, test_api.GetCurrentCursorRotation()); 1471 EXPECT_EQ(display::Display::ROTATE_0, test_api.GetCurrentCursorRotation());
1457 1472
1458 UpdateDisplay("300x300*2/r"); 1473 UpdateDisplay("300x300*2/r");
1459 ASSERT_NE(primary_display_id, 1474 ASSERT_NE(primary_display_id,
1460 window_tree_host_manager->GetPrimaryDisplayId()); 1475 window_tree_host_manager->GetPrimaryDisplayId());
1461 1476
1462 // Cursor should be centered on the remaining display. 1477 // Cursor should be centered on the remaining display.
1463 EXPECT_EQ("75,75", env->last_mouse_location().ToString()); 1478 EXPECT_EQ("75,75", env->last_mouse_location().ToString());
1464 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); 1479 EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor());
1465 EXPECT_EQ(gfx::Display::ROTATE_90, test_api.GetCurrentCursorRotation()); 1480 EXPECT_EQ(display::Display::ROTATE_90, test_api.GetCurrentCursorRotation());
1466 } 1481 }
1467 1482
1468 // GetRootWindowForDisplayId() for removed gfx::Display during 1483 // GetRootWindowForDisplayId() for removed display::Display during
1469 // OnDisplayRemoved() should not cause crash. See http://crbug.com/415222 1484 // OnDisplayRemoved() should not cause crash. See http://crbug.com/415222
1470 TEST_F(WindowTreeHostManagerTest, 1485 TEST_F(WindowTreeHostManagerTest,
1471 GetRootWindowForDisplayIdDuringDisplayDisconnection) { 1486 GetRootWindowForDisplayIdDuringDisplayDisconnection) {
1472 if (!SupportsMultipleDisplays()) 1487 if (!SupportsMultipleDisplays())
1473 return; 1488 return;
1474 1489
1475 UpdateDisplay("300x300,200x200"); 1490 UpdateDisplay("300x300,200x200");
1476 aura::Window* root2 = 1491 aura::Window* root2 =
1477 Shell::GetInstance() 1492 Shell::GetInstance()
1478 ->window_tree_host_manager() 1493 ->window_tree_host_manager()
(...skipping 14 matching lines...) Expand all
1493 widget->GetNativeWindow()->GetRootWindow()); 1508 widget->GetNativeWindow()->GetRootWindow());
1494 event_generator.MoveMouseToCenterOf(widget->GetNativeWindow()); 1509 event_generator.MoveMouseToCenterOf(widget->GetNativeWindow());
1495 1510
1496 UpdateDisplay("300x300"); 1511 UpdateDisplay("300x300");
1497 watcher.Stop(); 1512 watcher.Stop();
1498 1513
1499 widget->CloseNow(); 1514 widget->CloseNow();
1500 } 1515 }
1501 1516
1502 } // namespace ash 1517 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/window_tree_host_manager.cc ('k') | ash/drag_drop/drag_drop_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698