OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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/gfx/monitor.h" | |
6 | |
7 #include "testing/gtest/include/gtest/gtest.h" | |
8 #include "ui/gfx/insets.h" | |
9 | |
10 namespace { | |
11 | |
12 TEST(MonitorTest, WorkArea) { | |
13 gfx::Monitor monitor(0, gfx::Rect(0, 0, 100, 100)); | |
14 EXPECT_EQ("0,0 100x100", monitor.bounds().ToString()); | |
15 EXPECT_EQ("0,0 100x100", monitor.work_area().ToString()); | |
16 | |
17 monitor.set_work_area(gfx::Rect(3, 4, 90, 80)); | |
18 EXPECT_EQ("0,0 100x100", monitor.bounds().ToString()); | |
19 EXPECT_EQ("3,4 90x80", monitor.work_area().ToString()); | |
20 | |
21 monitor.SetScaleAndBounds(1.0f, gfx::Rect(10, 20, 50, 50)); | |
22 EXPECT_EQ("0,0 50x50", monitor.bounds().ToString()); | |
23 EXPECT_EQ("3,4 40x30", monitor.work_area().ToString()); | |
24 | |
25 monitor.SetSize(gfx::Size(200, 200)); | |
26 EXPECT_EQ("3,4 190x180", monitor.work_area().ToString()); | |
27 | |
28 monitor.UpdateWorkAreaFromInsets(gfx::Insets(3, 4, 5, 6)); | |
29 EXPECT_EQ("4,3 190x192", monitor.work_area().ToString()); | |
30 } | |
31 | |
32 TEST(MonitorTest, Scale) { | |
33 gfx::Monitor monitor(0, gfx::Rect(0, 0, 100, 100)); | |
34 monitor.set_work_area(gfx::Rect(10, 10, 80, 80)); | |
35 EXPECT_EQ("0,0 100x100", monitor.bounds().ToString()); | |
36 EXPECT_EQ("10,10 80x80", monitor.work_area().ToString()); | |
37 | |
38 // Scale it back to 2x | |
39 monitor.SetScaleAndBounds(2.0f, gfx::Rect(0, 0, 140, 140)); | |
40 EXPECT_EQ("0,0 70x70", monitor.bounds().ToString()); | |
41 EXPECT_EQ("10,10 50x50", monitor.work_area().ToString()); | |
42 | |
43 // Scale it back to 1x | |
44 monitor.SetScaleAndBounds(1.0f, gfx::Rect(0, 0, 100, 100)); | |
45 EXPECT_EQ("0,0 100x100", monitor.bounds().ToString()); | |
46 EXPECT_EQ("10,10 80x80", monitor.work_area().ToString()); | |
47 } | |
48 | |
49 } | |
OLD | NEW |