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

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

Issue 10855068: Add more test to DisplayControllerTest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 8 years, 4 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 | « no previous file | no next file » | 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 "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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // Touch the top edge of the secondary root window. 156 // Touch the top edge of the secondary root window.
157 is_warped = controller->WarpMouseCursorIfNecessary(root_windows[1], 157 is_warped = controller->WarpMouseCursorIfNecessary(root_windows[1],
158 gfx::Point(11, 0)); 158 gfx::Point(11, 0));
159 EXPECT_FALSE(is_warped); 159 EXPECT_FALSE(is_warped);
160 // Touch the bottom edge of the secondary root window. 160 // Touch the bottom edge of the secondary root window.
161 is_warped = controller->WarpMouseCursorIfNecessary(root_windows[1], 161 is_warped = controller->WarpMouseCursorIfNecessary(root_windows[1],
162 gfx::Point(11, 499)); 162 gfx::Point(11, 499));
163 EXPECT_FALSE(is_warped); 163 EXPECT_FALSE(is_warped);
164 } 164 }
165 165
166 TEST_F(DisplayControllerTest, WarpMouseDifferentSizeDisplays) {
sky 2012/08/09 16:24:05 Add a brief description to all of these as to what
Yusuke Sato 2012/08/09 18:13:31 Done.
167 UpdateDisplay("500x500,600x600"); // the second one is larger.
168
169 ash::internal::DisplayController* controller =
170 Shell::GetInstance()->display_controller();
171 EXPECT_EQ(internal::DisplayController::RIGHT,
172 controller->secondary_display_layout());
173
174 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
175 aura::Env::GetInstance()->SetLastMouseLocation(*root_windows[1],
176 gfx::Point(123, 123));
177
178 // Touch the left edge of the secondary root window. Pointer should NOT warp
179 // because 1px left of (0, 500) is outside the primary root window.
180 bool is_warped = controller->WarpMouseCursorIfNecessary(root_windows[1],
181 gfx::Point(0, 500));
182 EXPECT_FALSE(is_warped);
183 EXPECT_EQ("623,123", // by 2px.
184 aura::Env::GetInstance()->last_mouse_location().ToString());
185
186 // Touch the left edge of the secondary root window. Pointer should warp
187 // because 1px left of (0, 499) is inside the primary root window.
188 is_warped = controller->WarpMouseCursorIfNecessary(root_windows[1],
189 gfx::Point(0, 499));
190 EXPECT_TRUE(is_warped);
191 EXPECT_EQ("498,499", // by 2px.
192 aura::Env::GetInstance()->last_mouse_location().ToString());
193 }
194
166 TEST_F(DisplayControllerTest, SetUnsetDontWarpMousedFlag) { 195 TEST_F(DisplayControllerTest, SetUnsetDontWarpMousedFlag) {
167 UpdateDisplay("500x500,500x500"); 196 UpdateDisplay("500x500,500x500");
168 197
169 ash::internal::DisplayController* controller = 198 ash::internal::DisplayController* controller =
170 Shell::GetInstance()->display_controller(); 199 Shell::GetInstance()->display_controller();
171 200
172 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 201 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
173 aura::Env::GetInstance()->SetLastMouseLocation(*root_windows[0], 202 aura::Env::GetInstance()->SetLastMouseLocation(*root_windows[0],
174 gfx::Point(1, 1)); 203 gfx::Point(1, 1));
175 204
176 controller->set_dont_warp_mouse(true); 205 controller->set_dont_warp_mouse(true);
177 bool is_warped = controller->WarpMouseCursorIfNecessary(root_windows[0], 206 bool is_warped = controller->WarpMouseCursorIfNecessary(root_windows[0],
178 gfx::Point(499, 11)); 207 gfx::Point(499, 11));
179 EXPECT_FALSE(is_warped); 208 EXPECT_FALSE(is_warped);
180 EXPECT_EQ("1,1", 209 EXPECT_EQ("1,1",
181 aura::Env::GetInstance()->last_mouse_location().ToString()); 210 aura::Env::GetInstance()->last_mouse_location().ToString());
182 211
183 controller->set_dont_warp_mouse(false); 212 controller->set_dont_warp_mouse(false);
184 is_warped = controller->WarpMouseCursorIfNecessary(root_windows[0], 213 is_warped = controller->WarpMouseCursorIfNecessary(root_windows[0],
185 gfx::Point(499, 11)); 214 gfx::Point(499, 11));
186 EXPECT_TRUE(is_warped); 215 EXPECT_TRUE(is_warped);
187 EXPECT_EQ("501,11", 216 EXPECT_EQ("501,11",
188 aura::Env::GetInstance()->last_mouse_location().ToString()); 217 aura::Env::GetInstance()->last_mouse_location().ToString());
189 } 218 }
190 219
191 } // namespace test 220 } // namespace test
192 } // namespace ash 221 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698