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

Side by Side Diff: services/ui/display/platform_screen_ozone_unittests.cc

Issue 2461513002: Primary display change notifications. (Closed)
Patch Set: Fixes for sky. Created 4 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <memory> 5 #include <memory>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/strings/string_number_conversions.h"
11 #include "services/ui/display/platform_screen.h" 12 #include "services/ui/display/platform_screen.h"
12 #include "services/ui/display/platform_screen_ozone.h" 13 #include "services/ui/display/platform_screen_ozone.h"
13 #include "services/ui/display/viewport_metrics.h" 14 #include "services/ui/display/viewport_metrics.h"
14 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 #include "ui/display/chromeos/display_configurator.h"
17 #include "ui/display/display_switches.h" 17 #include "ui/display/display_switches.h"
18 #include "ui/display/fake_display_snapshot.h" 18 #include "ui/display/fake_display_snapshot.h"
19 #include "ui/display/types/display_constants.h" 19 #include "ui/display/types/display_constants.h"
20 #include "ui/display/types/display_mode.h" 20 #include "ui/display/types/display_mode.h"
21 #include "ui/display/types/display_snapshot.h" 21 #include "ui/display/types/display_snapshot.h"
22 #include "ui/ozone/public/ozone_platform.h" 22 #include "ui/ozone/public/ozone_platform.h"
23 23
24 namespace display { 24 namespace display {
25 25
26 using ui::DisplayConfigurator;
27 using ui::DisplayMode; 26 using ui::DisplayMode;
28 using ui::DisplaySnapshot; 27 using ui::DisplaySnapshot;
29 using ui::DisplaySnapshotVirtual;
30 using testing::IsEmpty; 28 using testing::IsEmpty;
31 using testing::SizeIs; 29 using testing::SizeIs;
32 30
33 namespace { 31 namespace {
34 32
35 // The ID of default "display" that gets added when running off device.
36 const int64_t kDefaultDisplayId = 1;
37
38 // Holds info about the display state we want to test. 33 // Holds info about the display state we want to test.
39 struct DisplayState { 34 struct DisplayState {
40 int64_t id; 35 int64_t id;
41 ViewportMetrics metrics; 36 ViewportMetrics metrics;
42 }; 37 };
43 38
44 // Matchers that operate on DisplayState. 39 // Matchers that operate on DisplayState.
45 MATCHER_P(DisplayId, display_id, "") { 40 MATCHER_P(DisplayId, display_id, "") {
46 *result_listener << "has id " << arg.id; 41 *result_listener << "has id " << arg.id;
47 return arg.id == display_id; 42 return arg.id == display_id;
(...skipping 18 matching lines...) Expand all
66 .SetCurrentMode(size) 61 .SetCurrentMode(size)
67 .Build(); 62 .Build();
68 } 63 }
69 64
70 // Test delegate to track what functions calls the delegate receives. 65 // Test delegate to track what functions calls the delegate receives.
71 class TestPlatformScreenDelegate : public PlatformScreenDelegate { 66 class TestPlatformScreenDelegate : public PlatformScreenDelegate {
72 public: 67 public:
73 TestPlatformScreenDelegate() {} 68 TestPlatformScreenDelegate() {}
74 ~TestPlatformScreenDelegate() override {} 69 ~TestPlatformScreenDelegate() override {}
75 70
76 std::vector<DisplayState> added() { return added_; } 71 const std::vector<DisplayState>& added() { return added_; }
sky 2016/10/28 19:59:36 const functions too?
kylechar 2016/10/28 20:43:52 Done.
77 std::vector<DisplayState> removed() { return removed_; } 72 const std::vector<DisplayState>& modified() { return modified_; }
78 std::vector<DisplayState> modified() { return modified_; } 73
74 // Returns a string containing the function calls that PlatformScreenDelegate
75 // has received in the order they occured. Each function call will be in the
76 // form "<action>(<id>)" and multiple function calls will be separated by ";".
77 // For example, if display 2 was added then display 1 was modified, changes()
78 // would return "Added(2);Modified(1)".
79 const std::string& changes() { return changes_; }
79 80
80 void Reset() { 81 void Reset() {
81 added_.clear(); 82 added_.clear();
82 removed_.clear();
83 modified_.clear(); 83 modified_.clear();
84 changes_.clear();
84 } 85 }
85 86
86 private: 87 private:
88 void AddChange(const std::string& name, const std::string& value) {
89 if (!changes_.empty())
90 changes_ += ";";
91 changes_ += name + "(" + value + ")";
92 }
93
87 void OnDisplayAdded(int64_t id, const ViewportMetrics& metrics) override { 94 void OnDisplayAdded(int64_t id, const ViewportMetrics& metrics) override {
88 added_.push_back({id, metrics}); 95 added_.push_back({id, metrics});
96 AddChange("Added", base::Int64ToString(id));
89 } 97 }
90 98
91 void OnDisplayRemoved(int64_t id) override { 99 void OnDisplayRemoved(int64_t id) override {
92 removed_.push_back({id, ViewportMetrics()}); 100 AddChange("Removed", base::Int64ToString(id));
93 } 101 }
94 102
95 void OnDisplayModified(int64_t id, const ViewportMetrics& metrics) override { 103 void OnDisplayModified(int64_t id, const ViewportMetrics& metrics) override {
96 modified_.push_back({id, metrics}); 104 modified_.push_back({id, metrics});
105 AddChange("Modified", base::Int64ToString(id));
106 }
107
108 void OnPrimaryDisplayChanged(int64_t primary_display_id) override {
109 AddChange("Primary", base::Int64ToString(primary_display_id));
97 } 110 }
98 111
99 std::vector<DisplayState> added_; 112 std::vector<DisplayState> added_;
100 std::vector<DisplayState> removed_;
101 std::vector<DisplayState> modified_; 113 std::vector<DisplayState> modified_;
114 std::string changes_;
102 115
103 DISALLOW_COPY_AND_ASSIGN(TestPlatformScreenDelegate); 116 DISALLOW_COPY_AND_ASSIGN(TestPlatformScreenDelegate);
104 }; 117 };
105 118
119 } // namespace
120
106 // Test fixture with helpers to act like ui::DisplayConfigurator and send 121 // Test fixture with helpers to act like ui::DisplayConfigurator and send
107 // OnDisplayModeChanged() to PlatformScreenOzone. 122 // OnDisplayModeChanged() to PlatformScreenOzone.
108 class PlatformScreenOzoneTest : public testing::Test { 123 class PlatformScreenOzoneTest : public testing::Test {
109 public: 124 public:
110 PlatformScreenOzoneTest() {} 125 PlatformScreenOzoneTest() {}
111 ~PlatformScreenOzoneTest() override {} 126 ~PlatformScreenOzoneTest() override {}
112 127
113 PlatformScreen* platform_screen() { return platform_screen_.get(); } 128 PlatformScreenOzone* platform_screen() { return platform_screen_.get(); }
114 TestPlatformScreenDelegate* delegate() { return &delegate_; } 129 TestPlatformScreenDelegate* delegate() { return &delegate_; }
115 130
116 // Adds a display snapshot with specified ID and default size. 131 // Adds a display snapshot with specified ID and default size.
117 void AddDisplay(int64_t id) { return AddDisplay(id, gfx::Size(1024, 768)); } 132 void AddDisplay(int64_t id) { return AddDisplay(id, gfx::Size(1024, 768)); }
118 133
119 // Adds a display snapshot with specified ID and size to list of snapshots. 134 // Adds a display snapshot with specified ID and size to list of snapshots.
120 void AddDisplay(int64_t id, const gfx::Size& size) { 135 void AddDisplay(int64_t id, const gfx::Size& size) {
121 snapshots_.push_back(MakeSnapshot(id, size)); 136 snapshots_.push_back(MakeSnapshot(id, size));
137 TriggerOnDisplayModeChanged();
122 } 138 }
123 139
124 // Removes display snapshot with specified ID. 140 // Removes display snapshot with specified ID.
125 void RemoveDisplay(int64_t id) { 141 void RemoveDisplay(int64_t id) {
126 snapshots_.erase( 142 snapshots_.erase(
127 std::remove_if(snapshots_.begin(), snapshots_.end(), 143 std::remove_if(snapshots_.begin(), snapshots_.end(),
128 [id](std::unique_ptr<DisplaySnapshot>& snapshot) { 144 [id](std::unique_ptr<DisplaySnapshot>& snapshot) {
129 return snapshot->display_id() == id; 145 return snapshot->display_id() == id;
130 })); 146 }));
147 TriggerOnDisplayModeChanged();
131 } 148 }
132 149
133 // Modify the size of the display snapshot with specified ID. 150 // Modify the size of the display snapshot with specified ID.
134 void ModifyDisplay(int64_t id, const gfx::Size& size) { 151 void ModifyDisplay(int64_t id, const gfx::Size& size) {
135 DisplaySnapshot* snapshot = GetSnapshotById(id); 152 DisplaySnapshot* snapshot = GetSnapshotById(id);
136 153
137 const DisplayMode* new_mode = nullptr; 154 const DisplayMode* new_mode = nullptr;
138 for (auto& mode : snapshot->modes()) { 155 for (auto& mode : snapshot->modes()) {
139 if (mode->size() == size) { 156 if (mode->size() == size) {
140 new_mode = mode.get(); 157 new_mode = mode.get();
141 break; 158 break;
142 } 159 }
143 } 160 }
144 161
145 if (!new_mode) { 162 if (!new_mode) {
146 snapshot->add_mode(new DisplayMode(size, false, 30.0f)); 163 snapshot->add_mode(new DisplayMode(size, false, 30.0f));
147 new_mode = snapshot->modes().back().get(); 164 new_mode = snapshot->modes().back().get();
148 } 165 }
149 166
150 snapshot->set_current_mode(new_mode); 167 snapshot->set_current_mode(new_mode);
168 TriggerOnDisplayModeChanged();
151 } 169 }
152 170
153 // Calls OnDisplayModeChanged with our list of display snapshots. 171 // Calls OnDisplayModeChanged with our list of display snapshots.
154 void TriggerOnDisplayModeChanged() { 172 void TriggerOnDisplayModeChanged() {
155 std::vector<DisplaySnapshot*> snapshots_ptrs; 173 std::vector<DisplaySnapshot*> snapshots_ptrs;
156 for (auto& snapshot : snapshots_) { 174 for (auto& snapshot : snapshots_) {
157 snapshots_ptrs.push_back(snapshot.get()); 175 snapshots_ptrs.push_back(snapshot.get());
158 } 176 }
159 static_cast<DisplayConfigurator::Observer*>(platform_screen_.get()) 177 platform_screen_->OnDisplayModeChanged(snapshots_ptrs);
160 ->OnDisplayModeChanged(snapshots_ptrs);
161 } 178 }
162 179
163 private: 180 private:
164 DisplaySnapshot* GetSnapshotById(int64_t id) { 181 DisplaySnapshot* GetSnapshotById(int64_t id) {
165 for (auto& snapshot : snapshots_) { 182 for (auto& snapshot : snapshots_) {
166 if (snapshot->display_id() == id) 183 if (snapshot->display_id() == id)
167 return snapshot.get(); 184 return snapshot.get();
168 } 185 }
169 return nullptr; 186 return nullptr;
170 } 187 }
171 188
172 // testing::Test: 189 // testing::Test:
173 void SetUp() override { 190 void SetUp() override {
174 base::CommandLine::ForCurrentProcess()->AppendSwitchNative( 191 base::CommandLine::ForCurrentProcess()->AppendSwitchNative(
175 switches::kScreenConfig, "none"); 192 switches::kScreenConfig, "none");
176 193
177 testing::Test::SetUp(); 194 testing::Test::SetUp();
178 ui::OzonePlatform::InitializeForUI(); 195 ui::OzonePlatform::InitializeForUI();
179 platform_screen_ = base::MakeUnique<PlatformScreenOzone>(); 196 platform_screen_ = base::MakeUnique<PlatformScreenOzone>();
180 platform_screen_->Init(&delegate_); 197 platform_screen_->Init(&delegate_);
181 198
182 // Have all tests start with a 1024x768 display by default. 199 // Have all tests start with a 1024x768 display by default.
183 AddDisplay(kDefaultDisplayId, gfx::Size(1024, 768)); 200 AddDisplay(1, gfx::Size(1024, 768));
184 TriggerOnDisplayModeChanged(); 201 TriggerOnDisplayModeChanged();
185 202
186 // Double check the expected display exists and clear counters. 203 // Double check the expected display exists and clear counters.
187 ASSERT_THAT(delegate()->added(), SizeIs(1)); 204 ASSERT_THAT(delegate()->added(), SizeIs(1));
188 ASSERT_THAT(delegate_.added()[0], DisplayId(kDefaultDisplayId)); 205 ASSERT_THAT(delegate_.added()[0], DisplayId(1));
189 ASSERT_THAT(delegate_.added()[0], DisplayOrigin("0,0")); 206 ASSERT_THAT(delegate_.added()[0], DisplayOrigin("0,0"));
190 ASSERT_THAT(delegate_.added()[0], DisplaySize("1024x768")); 207 ASSERT_THAT(delegate_.added()[0], DisplaySize("1024x768"));
208 ASSERT_EQ("Added(1);Primary(1)", delegate()->changes());
191 delegate_.Reset(); 209 delegate_.Reset();
192 } 210 }
193 211
194 void TearDown() override { 212 void TearDown() override {
195 snapshots_.clear(); 213 snapshots_.clear();
196 delegate_.Reset(); 214 delegate_.Reset();
197 platform_screen_.reset(); 215 platform_screen_.reset();
198 } 216 }
199 217
200 TestPlatformScreenDelegate delegate_; 218 TestPlatformScreenDelegate delegate_;
201 std::unique_ptr<PlatformScreenOzone> platform_screen_; 219 std::unique_ptr<PlatformScreenOzone> platform_screen_;
202 std::vector<std::unique_ptr<DisplaySnapshot>> snapshots_; 220 std::vector<std::unique_ptr<DisplaySnapshot>> snapshots_;
203 }; 221 };
204 222
205 } // namespace
206
207 TEST_F(PlatformScreenOzoneTest, AddDisplay) { 223 TEST_F(PlatformScreenOzoneTest, AddDisplay) {
208 AddDisplay(2); 224 AddDisplay(2);
209 TriggerOnDisplayModeChanged();
210 225
211 // Check that display 2 was added. 226 // Check that display 2 was added.
212 ASSERT_THAT(delegate()->added(), SizeIs(1)); 227 EXPECT_EQ("Added(2)", delegate()->changes());
213 EXPECT_THAT(delegate()->added()[0], DisplayId(2));
214 EXPECT_THAT(delegate()->removed(), IsEmpty());
215 EXPECT_THAT(delegate()->modified(), IsEmpty());
216 } 228 }
217 229
218 TEST_F(PlatformScreenOzoneTest, RemoveDisplay) { 230 TEST_F(PlatformScreenOzoneTest, RemoveDisplay) {
219 AddDisplay(2); 231 AddDisplay(2);
220 TriggerOnDisplayModeChanged();
221 delegate()->Reset(); 232 delegate()->Reset();
222 233
223 RemoveDisplay(2); 234 RemoveDisplay(2);
224 TriggerOnDisplayModeChanged();
225 235
226 // Check that display 2 was removed. 236 // Check that display 2 was removed.
227 ASSERT_THAT(delegate()->removed(), SizeIs(1)); 237 EXPECT_EQ("Removed(2)", delegate()->changes());
228 EXPECT_THAT(delegate()->removed()[0], DisplayId(2));
229 EXPECT_THAT(delegate()->added(), IsEmpty());
230 EXPECT_THAT(delegate()->modified(), IsEmpty());
231 } 238 }
232 239
233 TEST_F(PlatformScreenOzoneTest, RemoveFirstDisplay) { 240 TEST_F(PlatformScreenOzoneTest, RemoveFirstDisplay) {
234 AddDisplay(2); 241 AddDisplay(2);
235 TriggerOnDisplayModeChanged();
236 delegate()->Reset(); 242 delegate()->Reset();
237 243
238 RemoveDisplay(kDefaultDisplayId); 244 RemoveDisplay(1);
239 TriggerOnDisplayModeChanged();
240 245
241 // Check that the default display was removed and display 2 was modified due 246 // Check that display 1 was removed and display 2 was modified due to the
242 // to the origin changing. 247 // origin changing.
243 EXPECT_THAT(delegate()->added(), IsEmpty()); 248 EXPECT_EQ("Primary(2);Removed(1);Modified(2)", delegate()->changes());
244 ASSERT_THAT(delegate()->removed(), SizeIs(1));
245 EXPECT_THAT(delegate()->removed()[0], DisplayId(kDefaultDisplayId));
246
247 ASSERT_THAT(delegate()->modified(), SizeIs(1)); 249 ASSERT_THAT(delegate()->modified(), SizeIs(1));
248 EXPECT_THAT(delegate()->modified()[0], DisplayId(2)); 250 EXPECT_THAT(delegate()->modified()[0], DisplayId(2));
249 EXPECT_THAT(delegate()->modified()[0], DisplayOrigin("0,0")); 251 EXPECT_THAT(delegate()->modified()[0], DisplayOrigin("0,0"));
250 } 252 }
251 253
252 TEST_F(PlatformScreenOzoneTest, RemovePrimaryDisplay) {
253 EXPECT_EQ(kDefaultDisplayId, platform_screen()->GetPrimaryDisplayId());
254
255 AddDisplay(2);
256 RemoveDisplay(kDefaultDisplayId);
257 TriggerOnDisplayModeChanged();
258
259 // Check the primary display changed because the old primary was removed.
260 EXPECT_EQ(2, platform_screen()->GetPrimaryDisplayId());
261 }
262
263 TEST_F(PlatformScreenOzoneTest, RemoveMultipleDisplay) { 254 TEST_F(PlatformScreenOzoneTest, RemoveMultipleDisplay) {
264 AddDisplay(2); 255 AddDisplay(2);
265 AddDisplay(3); 256 AddDisplay(3);
266 TriggerOnDisplayModeChanged();
267 delegate()->Reset(); 257 delegate()->Reset();
268 258
269 RemoveDisplay(2); 259 RemoveDisplay(2);
270 TriggerOnDisplayModeChanged(); 260 RemoveDisplay(3);
271 261
272 // Check that display 2 was removed. 262 // Check that display 2 was removed and display 3 is modifed (origin change),
273 ASSERT_THAT(delegate()->removed(), SizeIs(1)); 263 // then display 3 was removed.
274 EXPECT_THAT(delegate()->removed()[0], DisplayId(2)); 264 EXPECT_EQ("Removed(2);Modified(3);Removed(3)", delegate()->changes());
275
276 delegate()->Reset();
277 RemoveDisplay(3);
278 TriggerOnDisplayModeChanged();
279
280 // Check that display 3 was removed.
281 ASSERT_THAT(delegate()->removed(), SizeIs(1));
282 EXPECT_THAT(delegate()->removed()[0], DisplayId(3));
283 } 265 }
284 266
285 TEST_F(PlatformScreenOzoneTest, ModifyDisplaySize) { 267 TEST_F(PlatformScreenOzoneTest, ModifyDisplaySize) {
286 const gfx::Size size1(1920, 1200); 268 const gfx::Size size1(1920, 1200);
287 const gfx::Size size2(1680, 1050); 269 const gfx::Size size2(1680, 1050);
288 270
289 AddDisplay(2, size1); 271 AddDisplay(2, size1);
290 TriggerOnDisplayModeChanged();
291 272
292 // Check that display 2 was added with expected size. 273 // Check that display 2 was added with expected size.
293 ASSERT_THAT(delegate()->added(), SizeIs(1)); 274 ASSERT_THAT(delegate()->added(), SizeIs(1));
294 EXPECT_THAT(delegate()->added()[0], DisplayId(2)); 275 EXPECT_THAT(delegate()->added()[0], DisplayId(2));
295 EXPECT_THAT(delegate()->added()[0], DisplaySize(size1.ToString())); 276 EXPECT_THAT(delegate()->added()[0], DisplaySize(size1.ToString()));
277 EXPECT_EQ("Added(2)", delegate()->changes());
296 delegate()->Reset(); 278 delegate()->Reset();
297 279
298 ModifyDisplay(2, size2); 280 ModifyDisplay(2, size2);
299 TriggerOnDisplayModeChanged();
300 281
301 // Check that display 2 was modified to have the new expected size. 282 // Check that display 2 was modified to have the new expected size.
302 ASSERT_THAT(delegate()->modified(), SizeIs(1)); 283 ASSERT_THAT(delegate()->modified(), SizeIs(1));
303 EXPECT_THAT(delegate()->modified()[0], DisplayId(2)); 284 EXPECT_THAT(delegate()->modified()[0], DisplayId(2));
304 EXPECT_THAT(delegate()->modified()[0], DisplaySize(size2.ToString())); 285 EXPECT_THAT(delegate()->modified()[0], DisplaySize(size2.ToString()));
286 EXPECT_EQ("Modified(2)", delegate()->changes());
305 } 287 }
306 288
307 TEST_F(PlatformScreenOzoneTest, ModifyFirstDisplaySize) { 289 TEST_F(PlatformScreenOzoneTest, ModifyFirstDisplaySize) {
308 const gfx::Size size(1920, 1200); 290 const gfx::Size size(1920, 1200);
309 291
310 AddDisplay(2, size); 292 AddDisplay(2, size);
311 TriggerOnDisplayModeChanged();
312 293
313 // Check that display two has the expected initial origin. 294 // Check that display 2 has the expected initial origin.
295 EXPECT_EQ("Added(2)", delegate()->changes());
314 ASSERT_THAT(delegate()->added(), SizeIs(1)); 296 ASSERT_THAT(delegate()->added(), SizeIs(1));
315 EXPECT_THAT(delegate()->added()[0], DisplayOrigin("1024,0")); 297 EXPECT_THAT(delegate()->added()[0], DisplayOrigin("1024,0"));
316 delegate()->Reset(); 298 delegate()->Reset();
317 299
318 ModifyDisplay(kDefaultDisplayId, size); 300 ModifyDisplay(1, size);
319 TriggerOnDisplayModeChanged();
320 301
321 // Check that the default display was modified with a new size and display 2 302 // Check that display 1 was modified with a new size and display 2 origin was
322 // was modified with a new origin. 303 // modified after.
304 EXPECT_EQ("Modified(1);Modified(2)", delegate()->changes());
323 ASSERT_THAT(delegate()->modified(), SizeIs(2)); 305 ASSERT_THAT(delegate()->modified(), SizeIs(2));
324 EXPECT_THAT(delegate()->modified()[0], DisplayId(kDefaultDisplayId)); 306 EXPECT_THAT(delegate()->modified()[0], DisplayId(1));
325 EXPECT_THAT(delegate()->modified()[0], DisplaySize(size.ToString())); 307 EXPECT_THAT(delegate()->modified()[0], DisplaySize(size.ToString()));
326 EXPECT_THAT(delegate()->modified()[1], DisplayId(2)); 308 EXPECT_THAT(delegate()->modified()[1], DisplayId(2));
327 EXPECT_THAT(delegate()->modified()[1], DisplayOrigin("1920,0")); 309 EXPECT_THAT(delegate()->modified()[1], DisplayOrigin("1920,0"));
328 } 310 }
329 311
312 TEST_F(PlatformScreenOzoneTest, RemovePrimaryDisplay) {
313 AddDisplay(2);
314 delegate()->Reset();
315
316 RemoveDisplay(1);
317
318 // Check the primary display changed because the old primary was removed.
319 EXPECT_EQ("Primary(2);Removed(1);Modified(2)", delegate()->changes());
320 }
321
322 TEST_F(PlatformScreenOzoneTest, RemoveLastDisplay) {
323 RemoveDisplay(1);
324
325 // Check that display 1 is removed and no updates for the primary display are
326 // received.
327 EXPECT_EQ("Removed(1)", delegate()->changes());
328 }
329
330 TEST_F(PlatformScreenOzoneTest, SwapPrimaryDisplay) {
331 AddDisplay(2);
332 delegate()->Reset();
333
334 platform_screen()->SwapPrimaryDisplay();
335 EXPECT_EQ("Primary(2)", delegate()->changes());
336 }
337
338 TEST_F(PlatformScreenOzoneTest, SwapPrimaryThreeDisplays) {
339 AddDisplay(2);
340 AddDisplay(3);
341 EXPECT_EQ("Added(2);Added(3)", delegate()->changes());
342 delegate()->Reset();
343
344 platform_screen()->SwapPrimaryDisplay();
345 platform_screen()->SwapPrimaryDisplay();
346 platform_screen()->SwapPrimaryDisplay();
347 EXPECT_EQ("Primary(2);Primary(3);Primary(1)", delegate()->changes());
348 }
349
330 } // namespace display 350 } // namespace display
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698