| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_change_observer_chromeos.h" | 5 #include "ash/display/display_change_observer_chromeos.h" |
| 6 | 6 |
| 7 #include "ash/display/display_info.h" | 7 #include "ash/display/display_info.h" |
| 8 #include "chromeos/display/output_configurator.h" | 8 #include "chromeos/display/output_configurator.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 using chromeos::OutputConfigurator; | 11 using chromeos::OutputConfigurator; |
| 12 | 12 |
| 13 typedef testing::Test DisplayChangeObserverTest; | 13 typedef testing::Test DisplayChangeObserverTest; |
| 14 | 14 |
| 15 namespace ash { | 15 namespace ash { |
| 16 namespace internal { | 16 namespace internal { |
| 17 | 17 |
| 18 TEST_F(DisplayChangeObserverTest, GetDisplayModeList) { | 18 TEST_F(DisplayChangeObserverTest, GetResolutionList) { |
| 19 OutputConfigurator::OutputSnapshot output; | 19 OutputConfigurator::OutputSnapshot output; |
| 20 output.mode_infos[11] = OutputConfigurator::ModeInfo(1920, 1200, false, 60); | 20 output.mode_infos[11] = OutputConfigurator::ModeInfo(1920, 1200, false, 60); |
| 21 | 21 |
| 22 // All non-interlaced (as would be seen with different refresh rates). | 22 // All non-interlaced (as would be seen with different refresh rates). |
| 23 output.mode_infos[12] = OutputConfigurator::ModeInfo(1920, 1080, false, 80); | 23 output.mode_infos[12] = OutputConfigurator::ModeInfo(1920, 1080, false, 80); |
| 24 output.mode_infos[13] = OutputConfigurator::ModeInfo(1920, 1080, false, 70); | 24 output.mode_infos[13] = OutputConfigurator::ModeInfo(1920, 1080, false, 70); |
| 25 output.mode_infos[14] = OutputConfigurator::ModeInfo(1920, 1080, false, 60); | 25 output.mode_infos[14] = OutputConfigurator::ModeInfo(1920, 1080, false, 60); |
| 26 | 26 |
| 27 // Interlaced vs non-interlaced. | 27 // Interlaced vs non-interlaced. |
| 28 output.mode_infos[15] = OutputConfigurator::ModeInfo(1280, 720, true, 60); | 28 output.mode_infos[15] = OutputConfigurator::ModeInfo(1280, 720, true, 60); |
| 29 output.mode_infos[16] = OutputConfigurator::ModeInfo(1280, 720, false, 60); | 29 output.mode_infos[16] = OutputConfigurator::ModeInfo(1280, 720, false, 60); |
| 30 | 30 |
| 31 // Interlaced only. | 31 // Interlaced only. |
| 32 output.mode_infos[17] = OutputConfigurator::ModeInfo(1024, 768, true, 70); | 32 output.mode_infos[17] = OutputConfigurator::ModeInfo(1024, 768, true, 70); |
| 33 output.mode_infos[18] = OutputConfigurator::ModeInfo(1024, 768, true, 60); | 33 output.mode_infos[18] = OutputConfigurator::ModeInfo(1024, 768, true, 60); |
| 34 | 34 |
| 35 // Mixed. | 35 // Mixed. |
| 36 output.mode_infos[19] = OutputConfigurator::ModeInfo(1024, 600, true, 60); | 36 output.mode_infos[19] = OutputConfigurator::ModeInfo(1024, 600, true, 60); |
| 37 output.mode_infos[20] = OutputConfigurator::ModeInfo(1024, 600, false, 70); | 37 output.mode_infos[20] = OutputConfigurator::ModeInfo(1024, 600, false, 70); |
| 38 output.mode_infos[21] = OutputConfigurator::ModeInfo(1024, 600, false, 60); | 38 output.mode_infos[21] = OutputConfigurator::ModeInfo(1024, 600, false, 60); |
| 39 | 39 |
| 40 // Just one interlaced mode. | 40 // Just one interlaced mode. |
| 41 output.mode_infos[22] = OutputConfigurator::ModeInfo(640, 480, true, 60); | 41 output.mode_infos[22] = OutputConfigurator::ModeInfo(640, 480, true, 60); |
| 42 | 42 |
| 43 std::vector<DisplayMode> display_modes = | 43 std::vector<Resolution> resolutions = |
| 44 DisplayChangeObserver::GetDisplayModeList(output); | 44 DisplayChangeObserver::GetResolutionList(output); |
| 45 ASSERT_EQ(6u, display_modes.size()); | 45 ASSERT_EQ(6u, resolutions.size()); |
| 46 EXPECT_EQ("1920x1200", display_modes[0].size.ToString()); | 46 EXPECT_EQ("1920x1200", resolutions[0].size.ToString()); |
| 47 EXPECT_FALSE(display_modes[0].interlaced); | 47 EXPECT_FALSE(resolutions[0].interlaced); |
| 48 EXPECT_EQ(display_modes[0].refresh_rate, 60); | |
| 49 | 48 |
| 50 EXPECT_EQ("1920x1080", display_modes[1].size.ToString()); | 49 EXPECT_EQ("1920x1080", resolutions[1].size.ToString()); |
| 51 EXPECT_FALSE(display_modes[1].interlaced); | 50 EXPECT_FALSE(resolutions[1].interlaced); |
| 52 EXPECT_EQ(display_modes[1].refresh_rate, 80); | |
| 53 | 51 |
| 54 EXPECT_EQ("1280x720", display_modes[2].size.ToString()); | 52 EXPECT_EQ("1280x720", resolutions[2].size.ToString()); |
| 55 EXPECT_FALSE(display_modes[2].interlaced); | 53 EXPECT_FALSE(resolutions[2].interlaced); |
| 56 EXPECT_EQ(display_modes[2].refresh_rate, 60); | |
| 57 | 54 |
| 58 EXPECT_EQ("1024x768", display_modes[3].size.ToString()); | 55 EXPECT_EQ("1024x768", resolutions[3].size.ToString()); |
| 59 EXPECT_TRUE(display_modes[3].interlaced); | 56 EXPECT_TRUE(resolutions[3].interlaced); |
| 60 EXPECT_EQ(display_modes[3].refresh_rate, 70); | |
| 61 | 57 |
| 62 EXPECT_EQ("1024x600", display_modes[4].size.ToString()); | 58 EXPECT_EQ("1024x600", resolutions[4].size.ToString()); |
| 63 EXPECT_FALSE(display_modes[4].interlaced); | 59 EXPECT_FALSE(resolutions[4].interlaced); |
| 64 EXPECT_EQ(display_modes[4].refresh_rate, 70); | |
| 65 | 60 |
| 66 EXPECT_EQ("640x480", display_modes[5].size.ToString()); | 61 EXPECT_EQ("640x480", resolutions[5].size.ToString()); |
| 67 EXPECT_TRUE(display_modes[5].interlaced); | 62 EXPECT_TRUE(resolutions[5].interlaced); |
| 68 EXPECT_EQ(display_modes[5].refresh_rate, 60); | |
| 69 | 63 |
| 70 // Outputs without any modes shouldn't cause a crash. | 64 // Outputs without any modes shouldn't cause a crash. |
| 71 output.mode_infos.clear(); | 65 output.mode_infos.clear(); |
| 72 display_modes = DisplayChangeObserver::GetDisplayModeList(output); | 66 resolutions = DisplayChangeObserver::GetResolutionList(output); |
| 73 EXPECT_EQ(0u, display_modes.size()); | 67 EXPECT_EQ(0u, resolutions.size()); |
| 74 } | 68 } |
| 75 | 69 |
| 76 } // namespace internal | 70 } // namespace internal |
| 77 } // namespace ash | 71 } // namespace ash |
| OLD | NEW |