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
3 // found in the LICENSE file.
5 #include "ash/display/display_info.h"
7 #include "testing/gtest/include/gtest/gtest.h"
11 typedef testing::Test DisplayInfoTest
;
13 TEST_F(DisplayInfoTest
, CreateFromSpec
) {
14 DisplayInfo info
= DisplayInfo::CreateFromSpecWithID("200x100", 10);
15 EXPECT_EQ(10, info
.id());
16 EXPECT_EQ("0,0 200x100", info
.bounds_in_native().ToString());
17 EXPECT_EQ("200x100", info
.size_in_pixel().ToString());
18 EXPECT_EQ(gfx::Display::ROTATE_0
, info
.rotation());
19 EXPECT_EQ("0,0,0,0", info
.overscan_insets_in_dip().ToString());
20 EXPECT_EQ(1.0f
, info
.configured_ui_scale());
22 info
= DisplayInfo::CreateFromSpecWithID("10+20-300x400*2/o", 10);
23 EXPECT_EQ("10,20 300x400", info
.bounds_in_native().ToString());
24 EXPECT_EQ("288x380", info
.size_in_pixel().ToString());
25 EXPECT_EQ(gfx::Display::ROTATE_0
, info
.rotation());
26 EXPECT_EQ("5,3,5,3", info
.overscan_insets_in_dip().ToString());
28 info
= DisplayInfo::CreateFromSpecWithID("10+20-300x400*2/ob", 10);
29 EXPECT_EQ("10,20 300x400", info
.bounds_in_native().ToString());
30 EXPECT_EQ("288x380", info
.size_in_pixel().ToString());
31 EXPECT_EQ(gfx::Display::ROTATE_0
, info
.rotation());
32 EXPECT_EQ("5,3,5,3", info
.overscan_insets_in_dip().ToString());
34 info
= DisplayInfo::CreateFromSpecWithID("10+20-300x400*2/or", 10);
35 EXPECT_EQ("10,20 300x400", info
.bounds_in_native().ToString());
36 EXPECT_EQ("380x288", info
.size_in_pixel().ToString());
37 EXPECT_EQ(gfx::Display::ROTATE_90
, info
.rotation());
38 // TODO(oshima): This should be rotated too. Fix this.
39 EXPECT_EQ("5,3,5,3", info
.overscan_insets_in_dip().ToString());
41 info
= DisplayInfo::CreateFromSpecWithID("10+20-300x400*2/l@1.5", 10);
42 EXPECT_EQ("10,20 300x400", info
.bounds_in_native().ToString());
43 EXPECT_EQ(gfx::Display::ROTATE_270
, info
.rotation());
44 EXPECT_EQ(1.5f
, info
.configured_ui_scale());
46 info
= DisplayInfo::CreateFromSpecWithID(
47 "200x200#300x200|200x200%59.9|100x100%60", 10);
48 EXPECT_EQ("0,0 200x200", info
.bounds_in_native().ToString());
49 EXPECT_EQ(3u, info
.display_modes().size());
50 EXPECT_EQ("300x200", info
.display_modes()[0].size
.ToString());
51 EXPECT_EQ("200x200", info
.display_modes()[1].size
.ToString());
52 EXPECT_EQ("100x100", info
.display_modes()[2].size
.ToString());
53 EXPECT_EQ(59.9f
, info
.display_modes()[1].refresh_rate
);
54 EXPECT_EQ(60.0f
, info
.display_modes()[2].refresh_rate
);
55 EXPECT_TRUE(info
.display_modes()[0].native
);
56 EXPECT_FALSE(info
.display_modes()[1].native
);
57 EXPECT_FALSE(info
.display_modes()[2].native
);