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