// Copyright 2012 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ui/gfx/animation/keyframe/keyframed_animation_curve.h" #include <memory> #include "testing/gtest/include/gtest/gtest.h" #include "ui/gfx/animation/tween.h" #include "ui/gfx/geometry/box_f.h" #include "ui/gfx/geometry/test/geometry_util.h" #include "ui/gfx/geometry/transform_operations.h" #include "ui/gfx/test/sk_color_eq.h" namespace gfx { namespace { void ExpectTranslateX(SkScalar translate_x, const gfx::TransformOperations& operations) { … } #define SAMPLE(curve, time) … // Tests that a color animation with one keyframe works as expected. TEST(KeyframedAnimationCurveTest, OneColorKeyFrame) { … } // Tests that a color animation with two keyframes works as expected. TEST(KeyframedAnimationCurveTest, TwoColorKeyFrame) { … } // Tests that a color animation with three keyframes works as expected. TEST(KeyframedAnimationCurveTest, ThreeColorKeyFrame) { … } // Tests that a color animation with multiple keys at a given time works sanely. TEST(KeyframedAnimationCurveTest, RepeatedColorKeyFrame) { … } // Tests that a float animation with one keyframe works as expected. TEST(KeyframedAnimationCurveTest, OneFloatKeyframe) { … } // Tests that a float animation with two keyframes works as expected. TEST(KeyframedAnimationCurveTest, TwoFloatKeyframe) { … } // Tests that a float animation with three keyframes works as expected. TEST(KeyframedAnimationCurveTest, ThreeFloatKeyframe) { … } // Tests that a float animation with multiple keys at a given time works sanely. TEST(KeyframedAnimationCurveTest, RepeatedFloatKeyTimes) { … } // Tests that a transform animation with one keyframe works as expected. TEST(KeyframedAnimationCurveTest, OneTransformKeyframe) { … } // Tests that a transform animation with two keyframes works as expected. TEST(KeyframedAnimationCurveTest, TwoTransformKeyframe) { … } // Tests that a transform animation with three keyframes works as expected. TEST(KeyframedAnimationCurveTest, ThreeTransformKeyframe) { … } // Tests that a transform animation with multiple keys at a given time works // sanely. TEST(KeyframedAnimationCurveTest, RepeatedTransformKeyTimes) { … } // Tests that a discrete transform animation (e.g. where one or more keyframes // is a non-invertible matrix) works as expected. TEST(KeyframedAnimationCurveTest, DiscreteLinearTransformAnimation) { … } TEST(KeyframedAnimationCurveTest, DiscreteCubicBezierTransformAnimation) { … } // Tests that the keyframes may be added out of order. TEST(KeyframedAnimationCurveTest, UnsortedKeyframes) { … } // Tests that a linear timing function works as expected. TEST(KeyframedAnimationCurveTest, LinearTimingFunction) { … } // Tests that a cubic bezier timing function works as expected. TEST(KeyframedAnimationCurveTest, CubicBezierTimingFunction) { … } // Tests a step timing function if the change of values occur at the start. TEST(KeyframedAnimationCurveTest, KeyframeStepsTimingFunctionStepAtStart) { … } // Similar to KeyframeStepsTimingFunctionStepAtStart, but applying the timing // function to the curve rather than the first keyframe. TEST(KeyframedAnimationCurveTest, CurveStepsTimingFunctionStepAtStart) { … } // Tests a step timing function if the change of values occur at the end. TEST(KeyframedAnimationCurveTest, StepsTimingFunctionStepAtEnd) { … } // A jump_both steps function has 1 extra jump. Ensure that this doesn't // overflow when using the maximum number of steps. In this case, the steps // function should be effectively the same as linear. // crbug.com/1313399 TEST(KeyframedAnimationCurveTest, StepsTimingFunctionMaxSteps) { … } // Tests that maximum animation scale is computed as expected. TEST(KeyframedAnimationCurveTest, MaximumScale) { … } TEST(KeyframeAnimationCurveTest, NonCalculatableMaximumScale) { … } // Tests that an animation with a curve timing function works as expected. TEST(KeyframedAnimationCurveTest, CurveTiming) { … } // Tests that an animation with a curve and keyframe timing function works as // expected. TEST(KeyframedAnimationCurveTest, CurveAndKeyframeTiming) { … } // Tests that a linear timing function works as expected for inputs outside of // range [0,1] TEST(KeyframedAnimationCurveTest, LinearTimingInputsOutsideZeroOneRange) { … } // If a curve cubic-bezier timing function produces timing outputs outside // the range [0, 1] then a keyframe cubic-bezier timing function // should consume that input properly (using end-point gradients). TEST(KeyframedAnimationCurveTest, CurveTimingInputsOutsideZeroOneRange) { … } // Tests that a step timing function works as expected for inputs outside of // range [0,1] TEST(KeyframedAnimationCurveTest, StepsTimingStartInputsOutsideZeroOneRange) { … } TEST(KeyframedAnimationCurveTest, StepsTimingEndInputsOutsideZeroOneRange) { … } TEST(KeyframedAnimationCurveTest, StepTimingAtBounds) { … } // Tests that an animation with a curve timing function and multiple keyframes // works as expected. TEST(KeyframedAnimationCurveTest, CurveTimingMultipleKeyframes) { … } // Tests that an animation with a curve timing function that overshoots works as // expected. TEST(KeyframedAnimationCurveTest, CurveTimingOvershootMultipeKeyframes) { … } // Tests that a float animation with multiple keys works with scaled duration. TEST(KeyframedAnimationCurveTest, ScaledDuration) { … } // Tests that a size animation with one keyframe works as expected. TEST(KeyframedAnimationCurveTest, OneSizeKeyFrame) { … } // Tests that a size animation with two keyframes works as expected. TEST(KeyframedAnimationCurveTest, TwoSizeKeyFrame) { … } // Tests that a size animation with three keyframes works as expected. TEST(KeyframedAnimationCurveTest, ThreeSizeKeyFrame) { … } // Tests that a size animation with multiple keys at a given time works sanely. TEST(KeyframedAnimationCurveTest, RepeatedSizeKeyFrame) { … } // Tests that a rect animation with one keyframe works as expected. TEST(KeyframedAnimationCurveTest, OneRectKeyFrame) { … } // Tests that a rect animation with two keyframes works as expected. TEST(KeyframedAnimationCurveTest, TwoRectKeyFrame) { … } // Tests that a rect animation with three keyframes works as expected. TEST(KeyframedAnimationCurveTest, ThreeRectKeyFrame) { … } // Tests that a rect animation with multiple keys at a given time works sanely. TEST(KeyframedAnimationCurveTest, RepeatedRectKeyFrame) { … } // Tests that the computing of tick interval for STEPS TimingFunction works // correctly. TEST(KeyFrameAnimationCurveTest, TickIntervalForStepsTimingFunction) { … } // Tests that the computing of tick interval for CUBIC_BEZIER TimingFunction // works correctly. TEST(KeyFrameAnimationCurveTest, TickIntervalForCubicBezierTimingFunction) { … } // Tests that the computing of tick interval for LINEAR TimingFunction works // correctly. TEST(KeyFrameAnimationCurveTest, TickIntervalForLinearTimingFunction) { … } } // namespace } // namespace gfx