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

Side by Side Diff: ash/monitor/monitor_controller_unittest.cc

Issue 10696002: ASH: Use virtual screen coordinates in Display::bounds() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 5 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 | Annotate | Revision Log
OLDNEW
(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 "ash/monitor/monitor_controller.h"
6
7 #include "ash/shell.h"
8 #include "ash/test/ash_test_base.h"
9 #include "ui/aura/root_window.h"
10 #include "ui/gfx/display.h"
11 #include "ui/gfx/screen.h"
12
13 #include "ui/aura/env.h"
14 #include "ui/aura/monitor_manager.h"
15
16 namespace ash {
17 namespace test {
18 namespace {
19
20 gfx::Display GetPrimaryDisplay() {
21 return gfx::Screen::GetDisplayNearestWindow(
22 Shell::GetAllRootWindows()[0]);
23 }
24
25 gfx::Display GetSecondaryDisplay() {
26 return gfx::Screen::GetDisplayNearestWindow(
27 Shell::GetAllRootWindows()[1]);
28 }
29
30 } // namespace
31
32 class MonitorControllerTest : public test::AshTestBase {
33 public:
34 MonitorControllerTest() {}
35 virtual ~MonitorControllerTest() {}
36
37 virtual void SetUp() OVERRIDE {
38 internal::MonitorController::SetExtendedDesktopEnabled(true);
39 internal::MonitorController::SetVirtualScreenCoordinatesEnabled(true);
40 AshTestBase::SetUp();
41 }
42
43 virtual void TearDown() OVERRIDE {
44 AshTestBase::TearDown();
45 internal::MonitorController::SetExtendedDesktopEnabled(false);
46 internal::MonitorController::SetVirtualScreenCoordinatesEnabled(false);
47 }
48
49 private:
50 DISALLOW_COPY_AND_ASSIGN(MonitorControllerTest);
51 };
52
53 TEST_F(MonitorControllerTest, SecondaryDisplayLayout) {
54 UpdateMonitor("0+0-500x500,0+0-400x400");
55 gfx::Display* secondary_display =
56 aura::Env::GetInstance()->monitor_manager()->GetDisplayAt(1);
57 gfx::Insets insets(5, 5, 5, 5);
58 secondary_display->UpdateWorkAreaFromInsets(insets);
59
60 // Default layout is LEFT.
61 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString());
62 EXPECT_EQ("500,0 400x400", GetSecondaryDisplay().bounds().ToString());
63 EXPECT_EQ("505,5 390x390", GetSecondaryDisplay().work_area().ToString());
64
65 // Layout the secondary display to the bottom of the primary.
66 Shell::GetInstance()->monitor_controller()->SetSecondaryDisplayLayout(
67 internal::MonitorController::BOTTOM);
68 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString());
69 EXPECT_EQ("0,500 400x400", GetSecondaryDisplay().bounds().ToString());
70 EXPECT_EQ("5,505 390x390", GetSecondaryDisplay().work_area().ToString());
71
72 // Layout the secondary display to the left of the primary.
73 Shell::GetInstance()->monitor_controller()->SetSecondaryDisplayLayout(
74 internal::MonitorController::LEFT);
75 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString());
76 EXPECT_EQ("-400,0 400x400", GetSecondaryDisplay().bounds().ToString());
77 EXPECT_EQ("-395,5 390x390", GetSecondaryDisplay().work_area().ToString());
78
79 // Layout the secondary display to the top of the primary.
80 Shell::GetInstance()->monitor_controller()->SetSecondaryDisplayLayout(
81 internal::MonitorController::TOP);
82 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString());
83 EXPECT_EQ("0,-400 400x400", GetSecondaryDisplay().bounds().ToString());
84 EXPECT_EQ("5,-395 390x390", GetSecondaryDisplay().work_area().ToString());
85 }
86
87 TEST_F(MonitorControllerTest, BoundsUpdated) {
88 Shell::GetInstance()->monitor_controller()->SetSecondaryDisplayLayout(
89 internal::MonitorController::BOTTOM);
90 UpdateMonitor("0+0-500x500,0+0-400x400");
91 gfx::Display* secondary_display =
92 aura::Env::GetInstance()->monitor_manager()->GetDisplayAt(1);
93 gfx::Insets insets(5, 5, 5, 5);
94 secondary_display->UpdateWorkAreaFromInsets(insets);
95
96 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString());
97 EXPECT_EQ("0,500 400x400", GetSecondaryDisplay().bounds().ToString());
98 EXPECT_EQ("5,505 390x390", GetSecondaryDisplay().work_area().ToString());
99
100 UpdateMonitor("0+0-600x600,0+0-400x400");
101 EXPECT_EQ("0,0 600x600", GetPrimaryDisplay().bounds().ToString());
102 EXPECT_EQ("0,600 400x400", GetSecondaryDisplay().bounds().ToString());
103 EXPECT_EQ("5,605 390x390", GetSecondaryDisplay().work_area().ToString());
104
105 UpdateMonitor("0+0-600x600,0+0-500x500");
106 EXPECT_EQ("0,0 600x600", GetPrimaryDisplay().bounds().ToString());
107 EXPECT_EQ("0,600 500x500", GetSecondaryDisplay().bounds().ToString());
108 EXPECT_EQ("5,605 490x490", GetSecondaryDisplay().work_area().ToString());
109
110 UpdateMonitor("0+0-600x600");
111 EXPECT_EQ("0,0 600x600", GetPrimaryDisplay().bounds().ToString());
112 EXPECT_EQ(1, gfx::Screen::GetNumDisplays());
113
114 UpdateMonitor("0+0-700x700,0+0-1000x1000");
115 ASSERT_EQ(2, gfx::Screen::GetNumDisplays());
116 EXPECT_EQ("0,0 700x700", GetPrimaryDisplay().bounds().ToString());
117 EXPECT_EQ("0,700 1000x1000", GetSecondaryDisplay().bounds().ToString());
118 }
119
120 } // namespace test
121 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698