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

Side by Side Diff: content/browser/web_contents/aura/window_slider_unittest.cc

Issue 420013002: Introduce NON_ZERO_DURATION for animation unit tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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
OLDNEW
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
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698