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

Unified Diff: ui/gfx/compositor/layer_animator_unittest.cc

Issue 9320018: Revert 120092 - Reland 120074 -- Disable animations during aura tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/compositor/layer_animator.cc ('k') | ui/gfx/compositor/scoped_layer_animation_settings.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/compositor/layer_animator_unittest.cc
===================================================================
--- ui/gfx/compositor/layer_animator_unittest.cc (revision 120096)
+++ ui/gfx/compositor/layer_animator_unittest.cc (working copy)
@@ -133,7 +133,7 @@
EXPECT_TRUE(animator->is_animating());
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity);
- base::TimeTicks start_time = animator->last_step_time();
+ base::TimeTicks start_time = animator->get_last_step_time_for_test();
element->Step(start_time + base::TimeDelta::FromMilliseconds(500));
@@ -181,7 +181,7 @@
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity);
CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), start_bounds);
- base::TimeTicks start_time = animator->last_step_time();
+ base::TimeTicks start_time = animator->get_last_step_time_for_test();
element->Step(start_time + base::TimeDelta::FromMilliseconds(500));
@@ -224,7 +224,7 @@
EXPECT_TRUE(animator->is_animating());
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity);
- base::TimeTicks start_time = animator->last_step_time();
+ base::TimeTicks start_time = animator->get_last_step_time_for_test();
element->Step(start_time + base::TimeDelta::FromMilliseconds(500));
@@ -292,7 +292,7 @@
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity);
CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), start_bounds);
- base::TimeTicks start_time = animator->last_step_time();
+ base::TimeTicks start_time = animator->get_last_step_time_for_test();
element->Step(start_time + base::TimeDelta::FromMilliseconds(500));
@@ -364,7 +364,7 @@
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity);
CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), start_bounds);
- base::TimeTicks start_time = animator->last_step_time();
+ base::TimeTicks start_time = animator->get_last_step_time_for_test();
element->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
@@ -403,7 +403,7 @@
EXPECT_TRUE(animator->is_animating());
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), start_opacity);
- base::TimeTicks start_time = animator->last_step_time();
+ base::TimeTicks start_time = animator->get_last_step_time_for_test();
element->Step(start_time + base::TimeDelta::FromMilliseconds(500));
@@ -467,7 +467,7 @@
new LayerAnimationSequence(
LayerAnimationElement::CreateOpacityElement(target_opacity, delta)));
- base::TimeTicks start_time = animator->last_step_time();
+ base::TimeTicks start_time = animator->get_last_step_time_for_test();
element->Step(start_time + base::TimeDelta::FromMilliseconds(500));
@@ -518,7 +518,7 @@
new LayerAnimationSequence(
LayerAnimationElement::CreateOpacityElement(target_opacity, delta)));
- base::TimeTicks start_time = animator->last_step_time();
+ base::TimeTicks start_time = animator->get_last_step_time_for_test();
element->Step(start_time + base::TimeDelta::FromMilliseconds(500));
@@ -571,7 +571,7 @@
new LayerAnimationSequence(
LayerAnimationElement::CreateOpacityElement(target_opacity, delta)));
- base::TimeTicks start_time = animator->last_step_time();
+ base::TimeTicks start_time = animator->get_last_step_time_for_test();
element->Step(start_time + base::TimeDelta::FromMilliseconds(500));
@@ -630,7 +630,7 @@
animator->StartAnimation(sequence.release());
- base::TimeTicks start_time = animator->last_step_time();
+ base::TimeTicks start_time = animator->get_last_step_time_for_test();
element->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
@@ -687,7 +687,7 @@
EXPECT_EQ(observer.last_scheduled_sequence(), sequence);
- base::TimeTicks start_time = animator->last_step_time();
+ base::TimeTicks start_time = animator->get_last_step_time_for_test();
element->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
@@ -704,6 +704,45 @@
EXPECT_EQ(observer.last_aborted_sequence(), sequence);
}
+TEST(LayerAnimatorTest, AddObserverImplicit) {
+ scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
+ AnimationContainerElement* element = animator.get();
+ animator->set_disable_timer_for_test(true);
+ TestLayerAnimationObserver observer;
+ TestLayerAnimationDelegate delegate;
+ animator->SetDelegate(&delegate);
+ animator->AddObserver(&observer);
+
+ // Should end a sequence with the default animator.
+ EXPECT_TRUE(!observer.last_ended_sequence());
+ animator->SetOpacity(1.0f);
+ base::TimeTicks start_time = base::TimeTicks::Now();
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
+ EXPECT_TRUE(observer.last_ended_sequence());
+
+ TestLayerAnimationObserver scoped_observer;
+ {
+ ScopedLayerAnimationSettings settings(animator.get());
+ settings.AddObserver(&scoped_observer);
+ for (int i = 0; i < 2; ++i) {
+ // reset the observer
+ scoped_observer = TestLayerAnimationObserver();
+ EXPECT_TRUE(!scoped_observer.last_ended_sequence());
+ animator->SetOpacity(1.0f);
+ start_time = animator->get_last_step_time_for_test();
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
+ EXPECT_FALSE(!scoped_observer.last_ended_sequence());
+ }
+ }
+
+ scoped_observer = TestLayerAnimationObserver();
+ EXPECT_TRUE(!scoped_observer.last_ended_sequence());
+ animator->SetOpacity(1.0f);
+ start_time = base::TimeTicks::Now();
+ element->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
+ EXPECT_TRUE(!scoped_observer.last_ended_sequence());
+}
+
// Tests that an observer added to a scoped settings object is still notified
// when the object goes out of scope.
TEST(LayerAnimatorTest, ImplicitAnimationObservers) {
@@ -719,12 +758,12 @@
{
ScopedLayerAnimationSettings settings(animator.get());
- settings.AddObserver(&observer);
+ settings.AddImplicitObserver(&observer);
animator->SetOpacity(0.0f);
}
EXPECT_FALSE(observer.animations_completed());
- base::TimeTicks start_time = animator->last_step_time();
+ base::TimeTicks start_time = animator->get_last_step_time_for_test();
element->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
EXPECT_TRUE(observer.animations_completed());
EXPECT_FLOAT_EQ(0.0f, delegate.GetOpacityForAnimation());
@@ -744,7 +783,7 @@
{
ScopedLayerAnimationSettings settings(animator.get());
- settings.AddObserver(&observer);
+ settings.AddImplicitObserver(&observer);
animator->SetOpacity(0.0f);
}
@@ -783,7 +822,7 @@
// This should stop the observer from observing sequence.
animator->RemoveObserver(&removed_observer);
- base::TimeTicks start_time = animator->last_step_time();
+ base::TimeTicks start_time = animator->get_last_step_time_for_test();
element->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
@@ -819,70 +858,6 @@
EXPECT_EQ(static_cast<size_t>(0), sequence->observers_.size());
}
-TEST(LayerAnimatorTest, ObserverAttachedAfterAnimationStarted) {
- scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
- AnimationContainerElement* element = animator.get();
- animator->set_disable_timer_for_test(true);
-
- TestImplicitAnimationObserver observer;
- TestLayerAnimationDelegate delegate;
- animator->SetDelegate(&delegate);
-
- delegate.SetOpacityFromAnimation(0.0f);
-
- {
- ScopedLayerAnimationSettings setter(animator.get());
-
- base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
- LayerAnimationSequence* sequence = new LayerAnimationSequence(
- LayerAnimationElement::CreateOpacityElement(1.0f, delta));
-
- animator->StartAnimation(sequence);
- base::TimeTicks start_time = animator->last_step_time();
- element->Step(start_time + base::TimeDelta::FromMilliseconds(500));
-
- setter.AddObserver(&observer);
-
- // Start observing an in-flight animation.
- sequence->AddObserver(&observer);
-
- element->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
- }
-
- EXPECT_TRUE(observer.animations_completed());
-}
-
-TEST(LayerAnimatorTest, ObserverDetachedBeforeAnimationFinished) {
- scoped_ptr<LayerAnimator> animator(LayerAnimator::CreateDefaultAnimator());
- AnimationContainerElement* element = animator.get();
- animator->set_disable_timer_for_test(true);
-
- TestImplicitAnimationObserver observer;
- TestLayerAnimationDelegate delegate;
- animator->SetDelegate(&delegate);
-
- delegate.SetOpacityFromAnimation(0.0f);
- base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
- LayerAnimationSequence* sequence = new LayerAnimationSequence(
- LayerAnimationElement::CreateOpacityElement(1.0f, delta));
-
- {
- ScopedLayerAnimationSettings setter(animator.get());
- setter.AddObserver(&observer);
-
- animator->StartAnimation(sequence);
- base::TimeTicks start_time = animator->last_step_time();
- element->Step(start_time + base::TimeDelta::FromMilliseconds(500));
- }
-
- EXPECT_FALSE(observer.animations_completed());
-
- // Stop observing an in-flight animation.
- sequence->RemoveObserver(&observer);
-
- EXPECT_TRUE(observer.animations_completed());
-}
-
// Check that setting a property during an animation with a default animator
// cancels the original animation.
TEST(LayerAnimatorTest, SettingPropertyDuringAnAnimation) {
« no previous file with comments | « ui/gfx/compositor/layer_animator.cc ('k') | ui/gfx/compositor/scoped_layer_animation_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698