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