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

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

Issue 2067223003: Parameterize Ash unittests to pass with material design enabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: SupportsHostWindowResize() Created 4 years, 6 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
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_manager.h" 5 #include "ash/display/display_manager.h"
6 6
7 #include "ash/accelerators/accelerator_commands.h" 7 #include "ash/accelerators/accelerator_commands.h"
8 #include "ash/common/ash_switches.h" 8 #include "ash/common/ash_switches.h"
9 #include "ash/common/material_design/material_design_controller.h"
9 #include "ash/common/wm/window_state.h" 10 #include "ash/common/wm/window_state.h"
10 #include "ash/display/display_configuration_controller.h" 11 #include "ash/display/display_configuration_controller.h"
11 #include "ash/display/display_info.h" 12 #include "ash/display/display_info.h"
12 #include "ash/display/display_layout_store.h" 13 #include "ash/display/display_layout_store.h"
13 #include "ash/display/display_util.h" 14 #include "ash/display/display_util.h"
14 #include "ash/display/mirror_window_controller.h" 15 #include "ash/display/mirror_window_controller.h"
15 #include "ash/display/window_tree_host_manager.h" 16 #include "ash/display/window_tree_host_manager.h"
16 #include "ash/screen_util.h" 17 #include "ash/screen_util.h"
17 #include "ash/shell.h" 18 #include "ash/shell.h"
19 #include "ash/test/ash_md_test_base.h"
18 #include "ash/test/ash_test_base.h" 20 #include "ash/test/ash_test_base.h"
19 #include "ash/test/display_manager_test_api.h" 21 #include "ash/test/display_manager_test_api.h"
20 #include "ash/test/mirror_window_test_api.h" 22 #include "ash/test/mirror_window_test_api.h"
21 #include "ash/wm/window_state_aura.h" 23 #include "ash/wm/window_state_aura.h"
22 #include "base/command_line.h" 24 #include "base/command_line.h"
23 #include "base/format_macros.h" 25 #include "base/format_macros.h"
24 #include "base/strings/string_number_conversions.h" 26 #include "base/strings/string_number_conversions.h"
25 #include "base/strings/stringprintf.h" 27 #include "base/strings/stringprintf.h"
26 #include "grit/ash_strings.h" 28 #include "grit/ash_strings.h"
27 #include "ui/aura/client/aura_constants.h" 29 #include "ui/aura/client/aura_constants.h"
(...skipping 16 matching lines...) Expand all
44 using base::StringPrintf; 46 using base::StringPrintf;
45 47
46 namespace { 48 namespace {
47 49
48 std::string ToDisplayName(int64_t id) { 50 std::string ToDisplayName(int64_t id) {
49 return "x-" + base::Int64ToString(id); 51 return "x-" + base::Int64ToString(id);
50 } 52 }
51 53
52 } // namespace 54 } // namespace
53 55
54 class DisplayManagerTest : public test::AshTestBase, 56 class DisplayManagerTest : public test::AshMDTestBase,
55 public display::DisplayObserver, 57 public display::DisplayObserver,
56 public aura::WindowObserver { 58 public aura::WindowObserver {
57 public: 59 public:
58 DisplayManagerTest() 60 DisplayManagerTest()
59 : removed_count_(0U), 61 : removed_count_(0U),
60 root_window_destroyed_(false), 62 root_window_destroyed_(false),
61 changed_metrics_(0U) { 63 changed_metrics_(0U) {
62 } 64 }
63 ~DisplayManagerTest() override {} 65 ~DisplayManagerTest() override {}
64 66
65 void SetUp() override { 67 void SetUp() override {
66 AshTestBase::SetUp(); 68 AshMDTestBase::SetUp();
67 display::Screen::GetScreen()->AddObserver(this); 69 display::Screen::GetScreen()->AddObserver(this);
68 Shell::GetPrimaryRootWindow()->AddObserver(this); 70 Shell::GetPrimaryRootWindow()->AddObserver(this);
69 } 71 }
70 void TearDown() override { 72 void TearDown() override {
71 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 73 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
72 display::Screen::GetScreen()->RemoveObserver(this); 74 display::Screen::GetScreen()->RemoveObserver(this);
73 AshTestBase::TearDown(); 75 AshMDTestBase::TearDown();
74 } 76 }
75 77
76 DisplayManager* display_manager() { 78 DisplayManager* display_manager() {
77 return Shell::GetInstance()->display_manager(); 79 return Shell::GetInstance()->display_manager();
78 } 80 }
79 const vector<display::Display>& changed() const { return changed_; } 81 const vector<display::Display>& changed() const { return changed_; }
80 const vector<display::Display>& added() const { return added_; } 82 const vector<display::Display>& added() const { return added_; }
81 uint32_t changed_metrics() const { return changed_metrics_; } 83 uint32_t changed_metrics() const { return changed_metrics_; }
82 84
83 string GetCountSummary() const { 85 string GetCountSummary() const {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 private: 137 private:
136 vector<display::Display> changed_; 138 vector<display::Display> changed_;
137 vector<display::Display> added_; 139 vector<display::Display> added_;
138 size_t removed_count_; 140 size_t removed_count_;
139 bool root_window_destroyed_; 141 bool root_window_destroyed_;
140 uint32_t changed_metrics_; 142 uint32_t changed_metrics_;
141 143
142 DISALLOW_COPY_AND_ASSIGN(DisplayManagerTest); 144 DISALLOW_COPY_AND_ASSIGN(DisplayManagerTest);
143 }; 145 };
144 146
145 TEST_F(DisplayManagerTest, UpdateDisplayTest) { 147 // The prefix has intentionally been left blank since there is only one
148 // parameterization of this test fixture.
149 INSTANTIATE_TEST_CASE_P(
150 /* prefix intentionally left blank */,
151 DisplayManagerTest,
152 testing::Values(MaterialDesignController::NON_MATERIAL,
153 MaterialDesignController::MATERIAL_NORMAL,
154 MaterialDesignController::MATERIAL_EXPERIMENTAL));
155
156 TEST_P(DisplayManagerTest, UpdateDisplayTest) {
146 if (!SupportsMultipleDisplays()) 157 if (!SupportsMultipleDisplays())
147 return; 158 return;
148 159
149 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 160 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
150 161
151 // Update primary and add seconary. 162 // Update primary and add seconary.
152 UpdateDisplay("100+0-500x500,0+501-400x400"); 163 UpdateDisplay("100+0-500x500,0+501-400x400");
153 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); 164 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
154 EXPECT_EQ("0,0 500x500", 165 EXPECT_EQ("0,0 500x500",
155 display_manager()->GetDisplayAt(0).bounds().ToString()); 166 display_manager()->GetDisplayAt(0).bounds().ToString());
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 // Changing primary will update secondary as well. 248 // Changing primary will update secondary as well.
238 UpdateDisplay("0+0-800x600,1000+1000-600x400"); 249 UpdateDisplay("0+0-800x600,1000+1000-600x400");
239 EXPECT_EQ("2 0 0", GetCountSummary()); 250 EXPECT_EQ("2 0 0", GetCountSummary());
240 reset(); 251 reset();
241 EXPECT_EQ("0,0 800x600", 252 EXPECT_EQ("0,0 800x600",
242 display_manager()->GetDisplayAt(0).bounds().ToString()); 253 display_manager()->GetDisplayAt(0).bounds().ToString());
243 EXPECT_EQ("800,0 600x400", 254 EXPECT_EQ("800,0 600x400",
244 display_manager()->GetDisplayAt(1).bounds().ToString()); 255 display_manager()->GetDisplayAt(1).bounds().ToString());
245 } 256 }
246 257
247 TEST_F(DisplayManagerTest, ScaleOnlyChange) { 258 TEST_P(DisplayManagerTest, ScaleOnlyChange) {
248 if (!SupportsMultipleDisplays()) 259 if (!SupportsMultipleDisplays())
249 return; 260 return;
250 display_manager()->ToggleDisplayScaleFactor(); 261 display_manager()->ToggleDisplayScaleFactor();
251 EXPECT_TRUE(changed_metrics() & 262 EXPECT_TRUE(changed_metrics() &
252 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); 263 display::DisplayObserver::DISPLAY_METRIC_BOUNDS);
253 EXPECT_TRUE(changed_metrics() & 264 EXPECT_TRUE(changed_metrics() &
254 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); 265 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
255 } 266 }
256 267
257 // Test in emulation mode (use_fullscreen_host_window=false) 268 // Test in emulation mode (use_fullscreen_host_window=false)
258 TEST_F(DisplayManagerTest, EmulatorTest) { 269 TEST_P(DisplayManagerTest, EmulatorTest) {
259 if (!SupportsMultipleDisplays()) 270 if (!SupportsMultipleDisplays())
260 return; 271 return;
261 272
262 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 273 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
263 274
264 display_manager()->AddRemoveDisplay(); 275 display_manager()->AddRemoveDisplay();
265 // Update primary and add seconary. 276 // Update primary and add seconary.
266 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); 277 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
267 EXPECT_EQ("0 1 0", GetCountSummary()); 278 EXPECT_EQ("0 1 0", GetCountSummary());
268 reset(); 279 reset();
269 280
270 display_manager()->AddRemoveDisplay(); 281 display_manager()->AddRemoveDisplay();
271 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 282 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
272 EXPECT_EQ("0 0 1", GetCountSummary()); 283 EXPECT_EQ("0 0 1", GetCountSummary());
273 reset(); 284 reset();
274 285
275 display_manager()->AddRemoveDisplay(); 286 display_manager()->AddRemoveDisplay();
276 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); 287 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
277 EXPECT_EQ("0 1 0", GetCountSummary()); 288 EXPECT_EQ("0 1 0", GetCountSummary());
278 } 289 }
279 290
280 // Tests support for 3 displays. 291 // Tests support for 3 displays.
281 TEST_F(DisplayManagerTest, UpdateThreeDisplaysWithDefaultLayout) { 292 TEST_P(DisplayManagerTest, UpdateThreeDisplaysWithDefaultLayout) {
282 if (!SupportsMultipleDisplays()) 293 if (!SupportsMultipleDisplays())
283 return; 294 return;
284 295
285 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 296 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
286 297
287 // Test with three displays. Native origin will not affect ash 298 // Test with three displays. Native origin will not affect ash
288 // display layout. 299 // display layout.
289 UpdateDisplay("0+0-640x480,1000+0-320x200,2000+0-400x300"); 300 UpdateDisplay("0+0-640x480,1000+0-320x200,2000+0-400x300");
290 301
291 EXPECT_EQ(3U, display_manager()->GetNumDisplays()); 302 EXPECT_EQ(3U, display_manager()->GetNumDisplays());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 UpdateDisplay("640x480,320x200,400x300"); 340 UpdateDisplay("640x480,320x200,400x300");
330 341
331 EXPECT_EQ("0,0 640x480", 342 EXPECT_EQ("0,0 640x480",
332 display_manager()->GetDisplayAt(0).bounds().ToString()); 343 display_manager()->GetDisplayAt(0).bounds().ToString());
333 EXPECT_EQ("10,480 320x200", 344 EXPECT_EQ("10,480 320x200",
334 display_manager()->GetDisplayAt(1).bounds().ToString()); 345 display_manager()->GetDisplayAt(1).bounds().ToString());
335 EXPECT_EQ("20,680 400x300", 346 EXPECT_EQ("20,680 400x300",
336 display_manager()->GetDisplayAt(2).bounds().ToString()); 347 display_manager()->GetDisplayAt(2).bounds().ToString());
337 } 348 }
338 349
339 TEST_F(DisplayManagerTest, LayoutMorethanThreeDisplaysTest) { 350 TEST_P(DisplayManagerTest, LayoutMorethanThreeDisplaysTest) {
340 if (!SupportsMultipleDisplays()) 351 if (!SupportsMultipleDisplays())
341 return; 352 return;
342 353
343 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 354 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
344 display::DisplayIdList list = ash::test::CreateDisplayIdListN( 355 display::DisplayIdList list = ash::test::CreateDisplayIdListN(
345 3, primary_id, primary_id + 1, primary_id + 2); 356 3, primary_id, primary_id + 1, primary_id + 2);
346 { 357 {
347 // Layout: [2] 358 // Layout: [2]
348 // [1][P] 359 // [1][P]
349 display::DisplayLayoutBuilder builder(primary_id); 360 display::DisplayLayoutBuilder builder(primary_id);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 display_manager()->GetDisplayAt(4).bounds().ToString()); 455 display_manager()->GetDisplayAt(4).bounds().ToString());
445 // 3rd is the left of 4th. 456 // 3rd is the left of 4th.
446 EXPECT_EQ("-290,480 300x200", 457 EXPECT_EQ("-290,480 300x200",
447 display_manager()->GetDisplayAt(3).bounds().ToString()); 458 display_manager()->GetDisplayAt(3).bounds().ToString());
448 // 1st is the bottom of 3rd. 459 // 1st is the bottom of 3rd.
449 EXPECT_EQ("-280,680 320x200", 460 EXPECT_EQ("-280,680 320x200",
450 display_manager()->GetDisplayAt(1).bounds().ToString()); 461 display_manager()->GetDisplayAt(1).bounds().ToString());
451 } 462 }
452 } 463 }
453 464
454 TEST_F(DisplayManagerTest, NoMirrorInThreeDisplays) { 465 TEST_P(DisplayManagerTest, NoMirrorInThreeDisplays) {
455 if (!SupportsMultipleDisplays()) 466 if (!SupportsMultipleDisplays())
456 return; 467 return;
457 468
458 UpdateDisplay("640x480,320x200,400x300"); 469 UpdateDisplay("640x480,320x200,400x300");
459 ash::Shell::GetInstance()->display_configuration_controller()->SetMirrorMode( 470 ash::Shell::GetInstance()->display_configuration_controller()->SetMirrorMode(
460 true, true); 471 true, true);
461 EXPECT_FALSE(display_manager()->IsInMirrorMode()); 472 EXPECT_FALSE(display_manager()->IsInMirrorMode());
462 EXPECT_EQ(3u, display_manager()->GetNumDisplays()); 473 EXPECT_EQ(3u, display_manager()->GetNumDisplays());
463 #if defined(OS_CHROMEOS) 474 #if defined(OS_CHROMEOS)
464 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_MIRRORING_NOT_SUPPORTED), 475 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_MIRRORING_NOT_SUPPORTED),
465 GetDisplayErrorNotificationMessageForTest()); 476 GetDisplayErrorNotificationMessageForTest());
466 #endif 477 #endif
467 } 478 }
468 479
469 TEST_F(DisplayManagerTest, OverscanInsetsTest) { 480 TEST_P(DisplayManagerTest, OverscanInsetsTest) {
470 if (!SupportsMultipleDisplays()) 481 if (!SupportsMultipleDisplays())
471 return; 482 return;
472 483
473 UpdateDisplay("0+0-500x500,0+501-400x400"); 484 UpdateDisplay("0+0-500x500,0+501-400x400");
474 reset(); 485 reset();
475 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); 486 ASSERT_EQ(2u, display_manager()->GetNumDisplays());
476 const DisplayInfo& display_info1 = GetDisplayInfoAt(0); 487 const DisplayInfo& display_info1 = GetDisplayInfoAt(0);
477 const DisplayInfo& display_info2 = GetDisplayInfoAt(1); 488 const DisplayInfo& display_info2 = GetDisplayInfoAt(1);
478 display_manager()->SetOverscanInsets( 489 display_manager()->SetOverscanInsets(
479 display_info2.id(), gfx::Insets(13, 12, 11, 10)); 490 display_info2.id(), gfx::Insets(13, 12, 11, 10));
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 display_manager()->SetOverscanInsets(primary_id, gfx::Insets(0, 0, 0, 0)); 603 display_manager()->SetOverscanInsets(primary_id, gfx::Insets(0, 0, 0, 0));
593 EXPECT_TRUE(changed_metrics() & 604 EXPECT_TRUE(changed_metrics() &
594 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); 605 display::DisplayObserver::DISPLAY_METRIC_BOUNDS);
595 EXPECT_TRUE(changed_metrics() & 606 EXPECT_TRUE(changed_metrics() &
596 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); 607 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
597 EXPECT_EQ( 608 EXPECT_EQ(
598 "0,0 500x500", 609 "0,0 500x500",
599 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString()); 610 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString());
600 } 611 }
601 612
602 TEST_F(DisplayManagerTest, ZeroOverscanInsets) { 613 TEST_P(DisplayManagerTest, ZeroOverscanInsets) {
603 if (!SupportsMultipleDisplays()) 614 if (!SupportsMultipleDisplays())
604 return; 615 return;
605 616
606 // Make sure the display change events is emitted for overscan inset changes. 617 // Make sure the display change events is emitted for overscan inset changes.
607 UpdateDisplay("0+0-500x500,0+501-400x400"); 618 UpdateDisplay("0+0-500x500,0+501-400x400");
608 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); 619 ASSERT_EQ(2u, display_manager()->GetNumDisplays());
609 int64_t display2_id = display_manager()->GetDisplayAt(1).id(); 620 int64_t display2_id = display_manager()->GetDisplayAt(1).id();
610 621
611 reset(); 622 reset();
612 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0)); 623 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0));
613 EXPECT_EQ(0u, changed().size()); 624 EXPECT_EQ(0u, changed().size());
614 625
615 reset(); 626 reset();
616 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(1, 0, 0, 0)); 627 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(1, 0, 0, 0));
617 EXPECT_EQ(1u, changed().size()); 628 EXPECT_EQ(1u, changed().size());
618 EXPECT_EQ(display2_id, changed()[0].id()); 629 EXPECT_EQ(display2_id, changed()[0].id());
619 630
620 reset(); 631 reset();
621 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0)); 632 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0));
622 EXPECT_EQ(1u, changed().size()); 633 EXPECT_EQ(1u, changed().size());
623 EXPECT_EQ(display2_id, changed()[0].id()); 634 EXPECT_EQ(display2_id, changed()[0].id());
624 } 635 }
625 636
626 TEST_F(DisplayManagerTest, TestDeviceScaleOnlyChange) { 637 TEST_P(DisplayManagerTest, TestDeviceScaleOnlyChange) {
627 if (!SupportsHostWindowResize()) 638 if (!SupportsHostWindowResize())
628 return; 639 return;
629 640
630 UpdateDisplay("1000x600"); 641 UpdateDisplay("1000x600");
631 aura::WindowTreeHost* host = Shell::GetPrimaryRootWindow()->GetHost(); 642 aura::WindowTreeHost* host = Shell::GetPrimaryRootWindow()->GetHost();
632 EXPECT_EQ(1, host->compositor()->device_scale_factor()); 643 EXPECT_EQ(1, host->compositor()->device_scale_factor());
633 EXPECT_EQ("1000x600", 644 EXPECT_EQ("1000x600",
634 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); 645 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
635 EXPECT_EQ("1 0 0", GetCountSummary()); 646 EXPECT_EQ("1 0 0", GetCountSummary());
636 647
637 UpdateDisplay("1000x600*2"); 648 UpdateDisplay("1000x600*2");
638 EXPECT_EQ(2, host->compositor()->device_scale_factor()); 649 EXPECT_EQ(2, host->compositor()->device_scale_factor());
639 EXPECT_EQ("2 0 0", GetCountSummary()); 650 EXPECT_EQ("2 0 0", GetCountSummary());
640 EXPECT_EQ("500x300", 651 EXPECT_EQ("500x300",
641 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); 652 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
642 } 653 }
643 654
644 DisplayInfo CreateDisplayInfo(int64_t id, const gfx::Rect& bounds) { 655 DisplayInfo CreateDisplayInfo(int64_t id, const gfx::Rect& bounds) {
645 DisplayInfo info(id, ToDisplayName(id), false); 656 DisplayInfo info(id, ToDisplayName(id), false);
646 info.SetBounds(bounds); 657 info.SetBounds(bounds);
647 return info; 658 return info;
648 } 659 }
649 660
650 TEST_F(DisplayManagerTest, TestNativeDisplaysChanged) { 661 TEST_P(DisplayManagerTest, TestNativeDisplaysChanged) {
651 const int64_t internal_display_id = 662 const int64_t internal_display_id =
652 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); 663 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay();
653 const int external_id = 10; 664 const int external_id = 10;
654 const int mirror_id = 11; 665 const int mirror_id = 11;
655 const int64_t invalid_id = display::Display::kInvalidDisplayID; 666 const int64_t invalid_id = display::Display::kInvalidDisplayID;
656 const DisplayInfo internal_display_info = 667 const DisplayInfo internal_display_info =
657 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); 668 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500));
658 const DisplayInfo external_display_info = 669 const DisplayInfo external_display_info =
659 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); 670 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100));
660 const DisplayInfo mirroring_display_info = 671 const DisplayInfo mirroring_display_info =
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 819 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
809 EXPECT_EQ( 820 EXPECT_EQ(
810 "0,0 500x500", 821 "0,0 500x500",
811 GetDisplayInfoForId(internal_display_id).bounds_in_native().ToString()); 822 GetDisplayInfoForId(internal_display_id).bounds_in_native().ToString());
812 EXPECT_EQ(1U, display_manager()->num_connected_displays()); 823 EXPECT_EQ(1U, display_manager()->num_connected_displays());
813 EXPECT_FALSE(display_manager()->IsInMirrorMode()); 824 EXPECT_FALSE(display_manager()->IsInMirrorMode());
814 } 825 }
815 826
816 // Make sure crash does not happen if add and remove happens at the same time. 827 // Make sure crash does not happen if add and remove happens at the same time.
817 // See: crbug.com/414394 828 // See: crbug.com/414394
818 TEST_F(DisplayManagerTest, DisplayAddRemoveAtTheSameTime) { 829 TEST_P(DisplayManagerTest, DisplayAddRemoveAtTheSameTime) {
819 if (!SupportsMultipleDisplays()) 830 if (!SupportsMultipleDisplays())
820 return; 831 return;
821 832
822 UpdateDisplay("100+0-500x500,0+501-400x400"); 833 UpdateDisplay("100+0-500x500,0+501-400x400");
823 834
824 const int64_t primary_id = WindowTreeHostManager::GetPrimaryDisplayId(); 835 const int64_t primary_id = WindowTreeHostManager::GetPrimaryDisplayId();
825 const int64_t secondary_id = ScreenUtil::GetSecondaryDisplay().id(); 836 const int64_t secondary_id = ScreenUtil::GetSecondaryDisplay().id();
826 837
827 DisplayInfo primary_info = display_manager()->GetDisplayInfo(primary_id); 838 DisplayInfo primary_info = display_manager()->GetDisplayInfo(primary_id);
828 DisplayInfo secondary_info = display_manager()->GetDisplayInfo(secondary_id); 839 DisplayInfo secondary_info = display_manager()->GetDisplayInfo(secondary_id);
829 840
830 // An id which is different from primary and secondary. 841 // An id which is different from primary and secondary.
831 const int64_t third_id = secondary_id + 1; 842 const int64_t third_id = secondary_id + 1;
832 843
833 DisplayInfo third_info = 844 DisplayInfo third_info =
834 CreateDisplayInfo(third_id, gfx::Rect(0, 0, 600, 600)); 845 CreateDisplayInfo(third_id, gfx::Rect(0, 0, 600, 600));
835 846
836 std::vector<DisplayInfo> display_info_list; 847 std::vector<DisplayInfo> display_info_list;
837 display_info_list.push_back(third_info); 848 display_info_list.push_back(third_info);
838 display_info_list.push_back(secondary_info); 849 display_info_list.push_back(secondary_info);
839 display_manager()->OnNativeDisplaysChanged(display_info_list); 850 display_manager()->OnNativeDisplaysChanged(display_info_list);
840 851
841 // Secondary seconary_id becomes the primary as it has smaller output index. 852 // Secondary seconary_id becomes the primary as it has smaller output index.
842 EXPECT_EQ(secondary_id, WindowTreeHostManager::GetPrimaryDisplayId()); 853 EXPECT_EQ(secondary_id, WindowTreeHostManager::GetPrimaryDisplayId());
843 EXPECT_EQ(third_id, ScreenUtil::GetSecondaryDisplay().id()); 854 EXPECT_EQ(third_id, ScreenUtil::GetSecondaryDisplay().id());
844 EXPECT_EQ("600x600", GetDisplayForId(third_id).size().ToString()); 855 EXPECT_EQ("600x600", GetDisplayForId(third_id).size().ToString());
845 } 856 }
846 857
847 #if defined(OS_WIN)
848 // TODO(scottmg): RootWindow doesn't get resized on Windows 858 // TODO(scottmg): RootWindow doesn't get resized on Windows
849 // Ash. http://crbug.com/247916. 859 // Ash. http://crbug.com/247916.
850 #define MAYBE_TestNativeDisplaysChangedNoInternal \ 860 #if defined(OS_CHROMEOS)
851 DISABLED_TestNativeDisplaysChangedNoInternal 861 TEST_P(DisplayManagerTest, TestNativeDisplaysChangedNoInternal) {
852 #else
853 #define MAYBE_TestNativeDisplaysChangedNoInternal \
854 TestNativeDisplaysChangedNoInternal
855 #endif
856 TEST_F(DisplayManagerTest, MAYBE_TestNativeDisplaysChangedNoInternal) {
857 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 862 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
858 863
859 // Don't change the display info if all displays are disconnected. 864 // Don't change the display info if all displays are disconnected.
860 std::vector<DisplayInfo> display_info_list; 865 std::vector<DisplayInfo> display_info_list;
861 display_manager()->OnNativeDisplaysChanged(display_info_list); 866 display_manager()->OnNativeDisplaysChanged(display_info_list);
862 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 867 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
863 868
864 // Connect another display which will become primary. 869 // Connect another display which will become primary.
865 const DisplayInfo external_display_info = 870 const DisplayInfo external_display_info =
866 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); 871 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100));
867 display_info_list.push_back(external_display_info); 872 display_info_list.push_back(external_display_info);
868 display_manager()->OnNativeDisplaysChanged(display_info_list); 873 display_manager()->OnNativeDisplaysChanged(display_info_list);
869 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 874 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
870 EXPECT_EQ("1,1 100x100", 875 EXPECT_EQ("1,1 100x100",
871 GetDisplayInfoForId(10).bounds_in_native().ToString()); 876 GetDisplayInfoForId(10).bounds_in_native().ToString());
872 EXPECT_EQ("100x100", ash::Shell::GetPrimaryRootWindow()->GetHost()-> 877 EXPECT_EQ("100x100", ash::Shell::GetPrimaryRootWindow()->GetHost()->
873 GetBounds().size().ToString()); 878 GetBounds().size().ToString());
874 } 879 }
880 #endif // defined(OS_CHROMEOS)
875 881
876 TEST_F(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) { 882 TEST_P(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) {
877 if (!SupportsMultipleDisplays()) 883 if (!SupportsMultipleDisplays())
878 return; 884 return;
879 885
880 const int64_t internal_display_id = 886 const int64_t internal_display_id =
881 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); 887 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay();
882 const DisplayInfo native_display_info = 888 const DisplayInfo native_display_info =
883 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); 889 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500));
884 const DisplayInfo secondary_display_info = 890 const DisplayInfo secondary_display_info =
885 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); 891 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100));
886 892
(...skipping 13 matching lines...) Expand all
900 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString()); 906 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString());
901 907
902 // OnNativeDisplaysChanged may change the display bounds. Here makes sure 908 // OnNativeDisplaysChanged may change the display bounds. Here makes sure
903 // nothing changed if the exactly same displays are specified. 909 // nothing changed if the exactly same displays are specified.
904 display_manager()->OnNativeDisplaysChanged(display_info_list); 910 display_manager()->OnNativeDisplaysChanged(display_info_list);
905 EXPECT_EQ("-500,0 500x500", 911 EXPECT_EQ("-500,0 500x500",
906 GetDisplayForId(internal_display_id).bounds().ToString()); 912 GetDisplayForId(internal_display_id).bounds().ToString());
907 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString()); 913 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString());
908 } 914 }
909 915
910 #if defined(OS_WIN)
911 // TODO(msw): Broken on Windows. http://crbug.com/584038 916 // TODO(msw): Broken on Windows. http://crbug.com/584038
912 #define MAYBE_DontRememberBestResolution DISABLED_DontRememberBestResolution 917 #if defined(OS_CHROMEOS)
913 #else 918 TEST_P(DisplayManagerTest, DontRememberBestResolution) {
914 #define MAYBE_DontRememberBestResolution DontRememberBestResolution
915 #endif
916 TEST_F(DisplayManagerTest, MAYBE_DontRememberBestResolution) {
917 int display_id = 1000; 919 int display_id = 1000;
918 DisplayInfo native_display_info = 920 DisplayInfo native_display_info =
919 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); 921 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500));
920 std::vector<DisplayMode> display_modes; 922 std::vector<DisplayMode> display_modes;
921 display_modes.push_back( 923 display_modes.push_back(
922 DisplayMode(gfx::Size(1000, 500), 58.0f, false, true)); 924 DisplayMode(gfx::Size(1000, 500), 58.0f, false, true));
923 display_modes.push_back( 925 display_modes.push_back(
924 DisplayMode(gfx::Size(800, 300), 59.0f, false, false)); 926 DisplayMode(gfx::Size(800, 300), 59.0f, false, false));
925 display_modes.push_back( 927 display_modes.push_back(
926 DisplayMode(gfx::Size(400, 500), 60.0f, false, false)); 928 DisplayMode(gfx::Size(400, 500), 60.0f, false, false));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 test::SetDisplayResolution(display_id, gfx::Size(1000, 500)); 963 test::SetDisplayResolution(display_id, gfx::Size(1000, 500));
962 EXPECT_TRUE( 964 EXPECT_TRUE(
963 display_manager()->GetSelectedModeForDisplayId(display_id, &mode)); 965 display_manager()->GetSelectedModeForDisplayId(display_id, &mode));
964 EXPECT_EQ("1000x500", mode.size.ToString()); 966 EXPECT_EQ("1000x500", mode.size.ToString());
965 EXPECT_EQ(58.0f, mode.refresh_rate); 967 EXPECT_EQ(58.0f, mode.refresh_rate);
966 EXPECT_TRUE(mode.native); 968 EXPECT_TRUE(mode.native);
967 expected_mode.size = gfx::Size(1000, 500); 969 expected_mode.size = gfx::Size(1000, 500);
968 EXPECT_TRUE(expected_mode.IsEquivalent( 970 EXPECT_TRUE(expected_mode.IsEquivalent(
969 display_manager()->GetActiveModeForDisplayId(display_id))); 971 display_manager()->GetActiveModeForDisplayId(display_id)));
970 } 972 }
973 #endif // defined(OS_CHROMEOS)
971 974
972 #if defined(OS_WIN)
973 // TODO(msw): Broken on Windows. http://crbug.com/584038 975 // TODO(msw): Broken on Windows. http://crbug.com/584038
974 #define MAYBE_ResolutionFallback DISABLED_ResolutionFallback 976 #if defined(OS_CHROMEOS)
975 #else 977 TEST_P(DisplayManagerTest, ResolutionFallback) {
976 #define MAYBE_ResolutionFallback ResolutionFallback
977 #endif
978 TEST_F(DisplayManagerTest, MAYBE_ResolutionFallback) {
979 int display_id = 1000; 978 int display_id = 1000;
980 DisplayInfo native_display_info = 979 DisplayInfo native_display_info =
981 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); 980 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500));
982 std::vector<DisplayMode> display_modes; 981 std::vector<DisplayMode> display_modes;
983 display_modes.push_back( 982 display_modes.push_back(
984 DisplayMode(gfx::Size(1000, 500), 58.0f, false, true)); 983 DisplayMode(gfx::Size(1000, 500), 58.0f, false, true));
985 display_modes.push_back( 984 display_modes.push_back(
986 DisplayMode(gfx::Size(800, 300), 59.0f, false, false)); 985 DisplayMode(gfx::Size(800, 300), 59.0f, false, false));
987 display_modes.push_back( 986 display_modes.push_back(
988 DisplayMode(gfx::Size(400, 500), 60.0f, false, false)); 987 DisplayMode(gfx::Size(400, 500), 60.0f, false, false));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 display_manager()->OnNativeDisplaysChanged(new_display_info_list); 1021 display_manager()->OnNativeDisplaysChanged(new_display_info_list);
1023 1022
1024 DisplayMode mode; 1023 DisplayMode mode;
1025 EXPECT_TRUE( 1024 EXPECT_TRUE(
1026 display_manager()->GetSelectedModeForDisplayId(display_id, &mode)); 1025 display_manager()->GetSelectedModeForDisplayId(display_id, &mode));
1027 EXPECT_EQ("1000x500", mode.size.ToString()); 1026 EXPECT_EQ("1000x500", mode.size.ToString());
1028 EXPECT_EQ(58.0f, mode.refresh_rate); 1027 EXPECT_EQ(58.0f, mode.refresh_rate);
1029 EXPECT_TRUE(mode.native); 1028 EXPECT_TRUE(mode.native);
1030 } 1029 }
1031 } 1030 }
1031 #endif // defined(OS_CHROMEOS)
1032 1032
1033 TEST_F(DisplayManagerTest, Rotate) { 1033 TEST_P(DisplayManagerTest, Rotate) {
1034 if (!SupportsMultipleDisplays()) 1034 if (!SupportsMultipleDisplays())
1035 return; 1035 return;
1036 1036
1037 UpdateDisplay("100x200/r,300x400/l"); 1037 UpdateDisplay("100x200/r,300x400/l");
1038 EXPECT_EQ("1,1 100x200", 1038 EXPECT_EQ("1,1 100x200",
1039 GetDisplayInfoAt(0).bounds_in_native().ToString()); 1039 GetDisplayInfoAt(0).bounds_in_native().ToString());
1040 EXPECT_EQ("200x100", 1040 EXPECT_EQ("200x100",
1041 GetDisplayInfoAt(0).size_in_pixel().ToString()); 1041 GetDisplayInfoAt(0).size_in_pixel().ToString());
1042 1042
1043 EXPECT_EQ("1,201 300x400", 1043 EXPECT_EQ("1,201 300x400",
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 display_manager()->SetDisplayRotation( 1115 display_manager()->SetDisplayRotation(
1116 internal_display_id, display::Display::ROTATE_180, 1116 internal_display_id, display::Display::ROTATE_180,
1117 display::Display::ROTATION_SOURCE_ACTIVE); 1117 display::Display::ROTATION_SOURCE_ACTIVE);
1118 const DisplayInfo post_rotation_info = 1118 const DisplayInfo post_rotation_info =
1119 display_manager()->display_info_[internal_display_id]; 1119 display_manager()->display_info_[internal_display_id];
1120 EXPECT_NE(info.GetActiveRotation(), post_rotation_info.GetActiveRotation()); 1120 EXPECT_NE(info.GetActiveRotation(), post_rotation_info.GetActiveRotation());
1121 EXPECT_EQ(display::Display::ROTATE_180, 1121 EXPECT_EQ(display::Display::ROTATE_180,
1122 post_rotation_info.GetActiveRotation()); 1122 post_rotation_info.GetActiveRotation());
1123 } 1123 }
1124 1124
1125 #if defined(OS_WIN)
1126 // TODO(msw): Broken on Windows. http://crbug.com/584038 1125 // TODO(msw): Broken on Windows. http://crbug.com/584038
1127 #define MAYBE_UIScale DISABLED_UIScale 1126 #if defined(OS_CHROMEOS)
1128 #else 1127 TEST_P(DisplayManagerTest, UIScale) {
1129 #define MAYBE_UIScale UIScale
1130 #endif
1131 TEST_F(DisplayManagerTest, MAYBE_UIScale) {
1132 test::ScopedDisable125DSFForUIScaling disable; 1128 test::ScopedDisable125DSFForUIScaling disable;
1133 1129
1134 UpdateDisplay("1280x800"); 1130 UpdateDisplay("1280x800");
1135 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1131 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1136 SetDisplayUIScale(display_id, 1.125f); 1132 SetDisplayUIScale(display_id, 1.125f);
1137 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale()); 1133 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale());
1138 SetDisplayUIScale(display_id, 0.8f); 1134 SetDisplayUIScale(display_id, 0.8f);
1139 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1135 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1140 SetDisplayUIScale(display_id, 0.75f); 1136 SetDisplayUIScale(display_id, 0.75f);
1141 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1137 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 // 1.25 ui scaling on 1.25 DSF device should use 1.0 DSF 1210 // 1.25 ui scaling on 1.25 DSF device should use 1.0 DSF
1215 // on screen. 1211 // on screen.
1216 UpdateDisplay("1280x850*1.25"); 1212 UpdateDisplay("1280x850*1.25");
1217 SetDisplayUIScale(display_id, 1.25f); 1213 SetDisplayUIScale(display_id, 1.25f);
1218 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).configured_ui_scale()); 1214 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).configured_ui_scale());
1219 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1215 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1220 display = display::Screen::GetScreen()->GetPrimaryDisplay(); 1216 display = display::Screen::GetScreen()->GetPrimaryDisplay();
1221 EXPECT_EQ(1.0f, display.device_scale_factor()); 1217 EXPECT_EQ(1.0f, display.device_scale_factor());
1222 EXPECT_EQ("1280x850", display.bounds().size().ToString()); 1218 EXPECT_EQ("1280x850", display.bounds().size().ToString());
1223 } 1219 }
1220 #endif // defined(OS_CHROMEOS)
1224 1221
1225 TEST_F(DisplayManagerTest, UIScaleWithDisplayMode) { 1222 TEST_P(DisplayManagerTest, UIScaleWithDisplayMode) {
1226 int display_id = 1000; 1223 int display_id = 1000;
1227 1224
1228 // Setup the display modes with UI-scale. 1225 // Setup the display modes with UI-scale.
1229 DisplayInfo native_display_info = 1226 DisplayInfo native_display_info =
1230 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1280, 800)); 1227 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1280, 800));
1231 const DisplayMode base_mode(gfx::Size(1280, 800), 60.0f, false, false); 1228 const DisplayMode base_mode(gfx::Size(1280, 800), 60.0f, false, false);
1232 std::vector<DisplayMode> mode_list = CreateInternalDisplayModeList(base_mode); 1229 std::vector<DisplayMode> mode_list = CreateInternalDisplayModeList(base_mode);
1233 native_display_info.SetDisplayModes(mode_list); 1230 native_display_info.SetDisplayModes(mode_list);
1234 1231
1235 std::vector<DisplayInfo> display_info_list; 1232 std::vector<DisplayInfo> display_info_list;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); 1270 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale());
1274 EXPECT_TRUE(expected_mode.IsEquivalent( 1271 EXPECT_TRUE(expected_mode.IsEquivalent(
1275 display_manager()->GetActiveModeForDisplayId(display_id))); 1272 display_manager()->GetActiveModeForDisplayId(display_id)));
1276 SetDisplayUIScale(display_id, 0.5f); 1273 SetDisplayUIScale(display_id, 0.5f);
1277 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale()); 1274 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale());
1278 expected_mode.ui_scale = 0.5f; 1275 expected_mode.ui_scale = 0.5f;
1279 EXPECT_TRUE(expected_mode.IsEquivalent( 1276 EXPECT_TRUE(expected_mode.IsEquivalent(
1280 display_manager()->GetActiveModeForDisplayId(display_id))); 1277 display_manager()->GetActiveModeForDisplayId(display_id)));
1281 } 1278 }
1282 1279
1283 #if defined(OS_WIN) && !defined(USE_ASH)
1284 // TODO(msw): Broken on Windows. http://crbug.com/584038 1280 // TODO(msw): Broken on Windows. http://crbug.com/584038
1285 #define MAYBE_Use125DSFForUIScaling DISABLED_Use125DSFForUIScaling 1281 #if defined(OS_CHROMEOS)
1286 #else 1282 TEST_P(DisplayManagerTest, Use125DSFForUIScaling) {
1287 #define MAYBE_Use125DSFForUIScaling Use125DSFForUIScaling
1288 #endif
1289 TEST_F(DisplayManagerTest, MAYBE_Use125DSFForUIScaling) {
1290 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1283 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1291 1284
1292 test::ScopedSetInternalDisplayId set_internal(display_id); 1285 test::ScopedSetInternalDisplayId set_internal(display_id);
1293 UpdateDisplay("1920x1080*1.25"); 1286 UpdateDisplay("1920x1080*1.25");
1294 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1287 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1295 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1288 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1296 1289
1297 SetDisplayUIScale(display_id, 0.8f); 1290 SetDisplayUIScale(display_id, 0.8f);
1298 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1291 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1299 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1292 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1300 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString()); 1293 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString());
1301 1294
1302 SetDisplayUIScale(display_id, 0.5f); 1295 SetDisplayUIScale(display_id, 0.5f);
1303 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1296 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1304 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1297 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1305 EXPECT_EQ("960x540", GetDisplayForId(display_id).size().ToString()); 1298 EXPECT_EQ("960x540", GetDisplayForId(display_id).size().ToString());
1306 1299
1307 SetDisplayUIScale(display_id, 1.25f); 1300 SetDisplayUIScale(display_id, 1.25f);
1308 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1301 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1309 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1302 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1310 EXPECT_EQ("2400x1350", GetDisplayForId(display_id).size().ToString()); 1303 EXPECT_EQ("2400x1350", GetDisplayForId(display_id).size().ToString());
1311 } 1304 }
1305 #endif // defined(OS_CHROMEOS)
1312 1306
1313 #if defined(OS_WIN) && !defined(USE_ASH)
1314 // TODO(msw): Broken on Windows. http://crbug.com/584038 1307 // TODO(msw): Broken on Windows. http://crbug.com/584038
1315 #define MAYBE_FHD125DefaultsTo08UIScaling DISABLED_FHD125DefaultsTo08UIScaling 1308 #if defined(OS_CHROMEOS)
1316 #else 1309 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScaling) {
1317 #define MAYBE_FHD125DefaultsTo08UIScaling FHD125DefaultsTo08UIScaling
1318 #endif
1319 TEST_F(DisplayManagerTest, MAYBE_FHD125DefaultsTo08UIScaling) {
1320 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1310 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1321 1311
1322 display_id++; 1312 display_id++;
1323 test::ScopedSetInternalDisplayId set_internal(display_id); 1313 test::ScopedSetInternalDisplayId set_internal(display_id);
1324 1314
1325 // Setup the display modes with UI-scale. 1315 // Setup the display modes with UI-scale.
1326 DisplayInfo native_display_info = 1316 DisplayInfo native_display_info =
1327 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080)); 1317 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080));
1328 native_display_info.set_device_scale_factor(1.25); 1318 native_display_info.set_device_scale_factor(1.25);
1329 1319
1330 const DisplayMode base_mode(gfx::Size(1920, 1080), 60.0f, false, false); 1320 const DisplayMode base_mode(gfx::Size(1920, 1080), 60.0f, false, false);
1331 std::vector<DisplayMode> mode_list = CreateInternalDisplayModeList(base_mode); 1321 std::vector<DisplayMode> mode_list = CreateInternalDisplayModeList(base_mode);
1332 native_display_info.SetDisplayModes(mode_list); 1322 native_display_info.SetDisplayModes(mode_list);
1333 1323
1334 std::vector<DisplayInfo> display_info_list; 1324 std::vector<DisplayInfo> display_info_list;
1335 display_info_list.push_back(native_display_info); 1325 display_info_list.push_back(native_display_info);
1336 1326
1337 display_manager()->OnNativeDisplaysChanged(display_info_list); 1327 display_manager()->OnNativeDisplaysChanged(display_info_list);
1338 1328
1339 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1329 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1340 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1330 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1341 } 1331 }
1332 #endif // defined(OS_CHROMEOS)
1342 1333
1343 #if defined(OS_WIN) && !defined(USE_ASH)
1344 // TODO(msw): Broken on Windows. http://crbug.com/584038 1334 // TODO(msw): Broken on Windows. http://crbug.com/584038
1345 #define MAYBE_FHD125DefaultsTo08UIScalingNoOverride \ 1335 #if defined(OS_CHROMEOS)
1346 DISABLED_FHD125DefaultsTo08UIScalingNoOverride
1347 #else
1348 #define MAYBE_FHD125DefaultsTo08UIScalingNoOverride \
1349 FHD125DefaultsTo08UIScalingNoOverride
1350 #endif
1351 // Don't default to 1.25 DSF if the user already has a prefrence stored for 1336 // Don't default to 1.25 DSF if the user already has a prefrence stored for
1352 // the internal display. 1337 // the internal display.
1353 TEST_F(DisplayManagerTest, MAYBE_FHD125DefaultsTo08UIScalingNoOverride) { 1338 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScalingNoOverride) {
1354 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1339 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1355 1340
1356 display_id++; 1341 display_id++;
1357 test::ScopedSetInternalDisplayId set_internal(display_id); 1342 test::ScopedSetInternalDisplayId set_internal(display_id);
1358 const gfx::Insets dummy_overscan_insets; 1343 const gfx::Insets dummy_overscan_insets;
1359 display_manager()->RegisterDisplayProperty( 1344 display_manager()->RegisterDisplayProperty(
1360 display_id, display::Display::ROTATE_0, 1.0f, &dummy_overscan_insets, 1345 display_id, display::Display::ROTATE_0, 1.0f, &dummy_overscan_insets,
1361 gfx::Size(), 1.0f, ui::ColorCalibrationProfile()); 1346 gfx::Size(), 1.0f, ui::ColorCalibrationProfile());
1362 1347
1363 // Setup the display modes with UI-scale. 1348 // Setup the display modes with UI-scale.
1364 DisplayInfo native_display_info = 1349 DisplayInfo native_display_info =
1365 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080)); 1350 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080));
1366 native_display_info.set_device_scale_factor(1.25); 1351 native_display_info.set_device_scale_factor(1.25);
1367 1352
1368 const DisplayMode base_mode(gfx::Size(1920, 1080), 60.0f, false, false); 1353 const DisplayMode base_mode(gfx::Size(1920, 1080), 60.0f, false, false);
1369 std::vector<DisplayMode> mode_list = CreateInternalDisplayModeList(base_mode); 1354 std::vector<DisplayMode> mode_list = CreateInternalDisplayModeList(base_mode);
1370 native_display_info.SetDisplayModes(mode_list); 1355 native_display_info.SetDisplayModes(mode_list);
1371 1356
1372 std::vector<DisplayInfo> display_info_list; 1357 std::vector<DisplayInfo> display_info_list;
1373 display_info_list.push_back(native_display_info); 1358 display_info_list.push_back(native_display_info);
1374 1359
1375 display_manager()->OnNativeDisplaysChanged(display_info_list); 1360 display_manager()->OnNativeDisplaysChanged(display_info_list);
1376 1361
1377 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1362 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1378 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1363 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1379 } 1364 }
1365 #endif // defined(OS_CHROMEOS)
1380 1366
1381 TEST_F(DisplayManagerTest, ResolutionChangeInUnifiedMode) { 1367 TEST_P(DisplayManagerTest, ResolutionChangeInUnifiedMode) {
1382 if (!SupportsMultipleDisplays()) 1368 if (!SupportsMultipleDisplays())
1383 return; 1369 return;
1384 // Don't check root window destruction in unified mode. 1370 // Don't check root window destruction in unified mode.
1385 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 1371 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
1386 1372
1387 display_manager()->SetUnifiedDesktopEnabled(true); 1373 display_manager()->SetUnifiedDesktopEnabled(true);
1388 1374
1389 UpdateDisplay("200x200, 400x400"); 1375 UpdateDisplay("200x200, 400x400");
1390 1376
1391 int64_t unified_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1377 int64_t unified_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
(...skipping 24 matching lines...) Expand all
1416 UpdateDisplay("600x600, 200x200"); 1402 UpdateDisplay("600x600, 200x200");
1417 EXPECT_EQ( 1403 EXPECT_EQ(
1418 "1200x600", 1404 "1200x600",
1419 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); 1405 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString());
1420 active_mode = display_manager()->GetActiveModeForDisplayId(unified_id); 1406 active_mode = display_manager()->GetActiveModeForDisplayId(unified_id);
1421 EXPECT_EQ(1.0f, active_mode.ui_scale); 1407 EXPECT_EQ(1.0f, active_mode.ui_scale);
1422 EXPECT_TRUE(active_mode.native); 1408 EXPECT_TRUE(active_mode.native);
1423 EXPECT_EQ("1200x600", active_mode.size.ToString()); 1409 EXPECT_EQ("1200x600", active_mode.size.ToString());
1424 } 1410 }
1425 1411
1426 #if defined(OS_WIN)
1427 // TODO(scottmg): RootWindow doesn't get resized on Windows 1412 // TODO(scottmg): RootWindow doesn't get resized on Windows
1428 // Ash. http://crbug.com/247916. 1413 // Ash. http://crbug.com/247916.
1429 #define MAYBE_UpdateMouseCursorAfterRotateZoom \ 1414 #if defined(OS_CHROMEOS)
1430 DISABLED_UpdateMouseCursorAfterRotateZoom 1415 TEST_P(DisplayManagerTest, UpdateMouseCursorAfterRotateZoom) {
1431 #else
1432 #define MAYBE_UpdateMouseCursorAfterRotateZoom UpdateMouseCursorAfterRotateZoom
1433 #endif
1434 TEST_F(DisplayManagerTest, MAYBE_UpdateMouseCursorAfterRotateZoom) {
1435 // Make sure just rotating will not change native location. 1416 // Make sure just rotating will not change native location.
1436 UpdateDisplay("300x200,200x150"); 1417 UpdateDisplay("300x200,200x150");
1437 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1418 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1438 aura::Env* env = aura::Env::GetInstance(); 1419 aura::Env* env = aura::Env::GetInstance();
1439 1420
1440 ui::test::EventGenerator generator1(root_windows[0]); 1421 ui::test::EventGenerator generator1(root_windows[0]);
1441 ui::test::EventGenerator generator2(root_windows[1]); 1422 ui::test::EventGenerator generator2(root_windows[1]);
1442 1423
1443 // Test on 1st display. 1424 // Test on 1st display.
1444 generator1.MoveMouseToInHost(150, 50); 1425 generator1.MoveMouseToInHost(150, 50);
(...skipping 26 matching lines...) Expand all
1471 generator2.MoveMouseToInHost(200, 250); 1452 generator2.MoveMouseToInHost(200, 250);
1472 EXPECT_EQ("700,125", env->last_mouse_location().ToString()); 1453 EXPECT_EQ("700,125", env->last_mouse_location().ToString());
1473 UpdateDisplay("600x400,400x300*2@1.5"); 1454 UpdateDisplay("600x400,400x300*2@1.5");
1474 EXPECT_EQ("750,187", env->last_mouse_location().ToString()); 1455 EXPECT_EQ("750,187", env->last_mouse_location().ToString());
1475 1456
1476 // The native location is now outside, so move to the 1457 // The native location is now outside, so move to the
1477 // center of closest display. 1458 // center of closest display.
1478 UpdateDisplay("600x400,400x200*2@1.5"); 1459 UpdateDisplay("600x400,400x200*2@1.5");
1479 EXPECT_EQ("750,75", env->last_mouse_location().ToString()); 1460 EXPECT_EQ("750,75", env->last_mouse_location().ToString());
1480 } 1461 }
1462 #endif // defined(OS_CHROMEOS)
1481 1463
1482 class TestDisplayObserver : public display::DisplayObserver { 1464 class TestDisplayObserver : public display::DisplayObserver {
1483 public: 1465 public:
1484 TestDisplayObserver() : changed_(false) {} 1466 TestDisplayObserver() : changed_(false) {}
1485 ~TestDisplayObserver() override {} 1467 ~TestDisplayObserver() override {}
1486 1468
1487 // display::DisplayObserver overrides: 1469 // display::DisplayObserver overrides:
1488 void OnDisplayMetricsChanged(const display::Display&, uint32_t) override {} 1470 void OnDisplayMetricsChanged(const display::Display&, uint32_t) override {}
1489 void OnDisplayAdded(const display::Display& new_display) override { 1471 void OnDisplayAdded(const display::Display& new_display) override {
1490 // Mirror window should already be delete before restoring 1472 // Mirror window should already be delete before restoring
(...skipping 14 matching lines...) Expand all
1505 return changed; 1487 return changed;
1506 } 1488 }
1507 1489
1508 private: 1490 private:
1509 test::MirrorWindowTestApi test_api; 1491 test::MirrorWindowTestApi test_api;
1510 bool changed_; 1492 bool changed_;
1511 1493
1512 DISALLOW_COPY_AND_ASSIGN(TestDisplayObserver); 1494 DISALLOW_COPY_AND_ASSIGN(TestDisplayObserver);
1513 }; 1495 };
1514 1496
1515 TEST_F(DisplayManagerTest, SoftwareMirroring) { 1497 TEST_P(DisplayManagerTest, SoftwareMirroring) {
1516 if (!SupportsMultipleDisplays()) 1498 if (!SupportsMultipleDisplays())
1517 return; 1499 return;
1518 1500
1519 UpdateDisplay("300x400,400x500"); 1501 UpdateDisplay("300x400,400x500");
1520 1502
1521 test::MirrorWindowTestApi test_api; 1503 test::MirrorWindowTestApi test_api;
1522 EXPECT_EQ(nullptr, test_api.GetHost()); 1504 EXPECT_EQ(nullptr, test_api.GetHost());
1523 1505
1524 TestDisplayObserver display_observer; 1506 TestDisplayObserver display_observer;
1525 display::Screen::GetScreen()->AddObserver(&display_observer); 1507 display::Screen::GetScreen()->AddObserver(&display_observer);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 1553
1572 // Overscan insets are ignored. 1554 // Overscan insets are ignored.
1573 UpdateDisplay("400x600/o,600x800/o"); 1555 UpdateDisplay("400x600/o,600x800/o");
1574 EXPECT_FALSE(display_observer.changed_and_reset()); 1556 EXPECT_FALSE(display_observer.changed_and_reset());
1575 EXPECT_EQ("400x600", 1557 EXPECT_EQ("400x600",
1576 test_api.GetHost()->window()->bounds().size().ToString()); 1558 test_api.GetHost()->window()->bounds().size().ToString());
1577 1559
1578 display::Screen::GetScreen()->RemoveObserver(&display_observer); 1560 display::Screen::GetScreen()->RemoveObserver(&display_observer);
1579 } 1561 }
1580 1562
1581 TEST_F(DisplayManagerTest, RotateInSoftwareMirroring) { 1563 TEST_P(DisplayManagerTest, RotateInSoftwareMirroring) {
1582 if (!SupportsMultipleDisplays()) 1564 if (!SupportsMultipleDisplays())
1583 return; 1565 return;
1584 1566
1585 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 1567 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
1586 UpdateDisplay("600x400,500x300"); 1568 UpdateDisplay("600x400,500x300");
1587 display_manager->SetMirrorMode(true); 1569 display_manager->SetMirrorMode(true);
1588 1570
1589 EXPECT_EQ(1U, display_manager->GetNumDisplays()); 1571 EXPECT_EQ(1U, display_manager->GetNumDisplays());
1590 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1572 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1591 display_manager->SetDisplayRotation(primary_id, display::Display::ROTATE_180, 1573 display_manager->SetDisplayRotation(primary_id, display::Display::ROTATE_180,
1592 display::Display::ROTATION_SOURCE_ACTIVE); 1574 display::Display::ROTATION_SOURCE_ACTIVE);
1593 display_manager->SetMirrorMode(false); 1575 display_manager->SetMirrorMode(false);
1594 } 1576 }
1595 1577
1596 TEST_F(DisplayManagerTest, SingleDisplayToSoftwareMirroring) { 1578 TEST_P(DisplayManagerTest, SingleDisplayToSoftwareMirroring) {
1597 if (!SupportsMultipleDisplays()) 1579 if (!SupportsMultipleDisplays())
1598 return; 1580 return;
1599 UpdateDisplay("600x400"); 1581 UpdateDisplay("600x400");
1600 1582
1601 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 1583 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
1602 display_manager->SetMultiDisplayMode(DisplayManager::MIRRORING); 1584 display_manager->SetMultiDisplayMode(DisplayManager::MIRRORING);
1603 UpdateDisplay("600x400,600x400"); 1585 UpdateDisplay("600x400,600x400");
1604 1586
1605 EXPECT_TRUE(display_manager->IsInMirrorMode()); 1587 EXPECT_TRUE(display_manager->IsInMirrorMode());
1606 EXPECT_EQ(1U, display_manager->GetNumDisplays()); 1588 EXPECT_EQ(1U, display_manager->GetNumDisplays());
1607 WindowTreeHostManager* window_tree_host_manager = 1589 WindowTreeHostManager* window_tree_host_manager =
1608 ash::Shell::GetInstance()->window_tree_host_manager(); 1590 ash::Shell::GetInstance()->window_tree_host_manager();
1609 EXPECT_TRUE( 1591 EXPECT_TRUE(
1610 window_tree_host_manager->mirror_window_controller()->GetWindow()); 1592 window_tree_host_manager->mirror_window_controller()->GetWindow());
1611 1593
1612 UpdateDisplay("600x400"); 1594 UpdateDisplay("600x400");
1613 EXPECT_FALSE(display_manager->IsInMirrorMode()); 1595 EXPECT_FALSE(display_manager->IsInMirrorMode());
1614 EXPECT_EQ(1U, display_manager->GetNumDisplays()); 1596 EXPECT_EQ(1U, display_manager->GetNumDisplays());
1615 EXPECT_FALSE( 1597 EXPECT_FALSE(
1616 window_tree_host_manager->mirror_window_controller()->GetWindow()); 1598 window_tree_host_manager->mirror_window_controller()->GetWindow());
1617 } 1599 }
1618 1600
1619 #if defined(OS_CHROMEOS) 1601 #if defined(OS_CHROMEOS)
1620 // Make sure this does not cause any crashes. See http://crbug.com/412910 1602 // Make sure this does not cause any crashes. See http://crbug.com/412910
1621 // This test is limited to OS_CHROMEOS because CursorCompositingEnabled is only 1603 // This test is limited to OS_CHROMEOS because CursorCompositingEnabled is only
1622 // for ChromeOS. 1604 // for ChromeOS.
1623 TEST_F(DisplayManagerTest, SoftwareMirroringWithCompositingCursor) { 1605 TEST_P(DisplayManagerTest, SoftwareMirroringWithCompositingCursor) {
1624 if (!SupportsMultipleDisplays()) 1606 if (!SupportsMultipleDisplays())
1625 return; 1607 return;
1626 1608
1627 UpdateDisplay("300x400,400x500"); 1609 UpdateDisplay("300x400,400x500");
1628 1610
1629 test::MirrorWindowTestApi test_api; 1611 test::MirrorWindowTestApi test_api;
1630 EXPECT_EQ(nullptr, test_api.GetHost()); 1612 EXPECT_EQ(nullptr, test_api.GetHost());
1631 1613
1632 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 1614 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
1633 DisplayInfo secondary_info = display_manager->GetDisplayInfo( 1615 DisplayInfo secondary_info = display_manager->GetDisplayInfo(
(...skipping 15 matching lines...) Expand all
1649 new_info_list.push_back(secondary_info); 1631 new_info_list.push_back(secondary_info);
1650 display_manager->OnNativeDisplaysChanged(new_info_list); 1632 display_manager->OnNativeDisplaysChanged(new_info_list);
1651 1633
1652 root_windows = Shell::GetAllRootWindows(); 1634 root_windows = Shell::GetAllRootWindows();
1653 EXPECT_TRUE(root_windows[0]->Contains(test_api.GetCursorWindow())); 1635 EXPECT_TRUE(root_windows[0]->Contains(test_api.GetCursorWindow()));
1654 1636
1655 Shell::GetInstance()->SetCursorCompositingEnabled(false); 1637 Shell::GetInstance()->SetCursorCompositingEnabled(false);
1656 } 1638 }
1657 #endif // OS_CHROMEOS 1639 #endif // OS_CHROMEOS
1658 1640
1659 TEST_F(DisplayManagerTest, MirroredLayout) { 1641 TEST_P(DisplayManagerTest, MirroredLayout) {
1660 if (!SupportsMultipleDisplays()) 1642 if (!SupportsMultipleDisplays())
1661 return; 1643 return;
1662 1644
1663 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 1645 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
1664 UpdateDisplay("500x500,400x400"); 1646 UpdateDisplay("500x500,400x400");
1665 EXPECT_FALSE(display_manager->GetCurrentDisplayLayout().mirrored); 1647 EXPECT_FALSE(display_manager->GetCurrentDisplayLayout().mirrored);
1666 EXPECT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); 1648 EXPECT_EQ(2, display::Screen::GetScreen()->GetNumDisplays());
1667 EXPECT_EQ(2U, display_manager->num_connected_displays()); 1649 EXPECT_EQ(2U, display_manager->num_connected_displays());
1668 1650
1669 UpdateDisplay("1+0-500x500,1+0-500x500"); 1651 UpdateDisplay("1+0-500x500,1+0-500x500");
1670 EXPECT_TRUE(display_manager->GetCurrentDisplayLayout().mirrored); 1652 EXPECT_TRUE(display_manager->GetCurrentDisplayLayout().mirrored);
1671 EXPECT_EQ(1, display::Screen::GetScreen()->GetNumDisplays()); 1653 EXPECT_EQ(1, display::Screen::GetScreen()->GetNumDisplays());
1672 EXPECT_EQ(2U, display_manager->num_connected_displays()); 1654 EXPECT_EQ(2U, display_manager->num_connected_displays());
1673 1655
1674 UpdateDisplay("500x500,500x500"); 1656 UpdateDisplay("500x500,500x500");
1675 EXPECT_FALSE(display_manager->GetCurrentDisplayLayout().mirrored); 1657 EXPECT_FALSE(display_manager->GetCurrentDisplayLayout().mirrored);
1676 EXPECT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); 1658 EXPECT_EQ(2, display::Screen::GetScreen()->GetNumDisplays());
1677 EXPECT_EQ(2U, display_manager->num_connected_displays()); 1659 EXPECT_EQ(2U, display_manager->num_connected_displays());
1678 } 1660 }
1679 1661
1680 TEST_F(DisplayManagerTest, InvertLayout) { 1662 TEST_P(DisplayManagerTest, InvertLayout) {
1681 EXPECT_EQ("left, 0", 1663 EXPECT_EQ("left, 0",
1682 display::DisplayPlacement(display::DisplayPlacement::RIGHT, 0) 1664 display::DisplayPlacement(display::DisplayPlacement::RIGHT, 0)
1683 .Swap() 1665 .Swap()
1684 .ToString()); 1666 .ToString());
1685 EXPECT_EQ("left, -100", 1667 EXPECT_EQ("left, -100",
1686 display::DisplayPlacement(display::DisplayPlacement::RIGHT, 100) 1668 display::DisplayPlacement(display::DisplayPlacement::RIGHT, 100)
1687 .Swap() 1669 .Swap()
1688 .ToString()); 1670 .ToString());
1689 EXPECT_EQ("left, 50", 1671 EXPECT_EQ("left, 50",
1690 display::DisplayPlacement(display::DisplayPlacement::RIGHT, -50) 1672 display::DisplayPlacement(display::DisplayPlacement::RIGHT, -50)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 EXPECT_EQ("top, -70", 1706 EXPECT_EQ("top, -70",
1725 display::DisplayPlacement(display::DisplayPlacement::BOTTOM, 70) 1707 display::DisplayPlacement(display::DisplayPlacement::BOTTOM, 70)
1726 .Swap() 1708 .Swap()
1727 .ToString()); 1709 .ToString());
1728 EXPECT_EQ("top, 80", 1710 EXPECT_EQ("top, 80",
1729 display::DisplayPlacement(display::DisplayPlacement::BOTTOM, -80) 1711 display::DisplayPlacement(display::DisplayPlacement::BOTTOM, -80)
1730 .Swap() 1712 .Swap()
1731 .ToString()); 1713 .ToString());
1732 } 1714 }
1733 1715
1734 TEST_F(DisplayManagerTest, NotifyPrimaryChange) { 1716 TEST_P(DisplayManagerTest, NotifyPrimaryChange) {
1735 if (!SupportsMultipleDisplays()) 1717 if (!SupportsMultipleDisplays())
1736 return; 1718 return;
1737 UpdateDisplay("500x500,500x500"); 1719 UpdateDisplay("500x500,500x500");
1738 test::SwapPrimaryDisplay(); 1720 test::SwapPrimaryDisplay();
1739 reset(); 1721 reset();
1740 UpdateDisplay("500x500"); 1722 UpdateDisplay("500x500");
1741 EXPECT_FALSE(changed_metrics() & 1723 EXPECT_FALSE(changed_metrics() &
1742 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); 1724 display::DisplayObserver::DISPLAY_METRIC_BOUNDS);
1743 EXPECT_FALSE(changed_metrics() & 1725 EXPECT_FALSE(changed_metrics() &
1744 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); 1726 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
1745 EXPECT_TRUE(changed_metrics() & 1727 EXPECT_TRUE(changed_metrics() &
1746 display::DisplayObserver::DISPLAY_METRIC_PRIMARY); 1728 display::DisplayObserver::DISPLAY_METRIC_PRIMARY);
1747 1729
1748 UpdateDisplay("500x500,500x500"); 1730 UpdateDisplay("500x500,500x500");
1749 test::SwapPrimaryDisplay(); 1731 test::SwapPrimaryDisplay();
1750 UpdateDisplay("500x400"); 1732 UpdateDisplay("500x400");
1751 EXPECT_TRUE(changed_metrics() & 1733 EXPECT_TRUE(changed_metrics() &
1752 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); 1734 display::DisplayObserver::DISPLAY_METRIC_BOUNDS);
1753 EXPECT_TRUE(changed_metrics() & 1735 EXPECT_TRUE(changed_metrics() &
1754 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); 1736 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
1755 EXPECT_TRUE(changed_metrics() & 1737 EXPECT_TRUE(changed_metrics() &
1756 display::DisplayObserver::DISPLAY_METRIC_PRIMARY); 1738 display::DisplayObserver::DISPLAY_METRIC_PRIMARY);
1757 } 1739 }
1758 1740
1759 TEST_F(DisplayManagerTest, NotifyPrimaryChangeUndock) { 1741 TEST_P(DisplayManagerTest, NotifyPrimaryChangeUndock) {
1760 if (!SupportsMultipleDisplays()) 1742 if (!SupportsMultipleDisplays())
1761 return; 1743 return;
1762 // Assume the default display is an external display, and 1744 // Assume the default display is an external display, and
1763 // emulates undocking by switching to another display. 1745 // emulates undocking by switching to another display.
1764 DisplayInfo another_display_info = 1746 DisplayInfo another_display_info =
1765 CreateDisplayInfo(1, gfx::Rect(0, 0, 1280, 800)); 1747 CreateDisplayInfo(1, gfx::Rect(0, 0, 1280, 800));
1766 std::vector<DisplayInfo> info_list; 1748 std::vector<DisplayInfo> info_list;
1767 info_list.push_back(another_display_info); 1749 info_list.push_back(another_display_info);
1768 reset(); 1750 reset();
1769 display_manager()->OnNativeDisplaysChanged(info_list); 1751 display_manager()->OnNativeDisplaysChanged(info_list);
1770 EXPECT_TRUE(changed_metrics() & 1752 EXPECT_TRUE(changed_metrics() &
1771 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); 1753 display::DisplayObserver::DISPLAY_METRIC_BOUNDS);
1772 EXPECT_TRUE(changed_metrics() & 1754 EXPECT_TRUE(changed_metrics() &
1773 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); 1755 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
1774 EXPECT_TRUE(changed_metrics() & 1756 EXPECT_TRUE(changed_metrics() &
1775 display::DisplayObserver::DISPLAY_METRIC_PRIMARY); 1757 display::DisplayObserver::DISPLAY_METRIC_PRIMARY);
1776 } 1758 }
1777 1759
1778 #if defined(OS_WIN)
1779 // TODO(scottmg): RootWindow doesn't get resized on Windows 1760 // TODO(scottmg): RootWindow doesn't get resized on Windows
1780 // Ash. http://crbug.com/247916. 1761 // Ash. http://crbug.com/247916.
1781 #define MAYBE_UpdateDisplayWithHostOrigin DISABLED_UpdateDisplayWithHostOrigin 1762 #if defined(OS_CHROMEOS)
1782 #else 1763 TEST_P(DisplayManagerTest, UpdateDisplayWithHostOrigin) {
1783 #define MAYBE_UpdateDisplayWithHostOrigin UpdateDisplayWithHostOrigin
1784 #endif
1785
1786 TEST_F(DisplayManagerTest, MAYBE_UpdateDisplayWithHostOrigin) {
1787 UpdateDisplay("100x200,300x400"); 1764 UpdateDisplay("100x200,300x400");
1788 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); 1765 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays());
1789 aura::Window::Windows root_windows = 1766 aura::Window::Windows root_windows =
1790 Shell::GetInstance()->GetAllRootWindows(); 1767 Shell::GetInstance()->GetAllRootWindows();
1791 ASSERT_EQ(2U, root_windows.size()); 1768 ASSERT_EQ(2U, root_windows.size());
1792 aura::WindowTreeHost* host0 = root_windows[0]->GetHost(); 1769 aura::WindowTreeHost* host0 = root_windows[0]->GetHost();
1793 aura::WindowTreeHost* host1 = root_windows[1]->GetHost(); 1770 aura::WindowTreeHost* host1 = root_windows[1]->GetHost();
1794 1771
1795 EXPECT_EQ("1,1", host0->GetBounds().origin().ToString()); 1772 EXPECT_EQ("1,1", host0->GetBounds().origin().ToString());
1796 EXPECT_EQ("100x200", host0->GetBounds().size().ToString()); 1773 EXPECT_EQ("100x200", host0->GetBounds().size().ToString());
(...skipping 15 matching lines...) Expand all
1812 EXPECT_EQ("0,0", host1->GetBounds().origin().ToString()); 1789 EXPECT_EQ("0,0", host1->GetBounds().origin().ToString());
1813 EXPECT_EQ("300x400", host1->GetBounds().size().ToString()); 1790 EXPECT_EQ("300x400", host1->GetBounds().size().ToString());
1814 1791
1815 UpdateDisplay("100+200-100x200,300+500-200x300"); 1792 UpdateDisplay("100+200-100x200,300+500-200x300");
1816 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); 1793 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays());
1817 EXPECT_EQ("100,200", host0->GetBounds().origin().ToString()); 1794 EXPECT_EQ("100,200", host0->GetBounds().origin().ToString());
1818 EXPECT_EQ("100x200", host0->GetBounds().size().ToString()); 1795 EXPECT_EQ("100x200", host0->GetBounds().size().ToString());
1819 EXPECT_EQ("300,500", host1->GetBounds().origin().ToString()); 1796 EXPECT_EQ("300,500", host1->GetBounds().origin().ToString());
1820 EXPECT_EQ("200x300", host1->GetBounds().size().ToString()); 1797 EXPECT_EQ("200x300", host1->GetBounds().size().ToString());
1821 } 1798 }
1799 #endif // defined(OS_CHROMEOS)
1822 1800
1823 TEST_F(DisplayManagerTest, UnifiedDesktopBasic) { 1801 TEST_P(DisplayManagerTest, UnifiedDesktopBasic) {
1824 if (!SupportsMultipleDisplays()) 1802 if (!SupportsMultipleDisplays())
1825 return; 1803 return;
1826 1804
1827 // Don't check root window destruction in unified mode. 1805 // Don't check root window destruction in unified mode.
1828 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 1806 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
1829 1807
1830 UpdateDisplay("400x500,300x200"); 1808 UpdateDisplay("400x500,300x200");
1831 1809
1832 // Enable after extended mode. 1810 // Enable after extended mode.
1833 display_manager()->SetUnifiedDesktopEnabled(true); 1811 display_manager()->SetUnifiedDesktopEnabled(true);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1872 // Switch back to extended desktop. 1850 // Switch back to extended desktop.
1873 display_manager()->SetUnifiedDesktopEnabled(false); 1851 display_manager()->SetUnifiedDesktopEnabled(false);
1874 EXPECT_EQ(gfx::Size(500, 300), screen->GetPrimaryDisplay().size()); 1852 EXPECT_EQ(gfx::Size(500, 300), screen->GetPrimaryDisplay().size());
1875 EXPECT_EQ(gfx::Size(400, 500), ScreenUtil::GetSecondaryDisplay().size()); 1853 EXPECT_EQ(gfx::Size(400, 500), ScreenUtil::GetSecondaryDisplay().size());
1876 EXPECT_EQ(gfx::Size(500, 300), 1854 EXPECT_EQ(gfx::Size(500, 300),
1877 display_manager() 1855 display_manager()
1878 ->GetDisplayForId(ScreenUtil::GetSecondaryDisplay().id() + 1) 1856 ->GetDisplayForId(ScreenUtil::GetSecondaryDisplay().id() + 1)
1879 .size()); 1857 .size());
1880 } 1858 }
1881 1859
1882 TEST_F(DisplayManagerTest, UnifiedDesktopWithHardwareMirroring) { 1860 TEST_P(DisplayManagerTest, UnifiedDesktopWithHardwareMirroring) {
1883 if (!SupportsMultipleDisplays()) 1861 if (!SupportsMultipleDisplays())
1884 return; 1862 return;
1885 // Don't check root window destruction in unified mode. 1863 // Don't check root window destruction in unified mode.
1886 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 1864 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
1887 1865
1888 // Enter to hardware mirroring. 1866 // Enter to hardware mirroring.
1889 DisplayInfo d1(1, "", false); 1867 DisplayInfo d1(1, "", false);
1890 d1.SetBounds(gfx::Rect(0, 0, 500, 500)); 1868 d1.SetBounds(gfx::Rect(0, 0, 500, 500));
1891 DisplayInfo d2(2, "", false); 1869 DisplayInfo d2(2, "", false);
1892 d2.SetBounds(gfx::Rect(0, 0, 500, 500)); 1870 d2.SetBounds(gfx::Rect(0, 0, 500, 500));
(...skipping 19 matching lines...) Expand all
1912 // Exit from hardware mirroring. 1890 // Exit from hardware mirroring.
1913 d2.SetBounds(gfx::Rect(0, 500, 500, 500)); 1891 d2.SetBounds(gfx::Rect(0, 500, 500, 500));
1914 display_info_list.clear(); 1892 display_info_list.clear();
1915 display_info_list.push_back(d1); 1893 display_info_list.push_back(d1);
1916 display_info_list.push_back(d2); 1894 display_info_list.push_back(d2);
1917 display_manager()->OnNativeDisplaysChanged(display_info_list); 1895 display_manager()->OnNativeDisplaysChanged(display_info_list);
1918 EXPECT_FALSE(display_manager()->IsInMirrorMode()); 1896 EXPECT_FALSE(display_manager()->IsInMirrorMode());
1919 EXPECT_TRUE(display_manager()->IsInUnifiedMode()); 1897 EXPECT_TRUE(display_manager()->IsInUnifiedMode());
1920 } 1898 }
1921 1899
1922 TEST_F(DisplayManagerTest, UnifiedDesktopEnabledWithExtended) { 1900 TEST_P(DisplayManagerTest, UnifiedDesktopEnabledWithExtended) {
1923 if (!SupportsMultipleDisplays()) 1901 if (!SupportsMultipleDisplays())
1924 return; 1902 return;
1925 // Don't check root window destruction in unified mode. 1903 // Don't check root window destruction in unified mode.
1926 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 1904 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
1927 1905
1928 UpdateDisplay("400x500,300x200"); 1906 UpdateDisplay("400x500,300x200");
1929 display::DisplayIdList list = display_manager()->GetCurrentDisplayIdList(); 1907 display::DisplayIdList list = display_manager()->GetCurrentDisplayIdList();
1930 display::DisplayLayoutBuilder builder( 1908 display::DisplayLayoutBuilder builder(
1931 display_manager()->layout_store()->GetRegisteredDisplayLayout(list)); 1909 display_manager()->layout_store()->GetRegisteredDisplayLayout(list));
1932 builder.SetDefaultUnified(false); 1910 builder.SetDefaultUnified(false);
1933 display_manager()->layout_store()->RegisterLayoutForDisplayIdList( 1911 display_manager()->layout_store()->RegisterLayoutForDisplayIdList(
1934 list, builder.Build()); 1912 list, builder.Build());
1935 display_manager()->SetUnifiedDesktopEnabled(true); 1913 display_manager()->SetUnifiedDesktopEnabled(true);
1936 EXPECT_FALSE(display_manager()->IsInUnifiedMode()); 1914 EXPECT_FALSE(display_manager()->IsInUnifiedMode());
1937 } 1915 }
1938 1916
1939 TEST_F(DisplayManagerTest, UnifiedDesktopWith2xDSF) { 1917 TEST_P(DisplayManagerTest, UnifiedDesktopWith2xDSF) {
1940 if (!SupportsMultipleDisplays()) 1918 if (!SupportsMultipleDisplays())
1941 return; 1919 return;
1942 // Don't check root window destruction in unified mode. 1920 // Don't check root window destruction in unified mode.
1943 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 1921 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
1944 1922
1945 display_manager()->SetUnifiedDesktopEnabled(true); 1923 display_manager()->SetUnifiedDesktopEnabled(true);
1946 display::Screen* screen = display::Screen::GetScreen(); 1924 display::Screen* screen = display::Screen::GetScreen();
1947 1925
1948 // 2nd display is 2x. 1926 // 2nd display is 2x.
1949 UpdateDisplay("400x500,1000x800*2"); 1927 UpdateDisplay("400x500,1000x800*2");
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
2033 EXPECT_EQ("1300x800", 2011 EXPECT_EQ("1300x800",
2034 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); 2012 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
2035 accelerators::ZoomInternalDisplay(false); 2013 accelerators::ZoomInternalDisplay(false);
2036 EXPECT_EQ("650x400", screen->GetPrimaryDisplay().size().ToString()); 2014 EXPECT_EQ("650x400", screen->GetPrimaryDisplay().size().ToString());
2037 EXPECT_EQ("650x400", 2015 EXPECT_EQ("650x400",
2038 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); 2016 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
2039 } 2017 }
2040 2018
2041 // Updating displays again in unified desktop mode should not crash. 2019 // Updating displays again in unified desktop mode should not crash.
2042 // crbug.com/491094. 2020 // crbug.com/491094.
2043 TEST_F(DisplayManagerTest, ConfigureUnifiedTwice) { 2021 TEST_P(DisplayManagerTest, ConfigureUnifiedTwice) {
2044 if (!SupportsMultipleDisplays()) 2022 if (!SupportsMultipleDisplays())
2045 return; 2023 return;
2046 // Don't check root window destruction in unified mode. 2024 // Don't check root window destruction in unified mode.
2047 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 2025 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
2048 2026
2049 UpdateDisplay("300x200,400x500"); 2027 UpdateDisplay("300x200,400x500");
2050 // Mirror windows are created in a posted task. 2028 // Mirror windows are created in a posted task.
2051 RunAllPendingInMessageLoop(); 2029 RunAllPendingInMessageLoop();
2052 2030
2053 UpdateDisplay("300x250,400x550"); 2031 UpdateDisplay("300x250,400x550");
2054 RunAllPendingInMessageLoop(); 2032 RunAllPendingInMessageLoop();
2055 } 2033 }
2056 2034
2057 TEST_F(DisplayManagerTest, NoRotateUnifiedDesktop) { 2035 TEST_P(DisplayManagerTest, NoRotateUnifiedDesktop) {
2058 if (!SupportsMultipleDisplays()) 2036 if (!SupportsMultipleDisplays())
2059 return; 2037 return;
2060 display_manager()->SetUnifiedDesktopEnabled(true); 2038 display_manager()->SetUnifiedDesktopEnabled(true);
2061 2039
2062 // Don't check root window destruction in unified mode. 2040 // Don't check root window destruction in unified mode.
2063 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 2041 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
2064 2042
2065 UpdateDisplay("400x500,300x200"); 2043 UpdateDisplay("400x500,300x200");
2066 2044
2067 display::Screen* screen = display::Screen::GetScreen(); 2045 display::Screen* screen = display::Screen::GetScreen();
2068 const display::Display& display = screen->GetPrimaryDisplay(); 2046 const display::Display& display = screen->GetPrimaryDisplay();
2069 EXPECT_EQ("1150x500", display.size().ToString()); 2047 EXPECT_EQ("1150x500", display.size().ToString());
2070 display_manager()->SetDisplayRotation( 2048 display_manager()->SetDisplayRotation(
2071 display.id(), display::Display::ROTATE_90, 2049 display.id(), display::Display::ROTATE_90,
2072 display::Display::ROTATION_SOURCE_ACTIVE); 2050 display::Display::ROTATION_SOURCE_ACTIVE);
2073 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString()); 2051 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString());
2074 display_manager()->SetDisplayRotation( 2052 display_manager()->SetDisplayRotation(
2075 display.id(), display::Display::ROTATE_0, 2053 display.id(), display::Display::ROTATE_0,
2076 display::Display::ROTATION_SOURCE_ACTIVE); 2054 display::Display::ROTATION_SOURCE_ACTIVE);
2077 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString()); 2055 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString());
2078 2056
2079 UpdateDisplay("400x500"); 2057 UpdateDisplay("400x500");
2080 EXPECT_EQ("400x500", screen->GetPrimaryDisplay().size().ToString()); 2058 EXPECT_EQ("400x500", screen->GetPrimaryDisplay().size().ToString());
2081 } 2059 }
2082 2060
2083 // Makes sure the transition from unified to single won't crash 2061 // Makes sure the transition from unified to single won't crash
2084 // with docked windows. 2062 // with docked windows.
2085 TEST_F(DisplayManagerTest, UnifiedWithDockWindows) { 2063 TEST_P(DisplayManagerTest, UnifiedWithDockWindows) {
2086 if (!SupportsMultipleDisplays()) 2064 if (!SupportsMultipleDisplays())
2087 return; 2065 return;
2066 const int height_offset = GetMdMaximizedWindowHeightOffset();
2088 display_manager()->SetUnifiedDesktopEnabled(true); 2067 display_manager()->SetUnifiedDesktopEnabled(true);
2089 2068
2090 // Don't check root window destruction in unified mode. 2069 // Don't check root window destruction in unified mode.
2091 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 2070 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
2092 2071
2093 UpdateDisplay("400x500,300x200"); 2072 UpdateDisplay("400x500,300x200");
2094 2073
2095 std::unique_ptr<aura::Window> docked( 2074 std::unique_ptr<aura::Window> docked(
2096 CreateTestWindowInShellWithBounds(gfx::Rect(10, 10, 50, 50))); 2075 CreateTestWindowInShellWithBounds(gfx::Rect(10, 10, 50, 50)));
2097 docked->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DOCKED); 2076 docked->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DOCKED);
2098 ASSERT_TRUE(wm::GetWindowState(docked.get())->IsDocked()); 2077 ASSERT_TRUE(wm::GetWindowState(docked.get())->IsDocked());
2099 // 47 pixels reserved for launcher shelf height. 2078 // 47 pixels reserved for launcher shelf height in non-material design, and
2100 EXPECT_EQ("0,0 250x453", docked->bounds().ToString()); 2079 // 48 pixels reserved in material design.
2080 EXPECT_EQ(gfx::Rect(0, 0, 250, 453 + height_offset).ToString(),
2081 docked->bounds().ToString());
2101 UpdateDisplay("300x300"); 2082 UpdateDisplay("300x300");
2102 // Make sure the window is still docked. 2083 // Make sure the window is still docked.
2103 EXPECT_TRUE(wm::GetWindowState(docked.get())->IsDocked()); 2084 EXPECT_TRUE(wm::GetWindowState(docked.get())->IsDocked());
2104 EXPECT_EQ("0,0 250x253", docked->bounds().ToString()); 2085 EXPECT_EQ(gfx::Rect(0, 0, 250, 253 + height_offset).ToString(),
2086 docked->bounds().ToString());
2105 } 2087 }
2106 2088
2107 TEST_F(DisplayManagerTest, DockMode) { 2089 TEST_P(DisplayManagerTest, DockMode) {
2108 if (!SupportsMultipleDisplays()) 2090 if (!SupportsMultipleDisplays())
2109 return; 2091 return;
2110 const int64_t internal_id = 1; 2092 const int64_t internal_id = 1;
2111 const int64_t external_id = 2; 2093 const int64_t external_id = 2;
2112 2094
2113 const DisplayInfo internal_display_info = 2095 const DisplayInfo internal_display_info =
2114 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500)); 2096 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500));
2115 const DisplayInfo external_display_info = 2097 const DisplayInfo external_display_info =
2116 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); 2098 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100));
2117 std::vector<DisplayInfo> display_info_list; 2099 std::vector<DisplayInfo> display_info_list;
(...skipping 21 matching lines...) Expand all
2139 EXPECT_FALSE(GetDisplayModeForNextUIScale(info, false, &mode)); 2121 EXPECT_FALSE(GetDisplayModeForNextUIScale(info, false, &mode));
2140 EXPECT_FALSE(SetDisplayUIScale(internal_id, 1.0f)); 2122 EXPECT_FALSE(SetDisplayUIScale(internal_id, 1.0f));
2141 2123
2142 DisplayInfo invalid_info; 2124 DisplayInfo invalid_info;
2143 EXPECT_FALSE(GetDisplayModeForNextUIScale(invalid_info, true, &mode)); 2125 EXPECT_FALSE(GetDisplayModeForNextUIScale(invalid_info, true, &mode));
2144 EXPECT_FALSE(GetDisplayModeForNextUIScale(invalid_info, false, &mode)); 2126 EXPECT_FALSE(GetDisplayModeForNextUIScale(invalid_info, false, &mode));
2145 EXPECT_FALSE(SetDisplayUIScale(display::Display::kInvalidDisplayID, 1.0f)); 2127 EXPECT_FALSE(SetDisplayUIScale(display::Display::kInvalidDisplayID, 1.0f));
2146 } 2128 }
2147 2129
2148 // Make sure that bad layout information is ignored and does not crash. 2130 // Make sure that bad layout information is ignored and does not crash.
2149 TEST_F(DisplayManagerTest, DontRegisterBadConfig) { 2131 TEST_P(DisplayManagerTest, DontRegisterBadConfig) {
2150 if (!SupportsMultipleDisplays()) 2132 if (!SupportsMultipleDisplays())
2151 return; 2133 return;
2152 display::DisplayIdList list = ash::test::CreateDisplayIdList2(1, 2); 2134 display::DisplayIdList list = ash::test::CreateDisplayIdList2(1, 2);
2153 display::DisplayLayoutBuilder builder(1); 2135 display::DisplayLayoutBuilder builder(1);
2154 builder.AddDisplayPlacement(2, 1, display::DisplayPlacement::LEFT, 0); 2136 builder.AddDisplayPlacement(2, 1, display::DisplayPlacement::LEFT, 0);
2155 builder.AddDisplayPlacement(3, 1, display::DisplayPlacement::BOTTOM, 0); 2137 builder.AddDisplayPlacement(3, 1, display::DisplayPlacement::BOTTOM, 0);
2156 2138
2157 display_manager()->layout_store()->RegisterLayoutForDisplayIdList( 2139 display_manager()->layout_store()->RegisterLayoutForDisplayIdList(
2158 list, builder.Build()); 2140 list, builder.Build());
2159 } 2141 }
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
2313 SetDisplayUIScale(display::Screen::GetScreen()->GetPrimaryDisplay().id(), 2295 SetDisplayUIScale(display::Screen::GetScreen()->GetPrimaryDisplay().id(),
2314 0.8f); 2296 0.8f);
2315 2297
2316 ASSERT_DOUBLE_EQ( 2298 ASSERT_DOUBLE_EQ(
2317 1.25f, 2299 1.25f,
2318 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 2300 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
2319 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); 2301 EXPECT_TRUE(IsTextSubpixelPositioningEnabled());
2320 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); 2302 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
2321 } 2303 }
2322 2304
2323 TEST_F(DisplayManagerTest, CheckInitializationOfRotationProperty) { 2305 TEST_P(DisplayManagerTest, CheckInitializationOfRotationProperty) {
2324 int64_t id = display_manager()->GetDisplayAt(0).id(); 2306 int64_t id = display_manager()->GetDisplayAt(0).id();
2325 display_manager()->RegisterDisplayProperty(id, display::Display::ROTATE_90, 2307 display_manager()->RegisterDisplayProperty(id, display::Display::ROTATE_90,
2326 1.0f, nullptr, gfx::Size(), 1.0f, 2308 1.0f, nullptr, gfx::Size(), 1.0f,
2327 ui::COLOR_PROFILE_STANDARD); 2309 ui::COLOR_PROFILE_STANDARD);
2328 2310
2329 const DisplayInfo& info = display_manager()->GetDisplayInfo(id); 2311 const DisplayInfo& info = display_manager()->GetDisplayInfo(id);
2330 2312
2331 EXPECT_EQ(display::Display::ROTATE_90, 2313 EXPECT_EQ(display::Display::ROTATE_90,
2332 info.GetRotation(display::Display::ROTATION_SOURCE_USER)); 2314 info.GetRotation(display::Display::ROTATION_SOURCE_USER));
2333 EXPECT_EQ(display::Display::ROTATE_90, 2315 EXPECT_EQ(display::Display::ROTATE_90,
2334 info.GetRotation(display::Display::ROTATION_SOURCE_ACTIVE)); 2316 info.GetRotation(display::Display::ROTATION_SOURCE_ACTIVE));
2335 } 2317 }
2336 2318
2337 TEST_F(DisplayManagerTest, RejectInvalidLayoutData) { 2319 TEST_P(DisplayManagerTest, RejectInvalidLayoutData) {
2338 DisplayLayoutStore* layout_store = display_manager()->layout_store(); 2320 DisplayLayoutStore* layout_store = display_manager()->layout_store();
2339 int64_t id1 = 10001; 2321 int64_t id1 = 10001;
2340 int64_t id2 = 10002; 2322 int64_t id2 = 10002;
2341 ASSERT_TRUE(CompareDisplayIds(id1, id2)); 2323 ASSERT_TRUE(CompareDisplayIds(id1, id2));
2342 display::DisplayLayoutBuilder good_builder(id1); 2324 display::DisplayLayoutBuilder good_builder(id1);
2343 good_builder.SetSecondaryPlacement(id2, display::DisplayPlacement::LEFT, 0); 2325 good_builder.SetSecondaryPlacement(id2, display::DisplayPlacement::LEFT, 0);
2344 std::unique_ptr<display::DisplayLayout> good(good_builder.Build()); 2326 std::unique_ptr<display::DisplayLayout> good(good_builder.Build());
2345 2327
2346 display::DisplayIdList good_list = test::CreateDisplayIdList2(id1, id2); 2328 display::DisplayIdList good_list = test::CreateDisplayIdList2(id1, id2);
2347 layout_store->RegisterLayoutForDisplayIdList(good_list, good->Copy()); 2329 layout_store->RegisterLayoutForDisplayIdList(good_list, good->Copy());
2348 2330
2349 display::DisplayLayoutBuilder bad(id1); 2331 display::DisplayLayoutBuilder bad(id1);
2350 bad.SetSecondaryPlacement(id2, display::DisplayPlacement::BOTTOM, 0); 2332 bad.SetSecondaryPlacement(id2, display::DisplayPlacement::BOTTOM, 0);
2351 2333
2352 display::DisplayIdList bad_list(2); 2334 display::DisplayIdList bad_list(2);
2353 bad_list[0] = id2; 2335 bad_list[0] = id2;
2354 bad_list[1] = id1; 2336 bad_list[1] = id1;
2355 layout_store->RegisterLayoutForDisplayIdList(bad_list, bad.Build()); 2337 layout_store->RegisterLayoutForDisplayIdList(bad_list, bad.Build());
2356 2338
2357 EXPECT_EQ(good->ToString(), 2339 EXPECT_EQ(good->ToString(),
2358 layout_store->GetRegisteredDisplayLayout(good_list).ToString()); 2340 layout_store->GetRegisteredDisplayLayout(good_list).ToString());
2359 } 2341 }
2360 2342
2361 TEST_F(DisplayManagerTest, GuessDisplayIdFieldsInDisplayLayout) { 2343 TEST_P(DisplayManagerTest, GuessDisplayIdFieldsInDisplayLayout) {
2362 int64_t id1 = 10001; 2344 int64_t id1 = 10001;
2363 int64_t id2 = 10002; 2345 int64_t id2 = 10002;
2364 2346
2365 std::unique_ptr<display::DisplayLayout> old_layout( 2347 std::unique_ptr<display::DisplayLayout> old_layout(
2366 new display::DisplayLayout); 2348 new display::DisplayLayout);
2367 old_layout->placement_list.emplace_back(display::DisplayPlacement::BOTTOM, 0); 2349 old_layout->placement_list.emplace_back(display::DisplayPlacement::BOTTOM, 0);
2368 old_layout->primary_id = id1; 2350 old_layout->primary_id = id1;
2369 2351
2370 DisplayLayoutStore* layout_store = display_manager()->layout_store(); 2352 DisplayLayoutStore* layout_store = display_manager()->layout_store();
2371 display::DisplayIdList list = test::CreateDisplayIdList2(id1, id2); 2353 display::DisplayIdList list = test::CreateDisplayIdList2(id1, id2);
2372 layout_store->RegisterLayoutForDisplayIdList(list, std::move(old_layout)); 2354 layout_store->RegisterLayoutForDisplayIdList(list, std::move(old_layout));
2373 const display::DisplayLayout& stored = 2355 const display::DisplayLayout& stored =
2374 layout_store->GetRegisteredDisplayLayout(list); 2356 layout_store->GetRegisteredDisplayLayout(list);
2375 2357
2376 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id); 2358 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id);
2377 EXPECT_EQ(id2, stored.placement_list[0].display_id); 2359 EXPECT_EQ(id2, stored.placement_list[0].display_id);
2378 } 2360 }
2379 2361
2380 #endif // OS_CHROMEOS 2362 #endif // OS_CHROMEOS
2381 2363
2382 } // namespace ash 2364 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698