| 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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 | 397 |
| 398 // Verifies that touch-gestures drag the window correctly. | 398 // Verifies that touch-gestures drag the window correctly. |
| 399 TEST_F(ToplevelWindowEventHandlerTest, GestureDrag) { | 399 TEST_F(ToplevelWindowEventHandlerTest, GestureDrag) { |
| 400 scoped_ptr<aura::Window> target(CreateWindow(HTCAPTION)); | 400 scoped_ptr<aura::Window> target(CreateWindow(HTCAPTION)); |
| 401 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 401 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 402 target.get()); | 402 target.get()); |
| 403 gfx::Rect old_bounds = target->bounds(); | 403 gfx::Rect old_bounds = target->bounds(); |
| 404 gfx::Point location(5, 5); | 404 gfx::Point location(5, 5); |
| 405 target->SetProperty(aura::client::kCanMaximizeKey, true); | 405 target->SetProperty(aura::client::kCanMaximizeKey, true); |
| 406 | 406 |
| 407 gfx::Point end = location; |
| 408 |
| 407 // Snap right; | 409 // Snap right; |
| 408 gfx::Point end = location; | |
| 409 end.Offset(100, 0); | |
| 410 generator.GestureScrollSequence(location, end, | |
| 411 base::TimeDelta::FromMilliseconds(5), | |
| 412 10); | |
| 413 RunAllPendingInMessageLoop(); | |
| 414 | |
| 415 // Verify that the window has moved after the gesture. | |
| 416 EXPECT_NE(old_bounds.ToString(), target->bounds().ToString()); | |
| 417 { | 410 { |
| 411 // Get the expected snapped bounds before snapping. |
| 418 internal::SnapSizer sizer(target.get(), location, | 412 internal::SnapSizer sizer(target.get(), location, |
| 419 internal::SnapSizer::RIGHT_EDGE, | 413 internal::SnapSizer::RIGHT_EDGE, |
| 420 internal::SnapSizer::OTHER_INPUT); | 414 internal::SnapSizer::OTHER_INPUT); |
| 421 EXPECT_EQ(sizer.target_bounds().ToString(), target->bounds().ToString()); | 415 gfx::Rect snapped_bounds = sizer.GetSnapBounds(target->bounds()); |
| 416 |
| 417 end.Offset(100, 0); |
| 418 generator.GestureScrollSequence(location, end, |
| 419 base::TimeDelta::FromMilliseconds(5), |
| 420 10); |
| 421 RunAllPendingInMessageLoop(); |
| 422 |
| 423 // Verify that the window has moved after the gesture. |
| 424 EXPECT_NE(old_bounds.ToString(), target->bounds().ToString()); |
| 425 EXPECT_EQ(snapped_bounds.ToString(), target->bounds().ToString()); |
| 422 } | 426 } |
| 423 | 427 |
| 424 old_bounds = target->bounds(); | 428 old_bounds = target->bounds(); |
| 425 | 429 |
| 426 // Snap left. | 430 // Snap left. |
| 427 end = location = target->GetBoundsInRootWindow().CenterPoint(); | |
| 428 end.Offset(-100, 0); | |
| 429 generator.GestureScrollSequence(location, end, | |
| 430 base::TimeDelta::FromMilliseconds(5), | |
| 431 10); | |
| 432 RunAllPendingInMessageLoop(); | |
| 433 | |
| 434 EXPECT_NE(old_bounds.ToString(), target->bounds().ToString()); | |
| 435 { | 431 { |
| 432 // Get the expected snapped bounds before snapping. |
| 436 internal::SnapSizer sizer(target.get(), location, | 433 internal::SnapSizer sizer(target.get(), location, |
| 437 internal::SnapSizer::LEFT_EDGE, | 434 internal::SnapSizer::LEFT_EDGE, |
| 438 internal::SnapSizer::OTHER_INPUT); | 435 internal::SnapSizer::OTHER_INPUT); |
| 439 EXPECT_EQ(sizer.target_bounds().ToString(), target->bounds().ToString()); | 436 gfx::Rect snapped_bounds = sizer.GetSnapBounds(target->bounds()); |
| 437 end = location = target->GetBoundsInRootWindow().CenterPoint(); |
| 438 end.Offset(-100, 0); |
| 439 generator.GestureScrollSequence(location, end, |
| 440 base::TimeDelta::FromMilliseconds(5), |
| 441 10); |
| 442 RunAllPendingInMessageLoop(); |
| 443 |
| 444 EXPECT_NE(old_bounds.ToString(), target->bounds().ToString()); |
| 445 EXPECT_EQ(snapped_bounds.ToString(), target->bounds().ToString()); |
| 440 } | 446 } |
| 441 | 447 |
| 442 old_bounds = target->bounds(); | 448 old_bounds = target->bounds(); |
| 443 // Maximize. | 449 // Maximize. |
| 444 end = location = target->GetBoundsInRootWindow().CenterPoint(); | 450 end = location = target->GetBoundsInRootWindow().CenterPoint(); |
| 445 end.Offset(0, -100); | 451 end.Offset(0, -100); |
| 446 generator.GestureScrollSequence(location, end, | 452 generator.GestureScrollSequence(location, end, |
| 447 base::TimeDelta::FromMilliseconds(5), | 453 base::TimeDelta::FromMilliseconds(5), |
| 448 10); | 454 10); |
| 449 RunAllPendingInMessageLoop(); | 455 RunAllPendingInMessageLoop(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 | 536 |
| 531 generator.PressLeftButton(); | 537 generator.PressLeftButton(); |
| 532 generator.MoveMouseBy(10, 11); | 538 generator.MoveMouseBy(10, 11); |
| 533 RunAllPendingInMessageLoop(); | 539 RunAllPendingInMessageLoop(); |
| 534 EXPECT_EQ("10,11 100x100", target->bounds().ToString()); | 540 EXPECT_EQ("10,11 100x100", target->bounds().ToString()); |
| 535 } | 541 } |
| 536 } | 542 } |
| 537 | 543 |
| 538 } // namespace test | 544 } // namespace test |
| 539 } // namespace ash | 545 } // namespace ash |
| OLD | NEW |