Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
|
oshima
2013/08/19 20:00:24
same here.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ash/display/display_change_observer_chromeos.h" | |
| 6 | |
| 7 #include "ash/display/display_info.h" | |
| 8 #include "chromeos/display/output_configurator.h" | |
| 9 #include "chromeos/display/output_util.h" | |
| 10 #include "testing/gtest/include/gtest/gtest.h" | |
| 11 | |
| 12 using chromeos::OutputConfigurator; | |
| 13 | |
| 14 typedef testing::Test DisplayChangeObserverTest; | |
| 15 | |
| 16 namespace ash { | |
| 17 namespace internal { | |
| 18 | |
| 19 TEST_F(DisplayChangeObserverTest, TestBlackListedDisplay) { | |
| 20 EXPECT_TRUE(DisplayChangeObserver::ShouldIgnoreSize(10, 10)); | |
| 21 EXPECT_TRUE(DisplayChangeObserver::ShouldIgnoreSize(40, 30)); | |
| 22 EXPECT_TRUE(DisplayChangeObserver::ShouldIgnoreSize(50, 40)); | |
| 23 EXPECT_TRUE(DisplayChangeObserver::ShouldIgnoreSize(160, 90)); | |
| 24 EXPECT_TRUE(DisplayChangeObserver::ShouldIgnoreSize(160, 100)); | |
| 25 | |
| 26 EXPECT_FALSE(DisplayChangeObserver::ShouldIgnoreSize(50, 60)); | |
| 27 EXPECT_FALSE(DisplayChangeObserver::ShouldIgnoreSize(100, 70)); | |
| 28 EXPECT_FALSE(DisplayChangeObserver::ShouldIgnoreSize(272, 181)); | |
| 29 } | |
| 30 | |
| 31 TEST_F(DisplayChangeObserverTest, GetResolutionList) { | |
| 32 OutputConfigurator::OutputSnapshot output; | |
| 33 output.mode_infos[11] = OutputConfigurator::ModeInfo(1920, 1200, false); | |
| 34 | |
| 35 // All non-interlaced (as would be seen with different refresh rates). | |
| 36 output.mode_infos[12] = OutputConfigurator::ModeInfo(1920, 1080, false); | |
| 37 output.mode_infos[13] = OutputConfigurator::ModeInfo(1920, 1080, false); | |
| 38 output.mode_infos[14] = OutputConfigurator::ModeInfo(1920, 1080, false); | |
| 39 | |
| 40 // Interlaced vs non-interlaced. | |
| 41 output.mode_infos[15] = OutputConfigurator::ModeInfo(1280, 720, true); | |
| 42 output.mode_infos[16] = OutputConfigurator::ModeInfo(1280, 720, false); | |
| 43 | |
| 44 // Interlaced only. | |
| 45 output.mode_infos[17] = OutputConfigurator::ModeInfo(1024, 768, true); | |
| 46 output.mode_infos[18] = OutputConfigurator::ModeInfo(1024, 768, true); | |
| 47 | |
| 48 // Mixed. | |
| 49 output.mode_infos[19] = OutputConfigurator::ModeInfo(1024, 600, true); | |
| 50 output.mode_infos[20] = OutputConfigurator::ModeInfo(1024, 600, false); | |
| 51 output.mode_infos[21] = OutputConfigurator::ModeInfo(1024, 600, false); | |
| 52 | |
| 53 // Just one interlaced mode. | |
| 54 output.mode_infos[22] = OutputConfigurator::ModeInfo(640, 480, true); | |
| 55 | |
| 56 std::vector<Resolution> resolutions = | |
| 57 DisplayChangeObserver::GetResolutionList(output); | |
| 58 ASSERT_EQ(6u, resolutions.size()); | |
| 59 EXPECT_EQ("1920x1200", resolutions[0].size.ToString()); | |
| 60 EXPECT_FALSE(resolutions[0].interlaced); | |
| 61 | |
| 62 EXPECT_EQ("1920x1080", resolutions[1].size.ToString()); | |
| 63 EXPECT_FALSE(resolutions[1].interlaced); | |
| 64 | |
| 65 EXPECT_EQ("1280x720", resolutions[2].size.ToString()); | |
| 66 EXPECT_FALSE(resolutions[2].interlaced); | |
| 67 | |
| 68 EXPECT_EQ("1024x768", resolutions[3].size.ToString()); | |
| 69 EXPECT_TRUE(resolutions[3].interlaced); | |
| 70 | |
| 71 EXPECT_EQ("1024x600", resolutions[4].size.ToString()); | |
| 72 EXPECT_FALSE(resolutions[4].interlaced); | |
| 73 | |
| 74 EXPECT_EQ("640x480", resolutions[5].size.ToString()); | |
| 75 EXPECT_TRUE(resolutions[5].interlaced); | |
| 76 | |
| 77 // Outputs without any modes shouldn't cause a crash. | |
| 78 output.mode_infos.clear(); | |
| 79 resolutions = DisplayChangeObserver::GetResolutionList(output); | |
| 80 EXPECT_EQ(0u, resolutions.size()); | |
| 81 } | |
| 82 | |
| 83 } // namespace internal | |
| 84 } // namespace ash | |
| OLD | NEW |