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

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

Issue 10905288: Switch primary display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « ash/display/multi_display_manager.cc ('k') | ash/extended_desktop_unittest.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/multi_display_manager.h" 5 #include "ash/display/multi_display_manager.h"
6 6
7 #include "ash/display/display_controller.h" 7 #include "ash/display/display_controller.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/test/ash_test_base.h" 9 #include "ash/test/ash_test_base.h"
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 changed_.clear(); 58 changed_.clear();
59 added_.clear(); 59 added_.clear();
60 removed_count_ = 0U; 60 removed_count_ = 0U;
61 root_window_destroyed_ = false; 61 root_window_destroyed_ = false;
62 } 62 }
63 63
64 bool root_window_destroyed() const { 64 bool root_window_destroyed() const {
65 return root_window_destroyed_; 65 return root_window_destroyed_;
66 } 66 }
67 67
68 const gfx::Display& FindDisplayForId(int64 id) {
69 return display_manager()->FindDisplayForId(id);
70 }
71
68 // aura::DisplayObserver overrides: 72 // aura::DisplayObserver overrides:
69 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE { 73 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE {
70 changed_.push_back(display); 74 changed_.push_back(display);
71 } 75 }
72 virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE { 76 virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE {
73 added_.push_back(new_display); 77 added_.push_back(new_display);
74 } 78 }
75 virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE { 79 virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE {
76 ++removed_count_; 80 ++removed_count_;
77 } 81 }
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 UpdateDisplay("1000x600*2"); 236 UpdateDisplay("1000x600*2");
233 EXPECT_EQ(2, 237 EXPECT_EQ(2,
234 Shell::GetPrimaryRootWindow()->compositor()->device_scale_factor()); 238 Shell::GetPrimaryRootWindow()->compositor()->device_scale_factor());
235 EXPECT_EQ("500x300", 239 EXPECT_EQ("500x300",
236 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); 240 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
237 aura::DisplayManager::set_use_fullscreen_host_window(false); 241 aura::DisplayManager::set_use_fullscreen_host_window(false);
238 } 242 }
239 243
240 TEST_F(MultiDisplayManagerTest, MAYBE_TestNativeDisplaysChanged) { 244 TEST_F(MultiDisplayManagerTest, MAYBE_TestNativeDisplaysChanged) {
241 const int64 internal_display_id = 245 const int64 internal_display_id =
242 display_manager()->EnableInternalDisplayForTest(); 246 display_manager()->SetFirstDisplayAsInternalDisplayForTest();
243 const gfx::Display native_display(internal_display_id, 247 const gfx::Display native_display(internal_display_id,
244 gfx::Rect(0, 0, 500, 500)); 248 gfx::Rect(0, 0, 500, 500));
245 249
246 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 250 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
247 std::string default_bounds = 251 std::string default_bounds =
248 display_manager()->GetDisplayAt(0)->bounds().ToString(); 252 display_manager()->GetDisplayAt(0)->bounds().ToString();
249 253
250 std::vector<gfx::Display> displays; 254 std::vector<gfx::Display> displays;
251 // Primary disconnected. 255 // Primary disconnected.
252 display_manager()->OnNativeDisplaysChanged(displays); 256 display_manager()->OnNativeDisplaysChanged(displays);
253 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 257 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
254 EXPECT_EQ(default_bounds, 258 EXPECT_EQ(default_bounds,
255 display_manager()->GetDisplayAt(0)->bounds().ToString()); 259 display_manager()->GetDisplayAt(0)->bounds().ToString());
256 260
257 // External connected while primary was disconnected. 261 // External connected while primary was disconnected.
258 displays.push_back(gfx::Display(10, gfx::Rect(1, 1, 100, 100))); 262 displays.push_back(gfx::Display(10, gfx::Rect(1, 1, 100, 100)));
259 display_manager()->OnNativeDisplaysChanged(displays); 263 display_manager()->OnNativeDisplaysChanged(displays);
260 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); 264 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
261 EXPECT_EQ(default_bounds, 265 EXPECT_EQ(default_bounds,
262 display_manager()->GetDisplayAt(0)->bounds().ToString()); 266 FindDisplayForId(internal_display_id).bounds().ToString());
263 EXPECT_EQ("1,1 100x100", 267 EXPECT_EQ("1,1 100x100",
264 display_manager()->GetDisplayAt(1)->bounds_in_pixel().ToString()); 268 FindDisplayForId(10).bounds_in_pixel().ToString());
265 269
266 // Primary connected, with different bounds. 270 // Primary connected, with different bounds.
267 displays.clear(); 271 displays.clear();
268 displays.push_back(native_display); 272 displays.push_back(native_display);
269 displays.push_back(gfx::Display(10, gfx::Rect(1, 1, 100, 100))); 273 displays.push_back(gfx::Display(10, gfx::Rect(1, 1, 100, 100)));
270 display_manager()->OnNativeDisplaysChanged(displays); 274 display_manager()->OnNativeDisplaysChanged(displays);
271 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); 275 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
272 EXPECT_EQ("0,0 500x500", 276 EXPECT_EQ("0,0 500x500",
273 display_manager()->GetDisplayAt(0)->bounds().ToString()); 277 FindDisplayForId(internal_display_id).bounds().ToString());
274 EXPECT_EQ("1,1 100x100", 278 EXPECT_EQ("1,1 100x100",
275 display_manager()->GetDisplayAt(1)->bounds_in_pixel().ToString()); 279 FindDisplayForId(10).bounds_in_pixel().ToString());
276 280
277 // Turn off primary. 281 // Turn off primary.
278 displays.clear(); 282 displays.clear();
279 displays.push_back(gfx::Display(10, gfx::Rect(1, 1, 100, 100))); 283 displays.push_back(gfx::Display(10, gfx::Rect(1, 1, 100, 100)));
280 display_manager()->OnNativeDisplaysChanged(displays); 284 display_manager()->OnNativeDisplaysChanged(displays);
281 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); 285 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
282 EXPECT_EQ("0,0 500x500", 286 EXPECT_EQ("0,0 500x500",
283 display_manager()->GetDisplayAt(0)->bounds().ToString()); 287 FindDisplayForId(internal_display_id).bounds().ToString());
284 EXPECT_EQ("1,1 100x100", 288 EXPECT_EQ("1,1 100x100",
285 display_manager()->GetDisplayAt(1)->bounds_in_pixel().ToString()); 289 FindDisplayForId(10).bounds_in_pixel().ToString());
286 290
287 // Emulate suspend. 291 // Emulate suspend.
288 displays.clear(); 292 displays.clear();
289 display_manager()->OnNativeDisplaysChanged(displays); 293 display_manager()->OnNativeDisplaysChanged(displays);
290 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); 294 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
291 EXPECT_EQ("0,0 500x500", 295 EXPECT_EQ("0,0 500x500",
292 display_manager()->GetDisplayAt(0)->bounds().ToString()); 296 FindDisplayForId(internal_display_id).bounds().ToString());
293 EXPECT_EQ("1,1 100x100", 297 EXPECT_EQ("1,1 100x100",
294 display_manager()->GetDisplayAt(1)->bounds_in_pixel().ToString()); 298 FindDisplayForId(10).bounds_in_pixel().ToString());
295 299
296 // External display has disconnected then resumed. 300 // External display has disconnected then resumed.
297 displays.push_back(native_display); 301 displays.push_back(native_display);
298 display_manager()->OnNativeDisplaysChanged(displays); 302 display_manager()->OnNativeDisplaysChanged(displays);
299 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 303 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
300 EXPECT_EQ("0,0 500x500", 304 EXPECT_EQ("0,0 500x500",
301 display_manager()->GetDisplayAt(0)->bounds().ToString()); 305 FindDisplayForId(internal_display_id).bounds().ToString());
302 } 306 }
303 307
304 } // namespace internal 308 } // namespace internal
305 } // namespace ash 309 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/multi_display_manager.cc ('k') | ash/extended_desktop_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698