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/ash_constants.h" | 7 #include "ash/ash_constants.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
11 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
12 #include "ash/wm/lock_state_controller_impl2.h" | 12 #include "ash/wm/lock_state_controller_impl2.h" |
13 #include "ash/wm/property_util.h" | 13 #include "ash/wm/property_util.h" |
14 #include "ash/wm/resize_shadow.h" | 14 #include "ash/wm/resize_shadow.h" |
15 #include "ash/wm/resize_shadow_controller.h" | 15 #include "ash/wm/resize_shadow_controller.h" |
16 #include "ash/wm/window_util.h" | 16 #include "ash/wm/window_util.h" |
17 #include "ash/wm/workspace/snap_sizer.h" | |
18 #include "ash/wm/workspace_controller.h" | 17 #include "ash/wm/workspace_controller.h" |
19 #include "base/basictypes.h" | 18 #include "base/basictypes.h" |
20 #include "base/compiler_specific.h" | 19 #include "base/compiler_specific.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
22 #include "ui/aura/client/aura_constants.h" | 21 #include "ui/aura/client/aura_constants.h" |
23 #include "ui/aura/root_window.h" | 22 #include "ui/aura/root_window.h" |
24 #include "ui/aura/test/aura_test_base.h" | 23 #include "ui/aura/test/aura_test_base.h" |
25 #include "ui/aura/test/event_generator.h" | 24 #include "ui/aura/test/event_generator.h" |
26 #include "ui/aura/test/test_activation_client.h" | 25 #include "ui/aura/test/test_activation_client.h" |
27 #include "ui/aura/test/test_window_delegate.h" | 26 #include "ui/aura/test/test_window_delegate.h" |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 target.get()); | 382 target.get()); |
384 gfx::Rect old_bounds = target->bounds(); | 383 gfx::Rect old_bounds = target->bounds(); |
385 gfx::Point location(5, 5); | 384 gfx::Point location(5, 5); |
386 target->SetProperty(aura::client::kCanMaximizeKey, true); | 385 target->SetProperty(aura::client::kCanMaximizeKey, true); |
387 | 386 |
388 gfx::Point end = location; | 387 gfx::Point end = location; |
389 | 388 |
390 // Snap right; | 389 // Snap right; |
391 { | 390 { |
392 // Get the expected snapped bounds before snapping. | 391 // Get the expected snapped bounds before snapping. |
393 internal::SnapSizer sizer(target.get(), location, | 392 gfx::Rect snapped_bounds = wm::GetSnappedWindowBoundsInParent( |
394 internal::SnapSizer::RIGHT_EDGE, | 393 target.get(), wm::SNAP_RIGHT_EDGE); |
395 internal::SnapSizer::OTHER_INPUT); | |
396 gfx::Rect snapped_bounds = sizer.GetSnapBounds(target->bounds()); | |
397 | 394 |
398 end.Offset(100, 0); | 395 end.Offset(100, 0); |
399 generator.GestureScrollSequence(location, end, | 396 generator.GestureScrollSequence(location, end, |
400 base::TimeDelta::FromMilliseconds(5), | 397 base::TimeDelta::FromMilliseconds(5), |
401 10); | 398 10); |
402 RunAllPendingInMessageLoop(); | 399 RunAllPendingInMessageLoop(); |
403 | 400 |
404 // Verify that the window has moved after the gesture. | 401 // Verify that the window has moved after the gesture. |
405 EXPECT_NE(old_bounds.ToString(), target->bounds().ToString()); | 402 EXPECT_NE(old_bounds.ToString(), target->bounds().ToString()); |
406 EXPECT_EQ(snapped_bounds.ToString(), target->bounds().ToString()); | 403 EXPECT_EQ(snapped_bounds.ToString(), target->bounds().ToString()); |
407 } | 404 } |
408 | 405 |
409 old_bounds = target->bounds(); | 406 old_bounds = target->bounds(); |
410 | 407 |
411 // Snap left. | 408 // Snap left. |
412 { | 409 { |
413 // Get the expected snapped bounds before snapping. | 410 // Get the expected snapped bounds before snapping. |
414 internal::SnapSizer sizer(target.get(), location, | 411 gfx::Rect snapped_bounds = wm::GetSnappedWindowBoundsInParent( |
415 internal::SnapSizer::LEFT_EDGE, | 412 target.get(), wm::SNAP_LEFT_EDGE); |
416 internal::SnapSizer::OTHER_INPUT); | |
417 gfx::Rect snapped_bounds = sizer.GetSnapBounds(target->bounds()); | |
418 end = location = target->GetBoundsInRootWindow().CenterPoint(); | 413 end = location = target->GetBoundsInRootWindow().CenterPoint(); |
419 end.Offset(-100, 0); | 414 end.Offset(-100, 0); |
420 generator.GestureScrollSequence(location, end, | 415 generator.GestureScrollSequence(location, end, |
421 base::TimeDelta::FromMilliseconds(5), | 416 base::TimeDelta::FromMilliseconds(5), |
422 10); | 417 10); |
423 RunAllPendingInMessageLoop(); | 418 RunAllPendingInMessageLoop(); |
424 | 419 |
425 EXPECT_NE(old_bounds.ToString(), target->bounds().ToString()); | 420 EXPECT_NE(old_bounds.ToString(), target->bounds().ToString()); |
426 EXPECT_EQ(snapped_bounds.ToString(), target->bounds().ToString()); | 421 EXPECT_EQ(snapped_bounds.ToString(), target->bounds().ToString()); |
427 } | 422 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 gfx::Rect old_bounds = target->bounds(); | 518 gfx::Rect old_bounds = target->bounds(); |
524 gfx::Point location(5, 5); | 519 gfx::Point location(5, 5); |
525 | 520 |
526 target->SetProperty(aura::client::kCanResizeKey, false); | 521 target->SetProperty(aura::client::kCanResizeKey, false); |
527 | 522 |
528 gfx::Point end = location; | 523 gfx::Point end = location; |
529 | 524 |
530 // Try to snap right. The window is not resizable. So it should not snap. | 525 // Try to snap right. The window is not resizable. So it should not snap. |
531 { | 526 { |
532 // Get the expected snapped bounds before the gesture. | 527 // Get the expected snapped bounds before the gesture. |
533 internal::SnapSizer sizer(target.get(), location, | 528 gfx::Rect snapped_bounds = wm::GetSnappedWindowBoundsInParent( |
534 internal::SnapSizer::RIGHT_EDGE, | 529 target.get(), wm::SNAP_RIGHT_EDGE); |
535 internal::SnapSizer::OTHER_INPUT); | |
536 gfx::Rect snapped_bounds = sizer.GetSnapBounds(target->bounds()); | |
537 | 530 |
538 end.Offset(100, 0); | 531 end.Offset(100, 0); |
539 generator.GestureScrollSequence(location, end, | 532 generator.GestureScrollSequence(location, end, |
540 base::TimeDelta::FromMilliseconds(5), | 533 base::TimeDelta::FromMilliseconds(5), |
541 10); | 534 10); |
542 RunAllPendingInMessageLoop(); | 535 RunAllPendingInMessageLoop(); |
543 | 536 |
544 // Verify that the window has moved after the gesture. | 537 // Verify that the window has moved after the gesture. |
545 gfx::Rect expected_bounds(old_bounds); | 538 gfx::Rect expected_bounds(old_bounds); |
546 expected_bounds.Offset(gfx::Vector2d(100, 0)); | 539 expected_bounds.Offset(gfx::Vector2d(100, 0)); |
547 EXPECT_EQ(expected_bounds.ToString(), target->bounds().ToString()); | 540 EXPECT_EQ(expected_bounds.ToString(), target->bounds().ToString()); |
548 | 541 |
549 // Verify that the window did not snap left. | 542 // Verify that the window did not snap left. |
550 EXPECT_NE(snapped_bounds.ToString(), target->bounds().ToString()); | 543 EXPECT_NE(snapped_bounds.ToString(), target->bounds().ToString()); |
551 } | 544 } |
552 | 545 |
553 old_bounds = target->bounds(); | 546 old_bounds = target->bounds(); |
554 | 547 |
555 // Try to snap left. It should not snap. | 548 // Try to snap left. It should not snap. |
556 { | 549 { |
557 // Get the expected snapped bounds before the gesture. | 550 // Get the expected snapped bounds before the gesture. |
558 internal::SnapSizer sizer(target.get(), location, | 551 gfx::Rect snapped_bounds = wm::GetSnappedWindowBoundsInParent( |
559 internal::SnapSizer::LEFT_EDGE, | 552 target.get(), wm::SNAP_LEFT_EDGE); |
560 internal::SnapSizer::OTHER_INPUT); | |
561 gfx::Rect snapped_bounds = sizer.GetSnapBounds(target->bounds()); | |
562 end = location = target->GetBoundsInRootWindow().CenterPoint(); | 553 end = location = target->GetBoundsInRootWindow().CenterPoint(); |
563 end.Offset(-100, 0); | 554 end.Offset(-100, 0); |
564 generator.GestureScrollSequence(location, end, | 555 generator.GestureScrollSequence(location, end, |
565 base::TimeDelta::FromMilliseconds(5), | 556 base::TimeDelta::FromMilliseconds(5), |
566 10); | 557 10); |
567 RunAllPendingInMessageLoop(); | 558 RunAllPendingInMessageLoop(); |
568 | 559 |
569 // Verify that the window has moved after the gesture. | 560 // Verify that the window has moved after the gesture. |
570 gfx::Rect expected_bounds(old_bounds); | 561 gfx::Rect expected_bounds(old_bounds); |
571 expected_bounds.Offset(gfx::Vector2d(-100, 0)); | 562 expected_bounds.Offset(gfx::Vector2d(-100, 0)); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 | 798 |
808 // Move mouse out of the window. Shadows should disappear. | 799 // Move mouse out of the window. Shadows should disappear. |
809 generator.MoveMouseTo(150, 150); | 800 generator.MoveMouseTo(150, 150); |
810 EXPECT_FALSE(HasResizeShadow()); | 801 EXPECT_FALSE(HasResizeShadow()); |
811 | 802 |
812 RunAllPendingInMessageLoop(); | 803 RunAllPendingInMessageLoop(); |
813 } | 804 } |
814 | 805 |
815 } // namespace test | 806 } // namespace test |
816 } // namespace ash | 807 } // namespace ash |
OLD | NEW |