| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/browser/web_contents/aura/window_slider.h" | 5 #include "content/browser/web_contents/aura/window_slider.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/aura/test/aura_test_base.h" | 10 #include "ui/aura/test/aura_test_base.h" |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 EXPECT_TRUE(slider_delegate.slider_destroyed()); | 328 EXPECT_TRUE(slider_delegate.slider_destroyed()); |
| 329 } | 329 } |
| 330 | 330 |
| 331 // Tests that the window slide can continue after it is interrupted by another | 331 // Tests that the window slide can continue after it is interrupted by another |
| 332 // event if the user continues scrolling. | 332 // event if the user continues scrolling. |
| 333 TEST_F(WindowSliderTest, WindowSlideInterruptedThenContinues) { | 333 TEST_F(WindowSliderTest, WindowSlideInterruptedThenContinues) { |
| 334 scoped_ptr<aura::Window> window(CreateNormalWindow(0, root_window(), NULL)); | 334 scoped_ptr<aura::Window> window(CreateNormalWindow(0, root_window(), NULL)); |
| 335 window->SetBounds(gfx::Rect(0, 0, 400, 400)); | 335 window->SetBounds(gfx::Rect(0, 0, 400, 400)); |
| 336 WindowSliderDelegateTest slider_delegate; | 336 WindowSliderDelegateTest slider_delegate; |
| 337 | 337 |
| 338 ui::ScopedAnimationDurationScaleMode normal_duration_( | 338 ui::ScopedAnimationDurationScaleMode test_duration_( |
| 339 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); | 339 ui::ScopedAnimationDurationScaleMode::TEST_DURATION); |
| 340 ui::LayerAnimator* animator = window->layer()->GetAnimator(); | 340 ui::LayerAnimator* animator = window->layer()->GetAnimator(); |
| 341 animator->set_disable_timer_for_test(true); | 341 animator->set_disable_timer_for_test(true); |
| 342 ui::LayerAnimatorTestController test_controller(animator); | 342 ui::LayerAnimatorTestController test_controller(animator); |
| 343 | 343 |
| 344 WindowSlider* slider = | 344 WindowSlider* slider = |
| 345 new WindowSlider(&slider_delegate, root_window(), window.get()); | 345 new WindowSlider(&slider_delegate, root_window(), window.get()); |
| 346 | 346 |
| 347 ui::MouseEvent interrupt_event(ui::ET_MOUSE_MOVED, | 347 ui::MouseEvent interrupt_event(ui::ET_MOUSE_MOVED, |
| 348 gfx::Point(55, 10), | 348 gfx::Point(55, 10), |
| 349 gfx::Point(55, 10), | 349 gfx::Point(55, 10), |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 // that the second swipe occurs while the transition animation triggered by the | 582 // that the second swipe occurs while the transition animation triggered by the |
| 583 // first swipe is in progress. | 583 // first swipe is in progress. |
| 584 // The second swipe is supposed to instantly complete the animation caused by | 584 // The second swipe is supposed to instantly complete the animation caused by |
| 585 // the first swipe, ask the delegate to create a new layer, and animate it. | 585 // the first swipe, ask the delegate to create a new layer, and animate it. |
| 586 TEST_F(WindowSliderTest, SwipeDuringSwipeAnimation) { | 586 TEST_F(WindowSliderTest, SwipeDuringSwipeAnimation) { |
| 587 scoped_ptr<aura::Window> window(CreateNormalWindow(0, root_window(), NULL)); | 587 scoped_ptr<aura::Window> window(CreateNormalWindow(0, root_window(), NULL)); |
| 588 window->SetBounds(gfx::Rect(0, 0, 400, 400)); | 588 window->SetBounds(gfx::Rect(0, 0, 400, 400)); |
| 589 WindowSliderDelegateTest slider_delegate; | 589 WindowSliderDelegateTest slider_delegate; |
| 590 new WindowSlider(&slider_delegate, root_window(), window.get()); | 590 new WindowSlider(&slider_delegate, root_window(), window.get()); |
| 591 | 591 |
| 592 ui::ScopedAnimationDurationScaleMode normal_duration_( | 592 ui::ScopedAnimationDurationScaleMode test_duration( |
| 593 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); | 593 ui::ScopedAnimationDurationScaleMode::TEST_DURATION); |
| 594 ui::LayerAnimator* animator = window->layer()->GetAnimator(); | 594 ui::LayerAnimator* animator = window->layer()->GetAnimator(); |
| 595 animator->set_disable_timer_for_test(true); | 595 animator->set_disable_timer_for_test(true); |
| 596 ui::LayerAnimatorTestController test_controller(animator); | 596 ui::LayerAnimatorTestController test_controller(animator); |
| 597 | 597 |
| 598 aura::test::EventGenerator generator(root_window()); | 598 aura::test::EventGenerator generator(root_window()); |
| 599 | 599 |
| 600 // Swipe forward so that |window|'s layer is the one animating. | 600 // Swipe forward so that |window|'s layer is the one animating. |
| 601 generator.GestureScrollSequence( | 601 generator.GestureScrollSequence( |
| 602 gfx::Point(10, 10), | 602 gfx::Point(10, 10), |
| 603 gfx::Point(180, 10), | 603 gfx::Point(180, 10), |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 animator->Step(start_time2 + duration); | 638 animator->Step(start_time2 + duration); |
| 639 // The animation for the second slide should now be completed. | 639 // The animation for the second slide should now be completed. |
| 640 EXPECT_TRUE(slider_delegate.slide_completed()); | 640 EXPECT_TRUE(slider_delegate.slide_completed()); |
| 641 slider_delegate.Reset(); | 641 slider_delegate.Reset(); |
| 642 | 642 |
| 643 window.reset(); | 643 window.reset(); |
| 644 EXPECT_TRUE(slider_delegate.slider_destroyed()); | 644 EXPECT_TRUE(slider_delegate.slider_destroyed()); |
| 645 } | 645 } |
| 646 | 646 |
| 647 } // namespace content | 647 } // namespace content |
| OLD | NEW |