| Index: ui/compositor/layer_unittest.cc
|
| diff --git a/ui/compositor/layer_unittest.cc b/ui/compositor/layer_unittest.cc
|
| index 6efe2d23642bd7d2fc94eb8c7160cbd4491285de..bb3c63dc2fa283bac8f6bdfd5b0db1bedd45c321 100644
|
| --- a/ui/compositor/layer_unittest.cc
|
| +++ b/ui/compositor/layer_unittest.cc
|
| @@ -29,6 +29,8 @@
|
| #include "ui/compositor/layer_animator.h"
|
| #include "ui/compositor/paint_context.h"
|
| #include "ui/compositor/paint_recorder.h"
|
| +#include "ui/compositor/scoped_animation_duration_scale_mode.h"
|
| +#include "ui/compositor/scoped_layer_animation_settings.h"
|
| #include "ui/compositor/test/context_factories_for_test.h"
|
| #include "ui/compositor/test/draw_waiter_for_test.h"
|
| #include "ui/compositor/test/test_compositor_host.h"
|
| @@ -1604,6 +1606,77 @@ TEST_F(LayerWithRealCompositorTest, SwitchCCLayerAnimations) {
|
| EXPECT_FLOAT_EQ(l1->opacity(), 0.5f);
|
| }
|
|
|
| +// Tests that when a LAYER_SOLID_COLOR has its CC layer switched, that
|
| +// opaqueness and color set while not animating, are maintained.
|
| +TEST_F(LayerWithRealCompositorTest, SwitchCCLayerSolidColorNotAnimating) {
|
| + SkColor transparent = SK_ColorTRANSPARENT;
|
| + scoped_ptr<Layer> root(CreateLayer(LAYER_SOLID_COLOR));
|
| + GetCompositor()->SetRootLayer(root.get());
|
| + root->SetFillsBoundsOpaquely(false);
|
| + root->SetColor(transparent);
|
| +
|
| + EXPECT_FALSE(root->fills_bounds_opaquely());
|
| + EXPECT_FALSE(
|
| + root->GetAnimator()->IsAnimatingProperty(LayerAnimationElement::COLOR));
|
| + EXPECT_EQ(transparent, root->background_color());
|
| + EXPECT_EQ(transparent, root->GetTargetColor());
|
| +
|
| + // Changing the underlying layer should not affect targets.
|
| + root->SwitchCCLayerForTest();
|
| +
|
| + EXPECT_FALSE(root->fills_bounds_opaquely());
|
| + EXPECT_FALSE(
|
| + root->GetAnimator()->IsAnimatingProperty(LayerAnimationElement::COLOR));
|
| + EXPECT_EQ(transparent, root->background_color());
|
| + EXPECT_EQ(transparent, root->GetTargetColor());
|
| +}
|
| +
|
| +// Tests that when a LAYER_SOLID_COLOR has its CC layer switched during an
|
| +// animation of its opaquness and color, that both the current values, and the
|
| +// targets are maintained.
|
| +TEST_F(LayerWithRealCompositorTest, SwitchCCLayerSolidColorWhileAnimating) {
|
| + SkColor transparent = SK_ColorTRANSPARENT;
|
| + scoped_ptr<Layer> root(CreateLayer(LAYER_SOLID_COLOR));
|
| + GetCompositor()->SetRootLayer(root.get());
|
| + root->SetColor(SK_ColorBLACK);
|
| +
|
| + EXPECT_TRUE(root->fills_bounds_opaquely());
|
| + EXPECT_EQ(SK_ColorBLACK, root->GetTargetColor());
|
| +
|
| + scoped_ptr<ui::ScopedAnimationDurationScaleMode> long_duration_animation(
|
| + new ui::ScopedAnimationDurationScaleMode(
|
| + ui::ScopedAnimationDurationScaleMode::SLOW_DURATION));
|
| + {
|
| + ui::ScopedLayerAnimationSettings animation(root->GetAnimator());
|
| + animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds(1000));
|
| + root->SetFillsBoundsOpaquely(false);
|
| + root->SetColor(transparent);
|
| + }
|
| +
|
| + EXPECT_TRUE(root->fills_bounds_opaquely());
|
| + EXPECT_TRUE(
|
| + root->GetAnimator()->IsAnimatingProperty(LayerAnimationElement::COLOR));
|
| + EXPECT_EQ(SK_ColorBLACK, root->background_color());
|
| + EXPECT_EQ(transparent, root->GetTargetColor());
|
| +
|
| + // Changing the underlying layer should not affect targets.
|
| + root->SwitchCCLayerForTest();
|
| +
|
| + EXPECT_TRUE(root->fills_bounds_opaquely());
|
| + EXPECT_TRUE(
|
| + root->GetAnimator()->IsAnimatingProperty(LayerAnimationElement::COLOR));
|
| + EXPECT_EQ(SK_ColorBLACK, root->background_color());
|
| + EXPECT_EQ(transparent, root->GetTargetColor());
|
| +
|
| + // End all animations.
|
| + root->GetAnimator()->StopAnimating();
|
| + EXPECT_FALSE(root->fills_bounds_opaquely());
|
| + EXPECT_FALSE(
|
| + root->GetAnimator()->IsAnimatingProperty(LayerAnimationElement::COLOR));
|
| + EXPECT_EQ(transparent, root->background_color());
|
| + EXPECT_EQ(transparent, root->GetTargetColor());
|
| +}
|
| +
|
| // 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) {
|
|
|