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

Unified Diff: cc/animation/layer_animation_controller_unittest.cc

Issue 15732013: Allow animations with inactive observers to reach the Starting state (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 | « cc/animation/layer_animation_controller.cc ('k') | cc/test/animation_test_common.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/animation/layer_animation_controller_unittest.cc
diff --git a/cc/animation/layer_animation_controller_unittest.cc b/cc/animation/layer_animation_controller_unittest.cc
index 6e2e8e2b58e268d1e19ed2cd84a62a2e1eecbfb4..8ba0a7cd049badad79fb05142e9e7af876d3a4e1 100644
--- a/cc/animation/layer_animation_controller_unittest.cc
+++ b/cc/animation/layer_animation_controller_unittest.cc
@@ -1093,5 +1093,68 @@ TEST(LayerAnimationControllerTest, SkipUpdateState) {
EXPECT_FALSE(controller->HasActiveAnimation());
}
+// Tests that an animation controller with only an inactive observer gets ticked
+// but doesn't progress animations past the Starting state.
+TEST(LayerAnimationControllerTest, InactiveObserverGetsTicked) {
+ scoped_ptr<AnimationEventsVector> events(
+ make_scoped_ptr(new AnimationEventsVector));
+ FakeLayerAnimationValueObserver dummy;
+ FakeInactiveLayerAnimationValueObserver inactive_dummy;
+ scoped_refptr<LayerAnimationController> controller(
+ LayerAnimationController::Create(0));
+
+ const int id = 1;
+ controller->AddAnimation(CreateAnimation(scoped_ptr<AnimationCurve>(
+ new FakeFloatTransition(1.0, 0.5f, 1.f)).Pass(),
+ id,
+ Animation::Opacity));
+
+ // Without an observer, the animation shouldn't progress to the Starting
+ // state.
+ controller->Animate(0.0);
+ controller->UpdateState(true, events.get());
+ EXPECT_EQ(0u, events->size());
+ EXPECT_EQ(Animation::WaitingForTargetAvailability,
+ controller->GetAnimation(id, Animation::Opacity)->run_state());
+
+ controller->AddValueObserver(&inactive_dummy);
+
+ // With only an inactive observer, the animation should progress to the
+ // Starting state and get ticked at its starting point, but should not
+ // progress to Running.
+ controller->Animate(1.0);
+ controller->UpdateState(true, events.get());
+ EXPECT_EQ(0u, events->size());
+ EXPECT_EQ(Animation::Starting,
+ controller->GetAnimation(id, Animation::Opacity)->run_state());
+ EXPECT_EQ(0.5f, inactive_dummy.opacity());
+
+ // Even when already in the Starting state, the animation should stay
+ // there, and shouldn't be ticked past its starting point.
+ controller->Animate(2.0);
+ controller->UpdateState(true, events.get());
+ EXPECT_EQ(0u, events->size());
+ EXPECT_EQ(Animation::Starting,
+ controller->GetAnimation(id, Animation::Opacity)->run_state());
+ EXPECT_EQ(0.5f, inactive_dummy.opacity());
+
+ controller->AddValueObserver(&dummy);
+
+ // Now that an active observer has been added, the animation should still
+ // initially tick at its starting point, but should now progress to Running.
+ controller->Animate(3.0);
+ controller->UpdateState(true, events.get());
+ EXPECT_EQ(1u, events->size());
+ EXPECT_EQ(Animation::Running,
+ controller->GetAnimation(id, Animation::Opacity)->run_state());
+ EXPECT_EQ(0.5f, inactive_dummy.opacity());
+ EXPECT_EQ(0.5f, dummy.opacity());
+
+ // The animation should now tick past its starting point.
+ controller->Animate(3.5);
+ EXPECT_NE(0.5f, inactive_dummy.opacity());
+ EXPECT_NE(0.5f, dummy.opacity());
+}
+
} // namespace
} // namespace cc
« no previous file with comments | « cc/animation/layer_animation_controller.cc ('k') | cc/test/animation_test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698