| 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/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/display/display_layout_store.h" | 8 #include "ash/display/display_layout_store.h" |
| 9 #include "ash/screen_util.h" | 9 #include "ash/screen_util.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 display_manager()->OnNativeDisplaysChanged(display_info_list); | 712 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 713 EXPECT_EQ("-500,0 500x500", | 713 EXPECT_EQ("-500,0 500x500", |
| 714 GetDisplayForId(internal_display_id).bounds().ToString()); | 714 GetDisplayForId(internal_display_id).bounds().ToString()); |
| 715 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString()); | 715 EXPECT_EQ("0,0 100x100", GetDisplayForId(10).bounds().ToString()); |
| 716 } | 716 } |
| 717 | 717 |
| 718 TEST_F(DisplayManagerTest, DontRememberBestResolution) { | 718 TEST_F(DisplayManagerTest, DontRememberBestResolution) { |
| 719 int display_id = 1000; | 719 int display_id = 1000; |
| 720 DisplayInfo native_display_info = | 720 DisplayInfo native_display_info = |
| 721 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); | 721 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); |
| 722 std::vector<Resolution> resolutions; | 722 std::vector<DisplayMode> display_modes; |
| 723 resolutions.push_back(Resolution(gfx::Size(1000, 500), false)); | 723 display_modes.push_back( |
| 724 resolutions.push_back(Resolution(gfx::Size(800, 300), false)); | 724 DisplayMode(gfx::Size(1000, 500), 58.0f, false, true)); |
| 725 resolutions.push_back(Resolution(gfx::Size(400, 500), false)); | 725 display_modes.push_back( |
| 726 DisplayMode(gfx::Size(800, 300), 59.0f, false, false)); |
| 727 display_modes.push_back( |
| 728 DisplayMode(gfx::Size(400, 500), 60.0f, false, false)); |
| 726 | 729 |
| 727 native_display_info.set_resolutions(resolutions); | 730 native_display_info.set_display_modes(display_modes); |
| 728 | 731 |
| 729 std::vector<DisplayInfo> display_info_list; | 732 std::vector<DisplayInfo> display_info_list; |
| 730 display_info_list.push_back(native_display_info); | 733 display_info_list.push_back(native_display_info); |
| 731 display_manager()->OnNativeDisplaysChanged(display_info_list); | 734 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 732 | 735 |
| 733 gfx::Size selected; | 736 DisplayMode mode; |
| 734 EXPECT_FALSE(display_manager()->GetSelectedResolutionForDisplayId( | 737 EXPECT_FALSE( |
| 735 display_id, &selected)); | 738 display_manager()->GetSelectedModeForDisplayId(display_id, &mode)); |
| 736 | 739 |
| 737 // Unsupported resolution. | 740 // Unsupported resolution. |
| 738 display_manager()->SetDisplayResolution(display_id, gfx::Size(800, 4000)); | 741 display_manager()->SetDisplayResolution(display_id, gfx::Size(800, 4000)); |
| 739 EXPECT_FALSE(display_manager()->GetSelectedResolutionForDisplayId( | 742 EXPECT_FALSE( |
| 740 display_id, &selected)); | 743 display_manager()->GetSelectedModeForDisplayId(display_id, &mode)); |
| 741 | 744 |
| 742 // Supported resolution. | 745 // Supported resolution. |
| 743 display_manager()->SetDisplayResolution(display_id, gfx::Size(800, 300)); | 746 display_manager()->SetDisplayResolution(display_id, gfx::Size(800, 300)); |
| 744 EXPECT_TRUE(display_manager()->GetSelectedResolutionForDisplayId( | 747 EXPECT_TRUE( |
| 745 display_id, &selected)); | 748 display_manager()->GetSelectedModeForDisplayId(display_id, &mode)); |
| 746 EXPECT_EQ("800x300", selected.ToString()); | 749 EXPECT_EQ("800x300", mode.size.ToString()); |
| 750 EXPECT_EQ(59.0f, mode.refresh_rate); |
| 751 EXPECT_FALSE(mode.native); |
| 747 | 752 |
| 748 // Best resolution. | 753 // Best resolution. |
| 749 display_manager()->SetDisplayResolution(display_id, gfx::Size(1000, 500)); | 754 display_manager()->SetDisplayResolution(display_id, gfx::Size(1000, 500)); |
| 750 EXPECT_FALSE(display_manager()->GetSelectedResolutionForDisplayId( | 755 EXPECT_TRUE( |
| 751 display_id, &selected)); | 756 display_manager()->GetSelectedModeForDisplayId(display_id, &mode)); |
| 757 EXPECT_EQ("1000x500", mode.size.ToString()); |
| 758 EXPECT_EQ(58.0f, mode.refresh_rate); |
| 759 EXPECT_TRUE(mode.native); |
| 752 } | 760 } |
| 753 | 761 |
| 754 TEST_F(DisplayManagerTest, ResolutionFallback) { | 762 TEST_F(DisplayManagerTest, ResolutionFallback) { |
| 755 int display_id = 1000; | 763 int display_id = 1000; |
| 756 DisplayInfo native_display_info = | 764 DisplayInfo native_display_info = |
| 757 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); | 765 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); |
| 758 std::vector<Resolution> resolutions; | 766 std::vector<DisplayMode> display_modes; |
| 759 resolutions.push_back(Resolution(gfx::Size(1000, 500), false)); | 767 display_modes.push_back( |
| 760 resolutions.push_back(Resolution(gfx::Size(800, 300), false)); | 768 DisplayMode(gfx::Size(1000, 500), 58.0f, false, true)); |
| 761 resolutions.push_back(Resolution(gfx::Size(400, 500), false)); | 769 display_modes.push_back( |
| 770 DisplayMode(gfx::Size(800, 300), 59.0f, false, false)); |
| 771 display_modes.push_back( |
| 772 DisplayMode(gfx::Size(400, 500), 60.0f, false, false)); |
| 762 | 773 |
| 763 std::vector<Resolution> copy = resolutions; | 774 std::vector<DisplayMode> copy = display_modes; |
| 764 native_display_info.set_resolutions(copy); | 775 native_display_info.set_display_modes(copy); |
| 765 | 776 |
| 766 std::vector<DisplayInfo> display_info_list; | 777 std::vector<DisplayInfo> display_info_list; |
| 767 display_info_list.push_back(native_display_info); | 778 display_info_list.push_back(native_display_info); |
| 768 display_manager()->OnNativeDisplaysChanged(display_info_list); | 779 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 769 { | 780 { |
| 770 display_manager()->SetDisplayResolution(display_id, gfx::Size(800, 300)); | 781 display_manager()->SetDisplayResolution(display_id, gfx::Size(800, 300)); |
| 771 DisplayInfo new_native_display_info = | 782 DisplayInfo new_native_display_info = |
| 772 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 400, 500)); | 783 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 400, 500)); |
| 773 copy = resolutions; | 784 copy = display_modes; |
| 774 new_native_display_info.set_resolutions(copy); | 785 new_native_display_info.set_display_modes(copy); |
| 775 std::vector<DisplayInfo> new_display_info_list; | 786 std::vector<DisplayInfo> new_display_info_list; |
| 776 new_display_info_list.push_back(new_native_display_info); | 787 new_display_info_list.push_back(new_native_display_info); |
| 777 display_manager()->OnNativeDisplaysChanged(new_display_info_list); | 788 display_manager()->OnNativeDisplaysChanged(new_display_info_list); |
| 778 | 789 |
| 779 gfx::Size selected; | 790 DisplayMode mode; |
| 780 EXPECT_TRUE(display_manager()->GetSelectedResolutionForDisplayId( | 791 EXPECT_TRUE( |
| 781 display_id, &selected)); | 792 display_manager()->GetSelectedModeForDisplayId(display_id, &mode)); |
| 782 EXPECT_EQ("400x500", selected.ToString()); | 793 EXPECT_EQ("400x500", mode.size.ToString()); |
| 794 EXPECT_EQ(60.0f, mode.refresh_rate); |
| 795 EXPECT_FALSE(mode.native); |
| 783 } | 796 } |
| 784 { | 797 { |
| 785 // Best resolution should not be set. | 798 // Best resolution should find itself on the resolutions list. |
| 786 display_manager()->SetDisplayResolution(display_id, gfx::Size(800, 300)); | 799 display_manager()->SetDisplayResolution(display_id, gfx::Size(800, 300)); |
| 787 DisplayInfo new_native_display_info = | 800 DisplayInfo new_native_display_info = |
| 788 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); | 801 CreateDisplayInfo(display_id, gfx::Rect(0, 0, 1000, 500)); |
| 789 std::vector<Resolution> copy = resolutions; | 802 std::vector<DisplayMode> copy = display_modes; |
| 790 new_native_display_info.set_resolutions(copy); | 803 new_native_display_info.set_display_modes(copy); |
| 791 std::vector<DisplayInfo> new_display_info_list; | 804 std::vector<DisplayInfo> new_display_info_list; |
| 792 new_display_info_list.push_back(new_native_display_info); | 805 new_display_info_list.push_back(new_native_display_info); |
| 793 display_manager()->OnNativeDisplaysChanged(new_display_info_list); | 806 display_manager()->OnNativeDisplaysChanged(new_display_info_list); |
| 794 | 807 |
| 795 gfx::Size selected; | 808 DisplayMode mode; |
| 796 EXPECT_FALSE(display_manager()->GetSelectedResolutionForDisplayId( | 809 EXPECT_TRUE( |
| 797 display_id, &selected)); | 810 display_manager()->GetSelectedModeForDisplayId(display_id, &mode)); |
| 811 EXPECT_EQ("1000x500", mode.size.ToString()); |
| 812 EXPECT_EQ(58.0f, mode.refresh_rate); |
| 813 EXPECT_TRUE(mode.native); |
| 798 } | 814 } |
| 799 } | 815 } |
| 800 | 816 |
| 801 TEST_F(DisplayManagerTest, Rotate) { | 817 TEST_F(DisplayManagerTest, Rotate) { |
| 802 if (!SupportsMultipleDisplays()) | 818 if (!SupportsMultipleDisplays()) |
| 803 return; | 819 return; |
| 804 | 820 |
| 805 UpdateDisplay("100x200/r,300x400/l"); | 821 UpdateDisplay("100x200/r,300x400/l"); |
| 806 EXPECT_EQ("1,1 100x200", | 822 EXPECT_EQ("1,1 100x200", |
| 807 GetDisplayInfoAt(0).bounds_in_native().ToString()); | 823 GetDisplayInfoAt(0).bounds_in_native().ToString()); |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1211 }; | 1227 }; |
| 1212 | 1228 |
| 1213 TEST_F(ScreenShutdownTest, ScreenAfterShutdown) { | 1229 TEST_F(ScreenShutdownTest, ScreenAfterShutdown) { |
| 1214 if (!SupportsMultipleDisplays()) | 1230 if (!SupportsMultipleDisplays()) |
| 1215 return; | 1231 return; |
| 1216 UpdateDisplay("500x300,800x400"); | 1232 UpdateDisplay("500x300,800x400"); |
| 1217 } | 1233 } |
| 1218 | 1234 |
| 1219 } // namespace internal | 1235 } // namespace internal |
| 1220 } // namespace ash | 1236 } // namespace ash |
| OLD | NEW |