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

Unified Diff: ui/compositor/layer_unittest.cc

Issue 291843012: compositor: Tick the UI animations from cc, instead of from timer callbacks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 6 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/compositor/layer_animator_unittest.cc ('k') | ui/compositor/test/test_layer_animation_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/layer_unittest.cc
diff --git a/ui/compositor/layer_unittest.cc b/ui/compositor/layer_unittest.cc
index f216af3c2776faf1cb60f8e4506b0703f0983432..9c4b8a0aa2087963301d71dd0986873ed1c051ee 100644
--- a/ui/compositor/layer_unittest.cc
+++ b/ui/compositor/layer_unittest.cc
@@ -1507,4 +1507,54 @@ TEST_F(LayerWithRealCompositorTest, SwitchCCLayerAnimations) {
EXPECT_FLOAT_EQ(l1->opacity(), 0.5f);
}
+// Tests that the animators in the layer tree is added to the
+// animator-collection when the root-layer is set to the compositor.
+TEST_F(LayerWithDelegateTest, RootLayerAnimatorsInCompositor) {
+ scoped_ptr<Layer> root(CreateLayer(LAYER_SOLID_COLOR));
+ scoped_ptr<Layer> child(CreateColorLayer(SK_ColorRED, gfx::Rect(10, 10)));
+ child->SetAnimator(LayerAnimator::CreateImplicitAnimator());
+ child->SetOpacity(0.5f);
+ root->Add(child.get());
+
+ EXPECT_FALSE(compositor()->layer_animator_collection()->HasActiveAnimators());
+ compositor()->SetRootLayer(root.get());
+ EXPECT_TRUE(compositor()->layer_animator_collection()->HasActiveAnimators());
+}
+
+// Tests that adding/removing a layer adds/removes the animator from its entire
+// subtree from the compositor's animator-collection.
+TEST_F(LayerWithDelegateTest, AddRemoveLayerUpdatesAnimatorsFromSubtree) {
+ scoped_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
+ scoped_ptr<Layer> child(CreateLayer(LAYER_TEXTURED));
+ scoped_ptr<Layer> grandchild(CreateColorLayer(SK_ColorRED,
+ gfx::Rect(10, 10)));
+ root->Add(child.get());
+ child->Add(grandchild.get());
+ compositor()->SetRootLayer(root.get());
+
+ grandchild->SetAnimator(LayerAnimator::CreateImplicitAnimator());
+ grandchild->SetOpacity(0.5f);
+ EXPECT_TRUE(compositor()->layer_animator_collection()->HasActiveAnimators());
+
+ root->Remove(child.get());
+ EXPECT_FALSE(compositor()->layer_animator_collection()->HasActiveAnimators());
+
+ root->Add(child.get());
+ EXPECT_TRUE(compositor()->layer_animator_collection()->HasActiveAnimators());
+}
+
+TEST_F(LayerWithDelegateTest, DestroyingLayerRemovesTheAnimatorFromCollection) {
+ scoped_ptr<Layer> root(CreateLayer(LAYER_TEXTURED));
+ scoped_ptr<Layer> child(CreateLayer(LAYER_TEXTURED));
+ root->Add(child.get());
+ compositor()->SetRootLayer(root.get());
+
+ child->SetAnimator(LayerAnimator::CreateImplicitAnimator());
+ child->SetOpacity(0.5f);
+ EXPECT_TRUE(compositor()->layer_animator_collection()->HasActiveAnimators());
+
+ child.reset();
+ EXPECT_FALSE(compositor()->layer_animator_collection()->HasActiveAnimators());
+}
+
} // namespace ui
« no previous file with comments | « ui/compositor/layer_animator_unittest.cc ('k') | ui/compositor/test/test_layer_animation_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698