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