| 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
|
|
|