Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / ui / display / util / display_util_unittest.cc
1 // Copyright 2014 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 "ui/display/util/display_util.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 namespace ui {
10
11 TEST(DisplayUtilTest, TestBlackListedDisplay) {
12   EXPECT_TRUE(IsDisplaySizeBlackListed(gfx::Size(10, 10)));
13   EXPECT_TRUE(IsDisplaySizeBlackListed(gfx::Size(40, 30)));
14   EXPECT_TRUE(IsDisplaySizeBlackListed(gfx::Size(50, 40)));
15   EXPECT_TRUE(IsDisplaySizeBlackListed(gfx::Size(160, 90)));
16   EXPECT_TRUE(IsDisplaySizeBlackListed(gfx::Size(160, 100)));
17
18   EXPECT_FALSE(IsDisplaySizeBlackListed(gfx::Size(50, 60)));
19   EXPECT_FALSE(IsDisplaySizeBlackListed(gfx::Size(100, 70)));
20   EXPECT_FALSE(IsDisplaySizeBlackListed(gfx::Size(272, 181)));
21 }
22
23 TEST(DisplayUtilTest, GetScaleFactor) {
24   // Normal chromebook spec. DPI ~= 130
25   EXPECT_EQ(1.0f, GetScaleFactor(
26       gfx::Size(256, 144), gfx::Size(1366, 768)));
27
28   // HiDPI like Pixel. DPI ~= 240
29   EXPECT_EQ(2.0f, GetScaleFactor(
30       gfx::Size(272, 181), gfx::Size(2560, 1700)));
31
32   // A large external display but normal pixel density. DPI ~= 100
33   EXPECT_EQ(1.0f, GetScaleFactor(
34       gfx::Size(641, 400), gfx::Size(2560, 1600)));
35
36   // A large external display with high pixel density. DPI ~= 157
37   EXPECT_EQ(2.0f, GetScaleFactor(
38       gfx::Size(621, 341), gfx::Size(3840, 2160)));
39
40   // 4K resolution but the display is physically even larger. DPI ~= 114
41   EXPECT_EQ(1.0f, GetScaleFactor(
42       gfx::Size(854, 481), gfx::Size(3840, 2160)));
43
44   // 21.5 inch, 1080p. DPI ~= 102
45   EXPECT_EQ(1.0f, GetScaleFactor(
46       gfx::Size(476, 267), gfx::Size(1920, 1080)));
47
48   // Corner case; slightly higher density but smaller screens. DPI ~= 165
49   EXPECT_EQ(1.0f, GetScaleFactor(
50       gfx::Size(293, 165), gfx::Size(1920, 1080)));
51 }
52
53 }  // namespace ui