diff options
author | loyso <loyso@chromium.org> | 2016-01-04 18:52:37 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-05 02:53:30 +0000 |
commit | e3c9b761289c8a671da3b429c5ee35c98018f9f4 (patch) | |
tree | a7e8d68443dfd53e6f5baa2da678b76a4e7d4d33 | |
parent | 174857165e6d4ba57d36c8c5ce10134ebf8fcd9a (diff) | |
download | chromium_src-e3c9b761289c8a671da3b429c5ee35c98018f9f4.zip chromium_src-e3c9b761289c8a671da3b429c5ee35c98018f9f4.tar.gz chromium_src-e3c9b761289c8a671da3b429c5ee35c98018f9f4.tar.bz2 |
CC Animation: Port LayerUtilsGetAnimationBoundsTests to use animation timelines.
We preserve the old version of tests so we can fall back at any time.
BUG=394777
R=ajuma@chromium.org
R=vollick@chromium.org
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1554063002
Cr-Commit-Position: refs/heads/master@{#367466}
-rw-r--r-- | cc/layers/layer_utils_unittest.cc | 86 |
1 files changed, 75 insertions, 11 deletions
diff --git a/cc/layers/layer_utils_unittest.cc b/cc/layers/layer_utils_unittest.cc index 455632d..607b06c 100644 --- a/cc/layers/layer_utils_unittest.cc +++ b/cc/layers/layer_utils_unittest.cc @@ -4,6 +4,8 @@ #include "cc/layers/layer_utils.h" +#include "cc/animation/animation_host.h" +#include "cc/animation/animation_id_provider.h" #include "cc/animation/transform_operations.h" #include "cc/layers/layer_impl.h" #include "cc/test/animation_test_common.h" @@ -22,19 +24,35 @@ float diagonal(float width, float height) { return std::sqrt(width * width + height * height); } +class LayerTreeSettingsForAnimationBoundsTest : public LayerTreeSettings { + public: + LayerTreeSettingsForAnimationBoundsTest() { + use_compositor_animation_timelines = true; + } +}; + class LayerUtilsGetAnimationBoundsTest : public testing::Test { public: LayerUtilsGetAnimationBoundsTest() - : host_impl_(&task_runner_provider_, + : host_impl_(LayerTreeSettingsForAnimationBoundsTest(), + &task_runner_provider_, &shared_bitmap_manager_, &task_graph_runner_), root_(CreateThreeNodeTree(&host_impl_)), parent_(root_->children()[0].get()), - child_(parent_->children()[0].get()) {} + child_(parent_->children()[0].get()) { + if (host_impl_.settings().use_compositor_animation_timelines) { + timeline_ = + AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); + host_impl_.animation_host()->AddAnimationTimeline(timeline_); + } + } LayerImpl* root() { return root_.get(); } LayerImpl* parent() { return parent_; } LayerImpl* child() { return child_; } + scoped_refptr<AnimationTimeline> timeline() { return timeline_; } + FakeLayerTreeHostImpl& host_impl() { return host_impl_; } private: static scoped_ptr<LayerImpl> CreateThreeNodeTree( @@ -53,6 +71,7 @@ class LayerUtilsGetAnimationBoundsTest : public testing::Test { scoped_ptr<LayerImpl> root_; LayerImpl* parent_; LayerImpl* child_; + scoped_refptr<AnimationTimeline> timeline_; }; TEST_F(LayerUtilsGetAnimationBoundsTest, ScaleRoot) { @@ -62,7 +81,12 @@ TEST_F(LayerUtilsGetAnimationBoundsTest, ScaleRoot) { start.AppendScale(1.f, 1.f, 1.f); TransformOperations end; end.AppendScale(2.f, 2.f, 1.f); - AddAnimatedTransformToLayer(root(), duration, start, end); + if (host_impl().settings().use_compositor_animation_timelines) { + AddAnimatedTransformToLayerWithPlayer(root()->id(), timeline(), duration, + start, end); + } else { + AddAnimatedTransformToLayer(root(), duration, start, end); + } root()->SetPosition(gfx::PointF()); parent()->SetPosition(gfx::PointF()); @@ -87,7 +111,12 @@ TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateParentLayer) { start.AppendTranslate(0.f, 0.f, 0.f); TransformOperations end; end.AppendTranslate(50.f, 50.f, 0.f); - AddAnimatedTransformToLayer(parent(), duration, start, end); + if (host_impl().settings().use_compositor_animation_timelines) { + AddAnimatedTransformToLayerWithPlayer(parent()->id(), timeline(), duration, + start, end); + } else { + AddAnimatedTransformToLayer(parent(), duration, start, end); + } parent()->SetBounds(gfx::Size(350, 200)); @@ -110,7 +139,12 @@ TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateChildLayer) { start.AppendTranslate(0.f, 0.f, 0.f); TransformOperations end; end.AppendTranslate(50.f, 50.f, 0.f); - AddAnimatedTransformToLayer(child(), duration, start, end); + if (host_impl().settings().use_compositor_animation_timelines) { + AddAnimatedTransformToLayerWithPlayer(child()->id(), timeline(), duration, + start, end); + } else { + AddAnimatedTransformToLayer(child(), duration, start, end); + } parent()->SetBounds(gfx::Size(350, 200)); @@ -133,11 +167,21 @@ TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateBothLayers) { start.AppendTranslate(0.f, 0.f, 0.f); TransformOperations child_end; child_end.AppendTranslate(50.f, 0.f, 0.f); - AddAnimatedTransformToLayer(parent(), duration, start, child_end); + if (host_impl().settings().use_compositor_animation_timelines) { + AddAnimatedTransformToLayerWithPlayer(parent()->id(), timeline(), duration, + start, child_end); + } else { + AddAnimatedTransformToLayer(parent(), duration, start, child_end); + } TransformOperations grand_child_end; grand_child_end.AppendTranslate(0.f, 50.f, 0.f); - AddAnimatedTransformToLayer(child(), duration, start, grand_child_end); + if (host_impl().settings().use_compositor_animation_timelines) { + AddAnimatedTransformToLayerWithPlayer(child()->id(), timeline(), duration, + start, grand_child_end); + } else { + AddAnimatedTransformToLayer(child(), duration, start, grand_child_end); + } parent()->SetBounds(gfx::Size(350, 200)); @@ -160,7 +204,12 @@ TEST_F(LayerUtilsGetAnimationBoundsTest, RotateXNoPerspective) { start.AppendRotate(1.f, 0.f, 0.f, 0.f); TransformOperations end; end.AppendRotate(1.f, 0.f, 0.f, 90.f); - AddAnimatedTransformToLayer(child(), duration, start, end); + if (host_impl().settings().use_compositor_animation_timelines) { + AddAnimatedTransformToLayerWithPlayer(child()->id(), timeline(), duration, + start, end); + } else { + AddAnimatedTransformToLayer(child(), duration, start, end); + } parent()->SetBounds(gfx::Size(350, 200)); @@ -186,7 +235,12 @@ TEST_F(LayerUtilsGetAnimationBoundsTest, RotateXWithPerspective) { start.AppendRotate(1.f, 0.f, 0.f, 0.f); TransformOperations end; end.AppendRotate(1.f, 0.f, 0.f, 90.f); - AddAnimatedTransformToLayer(child(), duration, start, end); + if (host_impl().settings().use_compositor_animation_timelines) { + AddAnimatedTransformToLayerWithPlayer(child()->id(), timeline(), duration, + start, end); + } else { + AddAnimatedTransformToLayer(child(), duration, start, end); + } // Make the anchor point not the default 0.5 value and line up with the // child center to make the math easier. @@ -220,7 +274,12 @@ TEST_F(LayerUtilsGetAnimationBoundsTest, RotateZ) { start.AppendRotate(0.f, 0.f, 1.f, 0.f); TransformOperations end; end.AppendRotate(0.f, 0.f, 1.f, 90.f); - AddAnimatedTransformToLayer(child(), duration, start, end); + if (host_impl().settings().use_compositor_animation_timelines) { + AddAnimatedTransformToLayerWithPlayer(child()->id(), timeline(), duration, + start, end); + } else { + AddAnimatedTransformToLayer(child(), duration, start, end); + } parent()->SetBounds(gfx::Size(350, 200)); @@ -252,7 +311,12 @@ TEST_F(LayerUtilsGetAnimationBoundsTest, MismatchedTransforms) { start.AppendTranslate(5, 6, 7); TransformOperations end; end.AppendRotate(0.f, 0.f, 1.f, 90.f); - AddAnimatedTransformToLayer(child(), duration, start, end); + if (host_impl().settings().use_compositor_animation_timelines) { + AddAnimatedTransformToLayerWithPlayer(child()->id(), timeline(), duration, + start, end); + } else { + AddAnimatedTransformToLayer(child(), duration, start, end); + } parent()->SetBounds(gfx::Size(350, 200)); |