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