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

Side by Side Diff: ash/extended_desktop_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/multi_display_manager_unittest.cc ('k') | ash/screen_ash.cc » ('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 "ash/display/display_controller.h" 5 #include "ash/display/display_controller.h"
6 #include "ash/display/multi_display_manager.h" 6 #include "ash/display/multi_display_manager.h"
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 "ash/wm/window_cycle_controller.h" 9 #include "ash/wm/window_cycle_controller.h"
10 #include "ash/wm/window_util.h" 10 #include "ash/wm/window_util.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 EXPECT_EQ(ui::kCursorPointer, root_windows[1]->last_cursor().native_type()); 182 EXPECT_EQ(ui::kCursorPointer, root_windows[1]->last_cursor().native_type());
183 Shell::GetInstance()->SetCursor(ui::kCursorCopy); 183 Shell::GetInstance()->SetCursor(ui::kCursorCopy);
184 EXPECT_EQ(ui::kCursorCopy, root_windows[0]->last_cursor().native_type()); 184 EXPECT_EQ(ui::kCursorCopy, root_windows[0]->last_cursor().native_type());
185 EXPECT_EQ(ui::kCursorCopy, root_windows[1]->last_cursor().native_type()); 185 EXPECT_EQ(ui::kCursorCopy, root_windows[1]->last_cursor().native_type());
186 } 186 }
187 187
188 TEST_F(ExtendedDesktopTest, CycleWindows) { 188 TEST_F(ExtendedDesktopTest, CycleWindows) {
189 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true); 189 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true);
190 UpdateDisplay("0+0-700x500,0+0-500x500"); 190 UpdateDisplay("0+0-700x500,0+0-500x500");
191 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 191 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
192 // Emulate virtual screen coordinate system.
193 root_windows[0]->SetBounds(gfx::Rect(0, 0, 700, 500));
194 root_windows[1]->SetBounds(gfx::Rect(700, 0, 500, 500));
195 192
196 WindowCycleController* controller = 193 WindowCycleController* controller =
197 Shell::GetInstance()->window_cycle_controller(); 194 Shell::GetInstance()->window_cycle_controller();
198 195
199 views::Widget* d1_w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); 196 views::Widget* d1_w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
200 EXPECT_EQ(root_windows[0], d1_w1->GetNativeView()->GetRootWindow()); 197 EXPECT_EQ(root_windows[0], d1_w1->GetNativeView()->GetRootWindow());
201 views::Widget* d2_w1 = CreateTestWidget(gfx::Rect(800, 10, 100, 100)); 198 views::Widget* d2_w1 = CreateTestWidget(gfx::Rect(800, 10, 100, 100));
202 EXPECT_EQ(root_windows[1], d2_w1->GetNativeView()->GetRootWindow()); 199 EXPECT_EQ(root_windows[1], d2_w1->GetNativeView()->GetRootWindow());
203 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); 200 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView()));
204 201
(...skipping 29 matching lines...) Expand all
234 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); 231 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true);
235 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); 232 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView()));
236 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); 233 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true);
237 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView())); 234 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView()));
238 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false); 235 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false);
239 } 236 }
240 237
241 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { 238 TEST_F(ExtendedDesktopTest, GetRootWindowAt) {
242 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true); 239 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true);
243 UpdateDisplay("0+0-700x500,0+0-500x500"); 240 UpdateDisplay("0+0-700x500,0+0-500x500");
241 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout(
242 internal::DisplayController::LEFT);
244 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 243 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
245 // Emulate virtual screen coordinate system.
246 root_windows[0]->SetBounds(gfx::Rect(500, 0, 700, 500));
247 root_windows[1]->SetBounds(gfx::Rect(0, 0, 500, 500));
248 244
249 EXPECT_EQ(root_windows[1], Shell::GetRootWindowAt(gfx::Point(100, 100))); 245 EXPECT_EQ(root_windows[1], Shell::GetRootWindowAt(gfx::Point(-400, 100)));
250 EXPECT_EQ(root_windows[1], Shell::GetRootWindowAt(gfx::Point(499, 100))); 246 EXPECT_EQ(root_windows[1], Shell::GetRootWindowAt(gfx::Point(-1, 100)));
251 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(500, 300))); 247 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(0, 300)));
252 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(1200,300))); 248 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(700,300)));
253 249
254 // Zero origin. 250 // Zero origin.
255 EXPECT_EQ(root_windows[1], Shell::GetRootWindowAt(gfx::Point(0, 0))); 251 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(0, 0)));
256 252
257 // Out of range point should return the primary root window 253 // Out of range point should return the primary root window
258 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(-100, 0))); 254 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(-600, 0)));
259 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(1201, 100))); 255 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(701, 100)));
260 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false); 256 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false);
261 } 257 }
262 258
263 TEST_F(ExtendedDesktopTest, GetRootWindowMatching) { 259 TEST_F(ExtendedDesktopTest, GetRootWindowMatching) {
264 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true); 260 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true);
265 UpdateDisplay("0+0-700x500,0+0-500x500"); 261 UpdateDisplay("0+0-700x500,0+0-500x500");
262 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout(
263 internal::DisplayController::LEFT);
264
266 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 265 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
267 // Emulate virtual screen coordinate system.
268 root_windows[0]->SetBounds(gfx::Rect(500, 0, 700, 500));
269 root_windows[1]->SetBounds(gfx::Rect(0, 0, 500, 500));
270 266
271 // Containing rect. 267 // Containing rect.
272 EXPECT_EQ(root_windows[1], 268 EXPECT_EQ(root_windows[1],
273 Shell::GetRootWindowMatching(gfx::Rect(200, 10, 50, 50))); 269 Shell::GetRootWindowMatching(gfx::Rect(-300, 10, 50, 50)));
274 EXPECT_EQ(root_windows[0], 270 EXPECT_EQ(root_windows[0],
275 Shell::GetRootWindowMatching(gfx::Rect(600, 10, 50, 50))); 271 Shell::GetRootWindowMatching(gfx::Rect(100, 10, 50, 50)));
276 272
277 // Intersecting rect. 273 // Intersecting rect.
278 EXPECT_EQ(root_windows[1], 274 EXPECT_EQ(root_windows[1],
279 Shell::GetRootWindowMatching(gfx::Rect(300, 0, 300, 300))); 275 Shell::GetRootWindowMatching(gfx::Rect(-200, 0, 300, 300)));
280 EXPECT_EQ(root_windows[0], 276 EXPECT_EQ(root_windows[0],
281 Shell::GetRootWindowMatching(gfx::Rect(400, 0, 300, 300))); 277 Shell::GetRootWindowMatching(gfx::Rect(-100, 0, 300, 300)));
282 278
283 // Zero origin. 279 // Zero origin.
284 EXPECT_EQ(root_windows[1], 280 EXPECT_EQ(root_windows[0],
285 Shell::GetRootWindowMatching(gfx::Rect(0, 0, 0, 0))); 281 Shell::GetRootWindowMatching(gfx::Rect(0, 0, 0, 0)));
286 EXPECT_EQ(root_windows[1], 282 EXPECT_EQ(root_windows[0],
287 Shell::GetRootWindowMatching(gfx::Rect(0, 0, 1, 1))); 283 Shell::GetRootWindowMatching(gfx::Rect(0, 0, 1, 1)));
288 284
289 // Empty rect. 285 // Empty rect.
290 EXPECT_EQ(root_windows[1], 286 EXPECT_EQ(root_windows[1],
287 Shell::GetRootWindowMatching(gfx::Rect(-400, 100, 0, 0)));
288 EXPECT_EQ(root_windows[0],
291 Shell::GetRootWindowMatching(gfx::Rect(100, 100, 0, 0))); 289 Shell::GetRootWindowMatching(gfx::Rect(100, 100, 0, 0)));
292 EXPECT_EQ(root_windows[0],
293 Shell::GetRootWindowMatching(gfx::Rect(600, 100, 0, 0)));
294 290
295 // Out of range rect should return the primary root window. 291 // Out of range rect should return the primary root window.
296 EXPECT_EQ(root_windows[0], 292 EXPECT_EQ(root_windows[0],
297 Shell::GetRootWindowMatching(gfx::Rect(-100, -300, 50, 50))); 293 Shell::GetRootWindowMatching(gfx::Rect(-600, -300, 50, 50)));
298 EXPECT_EQ(root_windows[0], 294 EXPECT_EQ(root_windows[0],
299 Shell::GetRootWindowMatching(gfx::Rect(0, 2000, 50, 50))); 295 Shell::GetRootWindowMatching(gfx::Rect(0, 1000, 50, 50)));
300 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false); 296 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false);
301 } 297 }
302 298
303 TEST_F(ExtendedDesktopTest, Capture) { 299 TEST_F(ExtendedDesktopTest, Capture) {
304 UpdateDisplay("0+0-1000x600,1001+0-600x400"); 300 UpdateDisplay("0+0-1000x600,1001+0-600x400");
305 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 301 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
306 302
307 aura::test::EventCountDelegate r1_d1; 303 aura::test::EventCountDelegate r1_d1;
308 aura::test::EventCountDelegate r1_d2; 304 aura::test::EventCountDelegate r1_d2;
309 aura::test::EventCountDelegate r2_d1; 305 aura::test::EventCountDelegate r2_d1;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 // Convert point in the Root1's window to the Root2's window Coord. 380 // Convert point in the Root1's window to the Root2's window Coord.
385 p.SetPoint(0, 0); 381 p.SetPoint(0, 0);
386 aura::Window::ConvertPointToWindow(root_windows[0], root_windows[1], &p); 382 aura::Window::ConvertPointToWindow(root_windows[0], root_windows[1], &p);
387 EXPECT_EQ("-500,-500", p.ToString()); 383 EXPECT_EQ("-500,-500", p.ToString());
388 p.SetPoint(0, 0); 384 p.SetPoint(0, 0);
389 aura::Window::ConvertPointToWindow(d1, d2, &p); 385 aura::Window::ConvertPointToWindow(d1, d2, &p);
390 EXPECT_EQ("-510,-510", p.ToString()); 386 EXPECT_EQ("-510,-510", p.ToString());
391 } 387 }
392 } // namespace internal 388 } // namespace internal
393 } // namespace ash 389 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/multi_display_manager_unittest.cc ('k') | ash/screen_ash.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698