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

Side by Side Diff: ash/display/display_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: sync 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
« no previous file with comments | « ash/display/display_controller.cc ('k') | ash/display/multi_display_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/display/display_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/display_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 DisplayControllerTest : public test::AshTestBase {
33 public:
34 DisplayControllerTest() {}
35 virtual ~DisplayControllerTest() {}
36
37 virtual void SetUp() OVERRIDE {
38 internal::DisplayController::SetExtendedDesktopEnabled(true);
39 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true);
40 AshTestBase::SetUp();
41 }
42
43 virtual void TearDown() OVERRIDE {
44 AshTestBase::TearDown();
45 internal::DisplayController::SetExtendedDesktopEnabled(false);
46 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false);
47 }
48
49 private:
50 DISALLOW_COPY_AND_ASSIGN(DisplayControllerTest);
51 };
52
53 #if defined(OS_WIN)
54 // TOD(oshima): Windows creates a window with smaller client area.
55 // Fix this and enable tests.
56 #define MAYBE_SecondaryDisplayLayout DISABLED_SecondaryDisplayLayout
57 #define MAYBE_BoundsUpdated DISABLED_BoundsUpdated
58 #else
59 #define MAYBE_SecondaryDisplayLayout SecondaryDisplayLayout
60 #define MAYBE_BoundsUpdated BoundsUpdated
61 #endif
62
63 TEST_F(DisplayControllerTest, MAYBE_SecondaryDisplayLayout) {
64 UpdateDisplay("0+0-500x500,0+0-400x400");
65 gfx::Display* secondary_display =
66 aura::Env::GetInstance()->display_manager()->GetDisplayAt(1);
67 gfx::Insets insets(5, 5, 5, 5);
68 secondary_display->UpdateWorkAreaFromInsets(insets);
69
70 // Default layout is LEFT.
71 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString());
72 EXPECT_EQ("500,0 400x400", GetSecondaryDisplay().bounds().ToString());
73 EXPECT_EQ("505,5 390x390", GetSecondaryDisplay().work_area().ToString());
74
75 // Layout the secondary display to the bottom of the primary.
76 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout(
77 internal::DisplayController::BOTTOM);
78 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString());
79 EXPECT_EQ("0,500 400x400", GetSecondaryDisplay().bounds().ToString());
80 EXPECT_EQ("5,505 390x390", GetSecondaryDisplay().work_area().ToString());
81
82 // Layout the secondary display to the left of the primary.
83 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout(
84 internal::DisplayController::LEFT);
85 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString());
86 EXPECT_EQ("-400,0 400x400", GetSecondaryDisplay().bounds().ToString());
87 EXPECT_EQ("-395,5 390x390", GetSecondaryDisplay().work_area().ToString());
88
89 // Layout the secondary display to the top of the primary.
90 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout(
91 internal::DisplayController::TOP);
92 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString());
93 EXPECT_EQ("0,-400 400x400", GetSecondaryDisplay().bounds().ToString());
94 EXPECT_EQ("5,-395 390x390", GetSecondaryDisplay().work_area().ToString());
95 }
96
97 TEST_F(DisplayControllerTest, MAYBE_BoundsUpdated) {
98 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout(
99 internal::DisplayController::BOTTOM);
100 UpdateDisplay("0+0-500x500,0+0-400x400");
101 gfx::Display* secondary_display =
102 aura::Env::GetInstance()->display_manager()->GetDisplayAt(1);
103 gfx::Insets insets(5, 5, 5, 5);
104 secondary_display->UpdateWorkAreaFromInsets(insets);
105
106 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString());
107 EXPECT_EQ("0,500 400x400", GetSecondaryDisplay().bounds().ToString());
108 EXPECT_EQ("5,505 390x390", GetSecondaryDisplay().work_area().ToString());
109
110 UpdateDisplay("0+0-600x600,0+0-400x400");
111 EXPECT_EQ("0,0 600x600", GetPrimaryDisplay().bounds().ToString());
112 EXPECT_EQ("0,600 400x400", GetSecondaryDisplay().bounds().ToString());
113 EXPECT_EQ("5,605 390x390", GetSecondaryDisplay().work_area().ToString());
114
115 UpdateDisplay("0+0-600x600,0+0-500x500");
116 EXPECT_EQ("0,0 600x600", GetPrimaryDisplay().bounds().ToString());
117 EXPECT_EQ("0,600 500x500", GetSecondaryDisplay().bounds().ToString());
118 EXPECT_EQ("5,605 490x490", GetSecondaryDisplay().work_area().ToString());
119
120 UpdateDisplay("0+0-600x600");
121 EXPECT_EQ("0,0 600x600", GetPrimaryDisplay().bounds().ToString());
122 EXPECT_EQ(1, gfx::Screen::GetNumDisplays());
123
124 UpdateDisplay("0+0-700x700,0+0-1000x1000");
125 ASSERT_EQ(2, gfx::Screen::GetNumDisplays());
126 EXPECT_EQ("0,0 700x700", GetPrimaryDisplay().bounds().ToString());
127 EXPECT_EQ("0,700 1000x1000", GetSecondaryDisplay().bounds().ToString());
128 }
129
130 } // namespace test
131 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_controller.cc ('k') | ash/display/multi_display_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698