OLD | NEW |
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 23 matching lines...) Expand all Loading... |
34 | 34 |
35 namespace ash { | 35 namespace ash { |
36 | 36 |
37 using std::vector; | 37 using std::vector; |
38 using std::string; | 38 using std::string; |
39 | 39 |
40 using base::StringPrintf; | 40 using base::StringPrintf; |
41 | 41 |
42 namespace { | 42 namespace { |
43 | 43 |
44 std::string ToDisplayName(int64 id) { | 44 std::string ToDisplayName(int64_t id) { |
45 return "x-" + base::Int64ToString(id); | 45 return "x-" + base::Int64ToString(id); |
46 } | 46 } |
47 | 47 |
48 } // namespace | 48 } // namespace |
49 | 49 |
50 class DisplayManagerTest : public test::AshTestBase, | 50 class DisplayManagerTest : public test::AshTestBase, |
51 public gfx::DisplayObserver, | 51 public gfx::DisplayObserver, |
52 public aura::WindowObserver { | 52 public aura::WindowObserver { |
53 public: | 53 public: |
54 DisplayManagerTest() | 54 DisplayManagerTest() |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 } | 94 } |
95 | 95 |
96 const DisplayInfo& GetDisplayInfo(const gfx::Display& display) { | 96 const DisplayInfo& GetDisplayInfo(const gfx::Display& display) { |
97 return display_manager()->GetDisplayInfo(display.id()); | 97 return display_manager()->GetDisplayInfo(display.id()); |
98 } | 98 } |
99 | 99 |
100 const DisplayInfo& GetDisplayInfoAt(int index) { | 100 const DisplayInfo& GetDisplayInfoAt(int index) { |
101 return GetDisplayInfo(display_manager()->GetDisplayAt(index)); | 101 return GetDisplayInfo(display_manager()->GetDisplayAt(index)); |
102 } | 102 } |
103 | 103 |
104 const gfx::Display& GetDisplayForId(int64 id) { | 104 const gfx::Display& GetDisplayForId(int64_t id) { |
105 return display_manager()->GetDisplayForId(id); | 105 return display_manager()->GetDisplayForId(id); |
106 } | 106 } |
107 | 107 |
108 const DisplayInfo& GetDisplayInfoForId(int64 id) { | 108 const DisplayInfo& GetDisplayInfoForId(int64_t id) { |
109 return GetDisplayInfo(display_manager()->GetDisplayForId(id)); | 109 return GetDisplayInfo(display_manager()->GetDisplayForId(id)); |
110 } | 110 } |
111 | 111 |
112 // aura::DisplayObserver overrides: | 112 // aura::DisplayObserver overrides: |
113 void OnDisplayMetricsChanged(const gfx::Display& display, | 113 void OnDisplayMetricsChanged(const gfx::Display& display, |
114 uint32_t changed_metrics) override { | 114 uint32_t changed_metrics) override { |
115 changed_.push_back(display); | 115 changed_.push_back(display); |
116 changed_metrics_ |= changed_metrics; | 116 changed_metrics_ |= changed_metrics; |
117 } | 117 } |
118 void OnDisplayAdded(const gfx::Display& new_display) override { | 118 void OnDisplayAdded(const gfx::Display& new_display) override { |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 GetDisplayInfo(ScreenUtil::GetSecondaryDisplay()). | 404 GetDisplayInfo(ScreenUtil::GetSecondaryDisplay()). |
405 bounds_in_native().ToString()); | 405 bounds_in_native().ToString()); |
406 EXPECT_EQ("0,501 400x400", | 406 EXPECT_EQ("0,501 400x400", |
407 GetDisplayInfo(Shell::GetScreen()->GetPrimaryDisplay()). | 407 GetDisplayInfo(Shell::GetScreen()->GetPrimaryDisplay()). |
408 bounds_in_native().ToString()); | 408 bounds_in_native().ToString()); |
409 EXPECT_EQ("0,0 188x190", | 409 EXPECT_EQ("0,0 188x190", |
410 Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString()); | 410 Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString()); |
411 | 411 |
412 // Make sure just moving the overscan area should property notify observers. | 412 // Make sure just moving the overscan area should property notify observers. |
413 UpdateDisplay("0+0-500x500"); | 413 UpdateDisplay("0+0-500x500"); |
414 int64 primary_id = Shell::GetScreen()->GetPrimaryDisplay().id(); | 414 int64_t primary_id = Shell::GetScreen()->GetPrimaryDisplay().id(); |
415 display_manager()->SetOverscanInsets(primary_id, gfx::Insets(0, 0, 20, 20)); | 415 display_manager()->SetOverscanInsets(primary_id, gfx::Insets(0, 0, 20, 20)); |
416 EXPECT_EQ("0,0 480x480", | 416 EXPECT_EQ("0,0 480x480", |
417 Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString()); | 417 Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString()); |
418 reset(); | 418 reset(); |
419 display_manager()->SetOverscanInsets(primary_id, gfx::Insets(10, 10, 10, 10)); | 419 display_manager()->SetOverscanInsets(primary_id, gfx::Insets(10, 10, 10, 10)); |
420 EXPECT_TRUE(changed_metrics() & gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS); | 420 EXPECT_TRUE(changed_metrics() & gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS); |
421 EXPECT_TRUE( | 421 EXPECT_TRUE( |
422 changed_metrics() & gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA); | 422 changed_metrics() & gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA); |
423 EXPECT_EQ("0,0 480x480", | 423 EXPECT_EQ("0,0 480x480", |
424 Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString()); | 424 Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString()); |
425 reset(); | 425 reset(); |
426 display_manager()->SetOverscanInsets(primary_id, gfx::Insets(0, 0, 0, 0)); | 426 display_manager()->SetOverscanInsets(primary_id, gfx::Insets(0, 0, 0, 0)); |
427 EXPECT_TRUE(changed_metrics() & gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS); | 427 EXPECT_TRUE(changed_metrics() & gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS); |
428 EXPECT_TRUE( | 428 EXPECT_TRUE( |
429 changed_metrics() & gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA); | 429 changed_metrics() & gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA); |
430 EXPECT_EQ("0,0 500x500", | 430 EXPECT_EQ("0,0 500x500", |
431 Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString()); | 431 Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString()); |
432 } | 432 } |
433 | 433 |
434 TEST_F(DisplayManagerTest, ZeroOverscanInsets) { | 434 TEST_F(DisplayManagerTest, ZeroOverscanInsets) { |
435 if (!SupportsMultipleDisplays()) | 435 if (!SupportsMultipleDisplays()) |
436 return; | 436 return; |
437 | 437 |
438 // 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. |
439 UpdateDisplay("0+0-500x500,0+501-400x400"); | 439 UpdateDisplay("0+0-500x500,0+501-400x400"); |
440 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); | 440 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); |
441 int64 display2_id = display_manager()->GetDisplayAt(1).id(); | 441 int64_t display2_id = display_manager()->GetDisplayAt(1).id(); |
442 | 442 |
443 reset(); | 443 reset(); |
444 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0)); | 444 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0)); |
445 EXPECT_EQ(0u, changed().size()); | 445 EXPECT_EQ(0u, changed().size()); |
446 | 446 |
447 reset(); | 447 reset(); |
448 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(1, 0, 0, 0)); | 448 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(1, 0, 0, 0)); |
449 EXPECT_EQ(1u, changed().size()); | 449 EXPECT_EQ(1u, changed().size()); |
450 EXPECT_EQ(display2_id, changed()[0].id()); | 450 EXPECT_EQ(display2_id, changed()[0].id()); |
451 | 451 |
(...skipping 14 matching lines...) Expand all Loading... |
466 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); | 466 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); |
467 EXPECT_EQ("1 0 0", GetCountSummary()); | 467 EXPECT_EQ("1 0 0", GetCountSummary()); |
468 | 468 |
469 UpdateDisplay("1000x600*2"); | 469 UpdateDisplay("1000x600*2"); |
470 EXPECT_EQ(2, host->compositor()->device_scale_factor()); | 470 EXPECT_EQ(2, host->compositor()->device_scale_factor()); |
471 EXPECT_EQ("2 0 0", GetCountSummary()); | 471 EXPECT_EQ("2 0 0", GetCountSummary()); |
472 EXPECT_EQ("500x300", | 472 EXPECT_EQ("500x300", |
473 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); | 473 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); |
474 } | 474 } |
475 | 475 |
476 DisplayInfo CreateDisplayInfo(int64 id, const gfx::Rect& bounds) { | 476 DisplayInfo CreateDisplayInfo(int64_t id, const gfx::Rect& bounds) { |
477 DisplayInfo info(id, ToDisplayName(id), false); | 477 DisplayInfo info(id, ToDisplayName(id), false); |
478 info.SetBounds(bounds); | 478 info.SetBounds(bounds); |
479 return info; | 479 return info; |
480 } | 480 } |
481 | 481 |
482 TEST_F(DisplayManagerTest, TestNativeDisplaysChanged) { | 482 TEST_F(DisplayManagerTest, TestNativeDisplaysChanged) { |
483 const int64 internal_display_id = | 483 const int64_t internal_display_id = |
484 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); | 484 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); |
485 const int external_id = 10; | 485 const int external_id = 10; |
486 const int mirror_id = 11; | 486 const int mirror_id = 11; |
487 const int64 invalid_id = gfx::Display::kInvalidDisplayID; | 487 const int64_t invalid_id = gfx::Display::kInvalidDisplayID; |
488 const DisplayInfo internal_display_info = | 488 const DisplayInfo internal_display_info = |
489 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); | 489 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); |
490 const DisplayInfo external_display_info = | 490 const DisplayInfo external_display_info = |
491 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); | 491 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); |
492 const DisplayInfo mirroring_display_info = | 492 const DisplayInfo mirroring_display_info = |
493 CreateDisplayInfo(mirror_id, gfx::Rect(0, 0, 500, 500)); | 493 CreateDisplayInfo(mirror_id, gfx::Rect(0, 0, 500, 500)); |
494 | 494 |
495 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 495 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
496 EXPECT_EQ(1U, display_manager()->num_connected_displays()); | 496 EXPECT_EQ(1U, display_manager()->num_connected_displays()); |
497 std::string default_bounds = | 497 std::string default_bounds = |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 } | 644 } |
645 | 645 |
646 // Make sure crash does not happen if add and remove happens at the same time. | 646 // Make sure crash does not happen if add and remove happens at the same time. |
647 // See: crbug.com/414394 | 647 // See: crbug.com/414394 |
648 TEST_F(DisplayManagerTest, DisplayAddRemoveAtTheSameTime) { | 648 TEST_F(DisplayManagerTest, DisplayAddRemoveAtTheSameTime) { |
649 if (!SupportsMultipleDisplays()) | 649 if (!SupportsMultipleDisplays()) |
650 return; | 650 return; |
651 | 651 |
652 UpdateDisplay("100+0-500x500,0+501-400x400"); | 652 UpdateDisplay("100+0-500x500,0+501-400x400"); |
653 | 653 |
654 const int64 primary_id = WindowTreeHostManager::GetPrimaryDisplayId(); | 654 const int64_t primary_id = WindowTreeHostManager::GetPrimaryDisplayId(); |
655 const int64 secondary_id = ScreenUtil::GetSecondaryDisplay().id(); | 655 const int64_t secondary_id = ScreenUtil::GetSecondaryDisplay().id(); |
656 | 656 |
657 DisplayInfo primary_info = display_manager()->GetDisplayInfo(primary_id); | 657 DisplayInfo primary_info = display_manager()->GetDisplayInfo(primary_id); |
658 DisplayInfo secondary_info = display_manager()->GetDisplayInfo(secondary_id); | 658 DisplayInfo secondary_info = display_manager()->GetDisplayInfo(secondary_id); |
659 | 659 |
660 // An id which is different from primary and secondary. | 660 // An id which is different from primary and secondary. |
661 const int64 third_id = secondary_id + 1; | 661 const int64_t third_id = secondary_id + 1; |
662 | 662 |
663 DisplayInfo third_info = | 663 DisplayInfo third_info = |
664 CreateDisplayInfo(third_id, gfx::Rect(0, 0, 600, 600)); | 664 CreateDisplayInfo(third_id, gfx::Rect(0, 0, 600, 600)); |
665 | 665 |
666 std::vector<DisplayInfo> display_info_list; | 666 std::vector<DisplayInfo> display_info_list; |
667 display_info_list.push_back(third_info); | 667 display_info_list.push_back(third_info); |
668 display_info_list.push_back(secondary_info); | 668 display_info_list.push_back(secondary_info); |
669 display_manager()->OnNativeDisplaysChanged(display_info_list); | 669 display_manager()->OnNativeDisplaysChanged(display_info_list); |
670 | 670 |
671 // Secondary seconary_id becomes the primary as it has smaller output index. | 671 // Secondary seconary_id becomes the primary as it has smaller output index. |
(...skipping 29 matching lines...) Expand all Loading... |
701 EXPECT_EQ("1,1 100x100", | 701 EXPECT_EQ("1,1 100x100", |
702 GetDisplayInfoForId(10).bounds_in_native().ToString()); | 702 GetDisplayInfoForId(10).bounds_in_native().ToString()); |
703 EXPECT_EQ("100x100", ash::Shell::GetPrimaryRootWindow()->GetHost()-> | 703 EXPECT_EQ("100x100", ash::Shell::GetPrimaryRootWindow()->GetHost()-> |
704 GetBounds().size().ToString()); | 704 GetBounds().size().ToString()); |
705 } | 705 } |
706 | 706 |
707 TEST_F(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) { | 707 TEST_F(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) { |
708 if (!SupportsMultipleDisplays()) | 708 if (!SupportsMultipleDisplays()) |
709 return; | 709 return; |
710 | 710 |
711 const int64 internal_display_id = | 711 const int64_t internal_display_id = |
712 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); | 712 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); |
713 const DisplayInfo native_display_info = | 713 const DisplayInfo native_display_info = |
714 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); | 714 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); |
715 const DisplayInfo secondary_display_info = | 715 const DisplayInfo secondary_display_info = |
716 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); | 716 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); |
717 | 717 |
718 std::vector<DisplayInfo> display_info_list; | 718 std::vector<DisplayInfo> display_info_list; |
719 display_info_list.push_back(native_display_info); | 719 display_info_list.push_back(native_display_info); |
720 display_info_list.push_back(secondary_display_info); | 720 display_info_list.push_back(secondary_display_info); |
721 display_manager()->OnNativeDisplaysChanged(display_info_list); | 721 display_manager()->OnNativeDisplaysChanged(display_info_list); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 UpdateDisplay("200x200/u"); | 901 UpdateDisplay("200x200/u"); |
902 EXPECT_EQ("1 0 0", GetCountSummary()); | 902 EXPECT_EQ("1 0 0", GetCountSummary()); |
903 reset(); | 903 reset(); |
904 | 904 |
905 UpdateDisplay("200x200/l"); | 905 UpdateDisplay("200x200/l"); |
906 EXPECT_EQ("1 0 0", GetCountSummary()); | 906 EXPECT_EQ("1 0 0", GetCountSummary()); |
907 | 907 |
908 // Having the internal display deactivated should restore user rotation. Newly | 908 // Having the internal display deactivated should restore user rotation. Newly |
909 // set rotations should be applied. | 909 // set rotations should be applied. |
910 UpdateDisplay("200x200, 200x200"); | 910 UpdateDisplay("200x200, 200x200"); |
911 const int64 internal_display_id = | 911 const int64_t internal_display_id = |
912 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); | 912 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); |
913 | 913 |
914 display_manager()->SetDisplayRotation(internal_display_id, | 914 display_manager()->SetDisplayRotation(internal_display_id, |
915 gfx::Display::ROTATE_90, | 915 gfx::Display::ROTATE_90, |
916 gfx::Display::ROTATION_SOURCE_USER); | 916 gfx::Display::ROTATION_SOURCE_USER); |
917 display_manager()->SetDisplayRotation(internal_display_id, | 917 display_manager()->SetDisplayRotation(internal_display_id, |
918 gfx::Display::ROTATE_0, | 918 gfx::Display::ROTATE_0, |
919 gfx::Display::ROTATION_SOURCE_ACTIVE); | 919 gfx::Display::ROTATION_SOURCE_ACTIVE); |
920 | 920 |
921 const DisplayInfo info = GetDisplayInfoForId(internal_display_id); | 921 const DisplayInfo info = GetDisplayInfoForId(internal_display_id); |
(...skipping 15 matching lines...) Expand all Loading... |
937 const DisplayInfo post_rotation_info = | 937 const DisplayInfo post_rotation_info = |
938 display_manager()->display_info_[internal_display_id]; | 938 display_manager()->display_info_[internal_display_id]; |
939 EXPECT_NE(info.GetActiveRotation(), post_rotation_info.GetActiveRotation()); | 939 EXPECT_NE(info.GetActiveRotation(), post_rotation_info.GetActiveRotation()); |
940 EXPECT_EQ(gfx::Display::ROTATE_180, post_rotation_info.GetActiveRotation()); | 940 EXPECT_EQ(gfx::Display::ROTATE_180, post_rotation_info.GetActiveRotation()); |
941 } | 941 } |
942 | 942 |
943 TEST_F(DisplayManagerTest, UIScale) { | 943 TEST_F(DisplayManagerTest, UIScale) { |
944 test::ScopedDisable125DSFForUIScaling disable; | 944 test::ScopedDisable125DSFForUIScaling disable; |
945 | 945 |
946 UpdateDisplay("1280x800"); | 946 UpdateDisplay("1280x800"); |
947 int64 display_id = Shell::GetScreen()->GetPrimaryDisplay().id(); | 947 int64_t display_id = Shell::GetScreen()->GetPrimaryDisplay().id(); |
948 SetDisplayUIScale(display_id, 1.125f); | 948 SetDisplayUIScale(display_id, 1.125f); |
949 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale()); | 949 EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale()); |
950 SetDisplayUIScale(display_id, 0.8f); | 950 SetDisplayUIScale(display_id, 0.8f); |
951 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); | 951 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); |
952 SetDisplayUIScale(display_id, 0.75f); | 952 SetDisplayUIScale(display_id, 0.75f); |
953 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); | 953 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); |
954 SetDisplayUIScale(display_id, 0.625f); | 954 SetDisplayUIScale(display_id, 0.625f); |
955 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); | 955 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); |
956 | 956 |
957 test::ScopedSetInternalDisplayId set_internal(display_id); | 957 test::ScopedSetInternalDisplayId set_internal(display_id); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 EXPECT_TRUE(expected_mode.IsEquivalent( | 1087 EXPECT_TRUE(expected_mode.IsEquivalent( |
1088 display_manager()->GetActiveModeForDisplayId(display_id))); | 1088 display_manager()->GetActiveModeForDisplayId(display_id))); |
1089 SetDisplayUIScale(display_id, 0.5f); | 1089 SetDisplayUIScale(display_id, 0.5f); |
1090 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale()); | 1090 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale()); |
1091 expected_mode.ui_scale = 0.5f; | 1091 expected_mode.ui_scale = 0.5f; |
1092 EXPECT_TRUE(expected_mode.IsEquivalent( | 1092 EXPECT_TRUE(expected_mode.IsEquivalent( |
1093 display_manager()->GetActiveModeForDisplayId(display_id))); | 1093 display_manager()->GetActiveModeForDisplayId(display_id))); |
1094 } | 1094 } |
1095 | 1095 |
1096 TEST_F(DisplayManagerTest, Use125DSFForUIScaling) { | 1096 TEST_F(DisplayManagerTest, Use125DSFForUIScaling) { |
1097 int64 display_id = Shell::GetScreen()->GetPrimaryDisplay().id(); | 1097 int64_t display_id = Shell::GetScreen()->GetPrimaryDisplay().id(); |
1098 test::ScopedSetInternalDisplayId set_internal(display_id); | 1098 test::ScopedSetInternalDisplayId set_internal(display_id); |
1099 | 1099 |
1100 UpdateDisplay("1920x1080*1.25"); | 1100 UpdateDisplay("1920x1080*1.25"); |
1101 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); | 1101 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); |
1102 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); | 1102 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); |
1103 | 1103 |
1104 SetDisplayUIScale(display_id, 0.8f); | 1104 SetDisplayUIScale(display_id, 0.8f); |
1105 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); | 1105 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); |
1106 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); | 1106 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); |
1107 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString()); | 1107 EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString()); |
(...skipping 13 matching lines...) Expand all Loading... |
1121 if (!SupportsMultipleDisplays()) | 1121 if (!SupportsMultipleDisplays()) |
1122 return; | 1122 return; |
1123 // Don't check root window destruction in unified mode. | 1123 // Don't check root window destruction in unified mode. |
1124 Shell::GetPrimaryRootWindow()->RemoveObserver(this); | 1124 Shell::GetPrimaryRootWindow()->RemoveObserver(this); |
1125 | 1125 |
1126 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 1126 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
1127 display_manager->SetUnifiedDesktopEnabled(true); | 1127 display_manager->SetUnifiedDesktopEnabled(true); |
1128 | 1128 |
1129 UpdateDisplay("200x200, 400x400"); | 1129 UpdateDisplay("200x200, 400x400"); |
1130 | 1130 |
1131 int64 unified_id = Shell::GetScreen()->GetPrimaryDisplay().id(); | 1131 int64_t unified_id = Shell::GetScreen()->GetPrimaryDisplay().id(); |
1132 DisplayInfo info = display_manager->GetDisplayInfo(unified_id); | 1132 DisplayInfo info = display_manager->GetDisplayInfo(unified_id); |
1133 ASSERT_EQ(2u, info.display_modes().size()); | 1133 ASSERT_EQ(2u, info.display_modes().size()); |
1134 EXPECT_EQ("400x200", info.display_modes()[0].size.ToString()); | 1134 EXPECT_EQ("400x200", info.display_modes()[0].size.ToString()); |
1135 EXPECT_TRUE(info.display_modes()[0].native); | 1135 EXPECT_TRUE(info.display_modes()[0].native); |
1136 EXPECT_EQ("800x400", info.display_modes()[1].size.ToString()); | 1136 EXPECT_EQ("800x400", info.display_modes()[1].size.ToString()); |
1137 EXPECT_FALSE(info.display_modes()[1].native); | 1137 EXPECT_FALSE(info.display_modes()[1].native); |
1138 EXPECT_EQ("400x200", | 1138 EXPECT_EQ("400x200", |
1139 Shell::GetScreen()->GetPrimaryDisplay().size().ToString()); | 1139 Shell::GetScreen()->GetPrimaryDisplay().size().ToString()); |
1140 DisplayMode active_mode = | 1140 DisplayMode active_mode = |
1141 display_manager->GetActiveModeForDisplayId(unified_id); | 1141 display_manager->GetActiveModeForDisplayId(unified_id); |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1788 EXPECT_EQ("0,0 250x453", docked->bounds().ToString()); | 1788 EXPECT_EQ("0,0 250x453", docked->bounds().ToString()); |
1789 UpdateDisplay("300x300"); | 1789 UpdateDisplay("300x300"); |
1790 // Make sure the window is still docked. | 1790 // Make sure the window is still docked. |
1791 EXPECT_TRUE(wm::GetWindowState(docked.get())->IsDocked()); | 1791 EXPECT_TRUE(wm::GetWindowState(docked.get())->IsDocked()); |
1792 EXPECT_EQ("0,0 250x253", docked->bounds().ToString()); | 1792 EXPECT_EQ("0,0 250x253", docked->bounds().ToString()); |
1793 } | 1793 } |
1794 | 1794 |
1795 TEST_F(DisplayManagerTest, DockMode) { | 1795 TEST_F(DisplayManagerTest, DockMode) { |
1796 if (!SupportsMultipleDisplays()) | 1796 if (!SupportsMultipleDisplays()) |
1797 return; | 1797 return; |
1798 const int64 internal_id = 1; | 1798 const int64_t internal_id = 1; |
1799 const int64 external_id = 2; | 1799 const int64_t external_id = 2; |
1800 | 1800 |
1801 const DisplayInfo internal_display_info = | 1801 const DisplayInfo internal_display_info = |
1802 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500)); | 1802 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500)); |
1803 const DisplayInfo external_display_info = | 1803 const DisplayInfo external_display_info = |
1804 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); | 1804 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); |
1805 std::vector<DisplayInfo> display_info_list; | 1805 std::vector<DisplayInfo> display_info_list; |
1806 | 1806 |
1807 // software mirroring. | 1807 // software mirroring. |
1808 display_info_list.push_back(internal_display_info); | 1808 display_info_list.push_back(internal_display_info); |
1809 display_info_list.push_back(external_display_info); | 1809 display_info_list.push_back(external_display_info); |
1810 display_manager()->OnNativeDisplaysChanged(display_info_list); | 1810 display_manager()->OnNativeDisplaysChanged(display_info_list); |
1811 const int64 internal_display_id = | 1811 const int64_t internal_display_id = |
1812 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); | 1812 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); |
1813 EXPECT_EQ(internal_id, internal_display_id); | 1813 EXPECT_EQ(internal_id, internal_display_id); |
1814 | 1814 |
1815 display_info_list.clear(); | 1815 display_info_list.clear(); |
1816 display_info_list.push_back(external_display_info); | 1816 display_info_list.push_back(external_display_info); |
1817 display_manager()->OnNativeDisplaysChanged(display_info_list); | 1817 display_manager()->OnNativeDisplaysChanged(display_info_list); |
1818 EXPECT_EQ(1U, display_manager()->active_display_list().size()); | 1818 EXPECT_EQ(1U, display_manager()->active_display_list().size()); |
1819 | 1819 |
1820 EXPECT_TRUE(display_manager()->IsActiveDisplayId(external_id)); | 1820 EXPECT_TRUE(display_manager()->IsActiveDisplayId(external_id)); |
1821 EXPECT_FALSE(display_manager()->IsActiveDisplayId(internal_id)); | 1821 EXPECT_FALSE(display_manager()->IsActiveDisplayId(internal_id)); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1997 | 1997 |
1998 EXPECT_EQ(gfx::Display::ROTATE_90, | 1998 EXPECT_EQ(gfx::Display::ROTATE_90, |
1999 info.GetRotation(gfx::Display::ROTATION_SOURCE_USER)); | 1999 info.GetRotation(gfx::Display::ROTATION_SOURCE_USER)); |
2000 EXPECT_EQ(gfx::Display::ROTATE_90, | 2000 EXPECT_EQ(gfx::Display::ROTATE_90, |
2001 info.GetRotation(gfx::Display::ROTATION_SOURCE_ACTIVE)); | 2001 info.GetRotation(gfx::Display::ROTATION_SOURCE_ACTIVE)); |
2002 } | 2002 } |
2003 | 2003 |
2004 #endif // OS_CHROMEOS | 2004 #endif // OS_CHROMEOS |
2005 | 2005 |
2006 } // namespace ash | 2006 } // namespace ash |
OLD | NEW |