| 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_aura.h" | 7 #include "ash/accelerators/accelerator_commands_aura.h" |
| 8 #include "ash/common/ash_switches.h" | 8 #include "ash/common/ash_switches.h" |
| 9 #include "ash/common/display/display_info.h" | |
| 10 #include "ash/common/material_design/material_design_controller.h" | 9 #include "ash/common/material_design/material_design_controller.h" |
| 11 #include "ash/common/wm/window_state.h" | 10 #include "ash/common/wm/window_state.h" |
| 12 #include "ash/display/display_configuration_controller.h" | 11 #include "ash/display/display_configuration_controller.h" |
| 13 #include "ash/display/display_util.h" | 12 #include "ash/display/display_util.h" |
| 14 #include "ash/display/mirror_window_controller.h" | 13 #include "ash/display/mirror_window_controller.h" |
| 15 #include "ash/display/window_tree_host_manager.h" | 14 #include "ash/display/window_tree_host_manager.h" |
| 16 #include "ash/screen_util.h" | 15 #include "ash/screen_util.h" |
| 17 #include "ash/shell.h" | 16 #include "ash/shell.h" |
| 18 #include "ash/test/ash_md_test_base.h" | 17 #include "ash/test/ash_md_test_base.h" |
| 19 #include "ash/test/ash_test_base.h" | 18 #include "ash/test/ash_test_base.h" |
| 20 #include "ash/test/display_manager_test_api.h" | 19 #include "ash/test/display_manager_test_api.h" |
| 21 #include "ash/test/mirror_window_test_api.h" | 20 #include "ash/test/mirror_window_test_api.h" |
| 22 #include "ash/wm/window_state_aura.h" | 21 #include "ash/wm/window_state_aura.h" |
| 23 #include "base/command_line.h" | 22 #include "base/command_line.h" |
| 24 #include "base/format_macros.h" | 23 #include "base/format_macros.h" |
| 25 #include "base/strings/string_number_conversions.h" | 24 #include "base/strings/string_number_conversions.h" |
| 26 #include "base/strings/stringprintf.h" | 25 #include "base/strings/stringprintf.h" |
| 27 #include "grit/ash_strings.h" | 26 #include "grit/ash_strings.h" |
| 28 #include "ui/aura/client/aura_constants.h" | 27 #include "ui/aura/client/aura_constants.h" |
| 29 #include "ui/aura/env.h" | 28 #include "ui/aura/env.h" |
| 30 #include "ui/aura/window_observer.h" | 29 #include "ui/aura/window_observer.h" |
| 31 #include "ui/aura/window_tree_host.h" | 30 #include "ui/aura/window_tree_host.h" |
| 32 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 33 #include "ui/display/display.h" | 32 #include "ui/display/display.h" |
| 34 #include "ui/display/display_observer.h" | 33 #include "ui/display/display_observer.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" |
| 36 #include "ui/display/manager/managed_display_info.h" |
| 37 #include "ui/display/screen.h" | 37 #include "ui/display/screen.h" |
| 38 #include "ui/events/test/event_generator.h" | 38 #include "ui/events/test/event_generator.h" |
| 39 #include "ui/gfx/font_render_params.h" | 39 #include "ui/gfx/font_render_params.h" |
| 40 | 40 |
| 41 namespace ash { | 41 namespace ash { |
| 42 | 42 |
| 43 using std::vector; | 43 using std::vector; |
| 44 using std::string; | 44 using std::string; |
| 45 | 45 |
| 46 using base::StringPrintf; | 46 using base::StringPrintf; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 void reset() { | 89 void reset() { |
| 90 changed_.clear(); | 90 changed_.clear(); |
| 91 added_.clear(); | 91 added_.clear(); |
| 92 removed_count_ = 0U; | 92 removed_count_ = 0U; |
| 93 changed_metrics_ = 0U; | 93 changed_metrics_ = 0U; |
| 94 root_window_destroyed_ = false; | 94 root_window_destroyed_ = false; |
| 95 } | 95 } |
| 96 | 96 |
| 97 bool root_window_destroyed() const { return root_window_destroyed_; } | 97 bool root_window_destroyed() const { return root_window_destroyed_; } |
| 98 | 98 |
| 99 const DisplayInfo& GetDisplayInfo(const display::Display& display) { | 99 const ui::ManagedDisplayInfo& GetDisplayInfo( |
| 100 const display::Display& display) { |
| 100 return display_manager()->GetDisplayInfo(display.id()); | 101 return display_manager()->GetDisplayInfo(display.id()); |
| 101 } | 102 } |
| 102 | 103 |
| 103 const DisplayInfo& GetDisplayInfoAt(int index) { | 104 const ui::ManagedDisplayInfo& GetDisplayInfoAt(int index) { |
| 104 return GetDisplayInfo(display_manager()->GetDisplayAt(index)); | 105 return GetDisplayInfo(display_manager()->GetDisplayAt(index)); |
| 105 } | 106 } |
| 106 | 107 |
| 107 const display::Display& GetDisplayForId(int64_t id) { | 108 const display::Display& GetDisplayForId(int64_t id) { |
| 108 return display_manager()->GetDisplayForId(id); | 109 return display_manager()->GetDisplayForId(id); |
| 109 } | 110 } |
| 110 | 111 |
| 111 const DisplayInfo& GetDisplayInfoForId(int64_t id) { | 112 const ui::ManagedDisplayInfo& GetDisplayInfoForId(int64_t id) { |
| 112 return GetDisplayInfo(display_manager()->GetDisplayForId(id)); | 113 return GetDisplayInfo(display_manager()->GetDisplayForId(id)); |
| 113 } | 114 } |
| 114 | 115 |
| 115 // aura::DisplayObserver overrides: | 116 // aura::DisplayObserver overrides: |
| 116 void OnDisplayMetricsChanged(const display::Display& display, | 117 void OnDisplayMetricsChanged(const display::Display& display, |
| 117 uint32_t changed_metrics) override { | 118 uint32_t changed_metrics) override { |
| 118 changed_.push_back(display); | 119 changed_.push_back(display); |
| 119 changed_metrics_ |= changed_metrics; | 120 changed_metrics_ |= changed_metrics; |
| 120 } | 121 } |
| 121 void OnDisplayAdded(const display::Display& new_display) override { | 122 void OnDisplayAdded(const display::Display& new_display) override { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 199 |
| 199 // Secondary removed, primary changed. | 200 // Secondary removed, primary changed. |
| 200 UpdateDisplay("1+1-800x300"); | 201 UpdateDisplay("1+1-800x300"); |
| 201 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 202 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
| 202 EXPECT_EQ("1 0 1", GetCountSummary()); | 203 EXPECT_EQ("1 0 1", GetCountSummary()); |
| 203 EXPECT_EQ(display_manager()->GetDisplayAt(0).id(), changed()[0].id()); | 204 EXPECT_EQ(display_manager()->GetDisplayAt(0).id(), changed()[0].id()); |
| 204 EXPECT_EQ("0,0 800x300", changed()[0].bounds().ToString()); | 205 EXPECT_EQ("0,0 800x300", changed()[0].bounds().ToString()); |
| 205 reset(); | 206 reset(); |
| 206 | 207 |
| 207 // # of display can go to zero when screen is off. | 208 // # of display can go to zero when screen is off. |
| 208 const vector<DisplayInfo> empty; | 209 const vector<ui::ManagedDisplayInfo> empty; |
| 209 display_manager()->OnNativeDisplaysChanged(empty); | 210 display_manager()->OnNativeDisplaysChanged(empty); |
| 210 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 211 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
| 211 EXPECT_EQ("0 0 0", GetCountSummary()); | 212 EXPECT_EQ("0 0 0", GetCountSummary()); |
| 212 EXPECT_FALSE(root_window_destroyed()); | 213 EXPECT_FALSE(root_window_destroyed()); |
| 213 // Display configuration stays the same | 214 // Display configuration stays the same |
| 214 EXPECT_EQ("0,0 800x300", | 215 EXPECT_EQ("0,0 800x300", |
| 215 display_manager()->GetDisplayAt(0).bounds().ToString()); | 216 display_manager()->GetDisplayAt(0).bounds().ToString()); |
| 216 reset(); | 217 reset(); |
| 217 | 218 |
| 218 // Connect to display again | 219 // Connect to display again |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 #endif | 480 #endif |
| 480 } | 481 } |
| 481 | 482 |
| 482 TEST_P(DisplayManagerTest, OverscanInsetsTest) { | 483 TEST_P(DisplayManagerTest, OverscanInsetsTest) { |
| 483 if (!SupportsMultipleDisplays()) | 484 if (!SupportsMultipleDisplays()) |
| 484 return; | 485 return; |
| 485 | 486 |
| 486 UpdateDisplay("0+0-500x500,0+501-400x400"); | 487 UpdateDisplay("0+0-500x500,0+501-400x400"); |
| 487 reset(); | 488 reset(); |
| 488 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); | 489 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); |
| 489 const DisplayInfo& display_info1 = GetDisplayInfoAt(0); | 490 const ui::ManagedDisplayInfo& display_info1 = GetDisplayInfoAt(0); |
| 490 const DisplayInfo& display_info2 = GetDisplayInfoAt(1); | 491 const ui::ManagedDisplayInfo& display_info2 = GetDisplayInfoAt(1); |
| 491 display_manager()->SetOverscanInsets(display_info2.id(), | 492 display_manager()->SetOverscanInsets(display_info2.id(), |
| 492 gfx::Insets(13, 12, 11, 10)); | 493 gfx::Insets(13, 12, 11, 10)); |
| 493 | 494 |
| 494 std::vector<display::Display> changed_displays = changed(); | 495 std::vector<display::Display> changed_displays = changed(); |
| 495 EXPECT_EQ(1u, changed_displays.size()); | 496 EXPECT_EQ(1u, changed_displays.size()); |
| 496 EXPECT_EQ(display_info2.id(), changed_displays[0].id()); | 497 EXPECT_EQ(display_info2.id(), changed_displays[0].id()); |
| 497 EXPECT_EQ("0,0 500x500", GetDisplayInfoAt(0).bounds_in_native().ToString()); | 498 EXPECT_EQ("0,0 500x500", GetDisplayInfoAt(0).bounds_in_native().ToString()); |
| 498 DisplayInfo updated_display_info2 = GetDisplayInfoAt(1); | 499 ui::ManagedDisplayInfo updated_display_info2 = GetDisplayInfoAt(1); |
| 499 EXPECT_EQ("0,501 400x400", | 500 EXPECT_EQ("0,501 400x400", |
| 500 updated_display_info2.bounds_in_native().ToString()); | 501 updated_display_info2.bounds_in_native().ToString()); |
| 501 EXPECT_EQ("378x376", updated_display_info2.size_in_pixel().ToString()); | 502 EXPECT_EQ("378x376", updated_display_info2.size_in_pixel().ToString()); |
| 502 EXPECT_EQ("13,12,11,10", | 503 EXPECT_EQ("13,12,11,10", |
| 503 updated_display_info2.overscan_insets_in_dip().ToString()); | 504 updated_display_info2.overscan_insets_in_dip().ToString()); |
| 504 EXPECT_EQ("500,0 378x376", | 505 EXPECT_EQ("500,0 378x376", |
| 505 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 506 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
| 506 | 507 |
| 507 // Make sure that SetOverscanInsets() is idempotent. | 508 // Make sure that SetOverscanInsets() is idempotent. |
| 508 display_manager()->SetOverscanInsets(display_info1.id(), gfx::Insets()); | 509 display_manager()->SetOverscanInsets(display_info1.id(), gfx::Insets()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 526 // Recreate a new 2nd display. It won't apply the overscan inset because the | 527 // Recreate a new 2nd display. It won't apply the overscan inset because the |
| 527 // new display has a different ID. | 528 // new display has a different ID. |
| 528 UpdateDisplay("0+0-500x500"); | 529 UpdateDisplay("0+0-500x500"); |
| 529 UpdateDisplay("0+0-500x500,0+501-400x400"); | 530 UpdateDisplay("0+0-500x500,0+501-400x400"); |
| 530 EXPECT_EQ("0,0 500x500", GetDisplayInfoAt(0).bounds_in_native().ToString()); | 531 EXPECT_EQ("0,0 500x500", GetDisplayInfoAt(0).bounds_in_native().ToString()); |
| 531 EXPECT_EQ("0,501 400x400", GetDisplayInfoAt(1).bounds_in_native().ToString()); | 532 EXPECT_EQ("0,501 400x400", GetDisplayInfoAt(1).bounds_in_native().ToString()); |
| 532 | 533 |
| 533 // Recreate the displays with the same ID. It should apply the overscan | 534 // Recreate the displays with the same ID. It should apply the overscan |
| 534 // inset. | 535 // inset. |
| 535 UpdateDisplay("0+0-500x500"); | 536 UpdateDisplay("0+0-500x500"); |
| 536 std::vector<DisplayInfo> display_info_list; | 537 std::vector<ui::ManagedDisplayInfo> display_info_list; |
| 537 display_info_list.push_back(display_info1); | 538 display_info_list.push_back(display_info1); |
| 538 display_info_list.push_back(display_info2); | 539 display_info_list.push_back(display_info2); |
| 539 display_manager()->OnNativeDisplaysChanged(display_info_list); | 540 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 540 EXPECT_EQ("1,1 500x500", GetDisplayInfoAt(0).bounds_in_native().ToString()); | 541 EXPECT_EQ("1,1 500x500", GetDisplayInfoAt(0).bounds_in_native().ToString()); |
| 541 updated_display_info2 = GetDisplayInfoAt(1); | 542 updated_display_info2 = GetDisplayInfoAt(1); |
| 542 EXPECT_EQ("376x378", updated_display_info2.size_in_pixel().ToString()); | 543 EXPECT_EQ("376x378", updated_display_info2.size_in_pixel().ToString()); |
| 543 EXPECT_EQ("10,11,12,13", | 544 EXPECT_EQ("10,11,12,13", |
| 544 updated_display_info2.overscan_insets_in_dip().ToString()); | 545 updated_display_info2.overscan_insets_in_dip().ToString()); |
| 545 | 546 |
| 546 // HiDPI but overscan display. The specified insets size should be doubled. | 547 // HiDPI but overscan display. The specified insets size should be doubled. |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); | 636 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); |
| 636 EXPECT_EQ("1 0 0", GetCountSummary()); | 637 EXPECT_EQ("1 0 0", GetCountSummary()); |
| 637 | 638 |
| 638 UpdateDisplay("1000x600*2"); | 639 UpdateDisplay("1000x600*2"); |
| 639 EXPECT_EQ(2, host->compositor()->device_scale_factor()); | 640 EXPECT_EQ(2, host->compositor()->device_scale_factor()); |
| 640 EXPECT_EQ("2 0 0", GetCountSummary()); | 641 EXPECT_EQ("2 0 0", GetCountSummary()); |
| 641 EXPECT_EQ("500x300", | 642 EXPECT_EQ("500x300", |
| 642 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); | 643 Shell::GetPrimaryRootWindow()->bounds().size().ToString()); |
| 643 } | 644 } |
| 644 | 645 |
| 645 DisplayInfo CreateDisplayInfo(int64_t id, const gfx::Rect& bounds) { | 646 ui::ManagedDisplayInfo CreateDisplayInfo(int64_t id, const gfx::Rect& bounds) { |
| 646 DisplayInfo info(id, ToDisplayName(id), false); | 647 ui::ManagedDisplayInfo info(id, ToDisplayName(id), false); |
| 647 info.SetBounds(bounds); | 648 info.SetBounds(bounds); |
| 648 return info; | 649 return info; |
| 649 } | 650 } |
| 650 | 651 |
| 651 TEST_P(DisplayManagerTest, TestNativeDisplaysChanged) { | 652 TEST_P(DisplayManagerTest, TestNativeDisplaysChanged) { |
| 652 const int64_t internal_display_id = | 653 const int64_t internal_display_id = |
| 653 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); | 654 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); |
| 654 const int external_id = 10; | 655 const int external_id = 10; |
| 655 const int mirror_id = 11; | 656 const int mirror_id = 11; |
| 656 const int64_t invalid_id = display::Display::kInvalidDisplayID; | 657 const int64_t invalid_id = display::Display::kInvalidDisplayID; |
| 657 const DisplayInfo internal_display_info = | 658 const ui::ManagedDisplayInfo internal_display_info = |
| 658 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); | 659 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); |
| 659 const DisplayInfo external_display_info = | 660 const ui::ManagedDisplayInfo external_display_info = |
| 660 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); | 661 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); |
| 661 const DisplayInfo mirroring_display_info = | 662 const ui::ManagedDisplayInfo mirroring_display_info = |
| 662 CreateDisplayInfo(mirror_id, gfx::Rect(0, 0, 500, 500)); | 663 CreateDisplayInfo(mirror_id, gfx::Rect(0, 0, 500, 500)); |
| 663 | 664 |
| 664 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 665 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
| 665 EXPECT_EQ(1U, display_manager()->num_connected_displays()); | 666 EXPECT_EQ(1U, display_manager()->num_connected_displays()); |
| 666 std::string default_bounds = | 667 std::string default_bounds = |
| 667 display_manager()->GetDisplayAt(0).bounds().ToString(); | 668 display_manager()->GetDisplayAt(0).bounds().ToString(); |
| 668 | 669 |
| 669 std::vector<DisplayInfo> display_info_list; | 670 std::vector<ui::ManagedDisplayInfo> display_info_list; |
| 670 // Primary disconnected. | 671 // Primary disconnected. |
| 671 display_manager()->OnNativeDisplaysChanged(display_info_list); | 672 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 672 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 673 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
| 673 EXPECT_EQ(default_bounds, | 674 EXPECT_EQ(default_bounds, |
| 674 display_manager()->GetDisplayAt(0).bounds().ToString()); | 675 display_manager()->GetDisplayAt(0).bounds().ToString()); |
| 675 EXPECT_EQ(1U, display_manager()->num_connected_displays()); | 676 EXPECT_EQ(1U, display_manager()->num_connected_displays()); |
| 676 EXPECT_FALSE(display_manager()->IsInMirrorMode()); | 677 EXPECT_FALSE(display_manager()->IsInMirrorMode()); |
| 677 | 678 |
| 678 if (!SupportsMultipleDisplays()) | 679 if (!SupportsMultipleDisplays()) |
| 679 return; | 680 return; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 // See: crbug.com/414394 | 818 // See: crbug.com/414394 |
| 818 TEST_P(DisplayManagerTest, DisplayAddRemoveAtTheSameTime) { | 819 TEST_P(DisplayManagerTest, DisplayAddRemoveAtTheSameTime) { |
| 819 if (!SupportsMultipleDisplays()) | 820 if (!SupportsMultipleDisplays()) |
| 820 return; | 821 return; |
| 821 | 822 |
| 822 UpdateDisplay("100+0-500x500,0+501-400x400"); | 823 UpdateDisplay("100+0-500x500,0+501-400x400"); |
| 823 | 824 |
| 824 const int64_t primary_id = WindowTreeHostManager::GetPrimaryDisplayId(); | 825 const int64_t primary_id = WindowTreeHostManager::GetPrimaryDisplayId(); |
| 825 const int64_t secondary_id = ScreenUtil::GetSecondaryDisplay().id(); | 826 const int64_t secondary_id = ScreenUtil::GetSecondaryDisplay().id(); |
| 826 | 827 |
| 827 DisplayInfo primary_info = display_manager()->GetDisplayInfo(primary_id); | 828 ui::ManagedDisplayInfo primary_info = |
| 828 DisplayInfo secondary_info = display_manager()->GetDisplayInfo(secondary_id); | 829 display_manager()->GetDisplayInfo(primary_id); |
| 830 ui::ManagedDisplayInfo secondary_info = |
| 831 display_manager()->GetDisplayInfo(secondary_id); |
| 829 | 832 |
| 830 // An id which is different from primary and secondary. | 833 // An id which is different from primary and secondary. |
| 831 const int64_t third_id = secondary_id + 1; | 834 const int64_t third_id = secondary_id + 1; |
| 832 | 835 |
| 833 DisplayInfo third_info = | 836 ui::ManagedDisplayInfo third_info = |
| 834 CreateDisplayInfo(third_id, gfx::Rect(0, 0, 600, 600)); | 837 CreateDisplayInfo(third_id, gfx::Rect(0, 0, 600, 600)); |
| 835 | 838 |
| 836 std::vector<DisplayInfo> display_info_list; | 839 std::vector<ui::ManagedDisplayInfo> display_info_list; |
| 837 display_info_list.push_back(third_info); | 840 display_info_list.push_back(third_info); |
| 838 display_info_list.push_back(secondary_info); | 841 display_info_list.push_back(secondary_info); |
| 839 display_manager()->OnNativeDisplaysChanged(display_info_list); | 842 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 840 | 843 |
| 841 // Secondary seconary_id becomes the primary as it has smaller output index. | 844 // Secondary seconary_id becomes the primary as it has smaller output index. |
| 842 EXPECT_EQ(secondary_id, WindowTreeHostManager::GetPrimaryDisplayId()); | 845 EXPECT_EQ(secondary_id, WindowTreeHostManager::GetPrimaryDisplayId()); |
| 843 EXPECT_EQ(third_id, ScreenUtil::GetSecondaryDisplay().id()); | 846 EXPECT_EQ(third_id, ScreenUtil::GetSecondaryDisplay().id()); |
| 844 EXPECT_EQ("600x600", GetDisplayForId(third_id).size().ToString()); | 847 EXPECT_EQ("600x600", GetDisplayForId(third_id).size().ToString()); |
| 845 } | 848 } |
| 846 | 849 |
| 847 // TODO(scottmg): RootWindow doesn't get resized on Windows | 850 // TODO(scottmg): RootWindow doesn't get resized on Windows |
| 848 // Ash. http://crbug.com/247916. | 851 // Ash. http://crbug.com/247916. |
| 849 #if defined(OS_CHROMEOS) | 852 #if defined(OS_CHROMEOS) |
| 850 TEST_P(DisplayManagerTest, TestNativeDisplaysChangedNoInternal) { | 853 TEST_P(DisplayManagerTest, TestNativeDisplaysChangedNoInternal) { |
| 851 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 854 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
| 852 | 855 |
| 853 // Don't change the display info if all displays are disconnected. | 856 // Don't change the display info if all displays are disconnected. |
| 854 std::vector<DisplayInfo> display_info_list; | 857 std::vector<ui::ManagedDisplayInfo> display_info_list; |
| 855 display_manager()->OnNativeDisplaysChanged(display_info_list); | 858 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 856 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 859 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
| 857 | 860 |
| 858 // Connect another display which will become primary. | 861 // Connect another display which will become primary. |
| 859 const DisplayInfo external_display_info = | 862 const ui::ManagedDisplayInfo external_display_info = |
| 860 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); | 863 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); |
| 861 display_info_list.push_back(external_display_info); | 864 display_info_list.push_back(external_display_info); |
| 862 display_manager()->OnNativeDisplaysChanged(display_info_list); | 865 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 863 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); | 866 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
| 864 EXPECT_EQ("1,1 100x100", | 867 EXPECT_EQ("1,1 100x100", |
| 865 GetDisplayInfoForId(10).bounds_in_native().ToString()); | 868 GetDisplayInfoForId(10).bounds_in_native().ToString()); |
| 866 EXPECT_EQ("100x100", ash::Shell::GetPrimaryRootWindow() | 869 EXPECT_EQ("100x100", ash::Shell::GetPrimaryRootWindow() |
| 867 ->GetHost() | 870 ->GetHost() |
| 868 ->GetBounds() | 871 ->GetBounds() |
| 869 .size() | 872 .size() |
| 870 .ToString()); | 873 .ToString()); |
| 871 } | 874 } |
| 872 #endif // defined(OS_CHROMEOS) | 875 #endif // defined(OS_CHROMEOS) |
| 873 | 876 |
| 874 TEST_P(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) { | 877 TEST_P(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) { |
| 875 if (!SupportsMultipleDisplays()) | 878 if (!SupportsMultipleDisplays()) |
| 876 return; | 879 return; |
| 877 | 880 |
| 878 const int64_t internal_display_id = | 881 const int64_t internal_display_id = |
| 879 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); | 882 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); |
| 880 const DisplayInfo native_display_info = | 883 const ui::ManagedDisplayInfo native_display_info = |
| 881 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); | 884 CreateDisplayInfo(internal_display_id, gfx::Rect(0, 0, 500, 500)); |
| 882 const DisplayInfo secondary_display_info = | 885 const ui::ManagedDisplayInfo secondary_display_info = |
| 883 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); | 886 CreateDisplayInfo(10, gfx::Rect(1, 1, 100, 100)); |
| 884 | 887 |
| 885 std::vector<DisplayInfo> display_info_list; | 888 std::vector<ui::ManagedDisplayInfo> display_info_list; |
| 886 display_info_list.push_back(native_display_info); | 889 display_info_list.push_back(native_display_info); |
| 887 display_info_list.push_back(secondary_display_info); | 890 display_info_list.push_back(secondary_display_info); |
| 888 display_manager()->OnNativeDisplaysChanged(display_info_list); | 891 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 889 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); | 892 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); |
| 890 EXPECT_EQ("0,0 500x500", | 893 EXPECT_EQ("0,0 500x500", |
| 891 GetDisplayForId(internal_display_id).bounds().ToString()); | 894 GetDisplayForId(internal_display_id).bounds().ToString()); |
| 892 EXPECT_EQ("500,0 100x100", GetDisplayForId(10).bounds().ToString()); | 895 EXPECT_EQ("500,0 100x100", GetDisplayForId(10).bounds().ToString()); |
| 893 | 896 |
| 894 ash::Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId( | 897 ash::Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId( |
| 895 secondary_display_info.id()); | 898 secondary_display_info.id()); |
| 896 EXPECT_EQ("-500,0 500x500", | 899 EXPECT_EQ("-500,0 500x500", |
| 897 GetDisplayForId(internal_display_id).bounds().ToString()); | 900 GetDisplayForId(internal_display_id).bounds().ToString()); |
| 898 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString()); | 901 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString()); |
| 899 | 902 |
| 900 // OnNativeDisplaysChanged may change the display bounds. Here makes sure | 903 // OnNativeDisplaysChanged may change the display bounds. Here makes sure |
| 901 // nothing changed if the exactly same displays are specified. | 904 // nothing changed if the exactly same displays are specified. |
| 902 display_manager()->OnNativeDisplaysChanged(display_info_list); | 905 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 903 EXPECT_EQ("-500,0 500x500", | 906 EXPECT_EQ("-500,0 500x500", |
| 904 GetDisplayForId(internal_display_id).bounds().ToString()); | 907 GetDisplayForId(internal_display_id).bounds().ToString()); |
| 905 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString()); | 908 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString()); |
| 906 } | 909 } |
| 907 | 910 |
| 908 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 911 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
| 909 #if defined(OS_CHROMEOS) | 912 #if defined(OS_CHROMEOS) |
| 910 TEST_P(DisplayManagerTest, DontRememberBestResolution) { | 913 TEST_P(DisplayManagerTest, DontRememberBestResolution) { |
| 911 int display_id = 1000; | 914 int display_id = 1000; |
| 912 DisplayInfo native_display_info = | 915 ui::ManagedDisplayInfo native_display_info = |
| 913 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); | 916 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); |
| 914 DisplayInfo::ManagedDisplayModeList display_modes; | 917 ui::ManagedDisplayInfo::ManagedDisplayModeList display_modes; |
| 915 display_modes.push_back(make_scoped_refptr( | 918 display_modes.push_back(make_scoped_refptr( |
| 916 new ManagedDisplayMode(gfx::Size(1000, 500), 58.0f, false, true))); | 919 new ui::ManagedDisplayMode(gfx::Size(1000, 500), 58.0f, false, true))); |
| 917 display_modes.push_back(make_scoped_refptr( | 920 display_modes.push_back(make_scoped_refptr( |
| 918 new ManagedDisplayMode(gfx::Size(800, 300), 59.0f, false, false))); | 921 new ui::ManagedDisplayMode(gfx::Size(800, 300), 59.0f, false, false))); |
| 919 display_modes.push_back(make_scoped_refptr( | 922 display_modes.push_back(make_scoped_refptr( |
| 920 new ManagedDisplayMode(gfx::Size(400, 500), 60.0f, false, false))); | 923 new ui::ManagedDisplayMode(gfx::Size(400, 500), 60.0f, false, false))); |
| 921 | 924 |
| 922 native_display_info.SetManagedDisplayModes(display_modes); | 925 native_display_info.SetManagedDisplayModes(display_modes); |
| 923 | 926 |
| 924 std::vector<DisplayInfo> display_info_list; | 927 std::vector<ui::ManagedDisplayInfo> display_info_list; |
| 925 display_info_list.push_back(native_display_info); | 928 display_info_list.push_back(native_display_info); |
| 926 display_manager()->OnNativeDisplaysChanged(display_info_list); | 929 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 927 | 930 |
| 928 scoped_refptr<ManagedDisplayMode> mode; | 931 scoped_refptr<ui::ManagedDisplayMode> mode; |
| 929 scoped_refptr<ManagedDisplayMode> expected_mode( | 932 scoped_refptr<ui::ManagedDisplayMode> expected_mode( |
| 930 new ManagedDisplayMode(gfx::Size(1000, 500), 0.0f, false, false)); | 933 new ui::ManagedDisplayMode(gfx::Size(1000, 500), 0.0f, false, false)); |
| 931 | 934 |
| 932 mode = display_manager()->GetSelectedModeForDisplayId(display_id); | 935 mode = display_manager()->GetSelectedModeForDisplayId(display_id); |
| 933 EXPECT_FALSE(!!mode); | 936 EXPECT_FALSE(!!mode); |
| 934 EXPECT_TRUE(expected_mode->IsEquivalent( | 937 EXPECT_TRUE(expected_mode->IsEquivalent( |
| 935 display_manager()->GetActiveModeForDisplayId(display_id))); | 938 display_manager()->GetActiveModeForDisplayId(display_id))); |
| 936 | 939 |
| 937 // Unsupported resolution. | 940 // Unsupported resolution. |
| 938 test::SetDisplayResolution(display_id, gfx::Size(800, 4000)); | 941 test::SetDisplayResolution(display_id, gfx::Size(800, 4000)); |
| 939 mode = display_manager()->GetSelectedModeForDisplayId(display_id); | 942 mode = display_manager()->GetSelectedModeForDisplayId(display_id); |
| 940 EXPECT_FALSE(!!mode); | 943 EXPECT_FALSE(!!mode); |
| 941 EXPECT_TRUE(expected_mode->IsEquivalent( | 944 EXPECT_TRUE(expected_mode->IsEquivalent( |
| 942 display_manager()->GetActiveModeForDisplayId(display_id))); | 945 display_manager()->GetActiveModeForDisplayId(display_id))); |
| 943 | 946 |
| 944 // Supported resolution. | 947 // Supported resolution. |
| 945 test::SetDisplayResolution(display_id, gfx::Size(800, 300)); | 948 test::SetDisplayResolution(display_id, gfx::Size(800, 300)); |
| 946 mode = display_manager()->GetSelectedModeForDisplayId(display_id); | 949 mode = display_manager()->GetSelectedModeForDisplayId(display_id); |
| 947 EXPECT_TRUE(!!mode); | 950 EXPECT_TRUE(!!mode); |
| 948 EXPECT_EQ("800x300", mode->size().ToString()); | 951 EXPECT_EQ("800x300", mode->size().ToString()); |
| 949 EXPECT_EQ(59.0f, mode->refresh_rate()); | 952 EXPECT_EQ(59.0f, mode->refresh_rate()); |
| 950 EXPECT_FALSE(mode->native()); | 953 EXPECT_FALSE(mode->native()); |
| 951 | 954 |
| 952 expected_mode = | 955 expected_mode = |
| 953 new ManagedDisplayMode(gfx::Size(800, 300), 0.0f, false, false); | 956 new ui::ManagedDisplayMode(gfx::Size(800, 300), 0.0f, false, false); |
| 954 | 957 |
| 955 EXPECT_TRUE(expected_mode->IsEquivalent( | 958 EXPECT_TRUE(expected_mode->IsEquivalent( |
| 956 display_manager()->GetActiveModeForDisplayId(display_id))); | 959 display_manager()->GetActiveModeForDisplayId(display_id))); |
| 957 | 960 |
| 958 // Best resolution. | 961 // Best resolution. |
| 959 test::SetDisplayResolution(display_id, gfx::Size(1000, 500)); | 962 test::SetDisplayResolution(display_id, gfx::Size(1000, 500)); |
| 960 mode = display_manager()->GetSelectedModeForDisplayId(display_id); | 963 mode = display_manager()->GetSelectedModeForDisplayId(display_id); |
| 961 EXPECT_TRUE(!!mode); | 964 EXPECT_TRUE(!!mode); |
| 962 EXPECT_EQ("1000x500", mode->size().ToString()); | 965 EXPECT_EQ("1000x500", mode->size().ToString()); |
| 963 EXPECT_EQ(58.0f, mode->refresh_rate()); | 966 EXPECT_EQ(58.0f, mode->refresh_rate()); |
| 964 EXPECT_TRUE(mode->native()); | 967 EXPECT_TRUE(mode->native()); |
| 965 | 968 |
| 966 expected_mode = | 969 expected_mode = |
| 967 new ManagedDisplayMode(gfx::Size(1000, 500), 0.0f, false, false); | 970 new ui::ManagedDisplayMode(gfx::Size(1000, 500), 0.0f, false, false); |
| 968 | 971 |
| 969 EXPECT_TRUE(expected_mode->IsEquivalent( | 972 EXPECT_TRUE(expected_mode->IsEquivalent( |
| 970 display_manager()->GetActiveModeForDisplayId(display_id))); | 973 display_manager()->GetActiveModeForDisplayId(display_id))); |
| 971 } | 974 } |
| 972 #endif // defined(OS_CHROMEOS) | 975 #endif // defined(OS_CHROMEOS) |
| 973 | 976 |
| 974 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 977 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
| 975 #if defined(OS_CHROMEOS) | 978 #if defined(OS_CHROMEOS) |
| 976 TEST_P(DisplayManagerTest, ResolutionFallback) { | 979 TEST_P(DisplayManagerTest, ResolutionFallback) { |
| 977 int display_id = 1000; | 980 int display_id = 1000; |
| 978 DisplayInfo native_display_info = | 981 ui::ManagedDisplayInfo native_display_info = |
| 979 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); | 982 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); |
| 980 DisplayInfo::ManagedDisplayModeList display_modes; | 983 ui::ManagedDisplayInfo::ManagedDisplayModeList display_modes; |
| 981 display_modes.push_back(make_scoped_refptr( | 984 display_modes.push_back(make_scoped_refptr( |
| 982 new ManagedDisplayMode(gfx::Size(1000, 500), 58.0f, false, true))); | 985 new ui::ManagedDisplayMode(gfx::Size(1000, 500), 58.0f, false, true))); |
| 983 display_modes.push_back(make_scoped_refptr( | 986 display_modes.push_back(make_scoped_refptr( |
| 984 new ManagedDisplayMode(gfx::Size(800, 300), 59.0f, false, false))); | 987 new ui::ManagedDisplayMode(gfx::Size(800, 300), 59.0f, false, false))); |
| 985 display_modes.push_back(make_scoped_refptr( | 988 display_modes.push_back(make_scoped_refptr( |
| 986 new ManagedDisplayMode(gfx::Size(400, 500), 60.0f, false, false))); | 989 new ui::ManagedDisplayMode(gfx::Size(400, 500), 60.0f, false, false))); |
| 987 | 990 |
| 988 DisplayInfo::ManagedDisplayModeList copy = display_modes; | 991 ui::ManagedDisplayInfo::ManagedDisplayModeList copy = display_modes; |
| 989 native_display_info.SetManagedDisplayModes(copy); | 992 native_display_info.SetManagedDisplayModes(copy); |
| 990 | 993 |
| 991 std::vector<DisplayInfo> display_info_list; | 994 std::vector<ui::ManagedDisplayInfo> display_info_list; |
| 992 display_info_list.push_back(native_display_info); | 995 display_info_list.push_back(native_display_info); |
| 993 display_manager()->OnNativeDisplaysChanged(display_info_list); | 996 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 994 { | 997 { |
| 995 test::SetDisplayResolution(display_id, gfx::Size(800, 300)); | 998 test::SetDisplayResolution(display_id, gfx::Size(800, 300)); |
| 996 DisplayInfo new_native_display_info = | 999 ui::ManagedDisplayInfo new_native_display_info = |
| 997 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 400, 500)); | 1000 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 400, 500)); |
| 998 copy = display_modes; | 1001 copy = display_modes; |
| 999 new_native_display_info.SetManagedDisplayModes(copy); | 1002 new_native_display_info.SetManagedDisplayModes(copy); |
| 1000 std::vector<DisplayInfo> new_display_info_list; | 1003 std::vector<ui::ManagedDisplayInfo> new_display_info_list; |
| 1001 new_display_info_list.push_back(new_native_display_info); | 1004 new_display_info_list.push_back(new_native_display_info); |
| 1002 display_manager()->OnNativeDisplaysChanged(new_display_info_list); | 1005 display_manager()->OnNativeDisplaysChanged(new_display_info_list); |
| 1003 | 1006 |
| 1004 scoped_refptr<ManagedDisplayMode> mode = | 1007 scoped_refptr<ui::ManagedDisplayMode> mode = |
| 1005 display_manager()->GetSelectedModeForDisplayId(display_id); | 1008 display_manager()->GetSelectedModeForDisplayId(display_id); |
| 1006 EXPECT_TRUE(!!mode); | 1009 EXPECT_TRUE(!!mode); |
| 1007 EXPECT_EQ("400x500", mode->size().ToString()); | 1010 EXPECT_EQ("400x500", mode->size().ToString()); |
| 1008 EXPECT_EQ(60.0f, mode->refresh_rate()); | 1011 EXPECT_EQ(60.0f, mode->refresh_rate()); |
| 1009 EXPECT_FALSE(mode->native()); | 1012 EXPECT_FALSE(mode->native()); |
| 1010 } | 1013 } |
| 1011 { | 1014 { |
| 1012 // Best resolution should find itself on the resolutions list. | 1015 // Best resolution should find itself on the resolutions list. |
| 1013 test::SetDisplayResolution(display_id, gfx::Size(800, 300)); | 1016 test::SetDisplayResolution(display_id, gfx::Size(800, 300)); |
| 1014 DisplayInfo new_native_display_info = | 1017 ui::ManagedDisplayInfo new_native_display_info = |
| 1015 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); | 1018 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); |
| 1016 DisplayInfo::ManagedDisplayModeList copy = display_modes; | 1019 ui::ManagedDisplayInfo::ManagedDisplayModeList copy = display_modes; |
| 1017 new_native_display_info.SetManagedDisplayModes(copy); | 1020 new_native_display_info.SetManagedDisplayModes(copy); |
| 1018 std::vector<DisplayInfo> new_display_info_list; | 1021 std::vector<ui::ManagedDisplayInfo> new_display_info_list; |
| 1019 new_display_info_list.push_back(new_native_display_info); | 1022 new_display_info_list.push_back(new_native_display_info); |
| 1020 display_manager()->OnNativeDisplaysChanged(new_display_info_list); | 1023 display_manager()->OnNativeDisplaysChanged(new_display_info_list); |
| 1021 | 1024 |
| 1022 scoped_refptr<ManagedDisplayMode> mode = | 1025 scoped_refptr<ui::ManagedDisplayMode> mode = |
| 1023 display_manager()->GetSelectedModeForDisplayId(display_id); | 1026 display_manager()->GetSelectedModeForDisplayId(display_id); |
| 1024 EXPECT_TRUE(!!mode); | 1027 EXPECT_TRUE(!!mode); |
| 1025 EXPECT_EQ("1000x500", mode->size().ToString()); | 1028 EXPECT_EQ("1000x500", mode->size().ToString()); |
| 1026 EXPECT_EQ(58.0f, mode->refresh_rate()); | 1029 EXPECT_EQ(58.0f, mode->refresh_rate()); |
| 1027 EXPECT_TRUE(mode->native()); | 1030 EXPECT_TRUE(mode->native()); |
| 1028 } | 1031 } |
| 1029 } | 1032 } |
| 1030 #endif // defined(OS_CHROMEOS) | 1033 #endif // defined(OS_CHROMEOS) |
| 1031 | 1034 |
| 1032 TEST_P(DisplayManagerTest, Rotate) { | 1035 TEST_P(DisplayManagerTest, Rotate) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 const int64_t internal_display_id = | 1086 const int64_t internal_display_id = |
| 1084 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); | 1087 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); |
| 1085 | 1088 |
| 1086 display_manager()->SetDisplayRotation(internal_display_id, | 1089 display_manager()->SetDisplayRotation(internal_display_id, |
| 1087 display::Display::ROTATE_90, | 1090 display::Display::ROTATE_90, |
| 1088 display::Display::ROTATION_SOURCE_USER); | 1091 display::Display::ROTATION_SOURCE_USER); |
| 1089 display_manager()->SetDisplayRotation( | 1092 display_manager()->SetDisplayRotation( |
| 1090 internal_display_id, display::Display::ROTATE_0, | 1093 internal_display_id, display::Display::ROTATE_0, |
| 1091 display::Display::ROTATION_SOURCE_ACTIVE); | 1094 display::Display::ROTATION_SOURCE_ACTIVE); |
| 1092 | 1095 |
| 1093 const DisplayInfo info = GetDisplayInfoForId(internal_display_id); | 1096 const ui::ManagedDisplayInfo info = GetDisplayInfoForId(internal_display_id); |
| 1094 EXPECT_EQ(display::Display::ROTATE_0, info.GetActiveRotation()); | 1097 EXPECT_EQ(display::Display::ROTATE_0, info.GetActiveRotation()); |
| 1095 | 1098 |
| 1096 // Deactivate internal display to simulate Docked Mode. | 1099 // Deactivate internal display to simulate Docked Mode. |
| 1097 vector<DisplayInfo> secondary_only; | 1100 vector<ui::ManagedDisplayInfo> secondary_only; |
| 1098 secondary_only.push_back(GetDisplayInfoAt(1)); | 1101 secondary_only.push_back(GetDisplayInfoAt(1)); |
| 1099 display_manager()->OnNativeDisplaysChanged(secondary_only); | 1102 display_manager()->OnNativeDisplaysChanged(secondary_only); |
| 1100 | 1103 |
| 1101 const DisplayInfo post_removal_info = | 1104 const ui::ManagedDisplayInfo post_removal_info = |
| 1102 display_manager()->display_info_[internal_display_id]; | 1105 display_manager()->display_info_[internal_display_id]; |
| 1103 EXPECT_NE(info.GetActiveRotation(), post_removal_info.GetActiveRotation()); | 1106 EXPECT_NE(info.GetActiveRotation(), post_removal_info.GetActiveRotation()); |
| 1104 EXPECT_EQ(display::Display::ROTATE_90, post_removal_info.GetActiveRotation()); | 1107 EXPECT_EQ(display::Display::ROTATE_90, post_removal_info.GetActiveRotation()); |
| 1105 | 1108 |
| 1106 display_manager()->SetDisplayRotation( | 1109 display_manager()->SetDisplayRotation( |
| 1107 internal_display_id, display::Display::ROTATE_180, | 1110 internal_display_id, display::Display::ROTATE_180, |
| 1108 display::Display::ROTATION_SOURCE_ACTIVE); | 1111 display::Display::ROTATION_SOURCE_ACTIVE); |
| 1109 const DisplayInfo post_rotation_info = | 1112 const ui::ManagedDisplayInfo post_rotation_info = |
| 1110 display_manager()->display_info_[internal_display_id]; | 1113 display_manager()->display_info_[internal_display_id]; |
| 1111 EXPECT_NE(info.GetActiveRotation(), post_rotation_info.GetActiveRotation()); | 1114 EXPECT_NE(info.GetActiveRotation(), post_rotation_info.GetActiveRotation()); |
| 1112 EXPECT_EQ(display::Display::ROTATE_180, | 1115 EXPECT_EQ(display::Display::ROTATE_180, |
| 1113 post_rotation_info.GetActiveRotation()); | 1116 post_rotation_info.GetActiveRotation()); |
| 1114 } | 1117 } |
| 1115 | 1118 |
| 1116 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 1119 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
| 1117 #if defined(OS_CHROMEOS) | 1120 #if defined(OS_CHROMEOS) |
| 1118 TEST_P(DisplayManagerTest, UIScale) { | 1121 TEST_P(DisplayManagerTest, UIScale) { |
| 1119 test::ScopedDisable125DSFForUIScaling disable; | 1122 test::ScopedDisable125DSFForUIScaling disable; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 display = display::Screen::GetScreen()->GetPrimaryDisplay(); | 1210 display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 1208 EXPECT_EQ(1.0f, display.device_scale_factor()); | 1211 EXPECT_EQ(1.0f, display.device_scale_factor()); |
| 1209 EXPECT_EQ("1280x850", display.bounds().size().ToString()); | 1212 EXPECT_EQ("1280x850", display.bounds().size().ToString()); |
| 1210 } | 1213 } |
| 1211 #endif // defined(OS_CHROMEOS) | 1214 #endif // defined(OS_CHROMEOS) |
| 1212 | 1215 |
| 1213 TEST_P(DisplayManagerTest, UIScaleWithDisplayMode) { | 1216 TEST_P(DisplayManagerTest, UIScaleWithDisplayMode) { |
| 1214 int display_id = 1000; | 1217 int display_id = 1000; |
| 1215 | 1218 |
| 1216 // Setup the display modes with UI-scale. | 1219 // Setup the display modes with UI-scale. |
| 1217 DisplayInfo native_display_info = | 1220 ui::ManagedDisplayInfo native_display_info = |
| 1218 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1280, 800)); | 1221 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1280, 800)); |
| 1219 const scoped_refptr<ManagedDisplayMode>& base_mode( | 1222 const scoped_refptr<ui::ManagedDisplayMode>& base_mode( |
| 1220 new ManagedDisplayMode(gfx::Size(1280, 800), 60.0f, false, false)); | 1223 new ui::ManagedDisplayMode(gfx::Size(1280, 800), 60.0f, false, false)); |
| 1221 DisplayInfo::ManagedDisplayModeList mode_list = | 1224 ui::ManagedDisplayInfo::ManagedDisplayModeList mode_list = |
| 1222 CreateInternalManagedDisplayModeList(base_mode); | 1225 CreateInternalManagedDisplayModeList(base_mode); |
| 1223 native_display_info.SetManagedDisplayModes(mode_list); | 1226 native_display_info.SetManagedDisplayModes(mode_list); |
| 1224 | 1227 |
| 1225 std::vector<DisplayInfo> display_info_list; | 1228 std::vector<ui::ManagedDisplayInfo> display_info_list; |
| 1226 display_info_list.push_back(native_display_info); | 1229 display_info_list.push_back(native_display_info); |
| 1227 display_manager()->OnNativeDisplaysChanged(display_info_list); | 1230 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 1228 | 1231 |
| 1229 scoped_refptr<ManagedDisplayMode> expected_mode = base_mode; | 1232 scoped_refptr<ui::ManagedDisplayMode> expected_mode = base_mode; |
| 1230 EXPECT_TRUE(expected_mode->IsEquivalent( | 1233 EXPECT_TRUE(expected_mode->IsEquivalent( |
| 1231 display_manager()->GetActiveModeForDisplayId(display_id))); | 1234 display_manager()->GetActiveModeForDisplayId(display_id))); |
| 1232 | 1235 |
| 1233 test::ScopedSetInternalDisplayId set_internal(display_id); | 1236 test::ScopedSetInternalDisplayId set_internal(display_id); |
| 1234 | 1237 |
| 1235 SetDisplayUIScale(display_id, 1.5f); | 1238 SetDisplayUIScale(display_id, 1.5f); |
| 1236 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); | 1239 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); |
| 1237 EXPECT_TRUE(expected_mode->IsEquivalent( | 1240 EXPECT_TRUE(expected_mode->IsEquivalent( |
| 1238 display_manager()->GetActiveModeForDisplayId(display_id))); | 1241 display_manager()->GetActiveModeForDisplayId(display_id))); |
| 1239 SetDisplayUIScale(display_id, 1.25f); | 1242 SetDisplayUIScale(display_id, 1.25f); |
| 1240 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); | 1243 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); |
| 1241 EXPECT_TRUE(expected_mode->IsEquivalent( | 1244 EXPECT_TRUE(expected_mode->IsEquivalent( |
| 1242 display_manager()->GetActiveModeForDisplayId(display_id))); | 1245 display_manager()->GetActiveModeForDisplayId(display_id))); |
| 1243 SetDisplayUIScale(display_id, 1.125f); | 1246 SetDisplayUIScale(display_id, 1.125f); |
| 1244 EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale()); | 1247 EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale()); |
| 1245 | 1248 |
| 1246 expected_mode = new ManagedDisplayMode( | 1249 expected_mode = new ui::ManagedDisplayMode( |
| 1247 expected_mode->size(), expected_mode->refresh_rate(), | 1250 expected_mode->size(), expected_mode->refresh_rate(), |
| 1248 expected_mode->is_interlaced(), expected_mode->native(), | 1251 expected_mode->is_interlaced(), expected_mode->native(), |
| 1249 1.125f /* ui_scale */, expected_mode->device_scale_factor()); | 1252 1.125f /* ui_scale */, expected_mode->device_scale_factor()); |
| 1250 | 1253 |
| 1251 EXPECT_TRUE(expected_mode->IsEquivalent( | 1254 EXPECT_TRUE(expected_mode->IsEquivalent( |
| 1252 display_manager()->GetActiveModeForDisplayId(display_id))); | 1255 display_manager()->GetActiveModeForDisplayId(display_id))); |
| 1253 SetDisplayUIScale(display_id, 0.8f); | 1256 SetDisplayUIScale(display_id, 0.8f); |
| 1254 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale()); | 1257 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale()); |
| 1255 | 1258 |
| 1256 expected_mode = new ManagedDisplayMode( | 1259 expected_mode = new ui::ManagedDisplayMode( |
| 1257 expected_mode->size(), expected_mode->refresh_rate(), | 1260 expected_mode->size(), expected_mode->refresh_rate(), |
| 1258 expected_mode->is_interlaced(), expected_mode->native(), | 1261 expected_mode->is_interlaced(), expected_mode->native(), |
| 1259 0.8f /* ui_scale */, expected_mode->device_scale_factor()); | 1262 0.8f /* ui_scale */, expected_mode->device_scale_factor()); |
| 1260 | 1263 |
| 1261 EXPECT_TRUE(expected_mode->IsEquivalent( | 1264 EXPECT_TRUE(expected_mode->IsEquivalent( |
| 1262 display_manager()->GetActiveModeForDisplayId(display_id))); | 1265 display_manager()->GetActiveModeForDisplayId(display_id))); |
| 1263 SetDisplayUIScale(display_id, 0.75f); | 1266 SetDisplayUIScale(display_id, 0.75f); |
| 1264 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale()); | 1267 EXPECT_EQ(0.8f, GetDisplayInfoAt(0).configured_ui_scale()); |
| 1265 EXPECT_TRUE(expected_mode->IsEquivalent( | 1268 EXPECT_TRUE(expected_mode->IsEquivalent( |
| 1266 display_manager()->GetActiveModeForDisplayId(display_id))); | 1269 display_manager()->GetActiveModeForDisplayId(display_id))); |
| 1267 SetDisplayUIScale(display_id, 0.625f); | 1270 SetDisplayUIScale(display_id, 0.625f); |
| 1268 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); | 1271 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); |
| 1269 | 1272 |
| 1270 expected_mode = new ManagedDisplayMode( | 1273 expected_mode = new ui::ManagedDisplayMode( |
| 1271 expected_mode->size(), expected_mode->refresh_rate(), | 1274 expected_mode->size(), expected_mode->refresh_rate(), |
| 1272 expected_mode->is_interlaced(), expected_mode->native(), | 1275 expected_mode->is_interlaced(), expected_mode->native(), |
| 1273 0.625f /* ui_scale */, expected_mode->device_scale_factor()); | 1276 0.625f /* ui_scale */, expected_mode->device_scale_factor()); |
| 1274 | 1277 |
| 1275 EXPECT_TRUE(expected_mode->IsEquivalent( | 1278 EXPECT_TRUE(expected_mode->IsEquivalent( |
| 1276 display_manager()->GetActiveModeForDisplayId(display_id))); | 1279 display_manager()->GetActiveModeForDisplayId(display_id))); |
| 1277 SetDisplayUIScale(display_id, 0.6f); | 1280 SetDisplayUIScale(display_id, 0.6f); |
| 1278 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); | 1281 EXPECT_EQ(0.625f, GetDisplayInfoAt(0).configured_ui_scale()); |
| 1279 EXPECT_TRUE(expected_mode->IsEquivalent( | 1282 EXPECT_TRUE(expected_mode->IsEquivalent( |
| 1280 display_manager()->GetActiveModeForDisplayId(display_id))); | 1283 display_manager()->GetActiveModeForDisplayId(display_id))); |
| 1281 SetDisplayUIScale(display_id, 0.5f); | 1284 SetDisplayUIScale(display_id, 0.5f); |
| 1282 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale()); | 1285 EXPECT_EQ(0.5f, GetDisplayInfoAt(0).configured_ui_scale()); |
| 1283 | 1286 |
| 1284 expected_mode = new ManagedDisplayMode( | 1287 expected_mode = new ui::ManagedDisplayMode( |
| 1285 expected_mode->size(), expected_mode->refresh_rate(), | 1288 expected_mode->size(), expected_mode->refresh_rate(), |
| 1286 expected_mode->is_interlaced(), expected_mode->native(), | 1289 expected_mode->is_interlaced(), expected_mode->native(), |
| 1287 0.5f /* ui_scale */, expected_mode->device_scale_factor()); | 1290 0.5f /* ui_scale */, expected_mode->device_scale_factor()); |
| 1288 | 1291 |
| 1289 EXPECT_TRUE(expected_mode->IsEquivalent( | 1292 EXPECT_TRUE(expected_mode->IsEquivalent( |
| 1290 display_manager()->GetActiveModeForDisplayId(display_id))); | 1293 display_manager()->GetActiveModeForDisplayId(display_id))); |
| 1291 } | 1294 } |
| 1292 | 1295 |
| 1293 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 1296 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
| 1294 #if defined(OS_CHROMEOS) | 1297 #if defined(OS_CHROMEOS) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1319 | 1322 |
| 1320 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 1323 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
| 1321 #if defined(OS_CHROMEOS) | 1324 #if defined(OS_CHROMEOS) |
| 1322 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScaling) { | 1325 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScaling) { |
| 1323 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 1326 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 1324 | 1327 |
| 1325 display_id++; | 1328 display_id++; |
| 1326 test::ScopedSetInternalDisplayId set_internal(display_id); | 1329 test::ScopedSetInternalDisplayId set_internal(display_id); |
| 1327 | 1330 |
| 1328 // Setup the display modes with UI-scale. | 1331 // Setup the display modes with UI-scale. |
| 1329 DisplayInfo native_display_info = | 1332 ui::ManagedDisplayInfo native_display_info = |
| 1330 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080)); | 1333 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080)); |
| 1331 native_display_info.set_device_scale_factor(1.25); | 1334 native_display_info.set_device_scale_factor(1.25); |
| 1332 | 1335 |
| 1333 const scoped_refptr<ManagedDisplayMode>& base_mode( | 1336 const scoped_refptr<ui::ManagedDisplayMode>& base_mode( |
| 1334 new ManagedDisplayMode(gfx::Size(1920, 1080), 60.0f, false, false)); | 1337 new ui::ManagedDisplayMode(gfx::Size(1920, 1080), 60.0f, false, false)); |
| 1335 DisplayInfo::ManagedDisplayModeList mode_list = | 1338 ui::ManagedDisplayInfo::ManagedDisplayModeList mode_list = |
| 1336 CreateInternalManagedDisplayModeList(base_mode); | 1339 CreateInternalManagedDisplayModeList(base_mode); |
| 1337 native_display_info.SetManagedDisplayModes(mode_list); | 1340 native_display_info.SetManagedDisplayModes(mode_list); |
| 1338 | 1341 |
| 1339 std::vector<DisplayInfo> display_info_list; | 1342 std::vector<ui::ManagedDisplayInfo> display_info_list; |
| 1340 display_info_list.push_back(native_display_info); | 1343 display_info_list.push_back(native_display_info); |
| 1341 | 1344 |
| 1342 display_manager()->OnNativeDisplaysChanged(display_info_list); | 1345 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 1343 | 1346 |
| 1344 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); | 1347 EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); |
| 1345 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); | 1348 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); |
| 1346 } | 1349 } |
| 1347 #endif // defined(OS_CHROMEOS) | 1350 #endif // defined(OS_CHROMEOS) |
| 1348 | 1351 |
| 1349 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 1352 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
| 1350 #if defined(OS_CHROMEOS) | 1353 #if defined(OS_CHROMEOS) |
| 1351 // Don't default to 1.25 DSF if the user already has a prefrence stored for | 1354 // Don't default to 1.25 DSF if the user already has a prefrence stored for |
| 1352 // the internal display. | 1355 // the internal display. |
| 1353 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScalingNoOverride) { | 1356 TEST_P(DisplayManagerTest, FHD125DefaultsTo08UIScalingNoOverride) { |
| 1354 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 1357 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 1355 | 1358 |
| 1356 display_id++; | 1359 display_id++; |
| 1357 test::ScopedSetInternalDisplayId set_internal(display_id); | 1360 test::ScopedSetInternalDisplayId set_internal(display_id); |
| 1358 const gfx::Insets dummy_overscan_insets; | 1361 const gfx::Insets dummy_overscan_insets; |
| 1359 display_manager()->RegisterDisplayProperty( | 1362 display_manager()->RegisterDisplayProperty( |
| 1360 display_id, display::Display::ROTATE_0, 1.0f, &dummy_overscan_insets, | 1363 display_id, display::Display::ROTATE_0, 1.0f, &dummy_overscan_insets, |
| 1361 gfx::Size(), 1.0f, ui::ColorCalibrationProfile()); | 1364 gfx::Size(), 1.0f, ui::ColorCalibrationProfile()); |
| 1362 | 1365 |
| 1363 // Setup the display modes with UI-scale. | 1366 // Setup the display modes with UI-scale. |
| 1364 DisplayInfo native_display_info = | 1367 ui::ManagedDisplayInfo native_display_info = |
| 1365 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080)); | 1368 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1920, 1080)); |
| 1366 native_display_info.set_device_scale_factor(1.25); | 1369 native_display_info.set_device_scale_factor(1.25); |
| 1367 | 1370 |
| 1368 const scoped_refptr<ManagedDisplayMode>& base_mode( | 1371 const scoped_refptr<ui::ManagedDisplayMode>& base_mode( |
| 1369 new ManagedDisplayMode(gfx::Size(1920, 1080), 60.0f, false, false)); | 1372 new ui::ManagedDisplayMode(gfx::Size(1920, 1080), 60.0f, false, false)); |
| 1370 DisplayInfo::ManagedDisplayModeList mode_list = | 1373 ui::ManagedDisplayInfo::ManagedDisplayModeList mode_list = |
| 1371 CreateInternalManagedDisplayModeList(base_mode); | 1374 CreateInternalManagedDisplayModeList(base_mode); |
| 1372 native_display_info.SetManagedDisplayModes(mode_list); | 1375 native_display_info.SetManagedDisplayModes(mode_list); |
| 1373 | 1376 |
| 1374 std::vector<DisplayInfo> display_info_list; | 1377 std::vector<ui::ManagedDisplayInfo> display_info_list; |
| 1375 display_info_list.push_back(native_display_info); | 1378 display_info_list.push_back(native_display_info); |
| 1376 | 1379 |
| 1377 display_manager()->OnNativeDisplaysChanged(display_info_list); | 1380 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 1378 | 1381 |
| 1379 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); | 1382 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor()); |
| 1380 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); | 1383 EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); |
| 1381 } | 1384 } |
| 1382 #endif // defined(OS_CHROMEOS) | 1385 #endif // defined(OS_CHROMEOS) |
| 1383 | 1386 |
| 1384 TEST_P(DisplayManagerTest, ResolutionChangeInUnifiedMode) { | 1387 TEST_P(DisplayManagerTest, ResolutionChangeInUnifiedMode) { |
| 1385 if (!SupportsMultipleDisplays()) | 1388 if (!SupportsMultipleDisplays()) |
| 1386 return; | 1389 return; |
| 1387 // Don't check root window destruction in unified mode. | 1390 // Don't check root window destruction in unified mode. |
| 1388 Shell::GetPrimaryRootWindow()->RemoveObserver(this); | 1391 Shell::GetPrimaryRootWindow()->RemoveObserver(this); |
| 1389 | 1392 |
| 1390 display_manager()->SetUnifiedDesktopEnabled(true); | 1393 display_manager()->SetUnifiedDesktopEnabled(true); |
| 1391 | 1394 |
| 1392 UpdateDisplay("200x200, 400x400"); | 1395 UpdateDisplay("200x200, 400x400"); |
| 1393 | 1396 |
| 1394 int64_t unified_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 1397 int64_t unified_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 1395 DisplayInfo info = display_manager()->GetDisplayInfo(unified_id); | 1398 ui::ManagedDisplayInfo info = display_manager()->GetDisplayInfo(unified_id); |
| 1396 ASSERT_EQ(2u, info.display_modes().size()); | 1399 ASSERT_EQ(2u, info.display_modes().size()); |
| 1397 EXPECT_EQ("400x200", info.display_modes()[0]->size().ToString()); | 1400 EXPECT_EQ("400x200", info.display_modes()[0]->size().ToString()); |
| 1398 EXPECT_TRUE(info.display_modes()[0]->native()); | 1401 EXPECT_TRUE(info.display_modes()[0]->native()); |
| 1399 EXPECT_EQ("800x400", info.display_modes()[1]->size().ToString()); | 1402 EXPECT_EQ("800x400", info.display_modes()[1]->size().ToString()); |
| 1400 EXPECT_FALSE(info.display_modes()[1]->native()); | 1403 EXPECT_FALSE(info.display_modes()[1]->native()); |
| 1401 EXPECT_EQ( | 1404 EXPECT_EQ( |
| 1402 "400x200", | 1405 "400x200", |
| 1403 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); | 1406 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); |
| 1404 scoped_refptr<ManagedDisplayMode> active_mode = | 1407 scoped_refptr<ui::ManagedDisplayMode> active_mode = |
| 1405 display_manager()->GetActiveModeForDisplayId(unified_id); | 1408 display_manager()->GetActiveModeForDisplayId(unified_id); |
| 1406 EXPECT_EQ(1.0f, active_mode->ui_scale()); | 1409 EXPECT_EQ(1.0f, active_mode->ui_scale()); |
| 1407 EXPECT_EQ("400x200", active_mode->size().ToString()); | 1410 EXPECT_EQ("400x200", active_mode->size().ToString()); |
| 1408 | 1411 |
| 1409 EXPECT_TRUE(test::SetDisplayResolution(unified_id, gfx::Size(800, 400))); | 1412 EXPECT_TRUE(test::SetDisplayResolution(unified_id, gfx::Size(800, 400))); |
| 1410 EXPECT_EQ( | 1413 EXPECT_EQ( |
| 1411 "800x400", | 1414 "800x400", |
| 1412 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); | 1415 display::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); |
| 1413 | 1416 |
| 1414 active_mode = display_manager()->GetActiveModeForDisplayId(unified_id); | 1417 active_mode = display_manager()->GetActiveModeForDisplayId(unified_id); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1622 TEST_P(DisplayManagerTest, SoftwareMirroringWithCompositingCursor) { | 1625 TEST_P(DisplayManagerTest, SoftwareMirroringWithCompositingCursor) { |
| 1623 if (!SupportsMultipleDisplays()) | 1626 if (!SupportsMultipleDisplays()) |
| 1624 return; | 1627 return; |
| 1625 | 1628 |
| 1626 UpdateDisplay("300x400,400x500"); | 1629 UpdateDisplay("300x400,400x500"); |
| 1627 | 1630 |
| 1628 test::MirrorWindowTestApi test_api; | 1631 test::MirrorWindowTestApi test_api; |
| 1629 EXPECT_EQ(nullptr, test_api.GetHost()); | 1632 EXPECT_EQ(nullptr, test_api.GetHost()); |
| 1630 | 1633 |
| 1631 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 1634 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 1632 DisplayInfo secondary_info = | 1635 ui::ManagedDisplayInfo secondary_info = |
| 1633 display_manager->GetDisplayInfo(ScreenUtil::GetSecondaryDisplay().id()); | 1636 display_manager->GetDisplayInfo(ScreenUtil::GetSecondaryDisplay().id()); |
| 1634 | 1637 |
| 1635 display_manager->SetSoftwareMirroring(true); | 1638 display_manager->SetSoftwareMirroring(true); |
| 1636 display_manager->UpdateDisplays(); | 1639 display_manager->UpdateDisplays(); |
| 1637 | 1640 |
| 1638 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1641 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1639 EXPECT_FALSE(root_windows[0]->Contains(test_api.GetCursorWindow())); | 1642 EXPECT_FALSE(root_windows[0]->Contains(test_api.GetCursorWindow())); |
| 1640 | 1643 |
| 1641 Shell::GetInstance()->SetCursorCompositingEnabled(true); | 1644 Shell::GetInstance()->SetCursorCompositingEnabled(true); |
| 1642 | 1645 |
| 1643 EXPECT_TRUE(root_windows[0]->Contains(test_api.GetCursorWindow())); | 1646 EXPECT_TRUE(root_windows[0]->Contains(test_api.GetCursorWindow())); |
| 1644 | 1647 |
| 1645 // Removes the first display and keeps the second one. | 1648 // Removes the first display and keeps the second one. |
| 1646 display_manager->SetSoftwareMirroring(false); | 1649 display_manager->SetSoftwareMirroring(false); |
| 1647 std::vector<DisplayInfo> new_info_list; | 1650 std::vector<ui::ManagedDisplayInfo> new_info_list; |
| 1648 new_info_list.push_back(secondary_info); | 1651 new_info_list.push_back(secondary_info); |
| 1649 display_manager->OnNativeDisplaysChanged(new_info_list); | 1652 display_manager->OnNativeDisplaysChanged(new_info_list); |
| 1650 | 1653 |
| 1651 root_windows = Shell::GetAllRootWindows(); | 1654 root_windows = Shell::GetAllRootWindows(); |
| 1652 EXPECT_TRUE(root_windows[0]->Contains(test_api.GetCursorWindow())); | 1655 EXPECT_TRUE(root_windows[0]->Contains(test_api.GetCursorWindow())); |
| 1653 | 1656 |
| 1654 Shell::GetInstance()->SetCursorCompositingEnabled(false); | 1657 Shell::GetInstance()->SetCursorCompositingEnabled(false); |
| 1655 } | 1658 } |
| 1656 #endif // OS_CHROMEOS | 1659 #endif // OS_CHROMEOS |
| 1657 | 1660 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1753 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); | 1756 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); |
| 1754 EXPECT_TRUE(changed_metrics() & | 1757 EXPECT_TRUE(changed_metrics() & |
| 1755 display::DisplayObserver::DISPLAY_METRIC_PRIMARY); | 1758 display::DisplayObserver::DISPLAY_METRIC_PRIMARY); |
| 1756 } | 1759 } |
| 1757 | 1760 |
| 1758 TEST_P(DisplayManagerTest, NotifyPrimaryChangeUndock) { | 1761 TEST_P(DisplayManagerTest, NotifyPrimaryChangeUndock) { |
| 1759 if (!SupportsMultipleDisplays()) | 1762 if (!SupportsMultipleDisplays()) |
| 1760 return; | 1763 return; |
| 1761 // Assume the default display is an external display, and | 1764 // Assume the default display is an external display, and |
| 1762 // emulates undocking by switching to another display. | 1765 // emulates undocking by switching to another display. |
| 1763 DisplayInfo another_display_info = | 1766 ui::ManagedDisplayInfo another_display_info = |
| 1764 CreateDisplayInfo(1, gfx::Rect(0, 0, 1280, 800)); | 1767 CreateDisplayInfo(1, gfx::Rect(0, 0, 1280, 800)); |
| 1765 std::vector<DisplayInfo> info_list; | 1768 std::vector<ui::ManagedDisplayInfo> info_list; |
| 1766 info_list.push_back(another_display_info); | 1769 info_list.push_back(another_display_info); |
| 1767 reset(); | 1770 reset(); |
| 1768 display_manager()->OnNativeDisplaysChanged(info_list); | 1771 display_manager()->OnNativeDisplaysChanged(info_list); |
| 1769 EXPECT_TRUE(changed_metrics() & | 1772 EXPECT_TRUE(changed_metrics() & |
| 1770 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); | 1773 display::DisplayObserver::DISPLAY_METRIC_BOUNDS); |
| 1771 EXPECT_TRUE(changed_metrics() & | 1774 EXPECT_TRUE(changed_metrics() & |
| 1772 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); | 1775 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); |
| 1773 EXPECT_TRUE(changed_metrics() & | 1776 EXPECT_TRUE(changed_metrics() & |
| 1774 display::DisplayObserver::DISPLAY_METRIC_PRIMARY); | 1777 display::DisplayObserver::DISPLAY_METRIC_PRIMARY); |
| 1775 } | 1778 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1842 // Switch to single desktop. | 1845 // Switch to single desktop. |
| 1843 UpdateDisplay("500x300"); | 1846 UpdateDisplay("500x300"); |
| 1844 EXPECT_EQ(gfx::Size(500, 300), screen->GetPrimaryDisplay().size()); | 1847 EXPECT_EQ(gfx::Size(500, 300), screen->GetPrimaryDisplay().size()); |
| 1845 | 1848 |
| 1846 // Switch to unified desktop. | 1849 // Switch to unified desktop. |
| 1847 UpdateDisplay("500x300,400x500"); | 1850 UpdateDisplay("500x300,400x500"); |
| 1848 // 400 * 300 / 500 + 500 ~= 739. | 1851 // 400 * 300 / 500 + 500 ~= 739. |
| 1849 EXPECT_EQ(gfx::Size(739, 300), screen->GetPrimaryDisplay().size()); | 1852 EXPECT_EQ(gfx::Size(739, 300), screen->GetPrimaryDisplay().size()); |
| 1850 | 1853 |
| 1851 // The default should fit to the internal display. | 1854 // The default should fit to the internal display. |
| 1852 std::vector<DisplayInfo> display_info_list; | 1855 std::vector<ui::ManagedDisplayInfo> display_info_list; |
| 1853 display_info_list.push_back(CreateDisplayInfo(10, gfx::Rect(0, 0, 500, 300))); | 1856 display_info_list.push_back(CreateDisplayInfo(10, gfx::Rect(0, 0, 500, 300))); |
| 1854 display_info_list.push_back( | 1857 display_info_list.push_back( |
| 1855 CreateDisplayInfo(11, gfx::Rect(500, 0, 400, 500))); | 1858 CreateDisplayInfo(11, gfx::Rect(500, 0, 400, 500))); |
| 1856 { | 1859 { |
| 1857 test::ScopedSetInternalDisplayId set_internal(11); | 1860 test::ScopedSetInternalDisplayId set_internal(11); |
| 1858 display_manager()->OnNativeDisplaysChanged(display_info_list); | 1861 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 1859 // 500 * 500 / 300 + 400 ~= 1233. | 1862 // 500 * 500 / 300 + 400 ~= 1233. |
| 1860 EXPECT_EQ(gfx::Size(1233, 500), screen->GetPrimaryDisplay().size()); | 1863 EXPECT_EQ(gfx::Size(1233, 500), screen->GetPrimaryDisplay().size()); |
| 1861 } | 1864 } |
| 1862 | 1865 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1874 .size()); | 1877 .size()); |
| 1875 } | 1878 } |
| 1876 | 1879 |
| 1877 TEST_P(DisplayManagerTest, UnifiedDesktopWithHardwareMirroring) { | 1880 TEST_P(DisplayManagerTest, UnifiedDesktopWithHardwareMirroring) { |
| 1878 if (!SupportsMultipleDisplays()) | 1881 if (!SupportsMultipleDisplays()) |
| 1879 return; | 1882 return; |
| 1880 // Don't check root window destruction in unified mode. | 1883 // Don't check root window destruction in unified mode. |
| 1881 Shell::GetPrimaryRootWindow()->RemoveObserver(this); | 1884 Shell::GetPrimaryRootWindow()->RemoveObserver(this); |
| 1882 | 1885 |
| 1883 // Enter to hardware mirroring. | 1886 // Enter to hardware mirroring. |
| 1884 DisplayInfo d1(1, "", false); | 1887 ui::ManagedDisplayInfo d1(1, "", false); |
| 1885 d1.SetBounds(gfx::Rect(0, 0, 500, 500)); | 1888 d1.SetBounds(gfx::Rect(0, 0, 500, 500)); |
| 1886 DisplayInfo d2(2, "", false); | 1889 ui::ManagedDisplayInfo d2(2, "", false); |
| 1887 d2.SetBounds(gfx::Rect(0, 0, 500, 500)); | 1890 d2.SetBounds(gfx::Rect(0, 0, 500, 500)); |
| 1888 std::vector<DisplayInfo> display_info_list; | 1891 std::vector<ui::ManagedDisplayInfo> display_info_list; |
| 1889 display_info_list.push_back(d1); | 1892 display_info_list.push_back(d1); |
| 1890 display_info_list.push_back(d2); | 1893 display_info_list.push_back(d2); |
| 1891 display_manager()->OnNativeDisplaysChanged(display_info_list); | 1894 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 1892 ASSERT_TRUE(display_manager()->IsInMirrorMode()); | 1895 ASSERT_TRUE(display_manager()->IsInMirrorMode()); |
| 1893 display_manager()->SetUnifiedDesktopEnabled(true); | 1896 display_manager()->SetUnifiedDesktopEnabled(true); |
| 1894 EXPECT_TRUE(display_manager()->IsInMirrorMode()); | 1897 EXPECT_TRUE(display_manager()->IsInMirrorMode()); |
| 1895 | 1898 |
| 1896 // The display manager automaticaclly switches to software mirroring | 1899 // The display manager automaticaclly switches to software mirroring |
| 1897 // if the displays are configured to use mirroring when running on desktop. | 1900 // if the displays are configured to use mirroring when running on desktop. |
| 1898 // This is a workdaround to force the display manager to forget | 1901 // This is a workdaround to force the display manager to forget |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1935 if (!SupportsMultipleDisplays()) | 1938 if (!SupportsMultipleDisplays()) |
| 1936 return; | 1939 return; |
| 1937 // Don't check root window destruction in unified mode. | 1940 // Don't check root window destruction in unified mode. |
| 1938 Shell::GetPrimaryRootWindow()->RemoveObserver(this); | 1941 Shell::GetPrimaryRootWindow()->RemoveObserver(this); |
| 1939 | 1942 |
| 1940 display_manager()->SetUnifiedDesktopEnabled(true); | 1943 display_manager()->SetUnifiedDesktopEnabled(true); |
| 1941 display::Screen* screen = display::Screen::GetScreen(); | 1944 display::Screen* screen = display::Screen::GetScreen(); |
| 1942 | 1945 |
| 1943 // 2nd display is 2x. | 1946 // 2nd display is 2x. |
| 1944 UpdateDisplay("400x500,1000x800*2"); | 1947 UpdateDisplay("400x500,1000x800*2"); |
| 1945 DisplayInfo info = | 1948 ui::ManagedDisplayInfo info = |
| 1946 display_manager()->GetDisplayInfo(screen->GetPrimaryDisplay().id()); | 1949 display_manager()->GetDisplayInfo(screen->GetPrimaryDisplay().id()); |
| 1947 EXPECT_EQ(2u, info.display_modes().size()); | 1950 EXPECT_EQ(2u, info.display_modes().size()); |
| 1948 EXPECT_EQ("1640x800", info.display_modes()[0]->size().ToString()); | 1951 EXPECT_EQ("1640x800", info.display_modes()[0]->size().ToString()); |
| 1949 EXPECT_EQ(2.0f, info.display_modes()[0]->device_scale_factor()); | 1952 EXPECT_EQ(2.0f, info.display_modes()[0]->device_scale_factor()); |
| 1950 EXPECT_EQ("1025x500", info.display_modes()[1]->size().ToString()); | 1953 EXPECT_EQ("1025x500", info.display_modes()[1]->size().ToString()); |
| 1951 EXPECT_EQ(1.0f, info.display_modes()[1]->device_scale_factor()); | 1954 EXPECT_EQ(1.0f, info.display_modes()[1]->device_scale_factor()); |
| 1952 | 1955 |
| 1953 // For 1x, 400 + 500 / 800 * 100 = 1025. | 1956 // For 1x, 400 + 500 / 800 * 100 = 1025. |
| 1954 EXPECT_EQ("1025x500", screen->GetPrimaryDisplay().size().ToString()); | 1957 EXPECT_EQ("1025x500", screen->GetPrimaryDisplay().size().ToString()); |
| 1955 EXPECT_EQ("1025x500", | 1958 EXPECT_EQ("1025x500", |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2102 EXPECT_EQ(gfx::Rect(0, 0, 250, 253 + height_offset).ToString(), | 2105 EXPECT_EQ(gfx::Rect(0, 0, 250, 253 + height_offset).ToString(), |
| 2103 docked->bounds().ToString()); | 2106 docked->bounds().ToString()); |
| 2104 } | 2107 } |
| 2105 | 2108 |
| 2106 TEST_P(DisplayManagerTest, DockMode) { | 2109 TEST_P(DisplayManagerTest, DockMode) { |
| 2107 if (!SupportsMultipleDisplays()) | 2110 if (!SupportsMultipleDisplays()) |
| 2108 return; | 2111 return; |
| 2109 const int64_t internal_id = 1; | 2112 const int64_t internal_id = 1; |
| 2110 const int64_t external_id = 2; | 2113 const int64_t external_id = 2; |
| 2111 | 2114 |
| 2112 const DisplayInfo internal_display_info = | 2115 const ui::ManagedDisplayInfo internal_display_info = |
| 2113 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500)); | 2116 CreateDisplayInfo(internal_id, gfx::Rect(0, 0, 500, 500)); |
| 2114 const DisplayInfo external_display_info = | 2117 const ui::ManagedDisplayInfo external_display_info = |
| 2115 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); | 2118 CreateDisplayInfo(external_id, gfx::Rect(1, 1, 100, 100)); |
| 2116 std::vector<DisplayInfo> display_info_list; | 2119 std::vector<ui::ManagedDisplayInfo> display_info_list; |
| 2117 | 2120 |
| 2118 // software mirroring. | 2121 // software mirroring. |
| 2119 display_info_list.push_back(internal_display_info); | 2122 display_info_list.push_back(internal_display_info); |
| 2120 display_info_list.push_back(external_display_info); | 2123 display_info_list.push_back(external_display_info); |
| 2121 display_manager()->OnNativeDisplaysChanged(display_info_list); | 2124 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 2122 const int64_t internal_display_id = | 2125 const int64_t internal_display_id = |
| 2123 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); | 2126 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); |
| 2124 EXPECT_EQ(internal_id, internal_display_id); | 2127 EXPECT_EQ(internal_id, internal_display_id); |
| 2125 | 2128 |
| 2126 display_info_list.clear(); | 2129 display_info_list.clear(); |
| 2127 display_info_list.push_back(external_display_info); | 2130 display_info_list.push_back(external_display_info); |
| 2128 display_manager()->OnNativeDisplaysChanged(display_info_list); | 2131 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 2129 EXPECT_EQ(1U, display_manager()->active_display_list().size()); | 2132 EXPECT_EQ(1U, display_manager()->active_display_list().size()); |
| 2130 | 2133 |
| 2131 EXPECT_TRUE(display_manager()->IsActiveDisplayId(external_id)); | 2134 EXPECT_TRUE(display_manager()->IsActiveDisplayId(external_id)); |
| 2132 EXPECT_FALSE(display_manager()->IsActiveDisplayId(internal_id)); | 2135 EXPECT_FALSE(display_manager()->IsActiveDisplayId(internal_id)); |
| 2133 | 2136 |
| 2134 const DisplayInfo& info = display_manager()->GetDisplayInfo(internal_id); | 2137 const ui::ManagedDisplayInfo& info = |
| 2138 display_manager()->GetDisplayInfo(internal_id); |
| 2135 | 2139 |
| 2136 EXPECT_FALSE(!!GetDisplayModeForNextUIScale(info, true)); | 2140 EXPECT_FALSE(!!GetDisplayModeForNextUIScale(info, true)); |
| 2137 EXPECT_FALSE(!!GetDisplayModeForNextUIScale(info, false)); | 2141 EXPECT_FALSE(!!GetDisplayModeForNextUIScale(info, false)); |
| 2138 EXPECT_FALSE(SetDisplayUIScale(internal_id, 1.0f)); | 2142 EXPECT_FALSE(SetDisplayUIScale(internal_id, 1.0f)); |
| 2139 | 2143 |
| 2140 DisplayInfo invalid_info; | 2144 ui::ManagedDisplayInfo invalid_info; |
| 2141 EXPECT_FALSE(!!GetDisplayModeForNextUIScale(invalid_info, true)); | 2145 EXPECT_FALSE(!!GetDisplayModeForNextUIScale(invalid_info, true)); |
| 2142 EXPECT_FALSE(!!GetDisplayModeForNextUIScale(invalid_info, false)); | 2146 EXPECT_FALSE(!!GetDisplayModeForNextUIScale(invalid_info, false)); |
| 2143 EXPECT_FALSE(SetDisplayUIScale(display::Display::kInvalidDisplayID, 1.0f)); | 2147 EXPECT_FALSE(SetDisplayUIScale(display::Display::kInvalidDisplayID, 1.0f)); |
| 2144 } | 2148 } |
| 2145 | 2149 |
| 2146 // Make sure that bad layout information is ignored and does not crash. | 2150 // Make sure that bad layout information is ignored and does not crash. |
| 2147 TEST_P(DisplayManagerTest, DontRegisterBadConfig) { | 2151 TEST_P(DisplayManagerTest, DontRegisterBadConfig) { |
| 2148 if (!SupportsMultipleDisplays()) | 2152 if (!SupportsMultipleDisplays()) |
| 2149 return; | 2153 return; |
| 2150 display::DisplayIdList list = ash::test::CreateDisplayIdList2(1, 2); | 2154 display::DisplayIdList list = ash::test::CreateDisplayIdList2(1, 2); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2312 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); | 2316 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); |
| 2313 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); | 2317 EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); |
| 2314 } | 2318 } |
| 2315 | 2319 |
| 2316 TEST_P(DisplayManagerTest, CheckInitializationOfRotationProperty) { | 2320 TEST_P(DisplayManagerTest, CheckInitializationOfRotationProperty) { |
| 2317 int64_t id = display_manager()->GetDisplayAt(0).id(); | 2321 int64_t id = display_manager()->GetDisplayAt(0).id(); |
| 2318 display_manager()->RegisterDisplayProperty(id, display::Display::ROTATE_90, | 2322 display_manager()->RegisterDisplayProperty(id, display::Display::ROTATE_90, |
| 2319 1.0f, nullptr, gfx::Size(), 1.0f, | 2323 1.0f, nullptr, gfx::Size(), 1.0f, |
| 2320 ui::COLOR_PROFILE_STANDARD); | 2324 ui::COLOR_PROFILE_STANDARD); |
| 2321 | 2325 |
| 2322 const DisplayInfo& info = display_manager()->GetDisplayInfo(id); | 2326 const ui::ManagedDisplayInfo& info = display_manager()->GetDisplayInfo(id); |
| 2323 | 2327 |
| 2324 EXPECT_EQ(display::Display::ROTATE_90, | 2328 EXPECT_EQ(display::Display::ROTATE_90, |
| 2325 info.GetRotation(display::Display::ROTATION_SOURCE_USER)); | 2329 info.GetRotation(display::Display::ROTATION_SOURCE_USER)); |
| 2326 EXPECT_EQ(display::Display::ROTATE_90, | 2330 EXPECT_EQ(display::Display::ROTATE_90, |
| 2327 info.GetRotation(display::Display::ROTATION_SOURCE_ACTIVE)); | 2331 info.GetRotation(display::Display::ROTATION_SOURCE_ACTIVE)); |
| 2328 } | 2332 } |
| 2329 | 2333 |
| 2330 TEST_P(DisplayManagerTest, RejectInvalidLayoutData) { | 2334 TEST_P(DisplayManagerTest, RejectInvalidLayoutData) { |
| 2331 display::DisplayLayoutStore* layout_store = display_manager()->layout_store(); | 2335 display::DisplayLayoutStore* layout_store = display_manager()->layout_store(); |
| 2332 int64_t id1 = 10001; | 2336 int64_t id1 = 10001; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2366 const display::DisplayLayout& stored = | 2370 const display::DisplayLayout& stored = |
| 2367 layout_store->GetRegisteredDisplayLayout(list); | 2371 layout_store->GetRegisteredDisplayLayout(list); |
| 2368 | 2372 |
| 2369 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id); | 2373 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id); |
| 2370 EXPECT_EQ(id2, stored.placement_list[0].display_id); | 2374 EXPECT_EQ(id2, stored.placement_list[0].display_id); |
| 2371 } | 2375 } |
| 2372 | 2376 |
| 2373 #endif // OS_CHROMEOS | 2377 #endif // OS_CHROMEOS |
| 2374 | 2378 |
| 2375 } // namespace ash | 2379 } // namespace ash |
| OLD | NEW |