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

Side by Side Diff: cc/animation/layer_animation_controller_unittest.cc

Issue 642983003: cc: Make PictureLayerImpl use a better choice for animated raster scale. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: animationscale: onemorerename Created 6 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/animation/layer_animation_controller.h" 5 #include "cc/animation/layer_animation_controller.h"
6 6
7 #include "cc/animation/animation.h" 7 #include "cc/animation/animation.h"
8 #include "cc/animation/animation_curve.h" 8 #include "cc/animation/animation_curve.h"
9 #include "cc/animation/animation_delegate.h" 9 #include "cc/animation/animation_delegate.h"
10 #include "cc/animation/animation_registrar.h" 10 #include "cc/animation/animation_registrar.h"
(...skipping 1872 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 EXPECT_FALSE(controller_impl->HasOnlyTranslationTransforms()); 1883 EXPECT_FALSE(controller_impl->HasOnlyTranslationTransforms());
1884 1884
1885 controller_impl->GetAnimation(3, Animation::Transform) 1885 controller_impl->GetAnimation(3, Animation::Transform)
1886 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); 1886 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0));
1887 1887
1888 // Only unfinished animations should be considered by 1888 // Only unfinished animations should be considered by
1889 // HasOnlyTranslationTransforms. 1889 // HasOnlyTranslationTransforms.
1890 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms()); 1890 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms());
1891 } 1891 }
1892 1892
1893 TEST(LayerAnimationControllerTest, MaximumScale) { 1893 TEST(LayerAnimationControllerTest, MaximumTargetScale) {
1894 scoped_refptr<LayerAnimationController> controller_impl( 1894 scoped_refptr<LayerAnimationController> controller_impl(
1895 LayerAnimationController::Create(0)); 1895 LayerAnimationController::Create(0));
1896 1896
1897 float max_scale = 0.f; 1897 float max_scale = 0.f;
1898 EXPECT_TRUE(controller_impl->MaximumScale(&max_scale)); 1898 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale));
1899 EXPECT_EQ(0.f, max_scale); 1899 EXPECT_EQ(0.f, max_scale);
1900 1900
1901 scoped_ptr<KeyframedTransformAnimationCurve> curve1( 1901 scoped_ptr<KeyframedTransformAnimationCurve> curve1(
1902 KeyframedTransformAnimationCurve::Create()); 1902 KeyframedTransformAnimationCurve::Create());
1903 1903
1904 TransformOperations operations1; 1904 TransformOperations operations1;
1905 curve1->AddKeyframe(TransformKeyframe::Create( 1905 curve1->AddKeyframe(TransformKeyframe::Create(
1906 0.0, operations1, scoped_ptr<TimingFunction>())); 1906 0.0, operations1, scoped_ptr<TimingFunction>()));
1907 operations1.AppendScale(2.0, 3.0, 4.0); 1907 operations1.AppendScale(2.0, 3.0, 4.0);
1908 curve1->AddKeyframe(TransformKeyframe::Create( 1908 curve1->AddKeyframe(TransformKeyframe::Create(
1909 1.0, operations1, scoped_ptr<TimingFunction>())); 1909 1.0, operations1, scoped_ptr<TimingFunction>()));
1910 1910
1911 scoped_ptr<Animation> animation( 1911 scoped_ptr<Animation> animation(
1912 Animation::Create(curve1.Pass(), 1, 1, Animation::Transform)); 1912 Animation::Create(curve1.Pass(), 1, 1, Animation::Transform));
1913 controller_impl->AddAnimation(animation.Pass()); 1913 controller_impl->AddAnimation(animation.Pass());
1914 1914
1915 EXPECT_TRUE(controller_impl->MaximumScale(&max_scale)); 1915 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale));
1916 EXPECT_EQ(4.f, max_scale); 1916 EXPECT_EQ(4.f, max_scale);
1917 1917
1918 scoped_ptr<KeyframedTransformAnimationCurve> curve2( 1918 scoped_ptr<KeyframedTransformAnimationCurve> curve2(
1919 KeyframedTransformAnimationCurve::Create()); 1919 KeyframedTransformAnimationCurve::Create());
1920 1920
1921 TransformOperations operations2; 1921 TransformOperations operations2;
1922 curve2->AddKeyframe(TransformKeyframe::Create( 1922 curve2->AddKeyframe(TransformKeyframe::Create(
1923 0.0, operations2, scoped_ptr<TimingFunction>())); 1923 0.0, operations2, scoped_ptr<TimingFunction>()));
1924 operations2.AppendScale(6.0, 5.0, 4.0); 1924 operations2.AppendScale(6.0, 5.0, 4.0);
1925 curve2->AddKeyframe(TransformKeyframe::Create( 1925 curve2->AddKeyframe(TransformKeyframe::Create(
1926 1.0, operations2, scoped_ptr<TimingFunction>())); 1926 1.0, operations2, scoped_ptr<TimingFunction>()));
1927 1927
1928 animation = Animation::Create(curve2.Pass(), 2, 2, Animation::Transform); 1928 animation = Animation::Create(curve2.Pass(), 2, 2, Animation::Transform);
1929 controller_impl->AddAnimation(animation.Pass()); 1929 controller_impl->AddAnimation(animation.Pass());
1930 1930
1931 EXPECT_TRUE(controller_impl->MaximumScale(&max_scale)); 1931 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale));
1932 EXPECT_EQ(6.f, max_scale); 1932 EXPECT_EQ(6.f, max_scale);
1933 1933
1934 scoped_ptr<KeyframedTransformAnimationCurve> curve3( 1934 scoped_ptr<KeyframedTransformAnimationCurve> curve3(
1935 KeyframedTransformAnimationCurve::Create()); 1935 KeyframedTransformAnimationCurve::Create());
1936 1936
1937 TransformOperations operations3; 1937 TransformOperations operations3;
1938 curve3->AddKeyframe(TransformKeyframe::Create( 1938 curve3->AddKeyframe(TransformKeyframe::Create(
1939 0.0, operations3, scoped_ptr<TimingFunction>())); 1939 0.0, operations3, scoped_ptr<TimingFunction>()));
1940 operations3.AppendPerspective(6.0); 1940 operations3.AppendPerspective(6.0);
1941 curve3->AddKeyframe(TransformKeyframe::Create( 1941 curve3->AddKeyframe(TransformKeyframe::Create(
1942 1.0, operations3, scoped_ptr<TimingFunction>())); 1942 1.0, operations3, scoped_ptr<TimingFunction>()));
1943 1943
1944 animation = Animation::Create(curve3.Pass(), 3, 3, Animation::Transform); 1944 animation = Animation::Create(curve3.Pass(), 3, 3, Animation::Transform);
1945 controller_impl->AddAnimation(animation.Pass()); 1945 controller_impl->AddAnimation(animation.Pass());
1946 1946
1947 EXPECT_FALSE(controller_impl->MaximumScale(&max_scale)); 1947 EXPECT_FALSE(controller_impl->MaximumTargetScale(&max_scale));
1948 1948
1949 controller_impl->GetAnimation(3, Animation::Transform) 1949 controller_impl->GetAnimation(3, Animation::Transform)
1950 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); 1950 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0));
1951 controller_impl->GetAnimation(2, Animation::Transform) 1951 controller_impl->GetAnimation(2, Animation::Transform)
1952 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); 1952 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0));
1953 1953
1954 // Only unfinished animations should be considered by 1954 // Only unfinished animations should be considered by
1955 // MaximumScale. 1955 // MaximumTargetScale.
1956 EXPECT_TRUE(controller_impl->MaximumScale(&max_scale)); 1956 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale));
1957 EXPECT_EQ(4.f, max_scale); 1957 EXPECT_EQ(4.f, max_scale);
1958 } 1958 }
1959 1959
1960 TEST(LayerAnimationControllerTest, NewlyPushedAnimationWaitsForActivation) { 1960 TEST(LayerAnimationControllerTest, NewlyPushedAnimationWaitsForActivation) {
1961 scoped_ptr<AnimationEventsVector> events( 1961 scoped_ptr<AnimationEventsVector> events(
1962 make_scoped_ptr(new AnimationEventsVector)); 1962 make_scoped_ptr(new AnimationEventsVector));
1963 FakeLayerAnimationValueObserver dummy_impl; 1963 FakeLayerAnimationValueObserver dummy_impl;
1964 FakeInactiveLayerAnimationValueObserver pending_dummy_impl; 1964 FakeInactiveLayerAnimationValueObserver pending_dummy_impl;
1965 scoped_refptr<LayerAnimationController> controller_impl( 1965 scoped_refptr<LayerAnimationController> controller_impl(
1966 LayerAnimationController::Create(0)); 1966 LayerAnimationController::Create(0));
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
2254 // been ticked at the new animation's starting point. 2254 // been ticked at the new animation's starting point.
2255 EXPECT_EQ(Animation::Running, 2255 EXPECT_EQ(Animation::Running,
2256 controller_impl->GetAnimation(second_animation_group_id, 2256 controller_impl->GetAnimation(second_animation_group_id,
2257 Animation::Opacity)->run_state()); 2257 Animation::Opacity)->run_state());
2258 EXPECT_EQ(1.f, pending_dummy_impl.opacity()); 2258 EXPECT_EQ(1.f, pending_dummy_impl.opacity());
2259 EXPECT_EQ(1.f, dummy_impl.opacity()); 2259 EXPECT_EQ(1.f, dummy_impl.opacity());
2260 } 2260 }
2261 2261
2262 } // namespace 2262 } // namespace
2263 } // namespace cc 2263 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698