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

Side by Side Diff: ash/display/display_controller_unittest.cc

Issue 10870036: Allow storing display preferences per device. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 3 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
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 "ash/display/display_controller.h" 5 #include "ash/display/display_controller.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/test/ash_test_base.h" 8 #include "ash/test/ash_test_base.h"
9 #include "ui/aura/display_manager.h" 9 #include "ui/aura/display_manager.h"
10 #include "ui/aura/env.h" 10 #include "ui/aura/env.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 gfx::Insets insets(5, 5, 5, 5); 45 gfx::Insets insets(5, 5, 5, 5);
46 secondary_display->UpdateWorkAreaFromInsets(insets); 46 secondary_display->UpdateWorkAreaFromInsets(insets);
47 47
48 // Default layout is LEFT. 48 // Default layout is LEFT.
49 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); 49 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString());
50 EXPECT_EQ("500,0 400x400", GetSecondaryDisplay().bounds().ToString()); 50 EXPECT_EQ("500,0 400x400", GetSecondaryDisplay().bounds().ToString());
51 EXPECT_EQ("505,5 390x390", GetSecondaryDisplay().work_area().ToString()); 51 EXPECT_EQ("505,5 390x390", GetSecondaryDisplay().work_area().ToString());
52 52
53 // Layout the secondary display to the bottom of the primary. 53 // Layout the secondary display to the bottom of the primary.
54 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( 54 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout(
55 internal::DisplayController::BOTTOM); 55 internal::DisplayLayout::BOTTOM);
56 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); 56 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString());
57 EXPECT_EQ("0,500 400x400", GetSecondaryDisplay().bounds().ToString()); 57 EXPECT_EQ("0,500 400x400", GetSecondaryDisplay().bounds().ToString());
58 EXPECT_EQ("5,505 390x390", GetSecondaryDisplay().work_area().ToString()); 58 EXPECT_EQ("5,505 390x390", GetSecondaryDisplay().work_area().ToString());
59 59
60 // Layout the secondary display to the left of the primary. 60 // Layout the secondary display to the left of the primary.
61 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( 61 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout(
62 internal::DisplayController::LEFT); 62 internal::DisplayLayout::LEFT);
63 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); 63 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString());
64 EXPECT_EQ("-400,0 400x400", GetSecondaryDisplay().bounds().ToString()); 64 EXPECT_EQ("-400,0 400x400", GetSecondaryDisplay().bounds().ToString());
65 EXPECT_EQ("-395,5 390x390", GetSecondaryDisplay().work_area().ToString()); 65 EXPECT_EQ("-395,5 390x390", GetSecondaryDisplay().work_area().ToString());
66 66
67 // Layout the secondary display to the top of the primary. 67 // Layout the secondary display to the top of the primary.
68 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( 68 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout(
69 internal::DisplayController::TOP); 69 internal::DisplayLayout::TOP);
70 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); 70 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString());
71 EXPECT_EQ("0,-400 400x400", GetSecondaryDisplay().bounds().ToString()); 71 EXPECT_EQ("0,-400 400x400", GetSecondaryDisplay().bounds().ToString());
72 EXPECT_EQ("5,-395 390x390", GetSecondaryDisplay().work_area().ToString()); 72 EXPECT_EQ("5,-395 390x390", GetSecondaryDisplay().work_area().ToString());
73 } 73 }
74 74
75 // TODO(oshima,erg): I suspect this test is now failing because I've changed 75 // TODO(oshima,erg): I suspect this test is now failing because I've changed
76 // the timing of the RootWindow::Show to be synchronous. If true, this test has 76 // the timing of the RootWindow::Show to be synchronous. If true, this test has
77 // always been incorrect, but is now visibly broken now that we're processing 77 // always been incorrect, but is now visibly broken now that we're processing
78 // X11 configuration events while waiting for the MapNotify. 78 // X11 configuration events while waiting for the MapNotify.
79 TEST_F(DisplayControllerTest, DISABLED_BoundsUpdated) { 79 TEST_F(DisplayControllerTest, DISABLED_BoundsUpdated) {
80 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( 80 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout(
81 internal::DisplayController::BOTTOM); 81 internal::DisplayLayout::BOTTOM);
82 UpdateDisplay("500x500,400x400"); 82 UpdateDisplay("500x500,400x400");
83 gfx::Display* secondary_display = 83 gfx::Display* secondary_display =
84 aura::Env::GetInstance()->display_manager()->GetDisplayAt(1); 84 aura::Env::GetInstance()->display_manager()->GetDisplayAt(1);
85 gfx::Insets insets(5, 5, 5, 5); 85 gfx::Insets insets(5, 5, 5, 5);
86 secondary_display->UpdateWorkAreaFromInsets(insets); 86 secondary_display->UpdateWorkAreaFromInsets(insets);
87 87
88 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); 88 EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString());
89 EXPECT_EQ("0,500 400x400", GetSecondaryDisplay().bounds().ToString()); 89 EXPECT_EQ("0,500 400x400", GetSecondaryDisplay().bounds().ToString());
90 EXPECT_EQ("5,505 390x390", GetSecondaryDisplay().work_area().ToString()); 90 EXPECT_EQ("5,505 390x390", GetSecondaryDisplay().work_area().ToString());
91 91
(...skipping 17 matching lines...) Expand all
109 EXPECT_EQ("0,700 1000x1000", GetSecondaryDisplay().bounds().ToString()); 109 EXPECT_EQ("0,700 1000x1000", GetSecondaryDisplay().bounds().ToString());
110 } 110 }
111 111
112 // Verifies if the mouse pointer correctly moves to another display when there 112 // Verifies if the mouse pointer correctly moves to another display when there
113 // are two displays. 113 // are two displays.
114 TEST_F(DisplayControllerTest, WarpMouse) { 114 TEST_F(DisplayControllerTest, WarpMouse) {
115 UpdateDisplay("500x500,500x500"); 115 UpdateDisplay("500x500,500x500");
116 116
117 ash::internal::DisplayController* controller = 117 ash::internal::DisplayController* controller =
118 Shell::GetInstance()->display_controller(); 118 Shell::GetInstance()->display_controller();
119 EXPECT_EQ(internal::DisplayController::RIGHT, 119 EXPECT_EQ(internal::DisplayLayout::RIGHT,
120 controller->secondary_display_layout()); 120 controller->secondary_display_layout());
121 121
122 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 122 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
123 bool is_warped = controller->WarpMouseCursorIfNecessary(root_windows[0], 123 bool is_warped = controller->WarpMouseCursorIfNecessary(root_windows[0],
124 gfx::Point(11, 11)); 124 gfx::Point(11, 11));
125 EXPECT_FALSE(is_warped); 125 EXPECT_FALSE(is_warped);
126 is_warped = controller->WarpMouseCursorIfNecessary(root_windows[1], 126 is_warped = controller->WarpMouseCursorIfNecessary(root_windows[1],
127 gfx::Point(11, 11)); 127 gfx::Point(11, 11));
128 EXPECT_FALSE(is_warped); 128 EXPECT_FALSE(is_warped);
129 129
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 EXPECT_FALSE(is_warped); 167 EXPECT_FALSE(is_warped);
168 } 168 }
169 169
170 // Verifies if the mouse pointer correctly moves to another display even when 170 // Verifies if the mouse pointer correctly moves to another display even when
171 // two displays are not the same size. 171 // two displays are not the same size.
172 TEST_F(DisplayControllerTest, WarpMouseDifferentSizeDisplays) { 172 TEST_F(DisplayControllerTest, WarpMouseDifferentSizeDisplays) {
173 UpdateDisplay("500x500,600x600"); // the second one is larger. 173 UpdateDisplay("500x500,600x600"); // the second one is larger.
174 174
175 ash::internal::DisplayController* controller = 175 ash::internal::DisplayController* controller =
176 Shell::GetInstance()->display_controller(); 176 Shell::GetInstance()->display_controller();
177 EXPECT_EQ(internal::DisplayController::RIGHT, 177 EXPECT_EQ(internal::DisplayLayout::RIGHT,
178 controller->secondary_display_layout()); 178 controller->secondary_display_layout());
179 179
180 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 180 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
181 aura::Env::GetInstance()->SetLastMouseLocation(*root_windows[1], 181 aura::Env::GetInstance()->SetLastMouseLocation(*root_windows[1],
182 gfx::Point(123, 123)); 182 gfx::Point(123, 123));
183 183
184 // Touch the left edge of the secondary root window. Pointer should NOT warp 184 // Touch the left edge of the secondary root window. Pointer should NOT warp
185 // because 1px left of (0, 500) is outside the primary root window. 185 // because 1px left of (0, 500) is outside the primary root window.
186 bool is_warped = controller->WarpMouseCursorIfNecessary(root_windows[1], 186 bool is_warped = controller->WarpMouseCursorIfNecessary(root_windows[1],
187 gfx::Point(0, 500)); 187 gfx::Point(0, 500));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 controller->set_dont_warp_mouse(false); 219 controller->set_dont_warp_mouse(false);
220 is_warped = controller->WarpMouseCursorIfNecessary(root_windows[0], 220 is_warped = controller->WarpMouseCursorIfNecessary(root_windows[0],
221 gfx::Point(499, 11)); 221 gfx::Point(499, 11));
222 EXPECT_TRUE(is_warped); 222 EXPECT_TRUE(is_warped);
223 EXPECT_EQ("501,11", 223 EXPECT_EQ("501,11",
224 aura::Env::GetInstance()->last_mouse_location().ToString()); 224 aura::Env::GetInstance()->last_mouse_location().ToString());
225 } 225 }
226 226
227 } // namespace test 227 } // namespace test
228 } // namespace ash 228 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698