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

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

Issue 1608053002: Remove now-unnecessary wrappers around gfx::Screen::GetScreen() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@metro-mode-5
Patch Set: . Created 4 years, 11 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 "ash/display/display_manager.h"
6 6
7 #include "ash/accelerators/accelerator_commands.h" 7 #include "ash/accelerators/accelerator_commands.h"
8 #include "ash/ash_switches.h" 8 #include "ash/ash_switches.h"
9 #include "ash/display/display_info.h" 9 #include "ash/display/display_info.h"
10 #include "ash/display/display_layout_store.h" 10 #include "ash/display/display_layout_store.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 public: 52 public:
53 DisplayManagerTest() 53 DisplayManagerTest()
54 : removed_count_(0U), 54 : removed_count_(0U),
55 root_window_destroyed_(false), 55 root_window_destroyed_(false),
56 changed_metrics_(0U) { 56 changed_metrics_(0U) {
57 } 57 }
58 ~DisplayManagerTest() override {} 58 ~DisplayManagerTest() override {}
59 59
60 void SetUp() override { 60 void SetUp() override {
61 AshTestBase::SetUp(); 61 AshTestBase::SetUp();
62 Shell::GetScreen()->AddObserver(this); 62 gfx::Screen::GetScreen()->AddObserver(this);
63 Shell::GetPrimaryRootWindow()->AddObserver(this); 63 Shell::GetPrimaryRootWindow()->AddObserver(this);
64 } 64 }
65 void TearDown() override { 65 void TearDown() override {
66 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 66 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
67 Shell::GetScreen()->RemoveObserver(this); 67 gfx::Screen::GetScreen()->RemoveObserver(this);
68 AshTestBase::TearDown(); 68 AshTestBase::TearDown();
69 } 69 }
70 70
71 DisplayManager* display_manager() { 71 DisplayManager* display_manager() {
72 return Shell::GetInstance()->display_manager(); 72 return Shell::GetInstance()->display_manager();
73 } 73 }
74 const vector<gfx::Display>& changed() const { return changed_; } 74 const vector<gfx::Display>& changed() const { return changed_; }
75 const vector<gfx::Display>& added() const { return added_; } 75 const vector<gfx::Display>& added() const { return added_; }
76 uint32_t changed_metrics() const { return changed_metrics_; } 76 uint32_t changed_metrics() const { return changed_metrics_; }
77 77
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 396
397 // Make sure switching primary display applies the overscan offset only once. 397 // Make sure switching primary display applies the overscan offset only once.
398 ash::Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplay( 398 ash::Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplay(
399 ScreenUtil::GetSecondaryDisplay()); 399 ScreenUtil::GetSecondaryDisplay());
400 EXPECT_EQ("-500,0 500x500", 400 EXPECT_EQ("-500,0 500x500",
401 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); 401 ScreenUtil::GetSecondaryDisplay().bounds().ToString());
402 EXPECT_EQ("0,0 500x500", 402 EXPECT_EQ("0,0 500x500",
403 GetDisplayInfo(ScreenUtil::GetSecondaryDisplay()). 403 GetDisplayInfo(ScreenUtil::GetSecondaryDisplay()).
404 bounds_in_native().ToString()); 404 bounds_in_native().ToString());
405 EXPECT_EQ("0,501 400x400", 405 EXPECT_EQ("0,501 400x400",
406 GetDisplayInfo(Shell::GetScreen()->GetPrimaryDisplay()). 406 GetDisplayInfo(gfx::Screen::GetScreen()->GetPrimaryDisplay())
407 bounds_in_native().ToString()); 407 .bounds_in_native()
408 .ToString());
408 EXPECT_EQ("0,0 188x190", 409 EXPECT_EQ("0,0 188x190",
409 Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString()); 410 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString());
410 411
411 // Make sure just moving the overscan area should property notify observers. 412 // Make sure just moving the overscan area should property notify observers.
412 UpdateDisplay("0+0-500x500"); 413 UpdateDisplay("0+0-500x500");
413 int64_t primary_id = Shell::GetScreen()->GetPrimaryDisplay().id(); 414 int64_t primary_id = gfx::Screen::GetScreen()->GetPrimaryDisplay().id();
414 display_manager()->SetOverscanInsets(primary_id, gfx::Insets(0, 0, 20, 20)); 415 display_manager()->SetOverscanInsets(primary_id, gfx::Insets(0, 0, 20, 20));
415 EXPECT_EQ("0,0 480x480", 416 EXPECT_EQ("0,0 480x480",
416 Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString()); 417 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString());
417 reset(); 418 reset();
418 display_manager()->SetOverscanInsets(primary_id, gfx::Insets(10, 10, 10, 10)); 419 display_manager()->SetOverscanInsets(primary_id, gfx::Insets(10, 10, 10, 10));
419 EXPECT_TRUE(changed_metrics() & gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS); 420 EXPECT_TRUE(changed_metrics() & gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS);
420 EXPECT_TRUE( 421 EXPECT_TRUE(
421 changed_metrics() & gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA); 422 changed_metrics() & gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
422 EXPECT_EQ("0,0 480x480", 423 EXPECT_EQ("0,0 480x480",
423 Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString()); 424 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString());
424 reset(); 425 reset();
425 display_manager()->SetOverscanInsets(primary_id, gfx::Insets(0, 0, 0, 0)); 426 display_manager()->SetOverscanInsets(primary_id, gfx::Insets(0, 0, 0, 0));
426 EXPECT_TRUE(changed_metrics() & gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS); 427 EXPECT_TRUE(changed_metrics() & gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS);
427 EXPECT_TRUE( 428 EXPECT_TRUE(
428 changed_metrics() & gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA); 429 changed_metrics() & gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
429 EXPECT_EQ("0,0 500x500", 430 EXPECT_EQ("0,0 500x500",
430 Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString()); 431 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString());
431 } 432 }
432 433
433 TEST_F(DisplayManagerTest, ZeroOverscanInsets) { 434 TEST_F(DisplayManagerTest, ZeroOverscanInsets) {
434 if (!SupportsMultipleDisplays()) 435 if (!SupportsMultipleDisplays())
435 return; 436 return;
436 437
437 // Make sure the display change events is emitted for overscan inset changes. 438 // Make sure the display change events is emitted for overscan inset changes.
438 UpdateDisplay("0+0-500x500,0+501-400x400"); 439 UpdateDisplay("0+0-500x500,0+501-400x400");
439 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); 440 ASSERT_EQ(2u, display_manager()->GetNumDisplays());
440 int64_t display2_id = display_manager()->GetDisplayAt(1).id(); 441 int64_t display2_id = display_manager()->GetDisplayAt(1).id();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 // External connected while primary was disconnected. 512 // External connected while primary was disconnected.
512 display_info_list.push_back(external_display_info); 513 display_info_list.push_back(external_display_info);
513 display_manager()->OnNativeDisplaysChanged(display_info_list); 514 display_manager()->OnNativeDisplaysChanged(display_info_list);
514 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); 515 EXPECT_EQ(1U, display_manager()->GetNumDisplays());
515 516
516 EXPECT_EQ(invalid_id, GetDisplayForId(internal_display_id).id()); 517 EXPECT_EQ(invalid_id, GetDisplayForId(internal_display_id).id());
517 EXPECT_EQ("1,1 100x100", 518 EXPECT_EQ("1,1 100x100",
518 GetDisplayInfoForId(external_id).bounds_in_native().ToString()); 519 GetDisplayInfoForId(external_id).bounds_in_native().ToString());
519 EXPECT_EQ(1U, display_manager()->num_connected_displays()); 520 EXPECT_EQ(1U, display_manager()->num_connected_displays());
520 EXPECT_FALSE(display_manager()->IsInMirrorMode()); 521 EXPECT_FALSE(display_manager()->IsInMirrorMode());
521 EXPECT_EQ(external_id, Shell::GetScreen()->GetPrimaryDisplay().id()); 522 EXPECT_EQ(external_id, gfx::Screen::GetScreen()->GetPrimaryDisplay().id());
522 523
523 EXPECT_EQ(internal_display_id, gfx::Display::InternalDisplayId()); 524 EXPECT_EQ(internal_display_id, gfx::Display::InternalDisplayId());
524 525
525 // Primary connected, with different bounds. 526 // Primary connected, with different bounds.
526 display_info_list.clear(); 527 display_info_list.clear();
527 display_info_list.push_back(internal_display_info); 528 display_info_list.push_back(internal_display_info);
528 display_info_list.push_back(external_display_info); 529 display_info_list.push_back(external_display_info);
529 display_manager()->OnNativeDisplaysChanged(display_info_list); 530 display_manager()->OnNativeDisplaysChanged(display_info_list);
530 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); 531 EXPECT_EQ(2U, display_manager()->GetNumDisplays());
531 EXPECT_EQ(internal_display_id, Shell::GetScreen()->GetPrimaryDisplay().id()); 532 EXPECT_EQ(internal_display_id,
533 gfx::Screen::GetScreen()->GetPrimaryDisplay().id());
532 534
533 // This combinatino is new, so internal display becomes primary. 535 // This combinatino is new, so internal display becomes primary.
534 EXPECT_EQ("0,0 500x500", 536 EXPECT_EQ("0,0 500x500",
535 GetDisplayForId(internal_display_id).bounds().ToString()); 537 GetDisplayForId(internal_display_id).bounds().ToString());
536 EXPECT_EQ("1,1 100x100", 538 EXPECT_EQ("1,1 100x100",
537 GetDisplayInfoForId(10).bounds_in_native().ToString()); 539 GetDisplayInfoForId(10).bounds_in_native().ToString());
538 EXPECT_EQ(2U, display_manager()->num_connected_displays()); 540 EXPECT_EQ(2U, display_manager()->num_connected_displays());
539 EXPECT_FALSE(display_manager()->IsInMirrorMode()); 541 EXPECT_FALSE(display_manager()->IsInMirrorMode());
540 EXPECT_EQ(ToDisplayName(internal_display_id), 542 EXPECT_EQ(ToDisplayName(internal_display_id),
541 display_manager()->GetDisplayNameForId(internal_display_id)); 543 display_manager()->GetDisplayNameForId(internal_display_id));
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 const DisplayInfo post_rotation_info = 938 const DisplayInfo post_rotation_info =
937 display_manager()->display_info_[internal_display_id]; 939 display_manager()->display_info_[internal_display_id];
938 EXPECT_NE(info.GetActiveRotation(), post_rotation_info.GetActiveRotation()); 940 EXPECT_NE(info.GetActiveRotation(), post_rotation_info.GetActiveRotation());
939 EXPECT_EQ(gfx::Display::ROTATE_180, post_rotation_info.GetActiveRotation()); 941 EXPECT_EQ(gfx::Display::ROTATE_180, post_rotation_info.GetActiveRotation());
940 } 942 }
941 943
942 TEST_F(DisplayManagerTest, UIScale) { 944 TEST_F(DisplayManagerTest, UIScale) {
943 test::ScopedDisable125DSFForUIScaling disable; 945 test::ScopedDisable125DSFForUIScaling disable;
944 946
945 UpdateDisplay("1280x800"); 947 UpdateDisplay("1280x800");
946 int64_t display_id = Shell::GetScreen()->GetPrimaryDisplay().id(); 948 int64_t display_id = gfx::Screen::GetScreen()->GetPrimaryDisplay().id();
947 SetDisplayUIScale(display_id, 1.125f); 949 SetDisplayUIScale(display_id, 1.125f);
948 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale()); 950 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale());
949 SetDisplayUIScale(display_id, 0.8f); 951 SetDisplayUIScale(display_id, 0.8f);
950 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 952 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
951 SetDisplayUIScale(display_id, 0.75f); 953 SetDisplayUIScale(display_id, 0.75f);
952 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 954 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
953 SetDisplayUIScale(display_id, 0.625f); 955 SetDisplayUIScale(display_id, 0.625f);
954 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 956 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
955 957
956 test::ScopedSetInternalDisplayId set_internal(display_id); 958 test::ScopedSetInternalDisplayId set_internal(display_id);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 UpdateDisplay("1280x850*2"); 995 UpdateDisplay("1280x850*2");
994 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 996 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
995 SetDisplayUIScale(display_id, 1.5f); 997 SetDisplayUIScale(display_id, 1.5f);
996 EXPECT_EQ(1.5f, GetDisplayInfoAt(0).configured_ui_scale()); 998 EXPECT_EQ(1.5f, GetDisplayInfoAt(0).configured_ui_scale());
997 SetDisplayUIScale(display_id, 1.25f); 999 SetDisplayUIScale(display_id, 1.25f);
998 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).configured_ui_scale()); 1000 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).configured_ui_scale());
999 SetDisplayUIScale(display_id, 1.125f); 1001 SetDisplayUIScale(display_id, 1.125f);
1000 EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale()); 1002 EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale());
1001 SetDisplayUIScale(display_id, 1.0f); 1003 SetDisplayUIScale(display_id, 1.0f);
1002 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1004 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale());
1003 gfx::Display display = Shell::GetScreen()->GetPrimaryDisplay(); 1005 gfx::Display display = gfx::Screen::GetScreen()->GetPrimaryDisplay();
1004 EXPECT_EQ(2.0f, display.device_scale_factor()); 1006 EXPECT_EQ(2.0f, display.device_scale_factor());
1005 EXPECT_EQ("640x425", display.bounds().size().ToString()); 1007 EXPECT_EQ("640x425", display.bounds().size().ToString());
1006 1008
1007 SetDisplayUIScale(display_id, 0.8f); 1009 SetDisplayUIScale(display_id, 0.8f);
1008 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale()); 1010 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale());
1009 SetDisplayUIScale(display_id, 0.75f); 1011 SetDisplayUIScale(display_id, 0.75f);
1010 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale()); 1012 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale());
1011 SetDisplayUIScale(display_id, 0.625f); 1013 SetDisplayUIScale(display_id, 0.625f);
1012 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); 1014 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale());
1013 SetDisplayUIScale(display_id, 0.6f); 1015 SetDisplayUIScale(display_id, 0.6f);
1014 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); 1016 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale());
1015 SetDisplayUIScale(display_id, 0.5f); 1017 SetDisplayUIScale(display_id, 0.5f);
1016 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale()); 1018 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale());
1017 1019
1018 SetDisplayUIScale(display_id, 2.0f); 1020 SetDisplayUIScale(display_id, 2.0f);
1019 EXPECT_EQ(2.0f, GetDisplayInfoAt(0).configured_ui_scale()); 1021 EXPECT_EQ(2.0f, GetDisplayInfoAt(0).configured_ui_scale());
1020 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1022 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1021 display = Shell::GetScreen()->GetPrimaryDisplay(); 1023 display = gfx::Screen::GetScreen()->GetPrimaryDisplay();
1022 EXPECT_EQ(1.0f, display.device_scale_factor()); 1024 EXPECT_EQ(1.0f, display.device_scale_factor());
1023 EXPECT_EQ("1280x850", display.bounds().size().ToString()); 1025 EXPECT_EQ("1280x850", display.bounds().size().ToString());
1024 1026
1025 // 1.25 ui scaling on 1.25 DSF device should use 1.0 DSF 1027 // 1.25 ui scaling on 1.25 DSF device should use 1.0 DSF
1026 // on screen. 1028 // on screen.
1027 UpdateDisplay("1280x850*1.25"); 1029 UpdateDisplay("1280x850*1.25");
1028 SetDisplayUIScale(display_id, 1.25f); 1030 SetDisplayUIScale(display_id, 1.25f);
1029 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).configured_ui_scale()); 1031 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).configured_ui_scale());
1030 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1032 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1031 display = Shell::GetScreen()->GetPrimaryDisplay(); 1033 display = gfx::Screen::GetScreen()->GetPrimaryDisplay();
1032 EXPECT_EQ(1.0f, display.device_scale_factor()); 1034 EXPECT_EQ(1.0f, display.device_scale_factor());
1033 EXPECT_EQ("1280x850", display.bounds().size().ToString()); 1035 EXPECT_EQ("1280x850", display.bounds().size().ToString());
1034 } 1036 }
1035 1037
1036 TEST_F(DisplayManagerTest, UIScaleWithDisplayMode) { 1038 TEST_F(DisplayManagerTest, UIScaleWithDisplayMode) {
1037 int display_id = 1000; 1039 int display_id = 1000;
1038 1040
1039 // Setup the display modes with UI-scale. 1041 // Setup the display modes with UI-scale.
1040 DisplayInfo native_display_info = 1042 DisplayInfo native_display_info =
1041 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1280, 800)); 1043 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1280, 800));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 EXPECT_TRUE(expected_mode.IsEquivalent( 1088 EXPECT_TRUE(expected_mode.IsEquivalent(
1087 display_manager()->GetActiveModeForDisplayId(display_id))); 1089 display_manager()->GetActiveModeForDisplayId(display_id)));
1088 SetDisplayUIScale(display_id, 0.5f); 1090 SetDisplayUIScale(display_id, 0.5f);
1089 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale()); 1091 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale());
1090 expected_mode.ui_scale = 0.5f; 1092 expected_mode.ui_scale = 0.5f;
1091 EXPECT_TRUE(expected_mode.IsEquivalent( 1093 EXPECT_TRUE(expected_mode.IsEquivalent(
1092 display_manager()->GetActiveModeForDisplayId(display_id))); 1094 display_manager()->GetActiveModeForDisplayId(display_id)));
1093 } 1095 }
1094 1096
1095 TEST_F(DisplayManagerTest, Use125DSFForUIScaling) { 1097 TEST_F(DisplayManagerTest, Use125DSFForUIScaling) {
1096 int64_t display_id = Shell::GetScreen()->GetPrimaryDisplay().id(); 1098 int64_t display_id = gfx::Screen::GetScreen()->GetPrimaryDisplay().id();
1097 test::ScopedSetInternalDisplayId set_internal(display_id); 1099 test::ScopedSetInternalDisplayId set_internal(display_id);
1098 1100
1099 UpdateDisplay("1920x1080*1.25"); 1101 UpdateDisplay("1920x1080*1.25");
1100 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1102 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1101 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1103 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1102 1104
1103 SetDisplayUIScale(display_id, 0.8f); 1105 SetDisplayUIScale(display_id, 0.8f);
1104 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); 1106 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
1105 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); 1107 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
1106 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString()); 1108 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString());
(...skipping 13 matching lines...) Expand all
1120 if (!SupportsMultipleDisplays()) 1122 if (!SupportsMultipleDisplays())
1121 return; 1123 return;
1122 // Don't check root window destruction in unified mode. 1124 // Don't check root window destruction in unified mode.
1123 Shell::GetPrimaryRootWindow()->RemoveObserver(this); 1125 Shell::GetPrimaryRootWindow()->RemoveObserver(this);
1124 1126
1125 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 1127 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
1126 display_manager->SetUnifiedDesktopEnabled(true); 1128 display_manager->SetUnifiedDesktopEnabled(true);
1127 1129
1128 UpdateDisplay("200x200, 400x400"); 1130 UpdateDisplay("200x200, 400x400");
1129 1131
1130 int64_t unified_id = Shell::GetScreen()->GetPrimaryDisplay().id(); 1132 int64_t unified_id = gfx::Screen::GetScreen()->GetPrimaryDisplay().id();
1131 DisplayInfo info = display_manager->GetDisplayInfo(unified_id); 1133 DisplayInfo info = display_manager->GetDisplayInfo(unified_id);
1132 ASSERT_EQ(2u, info.display_modes().size()); 1134 ASSERT_EQ(2u, info.display_modes().size());
1133 EXPECT_EQ("400x200", info.display_modes()[0].size.ToString()); 1135 EXPECT_EQ("400x200", info.display_modes()[0].size.ToString());
1134 EXPECT_TRUE(info.display_modes()[0].native); 1136 EXPECT_TRUE(info.display_modes()[0].native);
1135 EXPECT_EQ("800x400", info.display_modes()[1].size.ToString()); 1137 EXPECT_EQ("800x400", info.display_modes()[1].size.ToString());
1136 EXPECT_FALSE(info.display_modes()[1].native); 1138 EXPECT_FALSE(info.display_modes()[1].native);
1137 EXPECT_EQ("400x200", 1139 EXPECT_EQ("400x200",
1138 Shell::GetScreen()->GetPrimaryDisplay().size().ToString()); 1140 gfx::Screen::GetScreen()->GetPrimaryDisplay().size().ToString());
1139 DisplayMode active_mode = 1141 DisplayMode active_mode =
1140 display_manager->GetActiveModeForDisplayId(unified_id); 1142 display_manager->GetActiveModeForDisplayId(unified_id);
1141 EXPECT_EQ(1.0f, active_mode.ui_scale); 1143 EXPECT_EQ(1.0f, active_mode.ui_scale);
1142 EXPECT_EQ("400x200", active_mode.size.ToString()); 1144 EXPECT_EQ("400x200", active_mode.size.ToString());
1143 1145
1144 EXPECT_TRUE(test::SetDisplayResolution(unified_id, gfx::Size(800, 400))); 1146 EXPECT_TRUE(test::SetDisplayResolution(unified_id, gfx::Size(800, 400)));
1145 EXPECT_EQ("800x400", 1147 EXPECT_EQ("800x400",
1146 Shell::GetScreen()->GetPrimaryDisplay().size().ToString()); 1148 gfx::Screen::GetScreen()->GetPrimaryDisplay().size().ToString());
1147 1149
1148 active_mode = display_manager->GetActiveModeForDisplayId(unified_id); 1150 active_mode = display_manager->GetActiveModeForDisplayId(unified_id);
1149 EXPECT_EQ(1.0f, active_mode.ui_scale); 1151 EXPECT_EQ(1.0f, active_mode.ui_scale);
1150 EXPECT_EQ("800x400", active_mode.size.ToString()); 1152 EXPECT_EQ("800x400", active_mode.size.ToString());
1151 1153
1152 // resolution change will not persist in unified desktop mode. 1154 // resolution change will not persist in unified desktop mode.
1153 UpdateDisplay("600x600, 200x200"); 1155 UpdateDisplay("600x600, 200x200");
1154 EXPECT_EQ("1200x600", 1156 EXPECT_EQ("1200x600",
1155 Shell::GetScreen()->GetPrimaryDisplay().size().ToString()); 1157 gfx::Screen::GetScreen()->GetPrimaryDisplay().size().ToString());
1156 active_mode = display_manager->GetActiveModeForDisplayId(unified_id); 1158 active_mode = display_manager->GetActiveModeForDisplayId(unified_id);
1157 EXPECT_EQ(1.0f, active_mode.ui_scale); 1159 EXPECT_EQ(1.0f, active_mode.ui_scale);
1158 EXPECT_TRUE(active_mode.native); 1160 EXPECT_TRUE(active_mode.native);
1159 EXPECT_EQ("1200x600", active_mode.size.ToString()); 1161 EXPECT_EQ("1200x600", active_mode.size.ToString());
1160 } 1162 }
1161 1163
1162 #if defined(OS_WIN) 1164 #if defined(OS_WIN)
1163 // TODO(scottmg): RootWindow doesn't get resized on Windows 1165 // TODO(scottmg): RootWindow doesn't get resized on Windows
1164 // Ash. http://crbug.com/247916. 1166 // Ash. http://crbug.com/247916.
1165 #define MAYBE_UpdateMouseCursorAfterRotateZoom DISABLED_UpdateMouseCursorAfterRo tateZoom 1167 #define MAYBE_UpdateMouseCursorAfterRotateZoom DISABLED_UpdateMouseCursorAfterRo tateZoom
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 TEST_F(DisplayManagerTest, SoftwareMirroring) { 1253 TEST_F(DisplayManagerTest, SoftwareMirroring) {
1252 if (!SupportsMultipleDisplays()) 1254 if (!SupportsMultipleDisplays())
1253 return; 1255 return;
1254 1256
1255 UpdateDisplay("300x400,400x500"); 1257 UpdateDisplay("300x400,400x500");
1256 1258
1257 test::MirrorWindowTestApi test_api; 1259 test::MirrorWindowTestApi test_api;
1258 EXPECT_EQ(NULL, test_api.GetHost()); 1260 EXPECT_EQ(NULL, test_api.GetHost());
1259 1261
1260 TestDisplayObserver display_observer; 1262 TestDisplayObserver display_observer;
1261 Shell::GetScreen()->AddObserver(&display_observer); 1263 gfx::Screen::GetScreen()->AddObserver(&display_observer);
1262 1264
1263 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 1265 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
1264 display_manager->SetMultiDisplayMode(DisplayManager::MIRRORING); 1266 display_manager->SetMultiDisplayMode(DisplayManager::MIRRORING);
1265 display_manager->UpdateDisplays(); 1267 display_manager->UpdateDisplays();
1266 RunAllPendingInMessageLoop(); 1268 RunAllPendingInMessageLoop();
1267 EXPECT_TRUE(display_observer.changed_and_reset()); 1269 EXPECT_TRUE(display_observer.changed_and_reset());
1268 EXPECT_EQ(1U, display_manager->GetNumDisplays()); 1270 EXPECT_EQ(1U, display_manager->GetNumDisplays());
1269 EXPECT_EQ("0,0 300x400", 1271 EXPECT_EQ("0,0 300x400",
1270 Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString()); 1272 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString());
1271 EXPECT_EQ("400x500", test_api.GetHost()->GetBounds().size().ToString()); 1273 EXPECT_EQ("400x500", test_api.GetHost()->GetBounds().size().ToString());
1272 EXPECT_EQ("300x400", 1274 EXPECT_EQ("300x400",
1273 test_api.GetHost()->window()->bounds().size().ToString()); 1275 test_api.GetHost()->window()->bounds().size().ToString());
1274 EXPECT_TRUE(display_manager->IsInMirrorMode()); 1276 EXPECT_TRUE(display_manager->IsInMirrorMode());
1275 1277
1276 display_manager->SetMirrorMode(false); 1278 display_manager->SetMirrorMode(false);
1277 EXPECT_TRUE(display_observer.changed_and_reset()); 1279 EXPECT_TRUE(display_observer.changed_and_reset());
1278 EXPECT_EQ(NULL, test_api.GetHost()); 1280 EXPECT_EQ(NULL, test_api.GetHost());
1279 EXPECT_EQ(2U, display_manager->GetNumDisplays()); 1281 EXPECT_EQ(2U, display_manager->GetNumDisplays());
1280 EXPECT_FALSE(display_manager->IsInMirrorMode()); 1282 EXPECT_FALSE(display_manager->IsInMirrorMode());
(...skipping 22 matching lines...) Expand all
1303 EXPECT_FALSE(display_observer.changed_and_reset()); 1305 EXPECT_FALSE(display_observer.changed_and_reset());
1304 EXPECT_EQ("330x440", 1306 EXPECT_EQ("330x440",
1305 test_api.GetHost()->window()->bounds().size().ToString()); 1307 test_api.GetHost()->window()->bounds().size().ToString());
1306 1308
1307 // Overscan insets are ignored. 1309 // Overscan insets are ignored.
1308 UpdateDisplay("400x600/o,600x800/o"); 1310 UpdateDisplay("400x600/o,600x800/o");
1309 EXPECT_FALSE(display_observer.changed_and_reset()); 1311 EXPECT_FALSE(display_observer.changed_and_reset());
1310 EXPECT_EQ("400x600", 1312 EXPECT_EQ("400x600",
1311 test_api.GetHost()->window()->bounds().size().ToString()); 1313 test_api.GetHost()->window()->bounds().size().ToString());
1312 1314
1313 Shell::GetScreen()->RemoveObserver(&display_observer); 1315 gfx::Screen::GetScreen()->RemoveObserver(&display_observer);
1314 } 1316 }
1315 1317
1316 TEST_F(DisplayManagerTest, SingleDisplayToSoftwareMirroring) { 1318 TEST_F(DisplayManagerTest, SingleDisplayToSoftwareMirroring) {
1317 if (!SupportsMultipleDisplays()) 1319 if (!SupportsMultipleDisplays())
1318 return; 1320 return;
1319 UpdateDisplay("600x400"); 1321 UpdateDisplay("600x400");
1320 1322
1321 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 1323 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
1322 display_manager->SetMultiDisplayMode(DisplayManager::MIRRORING); 1324 display_manager->SetMultiDisplayMode(DisplayManager::MIRRORING);
1323 UpdateDisplay("600x400,600x400"); 1325 UpdateDisplay("600x400,600x400");
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 } 1378 }
1377 #endif // OS_CHROMEOS 1379 #endif // OS_CHROMEOS
1378 1380
1379 TEST_F(DisplayManagerTest, MirroredLayout) { 1381 TEST_F(DisplayManagerTest, MirroredLayout) {
1380 if (!SupportsMultipleDisplays()) 1382 if (!SupportsMultipleDisplays())
1381 return; 1383 return;
1382 1384
1383 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 1385 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
1384 UpdateDisplay("500x500,400x400"); 1386 UpdateDisplay("500x500,400x400");
1385 EXPECT_FALSE(display_manager->GetCurrentDisplayLayout().mirrored); 1387 EXPECT_FALSE(display_manager->GetCurrentDisplayLayout().mirrored);
1386 EXPECT_EQ(2, Shell::GetScreen()->GetNumDisplays()); 1388 EXPECT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays());
1387 EXPECT_EQ(2U, display_manager->num_connected_displays()); 1389 EXPECT_EQ(2U, display_manager->num_connected_displays());
1388 1390
1389 UpdateDisplay("1+0-500x500,1+0-500x500"); 1391 UpdateDisplay("1+0-500x500,1+0-500x500");
1390 EXPECT_TRUE(display_manager->GetCurrentDisplayLayout().mirrored); 1392 EXPECT_TRUE(display_manager->GetCurrentDisplayLayout().mirrored);
1391 EXPECT_EQ(1, Shell::GetScreen()->GetNumDisplays()); 1393 EXPECT_EQ(1, gfx::Screen::GetScreen()->GetNumDisplays());
1392 EXPECT_EQ(2U, display_manager->num_connected_displays()); 1394 EXPECT_EQ(2U, display_manager->num_connected_displays());
1393 1395
1394 UpdateDisplay("500x500,500x500"); 1396 UpdateDisplay("500x500,500x500");
1395 EXPECT_FALSE(display_manager->GetCurrentDisplayLayout().mirrored); 1397 EXPECT_FALSE(display_manager->GetCurrentDisplayLayout().mirrored);
1396 EXPECT_EQ(2, Shell::GetScreen()->GetNumDisplays()); 1398 EXPECT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays());
1397 EXPECT_EQ(2U, display_manager->num_connected_displays()); 1399 EXPECT_EQ(2U, display_manager->num_connected_displays());
1398 } 1400 }
1399 1401
1400 TEST_F(DisplayManagerTest, InvertLayout) { 1402 TEST_F(DisplayManagerTest, InvertLayout) {
1401 EXPECT_EQ("left, 0", 1403 EXPECT_EQ("left, 0",
1402 DisplayLayout(DisplayLayout::RIGHT, 0).Invert().ToString()); 1404 DisplayLayout(DisplayLayout::RIGHT, 0).Invert().ToString());
1403 EXPECT_EQ("left, -100", 1405 EXPECT_EQ("left, -100",
1404 DisplayLayout(DisplayLayout::RIGHT, 100).Invert().ToString()); 1406 DisplayLayout(DisplayLayout::RIGHT, 100).Invert().ToString());
1405 EXPECT_EQ("left, 50", 1407 EXPECT_EQ("left, 50",
1406 DisplayLayout(DisplayLayout::RIGHT, -50).Invert().ToString()); 1408 DisplayLayout(DisplayLayout::RIGHT, -50).Invert().ToString());
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 #if defined(OS_WIN) 1474 #if defined(OS_WIN)
1473 // TODO(scottmg): RootWindow doesn't get resized on Windows 1475 // TODO(scottmg): RootWindow doesn't get resized on Windows
1474 // Ash. http://crbug.com/247916. 1476 // Ash. http://crbug.com/247916.
1475 #define MAYBE_UpdateDisplayWithHostOrigin DISABLED_UpdateDisplayWithHostOrigin 1477 #define MAYBE_UpdateDisplayWithHostOrigin DISABLED_UpdateDisplayWithHostOrigin
1476 #else 1478 #else
1477 #define MAYBE_UpdateDisplayWithHostOrigin UpdateDisplayWithHostOrigin 1479 #define MAYBE_UpdateDisplayWithHostOrigin UpdateDisplayWithHostOrigin
1478 #endif 1480 #endif
1479 1481
1480 TEST_F(DisplayManagerTest, MAYBE_UpdateDisplayWithHostOrigin) { 1482 TEST_F(DisplayManagerTest, MAYBE_UpdateDisplayWithHostOrigin) {
1481 UpdateDisplay("100x200,300x400"); 1483 UpdateDisplay("100x200,300x400");
1482 ASSERT_EQ(2, Shell::GetScreen()->GetNumDisplays()); 1484 ASSERT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays());
1483 aura::Window::Windows root_windows = 1485 aura::Window::Windows root_windows =
1484 Shell::GetInstance()->GetAllRootWindows(); 1486 Shell::GetInstance()->GetAllRootWindows();
1485 ASSERT_EQ(2U, root_windows.size()); 1487 ASSERT_EQ(2U, root_windows.size());
1486 aura::WindowTreeHost* host0 = root_windows[0]->GetHost(); 1488 aura::WindowTreeHost* host0 = root_windows[0]->GetHost();
1487 aura::WindowTreeHost* host1 = root_windows[1]->GetHost(); 1489 aura::WindowTreeHost* host1 = root_windows[1]->GetHost();
1488 1490
1489 EXPECT_EQ("1,1", host0->GetBounds().origin().ToString()); 1491 EXPECT_EQ("1,1", host0->GetBounds().origin().ToString());
1490 EXPECT_EQ("100x200", host0->GetBounds().size().ToString()); 1492 EXPECT_EQ("100x200", host0->GetBounds().size().ToString());
1491 // UpdateDisplay set the origin if it's not set. 1493 // UpdateDisplay set the origin if it's not set.
1492 EXPECT_NE("1,1", host1->GetBounds().origin().ToString()); 1494 EXPECT_NE("1,1", host1->GetBounds().origin().ToString());
1493 EXPECT_EQ("300x400", host1->GetBounds().size().ToString()); 1495 EXPECT_EQ("300x400", host1->GetBounds().size().ToString());
1494 1496
1495 UpdateDisplay("100x200,200+300-300x400"); 1497 UpdateDisplay("100x200,200+300-300x400");
1496 ASSERT_EQ(2, Shell::GetScreen()->GetNumDisplays()); 1498 ASSERT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays());
1497 EXPECT_EQ("0,0", host0->GetBounds().origin().ToString()); 1499 EXPECT_EQ("0,0", host0->GetBounds().origin().ToString());
1498 EXPECT_EQ("100x200", host0->GetBounds().size().ToString()); 1500 EXPECT_EQ("100x200", host0->GetBounds().size().ToString());
1499 EXPECT_EQ("200,300", host1->GetBounds().origin().ToString()); 1501 EXPECT_EQ("200,300", host1->GetBounds().origin().ToString());
1500 EXPECT_EQ("300x400", host1->GetBounds().size().ToString()); 1502 EXPECT_EQ("300x400", host1->GetBounds().size().ToString());
1501 1503
1502 UpdateDisplay("400+500-200x300,300x400"); 1504 UpdateDisplay("400+500-200x300,300x400");
1503 ASSERT_EQ(2, Shell::GetScreen()->GetNumDisplays()); 1505 ASSERT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays());
1504 EXPECT_EQ("400,500", host0->GetBounds().origin().ToString()); 1506 EXPECT_EQ("400,500", host0->GetBounds().origin().ToString());
1505 EXPECT_EQ("200x300", host0->GetBounds().size().ToString()); 1507 EXPECT_EQ("200x300", host0->GetBounds().size().ToString());
1506 EXPECT_EQ("0,0", host1->GetBounds().origin().ToString()); 1508 EXPECT_EQ("0,0", host1->GetBounds().origin().ToString());
1507 EXPECT_EQ("300x400", host1->GetBounds().size().ToString()); 1509 EXPECT_EQ("300x400", host1->GetBounds().size().ToString());
1508 1510
1509 UpdateDisplay("100+200-100x200,300+500-200x300"); 1511 UpdateDisplay("100+200-100x200,300+500-200x300");
1510 ASSERT_EQ(2, Shell::GetScreen()->GetNumDisplays()); 1512 ASSERT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays());
1511 EXPECT_EQ("100,200", host0->GetBounds().origin().ToString()); 1513 EXPECT_EQ("100,200", host0->GetBounds().origin().ToString());
1512 EXPECT_EQ("100x200", host0->GetBounds().size().ToString()); 1514 EXPECT_EQ("100x200", host0->GetBounds().size().ToString());
1513 EXPECT_EQ("300,500", host1->GetBounds().origin().ToString()); 1515 EXPECT_EQ("300,500", host1->GetBounds().origin().ToString());
1514 EXPECT_EQ("200x300", host1->GetBounds().size().ToString()); 1516 EXPECT_EQ("200x300", host1->GetBounds().size().ToString());
1515 } 1517 }
1516 1518
1517 TEST_F(DisplayManagerTest, UnifiedDesktopBasic) { 1519 TEST_F(DisplayManagerTest, UnifiedDesktopBasic) {
1518 if (!SupportsMultipleDisplays()) 1520 if (!SupportsMultipleDisplays())
1519 return; 1521 return;
1520 1522
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
2011 layout_store->RegisterLayoutForDisplayIdPair(id2, id1, bad); 2013 layout_store->RegisterLayoutForDisplayIdPair(id2, id1, bad);
2012 2014
2013 EXPECT_EQ(good.ToString(), layout_store->GetRegisteredDisplayLayout( 2015 EXPECT_EQ(good.ToString(), layout_store->GetRegisteredDisplayLayout(
2014 CreateDisplayIdPair(id1, id2)) 2016 CreateDisplayIdPair(id1, id2))
2015 .ToString()); 2017 .ToString());
2016 } 2018 }
2017 2019
2018 #endif // OS_CHROMEOS 2020 #endif // OS_CHROMEOS
2019 2021
2020 } // namespace ash 2022 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698