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

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

Issue 738243002: Notify primary display reassignment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed Created 6 years, 1 month 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 | « no previous file | ash/display/display_manager.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/display_controller.h" 5 #include "ash/display/display_controller.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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 public gfx::DisplayObserver, 62 public gfx::DisplayObserver,
63 public aura::client::FocusChangeObserver, 63 public aura::client::FocusChangeObserver,
64 public aura::client::ActivationChangeObserver { 64 public aura::client::ActivationChangeObserver {
65 public: 65 public:
66 TestObserver() 66 TestObserver()
67 : changing_count_(0), 67 : changing_count_(0),
68 changed_count_(0), 68 changed_count_(0),
69 bounds_changed_count_(0), 69 bounds_changed_count_(0),
70 rotation_changed_count_(0), 70 rotation_changed_count_(0),
71 workarea_changed_count_(0), 71 workarea_changed_count_(0),
72 primary_changed_count_(0),
72 changed_display_id_(0), 73 changed_display_id_(0),
73 focus_changed_count_(0), 74 focus_changed_count_(0),
74 activation_changed_count_(0) { 75 activation_changed_count_(0) {
75 Shell::GetInstance()->display_controller()->AddObserver(this); 76 Shell::GetInstance()->display_controller()->AddObserver(this);
76 Shell::GetScreen()->AddObserver(this); 77 Shell::GetScreen()->AddObserver(this);
77 aura::client::GetFocusClient(Shell::GetPrimaryRootWindow())-> 78 aura::client::GetFocusClient(Shell::GetPrimaryRootWindow())->
78 AddObserver(this); 79 AddObserver(this);
79 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> 80 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())->
80 AddObserver(this); 81 AddObserver(this);
81 } 82 }
(...skipping 14 matching lines...) Expand all
96 // Overrideen from gfx::DisplayObserver 97 // Overrideen from gfx::DisplayObserver
97 void OnDisplayMetricsChanged(const gfx::Display& display, 98 void OnDisplayMetricsChanged(const gfx::Display& display,
98 uint32_t metrics) override { 99 uint32_t metrics) override {
99 changed_display_id_ = display.id(); 100 changed_display_id_ = display.id();
100 if (metrics & DISPLAY_METRIC_BOUNDS) 101 if (metrics & DISPLAY_METRIC_BOUNDS)
101 ++bounds_changed_count_; 102 ++bounds_changed_count_;
102 if (metrics & DISPLAY_METRIC_ROTATION) 103 if (metrics & DISPLAY_METRIC_ROTATION)
103 ++rotation_changed_count_; 104 ++rotation_changed_count_;
104 if (metrics & DISPLAY_METRIC_WORK_AREA) 105 if (metrics & DISPLAY_METRIC_WORK_AREA)
105 ++workarea_changed_count_; 106 ++workarea_changed_count_;
107 if (metrics & DISPLAY_METRIC_PRIMARY)
108 ++primary_changed_count_;
106 } 109 }
107 void OnDisplayAdded(const gfx::Display& new_display) override {} 110 void OnDisplayAdded(const gfx::Display& new_display) override {}
108 void OnDisplayRemoved(const gfx::Display& old_display) override {} 111 void OnDisplayRemoved(const gfx::Display& old_display) override {}
109 112
110 // Overridden from aura::client::FocusChangeObserver 113 // Overridden from aura::client::FocusChangeObserver
111 void OnWindowFocused(aura::Window* gained_focus, 114 void OnWindowFocused(aura::Window* gained_focus,
112 aura::Window* lost_focus) override { 115 aura::Window* lost_focus) override {
113 focus_changed_count_++; 116 focus_changed_count_++;
114 } 117 }
115 118
(...skipping 16 matching lines...) Expand all
132 } 135 }
133 136
134 int64 GetRotationChangedCountAndReset() { 137 int64 GetRotationChangedCountAndReset() {
135 return Resetter<int>(&rotation_changed_count_).value(); 138 return Resetter<int>(&rotation_changed_count_).value();
136 } 139 }
137 140
138 int64 GetWorkareaChangedCountAndReset() { 141 int64 GetWorkareaChangedCountAndReset() {
139 return Resetter<int>(&workarea_changed_count_).value(); 142 return Resetter<int>(&workarea_changed_count_).value();
140 } 143 }
141 144
145 int64 GetPrimaryChangedCountAndReset() {
146 return Resetter<int>(&primary_changed_count_).value();
147 }
148
142 int64 GetChangedDisplayIdAndReset() { 149 int64 GetChangedDisplayIdAndReset() {
143 return Resetter<int64>(&changed_display_id_).value(); 150 return Resetter<int64>(&changed_display_id_).value();
144 } 151 }
145 152
146 int GetFocusChangedCountAndReset() { 153 int GetFocusChangedCountAndReset() {
147 return Resetter<int>(&focus_changed_count_).value(); 154 return Resetter<int>(&focus_changed_count_).value();
148 } 155 }
149 156
150 int GetActivationChangedCountAndReset() { 157 int GetActivationChangedCountAndReset() {
151 return Resetter<int>(&activation_changed_count_).value(); 158 return Resetter<int>(&activation_changed_count_).value();
152 } 159 }
153 160
154 private: 161 private:
155 int changing_count_; 162 int changing_count_;
156 int changed_count_; 163 int changed_count_;
157 164
158 int bounds_changed_count_; 165 int bounds_changed_count_;
159 int rotation_changed_count_; 166 int rotation_changed_count_;
160 int workarea_changed_count_; 167 int workarea_changed_count_;
168 int primary_changed_count_;
161 int64 changed_display_id_; 169 int64 changed_display_id_;
162 170
163 int focus_changed_count_; 171 int focus_changed_count_;
164 int activation_changed_count_; 172 int activation_changed_count_;
165 173
166 DISALLOW_COPY_AND_ASSIGN(TestObserver); 174 DISALLOW_COPY_AND_ASSIGN(TestObserver);
167 }; 175 };
168 176
169 gfx::Display GetPrimaryDisplay() { 177 gfx::Display GetPrimaryDisplay() {
170 return Shell::GetScreen()->GetDisplayNearestWindow( 178 return Shell::GetScreen()->GetDisplayNearestWindow(
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 window_state->OnWMEvent(&toggle_fullscreen_event); 582 window_state->OnWMEvent(&toggle_fullscreen_event);
575 EXPECT_TRUE(window_state->IsFullscreen()); 583 EXPECT_TRUE(window_state->IsFullscreen());
576 EXPECT_EQ("0,0 250x250", w1->bounds().ToString()); 584 EXPECT_EQ("0,0 250x250", w1->bounds().ToString());
577 // Dock mode. 585 // Dock mode.
578 TestObserver observer; 586 TestObserver observer;
579 display_info_list.clear(); 587 display_info_list.clear();
580 display_info_list.push_back(external_display_info); 588 display_info_list.push_back(external_display_info);
581 display_manager->OnNativeDisplaysChanged(display_info_list); 589 display_manager->OnNativeDisplaysChanged(display_info_list);
582 EXPECT_EQ(1U, display_manager->GetNumDisplays()); 590 EXPECT_EQ(1U, display_manager->GetNumDisplays());
583 EXPECT_EQ(1U, display_manager->num_connected_displays()); 591 EXPECT_EQ(1U, display_manager->num_connected_displays());
584 EXPECT_EQ(0, observer.GetChangedDisplayIdAndReset()); 592 // Observers are called due to primary change.
585 EXPECT_EQ(0, observer.GetBoundsChangedCountAndReset()); 593 EXPECT_EQ(2, observer.GetChangedDisplayIdAndReset());
586 EXPECT_EQ(0, observer.GetWorkareaChangedCountAndReset()); 594 EXPECT_EQ(1, observer.GetBoundsChangedCountAndReset());
595 EXPECT_EQ(1, observer.GetWorkareaChangedCountAndReset());
596 EXPECT_EQ(1, observer.GetPrimaryChangedCountAndReset());
587 EXPECT_EQ(1, observer.CountAndReset()); 597 EXPECT_EQ(1, observer.CountAndReset());
588 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); 598 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset());
589 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); 599 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset());
590 600
591 EXPECT_TRUE(window_state->IsFullscreen()); 601 EXPECT_TRUE(window_state->IsFullscreen());
592 EXPECT_EQ("0,0 500x500", w1->bounds().ToString()); 602 EXPECT_EQ("0,0 500x500", w1->bounds().ToString());
593 } 603 }
594 604
595 TEST_F(DisplayControllerTest, BoundsUpdated) { 605 TEST_F(DisplayControllerTest, BoundsUpdated) {
596 if (!SupportsMultipleDisplays()) 606 if (!SupportsMultipleDisplays())
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetHost())); 1337 EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetHost()));
1328 1338
1329 // Switching back to single display. 1339 // Switching back to single display.
1330 UpdateDisplay("300x400"); 1340 UpdateDisplay("300x400");
1331 EXPECT_EQ("aura_root_0", GetXWindowName( 1341 EXPECT_EQ("aura_root_0", GetXWindowName(
1332 Shell::GetPrimaryRootWindow()->GetHost())); 1342 Shell::GetPrimaryRootWindow()->GetHost()));
1333 } 1343 }
1334 #endif 1344 #endif
1335 1345
1336 } // namespace ash 1346 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/display/display_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698