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