OLD | NEW |
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/wm/toplevel_window_event_handler.h" | 5 #include "ash/wm/toplevel_window_event_handler.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 "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
10 #include "ash/wm/workspace/snap_sizer.h" | 10 #include "ash/wm/workspace/snap_sizer.h" |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 323 |
324 // Simulate a large bottom-right to top-left drag. Window size should be | 324 // Simulate a large bottom-right to top-left drag. Window size should be |
325 // clamped to minimum and position should not change. | 325 // clamped to minimum and position should not change. |
326 DragFromCenterBy(w1.get(), -333, -444); | 326 DragFromCenterBy(w1.get(), -333, -444); |
327 EXPECT_EQ(position, w1->bounds().origin()); | 327 EXPECT_EQ(position, w1->bounds().origin()); |
328 EXPECT_EQ(gfx::Size(40, 40), w1->bounds().size()); | 328 EXPECT_EQ(gfx::Size(40, 40), w1->bounds().size()); |
329 } | 329 } |
330 | 330 |
331 TEST_F(ToplevelWindowEventHandlerTest, BottomRightWorkArea) { | 331 TEST_F(ToplevelWindowEventHandlerTest, BottomRightWorkArea) { |
332 scoped_ptr<aura::Window> target(CreateWindow(HTBOTTOMRIGHT)); | 332 scoped_ptr<aura::Window> target(CreateWindow(HTBOTTOMRIGHT)); |
333 gfx::Rect work_area = | 333 gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow( |
334 gfx::Screen::GetDisplayNearestWindow(target.get()).work_area(); | 334 target.get()).work_area(); |
335 gfx::Point position = target->bounds().origin(); | 335 gfx::Point position = target->bounds().origin(); |
336 // Drag further than work_area bottom. | 336 // Drag further than work_area bottom. |
337 DragFromCenterBy(target.get(), 100, work_area.height()); | 337 DragFromCenterBy(target.get(), 100, work_area.height()); |
338 // Position should not have changed. | 338 // Position should not have changed. |
339 EXPECT_EQ(position, target->bounds().origin()); | 339 EXPECT_EQ(position, target->bounds().origin()); |
340 // Size should have increased by 100, work_area.height() - target->bounds.y() | 340 // Size should have increased by 100, work_area.height() - target->bounds.y() |
341 EXPECT_EQ(gfx::Size(200, work_area.height() - target->bounds().y()), | 341 EXPECT_EQ(gfx::Size(200, work_area.height() - target->bounds().y()), |
342 target->bounds().size()); | 342 target->bounds().size()); |
343 } | 343 } |
344 | 344 |
345 TEST_F(ToplevelWindowEventHandlerTest, BottomLeftWorkArea) { | 345 TEST_F(ToplevelWindowEventHandlerTest, BottomLeftWorkArea) { |
346 scoped_ptr<aura::Window> target(CreateWindow(HTBOTTOMLEFT)); | 346 scoped_ptr<aura::Window> target(CreateWindow(HTBOTTOMLEFT)); |
347 gfx::Rect work_area = | 347 gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow( |
348 gfx::Screen::GetDisplayNearestWindow(target.get()).work_area(); | 348 target.get()).work_area(); |
349 gfx::Point position = target->bounds().origin(); | 349 gfx::Point position = target->bounds().origin(); |
350 // Drag further than work_area bottom. | 350 // Drag further than work_area bottom. |
351 DragFromCenterBy(target.get(), -30, work_area.height()); | 351 DragFromCenterBy(target.get(), -30, work_area.height()); |
352 // origin is now at 70, 100. | 352 // origin is now at 70, 100. |
353 EXPECT_EQ(position.x() - 30, target->bounds().x()); | 353 EXPECT_EQ(position.x() - 30, target->bounds().x()); |
354 EXPECT_EQ(position.y(), target->bounds().y()); | 354 EXPECT_EQ(position.y(), target->bounds().y()); |
355 // Size should have increased by 30, work_area.height() - target->bounds.y() | 355 // Size should have increased by 30, work_area.height() - target->bounds.y() |
356 EXPECT_EQ(gfx::Size(130, work_area.height() - target->bounds().y()), | 356 EXPECT_EQ(gfx::Size(130, work_area.height() - target->bounds().y()), |
357 target->bounds().size()); | 357 target->bounds().size()); |
358 } | 358 } |
359 | 359 |
360 TEST_F(ToplevelWindowEventHandlerTest, BottomWorkArea) { | 360 TEST_F(ToplevelWindowEventHandlerTest, BottomWorkArea) { |
361 scoped_ptr<aura::Window> target(CreateWindow(HTBOTTOM)); | 361 scoped_ptr<aura::Window> target(CreateWindow(HTBOTTOM)); |
362 gfx::Rect work_area = | 362 gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow( |
363 gfx::Screen::GetDisplayNearestWindow(target.get()).work_area(); | 363 target.get()).work_area(); |
364 gfx::Point position = target->bounds().origin(); | 364 gfx::Point position = target->bounds().origin(); |
365 // Drag further than work_area bottom. | 365 // Drag further than work_area bottom. |
366 DragFromCenterBy(target.get(), 0, work_area.height()); | 366 DragFromCenterBy(target.get(), 0, work_area.height()); |
367 // Position should not have changed. | 367 // Position should not have changed. |
368 EXPECT_EQ(position, target->bounds().origin()); | 368 EXPECT_EQ(position, target->bounds().origin()); |
369 // Size should have increased by 0, work_area.height() - target->bounds.y() | 369 // Size should have increased by 0, work_area.height() - target->bounds.y() |
370 EXPECT_EQ(gfx::Size(100, work_area.height() - target->bounds().y()), | 370 EXPECT_EQ(gfx::Size(100, work_area.height() - target->bounds().y()), |
371 target->bounds().size()); | 371 target->bounds().size()); |
372 } | 372 } |
373 | 373 |
374 // Verifies we don't let windows drag to a -y location. | 374 // Verifies we don't let windows drag to a -y location. |
375 TEST_F(ToplevelWindowEventHandlerTest, DontDragToNegativeY) { | 375 TEST_F(ToplevelWindowEventHandlerTest, DontDragToNegativeY) { |
376 scoped_ptr<aura::Window> target(CreateWindow(HTTOP)); | 376 scoped_ptr<aura::Window> target(CreateWindow(HTTOP)); |
377 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 377 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
378 target.get()); | 378 target.get()); |
379 generator.MoveMouseTo(0, 5); | 379 generator.MoveMouseTo(0, 5); |
380 generator.DragMouseBy(0, -5); | 380 generator.DragMouseBy(0, -5); |
381 // The y location and height should not have changed. | 381 // The y location and height should not have changed. |
382 EXPECT_EQ(0, target->bounds().y()); | 382 EXPECT_EQ(0, target->bounds().y()); |
383 EXPECT_EQ(100, target->bounds().height()); | 383 EXPECT_EQ(100, target->bounds().height()); |
384 } | 384 } |
385 | 385 |
386 // Verifies we don't let windows go bigger than the display width. | 386 // Verifies we don't let windows go bigger than the display width. |
387 TEST_F(ToplevelWindowEventHandlerTest, DontGotWiderThanScreen) { | 387 TEST_F(ToplevelWindowEventHandlerTest, DontGotWiderThanScreen) { |
388 scoped_ptr<aura::Window> target(CreateWindow(HTRIGHT)); | 388 scoped_ptr<aura::Window> target(CreateWindow(HTRIGHT)); |
389 gfx::Rect work_area = | 389 gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow( |
390 gfx::Screen::GetDisplayNearestWindow(target.get()).bounds(); | 390 target.get()).bounds(); |
391 DragFromCenterBy(target.get(), work_area.width() * 2, 0); | 391 DragFromCenterBy(target.get(), work_area.width() * 2, 0); |
392 // The y location and height should not have changed. | 392 // The y location and height should not have changed. |
393 EXPECT_EQ(work_area.width(), target->bounds().width()); | 393 EXPECT_EQ(work_area.width(), target->bounds().width()); |
394 } | 394 } |
395 | 395 |
396 // Verifies that touch-gestures drag the window correctly. | 396 // Verifies that touch-gestures drag the window correctly. |
397 TEST_F(ToplevelWindowEventHandlerTest, GestureDrag) { | 397 TEST_F(ToplevelWindowEventHandlerTest, GestureDrag) { |
398 scoped_ptr<aura::Window> target(CreateWindow(HTCAPTION)); | 398 scoped_ptr<aura::Window> target(CreateWindow(HTCAPTION)); |
399 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 399 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
400 target.get()); | 400 target.get()); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 | 482 |
483 EXPECT_EQ("0,0 110x111", target->bounds().ToString()); | 483 EXPECT_EQ("0,0 110x111", target->bounds().ToString()); |
484 generator.PressKey(ui::VKEY_ESCAPE, 0); | 484 generator.PressKey(ui::VKEY_ESCAPE, 0); |
485 generator.ReleaseKey(ui::VKEY_ESCAPE, 0); | 485 generator.ReleaseKey(ui::VKEY_ESCAPE, 0); |
486 EXPECT_EQ("0,0 100x100", target->bounds().ToString()); | 486 EXPECT_EQ("0,0 100x100", target->bounds().ToString()); |
487 aura::client::SetActivationClient(root, original_client); | 487 aura::client::SetActivationClient(root, original_client); |
488 } | 488 } |
489 | 489 |
490 } // namespace test | 490 } // namespace test |
491 } // namespace ash | 491 } // namespace ash |
OLD | NEW |