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_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/display/display_info.h" | |
10 #include "ash/common/material_design/material_design_controller.h" | 9 #include "ash/common/material_design/material_design_controller.h" |
11 #include "ash/common/wm/window_state.h" | 10 #include "ash/common/wm/window_state.h" |
12 #include "ash/display/display_configuration_controller.h" | 11 #include "ash/display/display_configuration_controller.h" |
13 #include "ash/display/display_util.h" | 12 #include "ash/display/display_util.h" |
14 #include "ash/display/mirror_window_controller.h" | 13 #include "ash/display/mirror_window_controller.h" |
15 #include "ash/display/window_tree_host_manager.h" | 14 #include "ash/display/window_tree_host_manager.h" |
16 #include "ash/screen_util.h" | 15 #include "ash/screen_util.h" |
17 #include "ash/shell.h" | 16 #include "ash/shell.h" |
18 #include "ash/test/ash_md_test_base.h" | 17 #include "ash/test/ash_md_test_base.h" |
19 #include "ash/test/ash_test_base.h" | 18 #include "ash/test/ash_test_base.h" |
20 #include "ash/test/display_manager_test_api.h" | 19 #include "ash/test/display_manager_test_api.h" |
21 #include "ash/test/mirror_window_test_api.h" | 20 #include "ash/test/mirror_window_test_api.h" |
22 #include "ash/wm/window_state_aura.h" | 21 #include "ash/wm/window_state_aura.h" |
23 #include "base/command_line.h" | 22 #include "base/command_line.h" |
24 #include "base/format_macros.h" | 23 #include "base/format_macros.h" |
25 #include "base/strings/string_number_conversions.h" | 24 #include "base/strings/string_number_conversions.h" |
26 #include "base/strings/stringprintf.h" | 25 #include "base/strings/stringprintf.h" |
27 #include "grit/ash_strings.h" | 26 #include "grit/ash_strings.h" |
28 #include "ui/aura/client/aura_constants.h" | 27 #include "ui/aura/client/aura_constants.h" |
29 #include "ui/aura/env.h" | 28 #include "ui/aura/env.h" |
30 #include "ui/aura/window_observer.h" | 29 #include "ui/aura/window_observer.h" |
31 #include "ui/aura/window_tree_host.h" | 30 #include "ui/aura/window_tree_host.h" |
32 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
33 #include "ui/display/display.h" | 32 #include "ui/display/display.h" |
34 #include "ui/display/display_observer.h" | 33 #include "ui/display/display_observer.h" |
| 34 #include "ui/display/manager/display_info.h" |
35 #include "ui/display/manager/display_layout_builder.h" | 35 #include "ui/display/manager/display_layout_builder.h" |
36 #include "ui/display/manager/display_layout_store.h" | 36 #include "ui/display/manager/display_layout_store.h" |
37 #include "ui/display/screen.h" | 37 #include "ui/display/screen.h" |
38 #include "ui/events/test/event_generator.h" | 38 #include "ui/events/test/event_generator.h" |
39 #include "ui/gfx/font_render_params.h" | 39 #include "ui/gfx/font_render_params.h" |
40 | 40 |
41 namespace ash { | 41 namespace ash { |
42 | 42 |
43 using std::vector; | 43 using std::vector; |
44 using std::string; | 44 using std::string; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 void reset() { | 89 void reset() { |
90 changed_.clear(); | 90 changed_.clear(); |
91 added_.clear(); | 91 added_.clear(); |
92 removed_count_ = 0U; | 92 removed_count_ = 0U; |
93 changed_metrics_ = 0U; | 93 changed_metrics_ = 0U; |
94 root_window_destroyed_ = false; | 94 root_window_destroyed_ = false; |
95 } | 95 } |
96 | 96 |
97 bool root_window_destroyed() const { return root_window_destroyed_; } | 97 bool root_window_destroyed() const { return root_window_destroyed_; } |
98 | 98 |
99 const DisplayInfo& GetDisplayInfo(const display::Display& display) { | 99 const ui::DisplayInfo& GetDisplayInfo(const display::Display& display) { |
100 return display_manager()->GetDisplayInfo(display.id()); | 100 return display_manager()->GetDisplayInfo(display.id()); |
101 } | 101 } |
102 | 102 |
103 const DisplayInfo& GetDisplayInfoAt(int index) { | 103 const ui::DisplayInfo& GetDisplayInfoAt(int index) { |
104 return GetDisplayInfo(display_manager()->GetDisplayAt(index)); | 104 return GetDisplayInfo(display_manager()->GetDisplayAt(index)); |
105 } | 105 } |
106 | 106 |
107 const display::Display& GetDisplayForId(int64_t id) { | 107 const display::Display& GetDisplayForId(int64_t id) { |
108 return display_manager()->GetDisplayForId(id); | 108 return display_manager()->GetDisplayForId(id); |
109 } | 109 } |
110 | 110 |
111 const DisplayInfo& GetDisplayInfoForId(int64_t id) { | 111 const ui::DisplayInfo& GetDisplayInfoForId(int64_t id) { |
112 return GetDisplayInfo(display_manager()->GetDisplayForId(id)); | 112 return GetDisplayInfo(display_manager()->GetDisplayForId(id)); |
113 } | 113 } |
114 | 114 |
115 // aura::DisplayObserver overrides: | 115 // aura::DisplayObserver overrides: |
116 void OnDisplayMetricsChanged(const display::Display& display, | 116 void OnDisplayMetricsChanged(const display::Display& display, |
117 uint32_t changed_metrics) override { | 117 uint32_t changed_metrics) override { |
118 changed_.push_back(display); | 118 changed_.push_back(display); |
119 changed_metrics_ |= changed_metrics; | 119 changed_metrics_ |= changed_metrics; |
120 } | 120 } |
121 void OnDisplayAdded(const display::Display& new_display) override { | 121 void OnDisplayAdded(const display::Display& new_display) override { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 | 198 |
199 // Secondary removed, primary changed. | 199 // Secondary removed, primary changed. |
200 UpdateDisplay("1+1-800x300"); | 200 UpdateDisplay("1+1-800x300"); |
201 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 201 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
202 EXPECT_EQ("1 0 1", GetCountSummary()); | 202 EXPECT_EQ("1 0 1", GetCountSummary()); |
203 EXPECT_EQ(display_manager()->GetDisplayAt(0).id(), changed()[0].id()); | 203 EXPECT_EQ(display_manager()->GetDisplayAt(0).id(), changed()[0].id()); |
204 EXPECT_EQ("0,0 800x300", changed()[0].bounds().ToString()); | 204 EXPECT_EQ("0,0 800x300", changed()[0].bounds().ToString()); |
205 reset(); | 205 reset(); |
206 | 206 |
207 // # of display can go to zero when screen is off. | 207 // # of display can go to zero when screen is off. |
208 const vector<DisplayInfo> empty; | 208 const vector<ui::DisplayInfo> empty; |
209 display_manager()->OnNativeDisplaysChanged(empty); | 209 display_manager()->OnNativeDisplaysChanged(empty); |
210 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 210 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
211 EXPECT_EQ("0 0 0", GetCountSummary()); | 211 EXPECT_EQ("0 0 0", GetCountSummary()); |
212 EXPECT_FALSE(root_window_destroyed()); | 212 EXPECT_FALSE(root_window_destroyed()); |
213 // Display configuration stays the same | 213 // Display configuration stays the same |
214 EXPECT_EQ("0,0 800x300", | 214 EXPECT_EQ("0,0 800x300", |
215 display_manager()->GetDisplayAt(0).bounds().ToString()); | 215 display_manager()->GetDisplayAt(0).bounds().ToString()); |
216 reset(); | 216 reset(); |
217 | 217 |
218 // Connect to display again | 218 // Connect to display again |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 #endif | 479 #endif |
480 } | 480 } |
481 | 481 |
482 TEST_P(DisplayManagerTest, OverscanInsetsTest) { | 482 TEST_P(DisplayManagerTest, OverscanInsetsTest) { |
483 if (!SupportsMultipleDisplays()) | 483 if (!SupportsMultipleDisplays()) |
484 return; | 484 return; |
485 | 485 |
486 UpdateDisplay("0+0-500x500,0+501-400x400"); | 486 UpdateDisplay("0+0-500x500,0+501-400x400"); |
487 reset(); | 487 reset(); |
488 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); | 488 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); |
489 const DisplayInfo& display_info1 = GetDisplayInfoAt(0); | 489 const ui::DisplayInfo& display_info1 = GetDisplayInfoAt(0); |
490 const DisplayInfo& display_info2 = GetDisplayInfoAt(1); | 490 const ui::DisplayInfo& display_info2 = GetDisplayInfoAt(1); |
491 display_manager()->SetOverscanInsets(display_info2.id(), | 491 display_manager()->SetOverscanInsets(display_info2.id(), |
492 gfx::Insets(13, 12, 11, 10)); | 492 gfx::Insets(13, 12, 11, 10)); |
493 | 493 |
494 std::vector<display::Display> changed_displays = changed(); | 494 std::vector<display::Display> changed_displays = changed(); |
495 EXPECT_EQ(1u, changed_displays.size()); | 495 EXPECT_EQ(1u, changed_displays.size()); |
496 EXPECT_EQ(display_info2.id(), changed_displays[0].id()); | 496 EXPECT_EQ(display_info2.id(), changed_displays[0].id()); |
497 EXPECT_EQ("0,0 500x500", GetDisplayInfoAt(0).bounds_in_native().ToString()); | 497 EXPECT_EQ("0,0 500x500", GetDisplayInfoAt(0).bounds_in_native().ToString()); |
498 DisplayInfo updated_display_info2 = GetDisplayInfoAt(1); | 498 ui::DisplayInfo updated_display_info2 = GetDisplayInfoAt(1); |
499 EXPECT_EQ("0,501 400x400", | 499 EXPECT_EQ("0,501 400x400", |
500 updated_display_info2.bounds_in_native().ToString()); | 500 updated_display_info2.bounds_in_native().ToString()); |
501 EXPECT_EQ("378x376", updated_display_info2.size_in_pixel().ToString()); | 501 EXPECT_EQ("378x376", updated_display_info2.size_in_pixel().ToString()); |
502 EXPECT_EQ("13,12,11,10", | 502 EXPECT_EQ("13,12,11,10", |
503 updated_display_info2.overscan_insets_in_dip().ToString()); | 503 updated_display_info2.overscan_insets_in_dip().ToString()); |
504 EXPECT_EQ("500,0 378x376", | 504 EXPECT_EQ("500,0 378x376", |
505 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 505 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
506 | 506 |
507 // Make sure that SetOverscanInsets() is idempotent. | 507 // Make sure that SetOverscanInsets() is idempotent. |
508 display_manager()->SetOverscanInsets(display_info1.id(), gfx::Insets()); | 508 display_manager()->SetOverscanInsets(display_info1.id(), gfx::Insets()); |
(...skipping 17 matching lines...) Expand all Loading... |
526 // Recreate a new 2nd display. It won't apply the overscan inset because the | 526 // Recreate a new 2nd display. It won't apply the overscan inset because the |
527 // new display has a different ID. | 527 // new display has a different ID. |
528 UpdateDisplay("0+0-500x500"); | 528 UpdateDisplay("0+0-500x500"); |
529 UpdateDisplay("0+0-500x500,0+501-400x400"); | 529 UpdateDisplay("0+0-500x500,0+501-400x400"); |
530 EXPECT_EQ("0,0 500x500", GetDisplayInfoAt(0).bounds_in_native().ToString()); | 530 EXPECT_EQ("0,0 500x500", GetDisplayInfoAt(0).bounds_in_native().ToString()); |
531 EXPECT_EQ("0,501 400x400", GetDisplayInfoAt(1).bounds_in_native().ToString()); | 531 EXPECT_EQ("0,501 400x400", GetDisplayInfoAt(1).bounds_in_native().ToString()); |
532 | 532 |
533 // Recreate the displays with the same ID. It should apply the overscan | 533 // Recreate the displays with the same ID. It should apply the overscan |
534 // inset. | 534 // inset. |
535 UpdateDisplay("0+0-500x500"); | 535 UpdateDisplay("0+0-500x500"); |
536 std::vector<DisplayInfo> display_info_list; | 536 std::vector<ui::DisplayInfo> display_info_list; |
537 display_info_list.push_back(display_info1); | 537 display_info_list.push_back(display_info1); |
538 display_info_list.push_back(display_info2); | 538 display_info_list.push_back(display_info2); |
539 display_manager()->OnNativeDisplaysChanged(display_info_list); | 539 display_manager()->OnNativeDisplaysChanged(display_info_list); |
540 EXPECT_EQ("1,1 500x500", GetDisplayInfoAt(0).bounds_in_native().ToString()); | 540 EXPECT_EQ("1,1 500x500", GetDisplayInfoAt(0).bounds_in_native().ToString()); |
541 updated_display_info2 = GetDisplayInfoAt(1); | 541 updated_display_info2 = GetDisplayInfoAt(1); |
542 EXPECT_EQ("376x378", updated_display_info2.size_in_pixel().ToString()); | 542 EXPECT_EQ("376x378", updated_display_info2.size_in_pixel().ToString()); |
543 EXPECT_EQ("10,11,12,13", | 543 EXPECT_EQ("10,11,12,13", |
544 updated_display_info2.overscan_insets_in_dip().ToString()); | 544 updated_display_info2.overscan_insets_in_dip().ToString()); |
545 | 545 |
546 // HiDPI but overscan display. The specified insets size should be doubled. | 546 // HiDPI but overscan display. The specified insets size should be doubled. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); | 635 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); |
636 EXPECT_EQ("1 0 0", GetCountSummary()); | 636 EXPECT_EQ("1 0 0", GetCountSummary()); |
637 | 637 |
638 UpdateDisplay("1000x600*2"); | 638 UpdateDisplay("1000x600*2"); |
639 EXPECT_EQ(2, host->compositor()->device_scale_factor()); | 639 EXPECT_EQ(2, host->compositor()->device_scale_factor()); |
640 EXPECT_EQ("2 0 0", GetCountSummary()); | 640 EXPECT_EQ("2 0 0", GetCountSummary()); |
641 EXPECT_EQ("500x300", | 641 EXPECT_EQ("500x300", |
642 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); | 642 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); |
643 } | 643 } |
644 | 644 |
645 DisplayInfo CreateDisplayInfo(int64_t id, const gfx::Rect& bounds) { | 645 ui::DisplayInfo CreateDisplayInfo(int64_t id, const gfx::Rect& bounds) { |
646 DisplayInfo info(id, ToDisplayName(id), false); | 646 ui::DisplayInfo info(id, ToDisplayName(id), false); |
647 info.SetBounds(bounds); | 647 info.SetBounds(bounds); |
648 return info; | 648 return info; |
649 } | 649 } |
650 | 650 |
651 TEST_P(DisplayManagerTest, TestNativeDisplaysChanged) { | 651 TEST_P(DisplayManagerTest, TestNativeDisplaysChanged) { |
652 const int64_t internal_display_id = | 652 const int64_t internal_display_id = |
653 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); | 653 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); |
654 const int external_id = 10; | 654 const int external_id = 10; |
655 const int mirror_id = 11; | 655 const int mirror_id = 11; |
656 const int64_t invalid_id = display::Display::kInvalidDisplayID; | 656 const int64_t invalid_id = display::Display::kInvalidDisplayID; |
657 const DisplayInfo internal_display_info = | 657 const ui::DisplayInfo internal_display_info = |
658 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); | 658 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); |
659 const DisplayInfo external_display_info = | 659 const ui::DisplayInfo external_display_info = |
660 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); | 660 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); |
661 const DisplayInfo mirroring_display_info = | 661 const ui::DisplayInfo mirroring_display_info = |
662 CreateDisplayInfo(mirror_id, gfx::Rect(0, 0, 500, 500)); | 662 CreateDisplayInfo(mirror_id, gfx::Rect(0, 0, 500, 500)); |
663 | 663 |
664 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 664 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
665 EXPECT_EQ(1U, display_manager()->num_connected_displays()); | 665 EXPECT_EQ(1U, display_manager()->num_connected_displays()); |
666 std::string default_bounds = | 666 std::string default_bounds = |
667 display_manager()->GetDisplayAt(0).bounds().ToString(); | 667 display_manager()->GetDisplayAt(0).bounds().ToString(); |
668 | 668 |
669 std::vector<DisplayInfo> display_info_list; | 669 std::vector<ui::DisplayInfo> display_info_list; |
670 // Primary disconnected. | 670 // Primary disconnected. |
671 display_manager()->OnNativeDisplaysChanged(display_info_list); | 671 display_manager()->OnNativeDisplaysChanged(display_info_list); |
672 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 672 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
673 EXPECT_EQ(default_bounds, | 673 EXPECT_EQ(default_bounds, |
674 display_manager()->GetDisplayAt(0).bounds().ToString()); | 674 display_manager()->GetDisplayAt(0).bounds().ToString()); |
675 EXPECT_EQ(1U, display_manager()->num_connected_displays()); | 675 EXPECT_EQ(1U, display_manager()->num_connected_displays()); |
676 EXPECT_FALSE(display_manager()->IsInMirrorMode()); | 676 EXPECT_FALSE(display_manager()->IsInMirrorMode()); |
677 | 677 |
678 if (!SupportsMultipleDisplays()) | 678 if (!SupportsMultipleDisplays()) |
679 return; | 679 return; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 // See: crbug.com/414394 | 817 // See: crbug.com/414394 |
818 TEST_P(DisplayManagerTest, DisplayAddRemoveAtTheSameTime) { | 818 TEST_P(DisplayManagerTest, DisplayAddRemoveAtTheSameTime) { |
819 if (!SupportsMultipleDisplays()) | 819 if (!SupportsMultipleDisplays()) |
820 return; | 820 return; |
821 | 821 |
822 UpdateDisplay("100+0-500x500,0+501-400x400"); | 822 UpdateDisplay("100+0-500x500,0+501-400x400"); |
823 | 823 |
824 const int64_t primary_id = WindowTreeHostManager::GetPrimaryDisplayId(); | 824 const int64_t primary_id = WindowTreeHostManager::GetPrimaryDisplayId(); |
825 const int64_t secondary_id = ScreenUtil::GetSecondaryDisplay().id(); | 825 const int64_t secondary_id = ScreenUtil::GetSecondaryDisplay().id(); |
826 | 826 |
827 DisplayInfo primary_info = display_manager()->GetDisplayInfo(primary_id); | 827 ui::DisplayInfo primary_info = display_manager()->GetDisplayInfo(primary_id); |
828 DisplayInfo secondary_info = display_manager()->GetDisplayInfo(secondary_id); | 828 ui::DisplayInfo secondary_info = |
| 829 display_manager()->GetDisplayInfo(secondary_id); |
829 | 830 |
830 // An id which is different from primary and secondary. | 831 // An id which is different from primary and secondary. |
831 const int64_t third_id = secondary_id + 1; | 832 const int64_t third_id = secondary_id + 1; |
832 | 833 |
833 DisplayInfo third_info = | 834 ui::DisplayInfo third_info = |
834 CreateDisplayInfo(third_id, gfx::Rect(0, 0, 600, 600)); | 835 CreateDisplayInfo(third_id, gfx::Rect(0, 0, 600, 600)); |
835 | 836 |
836 std::vector<DisplayInfo> display_info_list; | 837 std::vector<ui::DisplayInfo> display_info_list; |
837 display_info_list.push_back(third_info); | 838 display_info_list.push_back(third_info); |
838 display_info_list.push_back(secondary_info); | 839 display_info_list.push_back(secondary_info); |
839 display_manager()->OnNativeDisplaysChanged(display_info_list); | 840 display_manager()->OnNativeDisplaysChanged(display_info_list); |
840 | 841 |
841 // Secondary seconary_id becomes the primary as it has smaller output index. | 842 // Secondary seconary_id becomes the primary as it has smaller output index. |
842 EXPECT_EQ(secondary_id, WindowTreeHostManager::GetPrimaryDisplayId()); | 843 EXPECT_EQ(secondary_id, WindowTreeHostManager::GetPrimaryDisplayId()); |
843 EXPECT_EQ(third_id, ScreenUtil::GetSecondaryDisplay().id()); | 844 EXPECT_EQ(third_id, ScreenUtil::GetSecondaryDisplay().id()); |
844 EXPECT_EQ("600x600", GetDisplayForId(third_id).size().ToString()); | 845 EXPECT_EQ("600x600", GetDisplayForId(third_id).size().ToString()); |
845 } | 846 } |
846 | 847 |
847 // TODO(scottmg): RootWindow doesn't get resized on Windows | 848 // TODO(scottmg): RootWindow doesn't get resized on Windows |
848 // Ash. http://crbug.com/247916. | 849 // Ash. http://crbug.com/247916. |
849 #if defined(OS_CHROMEOS) | 850 #if defined(OS_CHROMEOS) |
850 TEST_P(DisplayManagerTest, TestNativeDisplaysChangedNoInternal) { | 851 TEST_P(DisplayManagerTest, TestNativeDisplaysChangedNoInternal) { |
851 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 852 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
852 | 853 |
853 // Don't change the display info if all displays are disconnected. | 854 // Don't change the display info if all displays are disconnected. |
854 std::vector<DisplayInfo> display_info_list; | 855 std::vector<ui::DisplayInfo> display_info_list; |
855 display_manager()->OnNativeDisplaysChanged(display_info_list); | 856 display_manager()->OnNativeDisplaysChanged(display_info_list); |
856 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 857 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
857 | 858 |
858 // Connect another display which will become primary. | 859 // Connect another display which will become primary. |
859 const DisplayInfo external_display_info = | 860 const ui::DisplayInfo external_display_info = |
860 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); | 861 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); |
861 display_info_list.push_back(external_display_info); | 862 display_info_list.push_back(external_display_info); |
862 display_manager()->OnNativeDisplaysChanged(display_info_list); | 863 display_manager()->OnNativeDisplaysChanged(display_info_list); |
863 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 864 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
864 EXPECT_EQ("1,1 100x100", | 865 EXPECT_EQ("1,1 100x100", |
865 GetDisplayInfoForId(10).bounds_in_native().ToString()); | 866 GetDisplayInfoForId(10).bounds_in_native().ToString()); |
866 EXPECT_EQ("100x100", ash::Shell::GetPrimaryRootWindow() | 867 EXPECT_EQ("100x100", ash::Shell::GetPrimaryRootWindow() |
867 ->GetHost() | 868 ->GetHost() |
868 ->GetBounds() | 869 ->GetBounds() |
869 .size() | 870 .size() |
870 .ToString()); | 871 .ToString()); |
871 } | 872 } |
872 #endif // defined(OS_CHROMEOS) | 873 #endif // defined(OS_CHROMEOS) |
873 | 874 |
874 TEST_P(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) { | 875 TEST_P(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) { |
875 if (!SupportsMultipleDisplays()) | 876 if (!SupportsMultipleDisplays()) |
876 return; | 877 return; |
877 | 878 |
878 const int64_t internal_display_id = | 879 const int64_t internal_display_id = |
879 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); | 880 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); |
880 const DisplayInfo native_display_info = | 881 const ui::DisplayInfo native_display_info = |
881 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); | 882 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); |
882 const DisplayInfo secondary_display_info = | 883 const ui::DisplayInfo secondary_display_info = |
883 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); | 884 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); |
884 | 885 |
885 std::vector<DisplayInfo> display_info_list; | 886 std::vector<ui::DisplayInfo> display_info_list; |
886 display_info_list.push_back(native_display_info); | 887 display_info_list.push_back(native_display_info); |
887 display_info_list.push_back(secondary_display_info); | 888 display_info_list.push_back(secondary_display_info); |
888 display_manager()->OnNativeDisplaysChanged(display_info_list); | 889 display_manager()->OnNativeDisplaysChanged(display_info_list); |
889 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); | 890 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); |
890 EXPECT_EQ("0,0 500x500", | 891 EXPECT_EQ("0,0 500x500", |
891 GetDisplayForId(internal_display_id).bounds().ToString()); | 892 GetDisplayForId(internal_display_id).bounds().ToString()); |
892 EXPECT_EQ("500,0 100x100", GetDisplayForId(10).bounds().ToString()); | 893 EXPECT_EQ("500,0 100x100", GetDisplayForId(10).bounds().ToString()); |
893 | 894 |
894 ash::Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId( | 895 ash::Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId( |
895 secondary_display_info.id()); | 896 secondary_display_info.id()); |
896 EXPECT_EQ("-500,0 500x500", | 897 EXPECT_EQ("-500,0 500x500", |
897 GetDisplayForId(internal_display_id).bounds().ToString()); | 898 GetDisplayForId(internal_display_id).bounds().ToString()); |
898 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString()); | 899 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString()); |
899 | 900 |
900 // OnNativeDisplaysChanged may change the display bounds. Here makes sure | 901 // OnNativeDisplaysChanged may change the display bounds. Here makes sure |
901 // nothing changed if the exactly same displays are specified. | 902 // nothing changed if the exactly same displays are specified. |
902 display_manager()->OnNativeDisplaysChanged(display_info_list); | 903 display_manager()->OnNativeDisplaysChanged(display_info_list); |
903 EXPECT_EQ("-500,0 500x500", | 904 EXPECT_EQ("-500,0 500x500", |
904 GetDisplayForId(internal_display_id).bounds().ToString()); | 905 GetDisplayForId(internal_display_id).bounds().ToString()); |
905 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString()); | 906 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString()); |
906 } | 907 } |
907 | 908 |
908 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 909 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
909 #if defined(OS_CHROMEOS) | 910 #if defined(OS_CHROMEOS) |
910 TEST_P(DisplayManagerTest, DontRememberBestResolution) { | 911 TEST_P(DisplayManagerTest, DontRememberBestResolution) { |
911 int display_id = 1000; | 912 int display_id = 1000; |
912 DisplayInfo native_display_info = | 913 ui::DisplayInfo native_display_info = |
913 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); | 914 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); |
914 DisplayInfo::ManagedDisplayModeList display_modes; | 915 ui::DisplayInfo::ManagedDisplayModeList display_modes; |
915 display_modes.push_back(make_scoped_refptr( | 916 display_modes.push_back(make_scoped_refptr( |
916 new ManagedDisplayMode(gfx::Size(1000, 500), 58.0f, false, true))); | 917 new ui::ManagedDisplayMode(gfx::Size(1000, 500), 58.0f, false, true))); |
917 display_modes.push_back(make_scoped_refptr( | 918 display_modes.push_back(make_scoped_refptr( |
918 new ManagedDisplayMode(gfx::Size(800, 300), 59.0f, false, false))); | 919 new ui::ManagedDisplayMode(gfx::Size(800, 300), 59.0f, false, false))); |
919 display_modes.push_back(make_scoped_refptr( | 920 display_modes.push_back(make_scoped_refptr( |
920 new ManagedDisplayMode(gfx::Size(400, 500), 60.0f, false, false))); | 921 new ui::ManagedDisplayMode(gfx::Size(400, 500), 60.0f, false, false))); |
921 | 922 |
922 native_display_info.SetManagedDisplayModes(display_modes); | 923 native_display_info.SetManagedDisplayModes(display_modes); |
923 | 924 |
924 std::vector<DisplayInfo> display_info_list; | 925 std::vector<ui::DisplayInfo> display_info_list; |
925 display_info_list.push_back(native_display_info); | 926 display_info_list.push_back(native_display_info); |
926 display_manager()->OnNativeDisplaysChanged(display_info_list); | 927 display_manager()->OnNativeDisplaysChanged(display_info_list); |
927 | 928 |
928 scoped_refptr<ManagedDisplayMode> mode; | 929 scoped_refptr<ui::ManagedDisplayMode> mode; |
929 scoped_refptr<ManagedDisplayMode> expected_mode( | 930 scoped_refptr<ui::ManagedDisplayMode> expected_mode( |
930 new ManagedDisplayMode(gfx::Size(1000, 500), 0.0f, false, false)); | 931 new ui::ManagedDisplayMode(gfx::Size(1000, 500), 0.0f, false, false)); |
931 | 932 |
932 mode = display_manager()->GetSelectedModeForDisplayId(display_id); | 933 mode = display_manager()->GetSelectedModeForDisplayId(display_id); |
933 EXPECT_FALSE(!!mode); | 934 EXPECT_FALSE(!!mode); |
934 EXPECT_TRUE(expected_mode->IsEquivalent( | 935 EXPECT_TRUE(expected_mode->IsEquivalent( |
935 display_manager()->GetActiveModeForDisplayId(display_id))); | 936 display_manager()->GetActiveModeForDisplayId(display_id))); |
936 | 937 |
937 // Unsupported resolution. | 938 // Unsupported resolution. |
938 test::SetDisplayResolution(display_id, gfx::Size(800, 4000)); | 939 test::SetDisplayResolution(display_id, gfx::Size(800, 4000)); |
939 mode = display_manager()->GetSelectedModeForDisplayId(display_id); | 940 mode = display_manager()->GetSelectedModeForDisplayId(display_id); |
940 EXPECT_FALSE(!!mode); | 941 EXPECT_FALSE(!!mode); |
941 EXPECT_TRUE(expected_mode->IsEquivalent( | 942 EXPECT_TRUE(expected_mode->IsEquivalent( |
942 display_manager()->GetActiveModeForDisplayId(display_id))); | 943 display_manager()->GetActiveModeForDisplayId(display_id))); |
943 | 944 |
944 // Supported resolution. | 945 // Supported resolution. |
945 test::SetDisplayResolution(display_id, gfx::Size(800, 300)); | 946 test::SetDisplayResolution(display_id, gfx::Size(800, 300)); |
946 mode = display_manager()->GetSelectedModeForDisplayId(display_id); | 947 mode = display_manager()->GetSelectedModeForDisplayId(display_id); |
947 EXPECT_TRUE(!!mode); | 948 EXPECT_TRUE(!!mode); |
948 EXPECT_EQ("800x300", mode->size().ToString()); | 949 EXPECT_EQ("800x300", mode->size().ToString()); |
949 EXPECT_EQ(59.0f, mode->refresh_rate()); | 950 EXPECT_EQ(59.0f, mode->refresh_rate()); |
950 EXPECT_FALSE(mode->native()); | 951 EXPECT_FALSE(mode->native()); |
951 | 952 |
952 expected_mode = | 953 expected_mode = |
953 new ManagedDisplayMode(gfx::Size(800, 300), 0.0f, false, false); | 954 new ui::ManagedDisplayMode(gfx::Size(800, 300), 0.0f, false, false); |
954 | 955 |
955 EXPECT_TRUE(expected_mode->IsEquivalent( | 956 EXPECT_TRUE(expected_mode->IsEquivalent( |
956 display_manager()->GetActiveModeForDisplayId(display_id))); | 957 display_manager()->GetActiveModeForDisplayId(display_id))); |
957 | 958 |
958 // Best resolution. | 959 // Best resolution. |
959 test::SetDisplayResolution(display_id, gfx::Size(1000, 500)); | 960 test::SetDisplayResolution(display_id, gfx::Size(1000, 500)); |
960 mode = display_manager()->GetSelectedModeForDisplayId(display_id); | 961 mode = display_manager()->GetSelectedModeForDisplayId(display_id); |
961 EXPECT_TRUE(!!mode); | 962 EXPECT_TRUE(!!mode); |
962 EXPECT_EQ("1000x500", mode->size().ToString()); | 963 EXPECT_EQ("1000x500", mode->size().ToString()); |
963 EXPECT_EQ(58.0f, mode->refresh_rate()); | 964 EXPECT_EQ(58.0f, mode->refresh_rate()); |
964 EXPECT_TRUE(mode->native()); | 965 EXPECT_TRUE(mode->native()); |
965 | 966 |
966 expected_mode = | 967 expected_mode = |
967 new ManagedDisplayMode(gfx::Size(1000, 500), 0.0f, false, false); | 968 new ui::ManagedDisplayMode(gfx::Size(1000, 500), 0.0f, false, false); |
968 | 969 |
969 EXPECT_TRUE(expected_mode->IsEquivalent( | 970 EXPECT_TRUE(expected_mode->IsEquivalent( |
970 display_manager()->GetActiveModeForDisplayId(display_id))); | 971 display_manager()->GetActiveModeForDisplayId(display_id))); |
971 } | 972 } |
972 #endif // defined(OS_CHROMEOS) | 973 #endif // defined(OS_CHROMEOS) |
973 | 974 |
974 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 975 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
975 #if defined(OS_CHROMEOS) | 976 #if defined(OS_CHROMEOS) |
976 TEST_P(DisplayManagerTest, ResolutionFallback) { | 977 TEST_P(DisplayManagerTest, ResolutionFallback) { |
977 int display_id = 1000; | 978 int display_id = 1000; |
978 DisplayInfo native_display_info = | 979 ui::DisplayInfo native_display_info = |
979 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); | 980 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); |
980 DisplayInfo::ManagedDisplayModeList display_modes; | 981 ui::DisplayInfo::ManagedDisplayModeList display_modes; |
981 display_modes.push_back(make_scoped_refptr( | 982 display_modes.push_back(make_scoped_refptr( |
982 new ManagedDisplayMode(gfx::Size(1000, 500), 58.0f, false, true))); | 983 new ui::ManagedDisplayMode(gfx::Size(1000, 500), 58.0f, false, true))); |
983 display_modes.push_back(make_scoped_refptr( | 984 display_modes.push_back(make_scoped_refptr( |
984 new ManagedDisplayMode(gfx::Size(800, 300), 59.0f, false, false))); | 985 new ui::ManagedDisplayMode(gfx::Size(800, 300), 59.0f, false, false))); |
985 display_modes.push_back(make_scoped_refptr( | 986 display_modes.push_back(make_scoped_refptr( |
986 new ManagedDisplayMode(gfx::Size(400, 500), 60.0f, false, false))); | 987 new ui::ManagedDisplayMode(gfx::Size(400, 500), 60.0f, false, false))); |
987 | 988 |
988 DisplayInfo::ManagedDisplayModeList copy = display_modes; | 989 ui::DisplayInfo::ManagedDisplayModeList copy = display_modes; |
989 native_display_info.SetManagedDisplayModes(copy); | 990 native_display_info.SetManagedDisplayModes(copy); |
990 | 991 |
991 std::vector<DisplayInfo> display_info_list; | 992 std::vector<ui::DisplayInfo> display_info_list; |
992 display_info_list.push_back(native_display_info); | 993 display_info_list.push_back(native_display_info); |
993 display_manager()->OnNativeDisplaysChanged(display_info_list); | 994 display_manager()->OnNativeDisplaysChanged(display_info_list); |
994 { | 995 { |
995 test::SetDisplayResolution(display_id, gfx::Size(800, 300)); | 996 test::SetDisplayResolution(display_id, gfx::Size(800, 300)); |
996 DisplayInfo new_native_display_info = | 997 ui::DisplayInfo new_native_display_info = |
997 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 400, 500)); | 998 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 400, 500)); |
998 copy = display_modes; | 999 copy = display_modes; |
999 new_native_display_info.SetManagedDisplayModes(copy); | 1000 new_native_display_info.SetManagedDisplayModes(copy); |
1000 std::vector<DisplayInfo> new_display_info_list; | 1001 std::vector<ui::DisplayInfo> new_display_info_list; |
1001 new_display_info_list.push_back(new_native_display_info); | 1002 new_display_info_list.push_back(new_native_display_info); |
1002 display_manager()->OnNativeDisplaysChanged(new_display_info_list); | 1003 display_manager()->OnNativeDisplaysChanged(new_display_info_list); |
1003 | 1004 |
1004 scoped_refptr<ManagedDisplayMode> mode = | 1005 scoped_refptr<ui::ManagedDisplayMode> mode = |
1005 display_manager()->GetSelectedModeForDisplayId(display_id); | 1006 display_manager()->GetSelectedModeForDisplayId(display_id); |
1006 EXPECT_TRUE(!!mode); | 1007 EXPECT_TRUE(!!mode); |
1007 EXPECT_EQ("400x500", mode->size().ToString()); | 1008 EXPECT_EQ("400x500", mode->size().ToString()); |
1008 EXPECT_EQ(60.0f, mode->refresh_rate()); | 1009 EXPECT_EQ(60.0f, mode->refresh_rate()); |
1009 EXPECT_FALSE(mode->native()); | 1010 EXPECT_FALSE(mode->native()); |
1010 } | 1011 } |
1011 { | 1012 { |
1012 // Best resolution should find itself on the resolutions list. | 1013 // Best resolution should find itself on the resolutions list. |
1013 test::SetDisplayResolution(display_id, gfx::Size(800, 300)); | 1014 test::SetDisplayResolution(display_id, gfx::Size(800, 300)); |
1014 DisplayInfo new_native_display_info = | 1015 ui::DisplayInfo new_native_display_info = |
1015 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); | 1016 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); |
1016 DisplayInfo::ManagedDisplayModeList copy = display_modes; | 1017 ui::DisplayInfo::ManagedDisplayModeList copy = display_modes; |
1017 new_native_display_info.SetManagedDisplayModes(copy); | 1018 new_native_display_info.SetManagedDisplayModes(copy); |
1018 std::vector<DisplayInfo> new_display_info_list; | 1019 std::vector<ui::DisplayInfo> new_display_info_list; |
1019 new_display_info_list.push_back(new_native_display_info); | 1020 new_display_info_list.push_back(new_native_display_info); |
1020 display_manager()->OnNativeDisplaysChanged(new_display_info_list); | 1021 display_manager()->OnNativeDisplaysChanged(new_display_info_list); |
1021 | 1022 |
1022 scoped_refptr<ManagedDisplayMode> mode = | 1023 scoped_refptr<ui::ManagedDisplayMode> mode = |
1023 display_manager()->GetSelectedModeForDisplayId(display_id); | 1024 display_manager()->GetSelectedModeForDisplayId(display_id); |
1024 EXPECT_TRUE(!!mode); | 1025 EXPECT_TRUE(!!mode); |
1025 EXPECT_EQ("1000x500", mode->size().ToString()); | 1026 EXPECT_EQ("1000x500", mode->size().ToString()); |
1026 EXPECT_EQ(58.0f, mode->refresh_rate()); | 1027 EXPECT_EQ(58.0f, mode->refresh_rate()); |
1027 EXPECT_TRUE(mode->native()); | 1028 EXPECT_TRUE(mode->native()); |
1028 } | 1029 } |
1029 } | 1030 } |
1030 #endif // defined(OS_CHROMEOS) | 1031 #endif // defined(OS_CHROMEOS) |
1031 | 1032 |
1032 TEST_P(DisplayManagerTest, Rotate) { | 1033 TEST_P(DisplayManagerTest, Rotate) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 const int64_t internal_display_id = | 1084 const int64_t internal_display_id = |
1084 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); | 1085 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); |
1085 | 1086 |
1086 display_manager()->SetDisplayRotation(internal_display_id, | 1087 display_manager()->SetDisplayRotation(internal_display_id, |
1087 display::Display::ROTATE_90, | 1088 display::Display::ROTATE_90, |
1088 display::Display::ROTATION_SOURCE_USER); | 1089 display::Display::ROTATION_SOURCE_USER); |
1089 display_manager()->SetDisplayRotation( | 1090 display_manager()->SetDisplayRotation( |
1090 internal_display_id, display::Display::ROTATE_0, | 1091 internal_display_id, display::Display::ROTATE_0, |
1091 display::Display::ROTATION_SOURCE_ACTIVE); | 1092 display::Display::ROTATION_SOURCE_ACTIVE); |
1092 | 1093 |
1093 const DisplayInfo info = GetDisplayInfoForId(internal_display_id); | 1094 const ui::DisplayInfo info = GetDisplayInfoForId(internal_display_id); |
1094 EXPECT_EQ(display::Display::ROTATE_0, info.GetActiveRotation()); | 1095 EXPECT_EQ(display::Display::ROTATE_0, info.GetActiveRotation()); |
1095 | 1096 |
1096 // Deactivate internal display to simulate Docked Mode. | 1097 // Deactivate internal display to simulate Docked Mode. |
1097 vector<DisplayInfo> secondary_only; | 1098 vector<ui::DisplayInfo> secondary_only; |
1098 secondary_only.push_back(GetDisplayInfoAt(1)); | 1099 secondary_only.push_back(GetDisplayInfoAt(1)); |
1099 display_manager()->OnNativeDisplaysChanged(secondary_only); | 1100 display_manager()->OnNativeDisplaysChanged(secondary_only); |
1100 | 1101 |
1101 const DisplayInfo post_removal_info = | 1102 const ui::DisplayInfo post_removal_info = |
1102 display_manager()->display_info_[internal_display_id]; | 1103 display_manager()->display_info_[internal_display_id]; |
1103 EXPECT_NE(info.GetActiveRotation(), post_removal_info.GetActiveRotation()); | 1104 EXPECT_NE(info.GetActiveRotation(), post_removal_info.GetActiveRotation()); |
1104 EXPECT_EQ(display::Display::ROTATE_90, post_removal_info.GetActiveRotation()); | 1105 EXPECT_EQ(display::Display::ROTATE_90, post_removal_info.GetActiveRotation()); |
1105 | 1106 |
1106 display_manager()->SetDisplayRotation( | 1107 display_manager()->SetDisplayRotation( |
1107 internal_display_id, display::Display::ROTATE_180, | 1108 internal_display_id, display::Display::ROTATE_180, |
1108 display::Display::ROTATION_SOURCE_ACTIVE); | 1109 display::Display::ROTATION_SOURCE_ACTIVE); |
1109 const DisplayInfo post_rotation_info = | 1110 const ui::DisplayInfo post_rotation_info = |
1110 display_manager()->display_info_[internal_display_id]; | 1111 display_manager()->display_info_[internal_display_id]; |
1111 EXPECT_NE(info.GetActiveRotation(), post_rotation_info.GetActiveRotation()); | 1112 EXPECT_NE(info.GetActiveRotation(), post_rotation_info.GetActiveRotation()); |
1112 EXPECT_EQ(display::Display::ROTATE_180, | 1113 EXPECT_EQ(display::Display::ROTATE_180, |
1113 post_rotation_info.GetActiveRotation()); | 1114 post_rotation_info.GetActiveRotation()); |
1114 } | 1115 } |
1115 | 1116 |
1116 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 1117 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
1117 #if defined(OS_CHROMEOS) | 1118 #if defined(OS_CHROMEOS) |
1118 TEST_P(DisplayManagerTest, UIScale) { | 1119 TEST_P(DisplayManagerTest, UIScale) { |
1119 test::ScopedDisable125DSFForUIScaling disable; | 1120 test::ScopedDisable125DSFForUIScaling disable; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 display = display::Screen::GetScreen()->GetPrimaryDisplay(); | 1208 display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
1208 EXPECT_EQ(1.0f, display.device_scale_factor()); | 1209 EXPECT_EQ(1.0f, display.device_scale_factor()); |
1209 EXPECT_EQ("1280x850", display.bounds().size().ToString()); | 1210 EXPECT_EQ("1280x850", display.bounds().size().ToString()); |
1210 } | 1211 } |
1211 #endif // defined(OS_CHROMEOS) | 1212 #endif // defined(OS_CHROMEOS) |
1212 | 1213 |
1213 TEST_P(DisplayManagerTest, UIScaleWithDisplayMode) { | 1214 TEST_P(DisplayManagerTest, UIScaleWithDisplayMode) { |
1214 int display_id = 1000; | 1215 int display_id = 1000; |
1215 | 1216 |
1216 // Setup the display modes with UI-scale. | 1217 // Setup the display modes with UI-scale. |
1217 DisplayInfo native_display_info = | 1218 ui::DisplayInfo native_display_info = |
1218 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1280, 800)); | 1219 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1280, 800)); |
1219 const scoped_refptr<ManagedDisplayMode>& base_mode( | 1220 const scoped_refptr<ui::ManagedDisplayMode>& base_mode( |
1220 new ManagedDisplayMode(gfx::Size(1280, 800), 60.0f, false, false)); | 1221 new ui::ManagedDisplayMode(gfx::Size(1280, 800), 60.0f, false, false)); |
1221 DisplayInfo::ManagedDisplayModeList mode_list = | 1222 ui::DisplayInfo::ManagedDisplayModeList mode_list = |
1222 CreateInternalManagedDisplayModeList(base_mode); | 1223 CreateInternalManagedDisplayModeList(base_mode); |
1223 native_display_info.SetManagedDisplayModes(mode_list); | 1224 native_display_info.SetManagedDisplayModes(mode_list); |
1224 | 1225 |
1225 std::vector<DisplayInfo> display_info_list; | 1226 std::vector<ui::DisplayInfo> display_info_list; |
1226 display_info_list.push_back(native_display_info); | 1227 display_info_list.push_back(native_display_info); |
1227 display_manager()->OnNativeDisplaysChanged(display_info_list); | 1228 display_manager()->OnNativeDisplaysChanged(display_info_list); |
1228 | 1229 |
1229 scoped_refptr<ManagedDisplayMode> expected_mode = base_mode; | 1230 scoped_refptr<ui::ManagedDisplayMode> expected_mode = base_mode; |
1230 EXPECT_TRUE(expected_mode->IsEquivalent( | 1231 EXPECT_TRUE(expected_mode->IsEquivalent( |
1231 display_manager()->GetActiveModeForDisplayId(display_id))); | 1232 display_manager()->GetActiveModeForDisplayId(display_id))); |
1232 | 1233 |
1233 test::ScopedSetInternalDisplayId set_internal(display_id); | 1234 test::ScopedSetInternalDisplayId set_internal(display_id); |
1234 | 1235 |
1235 SetDisplayUIScale(display_id, 1.5f); | 1236 SetDisplayUIScale(display_id, 1.5f); |
1236 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); | 1237 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); |
1237 EXPECT_TRUE(expected_mode->IsEquivalent( | 1238 EXPECT_TRUE(expected_mode->IsEquivalent( |
1238 display_manager()->GetActiveModeForDisplayId(display_id))); | 1239 display_manager()->GetActiveModeForDisplayId(display_id))); |
1239 SetDisplayUIScale(display_id, 1.25f); | 1240 SetDisplayUIScale(display_id, 1.25f); |
1240 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); | 1241 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); |
1241 EXPECT_TRUE(expected_mode->IsEquivalent( | 1242 EXPECT_TRUE(expected_mode->IsEquivalent( |
1242 display_manager()->GetActiveModeForDisplayId(display_id))); | 1243 display_manager()->GetActiveModeForDisplayId(display_id))); |
1243 SetDisplayUIScale(display_id, 1.125f); | 1244 SetDisplayUIScale(display_id, 1.125f); |
1244 EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale()); | 1245 EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale()); |
1245 | 1246 |
1246 expected_mode = new ManagedDisplayMode( | 1247 expected_mode = new ui::ManagedDisplayMode( |
1247 expected_mode->size(), expected_mode->refresh_rate(), | 1248 expected_mode->size(), expected_mode->refresh_rate(), |
1248 expected_mode->is_interlaced(), expected_mode->native(), | 1249 expected_mode->is_interlaced(), expected_mode->native(), |
1249 1.125f /* ui_scale */, expected_mode->device_scale_factor()); | 1250 1.125f /* ui_scale */, expected_mode->device_scale_factor()); |
1250 | 1251 |
1251 EXPECT_TRUE(expected_mode->IsEquivalent( | 1252 EXPECT_TRUE(expected_mode->IsEquivalent( |
1252 display_manager()->GetActiveModeForDisplayId(display_id))); | 1253 display_manager()->GetActiveModeForDisplayId(display_id))); |
1253 SetDisplayUIScale(display_id, 0.8f); | 1254 SetDisplayUIScale(display_id, 0.8f); |
1254 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale()); | 1255 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale()); |
1255 | 1256 |
1256 expected_mode = new ManagedDisplayMode( | 1257 expected_mode = new ui::ManagedDisplayMode( |
1257 expected_mode->size(), expected_mode->refresh_rate(), | 1258 expected_mode->size(), expected_mode->refresh_rate(), |
1258 expected_mode->is_interlaced(), expected_mode->native(), | 1259 expected_mode->is_interlaced(), expected_mode->native(), |
1259 0.8f /* ui_scale */, expected_mode->device_scale_factor()); | 1260 0.8f /* ui_scale */, expected_mode->device_scale_factor()); |
1260 | 1261 |
1261 EXPECT_TRUE(expected_mode->IsEquivalent( | 1262 EXPECT_TRUE(expected_mode->IsEquivalent( |
1262 display_manager()->GetActiveModeForDisplayId(display_id))); | 1263 display_manager()->GetActiveModeForDisplayId(display_id))); |
1263 SetDisplayUIScale(display_id, 0.75f); | 1264 SetDisplayUIScale(display_id, 0.75f); |
1264 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale()); | 1265 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale()); |
1265 EXPECT_TRUE(expected_mode->IsEquivalent( | 1266 EXPECT_TRUE(expected_mode->IsEquivalent( |
1266 display_manager()->GetActiveModeForDisplayId(display_id))); | 1267 display_manager()->GetActiveModeForDisplayId(display_id))); |
1267 SetDisplayUIScale(display_id, 0.625f); | 1268 SetDisplayUIScale(display_id, 0.625f); |
1268 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); | 1269 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); |
1269 | 1270 |
1270 expected_mode = new ManagedDisplayMode( | 1271 expected_mode = new ui::ManagedDisplayMode( |
1271 expected_mode->size(), expected_mode->refresh_rate(), | 1272 expected_mode->size(), expected_mode->refresh_rate(), |
1272 expected_mode->is_interlaced(), expected_mode->native(), | 1273 expected_mode->is_interlaced(), expected_mode->native(), |
1273 0.625f /* ui_scale */, expected_mode->device_scale_factor()); | 1274 0.625f /* ui_scale */, expected_mode->device_scale_factor()); |
1274 | 1275 |
1275 EXPECT_TRUE(expected_mode->IsEquivalent( | 1276 EXPECT_TRUE(expected_mode->IsEquivalent( |
1276 display_manager()->GetActiveModeForDisplayId(display_id))); | 1277 display_manager()->GetActiveModeForDisplayId(display_id))); |
1277 SetDisplayUIScale(display_id, 0.6f); | 1278 SetDisplayUIScale(display_id, 0.6f); |
1278 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); | 1279 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); |
1279 EXPECT_TRUE(expected_mode->IsEquivalent( | 1280 EXPECT_TRUE(expected_mode->IsEquivalent( |
1280 display_manager()->GetActiveModeForDisplayId(display_id))); | 1281 display_manager()->GetActiveModeForDisplayId(display_id))); |
1281 SetDisplayUIScale(display_id, 0.5f); | 1282 SetDisplayUIScale(display_id, 0.5f); |
1282 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale()); | 1283 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale()); |
1283 | 1284 |
1284 expected_mode = new ManagedDisplayMode( | 1285 expected_mode = new ui::ManagedDisplayMode( |
1285 expected_mode->size(), expected_mode->refresh_rate(), | 1286 expected_mode->size(), expected_mode->refresh_rate(), |
1286 expected_mode->is_interlaced(), expected_mode->native(), | 1287 expected_mode->is_interlaced(), expected_mode->native(), |
1287 0.5f /* ui_scale */, expected_mode->device_scale_factor()); | 1288 0.5f /* ui_scale */, expected_mode->device_scale_factor()); |
1288 | 1289 |
1289 EXPECT_TRUE(expected_mode->IsEquivalent( | 1290 EXPECT_TRUE(expected_mode->IsEquivalent( |
1290 display_manager()->GetActiveModeForDisplayId(display_id))); | 1291 display_manager()->GetActiveModeForDisplayId(display_id))); |
1291 } | 1292 } |
1292 | 1293 |
1293 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 1294 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
1294 #if defined(OS_CHROMEOS) | 1295 #if defined(OS_CHROMEOS) |
(...skipping 24 matching lines...) Expand all Loading... |
1319 | 1320 |
1320 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 1321 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
1321 #if defined(OS_CHROMEOS) | 1322 #if defined(OS_CHROMEOS) |
1322 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScaling) { | 1323 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScaling) { |
1323 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 1324 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
1324 | 1325 |
1325 display_id++; | 1326 display_id++; |
1326 test::ScopedSetInternalDisplayId set_internal(display_id); | 1327 test::ScopedSetInternalDisplayId set_internal(display_id); |
1327 | 1328 |
1328 // Setup the display modes with UI-scale. | 1329 // Setup the display modes with UI-scale. |
1329 DisplayInfo native_display_info = | 1330 ui::DisplayInfo native_display_info = |
1330 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080)); | 1331 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080)); |
1331 native_display_info.set_device_scale_factor(1.25); | 1332 native_display_info.set_device_scale_factor(1.25); |
1332 | 1333 |
1333 const scoped_refptr<ManagedDisplayMode>& base_mode( | 1334 const scoped_refptr<ui::ManagedDisplayMode>& base_mode( |
1334 new ManagedDisplayMode(gfx::Size(1920, 1080), 60.0f, false, false)); | 1335 new ui::ManagedDisplayMode(gfx::Size(1920, 1080), 60.0f, false, false)); |
1335 DisplayInfo::ManagedDisplayModeList mode_list = | 1336 ui::DisplayInfo::ManagedDisplayModeList mode_list = |
1336 CreateInternalManagedDisplayModeList(base_mode); | 1337 CreateInternalManagedDisplayModeList(base_mode); |
1337 native_display_info.SetManagedDisplayModes(mode_list); | 1338 native_display_info.SetManagedDisplayModes(mode_list); |
1338 | 1339 |
1339 std::vector<DisplayInfo> display_info_list; | 1340 std::vector<ui::DisplayInfo> display_info_list; |
1340 display_info_list.push_back(native_display_info); | 1341 display_info_list.push_back(native_display_info); |
1341 | 1342 |
1342 display_manager()->OnNativeDisplaysChanged(display_info_list); | 1343 display_manager()->OnNativeDisplaysChanged(display_info_list); |
1343 | 1344 |
1344 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); | 1345 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); |
1345 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); | 1346 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); |
1346 } | 1347 } |
1347 #endif // defined(OS_CHROMEOS) | 1348 #endif // defined(OS_CHROMEOS) |
1348 | 1349 |
1349 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 1350 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
1350 #if defined(OS_CHROMEOS) | 1351 #if defined(OS_CHROMEOS) |
1351 // Don't default to 1.25 DSF if the user already has a prefrence stored for | 1352 // Don't default to 1.25 DSF if the user already has a prefrence stored for |
1352 // the internal display. | 1353 // the internal display. |
1353 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScalingNoOverride) { | 1354 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScalingNoOverride) { |
1354 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 1355 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
1355 | 1356 |
1356 display_id++; | 1357 display_id++; |
1357 test::ScopedSetInternalDisplayId set_internal(display_id); | 1358 test::ScopedSetInternalDisplayId set_internal(display_id); |
1358 const gfx::Insets dummy_overscan_insets; | 1359 const gfx::Insets dummy_overscan_insets; |
1359 display_manager()->RegisterDisplayProperty( | 1360 display_manager()->RegisterDisplayProperty( |
1360 display_id, display::Display::ROTATE_0, 1.0f, &dummy_overscan_insets, | 1361 display_id, display::Display::ROTATE_0, 1.0f, &dummy_overscan_insets, |
1361 gfx::Size(), 1.0f, ui::ColorCalibrationProfile()); | 1362 gfx::Size(), 1.0f, ui::ColorCalibrationProfile()); |
1362 | 1363 |
1363 // Setup the display modes with UI-scale. | 1364 // Setup the display modes with UI-scale. |
1364 DisplayInfo native_display_info = | 1365 ui::DisplayInfo native_display_info = |
1365 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080)); | 1366 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080)); |
1366 native_display_info.set_device_scale_factor(1.25); | 1367 native_display_info.set_device_scale_factor(1.25); |
1367 | 1368 |
1368 const scoped_refptr<ManagedDisplayMode>& base_mode( | 1369 const scoped_refptr<ui::ManagedDisplayMode>& base_mode( |
1369 new ManagedDisplayMode(gfx::Size(1920, 1080), 60.0f, false, false)); | 1370 new ui::ManagedDisplayMode(gfx::Size(1920, 1080), 60.0f, false, false)); |
1370 DisplayInfo::ManagedDisplayModeList mode_list = | 1371 ui::DisplayInfo::ManagedDisplayModeList mode_list = |
1371 CreateInternalManagedDisplayModeList(base_mode); | 1372 CreateInternalManagedDisplayModeList(base_mode); |
1372 native_display_info.SetManagedDisplayModes(mode_list); | 1373 native_display_info.SetManagedDisplayModes(mode_list); |
1373 | 1374 |
1374 std::vector<DisplayInfo> display_info_list; | 1375 std::vector<ui::DisplayInfo> display_info_list; |
1375 display_info_list.push_back(native_display_info); | 1376 display_info_list.push_back(native_display_info); |
1376 | 1377 |
1377 display_manager()->OnNativeDisplaysChanged(display_info_list); | 1378 display_manager()->OnNativeDisplaysChanged(display_info_list); |
1378 | 1379 |
1379 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); | 1380 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); |
1380 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); | 1381 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); |
1381 } | 1382 } |
1382 #endif // defined(OS_CHROMEOS) | 1383 #endif // defined(OS_CHROMEOS) |
1383 | 1384 |
1384 TEST_P(DisplayManagerTest, ResolutionChangeInUnifiedMode) { | 1385 TEST_P(DisplayManagerTest, ResolutionChangeInUnifiedMode) { |
1385 if (!SupportsMultipleDisplays()) | 1386 if (!SupportsMultipleDisplays()) |
1386 return; | 1387 return; |
1387 // Don't check root window destruction in unified mode. | 1388 // Don't check root window destruction in unified mode. |
1388 Shell::GetPrimaryRootWindow()->RemoveObserver(this); | 1389 Shell::GetPrimaryRootWindow()->RemoveObserver(this); |
1389 | 1390 |
1390 display_manager()->SetUnifiedDesktopEnabled(true); | 1391 display_manager()->SetUnifiedDesktopEnabled(true); |
1391 | 1392 |
1392 UpdateDisplay("200x200, 400x400"); | 1393 UpdateDisplay("200x200, 400x400"); |
1393 | 1394 |
1394 int64_t unified_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 1395 int64_t unified_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
1395 DisplayInfo info = display_manager()->GetDisplayInfo(unified_id); | 1396 ui::DisplayInfo info = display_manager()->GetDisplayInfo(unified_id); |
1396 ASSERT_EQ(2u, info.display_modes().size()); | 1397 ASSERT_EQ(2u, info.display_modes().size()); |
1397 EXPECT_EQ("400x200", info.display_modes()[0]->size().ToString()); | 1398 EXPECT_EQ("400x200", info.display_modes()[0]->size().ToString()); |
1398 EXPECT_TRUE(info.display_modes()[0]->native()); | 1399 EXPECT_TRUE(info.display_modes()[0]->native()); |
1399 EXPECT_EQ("800x400", info.display_modes()[1]->size().ToString()); | 1400 EXPECT_EQ("800x400", info.display_modes()[1]->size().ToString()); |
1400 EXPECT_FALSE(info.display_modes()[1]->native()); | 1401 EXPECT_FALSE(info.display_modes()[1]->native()); |
1401 EXPECT_EQ( | 1402 EXPECT_EQ( |
1402 "400x200", | 1403 "400x200", |
1403 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); | 1404 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); |
1404 scoped_refptr<ManagedDisplayMode> active_mode = | 1405 scoped_refptr<ui::ManagedDisplayMode> active_mode = |
1405 display_manager()->GetActiveModeForDisplayId(unified_id); | 1406 display_manager()->GetActiveModeForDisplayId(unified_id); |
1406 EXPECT_EQ(1.0f, active_mode->ui_scale()); | 1407 EXPECT_EQ(1.0f, active_mode->ui_scale()); |
1407 EXPECT_EQ("400x200", active_mode->size().ToString()); | 1408 EXPECT_EQ("400x200", active_mode->size().ToString()); |
1408 | 1409 |
1409 EXPECT_TRUE(test::SetDisplayResolution(unified_id, gfx::Size(800, 400))); | 1410 EXPECT_TRUE(test::SetDisplayResolution(unified_id, gfx::Size(800, 400))); |
1410 EXPECT_EQ( | 1411 EXPECT_EQ( |
1411 "800x400", | 1412 "800x400", |
1412 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); | 1413 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); |
1413 | 1414 |
1414 active_mode = display_manager()->GetActiveModeForDisplayId(unified_id); | 1415 active_mode = display_manager()->GetActiveModeForDisplayId(unified_id); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1622 TEST_P(DisplayManagerTest, SoftwareMirroringWithCompositingCursor) { | 1623 TEST_P(DisplayManagerTest, SoftwareMirroringWithCompositingCursor) { |
1623 if (!SupportsMultipleDisplays()) | 1624 if (!SupportsMultipleDisplays()) |
1624 return; | 1625 return; |
1625 | 1626 |
1626 UpdateDisplay("300x400,400x500"); | 1627 UpdateDisplay("300x400,400x500"); |
1627 | 1628 |
1628 test::MirrorWindowTestApi test_api; | 1629 test::MirrorWindowTestApi test_api; |
1629 EXPECT_EQ(nullptr, test_api.GetHost()); | 1630 EXPECT_EQ(nullptr, test_api.GetHost()); |
1630 | 1631 |
1631 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 1632 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
1632 DisplayInfo secondary_info = | 1633 ui::DisplayInfo secondary_info = |
1633 display_manager->GetDisplayInfo(ScreenUtil::GetSecondaryDisplay().id()); | 1634 display_manager->GetDisplayInfo(ScreenUtil::GetSecondaryDisplay().id()); |
1634 | 1635 |
1635 display_manager->SetSoftwareMirroring(true); | 1636 display_manager->SetSoftwareMirroring(true); |
1636 display_manager->UpdateDisplays(); | 1637 display_manager->UpdateDisplays(); |
1637 | 1638 |
1638 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1639 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
1639 EXPECT_FALSE(root_windows[0]->Contains(test_api.GetCursorWindow())); | 1640 EXPECT_FALSE(root_windows[0]->Contains(test_api.GetCursorWindow())); |
1640 | 1641 |
1641 Shell::GetInstance()->SetCursorCompositingEnabled(true); | 1642 Shell::GetInstance()->SetCursorCompositingEnabled(true); |
1642 | 1643 |
1643 EXPECT_TRUE(root_windows[0]->Contains(test_api.GetCursorWindow())); | 1644 EXPECT_TRUE(root_windows[0]->Contains(test_api.GetCursorWindow())); |
1644 | 1645 |
1645 // Removes the first display and keeps the second one. | 1646 // Removes the first display and keeps the second one. |
1646 display_manager->SetSoftwareMirroring(false); | 1647 display_manager->SetSoftwareMirroring(false); |
1647 std::vector<DisplayInfo> new_info_list; | 1648 std::vector<ui::DisplayInfo> new_info_list; |
1648 new_info_list.push_back(secondary_info); | 1649 new_info_list.push_back(secondary_info); |
1649 display_manager->OnNativeDisplaysChanged(new_info_list); | 1650 display_manager->OnNativeDisplaysChanged(new_info_list); |
1650 | 1651 |
1651 root_windows = Shell::GetAllRootWindows(); | 1652 root_windows = Shell::GetAllRootWindows(); |
1652 EXPECT_TRUE(root_windows[0]->Contains(test_api.GetCursorWindow())); | 1653 EXPECT_TRUE(root_windows[0]->Contains(test_api.GetCursorWindow())); |
1653 | 1654 |
1654 Shell::GetInstance()->SetCursorCompositingEnabled(false); | 1655 Shell::GetInstance()->SetCursorCompositingEnabled(false); |
1655 } | 1656 } |
1656 #endif // OS_CHROMEOS | 1657 #endif // OS_CHROMEOS |
1657 | 1658 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1753 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); | 1754 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); |
1754 EXPECT_TRUE(changed_metrics() & | 1755 EXPECT_TRUE(changed_metrics() & |
1755 display::DisplayObserver::DISPLAY_METRIC_PRIMARY); | 1756 display::DisplayObserver::DISPLAY_METRIC_PRIMARY); |
1756 } | 1757 } |
1757 | 1758 |
1758 TEST_P(DisplayManagerTest, NotifyPrimaryChangeUndock) { | 1759 TEST_P(DisplayManagerTest, NotifyPrimaryChangeUndock) { |
1759 if (!SupportsMultipleDisplays()) | 1760 if (!SupportsMultipleDisplays()) |
1760 return; | 1761 return; |
1761 // Assume the default display is an external display, and | 1762 // Assume the default display is an external display, and |
1762 // emulates undocking by switching to another display. | 1763 // emulates undocking by switching to another display. |
1763 DisplayInfo another_display_info = | 1764 ui::DisplayInfo another_display_info = |
1764 CreateDisplayInfo(1, gfx::Rect(0, 0, 1280, 800)); | 1765 CreateDisplayInfo(1, gfx::Rect(0, 0, 1280, 800)); |
1765 std::vector<DisplayInfo> info_list; | 1766 std::vector<ui::DisplayInfo> info_list; |
1766 info_list.push_back(another_display_info); | 1767 info_list.push_back(another_display_info); |
1767 reset(); | 1768 reset(); |
1768 display_manager()->OnNativeDisplaysChanged(info_list); | 1769 display_manager()->OnNativeDisplaysChanged(info_list); |
1769 EXPECT_TRUE(changed_metrics() & | 1770 EXPECT_TRUE(changed_metrics() & |
1770 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); | 1771 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); |
1771 EXPECT_TRUE(changed_metrics() & | 1772 EXPECT_TRUE(changed_metrics() & |
1772 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); | 1773 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); |
1773 EXPECT_TRUE(changed_metrics() & | 1774 EXPECT_TRUE(changed_metrics() & |
1774 display::DisplayObserver::DISPLAY_METRIC_PRIMARY); | 1775 display::DisplayObserver::DISPLAY_METRIC_PRIMARY); |
1775 } | 1776 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1842 // Switch to single desktop. | 1843 // Switch to single desktop. |
1843 UpdateDisplay("500x300"); | 1844 UpdateDisplay("500x300"); |
1844 EXPECT_EQ(gfx::Size(500, 300), screen->GetPrimaryDisplay().size()); | 1845 EXPECT_EQ(gfx::Size(500, 300), screen->GetPrimaryDisplay().size()); |
1845 | 1846 |
1846 // Switch to unified desktop. | 1847 // Switch to unified desktop. |
1847 UpdateDisplay("500x300,400x500"); | 1848 UpdateDisplay("500x300,400x500"); |
1848 // 400 * 300 / 500 + 500 ~= 739. | 1849 // 400 * 300 / 500 + 500 ~= 739. |
1849 EXPECT_EQ(gfx::Size(739, 300), screen->GetPrimaryDisplay().size()); | 1850 EXPECT_EQ(gfx::Size(739, 300), screen->GetPrimaryDisplay().size()); |
1850 | 1851 |
1851 // The default should fit to the internal display. | 1852 // The default should fit to the internal display. |
1852 std::vector<DisplayInfo> display_info_list; | 1853 std::vector<ui::DisplayInfo> display_info_list; |
1853 display_info_list.push_back(CreateDisplayInfo(10, gfx::Rect(0, 0, 500, 300))); | 1854 display_info_list.push_back(CreateDisplayInfo(10, gfx::Rect(0, 0, 500, 300))); |
1854 display_info_list.push_back( | 1855 display_info_list.push_back( |
1855 CreateDisplayInfo(11, gfx::Rect(500, 0, 400, 500))); | 1856 CreateDisplayInfo(11, gfx::Rect(500, 0, 400, 500))); |
1856 { | 1857 { |
1857 test::ScopedSetInternalDisplayId set_internal(11); | 1858 test::ScopedSetInternalDisplayId set_internal(11); |
1858 display_manager()->OnNativeDisplaysChanged(display_info_list); | 1859 display_manager()->OnNativeDisplaysChanged(display_info_list); |
1859 // 500 * 500 / 300 + 400 ~= 1233. | 1860 // 500 * 500 / 300 + 400 ~= 1233. |
1860 EXPECT_EQ(gfx::Size(1233, 500), screen->GetPrimaryDisplay().size()); | 1861 EXPECT_EQ(gfx::Size(1233, 500), screen->GetPrimaryDisplay().size()); |
1861 } | 1862 } |
1862 | 1863 |
(...skipping 11 matching lines...) Expand all Loading... |
1874 .size()); | 1875 .size()); |
1875 } | 1876 } |
1876 | 1877 |
1877 TEST_P(DisplayManagerTest, UnifiedDesktopWithHardwareMirroring) { | 1878 TEST_P(DisplayManagerTest, UnifiedDesktopWithHardwareMirroring) { |
1878 if (!SupportsMultipleDisplays()) | 1879 if (!SupportsMultipleDisplays()) |
1879 return; | 1880 return; |
1880 // Don't check root window destruction in unified mode. | 1881 // Don't check root window destruction in unified mode. |
1881 Shell::GetPrimaryRootWindow()->RemoveObserver(this); | 1882 Shell::GetPrimaryRootWindow()->RemoveObserver(this); |
1882 | 1883 |
1883 // Enter to hardware mirroring. | 1884 // Enter to hardware mirroring. |
1884 DisplayInfo d1(1, "", false); | 1885 ui::DisplayInfo d1(1, "", false); |
1885 d1.SetBounds(gfx::Rect(0, 0, 500, 500)); | 1886 d1.SetBounds(gfx::Rect(0, 0, 500, 500)); |
1886 DisplayInfo d2(2, "", false); | 1887 ui::DisplayInfo d2(2, "", false); |
1887 d2.SetBounds(gfx::Rect(0, 0, 500, 500)); | 1888 d2.SetBounds(gfx::Rect(0, 0, 500, 500)); |
1888 std::vector<DisplayInfo> display_info_list; | 1889 std::vector<ui::DisplayInfo> display_info_list; |
1889 display_info_list.push_back(d1); | 1890 display_info_list.push_back(d1); |
1890 display_info_list.push_back(d2); | 1891 display_info_list.push_back(d2); |
1891 display_manager()->OnNativeDisplaysChanged(display_info_list); | 1892 display_manager()->OnNativeDisplaysChanged(display_info_list); |
1892 ASSERT_TRUE(display_manager()->IsInMirrorMode()); | 1893 ASSERT_TRUE(display_manager()->IsInMirrorMode()); |
1893 display_manager()->SetUnifiedDesktopEnabled(true); | 1894 display_manager()->SetUnifiedDesktopEnabled(true); |
1894 EXPECT_TRUE(display_manager()->IsInMirrorMode()); | 1895 EXPECT_TRUE(display_manager()->IsInMirrorMode()); |
1895 | 1896 |
1896 // The display manager automaticaclly switches to software mirroring | 1897 // The display manager automaticaclly switches to software mirroring |
1897 // if the displays are configured to use mirroring when running on desktop. | 1898 // if the displays are configured to use mirroring when running on desktop. |
1898 // This is a workdaround to force the display manager to forget | 1899 // This is a workdaround to force the display manager to forget |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1935 if (!SupportsMultipleDisplays()) | 1936 if (!SupportsMultipleDisplays()) |
1936 return; | 1937 return; |
1937 // Don't check root window destruction in unified mode. | 1938 // Don't check root window destruction in unified mode. |
1938 Shell::GetPrimaryRootWindow()->RemoveObserver(this); | 1939 Shell::GetPrimaryRootWindow()->RemoveObserver(this); |
1939 | 1940 |
1940 display_manager()->SetUnifiedDesktopEnabled(true); | 1941 display_manager()->SetUnifiedDesktopEnabled(true); |
1941 display::Screen* screen = display::Screen::GetScreen(); | 1942 display::Screen* screen = display::Screen::GetScreen(); |
1942 | 1943 |
1943 // 2nd display is 2x. | 1944 // 2nd display is 2x. |
1944 UpdateDisplay("400x500,1000x800*2"); | 1945 UpdateDisplay("400x500,1000x800*2"); |
1945 DisplayInfo info = | 1946 ui::DisplayInfo info = |
1946 display_manager()->GetDisplayInfo(screen->GetPrimaryDisplay().id()); | 1947 display_manager()->GetDisplayInfo(screen->GetPrimaryDisplay().id()); |
1947 EXPECT_EQ(2u, info.display_modes().size()); | 1948 EXPECT_EQ(2u, info.display_modes().size()); |
1948 EXPECT_EQ("1640x800", info.display_modes()[0]->size().ToString()); | 1949 EXPECT_EQ("1640x800", info.display_modes()[0]->size().ToString()); |
1949 EXPECT_EQ(2.0f, info.display_modes()[0]->device_scale_factor()); | 1950 EXPECT_EQ(2.0f, info.display_modes()[0]->device_scale_factor()); |
1950 EXPECT_EQ("1025x500", info.display_modes()[1]->size().ToString()); | 1951 EXPECT_EQ("1025x500", info.display_modes()[1]->size().ToString()); |
1951 EXPECT_EQ(1.0f, info.display_modes()[1]->device_scale_factor()); | 1952 EXPECT_EQ(1.0f, info.display_modes()[1]->device_scale_factor()); |
1952 | 1953 |
1953 // For 1x, 400 + 500 / 800 * 100 = 1025. | 1954 // For 1x, 400 + 500 / 800 * 100 = 1025. |
1954 EXPECT_EQ("1025x500", screen->GetPrimaryDisplay().size().ToString()); | 1955 EXPECT_EQ("1025x500", screen->GetPrimaryDisplay().size().ToString()); |
1955 EXPECT_EQ("1025x500", | 1956 EXPECT_EQ("1025x500", |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2102 EXPECT_EQ(gfx::Rect(0, 0, 250, 253 + height_offset).ToString(), | 2103 EXPECT_EQ(gfx::Rect(0, 0, 250, 253 + height_offset).ToString(), |
2103 docked->bounds().ToString()); | 2104 docked->bounds().ToString()); |
2104 } | 2105 } |
2105 | 2106 |
2106 TEST_P(DisplayManagerTest, DockMode) { | 2107 TEST_P(DisplayManagerTest, DockMode) { |
2107 if (!SupportsMultipleDisplays()) | 2108 if (!SupportsMultipleDisplays()) |
2108 return; | 2109 return; |
2109 const int64_t internal_id = 1; | 2110 const int64_t internal_id = 1; |
2110 const int64_t external_id = 2; | 2111 const int64_t external_id = 2; |
2111 | 2112 |
2112 const DisplayInfo internal_display_info = | 2113 const ui::DisplayInfo internal_display_info = |
2113 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500)); | 2114 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500)); |
2114 const DisplayInfo external_display_info = | 2115 const ui::DisplayInfo external_display_info = |
2115 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); | 2116 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); |
2116 std::vector<DisplayInfo> display_info_list; | 2117 std::vector<ui::DisplayInfo> display_info_list; |
2117 | 2118 |
2118 // software mirroring. | 2119 // software mirroring. |
2119 display_info_list.push_back(internal_display_info); | 2120 display_info_list.push_back(internal_display_info); |
2120 display_info_list.push_back(external_display_info); | 2121 display_info_list.push_back(external_display_info); |
2121 display_manager()->OnNativeDisplaysChanged(display_info_list); | 2122 display_manager()->OnNativeDisplaysChanged(display_info_list); |
2122 const int64_t internal_display_id = | 2123 const int64_t internal_display_id = |
2123 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); | 2124 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); |
2124 EXPECT_EQ(internal_id, internal_display_id); | 2125 EXPECT_EQ(internal_id, internal_display_id); |
2125 | 2126 |
2126 display_info_list.clear(); | 2127 display_info_list.clear(); |
2127 display_info_list.push_back(external_display_info); | 2128 display_info_list.push_back(external_display_info); |
2128 display_manager()->OnNativeDisplaysChanged(display_info_list); | 2129 display_manager()->OnNativeDisplaysChanged(display_info_list); |
2129 EXPECT_EQ(1U, display_manager()->active_display_list().size()); | 2130 EXPECT_EQ(1U, display_manager()->active_display_list().size()); |
2130 | 2131 |
2131 EXPECT_TRUE(display_manager()->IsActiveDisplayId(external_id)); | 2132 EXPECT_TRUE(display_manager()->IsActiveDisplayId(external_id)); |
2132 EXPECT_FALSE(display_manager()->IsActiveDisplayId(internal_id)); | 2133 EXPECT_FALSE(display_manager()->IsActiveDisplayId(internal_id)); |
2133 | 2134 |
2134 const DisplayInfo& info = display_manager()->GetDisplayInfo(internal_id); | 2135 const ui::DisplayInfo& info = display_manager()->GetDisplayInfo(internal_id); |
2135 | 2136 |
2136 EXPECT_FALSE(!!GetDisplayModeForNextUIScale(info, true)); | 2137 EXPECT_FALSE(!!GetDisplayModeForNextUIScale(info, true)); |
2137 EXPECT_FALSE(!!GetDisplayModeForNextUIScale(info, false)); | 2138 EXPECT_FALSE(!!GetDisplayModeForNextUIScale(info, false)); |
2138 EXPECT_FALSE(SetDisplayUIScale(internal_id, 1.0f)); | 2139 EXPECT_FALSE(SetDisplayUIScale(internal_id, 1.0f)); |
2139 | 2140 |
2140 DisplayInfo invalid_info; | 2141 ui::DisplayInfo invalid_info; |
2141 EXPECT_FALSE(!!GetDisplayModeForNextUIScale(invalid_info, true)); | 2142 EXPECT_FALSE(!!GetDisplayModeForNextUIScale(invalid_info, true)); |
2142 EXPECT_FALSE(!!GetDisplayModeForNextUIScale(invalid_info, false)); | 2143 EXPECT_FALSE(!!GetDisplayModeForNextUIScale(invalid_info, false)); |
2143 EXPECT_FALSE(SetDisplayUIScale(display::Display::kInvalidDisplayID, 1.0f)); | 2144 EXPECT_FALSE(SetDisplayUIScale(display::Display::kInvalidDisplayID, 1.0f)); |
2144 } | 2145 } |
2145 | 2146 |
2146 // Make sure that bad layout information is ignored and does not crash. | 2147 // Make sure that bad layout information is ignored and does not crash. |
2147 TEST_P(DisplayManagerTest, DontRegisterBadConfig) { | 2148 TEST_P(DisplayManagerTest, DontRegisterBadConfig) { |
2148 if (!SupportsMultipleDisplays()) | 2149 if (!SupportsMultipleDisplays()) |
2149 return; | 2150 return; |
2150 display::DisplayIdList list = ash::test::CreateDisplayIdList2(1, 2); | 2151 display::DisplayIdList list = ash::test::CreateDisplayIdList2(1, 2); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2312 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); | 2313 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); |
2313 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); | 2314 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); |
2314 } | 2315 } |
2315 | 2316 |
2316 TEST_P(DisplayManagerTest, CheckInitializationOfRotationProperty) { | 2317 TEST_P(DisplayManagerTest, CheckInitializationOfRotationProperty) { |
2317 int64_t id = display_manager()->GetDisplayAt(0).id(); | 2318 int64_t id = display_manager()->GetDisplayAt(0).id(); |
2318 display_manager()->RegisterDisplayProperty(id, display::Display::ROTATE_90, | 2319 display_manager()->RegisterDisplayProperty(id, display::Display::ROTATE_90, |
2319 1.0f, nullptr, gfx::Size(), 1.0f, | 2320 1.0f, nullptr, gfx::Size(), 1.0f, |
2320 ui::COLOR_PROFILE_STANDARD); | 2321 ui::COLOR_PROFILE_STANDARD); |
2321 | 2322 |
2322 const DisplayInfo& info = display_manager()->GetDisplayInfo(id); | 2323 const ui::DisplayInfo& info = display_manager()->GetDisplayInfo(id); |
2323 | 2324 |
2324 EXPECT_EQ(display::Display::ROTATE_90, | 2325 EXPECT_EQ(display::Display::ROTATE_90, |
2325 info.GetRotation(display::Display::ROTATION_SOURCE_USER)); | 2326 info.GetRotation(display::Display::ROTATION_SOURCE_USER)); |
2326 EXPECT_EQ(display::Display::ROTATE_90, | 2327 EXPECT_EQ(display::Display::ROTATE_90, |
2327 info.GetRotation(display::Display::ROTATION_SOURCE_ACTIVE)); | 2328 info.GetRotation(display::Display::ROTATION_SOURCE_ACTIVE)); |
2328 } | 2329 } |
2329 | 2330 |
2330 TEST_P(DisplayManagerTest, RejectInvalidLayoutData) { | 2331 TEST_P(DisplayManagerTest, RejectInvalidLayoutData) { |
2331 display::DisplayLayoutStore* layout_store = display_manager()->layout_store(); | 2332 display::DisplayLayoutStore* layout_store = display_manager()->layout_store(); |
2332 int64_t id1 = 10001; | 2333 int64_t id1 = 10001; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2366 const display::DisplayLayout& stored = | 2367 const display::DisplayLayout& stored = |
2367 layout_store->GetRegisteredDisplayLayout(list); | 2368 layout_store->GetRegisteredDisplayLayout(list); |
2368 | 2369 |
2369 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id); | 2370 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id); |
2370 EXPECT_EQ(id2, stored.placement_list[0].display_id); | 2371 EXPECT_EQ(id2, stored.placement_list[0].display_id); |
2371 } | 2372 } |
2372 | 2373 |
2373 #endif // OS_CHROMEOS | 2374 #endif // OS_CHROMEOS |
2374 | 2375 |
2375 } // namespace ash | 2376 } // namespace ash |
OLD | NEW |