Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: ui/display/display_unittest.cc

Issue 1964153002: Move Screen, its impls, DisplayObserver and DisplayChangeNotifier to ui/display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tabs Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/display/display_observer.cc ('k') | ui/display/ios/screen_ios.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 "ui/gfx/display.h" 5 #include "ui/display/display.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/gfx/geometry/insets.h" 9 #include "ui/gfx/geometry/insets.h"
10 #include "ui/gfx/geometry/rect.h"
11 #include "ui/gfx/geometry/size.h"
10 #include "ui/gfx/switches.h" 12 #include "ui/gfx/switches.h"
11 13
12 namespace gfx { 14 namespace display {
13
14 namespace {
15 15
16 TEST(DisplayTest, WorkArea) { 16 TEST(DisplayTest, WorkArea) {
17 Display display(0, Rect(0, 0, 100, 100)); 17 Display display(0, gfx::Rect(0, 0, 100, 100));
18 EXPECT_EQ("0,0 100x100", display.bounds().ToString()); 18 EXPECT_EQ("0,0 100x100", display.bounds().ToString());
19 EXPECT_EQ("0,0 100x100", display.work_area().ToString()); 19 EXPECT_EQ("0,0 100x100", display.work_area().ToString());
20 20
21 display.set_work_area(Rect(3, 4, 90, 80)); 21 display.set_work_area(gfx::Rect(3, 4, 90, 80));
22 EXPECT_EQ("0,0 100x100", display.bounds().ToString()); 22 EXPECT_EQ("0,0 100x100", display.bounds().ToString());
23 EXPECT_EQ("3,4 90x80", display.work_area().ToString()); 23 EXPECT_EQ("3,4 90x80", display.work_area().ToString());
24 24
25 display.SetScaleAndBounds(1.0f, Rect(10, 20, 50, 50)); 25 display.SetScaleAndBounds(1.0f, gfx::Rect(10, 20, 50, 50));
26 EXPECT_EQ("10,20 50x50", display.bounds().ToString()); 26 EXPECT_EQ("10,20 50x50", display.bounds().ToString());
27 EXPECT_EQ("13,24 40x30", display.work_area().ToString()); 27 EXPECT_EQ("13,24 40x30", display.work_area().ToString());
28 28
29 display.SetSize(Size(200, 200)); 29 display.SetSize(gfx::Size(200, 200));
30 EXPECT_EQ("13,24 190x180", display.work_area().ToString()); 30 EXPECT_EQ("13,24 190x180", display.work_area().ToString());
31 31
32 display.UpdateWorkAreaFromInsets(Insets(3, 4, 5, 6)); 32 display.UpdateWorkAreaFromInsets(gfx::Insets(3, 4, 5, 6));
33 EXPECT_EQ("14,23 190x192", display.work_area().ToString()); 33 EXPECT_EQ("14,23 190x192", display.work_area().ToString());
34 } 34 }
35 35
36 TEST(DisplayTest, Scale) { 36 TEST(DisplayTest, Scale) {
37 Display display(0, Rect(0, 0, 100, 100)); 37 Display display(0, gfx::Rect(0, 0, 100, 100));
38 display.set_work_area(Rect(10, 10, 80, 80)); 38 display.set_work_area(gfx::Rect(10, 10, 80, 80));
39 EXPECT_EQ("0,0 100x100", display.bounds().ToString()); 39 EXPECT_EQ("0,0 100x100", display.bounds().ToString());
40 EXPECT_EQ("10,10 80x80", display.work_area().ToString()); 40 EXPECT_EQ("10,10 80x80", display.work_area().ToString());
41 41
42 // Scale it back to 2x 42 // Scale it back to 2x
43 display.SetScaleAndBounds(2.0f, Rect(0, 0, 140, 140)); 43 display.SetScaleAndBounds(2.0f, gfx::Rect(0, 0, 140, 140));
44 EXPECT_EQ("0,0 70x70", display.bounds().ToString()); 44 EXPECT_EQ("0,0 70x70", display.bounds().ToString());
45 EXPECT_EQ("10,10 50x50", display.work_area().ToString()); 45 EXPECT_EQ("10,10 50x50", display.work_area().ToString());
46 46
47 // Scale it back to 1x 47 // Scale it back to 1x
48 display.SetScaleAndBounds(1.0f, Rect(0, 0, 100, 100)); 48 display.SetScaleAndBounds(1.0f, gfx::Rect(0, 0, 100, 100));
49 EXPECT_EQ("0,0 100x100", display.bounds().ToString()); 49 EXPECT_EQ("0,0 100x100", display.bounds().ToString());
50 EXPECT_EQ("10,10 80x80", display.work_area().ToString()); 50 EXPECT_EQ("10,10 80x80", display.work_area().ToString());
51 } 51 }
52 52
53 // https://crbug.com/517944 53 // https://crbug.com/517944
54 TEST(DisplayTest, ForcedDeviceScaleFactorByCommandLine) { 54 TEST(DisplayTest, ForcedDeviceScaleFactorByCommandLine) {
55 Display::ResetForceDeviceScaleFactorForTesting(); 55 Display::ResetForceDeviceScaleFactorForTesting();
56 56
57 // Look ma, no value! 57 // Look ma, no value!
58 base::CommandLine::ForCurrentProcess()->AppendSwitch( 58 base::CommandLine::ForCurrentProcess()->AppendSwitch(
59 switches::kForceDeviceScaleFactor); 59 switches::kForceDeviceScaleFactor);
60 60
61 EXPECT_EQ(1, Display::GetForcedDeviceScaleFactor()); 61 EXPECT_EQ(1, Display::GetForcedDeviceScaleFactor());
62 Display::ResetForceDeviceScaleFactorForTesting(); 62 Display::ResetForceDeviceScaleFactorForTesting();
63 } 63 }
64 64
65 } // namespace 65 } // namespace display
66
67 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/display/display_observer.cc ('k') | ui/display/ios/screen_ios.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698