OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_info.h" | 5 #include "ash/display/display_info.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 namespace ash { | 9 namespace ash { |
10 namespace { | 10 namespace { |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 } // namespace | 23 } // namespace |
24 | 24 |
25 typedef testing::Test DisplayInfoTest; | 25 typedef testing::Test DisplayInfoTest; |
26 | 26 |
27 TEST_F(DisplayInfoTest, CreateFromSpec) { | 27 TEST_F(DisplayInfoTest, CreateFromSpec) { |
28 DisplayInfo info = DisplayInfo::CreateFromSpecWithID("200x100", 10); | 28 DisplayInfo info = DisplayInfo::CreateFromSpecWithID("200x100", 10); |
29 EXPECT_EQ(10, info.id()); | 29 EXPECT_EQ(10, info.id()); |
30 EXPECT_EQ("0,0 200x100", info.bounds_in_native().ToString()); | 30 EXPECT_EQ("0,0 200x100", info.bounds_in_native().ToString()); |
31 EXPECT_EQ("200x100", info.size_in_pixel().ToString()); | 31 EXPECT_EQ("200x100", info.size_in_pixel().ToString()); |
32 EXPECT_EQ(gfx::Display::ROTATE_0, info.rotation()); | 32 EXPECT_EQ(gfx::Display::ROTATE_0, |
| 33 info.Rotation(gfx::Display::ROTATION_SOURCE_ACTIVE)); |
33 EXPECT_EQ("0,0,0,0", info.overscan_insets_in_dip().ToString()); | 34 EXPECT_EQ("0,0,0,0", info.overscan_insets_in_dip().ToString()); |
34 EXPECT_EQ(1.0f, info.configured_ui_scale()); | 35 EXPECT_EQ(1.0f, info.configured_ui_scale()); |
35 | 36 |
36 info = DisplayInfo::CreateFromSpecWithID("10+20-300x400*2/o", 10); | 37 info = DisplayInfo::CreateFromSpecWithID("10+20-300x400*2/o", 10); |
37 EXPECT_EQ("10,20 300x400", info.bounds_in_native().ToString()); | 38 EXPECT_EQ("10,20 300x400", info.bounds_in_native().ToString()); |
38 EXPECT_EQ("288x380", info.size_in_pixel().ToString()); | 39 EXPECT_EQ("288x380", info.size_in_pixel().ToString()); |
39 EXPECT_EQ(gfx::Display::ROTATE_0, info.rotation()); | 40 EXPECT_EQ(gfx::Display::ROTATE_0, |
| 41 info.Rotation(gfx::Display::ROTATION_SOURCE_ACTIVE)); |
40 EXPECT_EQ("5,3,5,3", info.overscan_insets_in_dip().ToString()); | 42 EXPECT_EQ("5,3,5,3", info.overscan_insets_in_dip().ToString()); |
41 | 43 |
42 info = DisplayInfo::CreateFromSpecWithID("10+20-300x400*2/ob", 10); | 44 info = DisplayInfo::CreateFromSpecWithID("10+20-300x400*2/ob", 10); |
43 EXPECT_EQ("10,20 300x400", info.bounds_in_native().ToString()); | 45 EXPECT_EQ("10,20 300x400", info.bounds_in_native().ToString()); |
44 EXPECT_EQ("288x380", info.size_in_pixel().ToString()); | 46 EXPECT_EQ("288x380", info.size_in_pixel().ToString()); |
45 EXPECT_EQ(gfx::Display::ROTATE_0, info.rotation()); | 47 EXPECT_EQ(gfx::Display::ROTATE_0, |
| 48 info.Rotation(gfx::Display::ROTATION_SOURCE_ACTIVE)); |
46 EXPECT_EQ("5,3,5,3", info.overscan_insets_in_dip().ToString()); | 49 EXPECT_EQ("5,3,5,3", info.overscan_insets_in_dip().ToString()); |
47 | 50 |
48 info = DisplayInfo::CreateFromSpecWithID("10+20-300x400*2/or", 10); | 51 info = DisplayInfo::CreateFromSpecWithID("10+20-300x400*2/or", 10); |
49 EXPECT_EQ("10,20 300x400", info.bounds_in_native().ToString()); | 52 EXPECT_EQ("10,20 300x400", info.bounds_in_native().ToString()); |
50 EXPECT_EQ("380x288", info.size_in_pixel().ToString()); | 53 EXPECT_EQ("380x288", info.size_in_pixel().ToString()); |
51 EXPECT_EQ(gfx::Display::ROTATE_90, info.rotation()); | 54 EXPECT_EQ(gfx::Display::ROTATE_90, |
| 55 info.Rotation(gfx::Display::ROTATION_SOURCE_ACTIVE)); |
52 // TODO(oshima): This should be rotated too. Fix this. | 56 // TODO(oshima): This should be rotated too. Fix this. |
53 EXPECT_EQ("5,3,5,3", info.overscan_insets_in_dip().ToString()); | 57 EXPECT_EQ("5,3,5,3", info.overscan_insets_in_dip().ToString()); |
54 | 58 |
55 info = DisplayInfo::CreateFromSpecWithID("10+20-300x400*2/l@1.5", 10); | 59 info = DisplayInfo::CreateFromSpecWithID("10+20-300x400*2/l@1.5", 10); |
56 EXPECT_EQ("10,20 300x400", info.bounds_in_native().ToString()); | 60 EXPECT_EQ("10,20 300x400", info.bounds_in_native().ToString()); |
57 EXPECT_EQ(gfx::Display::ROTATE_270, info.rotation()); | 61 EXPECT_EQ(gfx::Display::ROTATE_270, |
| 62 info.Rotation(gfx::Display::ROTATION_SOURCE_ACTIVE)); |
58 EXPECT_EQ(1.5f, info.configured_ui_scale()); | 63 EXPECT_EQ(1.5f, info.configured_ui_scale()); |
59 | 64 |
60 info = DisplayInfo::CreateFromSpecWithID( | 65 info = DisplayInfo::CreateFromSpecWithID( |
61 "200x200#300x200|200x200%59.9|100x100%60|150x100*2|150x150*1.25%30", 10); | 66 "200x200#300x200|200x200%59.9|100x100%60|150x100*2|150x150*1.25%30", 10); |
62 | 67 |
63 EXPECT_EQ("0,0 200x200", info.bounds_in_native().ToString()); | 68 EXPECT_EQ("0,0 200x200", info.bounds_in_native().ToString()); |
64 EXPECT_EQ(5u, info.display_modes().size()); | 69 EXPECT_EQ(5u, info.display_modes().size()); |
65 // Modes are sorted in DIP for external display. | 70 // Modes are sorted in DIP for external display. |
66 EXPECT_EQ("150x100", info.display_modes()[0].size.ToString()); | 71 EXPECT_EQ("150x100", info.display_modes()[0].size.ToString()); |
67 EXPECT_EQ("100x100", info.display_modes()[1].size.ToString()); | 72 EXPECT_EQ("100x100", info.display_modes()[1].size.ToString()); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 TEST_F(DisplayInfoTest, DisplayModeGetSizeForExternal4K) { | 128 TEST_F(DisplayInfoTest, DisplayModeGetSizeForExternal4K) { |
124 DisplayInfo::SetUse125DSFForUIScaling(true); | 129 DisplayInfo::SetUse125DSFForUIScaling(true); |
125 gfx::Size size(3840, 2160); | 130 gfx::Size size(3840, 2160); |
126 EXPECT_EQ("1920x1080", GetModeSizeInDIP(size, 2.0f, 1.0f, false)); | 131 EXPECT_EQ("1920x1080", GetModeSizeInDIP(size, 2.0f, 1.0f, false)); |
127 EXPECT_EQ("3072x1728", GetModeSizeInDIP(size, 1.25f, 1.0f, false)); | 132 EXPECT_EQ("3072x1728", GetModeSizeInDIP(size, 1.25f, 1.0f, false)); |
128 EXPECT_EQ("3840x2160", GetModeSizeInDIP(size, 1.0f, 1.0f, false)); | 133 EXPECT_EQ("3840x2160", GetModeSizeInDIP(size, 1.0f, 1.0f, false)); |
129 DisplayInfo::SetUse125DSFForUIScaling(false); | 134 DisplayInfo::SetUse125DSFForUIScaling(false); |
130 } | 135 } |
131 | 136 |
132 } // namespace ash | 137 } // namespace ash |
OLD | NEW |