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

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

Issue 2355063002: Separate ash::test::DisplayManagerTestApi from ash (Closed)
Patch Set: review comment Created 4 years, 2 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/extended_mouse_warp_controller.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/material_design/material_design_controller.h" 8 #include "ash/common/material_design/material_design_controller.h"
9 #include "ash/common/wm/window_state.h" 9 #include "ash/common/wm/window_state.h"
10 #include "ash/display/display_configuration_controller.h" 10 #include "ash/display/display_configuration_controller.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 AshMDTestBase::SetUp(); 69 AshMDTestBase::SetUp();
70 display::Screen::GetScreen()->AddObserver(this); 70 display::Screen::GetScreen()->AddObserver(this);
71 Shell::GetPrimaryRootWindow()->AddObserver(this); 71 Shell::GetPrimaryRootWindow()->AddObserver(this);
72 } 72 }
73 void TearDown() override { 73 void TearDown() override {
74 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 74 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
75 display::Screen::GetScreen()->RemoveObserver(this); 75 display::Screen::GetScreen()->RemoveObserver(this);
76 AshMDTestBase::TearDown(); 76 AshMDTestBase::TearDown();
77 } 77 }
78 78
79 DisplayManager* display_manager() {
80 return Shell::GetInstance()->display_manager();
81 }
82 const vector<display::Display>& changed() const { return changed_; } 79 const vector<display::Display>& changed() const { return changed_; }
83 const vector<display::Display>& added() const { return added_; } 80 const vector<display::Display>& added() const { return added_; }
84 uint32_t changed_metrics() const { return changed_metrics_; } 81 uint32_t changed_metrics() const { return changed_metrics_; }
85 82
86 string GetCountSummary() const { 83 string GetCountSummary() const {
87 return StringPrintf("%" PRIuS " %" PRIuS " %" PRIuS, changed_.size(), 84 return StringPrintf("%" PRIuS " %" PRIuS " %" PRIuS, changed_.size(),
88 added_.size(), removed_count_); 85 added_.size(), removed_count_);
89 } 86 }
90 87
91 void reset() { 88 void reset() {
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 EXPECT_EQ(1u, changed_displays.size()); 495 EXPECT_EQ(1u, changed_displays.size());
499 EXPECT_EQ(display_info2.id(), changed_displays[0].id()); 496 EXPECT_EQ(display_info2.id(), changed_displays[0].id());
500 EXPECT_EQ("0,0 500x500", GetDisplayInfoAt(0).bounds_in_native().ToString()); 497 EXPECT_EQ("0,0 500x500", GetDisplayInfoAt(0).bounds_in_native().ToString());
501 display::ManagedDisplayInfo updated_display_info2 = GetDisplayInfoAt(1); 498 display::ManagedDisplayInfo updated_display_info2 = GetDisplayInfoAt(1);
502 EXPECT_EQ("0,501 400x400", 499 EXPECT_EQ("0,501 400x400",
503 updated_display_info2.bounds_in_native().ToString()); 500 updated_display_info2.bounds_in_native().ToString());
504 EXPECT_EQ("378x376", updated_display_info2.size_in_pixel().ToString()); 501 EXPECT_EQ("378x376", updated_display_info2.size_in_pixel().ToString());
505 EXPECT_EQ("13,12,11,10", 502 EXPECT_EQ("13,12,11,10",
506 updated_display_info2.overscan_insets_in_dip().ToString()); 503 updated_display_info2.overscan_insets_in_dip().ToString());
507 EXPECT_EQ("500,0 378x376", 504 EXPECT_EQ("500,0 378x376",
508 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); 505 display_manager()->GetSecondaryDisplay().bounds().ToString());
509 506
510 // Make sure that SetOverscanInsets() is idempotent. 507 // Make sure that SetOverscanInsets() is idempotent.
511 display_manager()->SetOverscanInsets(display_info1.id(), gfx::Insets()); 508 display_manager()->SetOverscanInsets(display_info1.id(), gfx::Insets());
512 display_manager()->SetOverscanInsets(display_info2.id(), 509 display_manager()->SetOverscanInsets(display_info2.id(),
513 gfx::Insets(13, 12, 11, 10)); 510 gfx::Insets(13, 12, 11, 10));
514 EXPECT_EQ("0,0 500x500", GetDisplayInfoAt(0).bounds_in_native().ToString()); 511 EXPECT_EQ("0,0 500x500", GetDisplayInfoAt(0).bounds_in_native().ToString());
515 updated_display_info2 = GetDisplayInfoAt(1); 512 updated_display_info2 = GetDisplayInfoAt(1);
516 EXPECT_EQ("0,501 400x400", 513 EXPECT_EQ("0,501 400x400",
517 updated_display_info2.bounds_in_native().ToString()); 514 updated_display_info2.bounds_in_native().ToString());
518 EXPECT_EQ("378x376", updated_display_info2.size_in_pixel().ToString()); 515 EXPECT_EQ("378x376", updated_display_info2.size_in_pixel().ToString());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 EXPECT_EQ("0,501 400x400", 552 EXPECT_EQ("0,501 400x400",
556 updated_display_info2.bounds_in_native().ToString()); 553 updated_display_info2.bounds_in_native().ToString());
557 EXPECT_EQ("376x380", updated_display_info2.size_in_pixel().ToString()); 554 EXPECT_EQ("376x380", updated_display_info2.size_in_pixel().ToString());
558 EXPECT_EQ("4,5,6,7", 555 EXPECT_EQ("4,5,6,7",
559 updated_display_info2.overscan_insets_in_dip().ToString()); 556 updated_display_info2.overscan_insets_in_dip().ToString());
560 EXPECT_EQ("8,10,12,14", 557 EXPECT_EQ("8,10,12,14",
561 updated_display_info2.GetOverscanInsetsInPixel().ToString()); 558 updated_display_info2.GetOverscanInsetsInPixel().ToString());
562 559
563 // Make sure switching primary display applies the overscan offset only once. 560 // Make sure switching primary display applies the overscan offset only once.
564 ash::Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId( 561 ash::Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId(
565 ScreenUtil::GetSecondaryDisplay().id()); 562 display_manager()->GetSecondaryDisplay().id());
566 EXPECT_EQ("-500,0 500x500", 563 EXPECT_EQ("-500,0 500x500",
567 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); 564 display_manager()->GetSecondaryDisplay().bounds().ToString());
568 EXPECT_EQ("0,0 500x500", GetDisplayInfo(ScreenUtil::GetSecondaryDisplay()) 565 EXPECT_EQ("0,0 500x500",
569 .bounds_in_native() 566 GetDisplayInfo(display_manager()->GetSecondaryDisplay())
570 .ToString()); 567 .bounds_in_native()
568 .ToString());
571 EXPECT_EQ("0,501 400x400", 569 EXPECT_EQ("0,501 400x400",
572 GetDisplayInfo(display::Screen::GetScreen()->GetPrimaryDisplay()) 570 GetDisplayInfo(display::Screen::GetScreen()->GetPrimaryDisplay())
573 .bounds_in_native() 571 .bounds_in_native()
574 .ToString()); 572 .ToString());
575 EXPECT_EQ( 573 EXPECT_EQ(
576 "0,0 188x190", 574 "0,0 188x190",
577 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString()); 575 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString());
578 576
579 // Make sure just moving the overscan area should property notify observers. 577 // Make sure just moving the overscan area should property notify observers.
580 UpdateDisplay("0+0-500x500"); 578 UpdateDisplay("0+0-500x500");
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 645
648 display::ManagedDisplayInfo CreateDisplayInfo(int64_t id, 646 display::ManagedDisplayInfo CreateDisplayInfo(int64_t id,
649 const gfx::Rect& bounds) { 647 const gfx::Rect& bounds) {
650 display::ManagedDisplayInfo info(id, ToDisplayName(id), false); 648 display::ManagedDisplayInfo info(id, ToDisplayName(id), false);
651 info.SetBounds(bounds); 649 info.SetBounds(bounds);
652 return info; 650 return info;
653 } 651 }
654 652
655 TEST_P(DisplayManagerTest, TestNativeDisplaysChanged) { 653 TEST_P(DisplayManagerTest, TestNativeDisplaysChanged) {
656 const int64_t internal_display_id = 654 const int64_t internal_display_id =
657 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); 655 test::DisplayManagerTestApi(display_manager())
656 .SetFirstDisplayAsInternalDisplay();
658 const int external_id = 10; 657 const int external_id = 10;
659 const int mirror_id = 11; 658 const int mirror_id = 11;
660 const int64_t invalid_id = display::Display::kInvalidDisplayID; 659 const int64_t invalid_id = display::Display::kInvalidDisplayID;
661 const display::ManagedDisplayInfo internal_display_info = 660 const display::ManagedDisplayInfo internal_display_info =
662 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); 661 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500));
663 const display::ManagedDisplayInfo external_display_info = 662 const display::ManagedDisplayInfo external_display_info =
664 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); 663 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100));
665 const display::ManagedDisplayInfo mirroring_display_info = 664 const display::ManagedDisplayInfo mirroring_display_info =
666 CreateDisplayInfo(mirror_id, gfx::Rect(0, 0, 500, 500)); 665 CreateDisplayInfo(mirror_id, gfx::Rect(0, 0, 500, 500));
667 666
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 818
820 // Make sure crash does not happen if add and remove happens at the same time. 819 // Make sure crash does not happen if add and remove happens at the same time.
821 // See: crbug.com/414394 820 // See: crbug.com/414394
822 TEST_P(DisplayManagerTest, DisplayAddRemoveAtTheSameTime) { 821 TEST_P(DisplayManagerTest, DisplayAddRemoveAtTheSameTime) {
823 if (!SupportsMultipleDisplays()) 822 if (!SupportsMultipleDisplays())
824 return; 823 return;
825 824
826 UpdateDisplay("100+0-500x500,0+501-400x400"); 825 UpdateDisplay("100+0-500x500,0+501-400x400");
827 826
828 const int64_t primary_id = WindowTreeHostManager::GetPrimaryDisplayId(); 827 const int64_t primary_id = WindowTreeHostManager::GetPrimaryDisplayId();
829 const int64_t secondary_id = ScreenUtil::GetSecondaryDisplay().id(); 828 const int64_t secondary_id = display_manager()->GetSecondaryDisplay().id();
830 829
831 display::ManagedDisplayInfo primary_info = 830 display::ManagedDisplayInfo primary_info =
832 display_manager()->GetDisplayInfo(primary_id); 831 display_manager()->GetDisplayInfo(primary_id);
833 display::ManagedDisplayInfo secondary_info = 832 display::ManagedDisplayInfo secondary_info =
834 display_manager()->GetDisplayInfo(secondary_id); 833 display_manager()->GetDisplayInfo(secondary_id);
835 834
836 // An id which is different from primary and secondary. 835 // An id which is different from primary and secondary.
837 const int64_t third_id = secondary_id + 1; 836 const int64_t third_id = secondary_id + 1;
838 837
839 display::ManagedDisplayInfo third_info = 838 display::ManagedDisplayInfo third_info =
840 CreateDisplayInfo(third_id, gfx::Rect(0, 0, 600, 600)); 839 CreateDisplayInfo(third_id, gfx::Rect(0, 0, 600, 600));
841 840
842 std::vector<display::ManagedDisplayInfo> display_info_list; 841 std::vector<display::ManagedDisplayInfo> display_info_list;
843 display_info_list.push_back(third_info); 842 display_info_list.push_back(third_info);
844 display_info_list.push_back(secondary_info); 843 display_info_list.push_back(secondary_info);
845 display_manager()->OnNativeDisplaysChanged(display_info_list); 844 display_manager()->OnNativeDisplaysChanged(display_info_list);
846 845
847 // Secondary seconary_id becomes the primary as it has smaller output index. 846 // Secondary seconary_id becomes the primary as it has smaller output index.
848 EXPECT_EQ(secondary_id, WindowTreeHostManager::GetPrimaryDisplayId()); 847 EXPECT_EQ(secondary_id, WindowTreeHostManager::GetPrimaryDisplayId());
849 EXPECT_EQ(third_id, ScreenUtil::GetSecondaryDisplay().id()); 848 EXPECT_EQ(third_id, display_manager()->GetSecondaryDisplay().id());
850 EXPECT_EQ("600x600", GetDisplayForId(third_id).size().ToString()); 849 EXPECT_EQ("600x600", GetDisplayForId(third_id).size().ToString());
851 } 850 }
852 851
853 // TODO(scottmg): RootWindow doesn't get resized on Windows 852 // TODO(scottmg): RootWindow doesn't get resized on Windows
854 // Ash. http://crbug.com/247916. 853 // Ash. http://crbug.com/247916.
855 #if defined(OS_CHROMEOS) 854 #if defined(OS_CHROMEOS)
856 TEST_P(DisplayManagerTest, TestNativeDisplaysChangedNoInternal) { 855 TEST_P(DisplayManagerTest, TestNativeDisplaysChangedNoInternal) {
857 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 856 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
858 857
859 // Don't change the display info if all displays are disconnected. 858 // Don't change the display info if all displays are disconnected.
(...skipping 15 matching lines...) Expand all
875 .size() 874 .size()
876 .ToString()); 875 .ToString());
877 } 876 }
878 #endif // defined(OS_CHROMEOS) 877 #endif // defined(OS_CHROMEOS)
879 878
880 TEST_P(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) { 879 TEST_P(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) {
881 if (!SupportsMultipleDisplays()) 880 if (!SupportsMultipleDisplays())
882 return; 881 return;
883 882
884 const int64_t internal_display_id = 883 const int64_t internal_display_id =
885 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); 884 test::DisplayManagerTestApi(display_manager())
885 .SetFirstDisplayAsInternalDisplay();
886 const display::ManagedDisplayInfo native_display_info = 886 const display::ManagedDisplayInfo native_display_info =
887 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); 887 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500));
888 const display::ManagedDisplayInfo secondary_display_info = 888 const display::ManagedDisplayInfo secondary_display_info =
889 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); 889 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100));
890 890
891 std::vector<display::ManagedDisplayInfo> display_info_list; 891 std::vector<display::ManagedDisplayInfo> display_info_list;
892 display_info_list.push_back(native_display_info); 892 display_info_list.push_back(native_display_info);
893 display_info_list.push_back(secondary_display_info); 893 display_info_list.push_back(secondary_display_info);
894 display_manager()->OnNativeDisplaysChanged(display_info_list); 894 display_manager()->OnNativeDisplaysChanged(display_info_list);
895 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); 895 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 scoped_refptr<display::ManagedDisplayMode> expected_mode( 935 scoped_refptr<display::ManagedDisplayMode> expected_mode(
936 new display::ManagedDisplayMode(gfx::Size(1000, 500), 0.0f, false, 936 new display::ManagedDisplayMode(gfx::Size(1000, 500), 0.0f, false,
937 false)); 937 false));
938 938
939 mode = display_manager()->GetSelectedModeForDisplayId(display_id); 939 mode = display_manager()->GetSelectedModeForDisplayId(display_id);
940 EXPECT_FALSE(!!mode); 940 EXPECT_FALSE(!!mode);
941 EXPECT_TRUE(expected_mode->IsEquivalent( 941 EXPECT_TRUE(expected_mode->IsEquivalent(
942 display_manager()->GetActiveModeForDisplayId(display_id))); 942 display_manager()->GetActiveModeForDisplayId(display_id)));
943 943
944 // Unsupported resolution. 944 // Unsupported resolution.
945 test::SetDisplayResolution(display_id, gfx::Size(800, 4000)); 945 test::SetDisplayResolution(display_manager(), display_id,
946 gfx::Size(800, 4000));
946 mode = display_manager()->GetSelectedModeForDisplayId(display_id); 947 mode = display_manager()->GetSelectedModeForDisplayId(display_id);
947 EXPECT_FALSE(!!mode); 948 EXPECT_FALSE(!!mode);
948 EXPECT_TRUE(expected_mode->IsEquivalent( 949 EXPECT_TRUE(expected_mode->IsEquivalent(
949 display_manager()->GetActiveModeForDisplayId(display_id))); 950 display_manager()->GetActiveModeForDisplayId(display_id)));
950 951
951 // Supported resolution. 952 // Supported resolution.
952 test::SetDisplayResolution(display_id, gfx::Size(800, 300)); 953 test::SetDisplayResolution(display_manager(), display_id,
954 gfx::Size(800, 300));
953 mode = display_manager()->GetSelectedModeForDisplayId(display_id); 955 mode = display_manager()->GetSelectedModeForDisplayId(display_id);
954 EXPECT_TRUE(!!mode); 956 EXPECT_TRUE(!!mode);
955 EXPECT_EQ("800x300", mode->size().ToString()); 957 EXPECT_EQ("800x300", mode->size().ToString());
956 EXPECT_EQ(59.0f, mode->refresh_rate()); 958 EXPECT_EQ(59.0f, mode->refresh_rate());
957 EXPECT_FALSE(mode->native()); 959 EXPECT_FALSE(mode->native());
958 960
959 expected_mode = 961 expected_mode =
960 new display::ManagedDisplayMode(gfx::Size(800, 300), 0.0f, false, false); 962 new display::ManagedDisplayMode(gfx::Size(800, 300), 0.0f, false, false);
961 963
962 EXPECT_TRUE(expected_mode->IsEquivalent( 964 EXPECT_TRUE(expected_mode->IsEquivalent(
963 display_manager()->GetActiveModeForDisplayId(display_id))); 965 display_manager()->GetActiveModeForDisplayId(display_id)));
964 966
965 // Best resolution. 967 // Best resolution.
966 test::SetDisplayResolution(display_id, gfx::Size(1000, 500)); 968 test::SetDisplayResolution(display_manager(), display_id,
969 gfx::Size(1000, 500));
967 mode = display_manager()->GetSelectedModeForDisplayId(display_id); 970 mode = display_manager()->GetSelectedModeForDisplayId(display_id);
968 EXPECT_TRUE(!!mode); 971 EXPECT_TRUE(!!mode);
969 EXPECT_EQ("1000x500", mode->size().ToString()); 972 EXPECT_EQ("1000x500", mode->size().ToString());
970 EXPECT_EQ(58.0f, mode->refresh_rate()); 973 EXPECT_EQ(58.0f, mode->refresh_rate());
971 EXPECT_TRUE(mode->native()); 974 EXPECT_TRUE(mode->native());
972 975
973 expected_mode = 976 expected_mode =
974 new display::ManagedDisplayMode(gfx::Size(1000, 500), 0.0f, false, false); 977 new display::ManagedDisplayMode(gfx::Size(1000, 500), 0.0f, false, false);
975 978
976 EXPECT_TRUE(expected_mode->IsEquivalent( 979 EXPECT_TRUE(expected_mode->IsEquivalent(
(...skipping 15 matching lines...) Expand all
992 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode( 995 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode(
993 gfx::Size(400, 500), 60.0f, false, false))); 996 gfx::Size(400, 500), 60.0f, false, false)));
994 997
995 display::ManagedDisplayInfo::ManagedDisplayModeList copy = display_modes; 998 display::ManagedDisplayInfo::ManagedDisplayModeList copy = display_modes;
996 native_display_info.SetManagedDisplayModes(copy); 999 native_display_info.SetManagedDisplayModes(copy);
997 1000
998 std::vector<display::ManagedDisplayInfo> display_info_list; 1001 std::vector<display::ManagedDisplayInfo> display_info_list;
999 display_info_list.push_back(native_display_info); 1002 display_info_list.push_back(native_display_info);
1000 display_manager()->OnNativeDisplaysChanged(display_info_list); 1003 display_manager()->OnNativeDisplaysChanged(display_info_list);
1001 { 1004 {
1002 test::SetDisplayResolution(display_id, gfx::Size(800, 300)); 1005 test::SetDisplayResolution(display_manager(), display_id,
1006 gfx::Size(800, 300));
1003 display::ManagedDisplayInfo new_native_display_info = 1007 display::ManagedDisplayInfo new_native_display_info =
1004 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 400, 500)); 1008 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 400, 500));
1005 copy = display_modes; 1009 copy = display_modes;
1006 new_native_display_info.SetManagedDisplayModes(copy); 1010 new_native_display_info.SetManagedDisplayModes(copy);
1007 std::vector<display::ManagedDisplayInfo> new_display_info_list; 1011 std::vector<display::ManagedDisplayInfo> new_display_info_list;
1008 new_display_info_list.push_back(new_native_display_info); 1012 new_display_info_list.push_back(new_native_display_info);
1009 display_manager()->OnNativeDisplaysChanged(new_display_info_list); 1013 display_manager()->OnNativeDisplaysChanged(new_display_info_list);
1010 1014
1011 scoped_refptr<display::ManagedDisplayMode> mode = 1015 scoped_refptr<display::ManagedDisplayMode> mode =
1012 display_manager()->GetSelectedModeForDisplayId(display_id); 1016 display_manager()->GetSelectedModeForDisplayId(display_id);
1013 EXPECT_TRUE(!!mode); 1017 EXPECT_TRUE(!!mode);
1014 EXPECT_EQ("400x500", mode->size().ToString()); 1018 EXPECT_EQ("400x500", mode->size().ToString());
1015 EXPECT_EQ(60.0f, mode->refresh_rate()); 1019 EXPECT_EQ(60.0f, mode->refresh_rate());
1016 EXPECT_FALSE(mode->native()); 1020 EXPECT_FALSE(mode->native());
1017 } 1021 }
1018 { 1022 {
1019 // Best resolution should find itself on the resolutions list. 1023 // Best resolution should find itself on the resolutions list.
1020 test::SetDisplayResolution(display_id, gfx::Size(800, 300)); 1024 test::SetDisplayResolution(display_manager(), display_id,
1025 gfx::Size(800, 300));
1021 display::ManagedDisplayInfo new_native_display_info = 1026 display::ManagedDisplayInfo new_native_display_info =
1022 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); 1027 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500));
1023 display::ManagedDisplayInfo::ManagedDisplayModeList copy = display_modes; 1028 display::ManagedDisplayInfo::ManagedDisplayModeList copy = display_modes;
1024 new_native_display_info.SetManagedDisplayModes(copy); 1029 new_native_display_info.SetManagedDisplayModes(copy);
1025 std::vector<display::ManagedDisplayInfo> new_display_info_list; 1030 std::vector<display::ManagedDisplayInfo> new_display_info_list;
1026 new_display_info_list.push_back(new_native_display_info); 1031 new_display_info_list.push_back(new_native_display_info);
1027 display_manager()->OnNativeDisplaysChanged(new_display_info_list); 1032 display_manager()->OnNativeDisplaysChanged(new_display_info_list);
1028 1033
1029 scoped_refptr<display::ManagedDisplayMode> mode = 1034 scoped_refptr<display::ManagedDisplayMode> mode =
1030 display_manager()->GetSelectedModeForDisplayId(display_id); 1035 display_manager()->GetSelectedModeForDisplayId(display_id);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 EXPECT_EQ("1 0 0", GetCountSummary()); 1086 EXPECT_EQ("1 0 0", GetCountSummary());
1082 reset(); 1087 reset();
1083 1088
1084 UpdateDisplay("200x200/l"); 1089 UpdateDisplay("200x200/l");
1085 EXPECT_EQ("1 0 0", GetCountSummary()); 1090 EXPECT_EQ("1 0 0", GetCountSummary());
1086 1091
1087 // Having the internal display deactivated should restore user rotation. Newly 1092 // Having the internal display deactivated should restore user rotation. Newly
1088 // set rotations should be applied. 1093 // set rotations should be applied.
1089 UpdateDisplay("200x200, 200x200"); 1094 UpdateDisplay("200x200, 200x200");
1090 const int64_t internal_display_id = 1095 const int64_t internal_display_id =
1091 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); 1096 test::DisplayManagerTestApi(display_manager())
1097 .SetFirstDisplayAsInternalDisplay();
1092 1098
1093 display_manager()->SetDisplayRotation(internal_display_id, 1099 display_manager()->SetDisplayRotation(internal_display_id,
1094 display::Display::ROTATE_90, 1100 display::Display::ROTATE_90,
1095 display::Display::ROTATION_SOURCE_USER); 1101 display::Display::ROTATION_SOURCE_USER);
1096 display_manager()->SetDisplayRotation( 1102 display_manager()->SetDisplayRotation(
1097 internal_display_id, display::Display::ROTATE_0, 1103 internal_display_id, display::Display::ROTATE_0,
1098 display::Display::ROTATION_SOURCE_ACTIVE); 1104 display::Display::ROTATION_SOURCE_ACTIVE);
1099 1105
1100 const display::ManagedDisplayInfo info = 1106 const display::ManagedDisplayInfo info =
1101 GetDisplayInfoForId(internal_display_id); 1107 GetDisplayInfoForId(internal_display_id);
1102 EXPECT_EQ(display::Display::ROTATE_0, info.GetActiveRotation()); 1108 EXPECT_EQ(display::Display::ROTATE_0, info.GetActiveRotation());
1103 1109
1104 // Deactivate internal display to simulate Docked Mode. 1110 // Deactivate internal display to simulate Docked Mode.
1105 vector<display::ManagedDisplayInfo> secondary_only; 1111 vector<display::ManagedDisplayInfo> secondary_only;
1106 secondary_only.push_back(GetDisplayInfoAt(1)); 1112 secondary_only.push_back(GetDisplayInfoAt(1));
1107 display_manager()->OnNativeDisplaysChanged(secondary_only); 1113 display_manager()->OnNativeDisplaysChanged(secondary_only);
1108 1114
1109 const display::ManagedDisplayInfo post_removal_info = 1115 const display::ManagedDisplayInfo& post_removal_info =
1110 display_manager()->display_info_[internal_display_id]; 1116 test::DisplayManagerTestApi(display_manager())
1117 .GetInternalManagedDisplayInfo(internal_display_id);
1111 EXPECT_NE(info.GetActiveRotation(), post_removal_info.GetActiveRotation()); 1118 EXPECT_NE(info.GetActiveRotation(), post_removal_info.GetActiveRotation());
1112 EXPECT_EQ(display::Display::ROTATE_90, post_removal_info.GetActiveRotation()); 1119 EXPECT_EQ(display::Display::ROTATE_90, post_removal_info.GetActiveRotation());
1113 1120
1114 display_manager()->SetDisplayRotation( 1121 display_manager()->SetDisplayRotation(
1115 internal_display_id, display::Display::ROTATE_180, 1122 internal_display_id, display::Display::ROTATE_180,
1116 display::Display::ROTATION_SOURCE_ACTIVE); 1123 display::Display::ROTATION_SOURCE_ACTIVE);
1117 const display::ManagedDisplayInfo post_rotation_info = 1124 const display::ManagedDisplayInfo& post_rotation_info =
1118 display_manager()->display_info_[internal_display_id]; 1125 test::DisplayManagerTestApi(display_manager())
1126 .GetInternalManagedDisplayInfo(internal_display_id);
1119 EXPECT_NE(info.GetActiveRotation(), post_rotation_info.GetActiveRotation()); 1127 EXPECT_NE(info.GetActiveRotation(), post_rotation_info.GetActiveRotation());
1120 EXPECT_EQ(display::Display::ROTATE_180, 1128 EXPECT_EQ(display::Display::ROTATE_180,
1121 post_rotation_info.GetActiveRotation()); 1129 post_rotation_info.GetActiveRotation());
1122 } 1130 }
1123 1131
1124 // TODO(msw): Broken on Windows. http://crbug.com/584038 1132 // TODO(msw): Broken on Windows. http://crbug.com/584038
1125 #if defined(OS_CHROMEOS) 1133 #if defined(OS_CHROMEOS)
1126 TEST_P(DisplayManagerTest, UIScale) { 1134 TEST_P(DisplayManagerTest, UIScale) {
1127 test::ScopedDisable125DSFForUIScaling disable; 1135 test::ScopedDisable125DSFForUIScaling disable;
1128 1136
1129 UpdateDisplay("1280x800"); 1137 UpdateDisplay("1280x800");
1130 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1138 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1131 display_manager()->SetDisplayUIScale(display_id, 1.125f); 1139 display_manager()->SetDisplayUIScale(display_id, 1.125f);
1132 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale()); 1140 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale());
1133 display_manager()->SetDisplayUIScale(display_id, 0.8f); 1141 display_manager()->SetDisplayUIScale(display_id, 0.8f);
1134 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1142 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1135 display_manager()->SetDisplayUIScale(display_id, 0.75f); 1143 display_manager()->SetDisplayUIScale(display_id, 0.75f);
1136 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1144 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1137 display_manager()->SetDisplayUIScale(display_id, 0.625f); 1145 display_manager()->SetDisplayUIScale(display_id, 0.625f);
1138 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1146 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1139 1147
1140 test::ScopedSetInternalDisplayId set_internal(display_id); 1148 test::ScopedSetInternalDisplayId set_internal(display_manager(), display_id);
1141 1149
1142 display_manager()->SetDisplayUIScale(display_id, 1.5f); 1150 display_manager()->SetDisplayUIScale(display_id, 1.5f);
1143 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1151 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1144 display_manager()->SetDisplayUIScale(display_id, 1.25f); 1152 display_manager()->SetDisplayUIScale(display_id, 1.25f);
1145 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1153 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1146 display_manager()->SetDisplayUIScale(display_id, 1.125f); 1154 display_manager()->SetDisplayUIScale(display_id, 1.125f);
1147 EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale()); 1155 EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale());
1148 display_manager()->SetDisplayUIScale(display_id, 0.8f); 1156 display_manager()->SetDisplayUIScale(display_id, 0.8f);
1149 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale()); 1157 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale());
1150 display_manager()->SetDisplayUIScale(display_id, 0.75f); 1158 display_manager()->SetDisplayUIScale(display_id, 0.75f);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 native_display_info.SetManagedDisplayModes(mode_list); 1240 native_display_info.SetManagedDisplayModes(mode_list);
1233 1241
1234 std::vector<display::ManagedDisplayInfo> display_info_list; 1242 std::vector<display::ManagedDisplayInfo> display_info_list;
1235 display_info_list.push_back(native_display_info); 1243 display_info_list.push_back(native_display_info);
1236 display_manager()->OnNativeDisplaysChanged(display_info_list); 1244 display_manager()->OnNativeDisplaysChanged(display_info_list);
1237 1245
1238 scoped_refptr<display::ManagedDisplayMode> expected_mode = base_mode; 1246 scoped_refptr<display::ManagedDisplayMode> expected_mode = base_mode;
1239 EXPECT_TRUE(expected_mode->IsEquivalent( 1247 EXPECT_TRUE(expected_mode->IsEquivalent(
1240 display_manager()->GetActiveModeForDisplayId(display_id))); 1248 display_manager()->GetActiveModeForDisplayId(display_id)));
1241 1249
1242 test::ScopedSetInternalDisplayId set_internal(display_id); 1250 test::ScopedSetInternalDisplayId set_internal(display_manager(), display_id);
1243 1251
1244 display_manager()->SetDisplayUIScale(display_id, 1.5f); 1252 display_manager()->SetDisplayUIScale(display_id, 1.5f);
1245 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1253 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1246 EXPECT_TRUE(expected_mode->IsEquivalent( 1254 EXPECT_TRUE(expected_mode->IsEquivalent(
1247 display_manager()->GetActiveModeForDisplayId(display_id))); 1255 display_manager()->GetActiveModeForDisplayId(display_id)));
1248 display_manager()->SetDisplayUIScale(display_id, 1.25f); 1256 display_manager()->SetDisplayUIScale(display_id, 1.25f);
1249 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1257 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1250 EXPECT_TRUE(expected_mode->IsEquivalent( 1258 EXPECT_TRUE(expected_mode->IsEquivalent(
1251 display_manager()->GetActiveModeForDisplayId(display_id))); 1259 display_manager()->GetActiveModeForDisplayId(display_id)));
1252 display_manager()->SetDisplayUIScale(display_id, 1.125f); 1260 display_manager()->SetDisplayUIScale(display_id, 1.125f);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 1305
1298 EXPECT_TRUE(expected_mode->IsEquivalent( 1306 EXPECT_TRUE(expected_mode->IsEquivalent(
1299 display_manager()->GetActiveModeForDisplayId(display_id))); 1307 display_manager()->GetActiveModeForDisplayId(display_id)));
1300 } 1308 }
1301 1309
1302 // TODO(msw): Broken on Windows. http://crbug.com/584038 1310 // TODO(msw): Broken on Windows. http://crbug.com/584038
1303 #if defined(OS_CHROMEOS) 1311 #if defined(OS_CHROMEOS)
1304 TEST_P(DisplayManagerTest, Use125DSFForUIScaling) { 1312 TEST_P(DisplayManagerTest, Use125DSFForUIScaling) {
1305 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1313 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1306 1314
1307 test::ScopedSetInternalDisplayId set_internal(display_id); 1315 test::ScopedSetInternalDisplayId set_internal(display_manager(), display_id);
1308 UpdateDisplay("1920x1080*1.25"); 1316 UpdateDisplay("1920x1080*1.25");
1309 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1317 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1310 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1318 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1311 1319
1312 display_manager()->SetDisplayUIScale(display_id, 0.8f); 1320 display_manager()->SetDisplayUIScale(display_id, 0.8f);
1313 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1321 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1314 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1322 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1315 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString()); 1323 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString());
1316 1324
1317 display_manager()->SetDisplayUIScale(display_id, 0.5f); 1325 display_manager()->SetDisplayUIScale(display_id, 0.5f);
1318 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1326 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1319 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1327 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1320 EXPECT_EQ("960x540", GetDisplayForId(display_id).size().ToString()); 1328 EXPECT_EQ("960x540", GetDisplayForId(display_id).size().ToString());
1321 1329
1322 display_manager()->SetDisplayUIScale(display_id, 1.25f); 1330 display_manager()->SetDisplayUIScale(display_id, 1.25f);
1323 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1331 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1324 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1332 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1325 EXPECT_EQ("2400x1350", GetDisplayForId(display_id).size().ToString()); 1333 EXPECT_EQ("2400x1350", GetDisplayForId(display_id).size().ToString());
1326 } 1334 }
1327 #endif // defined(OS_CHROMEOS) 1335 #endif // defined(OS_CHROMEOS)
1328 1336
1329 // TODO(msw): Broken on Windows. http://crbug.com/584038 1337 // TODO(msw): Broken on Windows. http://crbug.com/584038
1330 #if defined(OS_CHROMEOS) 1338 #if defined(OS_CHROMEOS)
1331 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScaling) { 1339 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScaling) {
1332 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1340 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1333 1341
1334 display_id++; 1342 display_id++;
1335 test::ScopedSetInternalDisplayId set_internal(display_id); 1343 test::ScopedSetInternalDisplayId set_internal(display_manager(), display_id);
1336 1344
1337 // Setup the display modes with UI-scale. 1345 // Setup the display modes with UI-scale.
1338 display::ManagedDisplayInfo native_display_info = 1346 display::ManagedDisplayInfo native_display_info =
1339 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080)); 1347 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080));
1340 native_display_info.set_device_scale_factor(1.25); 1348 native_display_info.set_device_scale_factor(1.25);
1341 1349
1342 const scoped_refptr<display::ManagedDisplayMode>& base_mode( 1350 const scoped_refptr<display::ManagedDisplayMode>& base_mode(
1343 new display::ManagedDisplayMode(gfx::Size(1920, 1080), 60.0f, false, 1351 new display::ManagedDisplayMode(gfx::Size(1920, 1080), 60.0f, false,
1344 false)); 1352 false));
1345 display::ManagedDisplayInfo::ManagedDisplayModeList mode_list = 1353 display::ManagedDisplayInfo::ManagedDisplayModeList mode_list =
(...skipping 11 matching lines...) Expand all
1357 #endif // defined(OS_CHROMEOS) 1365 #endif // defined(OS_CHROMEOS)
1358 1366
1359 // TODO(msw): Broken on Windows. http://crbug.com/584038 1367 // TODO(msw): Broken on Windows. http://crbug.com/584038
1360 #if defined(OS_CHROMEOS) 1368 #if defined(OS_CHROMEOS)
1361 // Don't default to 1.25 DSF if the user already has a prefrence stored for 1369 // Don't default to 1.25 DSF if the user already has a prefrence stored for
1362 // the internal display. 1370 // the internal display.
1363 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScalingNoOverride) { 1371 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScalingNoOverride) {
1364 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1372 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1365 1373
1366 display_id++; 1374 display_id++;
1367 test::ScopedSetInternalDisplayId set_internal(display_id); 1375 test::ScopedSetInternalDisplayId set_internal(display_manager(), display_id);
1368 const gfx::Insets dummy_overscan_insets; 1376 const gfx::Insets dummy_overscan_insets;
1369 display_manager()->RegisterDisplayProperty( 1377 display_manager()->RegisterDisplayProperty(
1370 display_id, display::Display::ROTATE_0, 1.0f, &dummy_overscan_insets, 1378 display_id, display::Display::ROTATE_0, 1.0f, &dummy_overscan_insets,
1371 gfx::Size(), 1.0f, ui::ColorCalibrationProfile()); 1379 gfx::Size(), 1.0f, ui::ColorCalibrationProfile());
1372 1380
1373 // Setup the display modes with UI-scale. 1381 // Setup the display modes with UI-scale.
1374 display::ManagedDisplayInfo native_display_info = 1382 display::ManagedDisplayInfo native_display_info =
1375 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080)); 1383 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080));
1376 native_display_info.set_device_scale_factor(1.25); 1384 native_display_info.set_device_scale_factor(1.25);
1377 1385
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 EXPECT_EQ("800x400", info.display_modes()[1]->size().ToString()); 1419 EXPECT_EQ("800x400", info.display_modes()[1]->size().ToString());
1412 EXPECT_FALSE(info.display_modes()[1]->native()); 1420 EXPECT_FALSE(info.display_modes()[1]->native());
1413 EXPECT_EQ( 1421 EXPECT_EQ(
1414 "400x200", 1422 "400x200",
1415 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); 1423 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString());
1416 scoped_refptr<display::ManagedDisplayMode> active_mode = 1424 scoped_refptr<display::ManagedDisplayMode> active_mode =
1417 display_manager()->GetActiveModeForDisplayId(unified_id); 1425 display_manager()->GetActiveModeForDisplayId(unified_id);
1418 EXPECT_EQ(1.0f, active_mode->ui_scale()); 1426 EXPECT_EQ(1.0f, active_mode->ui_scale());
1419 EXPECT_EQ("400x200", active_mode->size().ToString()); 1427 EXPECT_EQ("400x200", active_mode->size().ToString());
1420 1428
1421 EXPECT_TRUE(test::SetDisplayResolution(unified_id, gfx::Size(800, 400))); 1429 EXPECT_TRUE(test::SetDisplayResolution(display_manager(), unified_id,
1430 gfx::Size(800, 400)));
1422 EXPECT_EQ( 1431 EXPECT_EQ(
1423 "800x400", 1432 "800x400",
1424 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); 1433 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString());
1425 1434
1426 active_mode = display_manager()->GetActiveModeForDisplayId(unified_id); 1435 active_mode = display_manager()->GetActiveModeForDisplayId(unified_id);
1427 EXPECT_EQ(1.0f, active_mode->ui_scale()); 1436 EXPECT_EQ(1.0f, active_mode->ui_scale());
1428 EXPECT_EQ("800x400", active_mode->size().ToString()); 1437 EXPECT_EQ("800x400", active_mode->size().ToString());
1429 1438
1430 // resolution change will not persist in unified desktop mode. 1439 // resolution change will not persist in unified desktop mode.
1431 UpdateDisplay("600x600, 200x200"); 1440 UpdateDisplay("600x600, 200x200");
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 return; 1537 return;
1529 1538
1530 UpdateDisplay("300x400,400x500"); 1539 UpdateDisplay("300x400,400x500");
1531 1540
1532 test::MirrorWindowTestApi test_api; 1541 test::MirrorWindowTestApi test_api;
1533 EXPECT_EQ(nullptr, test_api.GetHost()); 1542 EXPECT_EQ(nullptr, test_api.GetHost());
1534 1543
1535 TestDisplayObserver display_observer; 1544 TestDisplayObserver display_observer;
1536 display::Screen::GetScreen()->AddObserver(&display_observer); 1545 display::Screen::GetScreen()->AddObserver(&display_observer);
1537 1546
1538 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 1547 display_manager()->SetMultiDisplayMode(DisplayManager::MIRRORING);
1539 display_manager->SetMultiDisplayMode(DisplayManager::MIRRORING); 1548 display_manager()->UpdateDisplays();
1540 display_manager->UpdateDisplays();
1541 RunAllPendingInMessageLoop(); 1549 RunAllPendingInMessageLoop();
1542 EXPECT_TRUE(display_observer.changed_and_reset()); 1550 EXPECT_TRUE(display_observer.changed_and_reset());
1543 EXPECT_EQ(1U, display_manager->GetNumDisplays()); 1551 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
1544 EXPECT_EQ( 1552 EXPECT_EQ(
1545 "0,0 300x400", 1553 "0,0 300x400",
1546 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString()); 1554 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString());
1547 EXPECT_EQ("400x500", test_api.GetHost()->GetBounds().size().ToString()); 1555 EXPECT_EQ("400x500", test_api.GetHost()->GetBounds().size().ToString());
1548 EXPECT_EQ("300x400", 1556 EXPECT_EQ("300x400",
1549 test_api.GetHost()->window()->bounds().size().ToString()); 1557 test_api.GetHost()->window()->bounds().size().ToString());
1550 EXPECT_TRUE(display_manager->IsInMirrorMode()); 1558 EXPECT_TRUE(display_manager()->IsInMirrorMode());
1551 1559
1552 display_manager->SetMirrorMode(false); 1560 display_manager()->SetMirrorMode(false);
1553 EXPECT_TRUE(display_observer.changed_and_reset()); 1561 EXPECT_TRUE(display_observer.changed_and_reset());
1554 EXPECT_EQ(nullptr, test_api.GetHost()); 1562 EXPECT_EQ(nullptr, test_api.GetHost());
1555 EXPECT_EQ(2U, display_manager->GetNumDisplays()); 1563 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
1556 EXPECT_FALSE(display_manager->IsInMirrorMode()); 1564 EXPECT_FALSE(display_manager()->IsInMirrorMode());
1557 1565
1558 // Make sure the mirror window has the pixel size of the 1566 // Make sure the mirror window has the pixel size of the
1559 // source display. 1567 // source display.
1560 display_manager->SetMirrorMode(true); 1568 display_manager()->SetMirrorMode(true);
1561 EXPECT_TRUE(display_observer.changed_and_reset()); 1569 EXPECT_TRUE(display_observer.changed_and_reset());
1562 1570
1563 UpdateDisplay("300x400@0.5,400x500"); 1571 UpdateDisplay("300x400@0.5,400x500");
1564 EXPECT_FALSE(display_observer.changed_and_reset()); 1572 EXPECT_FALSE(display_observer.changed_and_reset());
1565 EXPECT_EQ("300x400", 1573 EXPECT_EQ("300x400",
1566 test_api.GetHost()->window()->bounds().size().ToString()); 1574 test_api.GetHost()->window()->bounds().size().ToString());
1567 1575
1568 UpdateDisplay("310x410*2,400x500"); 1576 UpdateDisplay("310x410*2,400x500");
1569 EXPECT_FALSE(display_observer.changed_and_reset()); 1577 EXPECT_FALSE(display_observer.changed_and_reset());
1570 EXPECT_EQ("310x410", 1578 EXPECT_EQ("310x410",
(...skipping 15 matching lines...) Expand all
1586 EXPECT_EQ("400x600", 1594 EXPECT_EQ("400x600",
1587 test_api.GetHost()->window()->bounds().size().ToString()); 1595 test_api.GetHost()->window()->bounds().size().ToString());
1588 1596
1589 display::Screen::GetScreen()->RemoveObserver(&display_observer); 1597 display::Screen::GetScreen()->RemoveObserver(&display_observer);
1590 } 1598 }
1591 1599
1592 TEST_P(DisplayManagerTest, RotateInSoftwareMirroring) { 1600 TEST_P(DisplayManagerTest, RotateInSoftwareMirroring) {
1593 if (!SupportsMultipleDisplays()) 1601 if (!SupportsMultipleDisplays())
1594 return; 1602 return;
1595 1603
1596 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
1597 UpdateDisplay("600x400,500x300"); 1604 UpdateDisplay("600x400,500x300");
1598 display_manager->SetMirrorMode(true); 1605 display_manager()->SetMirrorMode(true);
1599 1606
1600 EXPECT_EQ(1U, display_manager->GetNumDisplays()); 1607 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
1601 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1608 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1602 display_manager->SetDisplayRotation(primary_id, display::Display::ROTATE_180, 1609 display_manager()->SetDisplayRotation(
1603 display::Display::ROTATION_SOURCE_ACTIVE); 1610 primary_id, display::Display::ROTATE_180,
1604 display_manager->SetMirrorMode(false); 1611 display::Display::ROTATION_SOURCE_ACTIVE);
1612 display_manager()->SetMirrorMode(false);
1605 } 1613 }
1606 1614
1607 TEST_P(DisplayManagerTest, SingleDisplayToSoftwareMirroring) { 1615 TEST_P(DisplayManagerTest, SingleDisplayToSoftwareMirroring) {
1608 if (!SupportsMultipleDisplays()) 1616 if (!SupportsMultipleDisplays())
1609 return; 1617 return;
1610 UpdateDisplay("600x400"); 1618 UpdateDisplay("600x400");
1611 1619
1612 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 1620 display_manager()->SetMultiDisplayMode(DisplayManager::MIRRORING);
1613 display_manager->SetMultiDisplayMode(DisplayManager::MIRRORING);
1614 UpdateDisplay("600x400,600x400"); 1621 UpdateDisplay("600x400,600x400");
1615 1622
1616 EXPECT_TRUE(display_manager->IsInMirrorMode()); 1623 EXPECT_TRUE(display_manager()->IsInMirrorMode());
1617 EXPECT_EQ(1U, display_manager->GetNumDisplays()); 1624 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
1618 WindowTreeHostManager* window_tree_host_manager = 1625 WindowTreeHostManager* window_tree_host_manager =
1619 ash::Shell::GetInstance()->window_tree_host_manager(); 1626 ash::Shell::GetInstance()->window_tree_host_manager();
1620 EXPECT_TRUE( 1627 EXPECT_TRUE(
1621 window_tree_host_manager->mirror_window_controller()->GetWindow()); 1628 window_tree_host_manager->mirror_window_controller()->GetWindow());
1622 1629
1623 UpdateDisplay("600x400"); 1630 UpdateDisplay("600x400");
1624 EXPECT_FALSE(display_manager->IsInMirrorMode()); 1631 EXPECT_FALSE(display_manager()->IsInMirrorMode());
1625 EXPECT_EQ(1U, display_manager->GetNumDisplays()); 1632 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
1626 EXPECT_FALSE( 1633 EXPECT_FALSE(
1627 window_tree_host_manager->mirror_window_controller()->GetWindow()); 1634 window_tree_host_manager->mirror_window_controller()->GetWindow());
1628 } 1635 }
1629 1636
1630 #if defined(OS_CHROMEOS) 1637 #if defined(OS_CHROMEOS)
1631 // Make sure this does not cause any crashes. See http://crbug.com/412910 1638 // Make sure this does not cause any crashes. See http://crbug.com/412910
1632 // This test is limited to OS_CHROMEOS because CursorCompositingEnabled is only 1639 // This test is limited to OS_CHROMEOS because CursorCompositingEnabled is only
1633 // for ChromeOS. 1640 // for ChromeOS.
1634 TEST_P(DisplayManagerTest, SoftwareMirroringWithCompositingCursor) { 1641 TEST_P(DisplayManagerTest, SoftwareMirroringWithCompositingCursor) {
1635 if (!SupportsMultipleDisplays()) 1642 if (!SupportsMultipleDisplays())
1636 return; 1643 return;
1637 1644
1638 UpdateDisplay("300x400,400x500"); 1645 UpdateDisplay("300x400,400x500");
1639 1646
1640 test::MirrorWindowTestApi test_api; 1647 test::MirrorWindowTestApi test_api;
1641 EXPECT_EQ(nullptr, test_api.GetHost()); 1648 EXPECT_EQ(nullptr, test_api.GetHost());
1642 1649
1643 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
1644 display::ManagedDisplayInfo secondary_info = 1650 display::ManagedDisplayInfo secondary_info =
1645 display_manager->GetDisplayInfo(ScreenUtil::GetSecondaryDisplay().id()); 1651 display_manager()->GetDisplayInfo(
1652 display_manager()->GetSecondaryDisplay().id());
1646 1653
1647 display_manager->SetSoftwareMirroring(true); 1654 display_manager()->SetSoftwareMirroring(true);
1648 display_manager->UpdateDisplays(); 1655 display_manager()->UpdateDisplays();
1649 1656
1650 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1657 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1651 EXPECT_FALSE(root_windows[0]->Contains(test_api.GetCursorWindow())); 1658 EXPECT_FALSE(root_windows[0]->Contains(test_api.GetCursorWindow()));
1652 1659
1653 Shell::GetInstance()->SetCursorCompositingEnabled(true); 1660 Shell::GetInstance()->SetCursorCompositingEnabled(true);
1654 1661
1655 EXPECT_TRUE(root_windows[0]->Contains(test_api.GetCursorWindow())); 1662 EXPECT_TRUE(root_windows[0]->Contains(test_api.GetCursorWindow()));
1656 1663
1657 // Removes the first display and keeps the second one. 1664 // Removes the first display and keeps the second one.
1658 display_manager->SetSoftwareMirroring(false); 1665 display_manager()->SetSoftwareMirroring(false);
1659 std::vector<display::ManagedDisplayInfo> new_info_list; 1666 std::vector<display::ManagedDisplayInfo> new_info_list;
1660 new_info_list.push_back(secondary_info); 1667 new_info_list.push_back(secondary_info);
1661 display_manager->OnNativeDisplaysChanged(new_info_list); 1668 display_manager()->OnNativeDisplaysChanged(new_info_list);
1662 1669
1663 root_windows = Shell::GetAllRootWindows(); 1670 root_windows = Shell::GetAllRootWindows();
1664 EXPECT_TRUE(root_windows[0]->Contains(test_api.GetCursorWindow())); 1671 EXPECT_TRUE(root_windows[0]->Contains(test_api.GetCursorWindow()));
1665 1672
1666 Shell::GetInstance()->SetCursorCompositingEnabled(false); 1673 Shell::GetInstance()->SetCursorCompositingEnabled(false);
1667 } 1674 }
1668 #endif // OS_CHROMEOS 1675 #endif // OS_CHROMEOS
1669 1676
1670 TEST_P(DisplayManagerTest, MirroredLayout) { 1677 TEST_P(DisplayManagerTest, MirroredLayout) {
1671 if (!SupportsMultipleDisplays()) 1678 if (!SupportsMultipleDisplays())
1672 return; 1679 return;
1673 1680
1674 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
1675 UpdateDisplay("500x500,400x400"); 1681 UpdateDisplay("500x500,400x400");
1676 EXPECT_FALSE(display_manager->GetCurrentDisplayLayout().mirrored); 1682 EXPECT_FALSE(display_manager()->GetCurrentDisplayLayout().mirrored);
1677 EXPECT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); 1683 EXPECT_EQ(2, display::Screen::GetScreen()->GetNumDisplays());
1678 EXPECT_EQ(2U, display_manager->num_connected_displays()); 1684 EXPECT_EQ(2U, display_manager()->num_connected_displays());
1679 1685
1680 UpdateDisplay("1+0-500x500,1+0-500x500"); 1686 UpdateDisplay("1+0-500x500,1+0-500x500");
1681 EXPECT_TRUE(display_manager->GetCurrentDisplayLayout().mirrored); 1687 EXPECT_TRUE(display_manager()->GetCurrentDisplayLayout().mirrored);
1682 EXPECT_EQ(1, display::Screen::GetScreen()->GetNumDisplays()); 1688 EXPECT_EQ(1, display::Screen::GetScreen()->GetNumDisplays());
1683 EXPECT_EQ(2U, display_manager->num_connected_displays()); 1689 EXPECT_EQ(2U, display_manager()->num_connected_displays());
1684 1690
1685 UpdateDisplay("500x500,500x500"); 1691 UpdateDisplay("500x500,500x500");
1686 EXPECT_FALSE(display_manager->GetCurrentDisplayLayout().mirrored); 1692 EXPECT_FALSE(display_manager()->GetCurrentDisplayLayout().mirrored);
1687 EXPECT_EQ(2, display::Screen::GetScreen()->GetNumDisplays()); 1693 EXPECT_EQ(2, display::Screen::GetScreen()->GetNumDisplays());
1688 EXPECT_EQ(2U, display_manager->num_connected_displays()); 1694 EXPECT_EQ(2U, display_manager()->num_connected_displays());
1689 } 1695 }
1690 1696
1691 TEST_P(DisplayManagerTest, InvertLayout) { 1697 TEST_P(DisplayManagerTest, InvertLayout) {
1692 EXPECT_EQ("left, 0", 1698 EXPECT_EQ("left, 0",
1693 display::DisplayPlacement(display::DisplayPlacement::RIGHT, 0) 1699 display::DisplayPlacement(display::DisplayPlacement::RIGHT, 0)
1694 .Swap() 1700 .Swap()
1695 .ToString()); 1701 .ToString());
1696 EXPECT_EQ("left, -100", 1702 EXPECT_EQ("left, -100",
1697 display::DisplayPlacement(display::DisplayPlacement::RIGHT, 100) 1703 display::DisplayPlacement(display::DisplayPlacement::RIGHT, 100)
1698 .Swap() 1704 .Swap()
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 EXPECT_EQ("top, 80", 1745 EXPECT_EQ("top, 80",
1740 display::DisplayPlacement(display::DisplayPlacement::BOTTOM, -80) 1746 display::DisplayPlacement(display::DisplayPlacement::BOTTOM, -80)
1741 .Swap() 1747 .Swap()
1742 .ToString()); 1748 .ToString());
1743 } 1749 }
1744 1750
1745 TEST_P(DisplayManagerTest, NotifyPrimaryChange) { 1751 TEST_P(DisplayManagerTest, NotifyPrimaryChange) {
1746 if (!SupportsMultipleDisplays()) 1752 if (!SupportsMultipleDisplays())
1747 return; 1753 return;
1748 UpdateDisplay("500x500,500x500"); 1754 UpdateDisplay("500x500,500x500");
1749 test::SwapPrimaryDisplay(); 1755 SwapPrimaryDisplay();
1750 reset(); 1756 reset();
1751 UpdateDisplay("500x500"); 1757 UpdateDisplay("500x500");
1752 EXPECT_FALSE(changed_metrics() & 1758 EXPECT_FALSE(changed_metrics() &
1753 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); 1759 display::DisplayObserver::DISPLAY_METRIC_BOUNDS);
1754 EXPECT_FALSE(changed_metrics() & 1760 EXPECT_FALSE(changed_metrics() &
1755 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); 1761 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
1756 EXPECT_TRUE(changed_metrics() & 1762 EXPECT_TRUE(changed_metrics() &
1757 display::DisplayObserver::DISPLAY_METRIC_PRIMARY); 1763 display::DisplayObserver::DISPLAY_METRIC_PRIMARY);
1758 1764
1759 UpdateDisplay("500x500,500x500"); 1765 UpdateDisplay("500x500,500x500");
1760 test::SwapPrimaryDisplay(); 1766 SwapPrimaryDisplay();
1761 UpdateDisplay("500x400"); 1767 UpdateDisplay("500x400");
1762 EXPECT_TRUE(changed_metrics() & 1768 EXPECT_TRUE(changed_metrics() &
1763 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); 1769 display::DisplayObserver::DISPLAY_METRIC_BOUNDS);
1764 EXPECT_TRUE(changed_metrics() & 1770 EXPECT_TRUE(changed_metrics() &
1765 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); 1771 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
1766 EXPECT_TRUE(changed_metrics() & 1772 EXPECT_TRUE(changed_metrics() &
1767 display::DisplayObserver::DISPLAY_METRIC_PRIMARY); 1773 display::DisplayObserver::DISPLAY_METRIC_PRIMARY);
1768 } 1774 }
1769 1775
1770 TEST_P(DisplayManagerTest, NotifyPrimaryChangeUndock) { 1776 TEST_P(DisplayManagerTest, NotifyPrimaryChangeUndock) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1859 UpdateDisplay("500x300,400x500"); 1865 UpdateDisplay("500x300,400x500");
1860 // 400 * 300 / 500 + 500 ~= 739. 1866 // 400 * 300 / 500 + 500 ~= 739.
1861 EXPECT_EQ(gfx::Size(739, 300), screen->GetPrimaryDisplay().size()); 1867 EXPECT_EQ(gfx::Size(739, 300), screen->GetPrimaryDisplay().size());
1862 1868
1863 // The default should fit to the internal display. 1869 // The default should fit to the internal display.
1864 std::vector<display::ManagedDisplayInfo> display_info_list; 1870 std::vector<display::ManagedDisplayInfo> display_info_list;
1865 display_info_list.push_back(CreateDisplayInfo(10, gfx::Rect(0, 0, 500, 300))); 1871 display_info_list.push_back(CreateDisplayInfo(10, gfx::Rect(0, 0, 500, 300)));
1866 display_info_list.push_back( 1872 display_info_list.push_back(
1867 CreateDisplayInfo(11, gfx::Rect(500, 0, 400, 500))); 1873 CreateDisplayInfo(11, gfx::Rect(500, 0, 400, 500)));
1868 { 1874 {
1869 test::ScopedSetInternalDisplayId set_internal(11); 1875 test::ScopedSetInternalDisplayId set_internal(display_manager(), 11);
1870 display_manager()->OnNativeDisplaysChanged(display_info_list); 1876 display_manager()->OnNativeDisplaysChanged(display_info_list);
1871 // 500 * 500 / 300 + 400 ~= 1233. 1877 // 500 * 500 / 300 + 400 ~= 1233.
1872 EXPECT_EQ(gfx::Size(1233, 500), screen->GetPrimaryDisplay().size()); 1878 EXPECT_EQ(gfx::Size(1233, 500), screen->GetPrimaryDisplay().size());
1873 } 1879 }
1874 1880
1875 // Switch to 3 displays. 1881 // Switch to 3 displays.
1876 UpdateDisplay("500x300,400x500,500x300"); 1882 UpdateDisplay("500x300,400x500,500x300");
1877 EXPECT_EQ(gfx::Size(1239, 300), screen->GetPrimaryDisplay().size()); 1883 EXPECT_EQ(gfx::Size(1239, 300), screen->GetPrimaryDisplay().size());
1878 1884
1879 // Switch back to extended desktop. 1885 // Switch back to extended desktop.
1880 display_manager()->SetUnifiedDesktopEnabled(false); 1886 display_manager()->SetUnifiedDesktopEnabled(false);
1881 EXPECT_EQ(gfx::Size(500, 300), screen->GetPrimaryDisplay().size()); 1887 EXPECT_EQ(gfx::Size(500, 300), screen->GetPrimaryDisplay().size());
1882 EXPECT_EQ(gfx::Size(400, 500), ScreenUtil::GetSecondaryDisplay().size()); 1888 EXPECT_EQ(gfx::Size(400, 500),
1883 EXPECT_EQ(gfx::Size(500, 300), 1889 display_manager()->GetSecondaryDisplay().size());
1884 display_manager() 1890 EXPECT_EQ(
1885 ->GetDisplayForId(ScreenUtil::GetSecondaryDisplay().id() + 1) 1891 gfx::Size(500, 300),
1886 .size()); 1892 display_manager()
1893 ->GetDisplayForId(display_manager()->GetSecondaryDisplay().id() + 1)
1894 .size());
1887 } 1895 }
1888 1896
1889 TEST_P(DisplayManagerTest, UnifiedDesktopWithHardwareMirroring) { 1897 TEST_P(DisplayManagerTest, UnifiedDesktopWithHardwareMirroring) {
1890 if (!SupportsMultipleDisplays()) 1898 if (!SupportsMultipleDisplays())
1891 return; 1899 return;
1892 // Don't check root window destruction in unified mode. 1900 // Don't check root window destruction in unified mode.
1893 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 1901 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
1894 1902
1895 // Enter to hardware mirroring. 1903 // Enter to hardware mirroring.
1896 display::ManagedDisplayInfo d1(1, "", false); 1904 display::ManagedDisplayInfo d1(1, "", false);
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
2125 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500)); 2133 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500));
2126 const display::ManagedDisplayInfo external_display_info = 2134 const display::ManagedDisplayInfo external_display_info =
2127 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); 2135 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100));
2128 std::vector<display::ManagedDisplayInfo> display_info_list; 2136 std::vector<display::ManagedDisplayInfo> display_info_list;
2129 2137
2130 // software mirroring. 2138 // software mirroring.
2131 display_info_list.push_back(internal_display_info); 2139 display_info_list.push_back(internal_display_info);
2132 display_info_list.push_back(external_display_info); 2140 display_info_list.push_back(external_display_info);
2133 display_manager()->OnNativeDisplaysChanged(display_info_list); 2141 display_manager()->OnNativeDisplaysChanged(display_info_list);
2134 const int64_t internal_display_id = 2142 const int64_t internal_display_id =
2135 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); 2143 test::DisplayManagerTestApi(display_manager())
2144 .SetFirstDisplayAsInternalDisplay();
2136 EXPECT_EQ(internal_id, internal_display_id); 2145 EXPECT_EQ(internal_id, internal_display_id);
2137 2146
2138 display_info_list.clear(); 2147 display_info_list.clear();
2139 display_info_list.push_back(external_display_info); 2148 display_info_list.push_back(external_display_info);
2140 display_manager()->OnNativeDisplaysChanged(display_info_list); 2149 display_manager()->OnNativeDisplaysChanged(display_info_list);
2141 EXPECT_EQ(1U, display_manager()->active_display_list().size()); 2150 EXPECT_EQ(1U, display_manager()->active_display_list().size());
2142 2151
2143 EXPECT_TRUE(display_manager()->IsActiveDisplayId(external_id)); 2152 EXPECT_TRUE(display_manager()->IsActiveDisplayId(external_id));
2144 EXPECT_FALSE(display_manager()->IsActiveDisplayId(internal_id)); 2153 EXPECT_FALSE(display_manager()->IsActiveDisplayId(internal_id));
2145 2154
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2226 } 2235 }
2227 2236
2228 gfx::FontRenderParams::Hinting GetFontHintingParams() { 2237 gfx::FontRenderParams::Hinting GetFontHintingParams() {
2229 gfx::FontRenderParams params = 2238 gfx::FontRenderParams params =
2230 gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), nullptr); 2239 gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), nullptr);
2231 return params.hinting; 2240 return params.hinting;
2232 } 2241 }
2233 2242
2234 } // namespace 2243 } // namespace
2235 2244
2236 typedef testing::Test DisplayManagerFontTest; 2245 using DisplayManagerFontTest = testing::Test;
2237 2246
2238 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100Internal) { 2247 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100Internal) {
2239 FontTestHelper helper(1.0f, FontTestHelper::INTERNAL); 2248 FontTestHelper helper(1.0f, FontTestHelper::INTERNAL);
2240 ASSERT_DOUBLE_EQ( 2249 ASSERT_DOUBLE_EQ(
2241 1.0f, 2250 1.0f,
2242 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 2251 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
2243 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); 2252 EXPECT_FALSE(IsTextSubpixelPositioningEnabled());
2244 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); 2253 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
2245 } 2254 }
2246 2255
2247 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125Internal) { 2256 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125Internal) {
2248 test::ScopedDisable125DSFForUIScaling disable; 2257 test::ScopedDisable125DSFForUIScaling disable;
2249 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL); 2258 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL);
2250 ASSERT_DOUBLE_EQ( 2259 ASSERT_DOUBLE_EQ(
2251 1.25f, 2260 1.25f,
2252 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 2261 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
2253 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); 2262 EXPECT_TRUE(IsTextSubpixelPositioningEnabled());
2254 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); 2263 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
2255 } 2264 }
2256 2265
2257 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200Internal) { 2266 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200Internal) {
2258 FontTestHelper helper(2.0f, FontTestHelper::INTERNAL); 2267 FontTestHelper helper(2.0f, FontTestHelper::INTERNAL);
2259 ASSERT_DOUBLE_EQ( 2268 ASSERT_DOUBLE_EQ(
2260 2.0f, 2269 2.0f,
2261 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 2270 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
2262 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); 2271 EXPECT_TRUE(IsTextSubpixelPositioningEnabled());
2263 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); 2272 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
2264 2273
2265 Shell::GetInstance()->display_manager()->SetDisplayUIScale( 2274 helper.display_manager()->SetDisplayUIScale(
2266 display::Screen::GetScreen()->GetPrimaryDisplay().id(), 2.0f); 2275 display::Screen::GetScreen()->GetPrimaryDisplay().id(), 2.0f);
2267 2276
2268 ASSERT_DOUBLE_EQ( 2277 ASSERT_DOUBLE_EQ(
2269 1.0f, 2278 1.0f,
2270 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 2279 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
2271 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); 2280 EXPECT_FALSE(IsTextSubpixelPositioningEnabled());
2272 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); 2281 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
2273 } 2282 }
2274 2283
2275 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100External) { 2284 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100External) {
(...skipping 25 matching lines...) Expand all
2301 2310
2302 TEST_F(DisplayManagerFontTest, 2311 TEST_F(DisplayManagerFontTest,
2303 TextSubpixelPositioningWithDsf125InternalWithScaling) { 2312 TextSubpixelPositioningWithDsf125InternalWithScaling) {
2304 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL); 2313 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL);
2305 ASSERT_DOUBLE_EQ( 2314 ASSERT_DOUBLE_EQ(
2306 1.0f, 2315 1.0f,
2307 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 2316 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
2308 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); 2317 EXPECT_FALSE(IsTextSubpixelPositioningEnabled());
2309 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); 2318 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
2310 2319
2311 Shell::GetInstance()->display_manager()->SetDisplayUIScale( 2320 helper.display_manager()->SetDisplayUIScale(
2312 display::Screen::GetScreen()->GetPrimaryDisplay().id(), 0.8f); 2321 display::Screen::GetScreen()->GetPrimaryDisplay().id(), 0.8f);
2313 2322
2314 ASSERT_DOUBLE_EQ( 2323 ASSERT_DOUBLE_EQ(
2315 1.25f, 2324 1.25f,
2316 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 2325 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
2317 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); 2326 EXPECT_TRUE(IsTextSubpixelPositioningEnabled());
2318 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); 2327 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
2319 } 2328 }
2320 2329
2321 TEST_P(DisplayManagerTest, CheckInitializationOfRotationProperty) { 2330 TEST_P(DisplayManagerTest, CheckInitializationOfRotationProperty) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2372 const display::DisplayLayout& stored = 2381 const display::DisplayLayout& stored =
2373 layout_store->GetRegisteredDisplayLayout(list); 2382 layout_store->GetRegisteredDisplayLayout(list);
2374 2383
2375 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id); 2384 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id);
2376 EXPECT_EQ(id2, stored.placement_list[0].display_id); 2385 EXPECT_EQ(id2, stored.placement_list[0].display_id);
2377 } 2386 }
2378 2387
2379 #endif // OS_CHROMEOS 2388 #endif // OS_CHROMEOS
2380 2389
2381 } // namespace ash 2390 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_manager.cc ('k') | ash/display/extended_mouse_warp_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698