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

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

Issue 2653593004: chromeos: Remove AshTestBase::SupportsMultipleDisplays (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/display/manager/display_manager.h" 5 #include "ui/display/manager/display_manager.h"
6 6
7 #include "ash/accelerators/accelerator_commands_aura.h" 7 #include "ash/accelerators/accelerator_commands_aura.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/material_design/material_design_controller.h"
10 #include "ash/common/wm/window_state.h" 10 #include "ash/common/wm/window_state.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 }; 143 };
144 144
145 INSTANTIATE_TEST_CASE_P( 145 INSTANTIATE_TEST_CASE_P(
146 /* prefix intentionally left blank due to only one parameterization */, 146 /* prefix intentionally left blank due to only one parameterization */,
147 DisplayManagerTest, 147 DisplayManagerTest,
148 testing::Values(MaterialDesignController::NON_MATERIAL, 148 testing::Values(MaterialDesignController::NON_MATERIAL,
149 MaterialDesignController::MATERIAL_NORMAL, 149 MaterialDesignController::MATERIAL_NORMAL,
150 MaterialDesignController::MATERIAL_EXPERIMENTAL)); 150 MaterialDesignController::MATERIAL_EXPERIMENTAL));
151 151
152 TEST_P(DisplayManagerTest, UpdateDisplayTest) { 152 TEST_P(DisplayManagerTest, UpdateDisplayTest) {
153 if (!SupportsMultipleDisplays())
154 return;
155
156 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 153 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
157 154
158 // Update primary and add seconary. 155 // Update primary and add seconary.
159 UpdateDisplay("100+0-500x500,0+501-400x400"); 156 UpdateDisplay("100+0-500x500,0+501-400x400");
160 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); 157 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
161 EXPECT_EQ("0,0 500x500", 158 EXPECT_EQ("0,0 500x500",
162 display_manager()->GetDisplayAt(0).bounds().ToString()); 159 display_manager()->GetDisplayAt(0).bounds().ToString());
163 160
164 EXPECT_EQ("2 1 0", GetCountSummary()); 161 EXPECT_EQ("2 1 0", GetCountSummary());
165 EXPECT_EQ(display_manager()->GetDisplayAt(1).id(), changed()[0].id()); 162 EXPECT_EQ(display_manager()->GetDisplayAt(1).id(), changed()[0].id());
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 UpdateDisplay("0+0-800x600,1000+1000-600x400"); 245 UpdateDisplay("0+0-800x600,1000+1000-600x400");
249 EXPECT_EQ("2 0 0", GetCountSummary()); 246 EXPECT_EQ("2 0 0", GetCountSummary());
250 reset(); 247 reset();
251 EXPECT_EQ("0,0 800x600", 248 EXPECT_EQ("0,0 800x600",
252 display_manager()->GetDisplayAt(0).bounds().ToString()); 249 display_manager()->GetDisplayAt(0).bounds().ToString());
253 EXPECT_EQ("800,0 600x400", 250 EXPECT_EQ("800,0 600x400",
254 display_manager()->GetDisplayAt(1).bounds().ToString()); 251 display_manager()->GetDisplayAt(1).bounds().ToString());
255 } 252 }
256 253
257 TEST_P(DisplayManagerTest, ScaleOnlyChange) { 254 TEST_P(DisplayManagerTest, ScaleOnlyChange) {
258 if (!SupportsMultipleDisplays())
259 return;
260 display_manager()->ToggleDisplayScaleFactor(); 255 display_manager()->ToggleDisplayScaleFactor();
261 EXPECT_TRUE(changed_metrics() & 256 EXPECT_TRUE(changed_metrics() &
262 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); 257 display::DisplayObserver::DISPLAY_METRIC_BOUNDS);
263 EXPECT_TRUE(changed_metrics() & 258 EXPECT_TRUE(changed_metrics() &
264 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); 259 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
265 } 260 }
266 261
267 // Test in emulation mode (use_fullscreen_host_window=false) 262 // Test in emulation mode (use_fullscreen_host_window=false)
268 TEST_P(DisplayManagerTest, EmulatorTest) { 263 TEST_P(DisplayManagerTest, EmulatorTest) {
269 if (!SupportsMultipleDisplays())
270 return;
271
272 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 264 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
273 265
274 display_manager()->AddRemoveDisplay(); 266 display_manager()->AddRemoveDisplay();
275 // Update primary and add seconary. 267 // Update primary and add seconary.
276 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); 268 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
277 EXPECT_EQ("1 1 0", GetCountSummary()); 269 EXPECT_EQ("1 1 0", GetCountSummary());
278 reset(); 270 reset();
279 271
280 display_manager()->AddRemoveDisplay(); 272 display_manager()->AddRemoveDisplay();
281 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 273 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
282 EXPECT_EQ("0 0 1", GetCountSummary()); 274 EXPECT_EQ("0 0 1", GetCountSummary());
283 reset(); 275 reset();
284 276
285 display_manager()->AddRemoveDisplay(); 277 display_manager()->AddRemoveDisplay();
286 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); 278 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
287 EXPECT_EQ("1 1 0", GetCountSummary()); 279 EXPECT_EQ("1 1 0", GetCountSummary());
288 } 280 }
289 281
290 // Tests support for 3 displays. 282 // Tests support for 3 displays.
291 TEST_P(DisplayManagerTest, UpdateThreeDisplaysWithDefaultLayout) { 283 TEST_P(DisplayManagerTest, UpdateThreeDisplaysWithDefaultLayout) {
292 if (!SupportsMultipleDisplays())
293 return;
294
295 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 284 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
296 285
297 // Test with three displays. Native origin will not affect ash 286 // Test with three displays. Native origin will not affect ash
298 // display layout. 287 // display layout.
299 UpdateDisplay("0+0-640x480,1000+0-320x200,2000+0-400x300"); 288 UpdateDisplay("0+0-640x480,1000+0-320x200,2000+0-400x300");
300 289
301 EXPECT_EQ(3U, display_manager()->GetNumDisplays()); 290 EXPECT_EQ(3U, display_manager()->GetNumDisplays());
302 EXPECT_EQ("0,0 640x480", 291 EXPECT_EQ("0,0 640x480",
303 display_manager()->GetDisplayAt(0).bounds().ToString()); 292 display_manager()->GetDisplayAt(0).bounds().ToString());
304 EXPECT_EQ("640,0 320x200", 293 EXPECT_EQ("640,0 320x200",
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 333
345 EXPECT_EQ("0,0 640x480", 334 EXPECT_EQ("0,0 640x480",
346 display_manager()->GetDisplayAt(0).bounds().ToString()); 335 display_manager()->GetDisplayAt(0).bounds().ToString());
347 EXPECT_EQ("10,480 320x200", 336 EXPECT_EQ("10,480 320x200",
348 display_manager()->GetDisplayAt(1).bounds().ToString()); 337 display_manager()->GetDisplayAt(1).bounds().ToString());
349 EXPECT_EQ("20,680 400x300", 338 EXPECT_EQ("20,680 400x300",
350 display_manager()->GetDisplayAt(2).bounds().ToString()); 339 display_manager()->GetDisplayAt(2).bounds().ToString());
351 } 340 }
352 341
353 TEST_P(DisplayManagerTest, LayoutMorethanThreeDisplaysTest) { 342 TEST_P(DisplayManagerTest, LayoutMorethanThreeDisplaysTest) {
354 if (!SupportsMultipleDisplays())
355 return;
356
357 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 343 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
358 display::DisplayIdList list = display::test::CreateDisplayIdListN( 344 display::DisplayIdList list = display::test::CreateDisplayIdListN(
359 3, primary_id, primary_id + 1, primary_id + 2); 345 3, primary_id, primary_id + 1, primary_id + 2);
360 { 346 {
361 // Layout: [2] 347 // Layout: [2]
362 // [1][P] 348 // [1][P]
363 display::DisplayLayoutBuilder builder(primary_id); 349 display::DisplayLayoutBuilder builder(primary_id);
364 builder.AddDisplayPlacement(list[1], primary_id, 350 builder.AddDisplayPlacement(list[1], primary_id,
365 display::DisplayPlacement::LEFT, 10); 351 display::DisplayPlacement::LEFT, 10);
366 builder.AddDisplayPlacement(list[2], list[1], 352 builder.AddDisplayPlacement(list[2], list[1],
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 // 3rd is the left of 4th. 445 // 3rd is the left of 4th.
460 EXPECT_EQ("-290,480 300x200", 446 EXPECT_EQ("-290,480 300x200",
461 display_manager()->GetDisplayAt(3).bounds().ToString()); 447 display_manager()->GetDisplayAt(3).bounds().ToString());
462 // 1st is the bottom of 3rd. 448 // 1st is the bottom of 3rd.
463 EXPECT_EQ("-280,680 320x200", 449 EXPECT_EQ("-280,680 320x200",
464 display_manager()->GetDisplayAt(1).bounds().ToString()); 450 display_manager()->GetDisplayAt(1).bounds().ToString());
465 } 451 }
466 } 452 }
467 453
468 TEST_P(DisplayManagerTest, NoMirrorInThreeDisplays) { 454 TEST_P(DisplayManagerTest, NoMirrorInThreeDisplays) {
469 if (!SupportsMultipleDisplays())
470 return;
471
472 UpdateDisplay("640x480,320x200,400x300"); 455 UpdateDisplay("640x480,320x200,400x300");
473 ash::Shell::GetInstance()->display_configuration_controller()->SetMirrorMode( 456 ash::Shell::GetInstance()->display_configuration_controller()->SetMirrorMode(
474 true, true); 457 true, true);
475 EXPECT_FALSE(display_manager()->IsInMirrorMode()); 458 EXPECT_FALSE(display_manager()->IsInMirrorMode());
476 EXPECT_EQ(3u, display_manager()->GetNumDisplays()); 459 EXPECT_EQ(3u, display_manager()->GetNumDisplays());
477 #if defined(OS_CHROMEOS)
478 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_MIRRORING_NOT_SUPPORTED), 460 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_MIRRORING_NOT_SUPPORTED),
479 GetDisplayErrorNotificationMessageForTest()); 461 GetDisplayErrorNotificationMessageForTest());
480 #endif
481 } 462 }
482 463
483 TEST_P(DisplayManagerTest, OverscanInsetsTest) { 464 TEST_P(DisplayManagerTest, OverscanInsetsTest) {
484 if (!SupportsMultipleDisplays())
485 return;
486
487 UpdateDisplay("0+0-500x500,0+501-400x400"); 465 UpdateDisplay("0+0-500x500,0+501-400x400");
488 reset(); 466 reset();
489 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); 467 ASSERT_EQ(2u, display_manager()->GetNumDisplays());
490 const display::ManagedDisplayInfo display_info1 = GetDisplayInfoAt(0); 468 const display::ManagedDisplayInfo display_info1 = GetDisplayInfoAt(0);
491 const display::ManagedDisplayInfo display_info2 = GetDisplayInfoAt(1); 469 const display::ManagedDisplayInfo display_info2 = GetDisplayInfoAt(1);
492 470
493 display_manager()->SetOverscanInsets(display_info2.id(), 471 display_manager()->SetOverscanInsets(display_info2.id(),
494 gfx::Insets(13, 12, 11, 10)); 472 gfx::Insets(13, 12, 11, 10));
495 473
496 std::vector<display::Display> changed_displays = changed(); 474 std::vector<display::Display> changed_displays = changed();
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 EXPECT_TRUE(changed_metrics() & 577 EXPECT_TRUE(changed_metrics() &
600 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); 578 display::DisplayObserver::DISPLAY_METRIC_BOUNDS);
601 EXPECT_TRUE(changed_metrics() & 579 EXPECT_TRUE(changed_metrics() &
602 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); 580 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
603 EXPECT_EQ( 581 EXPECT_EQ(
604 "0,0 500x500", 582 "0,0 500x500",
605 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString()); 583 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString());
606 } 584 }
607 585
608 TEST_P(DisplayManagerTest, ZeroOverscanInsets) { 586 TEST_P(DisplayManagerTest, ZeroOverscanInsets) {
609 if (!SupportsMultipleDisplays())
610 return;
611
612 // Make sure the display change events is emitted for overscan inset changes. 587 // Make sure the display change events is emitted for overscan inset changes.
613 UpdateDisplay("0+0-500x500,0+501-400x400"); 588 UpdateDisplay("0+0-500x500,0+501-400x400");
614 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); 589 ASSERT_EQ(2u, display_manager()->GetNumDisplays());
615 int64_t display2_id = display_manager()->GetDisplayAt(1).id(); 590 int64_t display2_id = display_manager()->GetDisplayAt(1).id();
616 591
617 reset(); 592 reset();
618 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0)); 593 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0));
619 EXPECT_EQ(0u, changed().size()); 594 EXPECT_EQ(0u, changed().size());
620 595
621 reset(); 596 reset();
622 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(1, 0, 0, 0)); 597 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(1, 0, 0, 0));
623 EXPECT_EQ(1u, changed().size()); 598 EXPECT_EQ(1u, changed().size());
624 EXPECT_EQ(display2_id, changed()[0].id()); 599 EXPECT_EQ(display2_id, changed()[0].id());
625 600
626 reset(); 601 reset();
627 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0)); 602 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0));
628 EXPECT_EQ(1u, changed().size()); 603 EXPECT_EQ(1u, changed().size());
629 EXPECT_EQ(display2_id, changed()[0].id()); 604 EXPECT_EQ(display2_id, changed()[0].id());
630 } 605 }
631 606
632 #if defined(OS_CHROMEOS)
633 TEST_P(DisplayManagerTest, TouchCalibrationTest) { 607 TEST_P(DisplayManagerTest, TouchCalibrationTest) {
634 if (!SupportsMultipleDisplays())
635 return;
636
637 UpdateDisplay("0+0-500x500,0+501-1024x600"); 608 UpdateDisplay("0+0-500x500,0+501-1024x600");
638 reset(); 609 reset();
639 610
640 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); 611 ASSERT_EQ(2u, display_manager()->GetNumDisplays());
641 const display::ManagedDisplayInfo display_info1 = GetDisplayInfoAt(0); 612 const display::ManagedDisplayInfo display_info1 = GetDisplayInfoAt(0);
642 const display::ManagedDisplayInfo display_info2 = GetDisplayInfoAt(1); 613 const display::ManagedDisplayInfo display_info2 = GetDisplayInfoAt(1);
643 614
644 EXPECT_FALSE(display_info2.has_touch_calibration_data()); 615 EXPECT_FALSE(display_info2.has_touch_calibration_data());
645 616
646 display::TouchCalibrationData::CalibrationPointPairQuad point_pair_quad = { 617 display::TouchCalibrationData::CalibrationPointPairQuad point_pair_quad = {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 UpdateDisplay("0+0-500x500"); 666 UpdateDisplay("0+0-500x500");
696 std::vector<display::ManagedDisplayInfo> display_info_list; 667 std::vector<display::ManagedDisplayInfo> display_info_list;
697 display_info_list.push_back(display_info1); 668 display_info_list.push_back(display_info1);
698 display_info_list.push_back(display_info2); 669 display_info_list.push_back(display_info2);
699 display_manager()->OnNativeDisplaysChanged(display_info_list); 670 display_manager()->OnNativeDisplaysChanged(display_info_list);
700 updated_display_info2 = GetDisplayInfoAt(1); 671 updated_display_info2 = GetDisplayInfoAt(1);
701 672
702 EXPECT_FALSE(updated_display_info2.has_touch_calibration_data()); 673 EXPECT_FALSE(updated_display_info2.has_touch_calibration_data());
703 EXPECT_EQ(touch_data, updated_display_info2.GetTouchCalibrationData()); 674 EXPECT_EQ(touch_data, updated_display_info2.GetTouchCalibrationData());
704 } 675 }
705 #endif // defined(OS_CHROMEOS)
706 676
707 #if !defined(OS_WIN)
708 // Disabled on windows because of http://crbug.com/650326.
709 TEST_P(DisplayManagerTest, TestDeviceScaleOnlyChange) { 677 TEST_P(DisplayManagerTest, TestDeviceScaleOnlyChange) {
710 UpdateDisplay("1000x600"); 678 UpdateDisplay("1000x600");
711 aura::WindowTreeHost* host = Shell::GetPrimaryRootWindow()->GetHost(); 679 aura::WindowTreeHost* host = Shell::GetPrimaryRootWindow()->GetHost();
712 EXPECT_EQ(1, host->compositor()->device_scale_factor()); 680 EXPECT_EQ(1, host->compositor()->device_scale_factor());
713 EXPECT_EQ("1000x600", 681 EXPECT_EQ("1000x600",
714 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); 682 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
715 EXPECT_EQ("1 0 0", GetCountSummary()); 683 EXPECT_EQ("1 0 0", GetCountSummary());
716 684
717 UpdateDisplay("1000x600*2"); 685 UpdateDisplay("1000x600*2");
718 EXPECT_EQ(2, host->compositor()->device_scale_factor()); 686 EXPECT_EQ(2, host->compositor()->device_scale_factor());
719 EXPECT_EQ("2 0 0", GetCountSummary()); 687 EXPECT_EQ("2 0 0", GetCountSummary());
720 EXPECT_EQ("500x300", 688 EXPECT_EQ("500x300",
721 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); 689 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
722 } 690 }
723 #endif
724 691
725 display::ManagedDisplayInfo CreateDisplayInfo(int64_t id, 692 display::ManagedDisplayInfo CreateDisplayInfo(int64_t id,
726 const gfx::Rect& bounds) { 693 const gfx::Rect& bounds) {
727 display::ManagedDisplayInfo info(id, ToDisplayName(id), false); 694 display::ManagedDisplayInfo info(id, ToDisplayName(id), false);
728 info.SetBounds(bounds); 695 info.SetBounds(bounds);
729 return info; 696 return info;
730 } 697 }
731 698
732 TEST_P(DisplayManagerTest, TestNativeDisplaysChanged) { 699 TEST_P(DisplayManagerTest, TestNativeDisplaysChanged) {
733 const int64_t internal_display_id = 700 const int64_t internal_display_id =
(...skipping 16 matching lines...) Expand all
750 717
751 std::vector<display::ManagedDisplayInfo> display_info_list; 718 std::vector<display::ManagedDisplayInfo> display_info_list;
752 // Primary disconnected. 719 // Primary disconnected.
753 display_manager()->OnNativeDisplaysChanged(display_info_list); 720 display_manager()->OnNativeDisplaysChanged(display_info_list);
754 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 721 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
755 EXPECT_EQ(default_bounds, 722 EXPECT_EQ(default_bounds,
756 display_manager()->GetDisplayAt(0).bounds().ToString()); 723 display_manager()->GetDisplayAt(0).bounds().ToString());
757 EXPECT_EQ(1U, display_manager()->num_connected_displays()); 724 EXPECT_EQ(1U, display_manager()->num_connected_displays());
758 EXPECT_FALSE(display_manager()->IsInMirrorMode()); 725 EXPECT_FALSE(display_manager()->IsInMirrorMode());
759 726
760 if (!SupportsMultipleDisplays())
761 return;
762
763 // External connected while primary was disconnected. 727 // External connected while primary was disconnected.
764 display_info_list.push_back(external_display_info); 728 display_info_list.push_back(external_display_info);
765 display_manager()->OnNativeDisplaysChanged(display_info_list); 729 display_manager()->OnNativeDisplaysChanged(display_info_list);
766 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 730 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
767 731
768 EXPECT_EQ(invalid_id, GetDisplayForId(internal_display_id).id()); 732 EXPECT_EQ(invalid_id, GetDisplayForId(internal_display_id).id());
769 EXPECT_EQ("1,1 100x100", 733 EXPECT_EQ("1,1 100x100",
770 GetDisplayInfoForId(external_id).bounds_in_native().ToString()); 734 GetDisplayInfoForId(external_id).bounds_in_native().ToString());
771 EXPECT_EQ(1U, display_manager()->num_connected_displays()); 735 EXPECT_EQ(1U, display_manager()->num_connected_displays());
772 EXPECT_FALSE(display_manager()->IsInMirrorMode()); 736 EXPECT_FALSE(display_manager()->IsInMirrorMode());
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 EXPECT_EQ( 855 EXPECT_EQ(
892 "0,0 500x500", 856 "0,0 500x500",
893 GetDisplayInfoForId(internal_display_id).bounds_in_native().ToString()); 857 GetDisplayInfoForId(internal_display_id).bounds_in_native().ToString());
894 EXPECT_EQ(1U, display_manager()->num_connected_displays()); 858 EXPECT_EQ(1U, display_manager()->num_connected_displays());
895 EXPECT_FALSE(display_manager()->IsInMirrorMode()); 859 EXPECT_FALSE(display_manager()->IsInMirrorMode());
896 } 860 }
897 861
898 // Make sure crash does not happen if add and remove happens at the same time. 862 // Make sure crash does not happen if add and remove happens at the same time.
899 // See: crbug.com/414394 863 // See: crbug.com/414394
900 TEST_P(DisplayManagerTest, DisplayAddRemoveAtTheSameTime) { 864 TEST_P(DisplayManagerTest, DisplayAddRemoveAtTheSameTime) {
901 if (!SupportsMultipleDisplays())
902 return;
903
904 UpdateDisplay("100+0-500x500,0+501-400x400"); 865 UpdateDisplay("100+0-500x500,0+501-400x400");
905 866
906 const int64_t primary_id = WindowTreeHostManager::GetPrimaryDisplayId(); 867 const int64_t primary_id = WindowTreeHostManager::GetPrimaryDisplayId();
907 const int64_t secondary_id = display_manager()->GetSecondaryDisplay().id(); 868 const int64_t secondary_id = display_manager()->GetSecondaryDisplay().id();
908 869
909 display::ManagedDisplayInfo primary_info = 870 display::ManagedDisplayInfo primary_info =
910 display_manager()->GetDisplayInfo(primary_id); 871 display_manager()->GetDisplayInfo(primary_id);
911 display::ManagedDisplayInfo secondary_info = 872 display::ManagedDisplayInfo secondary_info =
912 display_manager()->GetDisplayInfo(secondary_id); 873 display_manager()->GetDisplayInfo(secondary_id);
913 874
914 // An id which is different from primary and secondary. 875 // An id which is different from primary and secondary.
915 const int64_t third_id = secondary_id + 1; 876 const int64_t third_id = secondary_id + 1;
916 877
917 display::ManagedDisplayInfo third_info = 878 display::ManagedDisplayInfo third_info =
918 CreateDisplayInfo(third_id, gfx::Rect(0, 0, 600, 600)); 879 CreateDisplayInfo(third_id, gfx::Rect(0, 0, 600, 600));
919 880
920 std::vector<display::ManagedDisplayInfo> display_info_list; 881 std::vector<display::ManagedDisplayInfo> display_info_list;
921 display_info_list.push_back(third_info); 882 display_info_list.push_back(third_info);
922 display_info_list.push_back(secondary_info); 883 display_info_list.push_back(secondary_info);
923 display_manager()->OnNativeDisplaysChanged(display_info_list); 884 display_manager()->OnNativeDisplaysChanged(display_info_list);
924 885
925 // Secondary seconary_id becomes the primary as it has smaller output index. 886 // Secondary seconary_id becomes the primary as it has smaller output index.
926 EXPECT_EQ(secondary_id, WindowTreeHostManager::GetPrimaryDisplayId()); 887 EXPECT_EQ(secondary_id, WindowTreeHostManager::GetPrimaryDisplayId());
927 EXPECT_EQ(third_id, display_manager()->GetSecondaryDisplay().id()); 888 EXPECT_EQ(third_id, display_manager()->GetSecondaryDisplay().id());
928 EXPECT_EQ("600x600", GetDisplayForId(third_id).size().ToString()); 889 EXPECT_EQ("600x600", GetDisplayForId(third_id).size().ToString());
929 } 890 }
930 891
931 // TODO(scottmg): RootWindow doesn't get resized on Windows
932 // Ash. http://crbug.com/247916.
933 #if defined(OS_CHROMEOS)
934 TEST_P(DisplayManagerTest, TestNativeDisplaysChangedNoInternal) { 892 TEST_P(DisplayManagerTest, TestNativeDisplaysChangedNoInternal) {
935 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 893 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
936 894
937 // Don't change the display info if all displays are disconnected. 895 // Don't change the display info if all displays are disconnected.
938 std::vector<display::ManagedDisplayInfo> display_info_list; 896 std::vector<display::ManagedDisplayInfo> display_info_list;
939 display_manager()->OnNativeDisplaysChanged(display_info_list); 897 display_manager()->OnNativeDisplaysChanged(display_info_list);
940 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 898 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
941 899
942 // Connect another display which will become primary. 900 // Connect another display which will become primary.
943 const display::ManagedDisplayInfo external_display_info = 901 const display::ManagedDisplayInfo external_display_info =
944 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); 902 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100));
945 display_info_list.push_back(external_display_info); 903 display_info_list.push_back(external_display_info);
946 display_manager()->OnNativeDisplaysChanged(display_info_list); 904 display_manager()->OnNativeDisplaysChanged(display_info_list);
947 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 905 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
948 EXPECT_EQ("1,1 100x100", 906 EXPECT_EQ("1,1 100x100",
949 GetDisplayInfoForId(10).bounds_in_native().ToString()); 907 GetDisplayInfoForId(10).bounds_in_native().ToString());
950 EXPECT_EQ("100x100", ash::Shell::GetPrimaryRootWindow() 908 EXPECT_EQ("100x100", ash::Shell::GetPrimaryRootWindow()
951 ->GetHost() 909 ->GetHost()
952 ->GetBoundsInPixels() 910 ->GetBoundsInPixels()
953 .size() 911 .size()
954 .ToString()); 912 .ToString());
955 } 913 }
956 #endif // defined(OS_CHROMEOS)
957 914
958 TEST_P(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) { 915 TEST_P(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) {
959 if (!SupportsMultipleDisplays())
960 return;
961
962 const int64_t internal_display_id = 916 const int64_t internal_display_id =
963 display::test::DisplayManagerTestApi(display_manager()) 917 display::test::DisplayManagerTestApi(display_manager())
964 .SetFirstDisplayAsInternalDisplay(); 918 .SetFirstDisplayAsInternalDisplay();
965 const display::ManagedDisplayInfo native_display_info = 919 const display::ManagedDisplayInfo native_display_info =
966 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); 920 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500));
967 const display::ManagedDisplayInfo secondary_display_info = 921 const display::ManagedDisplayInfo secondary_display_info =
968 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); 922 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100));
969 923
970 std::vector<display::ManagedDisplayInfo> display_info_list; 924 std::vector<display::ManagedDisplayInfo> display_info_list;
971 display_info_list.push_back(native_display_info); 925 display_info_list.push_back(native_display_info);
(...skipping 11 matching lines...) Expand all
983 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString()); 937 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString());
984 938
985 // OnNativeDisplaysChanged may change the display bounds. Here makes sure 939 // OnNativeDisplaysChanged may change the display bounds. Here makes sure
986 // nothing changed if the exactly same displays are specified. 940 // nothing changed if the exactly same displays are specified.
987 display_manager()->OnNativeDisplaysChanged(display_info_list); 941 display_manager()->OnNativeDisplaysChanged(display_info_list);
988 EXPECT_EQ("-500,0 500x500", 942 EXPECT_EQ("-500,0 500x500",
989 GetDisplayForId(internal_display_id).bounds().ToString()); 943 GetDisplayForId(internal_display_id).bounds().ToString());
990 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString()); 944 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString());
991 } 945 }
992 946
993 // TODO(msw): Broken on Windows. http://crbug.com/584038
994 #if defined(OS_CHROMEOS)
995 TEST_P(DisplayManagerTest, DontRememberBestResolution) { 947 TEST_P(DisplayManagerTest, DontRememberBestResolution) {
996 int display_id = 1000; 948 int display_id = 1000;
997 display::ManagedDisplayInfo native_display_info = 949 display::ManagedDisplayInfo native_display_info =
998 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); 950 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500));
999 display::ManagedDisplayInfo::ManagedDisplayModeList display_modes; 951 display::ManagedDisplayInfo::ManagedDisplayModeList display_modes;
1000 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode( 952 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode(
1001 gfx::Size(1000, 500), 58.0f, false, true))); 953 gfx::Size(1000, 500), 58.0f, false, true)));
1002 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode( 954 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode(
1003 gfx::Size(800, 300), 59.0f, false, false))); 955 gfx::Size(800, 300), 59.0f, false, false)));
1004 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode( 956 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 EXPECT_EQ("1000x500", mode->size().ToString()); 1003 EXPECT_EQ("1000x500", mode->size().ToString());
1052 EXPECT_EQ(58.0f, mode->refresh_rate()); 1004 EXPECT_EQ(58.0f, mode->refresh_rate());
1053 EXPECT_TRUE(mode->native()); 1005 EXPECT_TRUE(mode->native());
1054 1006
1055 expected_mode = 1007 expected_mode =
1056 new display::ManagedDisplayMode(gfx::Size(1000, 500), 0.0f, false, false); 1008 new display::ManagedDisplayMode(gfx::Size(1000, 500), 0.0f, false, false);
1057 1009
1058 EXPECT_TRUE(expected_mode->IsEquivalent( 1010 EXPECT_TRUE(expected_mode->IsEquivalent(
1059 display_manager()->GetActiveModeForDisplayId(display_id))); 1011 display_manager()->GetActiveModeForDisplayId(display_id)));
1060 } 1012 }
1061 #endif // defined(OS_CHROMEOS)
1062 1013
1063 // TODO(msw): Broken on Windows. http://crbug.com/584038
1064 #if defined(OS_CHROMEOS)
1065 TEST_P(DisplayManagerTest, ResolutionFallback) { 1014 TEST_P(DisplayManagerTest, ResolutionFallback) {
1066 int display_id = 1000; 1015 int display_id = 1000;
1067 display::ManagedDisplayInfo native_display_info = 1016 display::ManagedDisplayInfo native_display_info =
1068 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); 1017 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500));
1069 display::ManagedDisplayInfo::ManagedDisplayModeList display_modes; 1018 display::ManagedDisplayInfo::ManagedDisplayModeList display_modes;
1070 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode( 1019 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode(
1071 gfx::Size(1000, 500), 58.0f, false, true))); 1020 gfx::Size(1000, 500), 58.0f, false, true)));
1072 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode( 1021 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode(
1073 gfx::Size(800, 300), 59.0f, false, false))); 1022 gfx::Size(800, 300), 59.0f, false, false)));
1074 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode( 1023 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 display_manager()->OnNativeDisplaysChanged(new_display_info_list); 1060 display_manager()->OnNativeDisplaysChanged(new_display_info_list);
1112 1061
1113 scoped_refptr<display::ManagedDisplayMode> mode = 1062 scoped_refptr<display::ManagedDisplayMode> mode =
1114 display_manager()->GetSelectedModeForDisplayId(display_id); 1063 display_manager()->GetSelectedModeForDisplayId(display_id);
1115 EXPECT_TRUE(!!mode); 1064 EXPECT_TRUE(!!mode);
1116 EXPECT_EQ("1000x500", mode->size().ToString()); 1065 EXPECT_EQ("1000x500", mode->size().ToString());
1117 EXPECT_EQ(58.0f, mode->refresh_rate()); 1066 EXPECT_EQ(58.0f, mode->refresh_rate());
1118 EXPECT_TRUE(mode->native()); 1067 EXPECT_TRUE(mode->native());
1119 } 1068 }
1120 } 1069 }
1121 #endif // defined(OS_CHROMEOS)
1122 1070
1123 TEST_P(DisplayManagerTest, Rotate) { 1071 TEST_P(DisplayManagerTest, Rotate) {
1124 if (!SupportsMultipleDisplays())
1125 return;
1126
1127 UpdateDisplay("100x200/r,300x400/l"); 1072 UpdateDisplay("100x200/r,300x400/l");
1128 EXPECT_EQ("1,1 100x200", GetDisplayInfoAt(0).bounds_in_native().ToString()); 1073 EXPECT_EQ("1,1 100x200", GetDisplayInfoAt(0).bounds_in_native().ToString());
1129 EXPECT_EQ("200x100", GetDisplayInfoAt(0).size_in_pixel().ToString()); 1074 EXPECT_EQ("200x100", GetDisplayInfoAt(0).size_in_pixel().ToString());
1130 1075
1131 EXPECT_EQ("1,201 300x400", GetDisplayInfoAt(1).bounds_in_native().ToString()); 1076 EXPECT_EQ("1,201 300x400", GetDisplayInfoAt(1).bounds_in_native().ToString());
1132 EXPECT_EQ("400x300", GetDisplayInfoAt(1).size_in_pixel().ToString()); 1077 EXPECT_EQ("400x300", GetDisplayInfoAt(1).size_in_pixel().ToString());
1133 reset(); 1078 reset();
1134 UpdateDisplay("100x200/b,300x400"); 1079 UpdateDisplay("100x200/b,300x400");
1135 EXPECT_EQ("2 0 0", GetCountSummary()); 1080 EXPECT_EQ("2 0 0", GetCountSummary());
1136 reset(); 1081 reset();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 internal_display_id, display::Display::ROTATE_180, 1146 internal_display_id, display::Display::ROTATE_180,
1202 display::Display::ROTATION_SOURCE_ACTIVE); 1147 display::Display::ROTATION_SOURCE_ACTIVE);
1203 const display::ManagedDisplayInfo& post_rotation_info = 1148 const display::ManagedDisplayInfo& post_rotation_info =
1204 display::test::DisplayManagerTestApi(display_manager()) 1149 display::test::DisplayManagerTestApi(display_manager())
1205 .GetInternalManagedDisplayInfo(internal_display_id); 1150 .GetInternalManagedDisplayInfo(internal_display_id);
1206 EXPECT_NE(info.GetActiveRotation(), post_rotation_info.GetActiveRotation()); 1151 EXPECT_NE(info.GetActiveRotation(), post_rotation_info.GetActiveRotation());
1207 EXPECT_EQ(display::Display::ROTATE_180, 1152 EXPECT_EQ(display::Display::ROTATE_180,
1208 post_rotation_info.GetActiveRotation()); 1153 post_rotation_info.GetActiveRotation());
1209 } 1154 }
1210 1155
1211 // TODO(msw): Broken on Windows. http://crbug.com/584038
1212 #if defined(OS_CHROMEOS)
1213 TEST_P(DisplayManagerTest, UIScale) { 1156 TEST_P(DisplayManagerTest, UIScale) {
1214 display::test::ScopedDisable125DSFForUIScaling disable; 1157 display::test::ScopedDisable125DSFForUIScaling disable;
1215 1158
1216 UpdateDisplay("1280x800"); 1159 UpdateDisplay("1280x800");
1217 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1160 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1218 display::test::DisplayManagerTestApi(display_manager()) 1161 display::test::DisplayManagerTestApi(display_manager())
1219 .SetDisplayUIScale(display_id, 1.125f); 1162 .SetDisplayUIScale(display_id, 1.125f);
1220 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale()); 1163 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale());
1221 display::test::DisplayManagerTestApi(display_manager()) 1164 display::test::DisplayManagerTestApi(display_manager())
1222 .SetDisplayUIScale(display_id, 0.8f); 1165 .SetDisplayUIScale(display_id, 0.8f);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 // on screen. 1271 // on screen.
1329 UpdateDisplay("1280x850*1.25"); 1272 UpdateDisplay("1280x850*1.25");
1330 display::test::DisplayManagerTestApi(display_manager()) 1273 display::test::DisplayManagerTestApi(display_manager())
1331 .SetDisplayUIScale(display_id, 1.25f); 1274 .SetDisplayUIScale(display_id, 1.25f);
1332 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).configured_ui_scale()); 1275 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).configured_ui_scale());
1333 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1276 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1334 display = display::Screen::GetScreen()->GetPrimaryDisplay(); 1277 display = display::Screen::GetScreen()->GetPrimaryDisplay();
1335 EXPECT_EQ(1.0f, display.device_scale_factor()); 1278 EXPECT_EQ(1.0f, display.device_scale_factor());
1336 EXPECT_EQ("1280x850", display.bounds().size().ToString()); 1279 EXPECT_EQ("1280x850", display.bounds().size().ToString());
1337 } 1280 }
1338 #endif // defined(OS_CHROMEOS)
1339 1281
1340 TEST_P(DisplayManagerTest, UIScaleWithDisplayMode) { 1282 TEST_P(DisplayManagerTest, UIScaleWithDisplayMode) {
1341 int display_id = 1000; 1283 int display_id = 1000;
1342 1284
1343 // Setup the display modes with UI-scale. 1285 // Setup the display modes with UI-scale.
1344 display::ManagedDisplayInfo native_display_info = 1286 display::ManagedDisplayInfo native_display_info =
1345 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1280, 800)); 1287 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1280, 800));
1346 const scoped_refptr<display::ManagedDisplayMode>& base_mode( 1288 const scoped_refptr<display::ManagedDisplayMode>& base_mode(
1347 new display::ManagedDisplayMode(gfx::Size(1280, 800), 60.0f, false, 1289 new display::ManagedDisplayMode(gfx::Size(1280, 800), 60.0f, false,
1348 false)); 1290 false));
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 1407
1466 // Reset the internal display zoom and expect the UI scale to go to the 1408 // Reset the internal display zoom and expect the UI scale to go to the
1467 // default 0.8f. 1409 // default 0.8f.
1468 display_manager()->ResetInternalDisplayZoom(); 1410 display_manager()->ResetInternalDisplayZoom();
1469 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1411 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1470 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1412 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1471 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale()); 1413 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale());
1472 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString()); 1414 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString());
1473 } 1415 }
1474 1416
1475 // TODO(msw): Broken on Windows. http://crbug.com/584038
1476 #if defined(OS_CHROMEOS)
1477 TEST_P(DisplayManagerTest, Use125DSFForUIScaling) { 1417 TEST_P(DisplayManagerTest, Use125DSFForUIScaling) {
1478 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1418 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1479 1419
1480 display::test::ScopedSetInternalDisplayId set_internal(display_manager(), 1420 display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
1481 display_id); 1421 display_id);
1482 UpdateDisplay("1920x1080*1.25"); 1422 UpdateDisplay("1920x1080*1.25");
1483 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1423 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1484 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1424 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1485 1425
1486 display::test::DisplayManagerTestApi(display_manager()) 1426 display::test::DisplayManagerTestApi(display_manager())
1487 .SetDisplayUIScale(display_id, 0.8f); 1427 .SetDisplayUIScale(display_id, 0.8f);
1488 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1428 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1489 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1429 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1490 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString()); 1430 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString());
1491 1431
1492 display::test::DisplayManagerTestApi(display_manager()) 1432 display::test::DisplayManagerTestApi(display_manager())
1493 .SetDisplayUIScale(display_id, 0.5f); 1433 .SetDisplayUIScale(display_id, 0.5f);
1494 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1434 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1495 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1435 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1496 EXPECT_EQ("960x540", GetDisplayForId(display_id).size().ToString()); 1436 EXPECT_EQ("960x540", GetDisplayForId(display_id).size().ToString());
1497 1437
1498 display::test::DisplayManagerTestApi(display_manager()) 1438 display::test::DisplayManagerTestApi(display_manager())
1499 .SetDisplayUIScale(display_id, 1.25f); 1439 .SetDisplayUIScale(display_id, 1.25f);
1500 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1440 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1501 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1441 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1502 EXPECT_EQ("2400x1350", GetDisplayForId(display_id).size().ToString()); 1442 EXPECT_EQ("2400x1350", GetDisplayForId(display_id).size().ToString());
1503 } 1443 }
1504 #endif // defined(OS_CHROMEOS)
1505 1444
1506 // TODO(msw): Broken on Windows. http://crbug.com/584038
1507 #if defined(OS_CHROMEOS)
1508 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScaling) { 1445 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScaling) {
1509 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1446 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1510 1447
1511 display_id++; 1448 display_id++;
1512 display::test::ScopedSetInternalDisplayId set_internal(display_manager(), 1449 display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
1513 display_id); 1450 display_id);
1514 1451
1515 // Setup the display modes with UI-scale. 1452 // Setup the display modes with UI-scale.
1516 display::ManagedDisplayInfo native_display_info = 1453 display::ManagedDisplayInfo native_display_info =
1517 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080)); 1454 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080));
1518 native_display_info.set_device_scale_factor(1.25); 1455 native_display_info.set_device_scale_factor(1.25);
1519 1456
1520 const scoped_refptr<display::ManagedDisplayMode>& base_mode( 1457 const scoped_refptr<display::ManagedDisplayMode>& base_mode(
1521 new display::ManagedDisplayMode(gfx::Size(1920, 1080), 60.0f, false, 1458 new display::ManagedDisplayMode(gfx::Size(1920, 1080), 60.0f, false,
1522 false)); 1459 false));
1523 display::ManagedDisplayInfo::ManagedDisplayModeList mode_list = 1460 display::ManagedDisplayInfo::ManagedDisplayModeList mode_list =
1524 CreateInternalManagedDisplayModeList(base_mode); 1461 CreateInternalManagedDisplayModeList(base_mode);
1525 native_display_info.SetManagedDisplayModes(mode_list); 1462 native_display_info.SetManagedDisplayModes(mode_list);
1526 1463
1527 std::vector<display::ManagedDisplayInfo> display_info_list; 1464 std::vector<display::ManagedDisplayInfo> display_info_list;
1528 display_info_list.push_back(native_display_info); 1465 display_info_list.push_back(native_display_info);
1529 1466
1530 display_manager()->OnNativeDisplaysChanged(display_info_list); 1467 display_manager()->OnNativeDisplaysChanged(display_info_list);
1531 1468
1532 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1469 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1533 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1470 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1534 } 1471 }
1535 #endif // defined(OS_CHROMEOS)
1536 1472
1537 // TODO(msw): Broken on Windows. http://crbug.com/584038
1538 #if defined(OS_CHROMEOS)
1539 // Don't default to 1.25 DSF if the user already has a prefrence stored for 1473 // Don't default to 1.25 DSF if the user already has a prefrence stored for
1540 // the internal display. 1474 // the internal display.
1541 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScalingNoOverride) { 1475 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScalingNoOverride) {
1542 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1476 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1543 1477
1544 display_id++; 1478 display_id++;
1545 display::test::ScopedSetInternalDisplayId set_internal(display_manager(), 1479 display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
1546 display_id); 1480 display_id);
1547 const gfx::Insets dummy_overscan_insets; 1481 const gfx::Insets dummy_overscan_insets;
1548 display_manager()->RegisterDisplayProperty( 1482 display_manager()->RegisterDisplayProperty(
(...skipping 13 matching lines...) Expand all
1562 native_display_info.SetManagedDisplayModes(mode_list); 1496 native_display_info.SetManagedDisplayModes(mode_list);
1563 1497
1564 std::vector<display::ManagedDisplayInfo> display_info_list; 1498 std::vector<display::ManagedDisplayInfo> display_info_list;
1565 display_info_list.push_back(native_display_info); 1499 display_info_list.push_back(native_display_info);
1566 1500
1567 display_manager()->OnNativeDisplaysChanged(display_info_list); 1501 display_manager()->OnNativeDisplaysChanged(display_info_list);
1568 1502
1569 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1503 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1570 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1504 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1571 } 1505 }
1572 #endif // defined(OS_CHROMEOS)
1573 1506
1574 TEST_P(DisplayManagerTest, ResolutionChangeInUnifiedMode) { 1507 TEST_P(DisplayManagerTest, ResolutionChangeInUnifiedMode) {
1575 if (!SupportsMultipleDisplays())
1576 return;
1577 // Don't check root window destruction in unified mode. 1508 // Don't check root window destruction in unified mode.
1578 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 1509 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
1579 1510
1580 display_manager()->SetUnifiedDesktopEnabled(true); 1511 display_manager()->SetUnifiedDesktopEnabled(true);
1581 1512
1582 UpdateDisplay("200x200, 400x400"); 1513 UpdateDisplay("200x200, 400x400");
1583 1514
1584 int64_t unified_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1515 int64_t unified_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1585 display::ManagedDisplayInfo info = 1516 display::ManagedDisplayInfo info =
1586 display_manager()->GetDisplayInfo(unified_id); 1517 display_manager()->GetDisplayInfo(unified_id);
(...skipping 24 matching lines...) Expand all
1611 UpdateDisplay("600x600, 200x200"); 1542 UpdateDisplay("600x600, 200x200");
1612 EXPECT_EQ( 1543 EXPECT_EQ(
1613 "1200x600", 1544 "1200x600",
1614 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); 1545 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString());
1615 active_mode = display_manager()->GetActiveModeForDisplayId(unified_id); 1546 active_mode = display_manager()->GetActiveModeForDisplayId(unified_id);
1616 EXPECT_EQ(1.0f, active_mode->ui_scale()); 1547 EXPECT_EQ(1.0f, active_mode->ui_scale());
1617 EXPECT_TRUE(active_mode->native()); 1548 EXPECT_TRUE(active_mode->native());
1618 EXPECT_EQ("1200x600", active_mode->size().ToString()); 1549 EXPECT_EQ("1200x600", active_mode->size().ToString());
1619 } 1550 }
1620 1551
1621 // TODO(scottmg): RootWindow doesn't get resized on Windows
1622 // Ash. http://crbug.com/247916.
1623 #if defined(OS_CHROMEOS)
1624 TEST_P(DisplayManagerTest, UpdateMouseCursorAfterRotateZoom) { 1552 TEST_P(DisplayManagerTest, UpdateMouseCursorAfterRotateZoom) {
1625 // Make sure just rotating will not change native location. 1553 // Make sure just rotating will not change native location.
1626 UpdateDisplay("300x200,200x150"); 1554 UpdateDisplay("300x200,200x150");
1627 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1555 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1628 aura::Env* env = aura::Env::GetInstance(); 1556 aura::Env* env = aura::Env::GetInstance();
1629 1557
1630 ui::test::EventGenerator generator1(root_windows[0]); 1558 ui::test::EventGenerator generator1(root_windows[0]);
1631 ui::test::EventGenerator generator2(root_windows[1]); 1559 ui::test::EventGenerator generator2(root_windows[1]);
1632 1560
1633 // Test on 1st display. 1561 // Test on 1st display.
(...skipping 27 matching lines...) Expand all
1661 generator2.MoveMouseToInHost(200, 250); 1589 generator2.MoveMouseToInHost(200, 250);
1662 EXPECT_EQ("700,125", env->last_mouse_location().ToString()); 1590 EXPECT_EQ("700,125", env->last_mouse_location().ToString());
1663 UpdateDisplay("600x400,400x300*2@1.5"); 1591 UpdateDisplay("600x400,400x300*2@1.5");
1664 EXPECT_EQ("750,187", env->last_mouse_location().ToString()); 1592 EXPECT_EQ("750,187", env->last_mouse_location().ToString());
1665 1593
1666 // The native location is now outside, so move to the 1594 // The native location is now outside, so move to the
1667 // center of closest display. 1595 // center of closest display.
1668 UpdateDisplay("600x400,400x200*2@1.5"); 1596 UpdateDisplay("600x400,400x200*2@1.5");
1669 EXPECT_EQ("750,75", env->last_mouse_location().ToString()); 1597 EXPECT_EQ("750,75", env->last_mouse_location().ToString());
1670 } 1598 }
1671 #endif // defined(OS_CHROMEOS)
1672 1599
1673 class TestDisplayObserver : public display::DisplayObserver { 1600 class TestDisplayObserver : public display::DisplayObserver {
1674 public: 1601 public:
1675 TestDisplayObserver() : changed_(false) {} 1602 TestDisplayObserver() : changed_(false) {}
1676 ~TestDisplayObserver() override {} 1603 ~TestDisplayObserver() override {}
1677 1604
1678 // display::DisplayObserver overrides: 1605 // display::DisplayObserver overrides:
1679 void OnDisplayMetricsChanged(const display::Display&, uint32_t) override {} 1606 void OnDisplayMetricsChanged(const display::Display&, uint32_t) override {}
1680 void OnDisplayAdded(const display::Display& new_display) override { 1607 void OnDisplayAdded(const display::Display& new_display) override {
1681 // Mirror window should already be delete before restoring 1608 // Mirror window should already be delete before restoring
(...skipping 15 matching lines...) Expand all
1697 } 1624 }
1698 1625
1699 private: 1626 private:
1700 test::MirrorWindowTestApi test_api; 1627 test::MirrorWindowTestApi test_api;
1701 bool changed_; 1628 bool changed_;
1702 1629
1703 DISALLOW_COPY_AND_ASSIGN(TestDisplayObserver); 1630 DISALLOW_COPY_AND_ASSIGN(TestDisplayObserver);
1704 }; 1631 };
1705 1632
1706 TEST_P(DisplayManagerTest, SoftwareMirroring) { 1633 TEST_P(DisplayManagerTest, SoftwareMirroring) {
1707 if (!SupportsMultipleDisplays())
1708 return;
1709
1710 UpdateDisplay("300x400,400x500"); 1634 UpdateDisplay("300x400,400x500");
1711 1635
1712 test::MirrorWindowTestApi test_api; 1636 test::MirrorWindowTestApi test_api;
1713 EXPECT_EQ(nullptr, test_api.GetHost()); 1637 EXPECT_EQ(nullptr, test_api.GetHost());
1714 1638
1715 TestDisplayObserver display_observer; 1639 TestDisplayObserver display_observer;
1716 display::Screen::GetScreen()->AddObserver(&display_observer); 1640 display::Screen::GetScreen()->AddObserver(&display_observer);
1717 1641
1718 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING); 1642 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING);
1719 display_manager()->UpdateDisplays(); 1643 display_manager()->UpdateDisplays();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1763 // Overscan insets are ignored. 1687 // Overscan insets are ignored.
1764 UpdateDisplay("400x600/o,600x800/o"); 1688 UpdateDisplay("400x600/o,600x800/o");
1765 EXPECT_FALSE(display_observer.changed_and_reset()); 1689 EXPECT_FALSE(display_observer.changed_and_reset());
1766 EXPECT_EQ("400x600", 1690 EXPECT_EQ("400x600",
1767 test_api.GetHost()->window()->bounds().size().ToString()); 1691 test_api.GetHost()->window()->bounds().size().ToString());
1768 1692
1769 display::Screen::GetScreen()->RemoveObserver(&display_observer); 1693 display::Screen::GetScreen()->RemoveObserver(&display_observer);
1770 } 1694 }
1771 1695
1772 TEST_P(DisplayManagerTest, RotateInSoftwareMirroring) { 1696 TEST_P(DisplayManagerTest, RotateInSoftwareMirroring) {
1773 if (!SupportsMultipleDisplays())
1774 return;
1775
1776 UpdateDisplay("600x400,500x300"); 1697 UpdateDisplay("600x400,500x300");
1777 display_manager()->SetMirrorMode(true); 1698 display_manager()->SetMirrorMode(true);
1778 1699
1779 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 1700 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
1780 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1701 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1781 display_manager()->SetDisplayRotation( 1702 display_manager()->SetDisplayRotation(
1782 primary_id, display::Display::ROTATE_180, 1703 primary_id, display::Display::ROTATE_180,
1783 display::Display::ROTATION_SOURCE_ACTIVE); 1704 display::Display::ROTATION_SOURCE_ACTIVE);
1784 display_manager()->SetMirrorMode(false); 1705 display_manager()->SetMirrorMode(false);
1785 } 1706 }
1786 1707
1787 TEST_P(DisplayManagerTest, SingleDisplayToSoftwareMirroring) { 1708 TEST_P(DisplayManagerTest, SingleDisplayToSoftwareMirroring) {
1788 if (!SupportsMultipleDisplays())
1789 return;
1790 UpdateDisplay("600x400"); 1709 UpdateDisplay("600x400");
1791 1710
1792 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING); 1711 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING);
1793 UpdateDisplay("600x400,600x400"); 1712 UpdateDisplay("600x400,600x400");
1794 1713
1795 EXPECT_TRUE(display_manager()->IsInMirrorMode()); 1714 EXPECT_TRUE(display_manager()->IsInMirrorMode());
1796 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 1715 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
1797 WindowTreeHostManager* window_tree_host_manager = 1716 WindowTreeHostManager* window_tree_host_manager =
1798 ash::Shell::GetInstance()->window_tree_host_manager(); 1717 ash::Shell::GetInstance()->window_tree_host_manager();
1799 EXPECT_TRUE( 1718 EXPECT_TRUE(
1800 window_tree_host_manager->mirror_window_controller()->GetWindow()); 1719 window_tree_host_manager->mirror_window_controller()->GetWindow());
1801 1720
1802 UpdateDisplay("600x400"); 1721 UpdateDisplay("600x400");
1803 EXPECT_FALSE(display_manager()->IsInMirrorMode()); 1722 EXPECT_FALSE(display_manager()->IsInMirrorMode());
1804 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 1723 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
1805 EXPECT_FALSE( 1724 EXPECT_FALSE(
1806 window_tree_host_manager->mirror_window_controller()->GetWindow()); 1725 window_tree_host_manager->mirror_window_controller()->GetWindow());
1807 } 1726 }
1808 1727
1809 #if defined(OS_CHROMEOS)
1810 // Make sure this does not cause any crashes. See http://crbug.com/412910 1728 // Make sure this does not cause any crashes. See http://crbug.com/412910
1811 // This test is limited to OS_CHROMEOS because CursorCompositingEnabled is only
1812 // for ChromeOS.
1813 TEST_P(DisplayManagerTest, SoftwareMirroringWithCompositingCursor) { 1729 TEST_P(DisplayManagerTest, SoftwareMirroringWithCompositingCursor) {
1814 if (!SupportsMultipleDisplays())
1815 return;
1816
1817 UpdateDisplay("300x400,400x500"); 1730 UpdateDisplay("300x400,400x500");
1818 1731
1819 test::MirrorWindowTestApi test_api; 1732 test::MirrorWindowTestApi test_api;
1820 EXPECT_EQ(nullptr, test_api.GetHost()); 1733 EXPECT_EQ(nullptr, test_api.GetHost());
1821 1734
1822 display::ManagedDisplayInfo secondary_info = 1735 display::ManagedDisplayInfo secondary_info =
1823 display_manager()->GetDisplayInfo( 1736 display_manager()->GetDisplayInfo(
1824 display_manager()->GetSecondaryDisplay().id()); 1737 display_manager()->GetSecondaryDisplay().id());
1825 1738
1826 display_manager()->SetSoftwareMirroring(true); 1739 display_manager()->SetSoftwareMirroring(true);
(...skipping 10 matching lines...) Expand all
1837 display_manager()->SetSoftwareMirroring(false); 1750 display_manager()->SetSoftwareMirroring(false);
1838 std::vector<display::ManagedDisplayInfo> new_info_list; 1751 std::vector<display::ManagedDisplayInfo> new_info_list;
1839 new_info_list.push_back(secondary_info); 1752 new_info_list.push_back(secondary_info);
1840 display_manager()->OnNativeDisplaysChanged(new_info_list); 1753 display_manager()->OnNativeDisplaysChanged(new_info_list);
1841 1754
1842 root_windows = Shell::GetAllRootWindows(); 1755 root_windows = Shell::GetAllRootWindows();
1843 EXPECT_TRUE(root_windows[0]->Contains(test_api.GetCursorWindow())); 1756 EXPECT_TRUE(root_windows[0]->Contains(test_api.GetCursorWindow()));
1844 1757
1845 Shell::GetInstance()->SetCursorCompositingEnabled(false); 1758 Shell::GetInstance()->SetCursorCompositingEnabled(false);
1846 } 1759 }
1847 #endif // OS_CHROMEOS
1848 1760
1849 TEST_P(DisplayManagerTest, MirroredLayout) { 1761 TEST_P(DisplayManagerTest, MirroredLayout) {
1850 if (!SupportsMultipleDisplays())
1851 return;
1852
1853 UpdateDisplay("500x500,400x400"); 1762 UpdateDisplay("500x500,400x400");
1854 EXPECT_FALSE(display_manager()->GetCurrentDisplayLayout().mirrored); 1763 EXPECT_FALSE(display_manager()->GetCurrentDisplayLayout().mirrored);
1855 EXPECT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); 1764 EXPECT_EQ(2, display::Screen::GetScreen()->GetNumDisplays());
1856 EXPECT_EQ(2U, display_manager()->num_connected_displays()); 1765 EXPECT_EQ(2U, display_manager()->num_connected_displays());
1857 1766
1858 UpdateDisplay("1+0-500x500,1+0-500x500"); 1767 UpdateDisplay("1+0-500x500,1+0-500x500");
1859 EXPECT_TRUE(display_manager()->GetCurrentDisplayLayout().mirrored); 1768 EXPECT_TRUE(display_manager()->GetCurrentDisplayLayout().mirrored);
1860 EXPECT_EQ(1, display::Screen::GetScreen()->GetNumDisplays()); 1769 EXPECT_EQ(1, display::Screen::GetScreen()->GetNumDisplays());
1861 EXPECT_EQ(2U, display_manager()->num_connected_displays()); 1770 EXPECT_EQ(2U, display_manager()->num_connected_displays());
1862 1771
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1914 display::DisplayPlacement(display::DisplayPlacement::BOTTOM, 70) 1823 display::DisplayPlacement(display::DisplayPlacement::BOTTOM, 70)
1915 .Swap() 1824 .Swap()
1916 .ToString()); 1825 .ToString());
1917 EXPECT_EQ("top, 80", 1826 EXPECT_EQ("top, 80",
1918 display::DisplayPlacement(display::DisplayPlacement::BOTTOM, -80) 1827 display::DisplayPlacement(display::DisplayPlacement::BOTTOM, -80)
1919 .Swap() 1828 .Swap()
1920 .ToString()); 1829 .ToString());
1921 } 1830 }
1922 1831
1923 TEST_P(DisplayManagerTest, NotifyPrimaryChange) { 1832 TEST_P(DisplayManagerTest, NotifyPrimaryChange) {
1924 if (!SupportsMultipleDisplays())
1925 return;
1926 UpdateDisplay("500x500,500x500"); 1833 UpdateDisplay("500x500,500x500");
1927 SwapPrimaryDisplay(); 1834 SwapPrimaryDisplay();
1928 reset(); 1835 reset();
1929 UpdateDisplay("500x500"); 1836 UpdateDisplay("500x500");
1930 EXPECT_FALSE(changed_metrics() & 1837 EXPECT_FALSE(changed_metrics() &
1931 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); 1838 display::DisplayObserver::DISPLAY_METRIC_BOUNDS);
1932 EXPECT_FALSE(changed_metrics() & 1839 EXPECT_FALSE(changed_metrics() &
1933 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); 1840 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
1934 EXPECT_TRUE(changed_metrics() & 1841 EXPECT_TRUE(changed_metrics() &
1935 display::DisplayObserver::DISPLAY_METRIC_PRIMARY); 1842 display::DisplayObserver::DISPLAY_METRIC_PRIMARY);
1936 1843
1937 UpdateDisplay("500x500,500x500"); 1844 UpdateDisplay("500x500,500x500");
1938 SwapPrimaryDisplay(); 1845 SwapPrimaryDisplay();
1939 UpdateDisplay("500x400"); 1846 UpdateDisplay("500x400");
1940 EXPECT_TRUE(changed_metrics() & 1847 EXPECT_TRUE(changed_metrics() &
1941 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); 1848 display::DisplayObserver::DISPLAY_METRIC_BOUNDS);
1942 EXPECT_TRUE(changed_metrics() & 1849 EXPECT_TRUE(changed_metrics() &
1943 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); 1850 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
1944 EXPECT_TRUE(changed_metrics() & 1851 EXPECT_TRUE(changed_metrics() &
1945 display::DisplayObserver::DISPLAY_METRIC_PRIMARY); 1852 display::DisplayObserver::DISPLAY_METRIC_PRIMARY);
1946 } 1853 }
1947 1854
1948 TEST_P(DisplayManagerTest, NotifyPrimaryChangeUndock) { 1855 TEST_P(DisplayManagerTest, NotifyPrimaryChangeUndock) {
1949 if (!SupportsMultipleDisplays())
1950 return;
1951 // Assume the default display is an external display, and 1856 // Assume the default display is an external display, and
1952 // emulates undocking by switching to another display. 1857 // emulates undocking by switching to another display.
1953 display::ManagedDisplayInfo another_display_info = 1858 display::ManagedDisplayInfo another_display_info =
1954 CreateDisplayInfo(1, gfx::Rect(0, 0, 1280, 800)); 1859 CreateDisplayInfo(1, gfx::Rect(0, 0, 1280, 800));
1955 std::vector<display::ManagedDisplayInfo> info_list; 1860 std::vector<display::ManagedDisplayInfo> info_list;
1956 info_list.push_back(another_display_info); 1861 info_list.push_back(another_display_info);
1957 reset(); 1862 reset();
1958 display_manager()->OnNativeDisplaysChanged(info_list); 1863 display_manager()->OnNativeDisplaysChanged(info_list);
1959 EXPECT_TRUE(changed_metrics() & 1864 EXPECT_TRUE(changed_metrics() &
1960 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); 1865 display::DisplayObserver::DISPLAY_METRIC_BOUNDS);
1961 EXPECT_TRUE(changed_metrics() & 1866 EXPECT_TRUE(changed_metrics() &
1962 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); 1867 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
1963 EXPECT_TRUE(changed_metrics() & 1868 EXPECT_TRUE(changed_metrics() &
1964 display::DisplayObserver::DISPLAY_METRIC_PRIMARY); 1869 display::DisplayObserver::DISPLAY_METRIC_PRIMARY);
1965 } 1870 }
1966 1871
1967 // TODO(scottmg): RootWindow doesn't get resized on Windows
1968 // Ash. http://crbug.com/247916.
1969 #if defined(OS_CHROMEOS)
1970 TEST_P(DisplayManagerTest, UpdateDisplayWithHostOrigin) { 1872 TEST_P(DisplayManagerTest, UpdateDisplayWithHostOrigin) {
1971 UpdateDisplay("100x200,300x400"); 1873 UpdateDisplay("100x200,300x400");
1972 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); 1874 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays());
1973 aura::Window::Windows root_windows = 1875 aura::Window::Windows root_windows =
1974 Shell::GetInstance()->GetAllRootWindows(); 1876 Shell::GetInstance()->GetAllRootWindows();
1975 ASSERT_EQ(2U, root_windows.size()); 1877 ASSERT_EQ(2U, root_windows.size());
1976 aura::WindowTreeHost* host0 = root_windows[0]->GetHost(); 1878 aura::WindowTreeHost* host0 = root_windows[0]->GetHost();
1977 aura::WindowTreeHost* host1 = root_windows[1]->GetHost(); 1879 aura::WindowTreeHost* host1 = root_windows[1]->GetHost();
1978 1880
1979 EXPECT_EQ("1,1", host0->GetBoundsInPixels().origin().ToString()); 1881 EXPECT_EQ("1,1", host0->GetBoundsInPixels().origin().ToString());
(...skipping 16 matching lines...) Expand all
1996 EXPECT_EQ("0,0", host1->GetBoundsInPixels().origin().ToString()); 1898 EXPECT_EQ("0,0", host1->GetBoundsInPixels().origin().ToString());
1997 EXPECT_EQ("300x400", host1->GetBoundsInPixels().size().ToString()); 1899 EXPECT_EQ("300x400", host1->GetBoundsInPixels().size().ToString());
1998 1900
1999 UpdateDisplay("100+200-100x200,300+500-200x300"); 1901 UpdateDisplay("100+200-100x200,300+500-200x300");
2000 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); 1902 ASSERT_EQ(2, display::Screen::GetScreen()->GetNumDisplays());
2001 EXPECT_EQ("100,200", host0->GetBoundsInPixels().origin().ToString()); 1903 EXPECT_EQ("100,200", host0->GetBoundsInPixels().origin().ToString());
2002 EXPECT_EQ("100x200", host0->GetBoundsInPixels().size().ToString()); 1904 EXPECT_EQ("100x200", host0->GetBoundsInPixels().size().ToString());
2003 EXPECT_EQ("300,500", host1->GetBoundsInPixels().origin().ToString()); 1905 EXPECT_EQ("300,500", host1->GetBoundsInPixels().origin().ToString());
2004 EXPECT_EQ("200x300", host1->GetBoundsInPixels().size().ToString()); 1906 EXPECT_EQ("200x300", host1->GetBoundsInPixels().size().ToString());
2005 } 1907 }
2006 #endif // defined(OS_CHROMEOS)
2007 1908
2008 TEST_P(DisplayManagerTest, UnifiedDesktopBasic) { 1909 TEST_P(DisplayManagerTest, UnifiedDesktopBasic) {
2009 if (!SupportsMultipleDisplays())
2010 return;
2011
2012 // Don't check root window destruction in unified mode. 1910 // Don't check root window destruction in unified mode.
2013 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 1911 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
2014 1912
2015 UpdateDisplay("400x500,300x200"); 1913 UpdateDisplay("400x500,300x200");
2016 1914
2017 // Enable after extended mode. 1915 // Enable after extended mode.
2018 display_manager()->SetUnifiedDesktopEnabled(true); 1916 display_manager()->SetUnifiedDesktopEnabled(true);
2019 1917
2020 // Defaults to the unified desktop. 1918 // Defaults to the unified desktop.
2021 display::Screen* screen = display::Screen::GetScreen(); 1919 display::Screen* screen = display::Screen::GetScreen();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2061 EXPECT_EQ(gfx::Size(400, 500), 1959 EXPECT_EQ(gfx::Size(400, 500),
2062 display_manager()->GetSecondaryDisplay().size()); 1960 display_manager()->GetSecondaryDisplay().size());
2063 EXPECT_EQ( 1961 EXPECT_EQ(
2064 gfx::Size(500, 300), 1962 gfx::Size(500, 300),
2065 display_manager() 1963 display_manager()
2066 ->GetDisplayForId(display_manager()->GetSecondaryDisplay().id() + 1) 1964 ->GetDisplayForId(display_manager()->GetSecondaryDisplay().id() + 1)
2067 .size()); 1965 .size());
2068 } 1966 }
2069 1967
2070 TEST_P(DisplayManagerTest, UnifiedDesktopWithHardwareMirroring) { 1968 TEST_P(DisplayManagerTest, UnifiedDesktopWithHardwareMirroring) {
2071 if (!SupportsMultipleDisplays())
2072 return;
2073 // Don't check root window destruction in unified mode. 1969 // Don't check root window destruction in unified mode.
2074 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 1970 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
2075 1971
2076 // Enter to hardware mirroring. 1972 // Enter to hardware mirroring.
2077 display::ManagedDisplayInfo d1(1, "", false); 1973 display::ManagedDisplayInfo d1(1, "", false);
2078 d1.SetBounds(gfx::Rect(0, 0, 500, 500)); 1974 d1.SetBounds(gfx::Rect(0, 0, 500, 500));
2079 display::ManagedDisplayInfo d2(2, "", false); 1975 display::ManagedDisplayInfo d2(2, "", false);
2080 d2.SetBounds(gfx::Rect(0, 0, 500, 500)); 1976 d2.SetBounds(gfx::Rect(0, 0, 500, 500));
2081 std::vector<display::ManagedDisplayInfo> display_info_list; 1977 std::vector<display::ManagedDisplayInfo> display_info_list;
2082 display_info_list.push_back(d1); 1978 display_info_list.push_back(d1);
(...skipping 18 matching lines...) Expand all
2101 d2.SetBounds(gfx::Rect(0, 500, 500, 500)); 1997 d2.SetBounds(gfx::Rect(0, 500, 500, 500));
2102 display_info_list.clear(); 1998 display_info_list.clear();
2103 display_info_list.push_back(d1); 1999 display_info_list.push_back(d1);
2104 display_info_list.push_back(d2); 2000 display_info_list.push_back(d2);
2105 display_manager()->OnNativeDisplaysChanged(display_info_list); 2001 display_manager()->OnNativeDisplaysChanged(display_info_list);
2106 EXPECT_FALSE(display_manager()->IsInMirrorMode()); 2002 EXPECT_FALSE(display_manager()->IsInMirrorMode());
2107 EXPECT_TRUE(display_manager()->IsInUnifiedMode()); 2003 EXPECT_TRUE(display_manager()->IsInUnifiedMode());
2108 } 2004 }
2109 2005
2110 TEST_P(DisplayManagerTest, UnifiedDesktopEnabledWithExtended) { 2006 TEST_P(DisplayManagerTest, UnifiedDesktopEnabledWithExtended) {
2111 if (!SupportsMultipleDisplays())
2112 return;
2113 // Don't check root window destruction in unified mode. 2007 // Don't check root window destruction in unified mode.
2114 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 2008 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
2115 2009
2116 UpdateDisplay("400x500,300x200"); 2010 UpdateDisplay("400x500,300x200");
2117 display::DisplayIdList list = display_manager()->GetCurrentDisplayIdList(); 2011 display::DisplayIdList list = display_manager()->GetCurrentDisplayIdList();
2118 display::DisplayLayoutBuilder builder( 2012 display::DisplayLayoutBuilder builder(
2119 display_manager()->layout_store()->GetRegisteredDisplayLayout(list)); 2013 display_manager()->layout_store()->GetRegisteredDisplayLayout(list));
2120 builder.SetDefaultUnified(false); 2014 builder.SetDefaultUnified(false);
2121 display_manager()->layout_store()->RegisterLayoutForDisplayIdList( 2015 display_manager()->layout_store()->RegisterLayoutForDisplayIdList(
2122 list, builder.Build()); 2016 list, builder.Build());
2123 display_manager()->SetUnifiedDesktopEnabled(true); 2017 display_manager()->SetUnifiedDesktopEnabled(true);
2124 EXPECT_FALSE(display_manager()->IsInUnifiedMode()); 2018 EXPECT_FALSE(display_manager()->IsInUnifiedMode());
2125 } 2019 }
2126 2020
2127 TEST_P(DisplayManagerTest, UnifiedDesktopWith2xDSF) { 2021 TEST_P(DisplayManagerTest, UnifiedDesktopWith2xDSF) {
2128 if (!SupportsMultipleDisplays())
2129 return;
2130 // Don't check root window destruction in unified mode. 2022 // Don't check root window destruction in unified mode.
2131 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 2023 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
2132 2024
2133 display_manager()->SetUnifiedDesktopEnabled(true); 2025 display_manager()->SetUnifiedDesktopEnabled(true);
2134 display::Screen* screen = display::Screen::GetScreen(); 2026 display::Screen* screen = display::Screen::GetScreen();
2135 2027
2136 // 2nd display is 2x. 2028 // 2nd display is 2x.
2137 UpdateDisplay("400x500,1000x800*2"); 2029 UpdateDisplay("400x500,1000x800*2");
2138 display::ManagedDisplayInfo info = 2030 display::ManagedDisplayInfo info =
2139 display_manager()->GetDisplayInfo(screen->GetPrimaryDisplay().id()); 2031 display_manager()->GetDisplayInfo(screen->GetPrimaryDisplay().id());
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2222 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); 2114 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
2223 accelerators::ZoomInternalDisplay(false); 2115 accelerators::ZoomInternalDisplay(false);
2224 EXPECT_EQ("650x400", screen->GetPrimaryDisplay().size().ToString()); 2116 EXPECT_EQ("650x400", screen->GetPrimaryDisplay().size().ToString());
2225 EXPECT_EQ("650x400", 2117 EXPECT_EQ("650x400",
2226 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); 2118 Shell::GetPrimaryRootWindow()->bounds().size().ToString());
2227 } 2119 }
2228 2120
2229 // Updating displays again in unified desktop mode should not crash. 2121 // Updating displays again in unified desktop mode should not crash.
2230 // crbug.com/491094. 2122 // crbug.com/491094.
2231 TEST_P(DisplayManagerTest, ConfigureUnifiedTwice) { 2123 TEST_P(DisplayManagerTest, ConfigureUnifiedTwice) {
2232 if (!SupportsMultipleDisplays())
2233 return;
2234 // Don't check root window destruction in unified mode. 2124 // Don't check root window destruction in unified mode.
2235 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 2125 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
2236 2126
2237 UpdateDisplay("300x200,400x500"); 2127 UpdateDisplay("300x200,400x500");
2238 // Mirror windows are created in a posted task. 2128 // Mirror windows are created in a posted task.
2239 RunAllPendingInMessageLoop(); 2129 RunAllPendingInMessageLoop();
2240 2130
2241 UpdateDisplay("300x250,400x550"); 2131 UpdateDisplay("300x250,400x550");
2242 RunAllPendingInMessageLoop(); 2132 RunAllPendingInMessageLoop();
2243 } 2133 }
2244 2134
2245 TEST_P(DisplayManagerTest, NoRotateUnifiedDesktop) { 2135 TEST_P(DisplayManagerTest, NoRotateUnifiedDesktop) {
2246 if (!SupportsMultipleDisplays())
2247 return;
2248 display_manager()->SetUnifiedDesktopEnabled(true); 2136 display_manager()->SetUnifiedDesktopEnabled(true);
2249 2137
2250 // Don't check root window destruction in unified mode. 2138 // Don't check root window destruction in unified mode.
2251 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 2139 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
2252 2140
2253 UpdateDisplay("400x500,300x200"); 2141 UpdateDisplay("400x500,300x200");
2254 2142
2255 display::Screen* screen = display::Screen::GetScreen(); 2143 display::Screen* screen = display::Screen::GetScreen();
2256 const display::Display& display = screen->GetPrimaryDisplay(); 2144 const display::Display& display = screen->GetPrimaryDisplay();
2257 EXPECT_EQ("1150x500", display.size().ToString()); 2145 EXPECT_EQ("1150x500", display.size().ToString());
2258 display_manager()->SetDisplayRotation( 2146 display_manager()->SetDisplayRotation(
2259 display.id(), display::Display::ROTATE_90, 2147 display.id(), display::Display::ROTATE_90,
2260 display::Display::ROTATION_SOURCE_ACTIVE); 2148 display::Display::ROTATION_SOURCE_ACTIVE);
2261 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString()); 2149 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString());
2262 display_manager()->SetDisplayRotation( 2150 display_manager()->SetDisplayRotation(
2263 display.id(), display::Display::ROTATE_0, 2151 display.id(), display::Display::ROTATE_0,
2264 display::Display::ROTATION_SOURCE_ACTIVE); 2152 display::Display::ROTATION_SOURCE_ACTIVE);
2265 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString()); 2153 EXPECT_EQ("1150x500", screen->GetPrimaryDisplay().size().ToString());
2266 2154
2267 UpdateDisplay("400x500"); 2155 UpdateDisplay("400x500");
2268 EXPECT_EQ("400x500", screen->GetPrimaryDisplay().size().ToString()); 2156 EXPECT_EQ("400x500", screen->GetPrimaryDisplay().size().ToString());
2269 } 2157 }
2270 2158
2271 // Makes sure the transition from unified to single won't crash 2159 // Makes sure the transition from unified to single won't crash
2272 // with docked windows. 2160 // with docked windows.
2273 TEST_P(DisplayManagerTest, UnifiedWithDockWindows) { 2161 TEST_P(DisplayManagerTest, UnifiedWithDockWindows) {
2274 if (!SupportsMultipleDisplays())
2275 return;
2276
2277 // Enable window docking for this test. 2162 // Enable window docking for this test.
2278 base::CommandLine::ForCurrentProcess()->AppendSwitch( 2163 base::CommandLine::ForCurrentProcess()->AppendSwitch(
2279 ash::switches::kAshEnableDockedWindows); 2164 ash::switches::kAshEnableDockedWindows);
2280 2165
2281 const int height_offset = GetMdMaximizedWindowHeightOffset(); 2166 const int height_offset = GetMdMaximizedWindowHeightOffset();
2282 display_manager()->SetUnifiedDesktopEnabled(true); 2167 display_manager()->SetUnifiedDesktopEnabled(true);
2283 2168
2284 // Don't check root window destruction in unified mode. 2169 // Don't check root window destruction in unified mode.
2285 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 2170 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
2286 2171
2287 UpdateDisplay("400x500,300x200"); 2172 UpdateDisplay("400x500,300x200");
2288 2173
2289 std::unique_ptr<aura::Window> docked( 2174 std::unique_ptr<aura::Window> docked(
2290 CreateTestWindowInShellWithBounds(gfx::Rect(10, 10, 50, 50))); 2175 CreateTestWindowInShellWithBounds(gfx::Rect(10, 10, 50, 50)));
2291 docked->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DOCKED); 2176 docked->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DOCKED);
2292 ASSERT_TRUE(wm::GetWindowState(docked.get())->IsDocked()); 2177 ASSERT_TRUE(wm::GetWindowState(docked.get())->IsDocked());
2293 // 47 pixels reserved for launcher shelf height in non-material design, and 2178 // 47 pixels reserved for launcher shelf height in non-material design, and
2294 // 48 pixels reserved in material design. 2179 // 48 pixels reserved in material design.
2295 EXPECT_EQ(gfx::Rect(0, 0, 250, 453 + height_offset).ToString(), 2180 EXPECT_EQ(gfx::Rect(0, 0, 250, 453 + height_offset).ToString(),
2296 docked->bounds().ToString()); 2181 docked->bounds().ToString());
2297 UpdateDisplay("300x300"); 2182 UpdateDisplay("300x300");
2298 // Make sure the window is still docked. 2183 // Make sure the window is still docked.
2299 EXPECT_TRUE(wm::GetWindowState(docked.get())->IsDocked()); 2184 EXPECT_TRUE(wm::GetWindowState(docked.get())->IsDocked());
2300 EXPECT_EQ(gfx::Rect(0, 0, 250, 253 + height_offset).ToString(), 2185 EXPECT_EQ(gfx::Rect(0, 0, 250, 253 + height_offset).ToString(),
2301 docked->bounds().ToString()); 2186 docked->bounds().ToString());
2302 } 2187 }
2303 2188
2304 TEST_P(DisplayManagerTest, DockMode) { 2189 TEST_P(DisplayManagerTest, DockMode) {
2305 if (!SupportsMultipleDisplays())
2306 return;
2307 const int64_t internal_id = 1; 2190 const int64_t internal_id = 1;
2308 const int64_t external_id = 2; 2191 const int64_t external_id = 2;
2309 2192
2310 const display::ManagedDisplayInfo internal_display_info = 2193 const display::ManagedDisplayInfo internal_display_info =
2311 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500)); 2194 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500));
2312 const display::ManagedDisplayInfo external_display_info = 2195 const display::ManagedDisplayInfo external_display_info =
2313 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); 2196 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100));
2314 std::vector<display::ManagedDisplayInfo> display_info_list; 2197 std::vector<display::ManagedDisplayInfo> display_info_list;
2315 2198
2316 // software mirroring. 2199 // software mirroring.
(...skipping 14 matching lines...) Expand all
2331 EXPECT_FALSE(display_manager()->IsActiveDisplayId(internal_id)); 2214 EXPECT_FALSE(display_manager()->IsActiveDisplayId(internal_id));
2332 2215
2333 EXPECT_FALSE(display_manager()->ZoomInternalDisplay(true)); 2216 EXPECT_FALSE(display_manager()->ZoomInternalDisplay(true));
2334 EXPECT_FALSE(display_manager()->ZoomInternalDisplay(false)); 2217 EXPECT_FALSE(display_manager()->ZoomInternalDisplay(false));
2335 EXPECT_FALSE(display::test::DisplayManagerTestApi(display_manager()) 2218 EXPECT_FALSE(display::test::DisplayManagerTestApi(display_manager())
2336 .SetDisplayUIScale(internal_id, 1.0f)); 2219 .SetDisplayUIScale(internal_id, 1.0f));
2337 } 2220 }
2338 2221
2339 // Make sure that bad layout information is ignored and does not crash. 2222 // Make sure that bad layout information is ignored and does not crash.
2340 TEST_P(DisplayManagerTest, DontRegisterBadConfig) { 2223 TEST_P(DisplayManagerTest, DontRegisterBadConfig) {
2341 if (!SupportsMultipleDisplays())
2342 return;
2343 display::DisplayIdList list = display::test::CreateDisplayIdList2(1, 2); 2224 display::DisplayIdList list = display::test::CreateDisplayIdList2(1, 2);
2344 display::DisplayLayoutBuilder builder(1); 2225 display::DisplayLayoutBuilder builder(1);
2345 builder.AddDisplayPlacement(2, 1, display::DisplayPlacement::LEFT, 0); 2226 builder.AddDisplayPlacement(2, 1, display::DisplayPlacement::LEFT, 0);
2346 builder.AddDisplayPlacement(3, 1, display::DisplayPlacement::BOTTOM, 0); 2227 builder.AddDisplayPlacement(3, 1, display::DisplayPlacement::BOTTOM, 0);
2347 2228
2348 display_manager()->layout_store()->RegisterLayoutForDisplayIdList( 2229 display_manager()->layout_store()->RegisterLayoutForDisplayIdList(
2349 list, builder.Build()); 2230 list, builder.Build());
2350 } 2231 }
2351 2232
2352 class ScreenShutdownTest : public test::AshTestBase { 2233 class ScreenShutdownTest : public test::AshTestBase {
2353 public: 2234 public:
2354 ScreenShutdownTest() {} 2235 ScreenShutdownTest() {}
2355 ~ScreenShutdownTest() override {} 2236 ~ScreenShutdownTest() override {}
2356 2237
2357 void TearDown() override { 2238 void TearDown() override {
2358 display::Screen* orig_screen = display::Screen::GetScreen(); 2239 display::Screen* orig_screen = display::Screen::GetScreen();
2359 AshTestBase::TearDown(); 2240 AshTestBase::TearDown();
2360 if (!SupportsMultipleDisplays())
2361 return;
2362 display::Screen* screen = display::Screen::GetScreen(); 2241 display::Screen* screen = display::Screen::GetScreen();
2363 EXPECT_NE(orig_screen, screen); 2242 EXPECT_NE(orig_screen, screen);
2364 EXPECT_EQ(2, screen->GetNumDisplays()); 2243 EXPECT_EQ(2, screen->GetNumDisplays());
2365 EXPECT_EQ("500x300", screen->GetPrimaryDisplay().size().ToString()); 2244 EXPECT_EQ("500x300", screen->GetPrimaryDisplay().size().ToString());
2366 std::vector<display::Display> all = screen->GetAllDisplays(); 2245 std::vector<display::Display> all = screen->GetAllDisplays();
2367 EXPECT_EQ("500x300", all[0].size().ToString()); 2246 EXPECT_EQ("500x300", all[0].size().ToString());
2368 EXPECT_EQ("800x400", all[1].size().ToString()); 2247 EXPECT_EQ("800x400", all[1].size().ToString());
2369 } 2248 }
2370 2249
2371 private: 2250 private:
2372 DISALLOW_COPY_AND_ASSIGN(ScreenShutdownTest); 2251 DISALLOW_COPY_AND_ASSIGN(ScreenShutdownTest);
2373 }; 2252 };
2374 2253
2375 TEST_F(ScreenShutdownTest, ScreenAfterShutdown) { 2254 TEST_F(ScreenShutdownTest, ScreenAfterShutdown) {
2376 if (!SupportsMultipleDisplays())
2377 return;
2378 UpdateDisplay("500x300,800x400"); 2255 UpdateDisplay("500x300,800x400");
2379 } 2256 }
2380 2257
2381 #if defined(OS_CHROMEOS)
2382 namespace { 2258 namespace {
2383 2259
2384 // A helper class that sets the display configuration and starts ash. 2260 // A helper class that sets the display configuration and starts ash.
2385 // This is to make sure the font configuration happens during ash 2261 // This is to make sure the font configuration happens during ash
2386 // initialization process. 2262 // initialization process.
2387 class FontTestHelper : public test::AshTestBase { 2263 class FontTestHelper : public test::AshTestBase {
2388 public: 2264 public:
2389 enum DisplayType { INTERNAL, EXTERNAL }; 2265 enum DisplayType { INTERNAL, EXTERNAL };
2390 2266
2391 FontTestHelper(float scale, DisplayType display_type) { 2267 FontTestHelper(float scale, DisplayType display_type) {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
2560 display::DisplayLayoutStore* layout_store = display_manager()->layout_store(); 2436 display::DisplayLayoutStore* layout_store = display_manager()->layout_store();
2561 display::DisplayIdList list = display::test::CreateDisplayIdList2(id1, id2); 2437 display::DisplayIdList list = display::test::CreateDisplayIdList2(id1, id2);
2562 layout_store->RegisterLayoutForDisplayIdList(list, std::move(old_layout)); 2438 layout_store->RegisterLayoutForDisplayIdList(list, std::move(old_layout));
2563 const display::DisplayLayout& stored = 2439 const display::DisplayLayout& stored =
2564 layout_store->GetRegisteredDisplayLayout(list); 2440 layout_store->GetRegisteredDisplayLayout(list);
2565 2441
2566 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id); 2442 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id);
2567 EXPECT_EQ(id2, stored.placement_list[0].display_id); 2443 EXPECT_EQ(id2, stored.placement_list[0].display_id);
2568 } 2444 }
2569 2445
2570 #endif // OS_CHROMEOS
2571
2572 } // namespace ash 2446 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_error_observer_chromeos_unittest.cc ('k') | ash/display/display_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698