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

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

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

Powered by Google App Engine
This is Rietveld 408576698