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

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

Issue 2445583002: Relocate display_manager from ash to ui (Closed)
Patch Set: fix windows build Created 4 years, 1 month 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 "ui/display/manager/display_manager.h"
6 6
7 #include "ash/accelerators/accelerator_commands_aura.h" 7 #include "ash/accelerators/accelerator_commands_aura.h"
8 #include "ash/common/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"
11 #include "ash/display/display_util.h" 11 #include "ash/display/display_util.h"
12 #include "ash/display/mirror_window_controller.h" 12 #include "ash/display/mirror_window_controller.h"
13 #include "ash/display/window_tree_host_manager.h" 13 #include "ash/display/window_tree_host_manager.h"
14 #include "ash/screen_util.h" 14 #include "ash/screen_util.h"
15 #include "ash/shell.h" 15 #include "ash/shell.h"
16 #include "ash/test/ash_md_test_base.h" 16 #include "ash/test/ash_md_test_base.h"
17 #include "ash/test/ash_test_base.h" 17 #include "ash/test/ash_test_base.h"
18 #include "ash/test/display_manager_test_api.h"
19 #include "ash/test/mirror_window_test_api.h" 18 #include "ash/test/mirror_window_test_api.h"
20 #include "ash/wm/window_state_aura.h" 19 #include "ash/wm/window_state_aura.h"
21 #include "base/command_line.h" 20 #include "base/command_line.h"
22 #include "base/format_macros.h" 21 #include "base/format_macros.h"
23 #include "base/strings/string_number_conversions.h" 22 #include "base/strings/string_number_conversions.h"
24 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
25 #include "build/build_config.h" 24 #include "build/build_config.h"
26 #include "grit/ash_strings.h" 25 #include "grit/ash_strings.h"
27 #include "ui/aura/client/aura_constants.h" 26 #include "ui/aura/client/aura_constants.h"
28 #include "ui/aura/env.h" 27 #include "ui/aura/env.h"
29 #include "ui/aura/window_observer.h" 28 #include "ui/aura/window_observer.h"
30 #include "ui/aura/window_tree_host.h" 29 #include "ui/aura/window_tree_host.h"
31 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
32 #include "ui/display/display.h" 31 #include "ui/display/display.h"
33 #include "ui/display/display_observer.h" 32 #include "ui/display/display_observer.h"
34 #include "ui/display/display_switches.h" 33 #include "ui/display/display_switches.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"
37 #include "ui/display/manager/display_manager_utilities.h" 36 #include "ui/display/manager/display_manager_utilities.h"
38 #include "ui/display/manager/managed_display_info.h" 37 #include "ui/display/manager/managed_display_info.h"
39 #include "ui/display/screen.h" 38 #include "ui/display/screen.h"
39 #include "ui/display/test/display_manager_test_api.h"
40 #include "ui/events/test/event_generator.h" 40 #include "ui/events/test/event_generator.h"
41 #include "ui/gfx/font_render_params.h" 41 #include "ui/gfx/font_render_params.h"
42 42
43 namespace ash { 43 namespace ash {
44 44
45 using std::vector; 45 using std::vector;
46 using std::string; 46 using std::string;
47 47
48 using base::StringPrintf; 48 using base::StringPrintf;
49 49
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 display_manager()->GetDisplayAt(1).bounds().ToString()); 347 display_manager()->GetDisplayAt(1).bounds().ToString());
348 EXPECT_EQ("20,680 400x300", 348 EXPECT_EQ("20,680 400x300",
349 display_manager()->GetDisplayAt(2).bounds().ToString()); 349 display_manager()->GetDisplayAt(2).bounds().ToString());
350 } 350 }
351 351
352 TEST_P(DisplayManagerTest, LayoutMorethanThreeDisplaysTest) { 352 TEST_P(DisplayManagerTest, LayoutMorethanThreeDisplaysTest) {
353 if (!SupportsMultipleDisplays()) 353 if (!SupportsMultipleDisplays())
354 return; 354 return;
355 355
356 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 356 int64_t primary_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
357 display::DisplayIdList list = ash::test::CreateDisplayIdListN( 357 display::DisplayIdList list = display::test::CreateDisplayIdListN(
358 3, primary_id, primary_id + 1, primary_id + 2); 358 3, primary_id, primary_id + 1, primary_id + 2);
359 { 359 {
360 // Layout: [2] 360 // Layout: [2]
361 // [1][P] 361 // [1][P]
362 display::DisplayLayoutBuilder builder(primary_id); 362 display::DisplayLayoutBuilder builder(primary_id);
363 builder.AddDisplayPlacement(list[1], primary_id, 363 builder.AddDisplayPlacement(list[1], primary_id,
364 display::DisplayPlacement::LEFT, 10); 364 display::DisplayPlacement::LEFT, 10);
365 builder.AddDisplayPlacement(list[2], list[1], 365 builder.AddDisplayPlacement(list[2], list[1],
366 display::DisplayPlacement::TOP, 10); 366 display::DisplayPlacement::TOP, 10);
367 display_manager()->layout_store()->RegisterLayoutForDisplayIdList( 367 display_manager()->layout_store()->RegisterLayoutForDisplayIdList(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 418
419 EXPECT_EQ("0,0 640x480", 419 EXPECT_EQ("0,0 640x480",
420 display_manager()->GetDisplayAt(0).bounds().ToString()); 420 display_manager()->GetDisplayAt(0).bounds().ToString());
421 EXPECT_EQ("20,780 320x200", 421 EXPECT_EQ("20,780 320x200",
422 display_manager()->GetDisplayAt(1).bounds().ToString()); 422 display_manager()->GetDisplayAt(1).bounds().ToString());
423 EXPECT_EQ("10,480 400x300", 423 EXPECT_EQ("10,480 400x300",
424 display_manager()->GetDisplayAt(2).bounds().ToString()); 424 display_manager()->GetDisplayAt(2).bounds().ToString());
425 } 425 }
426 426
427 { 427 {
428 list = ash::test::CreateDisplayIdListN(5, primary_id, primary_id + 1, 428 list = display::test::CreateDisplayIdListN(5, primary_id, primary_id + 1,
429 primary_id + 2, primary_id + 3, 429 primary_id + 2, primary_id + 3,
430 primary_id + 4); 430 primary_id + 4);
431 // Layout: [P][2] 431 // Layout: [P][2]
432 // [3][4] 432 // [3][4]
433 // [1] 433 // [1]
434 display::DisplayLayoutBuilder builder(primary_id); 434 display::DisplayLayoutBuilder builder(primary_id);
435 builder.AddDisplayPlacement(list[2], primary_id, 435 builder.AddDisplayPlacement(list[2], primary_id,
436 display::DisplayPlacement::RIGHT, 10); 436 display::DisplayPlacement::RIGHT, 10);
437 builder.AddDisplayPlacement(list[1], list[3], 437 builder.AddDisplayPlacement(list[1], list[3],
438 display::DisplayPlacement::BOTTOM, 10); 438 display::DisplayPlacement::BOTTOM, 10);
439 builder.AddDisplayPlacement(list[3], list[4], 439 builder.AddDisplayPlacement(list[3], list[4],
440 display::DisplayPlacement::LEFT, 10); 440 display::DisplayPlacement::LEFT, 10);
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 645
646 display::ManagedDisplayInfo CreateDisplayInfo(int64_t id, 646 display::ManagedDisplayInfo CreateDisplayInfo(int64_t id,
647 const gfx::Rect& bounds) { 647 const gfx::Rect& bounds) {
648 display::ManagedDisplayInfo info(id, ToDisplayName(id), false); 648 display::ManagedDisplayInfo info(id, ToDisplayName(id), false);
649 info.SetBounds(bounds); 649 info.SetBounds(bounds);
650 return info; 650 return info;
651 } 651 }
652 652
653 TEST_P(DisplayManagerTest, TestNativeDisplaysChanged) { 653 TEST_P(DisplayManagerTest, TestNativeDisplaysChanged) {
654 const int64_t internal_display_id = 654 const int64_t internal_display_id =
655 test::DisplayManagerTestApi(display_manager()) 655 display::test::DisplayManagerTestApi(display_manager())
656 .SetFirstDisplayAsInternalDisplay(); 656 .SetFirstDisplayAsInternalDisplay();
657 const int external_id = 10; 657 const int external_id = 10;
658 const int mirror_id = 11; 658 const int mirror_id = 11;
659 const int64_t invalid_id = display::Display::kInvalidDisplayID; 659 const int64_t invalid_id = display::Display::kInvalidDisplayID;
660 const display::ManagedDisplayInfo internal_display_info = 660 const display::ManagedDisplayInfo internal_display_info =
661 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); 661 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500));
662 const display::ManagedDisplayInfo external_display_info = 662 const display::ManagedDisplayInfo external_display_info =
663 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); 663 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100));
664 const display::ManagedDisplayInfo mirroring_display_info = 664 const display::ManagedDisplayInfo mirroring_display_info =
665 CreateDisplayInfo(mirror_id, gfx::Rect(0, 0, 500, 500)); 665 CreateDisplayInfo(mirror_id, gfx::Rect(0, 0, 500, 500));
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 .size() 874 .size()
875 .ToString()); 875 .ToString());
876 } 876 }
877 #endif // defined(OS_CHROMEOS) 877 #endif // defined(OS_CHROMEOS)
878 878
879 TEST_P(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) { 879 TEST_P(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) {
880 if (!SupportsMultipleDisplays()) 880 if (!SupportsMultipleDisplays())
881 return; 881 return;
882 882
883 const int64_t internal_display_id = 883 const int64_t internal_display_id =
884 test::DisplayManagerTestApi(display_manager()) 884 display::test::DisplayManagerTestApi(display_manager())
885 .SetFirstDisplayAsInternalDisplay(); 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);
(...skipping 40 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_manager(), display_id, 945 display::test::SetDisplayResolution(display_manager(), display_id,
946 gfx::Size(800, 4000)); 946 gfx::Size(800, 4000));
947 mode = display_manager()->GetSelectedModeForDisplayId(display_id); 947 mode = display_manager()->GetSelectedModeForDisplayId(display_id);
948 EXPECT_FALSE(!!mode); 948 EXPECT_FALSE(!!mode);
949 EXPECT_TRUE(expected_mode->IsEquivalent( 949 EXPECT_TRUE(expected_mode->IsEquivalent(
950 display_manager()->GetActiveModeForDisplayId(display_id))); 950 display_manager()->GetActiveModeForDisplayId(display_id)));
951 951
952 // Supported resolution. 952 // Supported resolution.
953 test::SetDisplayResolution(display_manager(), display_id, 953 display::test::SetDisplayResolution(display_manager(), display_id,
954 gfx::Size(800, 300)); 954 gfx::Size(800, 300));
955 mode = display_manager()->GetSelectedModeForDisplayId(display_id); 955 mode = display_manager()->GetSelectedModeForDisplayId(display_id);
956 EXPECT_TRUE(!!mode); 956 EXPECT_TRUE(!!mode);
957 EXPECT_EQ("800x300", mode->size().ToString()); 957 EXPECT_EQ("800x300", mode->size().ToString());
958 EXPECT_EQ(59.0f, mode->refresh_rate()); 958 EXPECT_EQ(59.0f, mode->refresh_rate());
959 EXPECT_FALSE(mode->native()); 959 EXPECT_FALSE(mode->native());
960 960
961 expected_mode = 961 expected_mode =
962 new display::ManagedDisplayMode(gfx::Size(800, 300), 0.0f, false, false); 962 new display::ManagedDisplayMode(gfx::Size(800, 300), 0.0f, false, false);
963 963
964 EXPECT_TRUE(expected_mode->IsEquivalent( 964 EXPECT_TRUE(expected_mode->IsEquivalent(
965 display_manager()->GetActiveModeForDisplayId(display_id))); 965 display_manager()->GetActiveModeForDisplayId(display_id)));
966 966
967 // Best resolution. 967 // Best resolution.
968 test::SetDisplayResolution(display_manager(), display_id, 968 display::test::SetDisplayResolution(display_manager(), display_id,
969 gfx::Size(1000, 500)); 969 gfx::Size(1000, 500));
970 mode = display_manager()->GetSelectedModeForDisplayId(display_id); 970 mode = display_manager()->GetSelectedModeForDisplayId(display_id);
971 EXPECT_TRUE(!!mode); 971 EXPECT_TRUE(!!mode);
972 EXPECT_EQ("1000x500", mode->size().ToString()); 972 EXPECT_EQ("1000x500", mode->size().ToString());
973 EXPECT_EQ(58.0f, mode->refresh_rate()); 973 EXPECT_EQ(58.0f, mode->refresh_rate());
974 EXPECT_TRUE(mode->native()); 974 EXPECT_TRUE(mode->native());
975 975
976 expected_mode = 976 expected_mode =
977 new display::ManagedDisplayMode(gfx::Size(1000, 500), 0.0f, false, false); 977 new display::ManagedDisplayMode(gfx::Size(1000, 500), 0.0f, false, false);
978 978
979 EXPECT_TRUE(expected_mode->IsEquivalent( 979 EXPECT_TRUE(expected_mode->IsEquivalent(
(...skipping 15 matching lines...) Expand all
995 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode( 995 display_modes.push_back(make_scoped_refptr(new display::ManagedDisplayMode(
996 gfx::Size(400, 500), 60.0f, false, false))); 996 gfx::Size(400, 500), 60.0f, false, false)));
997 997
998 display::ManagedDisplayInfo::ManagedDisplayModeList copy = display_modes; 998 display::ManagedDisplayInfo::ManagedDisplayModeList copy = display_modes;
999 native_display_info.SetManagedDisplayModes(copy); 999 native_display_info.SetManagedDisplayModes(copy);
1000 1000
1001 std::vector<display::ManagedDisplayInfo> display_info_list; 1001 std::vector<display::ManagedDisplayInfo> display_info_list;
1002 display_info_list.push_back(native_display_info); 1002 display_info_list.push_back(native_display_info);
1003 display_manager()->OnNativeDisplaysChanged(display_info_list); 1003 display_manager()->OnNativeDisplaysChanged(display_info_list);
1004 { 1004 {
1005 test::SetDisplayResolution(display_manager(), display_id, 1005 display::test::SetDisplayResolution(display_manager(), display_id,
1006 gfx::Size(800, 300)); 1006 gfx::Size(800, 300));
1007 display::ManagedDisplayInfo new_native_display_info = 1007 display::ManagedDisplayInfo new_native_display_info =
1008 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 400, 500)); 1008 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 400, 500));
1009 copy = display_modes; 1009 copy = display_modes;
1010 new_native_display_info.SetManagedDisplayModes(copy); 1010 new_native_display_info.SetManagedDisplayModes(copy);
1011 std::vector<display::ManagedDisplayInfo> new_display_info_list; 1011 std::vector<display::ManagedDisplayInfo> new_display_info_list;
1012 new_display_info_list.push_back(new_native_display_info); 1012 new_display_info_list.push_back(new_native_display_info);
1013 display_manager()->OnNativeDisplaysChanged(new_display_info_list); 1013 display_manager()->OnNativeDisplaysChanged(new_display_info_list);
1014 1014
1015 scoped_refptr<display::ManagedDisplayMode> mode = 1015 scoped_refptr<display::ManagedDisplayMode> mode =
1016 display_manager()->GetSelectedModeForDisplayId(display_id); 1016 display_manager()->GetSelectedModeForDisplayId(display_id);
1017 EXPECT_TRUE(!!mode); 1017 EXPECT_TRUE(!!mode);
1018 EXPECT_EQ("400x500", mode->size().ToString()); 1018 EXPECT_EQ("400x500", mode->size().ToString());
1019 EXPECT_EQ(60.0f, mode->refresh_rate()); 1019 EXPECT_EQ(60.0f, mode->refresh_rate());
1020 EXPECT_FALSE(mode->native()); 1020 EXPECT_FALSE(mode->native());
1021 } 1021 }
1022 { 1022 {
1023 // Best resolution should find itself on the resolutions list. 1023 // Best resolution should find itself on the resolutions list.
1024 test::SetDisplayResolution(display_manager(), display_id, 1024 display::test::SetDisplayResolution(display_manager(), display_id,
1025 gfx::Size(800, 300)); 1025 gfx::Size(800, 300));
1026 display::ManagedDisplayInfo new_native_display_info = 1026 display::ManagedDisplayInfo new_native_display_info =
1027 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); 1027 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500));
1028 display::ManagedDisplayInfo::ManagedDisplayModeList copy = display_modes; 1028 display::ManagedDisplayInfo::ManagedDisplayModeList copy = display_modes;
1029 new_native_display_info.SetManagedDisplayModes(copy); 1029 new_native_display_info.SetManagedDisplayModes(copy);
1030 std::vector<display::ManagedDisplayInfo> new_display_info_list; 1030 std::vector<display::ManagedDisplayInfo> new_display_info_list;
1031 new_display_info_list.push_back(new_native_display_info); 1031 new_display_info_list.push_back(new_native_display_info);
1032 display_manager()->OnNativeDisplaysChanged(new_display_info_list); 1032 display_manager()->OnNativeDisplaysChanged(new_display_info_list);
1033 1033
1034 scoped_refptr<display::ManagedDisplayMode> mode = 1034 scoped_refptr<display::ManagedDisplayMode> mode =
1035 display_manager()->GetSelectedModeForDisplayId(display_id); 1035 display_manager()->GetSelectedModeForDisplayId(display_id);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 EXPECT_EQ("1 0 0", GetCountSummary()); 1086 EXPECT_EQ("1 0 0", GetCountSummary());
1087 reset(); 1087 reset();
1088 1088
1089 UpdateDisplay("200x200/l"); 1089 UpdateDisplay("200x200/l");
1090 EXPECT_EQ("1 0 0", GetCountSummary()); 1090 EXPECT_EQ("1 0 0", GetCountSummary());
1091 1091
1092 // Having the internal display deactivated should restore user rotation. Newly 1092 // Having the internal display deactivated should restore user rotation. Newly
1093 // set rotations should be applied. 1093 // set rotations should be applied.
1094 UpdateDisplay("200x200, 200x200"); 1094 UpdateDisplay("200x200, 200x200");
1095 const int64_t internal_display_id = 1095 const int64_t internal_display_id =
1096 test::DisplayManagerTestApi(display_manager()) 1096 display::test::DisplayManagerTestApi(display_manager())
1097 .SetFirstDisplayAsInternalDisplay(); 1097 .SetFirstDisplayAsInternalDisplay();
1098 1098
1099 display_manager()->SetDisplayRotation(internal_display_id, 1099 display_manager()->SetDisplayRotation(internal_display_id,
1100 display::Display::ROTATE_90, 1100 display::Display::ROTATE_90,
1101 display::Display::ROTATION_SOURCE_USER); 1101 display::Display::ROTATION_SOURCE_USER);
1102 display_manager()->SetDisplayRotation( 1102 display_manager()->SetDisplayRotation(
1103 internal_display_id, display::Display::ROTATE_0, 1103 internal_display_id, display::Display::ROTATE_0,
1104 display::Display::ROTATION_SOURCE_ACTIVE); 1104 display::Display::ROTATION_SOURCE_ACTIVE);
1105 1105
1106 const display::ManagedDisplayInfo info = 1106 const display::ManagedDisplayInfo info =
1107 GetDisplayInfoForId(internal_display_id); 1107 GetDisplayInfoForId(internal_display_id);
1108 EXPECT_EQ(display::Display::ROTATE_0, info.GetActiveRotation()); 1108 EXPECT_EQ(display::Display::ROTATE_0, info.GetActiveRotation());
1109 1109
1110 // Deactivate internal display to simulate Docked Mode. 1110 // Deactivate internal display to simulate Docked Mode.
1111 vector<display::ManagedDisplayInfo> secondary_only; 1111 vector<display::ManagedDisplayInfo> secondary_only;
1112 secondary_only.push_back(GetDisplayInfoAt(1)); 1112 secondary_only.push_back(GetDisplayInfoAt(1));
1113 display_manager()->OnNativeDisplaysChanged(secondary_only); 1113 display_manager()->OnNativeDisplaysChanged(secondary_only);
1114 1114
1115 const display::ManagedDisplayInfo& post_removal_info = 1115 const display::ManagedDisplayInfo& post_removal_info =
1116 test::DisplayManagerTestApi(display_manager()) 1116 display::test::DisplayManagerTestApi(display_manager())
1117 .GetInternalManagedDisplayInfo(internal_display_id); 1117 .GetInternalManagedDisplayInfo(internal_display_id);
1118 EXPECT_NE(info.GetActiveRotation(), post_removal_info.GetActiveRotation()); 1118 EXPECT_NE(info.GetActiveRotation(), post_removal_info.GetActiveRotation());
1119 EXPECT_EQ(display::Display::ROTATE_90, post_removal_info.GetActiveRotation()); 1119 EXPECT_EQ(display::Display::ROTATE_90, post_removal_info.GetActiveRotation());
1120 1120
1121 display_manager()->SetDisplayRotation( 1121 display_manager()->SetDisplayRotation(
1122 internal_display_id, display::Display::ROTATE_180, 1122 internal_display_id, display::Display::ROTATE_180,
1123 display::Display::ROTATION_SOURCE_ACTIVE); 1123 display::Display::ROTATION_SOURCE_ACTIVE);
1124 const display::ManagedDisplayInfo& post_rotation_info = 1124 const display::ManagedDisplayInfo& post_rotation_info =
1125 test::DisplayManagerTestApi(display_manager()) 1125 display::test::DisplayManagerTestApi(display_manager())
1126 .GetInternalManagedDisplayInfo(internal_display_id); 1126 .GetInternalManagedDisplayInfo(internal_display_id);
1127 EXPECT_NE(info.GetActiveRotation(), post_rotation_info.GetActiveRotation()); 1127 EXPECT_NE(info.GetActiveRotation(), post_rotation_info.GetActiveRotation());
1128 EXPECT_EQ(display::Display::ROTATE_180, 1128 EXPECT_EQ(display::Display::ROTATE_180,
1129 post_rotation_info.GetActiveRotation()); 1129 post_rotation_info.GetActiveRotation());
1130 } 1130 }
1131 1131
1132 // TODO(msw): Broken on Windows. http://crbug.com/584038 1132 // TODO(msw): Broken on Windows. http://crbug.com/584038
1133 #if defined(OS_CHROMEOS) 1133 #if defined(OS_CHROMEOS)
1134 TEST_P(DisplayManagerTest, UIScale) { 1134 TEST_P(DisplayManagerTest, UIScale) {
1135 test::ScopedDisable125DSFForUIScaling disable; 1135 display::test::ScopedDisable125DSFForUIScaling disable;
1136 1136
1137 UpdateDisplay("1280x800"); 1137 UpdateDisplay("1280x800");
1138 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1138 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1139 test::DisplayManagerTestApi(display_manager()) 1139 display::test::DisplayManagerTestApi(display_manager())
1140 .SetDisplayUIScale(display_id, 1.125f); 1140 .SetDisplayUIScale(display_id, 1.125f);
1141 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale()); 1141 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale());
1142 test::DisplayManagerTestApi(display_manager()) 1142 display::test::DisplayManagerTestApi(display_manager())
1143 .SetDisplayUIScale(display_id, 0.8f); 1143 .SetDisplayUIScale(display_id, 0.8f);
1144 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1144 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1145 test::DisplayManagerTestApi(display_manager()) 1145 display::test::DisplayManagerTestApi(display_manager())
1146 .SetDisplayUIScale(display_id, 0.75f); 1146 .SetDisplayUIScale(display_id, 0.75f);
1147 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1147 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1148 test::DisplayManagerTestApi(display_manager()) 1148 display::test::DisplayManagerTestApi(display_manager())
1149 .SetDisplayUIScale(display_id, 0.625f); 1149 .SetDisplayUIScale(display_id, 0.625f);
1150 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1150 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1151 1151
1152 test::ScopedSetInternalDisplayId set_internal(display_manager(), display_id); 1152 display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
1153 display_id);
1153 1154
1154 test::DisplayManagerTestApi(display_manager()) 1155 display::test::DisplayManagerTestApi(display_manager())
1155 .SetDisplayUIScale(display_id, 1.5f); 1156 .SetDisplayUIScale(display_id, 1.5f);
1156 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1157 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1157 test::DisplayManagerTestApi(display_manager()) 1158 display::test::DisplayManagerTestApi(display_manager())
1158 .SetDisplayUIScale(display_id, 1.25f); 1159 .SetDisplayUIScale(display_id, 1.25f);
1159 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1160 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1160 test::DisplayManagerTestApi(display_manager()) 1161 display::test::DisplayManagerTestApi(display_manager())
1161 .SetDisplayUIScale(display_id, 1.125f); 1162 .SetDisplayUIScale(display_id, 1.125f);
1162 EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale()); 1163 EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale());
1163 test::DisplayManagerTestApi(display_manager()) 1164 display::test::DisplayManagerTestApi(display_manager())
1164 .SetDisplayUIScale(display_id, 0.8f); 1165 .SetDisplayUIScale(display_id, 0.8f);
1165 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale()); 1166 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale());
1166 test::DisplayManagerTestApi(display_manager()) 1167 display::test::DisplayManagerTestApi(display_manager())
1167 .SetDisplayUIScale(display_id, 0.75f); 1168 .SetDisplayUIScale(display_id, 0.75f);
1168 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale()); 1169 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale());
1169 test::DisplayManagerTestApi(display_manager()) 1170 display::test::DisplayManagerTestApi(display_manager())
1170 .SetDisplayUIScale(display_id, 0.625f); 1171 .SetDisplayUIScale(display_id, 0.625f);
1171 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); 1172 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale());
1172 test::DisplayManagerTestApi(display_manager()) 1173 display::test::DisplayManagerTestApi(display_manager())
1173 .SetDisplayUIScale(display_id, 0.6f); 1174 .SetDisplayUIScale(display_id, 0.6f);
1174 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); 1175 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale());
1175 test::DisplayManagerTestApi(display_manager()) 1176 display::test::DisplayManagerTestApi(display_manager())
1176 .SetDisplayUIScale(display_id, 0.5f); 1177 .SetDisplayUIScale(display_id, 0.5f);
1177 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale()); 1178 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale());
1178 1179
1179 UpdateDisplay("1366x768"); 1180 UpdateDisplay("1366x768");
1180 test::DisplayManagerTestApi(display_manager()) 1181 display::test::DisplayManagerTestApi(display_manager())
1181 .SetDisplayUIScale(display_id, 1.5f); 1182 .SetDisplayUIScale(display_id, 1.5f);
1182 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1183 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1183 test::DisplayManagerTestApi(display_manager()) 1184 display::test::DisplayManagerTestApi(display_manager())
1184 .SetDisplayUIScale(display_id, 1.25f); 1185 .SetDisplayUIScale(display_id, 1.25f);
1185 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1186 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1186 test::DisplayManagerTestApi(display_manager()) 1187 display::test::DisplayManagerTestApi(display_manager())
1187 .SetDisplayUIScale(display_id, 1.125f); 1188 .SetDisplayUIScale(display_id, 1.125f);
1188 EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale()); 1189 EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale());
1189 test::DisplayManagerTestApi(display_manager()) 1190 display::test::DisplayManagerTestApi(display_manager())
1190 .SetDisplayUIScale(display_id, 0.8f); 1191 .SetDisplayUIScale(display_id, 0.8f);
1191 EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale()); 1192 EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale());
1192 test::DisplayManagerTestApi(display_manager()) 1193 display::test::DisplayManagerTestApi(display_manager())
1193 .SetDisplayUIScale(display_id, 0.75f); 1194 .SetDisplayUIScale(display_id, 0.75f);
1194 EXPECT_EQ(0.75f, GetDisplayInfoAt(0).configured_ui_scale()); 1195 EXPECT_EQ(0.75f, GetDisplayInfoAt(0).configured_ui_scale());
1195 test::DisplayManagerTestApi(display_manager()) 1196 display::test::DisplayManagerTestApi(display_manager())
1196 .SetDisplayUIScale(display_id, 0.6f); 1197 .SetDisplayUIScale(display_id, 0.6f);
1197 EXPECT_EQ(0.6f, GetDisplayInfoAt(0).configured_ui_scale()); 1198 EXPECT_EQ(0.6f, GetDisplayInfoAt(0).configured_ui_scale());
1198 test::DisplayManagerTestApi(display_manager()) 1199 display::test::DisplayManagerTestApi(display_manager())
1199 .SetDisplayUIScale(display_id, 0.625f); 1200 .SetDisplayUIScale(display_id, 0.625f);
1200 EXPECT_EQ(0.6f, GetDisplayInfoAt(0).configured_ui_scale()); 1201 EXPECT_EQ(0.6f, GetDisplayInfoAt(0).configured_ui_scale());
1201 test::DisplayManagerTestApi(display_manager()) 1202 display::test::DisplayManagerTestApi(display_manager())
1202 .SetDisplayUIScale(display_id, 0.5f); 1203 .SetDisplayUIScale(display_id, 0.5f);
1203 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale()); 1204 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale());
1204 1205
1205 UpdateDisplay("1280x850*2"); 1206 UpdateDisplay("1280x850*2");
1206 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1207 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1207 test::DisplayManagerTestApi(display_manager()) 1208 display::test::DisplayManagerTestApi(display_manager())
1208 .SetDisplayUIScale(display_id, 1.5f); 1209 .SetDisplayUIScale(display_id, 1.5f);
1209 EXPECT_EQ(1.5f, GetDisplayInfoAt(0).configured_ui_scale()); 1210 EXPECT_EQ(1.5f, GetDisplayInfoAt(0).configured_ui_scale());
1210 test::DisplayManagerTestApi(display_manager()) 1211 display::test::DisplayManagerTestApi(display_manager())
1211 .SetDisplayUIScale(display_id, 1.25f); 1212 .SetDisplayUIScale(display_id, 1.25f);
1212 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).configured_ui_scale()); 1213 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).configured_ui_scale());
1213 test::DisplayManagerTestApi(display_manager()) 1214 display::test::DisplayManagerTestApi(display_manager())
1214 .SetDisplayUIScale(display_id, 1.125f); 1215 .SetDisplayUIScale(display_id, 1.125f);
1215 EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale()); 1216 EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale());
1216 test::DisplayManagerTestApi(display_manager()) 1217 display::test::DisplayManagerTestApi(display_manager())
1217 .SetDisplayUIScale(display_id, 1.0f); 1218 .SetDisplayUIScale(display_id, 1.0f);
1218 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1219 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1219 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); 1220 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay();
1220 EXPECT_EQ(2.0f, display.device_scale_factor()); 1221 EXPECT_EQ(2.0f, display.device_scale_factor());
1221 EXPECT_EQ("640x425", display.bounds().size().ToString()); 1222 EXPECT_EQ("640x425", display.bounds().size().ToString());
1222 1223
1223 test::DisplayManagerTestApi(display_manager()) 1224 display::test::DisplayManagerTestApi(display_manager())
1224 .SetDisplayUIScale(display_id, 0.8f); 1225 .SetDisplayUIScale(display_id, 0.8f);
1225 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale()); 1226 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale());
1226 test::DisplayManagerTestApi(display_manager()) 1227 display::test::DisplayManagerTestApi(display_manager())
1227 .SetDisplayUIScale(display_id, 0.75f); 1228 .SetDisplayUIScale(display_id, 0.75f);
1228 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale()); 1229 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale());
1229 test::DisplayManagerTestApi(display_manager()) 1230 display::test::DisplayManagerTestApi(display_manager())
1230 .SetDisplayUIScale(display_id, 0.625f); 1231 .SetDisplayUIScale(display_id, 0.625f);
1231 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); 1232 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale());
1232 test::DisplayManagerTestApi(display_manager()) 1233 display::test::DisplayManagerTestApi(display_manager())
1233 .SetDisplayUIScale(display_id, 0.6f); 1234 .SetDisplayUIScale(display_id, 0.6f);
1234 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); 1235 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale());
1235 test::DisplayManagerTestApi(display_manager()) 1236 display::test::DisplayManagerTestApi(display_manager())
1236 .SetDisplayUIScale(display_id, 0.5f); 1237 .SetDisplayUIScale(display_id, 0.5f);
1237 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale()); 1238 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale());
1238 1239
1239 test::DisplayManagerTestApi(display_manager()) 1240 display::test::DisplayManagerTestApi(display_manager())
1240 .SetDisplayUIScale(display_id, 2.0f); 1241 .SetDisplayUIScale(display_id, 2.0f);
1241 EXPECT_EQ(2.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1242 EXPECT_EQ(2.0f, GetDisplayInfoAt(0).configured_ui_scale());
1242 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1243 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1243 display = display::Screen::GetScreen()->GetPrimaryDisplay(); 1244 display = display::Screen::GetScreen()->GetPrimaryDisplay();
1244 EXPECT_EQ(1.0f, display.device_scale_factor()); 1245 EXPECT_EQ(1.0f, display.device_scale_factor());
1245 EXPECT_EQ("1280x850", display.bounds().size().ToString()); 1246 EXPECT_EQ("1280x850", display.bounds().size().ToString());
1246 1247
1247 // 1.25 ui scaling on 1.25 DSF device should use 1.0 DSF 1248 // 1.25 ui scaling on 1.25 DSF device should use 1.0 DSF
1248 // on screen. 1249 // on screen.
1249 UpdateDisplay("1280x850*1.25"); 1250 UpdateDisplay("1280x850*1.25");
1250 test::DisplayManagerTestApi(display_manager()) 1251 display::test::DisplayManagerTestApi(display_manager())
1251 .SetDisplayUIScale(display_id, 1.25f); 1252 .SetDisplayUIScale(display_id, 1.25f);
1252 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).configured_ui_scale()); 1253 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).configured_ui_scale());
1253 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1254 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1254 display = display::Screen::GetScreen()->GetPrimaryDisplay(); 1255 display = display::Screen::GetScreen()->GetPrimaryDisplay();
1255 EXPECT_EQ(1.0f, display.device_scale_factor()); 1256 EXPECT_EQ(1.0f, display.device_scale_factor());
1256 EXPECT_EQ("1280x850", display.bounds().size().ToString()); 1257 EXPECT_EQ("1280x850", display.bounds().size().ToString());
1257 } 1258 }
1258 #endif // defined(OS_CHROMEOS) 1259 #endif // defined(OS_CHROMEOS)
1259 1260
1260 TEST_P(DisplayManagerTest, UIScaleWithDisplayMode) { 1261 TEST_P(DisplayManagerTest, UIScaleWithDisplayMode) {
(...skipping 10 matching lines...) Expand all
1271 native_display_info.SetManagedDisplayModes(mode_list); 1272 native_display_info.SetManagedDisplayModes(mode_list);
1272 1273
1273 std::vector<display::ManagedDisplayInfo> display_info_list; 1274 std::vector<display::ManagedDisplayInfo> display_info_list;
1274 display_info_list.push_back(native_display_info); 1275 display_info_list.push_back(native_display_info);
1275 display_manager()->OnNativeDisplaysChanged(display_info_list); 1276 display_manager()->OnNativeDisplaysChanged(display_info_list);
1276 1277
1277 scoped_refptr<display::ManagedDisplayMode> expected_mode = base_mode; 1278 scoped_refptr<display::ManagedDisplayMode> expected_mode = base_mode;
1278 EXPECT_TRUE(expected_mode->IsEquivalent( 1279 EXPECT_TRUE(expected_mode->IsEquivalent(
1279 display_manager()->GetActiveModeForDisplayId(display_id))); 1280 display_manager()->GetActiveModeForDisplayId(display_id)));
1280 1281
1281 test::ScopedSetInternalDisplayId set_internal(display_manager(), display_id); 1282 display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
1283 display_id);
1282 1284
1283 test::DisplayManagerTestApi(display_manager()) 1285 display::test::DisplayManagerTestApi(display_manager())
1284 .SetDisplayUIScale(display_id, 1.5f); 1286 .SetDisplayUIScale(display_id, 1.5f);
1285 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1287 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1286 EXPECT_TRUE(expected_mode->IsEquivalent( 1288 EXPECT_TRUE(expected_mode->IsEquivalent(
1287 display_manager()->GetActiveModeForDisplayId(display_id))); 1289 display_manager()->GetActiveModeForDisplayId(display_id)));
1288 test::DisplayManagerTestApi(display_manager()) 1290 display::test::DisplayManagerTestApi(display_manager())
1289 .SetDisplayUIScale(display_id, 1.25f); 1291 .SetDisplayUIScale(display_id, 1.25f);
1290 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1292 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1291 EXPECT_TRUE(expected_mode->IsEquivalent( 1293 EXPECT_TRUE(expected_mode->IsEquivalent(
1292 display_manager()->GetActiveModeForDisplayId(display_id))); 1294 display_manager()->GetActiveModeForDisplayId(display_id)));
1293 test::DisplayManagerTestApi(display_manager()) 1295 display::test::DisplayManagerTestApi(display_manager())
1294 .SetDisplayUIScale(display_id, 1.125f); 1296 .SetDisplayUIScale(display_id, 1.125f);
1295 EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale()); 1297 EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale());
1296 1298
1297 expected_mode = new display::ManagedDisplayMode( 1299 expected_mode = new display::ManagedDisplayMode(
1298 expected_mode->size(), expected_mode->refresh_rate(), 1300 expected_mode->size(), expected_mode->refresh_rate(),
1299 expected_mode->is_interlaced(), expected_mode->native(), 1301 expected_mode->is_interlaced(), expected_mode->native(),
1300 1.125f /* ui_scale */, expected_mode->device_scale_factor()); 1302 1.125f /* ui_scale */, expected_mode->device_scale_factor());
1301 1303
1302 EXPECT_TRUE(expected_mode->IsEquivalent( 1304 EXPECT_TRUE(expected_mode->IsEquivalent(
1303 display_manager()->GetActiveModeForDisplayId(display_id))); 1305 display_manager()->GetActiveModeForDisplayId(display_id)));
1304 test::DisplayManagerTestApi(display_manager()) 1306 display::test::DisplayManagerTestApi(display_manager())
1305 .SetDisplayUIScale(display_id, 0.8f); 1307 .SetDisplayUIScale(display_id, 0.8f);
1306 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale()); 1308 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale());
1307 1309
1308 expected_mode = new display::ManagedDisplayMode( 1310 expected_mode = new display::ManagedDisplayMode(
1309 expected_mode->size(), expected_mode->refresh_rate(), 1311 expected_mode->size(), expected_mode->refresh_rate(),
1310 expected_mode->is_interlaced(), expected_mode->native(), 1312 expected_mode->is_interlaced(), expected_mode->native(),
1311 0.8f /* ui_scale */, expected_mode->device_scale_factor()); 1313 0.8f /* ui_scale */, expected_mode->device_scale_factor());
1312 1314
1313 EXPECT_TRUE(expected_mode->IsEquivalent( 1315 EXPECT_TRUE(expected_mode->IsEquivalent(
1314 display_manager()->GetActiveModeForDisplayId(display_id))); 1316 display_manager()->GetActiveModeForDisplayId(display_id)));
1315 test::DisplayManagerTestApi(display_manager()) 1317 display::test::DisplayManagerTestApi(display_manager())
1316 .SetDisplayUIScale(display_id, 0.75f); 1318 .SetDisplayUIScale(display_id, 0.75f);
1317 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale()); 1319 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale());
1318 EXPECT_TRUE(expected_mode->IsEquivalent( 1320 EXPECT_TRUE(expected_mode->IsEquivalent(
1319 display_manager()->GetActiveModeForDisplayId(display_id))); 1321 display_manager()->GetActiveModeForDisplayId(display_id)));
1320 test::DisplayManagerTestApi(display_manager()) 1322 display::test::DisplayManagerTestApi(display_manager())
1321 .SetDisplayUIScale(display_id, 0.625f); 1323 .SetDisplayUIScale(display_id, 0.625f);
1322 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); 1324 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale());
1323 1325
1324 expected_mode = new display::ManagedDisplayMode( 1326 expected_mode = new display::ManagedDisplayMode(
1325 expected_mode->size(), expected_mode->refresh_rate(), 1327 expected_mode->size(), expected_mode->refresh_rate(),
1326 expected_mode->is_interlaced(), expected_mode->native(), 1328 expected_mode->is_interlaced(), expected_mode->native(),
1327 0.625f /* ui_scale */, expected_mode->device_scale_factor()); 1329 0.625f /* ui_scale */, expected_mode->device_scale_factor());
1328 1330
1329 EXPECT_TRUE(expected_mode->IsEquivalent( 1331 EXPECT_TRUE(expected_mode->IsEquivalent(
1330 display_manager()->GetActiveModeForDisplayId(display_id))); 1332 display_manager()->GetActiveModeForDisplayId(display_id)));
1331 test::DisplayManagerTestApi(display_manager()) 1333 display::test::DisplayManagerTestApi(display_manager())
1332 .SetDisplayUIScale(display_id, 0.6f); 1334 .SetDisplayUIScale(display_id, 0.6f);
1333 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); 1335 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale());
1334 EXPECT_TRUE(expected_mode->IsEquivalent( 1336 EXPECT_TRUE(expected_mode->IsEquivalent(
1335 display_manager()->GetActiveModeForDisplayId(display_id))); 1337 display_manager()->GetActiveModeForDisplayId(display_id)));
1336 test::DisplayManagerTestApi(display_manager()) 1338 display::test::DisplayManagerTestApi(display_manager())
1337 .SetDisplayUIScale(display_id, 0.5f); 1339 .SetDisplayUIScale(display_id, 0.5f);
1338 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale()); 1340 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale());
1339 1341
1340 expected_mode = new display::ManagedDisplayMode( 1342 expected_mode = new display::ManagedDisplayMode(
1341 expected_mode->size(), expected_mode->refresh_rate(), 1343 expected_mode->size(), expected_mode->refresh_rate(),
1342 expected_mode->is_interlaced(), expected_mode->native(), 1344 expected_mode->is_interlaced(), expected_mode->native(),
1343 0.5f /* ui_scale */, expected_mode->device_scale_factor()); 1345 0.5f /* ui_scale */, expected_mode->device_scale_factor());
1344 1346
1345 EXPECT_TRUE(expected_mode->IsEquivalent( 1347 EXPECT_TRUE(expected_mode->IsEquivalent(
1346 display_manager()->GetActiveModeForDisplayId(display_id))); 1348 display_manager()->GetActiveModeForDisplayId(display_id)));
(...skipping 18 matching lines...) Expand all
1365 native_display_info.SetManagedDisplayModes(mode_list); 1367 native_display_info.SetManagedDisplayModes(mode_list);
1366 1368
1367 std::vector<display::ManagedDisplayInfo> display_info_list; 1369 std::vector<display::ManagedDisplayInfo> display_info_list;
1368 display_info_list.push_back(native_display_info); 1370 display_info_list.push_back(native_display_info);
1369 display_manager()->OnNativeDisplaysChanged(display_info_list); 1371 display_manager()->OnNativeDisplaysChanged(display_info_list);
1370 1372
1371 scoped_refptr<display::ManagedDisplayMode> expected_mode = base_mode; 1373 scoped_refptr<display::ManagedDisplayMode> expected_mode = base_mode;
1372 EXPECT_TRUE(expected_mode->IsEquivalent( 1374 EXPECT_TRUE(expected_mode->IsEquivalent(
1373 display_manager()->GetActiveModeForDisplayId(display_id))); 1375 display_manager()->GetActiveModeForDisplayId(display_id)));
1374 1376
1375 test::ScopedSetInternalDisplayId set_internal(display_manager(), display_id); 1377 display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
1378 display_id);
1376 1379
1377 test::DisplayManagerTestApi(display_manager()) 1380 display::test::DisplayManagerTestApi(display_manager())
1378 .SetDisplayUIScale(display_id, 0.5f); 1381 .SetDisplayUIScale(display_id, 0.5f);
1379 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1382 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1380 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1383 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1381 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale()); 1384 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale());
1382 EXPECT_EQ("960x540", GetDisplayForId(display_id).size().ToString()); 1385 EXPECT_EQ("960x540", GetDisplayForId(display_id).size().ToString());
1383 1386
1384 // Reset the internal display zoom and expect the UI scale to go to the 1387 // Reset the internal display zoom and expect the UI scale to go to the
1385 // default 0.8f. 1388 // default 0.8f.
1386 display_manager()->ResetInternalDisplayZoom(); 1389 display_manager()->ResetInternalDisplayZoom();
1387 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1390 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1388 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1391 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1389 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale()); 1392 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale());
1390 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString()); 1393 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString());
1391 } 1394 }
1392 1395
1393 // TODO(msw): Broken on Windows. http://crbug.com/584038 1396 // TODO(msw): Broken on Windows. http://crbug.com/584038
1394 #if defined(OS_CHROMEOS) 1397 #if defined(OS_CHROMEOS)
1395 TEST_P(DisplayManagerTest, Use125DSFForUIScaling) { 1398 TEST_P(DisplayManagerTest, Use125DSFForUIScaling) {
1396 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1399 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1397 1400
1398 test::ScopedSetInternalDisplayId set_internal(display_manager(), display_id); 1401 display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
1402 display_id);
1399 UpdateDisplay("1920x1080*1.25"); 1403 UpdateDisplay("1920x1080*1.25");
1400 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1404 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1401 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1405 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1402 1406
1403 test::DisplayManagerTestApi(display_manager()) 1407 display::test::DisplayManagerTestApi(display_manager())
1404 .SetDisplayUIScale(display_id, 0.8f); 1408 .SetDisplayUIScale(display_id, 0.8f);
1405 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1409 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1406 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1410 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1407 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString()); 1411 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString());
1408 1412
1409 test::DisplayManagerTestApi(display_manager()) 1413 display::test::DisplayManagerTestApi(display_manager())
1410 .SetDisplayUIScale(display_id, 0.5f); 1414 .SetDisplayUIScale(display_id, 0.5f);
1411 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1415 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1412 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1416 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1413 EXPECT_EQ("960x540", GetDisplayForId(display_id).size().ToString()); 1417 EXPECT_EQ("960x540", GetDisplayForId(display_id).size().ToString());
1414 1418
1415 test::DisplayManagerTestApi(display_manager()) 1419 display::test::DisplayManagerTestApi(display_manager())
1416 .SetDisplayUIScale(display_id, 1.25f); 1420 .SetDisplayUIScale(display_id, 1.25f);
1417 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1421 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1418 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1422 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1419 EXPECT_EQ("2400x1350", GetDisplayForId(display_id).size().ToString()); 1423 EXPECT_EQ("2400x1350", GetDisplayForId(display_id).size().ToString());
1420 } 1424 }
1421 #endif // defined(OS_CHROMEOS) 1425 #endif // defined(OS_CHROMEOS)
1422 1426
1423 // TODO(msw): Broken on Windows. http://crbug.com/584038 1427 // TODO(msw): Broken on Windows. http://crbug.com/584038
1424 #if defined(OS_CHROMEOS) 1428 #if defined(OS_CHROMEOS)
1425 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScaling) { 1429 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScaling) {
1426 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1430 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1427 1431
1428 display_id++; 1432 display_id++;
1429 test::ScopedSetInternalDisplayId set_internal(display_manager(), display_id); 1433 display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
1434 display_id);
1430 1435
1431 // Setup the display modes with UI-scale. 1436 // Setup the display modes with UI-scale.
1432 display::ManagedDisplayInfo native_display_info = 1437 display::ManagedDisplayInfo native_display_info =
1433 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080)); 1438 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080));
1434 native_display_info.set_device_scale_factor(1.25); 1439 native_display_info.set_device_scale_factor(1.25);
1435 1440
1436 const scoped_refptr<display::ManagedDisplayMode>& base_mode( 1441 const scoped_refptr<display::ManagedDisplayMode>& base_mode(
1437 new display::ManagedDisplayMode(gfx::Size(1920, 1080), 60.0f, false, 1442 new display::ManagedDisplayMode(gfx::Size(1920, 1080), 60.0f, false,
1438 false)); 1443 false));
1439 display::ManagedDisplayInfo::ManagedDisplayModeList mode_list = 1444 display::ManagedDisplayInfo::ManagedDisplayModeList mode_list =
(...skipping 11 matching lines...) Expand all
1451 #endif // defined(OS_CHROMEOS) 1456 #endif // defined(OS_CHROMEOS)
1452 1457
1453 // TODO(msw): Broken on Windows. http://crbug.com/584038 1458 // TODO(msw): Broken on Windows. http://crbug.com/584038
1454 #if defined(OS_CHROMEOS) 1459 #if defined(OS_CHROMEOS)
1455 // Don't default to 1.25 DSF if the user already has a prefrence stored for 1460 // Don't default to 1.25 DSF if the user already has a prefrence stored for
1456 // the internal display. 1461 // the internal display.
1457 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScalingNoOverride) { 1462 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScalingNoOverride) {
1458 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1463 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1459 1464
1460 display_id++; 1465 display_id++;
1461 test::ScopedSetInternalDisplayId set_internal(display_manager(), display_id); 1466 display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
1467 display_id);
1462 const gfx::Insets dummy_overscan_insets; 1468 const gfx::Insets dummy_overscan_insets;
1463 display_manager()->RegisterDisplayProperty( 1469 display_manager()->RegisterDisplayProperty(
1464 display_id, display::Display::ROTATE_0, 1.0f, &dummy_overscan_insets, 1470 display_id, display::Display::ROTATE_0, 1.0f, &dummy_overscan_insets,
1465 gfx::Size(), 1.0f, ui::ColorCalibrationProfile()); 1471 gfx::Size(), 1.0f, ui::ColorCalibrationProfile());
1466 1472
1467 // Setup the display modes with UI-scale. 1473 // Setup the display modes with UI-scale.
1468 display::ManagedDisplayInfo native_display_info = 1474 display::ManagedDisplayInfo native_display_info =
1469 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080)); 1475 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080));
1470 native_display_info.set_device_scale_factor(1.25); 1476 native_display_info.set_device_scale_factor(1.25);
1471 1477
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 EXPECT_EQ("800x400", info.display_modes()[1]->size().ToString()); 1511 EXPECT_EQ("800x400", info.display_modes()[1]->size().ToString());
1506 EXPECT_FALSE(info.display_modes()[1]->native()); 1512 EXPECT_FALSE(info.display_modes()[1]->native());
1507 EXPECT_EQ( 1513 EXPECT_EQ(
1508 "400x200", 1514 "400x200",
1509 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); 1515 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString());
1510 scoped_refptr<display::ManagedDisplayMode> active_mode = 1516 scoped_refptr<display::ManagedDisplayMode> active_mode =
1511 display_manager()->GetActiveModeForDisplayId(unified_id); 1517 display_manager()->GetActiveModeForDisplayId(unified_id);
1512 EXPECT_EQ(1.0f, active_mode->ui_scale()); 1518 EXPECT_EQ(1.0f, active_mode->ui_scale());
1513 EXPECT_EQ("400x200", active_mode->size().ToString()); 1519 EXPECT_EQ("400x200", active_mode->size().ToString());
1514 1520
1515 EXPECT_TRUE(test::SetDisplayResolution(display_manager(), unified_id, 1521 EXPECT_TRUE(display::test::SetDisplayResolution(display_manager(), unified_id,
1516 gfx::Size(800, 400))); 1522 gfx::Size(800, 400)));
1517 EXPECT_EQ( 1523 EXPECT_EQ(
1518 "800x400", 1524 "800x400",
1519 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); 1525 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString());
1520 1526
1521 active_mode = display_manager()->GetActiveModeForDisplayId(unified_id); 1527 active_mode = display_manager()->GetActiveModeForDisplayId(unified_id);
1522 EXPECT_EQ(1.0f, active_mode->ui_scale()); 1528 EXPECT_EQ(1.0f, active_mode->ui_scale());
1523 EXPECT_EQ("800x400", active_mode->size().ToString()); 1529 EXPECT_EQ("800x400", active_mode->size().ToString());
1524 1530
1525 // resolution change will not persist in unified desktop mode. 1531 // resolution change will not persist in unified desktop mode.
1526 UpdateDisplay("600x600, 200x200"); 1532 UpdateDisplay("600x600, 200x200");
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1623 return; 1629 return;
1624 1630
1625 UpdateDisplay("300x400,400x500"); 1631 UpdateDisplay("300x400,400x500");
1626 1632
1627 test::MirrorWindowTestApi test_api; 1633 test::MirrorWindowTestApi test_api;
1628 EXPECT_EQ(nullptr, test_api.GetHost()); 1634 EXPECT_EQ(nullptr, test_api.GetHost());
1629 1635
1630 TestDisplayObserver display_observer; 1636 TestDisplayObserver display_observer;
1631 display::Screen::GetScreen()->AddObserver(&display_observer); 1637 display::Screen::GetScreen()->AddObserver(&display_observer);
1632 1638
1633 display_manager()->SetMultiDisplayMode(DisplayManager::MIRRORING); 1639 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING);
1634 display_manager()->UpdateDisplays(); 1640 display_manager()->UpdateDisplays();
1635 RunAllPendingInMessageLoop(); 1641 RunAllPendingInMessageLoop();
1636 EXPECT_TRUE(display_observer.changed_and_reset()); 1642 EXPECT_TRUE(display_observer.changed_and_reset());
1637 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 1643 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
1638 EXPECT_EQ( 1644 EXPECT_EQ(
1639 "0,0 300x400", 1645 "0,0 300x400",
1640 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString()); 1646 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString());
1641 EXPECT_EQ("400x500", test_api.GetHost()->GetBounds().size().ToString()); 1647 EXPECT_EQ("400x500", test_api.GetHost()->GetBounds().size().ToString());
1642 EXPECT_EQ("300x400", 1648 EXPECT_EQ("300x400",
1643 test_api.GetHost()->window()->bounds().size().ToString()); 1649 test_api.GetHost()->window()->bounds().size().ToString());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 primary_id, display::Display::ROTATE_180, 1702 primary_id, display::Display::ROTATE_180,
1697 display::Display::ROTATION_SOURCE_ACTIVE); 1703 display::Display::ROTATION_SOURCE_ACTIVE);
1698 display_manager()->SetMirrorMode(false); 1704 display_manager()->SetMirrorMode(false);
1699 } 1705 }
1700 1706
1701 TEST_P(DisplayManagerTest, SingleDisplayToSoftwareMirroring) { 1707 TEST_P(DisplayManagerTest, SingleDisplayToSoftwareMirroring) {
1702 if (!SupportsMultipleDisplays()) 1708 if (!SupportsMultipleDisplays())
1703 return; 1709 return;
1704 UpdateDisplay("600x400"); 1710 UpdateDisplay("600x400");
1705 1711
1706 display_manager()->SetMultiDisplayMode(DisplayManager::MIRRORING); 1712 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING);
1707 UpdateDisplay("600x400,600x400"); 1713 UpdateDisplay("600x400,600x400");
1708 1714
1709 EXPECT_TRUE(display_manager()->IsInMirrorMode()); 1715 EXPECT_TRUE(display_manager()->IsInMirrorMode());
1710 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 1716 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
1711 WindowTreeHostManager* window_tree_host_manager = 1717 WindowTreeHostManager* window_tree_host_manager =
1712 ash::Shell::GetInstance()->window_tree_host_manager(); 1718 ash::Shell::GetInstance()->window_tree_host_manager();
1713 EXPECT_TRUE( 1719 EXPECT_TRUE(
1714 window_tree_host_manager->mirror_window_controller()->GetWindow()); 1720 window_tree_host_manager->mirror_window_controller()->GetWindow());
1715 1721
1716 UpdateDisplay("600x400"); 1722 UpdateDisplay("600x400");
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1951 UpdateDisplay("500x300,400x500"); 1957 UpdateDisplay("500x300,400x500");
1952 // 400 * 300 / 500 + 500 ~= 739. 1958 // 400 * 300 / 500 + 500 ~= 739.
1953 EXPECT_EQ(gfx::Size(739, 300), screen->GetPrimaryDisplay().size()); 1959 EXPECT_EQ(gfx::Size(739, 300), screen->GetPrimaryDisplay().size());
1954 1960
1955 // The default should fit to the internal display. 1961 // The default should fit to the internal display.
1956 std::vector<display::ManagedDisplayInfo> display_info_list; 1962 std::vector<display::ManagedDisplayInfo> display_info_list;
1957 display_info_list.push_back(CreateDisplayInfo(10, gfx::Rect(0, 0, 500, 300))); 1963 display_info_list.push_back(CreateDisplayInfo(10, gfx::Rect(0, 0, 500, 300)));
1958 display_info_list.push_back( 1964 display_info_list.push_back(
1959 CreateDisplayInfo(11, gfx::Rect(500, 0, 400, 500))); 1965 CreateDisplayInfo(11, gfx::Rect(500, 0, 400, 500)));
1960 { 1966 {
1961 test::ScopedSetInternalDisplayId set_internal(display_manager(), 11); 1967 display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
1968 11);
1962 display_manager()->OnNativeDisplaysChanged(display_info_list); 1969 display_manager()->OnNativeDisplaysChanged(display_info_list);
1963 // 500 * 500 / 300 + 400 ~= 1233. 1970 // 500 * 500 / 300 + 400 ~= 1233.
1964 EXPECT_EQ(gfx::Size(1233, 500), screen->GetPrimaryDisplay().size()); 1971 EXPECT_EQ(gfx::Size(1233, 500), screen->GetPrimaryDisplay().size());
1965 } 1972 }
1966 1973
1967 // Switch to 3 displays. 1974 // Switch to 3 displays.
1968 UpdateDisplay("500x300,400x500,500x300"); 1975 UpdateDisplay("500x300,400x500,500x300");
1969 EXPECT_EQ(gfx::Size(1239, 300), screen->GetPrimaryDisplay().size()); 1976 EXPECT_EQ(gfx::Size(1239, 300), screen->GetPrimaryDisplay().size());
1970 1977
1971 // Switch back to extended desktop. 1978 // Switch back to extended desktop.
(...skipping 24 matching lines...) Expand all
1996 display_info_list.push_back(d2); 2003 display_info_list.push_back(d2);
1997 display_manager()->OnNativeDisplaysChanged(display_info_list); 2004 display_manager()->OnNativeDisplaysChanged(display_info_list);
1998 ASSERT_TRUE(display_manager()->IsInMirrorMode()); 2005 ASSERT_TRUE(display_manager()->IsInMirrorMode());
1999 display_manager()->SetUnifiedDesktopEnabled(true); 2006 display_manager()->SetUnifiedDesktopEnabled(true);
2000 EXPECT_TRUE(display_manager()->IsInMirrorMode()); 2007 EXPECT_TRUE(display_manager()->IsInMirrorMode());
2001 2008
2002 // The display manager automaticaclly switches to software mirroring 2009 // The display manager automaticaclly switches to software mirroring
2003 // if the displays are configured to use mirroring when running on desktop. 2010 // if the displays are configured to use mirroring when running on desktop.
2004 // This is a workdaround to force the display manager to forget 2011 // This is a workdaround to force the display manager to forget
2005 // the mirroing layout. 2012 // the mirroing layout.
2006 display::DisplayIdList list = test::CreateDisplayIdList2(1, 2); 2013 display::DisplayIdList list = display::test::CreateDisplayIdList2(1, 2);
2007 display::DisplayLayoutBuilder builder( 2014 display::DisplayLayoutBuilder builder(
2008 display_manager()->layout_store()->GetRegisteredDisplayLayout(list)); 2015 display_manager()->layout_store()->GetRegisteredDisplayLayout(list));
2009 builder.SetMirrored(false); 2016 builder.SetMirrored(false);
2010 display_manager()->layout_store()->RegisterLayoutForDisplayIdList( 2017 display_manager()->layout_store()->RegisterLayoutForDisplayIdList(
2011 list, builder.Build()); 2018 list, builder.Build());
2012 2019
2013 // Exit from hardware mirroring. 2020 // Exit from hardware mirroring.
2014 d2.SetBounds(gfx::Rect(0, 500, 500, 500)); 2021 d2.SetBounds(gfx::Rect(0, 500, 500, 500));
2015 display_info_list.clear(); 2022 display_info_list.clear();
2016 display_info_list.push_back(d1); 2023 display_info_list.push_back(d1);
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
2219 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500)); 2226 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500));
2220 const display::ManagedDisplayInfo external_display_info = 2227 const display::ManagedDisplayInfo external_display_info =
2221 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); 2228 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100));
2222 std::vector<display::ManagedDisplayInfo> display_info_list; 2229 std::vector<display::ManagedDisplayInfo> display_info_list;
2223 2230
2224 // software mirroring. 2231 // software mirroring.
2225 display_info_list.push_back(internal_display_info); 2232 display_info_list.push_back(internal_display_info);
2226 display_info_list.push_back(external_display_info); 2233 display_info_list.push_back(external_display_info);
2227 display_manager()->OnNativeDisplaysChanged(display_info_list); 2234 display_manager()->OnNativeDisplaysChanged(display_info_list);
2228 const int64_t internal_display_id = 2235 const int64_t internal_display_id =
2229 test::DisplayManagerTestApi(display_manager()) 2236 display::test::DisplayManagerTestApi(display_manager())
2230 .SetFirstDisplayAsInternalDisplay(); 2237 .SetFirstDisplayAsInternalDisplay();
2231 EXPECT_EQ(internal_id, internal_display_id); 2238 EXPECT_EQ(internal_id, internal_display_id);
2232 2239
2233 display_info_list.clear(); 2240 display_info_list.clear();
2234 display_info_list.push_back(external_display_info); 2241 display_info_list.push_back(external_display_info);
2235 display_manager()->OnNativeDisplaysChanged(display_info_list); 2242 display_manager()->OnNativeDisplaysChanged(display_info_list);
2236 EXPECT_EQ(1U, display_manager()->active_display_list().size()); 2243 EXPECT_EQ(1U, display_manager()->active_display_list().size());
2237 2244
2238 EXPECT_TRUE(display_manager()->IsActiveDisplayId(external_id)); 2245 EXPECT_TRUE(display_manager()->IsActiveDisplayId(external_id));
2239 EXPECT_FALSE(display_manager()->IsActiveDisplayId(internal_id)); 2246 EXPECT_FALSE(display_manager()->IsActiveDisplayId(internal_id));
2240 2247
2241 EXPECT_FALSE(display_manager()->ZoomInternalDisplay(true)); 2248 EXPECT_FALSE(display_manager()->ZoomInternalDisplay(true));
2242 EXPECT_FALSE(display_manager()->ZoomInternalDisplay(false)); 2249 EXPECT_FALSE(display_manager()->ZoomInternalDisplay(false));
2243 EXPECT_FALSE(test::DisplayManagerTestApi(display_manager()) 2250 EXPECT_FALSE(display::test::DisplayManagerTestApi(display_manager())
2244 .SetDisplayUIScale(internal_id, 1.0f)); 2251 .SetDisplayUIScale(internal_id, 1.0f));
2245 } 2252 }
2246 2253
2247 // Make sure that bad layout information is ignored and does not crash. 2254 // Make sure that bad layout information is ignored and does not crash.
2248 TEST_P(DisplayManagerTest, DontRegisterBadConfig) { 2255 TEST_P(DisplayManagerTest, DontRegisterBadConfig) {
2249 if (!SupportsMultipleDisplays()) 2256 if (!SupportsMultipleDisplays())
2250 return; 2257 return;
2251 display::DisplayIdList list = ash::test::CreateDisplayIdList2(1, 2); 2258 display::DisplayIdList list = display::test::CreateDisplayIdList2(1, 2);
2252 display::DisplayLayoutBuilder builder(1); 2259 display::DisplayLayoutBuilder builder(1);
2253 builder.AddDisplayPlacement(2, 1, display::DisplayPlacement::LEFT, 0); 2260 builder.AddDisplayPlacement(2, 1, display::DisplayPlacement::LEFT, 0);
2254 builder.AddDisplayPlacement(3, 1, display::DisplayPlacement::BOTTOM, 0); 2261 builder.AddDisplayPlacement(3, 1, display::DisplayPlacement::BOTTOM, 0);
2255 2262
2256 display_manager()->layout_store()->RegisterLayoutForDisplayIdList( 2263 display_manager()->layout_store()->RegisterLayoutForDisplayIdList(
2257 list, builder.Build()); 2264 list, builder.Build());
2258 } 2265 }
2259 2266
2260 class ScreenShutdownTest : public test::AshTestBase { 2267 class ScreenShutdownTest : public test::AshTestBase {
2261 public: 2268 public:
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2334 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100Internal) { 2341 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100Internal) {
2335 FontTestHelper helper(1.0f, FontTestHelper::INTERNAL); 2342 FontTestHelper helper(1.0f, FontTestHelper::INTERNAL);
2336 ASSERT_DOUBLE_EQ( 2343 ASSERT_DOUBLE_EQ(
2337 1.0f, 2344 1.0f,
2338 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 2345 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
2339 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); 2346 EXPECT_FALSE(IsTextSubpixelPositioningEnabled());
2340 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); 2347 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
2341 } 2348 }
2342 2349
2343 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125Internal) { 2350 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125Internal) {
2344 test::ScopedDisable125DSFForUIScaling disable; 2351 display::test::ScopedDisable125DSFForUIScaling disable;
2345 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL); 2352 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL);
2346 ASSERT_DOUBLE_EQ( 2353 ASSERT_DOUBLE_EQ(
2347 1.25f, 2354 1.25f,
2348 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 2355 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
2349 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); 2356 EXPECT_TRUE(IsTextSubpixelPositioningEnabled());
2350 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); 2357 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
2351 } 2358 }
2352 2359
2353 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200Internal) { 2360 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200Internal) {
2354 FontTestHelper helper(2.0f, FontTestHelper::INTERNAL); 2361 FontTestHelper helper(2.0f, FontTestHelper::INTERNAL);
2355 ASSERT_DOUBLE_EQ( 2362 ASSERT_DOUBLE_EQ(
2356 2.0f, 2363 2.0f,
2357 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 2364 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
2358 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); 2365 EXPECT_TRUE(IsTextSubpixelPositioningEnabled());
2359 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); 2366 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
2360 2367
2361 test::DisplayManagerTestApi(helper.display_manager()) 2368 display::test::DisplayManagerTestApi(helper.display_manager())
2362 .SetDisplayUIScale(display::Screen::GetScreen()->GetPrimaryDisplay().id(), 2369 .SetDisplayUIScale(display::Screen::GetScreen()->GetPrimaryDisplay().id(),
2363 2.0f); 2370 2.0f);
2364 2371
2365 ASSERT_DOUBLE_EQ( 2372 ASSERT_DOUBLE_EQ(
2366 1.0f, 2373 1.0f,
2367 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 2374 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
2368 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); 2375 EXPECT_FALSE(IsTextSubpixelPositioningEnabled());
2369 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); 2376 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
2370 } 2377 }
2371 2378
(...skipping 26 matching lines...) Expand all
2398 2405
2399 TEST_F(DisplayManagerFontTest, 2406 TEST_F(DisplayManagerFontTest,
2400 TextSubpixelPositioningWithDsf125InternalWithScaling) { 2407 TextSubpixelPositioningWithDsf125InternalWithScaling) {
2401 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL); 2408 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL);
2402 ASSERT_DOUBLE_EQ( 2409 ASSERT_DOUBLE_EQ(
2403 1.0f, 2410 1.0f,
2404 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 2411 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
2405 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); 2412 EXPECT_FALSE(IsTextSubpixelPositioningEnabled());
2406 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); 2413 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
2407 2414
2408 test::DisplayManagerTestApi(helper.display_manager()) 2415 display::test::DisplayManagerTestApi(helper.display_manager())
2409 .SetDisplayUIScale(display::Screen::GetScreen()->GetPrimaryDisplay().id(), 2416 .SetDisplayUIScale(display::Screen::GetScreen()->GetPrimaryDisplay().id(),
2410 0.8f); 2417 0.8f);
2411 2418
2412 ASSERT_DOUBLE_EQ( 2419 ASSERT_DOUBLE_EQ(
2413 1.25f, 2420 1.25f,
2414 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 2421 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
2415 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); 2422 EXPECT_TRUE(IsTextSubpixelPositioningEnabled());
2416 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); 2423 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
2417 } 2424 }
2418 2425
(...skipping 14 matching lines...) Expand all
2433 2440
2434 TEST_P(DisplayManagerTest, RejectInvalidLayoutData) { 2441 TEST_P(DisplayManagerTest, RejectInvalidLayoutData) {
2435 display::DisplayLayoutStore* layout_store = display_manager()->layout_store(); 2442 display::DisplayLayoutStore* layout_store = display_manager()->layout_store();
2436 int64_t id1 = 10001; 2443 int64_t id1 = 10001;
2437 int64_t id2 = 10002; 2444 int64_t id2 = 10002;
2438 ASSERT_TRUE(display::CompareDisplayIds(id1, id2)); 2445 ASSERT_TRUE(display::CompareDisplayIds(id1, id2));
2439 display::DisplayLayoutBuilder good_builder(id1); 2446 display::DisplayLayoutBuilder good_builder(id1);
2440 good_builder.SetSecondaryPlacement(id2, display::DisplayPlacement::LEFT, 0); 2447 good_builder.SetSecondaryPlacement(id2, display::DisplayPlacement::LEFT, 0);
2441 std::unique_ptr<display::DisplayLayout> good(good_builder.Build()); 2448 std::unique_ptr<display::DisplayLayout> good(good_builder.Build());
2442 2449
2443 display::DisplayIdList good_list = test::CreateDisplayIdList2(id1, id2); 2450 display::DisplayIdList good_list =
2451 display::test::CreateDisplayIdList2(id1, id2);
2444 layout_store->RegisterLayoutForDisplayIdList(good_list, good->Copy()); 2452 layout_store->RegisterLayoutForDisplayIdList(good_list, good->Copy());
2445 2453
2446 display::DisplayLayoutBuilder bad(id1); 2454 display::DisplayLayoutBuilder bad(id1);
2447 bad.SetSecondaryPlacement(id2, display::DisplayPlacement::BOTTOM, 0); 2455 bad.SetSecondaryPlacement(id2, display::DisplayPlacement::BOTTOM, 0);
2448 2456
2449 display::DisplayIdList bad_list(2); 2457 display::DisplayIdList bad_list(2);
2450 bad_list[0] = id2; 2458 bad_list[0] = id2;
2451 bad_list[1] = id1; 2459 bad_list[1] = id1;
2452 layout_store->RegisterLayoutForDisplayIdList(bad_list, bad.Build()); 2460 layout_store->RegisterLayoutForDisplayIdList(bad_list, bad.Build());
2453 2461
2454 EXPECT_EQ(good->ToString(), 2462 EXPECT_EQ(good->ToString(),
2455 layout_store->GetRegisteredDisplayLayout(good_list).ToString()); 2463 layout_store->GetRegisteredDisplayLayout(good_list).ToString());
2456 } 2464 }
2457 2465
2458 TEST_P(DisplayManagerTest, GuessDisplayIdFieldsInDisplayLayout) { 2466 TEST_P(DisplayManagerTest, GuessDisplayIdFieldsInDisplayLayout) {
2459 int64_t id1 = 10001; 2467 int64_t id1 = 10001;
2460 int64_t id2 = 10002; 2468 int64_t id2 = 10002;
2461 2469
2462 std::unique_ptr<display::DisplayLayout> old_layout( 2470 std::unique_ptr<display::DisplayLayout> old_layout(
2463 new display::DisplayLayout); 2471 new display::DisplayLayout);
2464 old_layout->placement_list.emplace_back(display::DisplayPlacement::BOTTOM, 0); 2472 old_layout->placement_list.emplace_back(display::DisplayPlacement::BOTTOM, 0);
2465 old_layout->primary_id = id1; 2473 old_layout->primary_id = id1;
2466 2474
2467 display::DisplayLayoutStore* layout_store = display_manager()->layout_store(); 2475 display::DisplayLayoutStore* layout_store = display_manager()->layout_store();
2468 display::DisplayIdList list = test::CreateDisplayIdList2(id1, id2); 2476 display::DisplayIdList list = display::test::CreateDisplayIdList2(id1, id2);
2469 layout_store->RegisterLayoutForDisplayIdList(list, std::move(old_layout)); 2477 layout_store->RegisterLayoutForDisplayIdList(list, std::move(old_layout));
2470 const display::DisplayLayout& stored = 2478 const display::DisplayLayout& stored =
2471 layout_store->GetRegisteredDisplayLayout(list); 2479 layout_store->GetRegisteredDisplayLayout(list);
2472 2480
2473 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id); 2481 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id);
2474 EXPECT_EQ(id2, stored.placement_list[0].display_id); 2482 EXPECT_EQ(id2, stored.placement_list[0].display_id);
2475 } 2483 }
2476 2484
2477 #endif // OS_CHROMEOS 2485 #endif // OS_CHROMEOS
2478 2486
2479 } // namespace ash 2487 } // 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