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

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

Issue 2445583002: Relocate display_manager from ash to ui (Closed)
Patch Set: 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
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 display_manager()->SetDisplayUIScale(display_id, 1.125f); 1139 display_manager()->SetDisplayUIScale(display_id, 1.125f);
1140 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale()); 1140 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale());
1141 display_manager()->SetDisplayUIScale(display_id, 0.8f); 1141 display_manager()->SetDisplayUIScale(display_id, 0.8f);
1142 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1142 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1143 display_manager()->SetDisplayUIScale(display_id, 0.75f); 1143 display_manager()->SetDisplayUIScale(display_id, 0.75f);
1144 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1144 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1145 display_manager()->SetDisplayUIScale(display_id, 0.625f); 1145 display_manager()->SetDisplayUIScale(display_id, 0.625f);
1146 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1146 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1147 1147
1148 test::ScopedSetInternalDisplayId set_internal(display_manager(), display_id); 1148 display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
1149 display_id);
1149 1150
1150 display_manager()->SetDisplayUIScale(display_id, 1.5f); 1151 display_manager()->SetDisplayUIScale(display_id, 1.5f);
1151 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1152 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1152 display_manager()->SetDisplayUIScale(display_id, 1.25f); 1153 display_manager()->SetDisplayUIScale(display_id, 1.25f);
1153 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1154 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1154 display_manager()->SetDisplayUIScale(display_id, 1.125f); 1155 display_manager()->SetDisplayUIScale(display_id, 1.125f);
1155 EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale()); 1156 EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale());
1156 display_manager()->SetDisplayUIScale(display_id, 0.8f); 1157 display_manager()->SetDisplayUIScale(display_id, 0.8f);
1157 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale()); 1158 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale());
1158 display_manager()->SetDisplayUIScale(display_id, 0.75f); 1159 display_manager()->SetDisplayUIScale(display_id, 0.75f);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 native_display_info.SetManagedDisplayModes(mode_list); 1241 native_display_info.SetManagedDisplayModes(mode_list);
1241 1242
1242 std::vector<display::ManagedDisplayInfo> display_info_list; 1243 std::vector<display::ManagedDisplayInfo> display_info_list;
1243 display_info_list.push_back(native_display_info); 1244 display_info_list.push_back(native_display_info);
1244 display_manager()->OnNativeDisplaysChanged(display_info_list); 1245 display_manager()->OnNativeDisplaysChanged(display_info_list);
1245 1246
1246 scoped_refptr<display::ManagedDisplayMode> expected_mode = base_mode; 1247 scoped_refptr<display::ManagedDisplayMode> expected_mode = base_mode;
1247 EXPECT_TRUE(expected_mode->IsEquivalent( 1248 EXPECT_TRUE(expected_mode->IsEquivalent(
1248 display_manager()->GetActiveModeForDisplayId(display_id))); 1249 display_manager()->GetActiveModeForDisplayId(display_id)));
1249 1250
1250 test::ScopedSetInternalDisplayId set_internal(display_manager(), display_id); 1251 display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
1252 display_id);
1251 1253
1252 display_manager()->SetDisplayUIScale(display_id, 1.5f); 1254 display_manager()->SetDisplayUIScale(display_id, 1.5f);
1253 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1255 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1254 EXPECT_TRUE(expected_mode->IsEquivalent( 1256 EXPECT_TRUE(expected_mode->IsEquivalent(
1255 display_manager()->GetActiveModeForDisplayId(display_id))); 1257 display_manager()->GetActiveModeForDisplayId(display_id)));
1256 display_manager()->SetDisplayUIScale(display_id, 1.25f); 1258 display_manager()->SetDisplayUIScale(display_id, 1.25f);
1257 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1259 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1258 EXPECT_TRUE(expected_mode->IsEquivalent( 1260 EXPECT_TRUE(expected_mode->IsEquivalent(
1259 display_manager()->GetActiveModeForDisplayId(display_id))); 1261 display_manager()->GetActiveModeForDisplayId(display_id)));
1260 display_manager()->SetDisplayUIScale(display_id, 1.125f); 1262 display_manager()->SetDisplayUIScale(display_id, 1.125f);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 1307
1306 EXPECT_TRUE(expected_mode->IsEquivalent( 1308 EXPECT_TRUE(expected_mode->IsEquivalent(
1307 display_manager()->GetActiveModeForDisplayId(display_id))); 1309 display_manager()->GetActiveModeForDisplayId(display_id)));
1308 } 1310 }
1309 1311
1310 // TODO(msw): Broken on Windows. http://crbug.com/584038 1312 // TODO(msw): Broken on Windows. http://crbug.com/584038
1311 #if defined(OS_CHROMEOS) 1313 #if defined(OS_CHROMEOS)
1312 TEST_P(DisplayManagerTest, Use125DSFForUIScaling) { 1314 TEST_P(DisplayManagerTest, Use125DSFForUIScaling) {
1313 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1315 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1314 1316
1315 test::ScopedSetInternalDisplayId set_internal(display_manager(), display_id); 1317 display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
1318 display_id);
1316 UpdateDisplay("1920x1080*1.25"); 1319 UpdateDisplay("1920x1080*1.25");
1317 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1320 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1318 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1321 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1319 1322
1320 display_manager()->SetDisplayUIScale(display_id, 0.8f); 1323 display_manager()->SetDisplayUIScale(display_id, 0.8f);
1321 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1324 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1322 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1325 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1323 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString()); 1326 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString());
1324 1327
1325 display_manager()->SetDisplayUIScale(display_id, 0.5f); 1328 display_manager()->SetDisplayUIScale(display_id, 0.5f);
1326 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1329 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1327 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1330 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1328 EXPECT_EQ("960x540", GetDisplayForId(display_id).size().ToString()); 1331 EXPECT_EQ("960x540", GetDisplayForId(display_id).size().ToString());
1329 1332
1330 display_manager()->SetDisplayUIScale(display_id, 1.25f); 1333 display_manager()->SetDisplayUIScale(display_id, 1.25f);
1331 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1334 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1332 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1335 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1333 EXPECT_EQ("2400x1350", GetDisplayForId(display_id).size().ToString()); 1336 EXPECT_EQ("2400x1350", GetDisplayForId(display_id).size().ToString());
1334 } 1337 }
1335 #endif // defined(OS_CHROMEOS) 1338 #endif // defined(OS_CHROMEOS)
1336 1339
1337 // TODO(msw): Broken on Windows. http://crbug.com/584038 1340 // TODO(msw): Broken on Windows. http://crbug.com/584038
1338 #if defined(OS_CHROMEOS) 1341 #if defined(OS_CHROMEOS)
1339 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScaling) { 1342 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScaling) {
1340 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1343 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1341 1344
1342 display_id++; 1345 display_id++;
1343 test::ScopedSetInternalDisplayId set_internal(display_manager(), display_id); 1346 display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
1347 display_id);
1344 1348
1345 // Setup the display modes with UI-scale. 1349 // Setup the display modes with UI-scale.
1346 display::ManagedDisplayInfo native_display_info = 1350 display::ManagedDisplayInfo native_display_info =
1347 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080)); 1351 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080));
1348 native_display_info.set_device_scale_factor(1.25); 1352 native_display_info.set_device_scale_factor(1.25);
1349 1353
1350 const scoped_refptr<display::ManagedDisplayMode>& base_mode( 1354 const scoped_refptr<display::ManagedDisplayMode>& base_mode(
1351 new display::ManagedDisplayMode(gfx::Size(1920, 1080), 60.0f, false, 1355 new display::ManagedDisplayMode(gfx::Size(1920, 1080), 60.0f, false,
1352 false)); 1356 false));
1353 display::ManagedDisplayInfo::ManagedDisplayModeList mode_list = 1357 display::ManagedDisplayInfo::ManagedDisplayModeList mode_list =
(...skipping 11 matching lines...) Expand all
1365 #endif // defined(OS_CHROMEOS) 1369 #endif // defined(OS_CHROMEOS)
1366 1370
1367 // TODO(msw): Broken on Windows. http://crbug.com/584038 1371 // TODO(msw): Broken on Windows. http://crbug.com/584038
1368 #if defined(OS_CHROMEOS) 1372 #if defined(OS_CHROMEOS)
1369 // Don't default to 1.25 DSF if the user already has a prefrence stored for 1373 // Don't default to 1.25 DSF if the user already has a prefrence stored for
1370 // the internal display. 1374 // the internal display.
1371 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScalingNoOverride) { 1375 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScalingNoOverride) {
1372 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1376 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
1373 1377
1374 display_id++; 1378 display_id++;
1375 test::ScopedSetInternalDisplayId set_internal(display_manager(), display_id); 1379 display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
1380 display_id);
1376 const gfx::Insets dummy_overscan_insets; 1381 const gfx::Insets dummy_overscan_insets;
1377 display_manager()->RegisterDisplayProperty( 1382 display_manager()->RegisterDisplayProperty(
1378 display_id, display::Display::ROTATE_0, 1.0f, &dummy_overscan_insets, 1383 display_id, display::Display::ROTATE_0, 1.0f, &dummy_overscan_insets,
1379 gfx::Size(), 1.0f, ui::ColorCalibrationProfile()); 1384 gfx::Size(), 1.0f, ui::ColorCalibrationProfile());
1380 1385
1381 // Setup the display modes with UI-scale. 1386 // Setup the display modes with UI-scale.
1382 display::ManagedDisplayInfo native_display_info = 1387 display::ManagedDisplayInfo native_display_info =
1383 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080)); 1388 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080));
1384 native_display_info.set_device_scale_factor(1.25); 1389 native_display_info.set_device_scale_factor(1.25);
1385 1390
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 EXPECT_EQ("800x400", info.display_modes()[1]->size().ToString()); 1424 EXPECT_EQ("800x400", info.display_modes()[1]->size().ToString());
1420 EXPECT_FALSE(info.display_modes()[1]->native()); 1425 EXPECT_FALSE(info.display_modes()[1]->native());
1421 EXPECT_EQ( 1426 EXPECT_EQ(
1422 "400x200", 1427 "400x200",
1423 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); 1428 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString());
1424 scoped_refptr<display::ManagedDisplayMode> active_mode = 1429 scoped_refptr<display::ManagedDisplayMode> active_mode =
1425 display_manager()->GetActiveModeForDisplayId(unified_id); 1430 display_manager()->GetActiveModeForDisplayId(unified_id);
1426 EXPECT_EQ(1.0f, active_mode->ui_scale()); 1431 EXPECT_EQ(1.0f, active_mode->ui_scale());
1427 EXPECT_EQ("400x200", active_mode->size().ToString()); 1432 EXPECT_EQ("400x200", active_mode->size().ToString());
1428 1433
1429 EXPECT_TRUE(test::SetDisplayResolution(display_manager(), unified_id, 1434 EXPECT_TRUE(display::test::SetDisplayResolution(display_manager(), unified_id,
1430 gfx::Size(800, 400))); 1435 gfx::Size(800, 400)));
1431 EXPECT_EQ( 1436 EXPECT_EQ(
1432 "800x400", 1437 "800x400",
1433 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); 1438 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString());
1434 1439
1435 active_mode = display_manager()->GetActiveModeForDisplayId(unified_id); 1440 active_mode = display_manager()->GetActiveModeForDisplayId(unified_id);
1436 EXPECT_EQ(1.0f, active_mode->ui_scale()); 1441 EXPECT_EQ(1.0f, active_mode->ui_scale());
1437 EXPECT_EQ("800x400", active_mode->size().ToString()); 1442 EXPECT_EQ("800x400", active_mode->size().ToString());
1438 1443
1439 // resolution change will not persist in unified desktop mode. 1444 // resolution change will not persist in unified desktop mode.
1440 UpdateDisplay("600x600, 200x200"); 1445 UpdateDisplay("600x600, 200x200");
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 return; 1542 return;
1538 1543
1539 UpdateDisplay("300x400,400x500"); 1544 UpdateDisplay("300x400,400x500");
1540 1545
1541 test::MirrorWindowTestApi test_api; 1546 test::MirrorWindowTestApi test_api;
1542 EXPECT_EQ(nullptr, test_api.GetHost()); 1547 EXPECT_EQ(nullptr, test_api.GetHost());
1543 1548
1544 TestDisplayObserver display_observer; 1549 TestDisplayObserver display_observer;
1545 display::Screen::GetScreen()->AddObserver(&display_observer); 1550 display::Screen::GetScreen()->AddObserver(&display_observer);
1546 1551
1547 display_manager()->SetMultiDisplayMode(DisplayManager::MIRRORING); 1552 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING);
1548 display_manager()->UpdateDisplays(); 1553 display_manager()->UpdateDisplays();
1549 RunAllPendingInMessageLoop(); 1554 RunAllPendingInMessageLoop();
1550 EXPECT_TRUE(display_observer.changed_and_reset()); 1555 EXPECT_TRUE(display_observer.changed_and_reset());
1551 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 1556 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
1552 EXPECT_EQ( 1557 EXPECT_EQ(
1553 "0,0 300x400", 1558 "0,0 300x400",
1554 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString()); 1559 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString());
1555 EXPECT_EQ("400x500", test_api.GetHost()->GetBounds().size().ToString()); 1560 EXPECT_EQ("400x500", test_api.GetHost()->GetBounds().size().ToString());
1556 EXPECT_EQ("300x400", 1561 EXPECT_EQ("300x400",
1557 test_api.GetHost()->window()->bounds().size().ToString()); 1562 test_api.GetHost()->window()->bounds().size().ToString());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1610 primary_id, display::Display::ROTATE_180, 1615 primary_id, display::Display::ROTATE_180,
1611 display::Display::ROTATION_SOURCE_ACTIVE); 1616 display::Display::ROTATION_SOURCE_ACTIVE);
1612 display_manager()->SetMirrorMode(false); 1617 display_manager()->SetMirrorMode(false);
1613 } 1618 }
1614 1619
1615 TEST_P(DisplayManagerTest, SingleDisplayToSoftwareMirroring) { 1620 TEST_P(DisplayManagerTest, SingleDisplayToSoftwareMirroring) {
1616 if (!SupportsMultipleDisplays()) 1621 if (!SupportsMultipleDisplays())
1617 return; 1622 return;
1618 UpdateDisplay("600x400"); 1623 UpdateDisplay("600x400");
1619 1624
1620 display_manager()->SetMultiDisplayMode(DisplayManager::MIRRORING); 1625 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING);
1621 UpdateDisplay("600x400,600x400"); 1626 UpdateDisplay("600x400,600x400");
1622 1627
1623 EXPECT_TRUE(display_manager()->IsInMirrorMode()); 1628 EXPECT_TRUE(display_manager()->IsInMirrorMode());
1624 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 1629 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
1625 WindowTreeHostManager* window_tree_host_manager = 1630 WindowTreeHostManager* window_tree_host_manager =
1626 ash::Shell::GetInstance()->window_tree_host_manager(); 1631 ash::Shell::GetInstance()->window_tree_host_manager();
1627 EXPECT_TRUE( 1632 EXPECT_TRUE(
1628 window_tree_host_manager->mirror_window_controller()->GetWindow()); 1633 window_tree_host_manager->mirror_window_controller()->GetWindow());
1629 1634
1630 UpdateDisplay("600x400"); 1635 UpdateDisplay("600x400");
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1865 UpdateDisplay("500x300,400x500"); 1870 UpdateDisplay("500x300,400x500");
1866 // 400 * 300 / 500 + 500 ~= 739. 1871 // 400 * 300 / 500 + 500 ~= 739.
1867 EXPECT_EQ(gfx::Size(739, 300), screen->GetPrimaryDisplay().size()); 1872 EXPECT_EQ(gfx::Size(739, 300), screen->GetPrimaryDisplay().size());
1868 1873
1869 // The default should fit to the internal display. 1874 // The default should fit to the internal display.
1870 std::vector<display::ManagedDisplayInfo> display_info_list; 1875 std::vector<display::ManagedDisplayInfo> display_info_list;
1871 display_info_list.push_back(CreateDisplayInfo(10, gfx::Rect(0, 0, 500, 300))); 1876 display_info_list.push_back(CreateDisplayInfo(10, gfx::Rect(0, 0, 500, 300)));
1872 display_info_list.push_back( 1877 display_info_list.push_back(
1873 CreateDisplayInfo(11, gfx::Rect(500, 0, 400, 500))); 1878 CreateDisplayInfo(11, gfx::Rect(500, 0, 400, 500)));
1874 { 1879 {
1875 test::ScopedSetInternalDisplayId set_internal(display_manager(), 11); 1880 display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
1881 11);
1876 display_manager()->OnNativeDisplaysChanged(display_info_list); 1882 display_manager()->OnNativeDisplaysChanged(display_info_list);
1877 // 500 * 500 / 300 + 400 ~= 1233. 1883 // 500 * 500 / 300 + 400 ~= 1233.
1878 EXPECT_EQ(gfx::Size(1233, 500), screen->GetPrimaryDisplay().size()); 1884 EXPECT_EQ(gfx::Size(1233, 500), screen->GetPrimaryDisplay().size());
1879 } 1885 }
1880 1886
1881 // Switch to 3 displays. 1887 // Switch to 3 displays.
1882 UpdateDisplay("500x300,400x500,500x300"); 1888 UpdateDisplay("500x300,400x500,500x300");
1883 EXPECT_EQ(gfx::Size(1239, 300), screen->GetPrimaryDisplay().size()); 1889 EXPECT_EQ(gfx::Size(1239, 300), screen->GetPrimaryDisplay().size());
1884 1890
1885 // Switch back to extended desktop. 1891 // Switch back to extended desktop.
(...skipping 24 matching lines...) Expand all
1910 display_info_list.push_back(d2); 1916 display_info_list.push_back(d2);
1911 display_manager()->OnNativeDisplaysChanged(display_info_list); 1917 display_manager()->OnNativeDisplaysChanged(display_info_list);
1912 ASSERT_TRUE(display_manager()->IsInMirrorMode()); 1918 ASSERT_TRUE(display_manager()->IsInMirrorMode());
1913 display_manager()->SetUnifiedDesktopEnabled(true); 1919 display_manager()->SetUnifiedDesktopEnabled(true);
1914 EXPECT_TRUE(display_manager()->IsInMirrorMode()); 1920 EXPECT_TRUE(display_manager()->IsInMirrorMode());
1915 1921
1916 // The display manager automaticaclly switches to software mirroring 1922 // The display manager automaticaclly switches to software mirroring
1917 // if the displays are configured to use mirroring when running on desktop. 1923 // if the displays are configured to use mirroring when running on desktop.
1918 // This is a workdaround to force the display manager to forget 1924 // This is a workdaround to force the display manager to forget
1919 // the mirroing layout. 1925 // the mirroing layout.
1920 display::DisplayIdList list = test::CreateDisplayIdList2(1, 2); 1926 display::DisplayIdList list = display::test::CreateDisplayIdList2(1, 2);
1921 display::DisplayLayoutBuilder builder( 1927 display::DisplayLayoutBuilder builder(
1922 display_manager()->layout_store()->GetRegisteredDisplayLayout(list)); 1928 display_manager()->layout_store()->GetRegisteredDisplayLayout(list));
1923 builder.SetMirrored(false); 1929 builder.SetMirrored(false);
1924 display_manager()->layout_store()->RegisterLayoutForDisplayIdList( 1930 display_manager()->layout_store()->RegisterLayoutForDisplayIdList(
1925 list, builder.Build()); 1931 list, builder.Build());
1926 1932
1927 // Exit from hardware mirroring. 1933 // Exit from hardware mirroring.
1928 d2.SetBounds(gfx::Rect(0, 500, 500, 500)); 1934 d2.SetBounds(gfx::Rect(0, 500, 500, 500));
1929 display_info_list.clear(); 1935 display_info_list.clear();
1930 display_info_list.push_back(d1); 1936 display_info_list.push_back(d1);
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
2133 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500)); 2139 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500));
2134 const display::ManagedDisplayInfo external_display_info = 2140 const display::ManagedDisplayInfo external_display_info =
2135 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); 2141 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100));
2136 std::vector<display::ManagedDisplayInfo> display_info_list; 2142 std::vector<display::ManagedDisplayInfo> display_info_list;
2137 2143
2138 // software mirroring. 2144 // software mirroring.
2139 display_info_list.push_back(internal_display_info); 2145 display_info_list.push_back(internal_display_info);
2140 display_info_list.push_back(external_display_info); 2146 display_info_list.push_back(external_display_info);
2141 display_manager()->OnNativeDisplaysChanged(display_info_list); 2147 display_manager()->OnNativeDisplaysChanged(display_info_list);
2142 const int64_t internal_display_id = 2148 const int64_t internal_display_id =
2143 test::DisplayManagerTestApi(display_manager()) 2149 display::test::DisplayManagerTestApi(display_manager())
2144 .SetFirstDisplayAsInternalDisplay(); 2150 .SetFirstDisplayAsInternalDisplay();
2145 EXPECT_EQ(internal_id, internal_display_id); 2151 EXPECT_EQ(internal_id, internal_display_id);
2146 2152
2147 display_info_list.clear(); 2153 display_info_list.clear();
2148 display_info_list.push_back(external_display_info); 2154 display_info_list.push_back(external_display_info);
2149 display_manager()->OnNativeDisplaysChanged(display_info_list); 2155 display_manager()->OnNativeDisplaysChanged(display_info_list);
2150 EXPECT_EQ(1U, display_manager()->active_display_list().size()); 2156 EXPECT_EQ(1U, display_manager()->active_display_list().size());
2151 2157
2152 EXPECT_TRUE(display_manager()->IsActiveDisplayId(external_id)); 2158 EXPECT_TRUE(display_manager()->IsActiveDisplayId(external_id));
2153 EXPECT_FALSE(display_manager()->IsActiveDisplayId(internal_id)); 2159 EXPECT_FALSE(display_manager()->IsActiveDisplayId(internal_id));
2154 2160
2155 EXPECT_FALSE(display_manager()->ZoomInternalDisplay(true)); 2161 EXPECT_FALSE(display_manager()->ZoomInternalDisplay(true));
2156 EXPECT_FALSE(display_manager()->ZoomInternalDisplay(false)); 2162 EXPECT_FALSE(display_manager()->ZoomInternalDisplay(false));
2157 EXPECT_FALSE(display_manager()->SetDisplayUIScale(internal_id, 1.0f)); 2163 EXPECT_FALSE(display_manager()->SetDisplayUIScale(internal_id, 1.0f));
2158 } 2164 }
2159 2165
2160 // Make sure that bad layout information is ignored and does not crash. 2166 // Make sure that bad layout information is ignored and does not crash.
2161 TEST_P(DisplayManagerTest, DontRegisterBadConfig) { 2167 TEST_P(DisplayManagerTest, DontRegisterBadConfig) {
2162 if (!SupportsMultipleDisplays()) 2168 if (!SupportsMultipleDisplays())
2163 return; 2169 return;
2164 display::DisplayIdList list = ash::test::CreateDisplayIdList2(1, 2); 2170 display::DisplayIdList list = display::test::CreateDisplayIdList2(1, 2);
2165 display::DisplayLayoutBuilder builder(1); 2171 display::DisplayLayoutBuilder builder(1);
2166 builder.AddDisplayPlacement(2, 1, display::DisplayPlacement::LEFT, 0); 2172 builder.AddDisplayPlacement(2, 1, display::DisplayPlacement::LEFT, 0);
2167 builder.AddDisplayPlacement(3, 1, display::DisplayPlacement::BOTTOM, 0); 2173 builder.AddDisplayPlacement(3, 1, display::DisplayPlacement::BOTTOM, 0);
2168 2174
2169 display_manager()->layout_store()->RegisterLayoutForDisplayIdList( 2175 display_manager()->layout_store()->RegisterLayoutForDisplayIdList(
2170 list, builder.Build()); 2176 list, builder.Build());
2171 } 2177 }
2172 2178
2173 class ScreenShutdownTest : public test::AshTestBase { 2179 class ScreenShutdownTest : public test::AshTestBase {
2174 public: 2180 public:
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2247 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100Internal) { 2253 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100Internal) {
2248 FontTestHelper helper(1.0f, FontTestHelper::INTERNAL); 2254 FontTestHelper helper(1.0f, FontTestHelper::INTERNAL);
2249 ASSERT_DOUBLE_EQ( 2255 ASSERT_DOUBLE_EQ(
2250 1.0f, 2256 1.0f,
2251 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 2257 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
2252 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); 2258 EXPECT_FALSE(IsTextSubpixelPositioningEnabled());
2253 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); 2259 EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
2254 } 2260 }
2255 2261
2256 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125Internal) { 2262 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125Internal) {
2257 test::ScopedDisable125DSFForUIScaling disable; 2263 display::test::ScopedDisable125DSFForUIScaling disable;
2258 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL); 2264 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL);
2259 ASSERT_DOUBLE_EQ( 2265 ASSERT_DOUBLE_EQ(
2260 1.25f, 2266 1.25f,
2261 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 2267 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
2262 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); 2268 EXPECT_TRUE(IsTextSubpixelPositioningEnabled());
2263 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); 2269 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams());
2264 } 2270 }
2265 2271
2266 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200Internal) { 2272 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200Internal) {
2267 FontTestHelper helper(2.0f, FontTestHelper::INTERNAL); 2273 FontTestHelper helper(2.0f, FontTestHelper::INTERNAL);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2344 2350
2345 TEST_P(DisplayManagerTest, RejectInvalidLayoutData) { 2351 TEST_P(DisplayManagerTest, RejectInvalidLayoutData) {
2346 display::DisplayLayoutStore* layout_store = display_manager()->layout_store(); 2352 display::DisplayLayoutStore* layout_store = display_manager()->layout_store();
2347 int64_t id1 = 10001; 2353 int64_t id1 = 10001;
2348 int64_t id2 = 10002; 2354 int64_t id2 = 10002;
2349 ASSERT_TRUE(display::CompareDisplayIds(id1, id2)); 2355 ASSERT_TRUE(display::CompareDisplayIds(id1, id2));
2350 display::DisplayLayoutBuilder good_builder(id1); 2356 display::DisplayLayoutBuilder good_builder(id1);
2351 good_builder.SetSecondaryPlacement(id2, display::DisplayPlacement::LEFT, 0); 2357 good_builder.SetSecondaryPlacement(id2, display::DisplayPlacement::LEFT, 0);
2352 std::unique_ptr<display::DisplayLayout> good(good_builder.Build()); 2358 std::unique_ptr<display::DisplayLayout> good(good_builder.Build());
2353 2359
2354 display::DisplayIdList good_list = test::CreateDisplayIdList2(id1, id2); 2360 display::DisplayIdList good_list =
2361 display::test::CreateDisplayIdList2(id1, id2);
2355 layout_store->RegisterLayoutForDisplayIdList(good_list, good->Copy()); 2362 layout_store->RegisterLayoutForDisplayIdList(good_list, good->Copy());
2356 2363
2357 display::DisplayLayoutBuilder bad(id1); 2364 display::DisplayLayoutBuilder bad(id1);
2358 bad.SetSecondaryPlacement(id2, display::DisplayPlacement::BOTTOM, 0); 2365 bad.SetSecondaryPlacement(id2, display::DisplayPlacement::BOTTOM, 0);
2359 2366
2360 display::DisplayIdList bad_list(2); 2367 display::DisplayIdList bad_list(2);
2361 bad_list[0] = id2; 2368 bad_list[0] = id2;
2362 bad_list[1] = id1; 2369 bad_list[1] = id1;
2363 layout_store->RegisterLayoutForDisplayIdList(bad_list, bad.Build()); 2370 layout_store->RegisterLayoutForDisplayIdList(bad_list, bad.Build());
2364 2371
2365 EXPECT_EQ(good->ToString(), 2372 EXPECT_EQ(good->ToString(),
2366 layout_store->GetRegisteredDisplayLayout(good_list).ToString()); 2373 layout_store->GetRegisteredDisplayLayout(good_list).ToString());
2367 } 2374 }
2368 2375
2369 TEST_P(DisplayManagerTest, GuessDisplayIdFieldsInDisplayLayout) { 2376 TEST_P(DisplayManagerTest, GuessDisplayIdFieldsInDisplayLayout) {
2370 int64_t id1 = 10001; 2377 int64_t id1 = 10001;
2371 int64_t id2 = 10002; 2378 int64_t id2 = 10002;
2372 2379
2373 std::unique_ptr<display::DisplayLayout> old_layout( 2380 std::unique_ptr<display::DisplayLayout> old_layout(
2374 new display::DisplayLayout); 2381 new display::DisplayLayout);
2375 old_layout->placement_list.emplace_back(display::DisplayPlacement::BOTTOM, 0); 2382 old_layout->placement_list.emplace_back(display::DisplayPlacement::BOTTOM, 0);
2376 old_layout->primary_id = id1; 2383 old_layout->primary_id = id1;
2377 2384
2378 display::DisplayLayoutStore* layout_store = display_manager()->layout_store(); 2385 display::DisplayLayoutStore* layout_store = display_manager()->layout_store();
2379 display::DisplayIdList list = test::CreateDisplayIdList2(id1, id2); 2386 display::DisplayIdList list = display::test::CreateDisplayIdList2(id1, id2);
2380 layout_store->RegisterLayoutForDisplayIdList(list, std::move(old_layout)); 2387 layout_store->RegisterLayoutForDisplayIdList(list, std::move(old_layout));
2381 const display::DisplayLayout& stored = 2388 const display::DisplayLayout& stored =
2382 layout_store->GetRegisteredDisplayLayout(list); 2389 layout_store->GetRegisteredDisplayLayout(list);
2383 2390
2384 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id); 2391 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id);
2385 EXPECT_EQ(id2, stored.placement_list[0].display_id); 2392 EXPECT_EQ(id2, stored.placement_list[0].display_id);
2386 } 2393 }
2387 2394
2388 #endif // OS_CHROMEOS 2395 #endif // OS_CHROMEOS
2389 2396
2390 } // namespace ash 2397 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698