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

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

Issue 1076313006: Animation start scale should be considered for the raster scale (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing and Added more tests Created 5 years, 7 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
« no previous file with comments | « cc/animation/layer_animation_controller.cc ('k') | cc/layers/draw_properties.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 EXPECT_FALSE(controller_impl->HasOnlyTranslationTransforms()); 1915 EXPECT_FALSE(controller_impl->HasOnlyTranslationTransforms());
1916 1916
1917 controller_impl->GetAnimationById(3) 1917 controller_impl->GetAnimationById(3)
1918 ->SetRunState(Animation::FINISHED, TicksFromSecondsF(0.0)); 1918 ->SetRunState(Animation::FINISHED, TicksFromSecondsF(0.0));
1919 1919
1920 // Only unfinished animations should be considered by 1920 // Only unfinished animations should be considered by
1921 // HasOnlyTranslationTransforms. 1921 // HasOnlyTranslationTransforms.
1922 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms()); 1922 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms());
1923 } 1923 }
1924 1924
1925 TEST(LayerAnimationControllerTest, AnimationStartScale) {
1926 scoped_refptr<LayerAnimationController> controller_impl(
1927 LayerAnimationController::Create(0));
1928 scoped_ptr<KeyframedTransformAnimationCurve> curve1(
1929 KeyframedTransformAnimationCurve::Create());
1930
1931 TransformOperations operations1;
1932 operations1.AppendScale(2.0, 3.0, 4.0);
1933 curve1->AddKeyframe(
1934 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr));
1935 TransformOperations operations2;
1936 curve1->AddKeyframe(TransformKeyframe::Create(
1937 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr));
1938 scoped_ptr<Animation> animation(
1939 Animation::Create(curve1.Pass(), 1, 1, Animation::TRANSFORM));
1940 controller_impl->AddAnimation(animation.Pass());
1941
1942 float start_scale = 0.f;
1943 EXPECT_TRUE(controller_impl->AnimationStartScale(&start_scale));
1944 EXPECT_EQ(4.f, start_scale);
1945
1946 scoped_ptr<KeyframedTransformAnimationCurve> curve2(
1947 KeyframedTransformAnimationCurve::Create());
1948
1949 TransformOperations operations3;
1950 curve2->AddKeyframe(
1951 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr));
1952 operations3.AppendScale(6.0, 5.0, 4.0);
1953 curve2->AddKeyframe(TransformKeyframe::Create(
1954 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr));
1955
1956 controller_impl->RemoveAnimation(1);
1957 animation = Animation::Create(curve2.Pass(), 2, 2, Animation::TRANSFORM);
1958
1959 // Reverse Direction
1960 animation->set_direction(Animation::DIRECTION_REVERSE);
1961 controller_impl->AddAnimation(animation.Pass());
1962
1963 scoped_ptr<KeyframedTransformAnimationCurve> curve3(
1964 KeyframedTransformAnimationCurve::Create());
1965
1966 TransformOperations operations4;
1967 operations4.AppendScale(5.0, 3.0, 1.0);
1968 curve3->AddKeyframe(
1969 TransformKeyframe::Create(base::TimeDelta(), operations4, nullptr));
1970 TransformOperations operations5;
1971 curve3->AddKeyframe(TransformKeyframe::Create(
1972 base::TimeDelta::FromSecondsD(1.0), operations5, nullptr));
1973
1974 animation = Animation::Create(curve3.Pass(), 3, 3, Animation::TRANSFORM);
1975 controller_impl->AddAnimation(animation.Pass());
1976
1977 EXPECT_TRUE(controller_impl->AnimationStartScale(&start_scale));
1978 EXPECT_EQ(6.f, start_scale);
1979
1980 controller_impl->GetAnimationById(2)
1981 ->SetRunState(Animation::FINISHED, TicksFromSecondsF(0.0));
1982
1983 // Only unfinished animations should be considered by
1984 // AnimationStartScale.
1985 EXPECT_TRUE(controller_impl->AnimationStartScale(&start_scale));
1986 EXPECT_EQ(5.f, start_scale);
1987 }
1988
1925 TEST(LayerAnimationControllerTest, MaximumTargetScale) { 1989 TEST(LayerAnimationControllerTest, MaximumTargetScale) {
1926 scoped_refptr<LayerAnimationController> controller_impl( 1990 scoped_refptr<LayerAnimationController> controller_impl(
1927 LayerAnimationController::Create(0)); 1991 LayerAnimationController::Create(0));
1928 1992
1929 float max_scale = 0.f; 1993 float max_scale = 0.f;
1930 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); 1994 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale));
1931 EXPECT_EQ(0.f, max_scale); 1995 EXPECT_EQ(0.f, max_scale);
1932 1996
1933 scoped_ptr<KeyframedTransformAnimationCurve> curve1( 1997 scoped_ptr<KeyframedTransformAnimationCurve> curve1(
1934 KeyframedTransformAnimationCurve::Create()); 1998 KeyframedTransformAnimationCurve::Create());
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
2381 EXPECT_FALSE(controller->IsAnimatingProperty(Animation::OPACITY)); 2445 EXPECT_FALSE(controller->IsAnimatingProperty(Animation::OPACITY));
2382 EXPECT_FALSE(controller->IsAnimatingProperty(Animation::FILTER)); 2446 EXPECT_FALSE(controller->IsAnimatingProperty(Animation::FILTER));
2383 2447
2384 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); 2448 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000));
2385 controller->UpdateState(true, nullptr); 2449 controller->UpdateState(true, nullptr);
2386 EXPECT_TRUE(controller->IsAnimatingProperty(Animation::OPACITY)); 2450 EXPECT_TRUE(controller->IsAnimatingProperty(Animation::OPACITY));
2387 } 2451 }
2388 2452
2389 } // namespace 2453 } // namespace
2390 } // namespace cc 2454 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/layer_animation_controller.cc ('k') | cc/layers/draw_properties.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698