| OLD | NEW |
| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "CCKeyframedAnimationCurve.h" | 7 #include "CCKeyframedAnimationCurve.h" |
| 8 | 8 |
| 9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include <public/WebTransformOperations.h> | 11 #include <public/WebTransformOperations.h> |
| 12 #include <public/WebTransformationMatrix.h> | 12 #include <public/WebTransformationMatrix.h> |
| 13 | 13 |
| 14 using namespace cc; | 14 using namespace cc; |
| 15 using WebKit::WebTransformationMatrix; | 15 using WebKit::WebTransformationMatrix; |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 void expectTranslateX(double translateX, const WebTransformationMatrix& matrix) | 19 void expectTranslateX(double translateX, const WebTransformationMatrix& matrix) |
| 20 { | 20 { |
| 21 EXPECT_FLOAT_EQ(translateX, matrix.m41()); | 21 EXPECT_FLOAT_EQ(translateX, matrix.m41()); |
| 22 } | 22 } |
| 23 | 23 |
| 24 // Tests that a float animation with one keyframe works as expected. | 24 // Tests that a float animation with one keyframe works as expected. |
| 25 TEST(CCKeyframedAnimationCurveTest, OneFloatKeyframe) | 25 TEST(KeyframedAnimationCurveTest, OneFloatKeyframe) |
| 26 { | 26 { |
| 27 scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCu
rve::create()); | 27 scoped_ptr<KeyframedFloatAnimationCurve> curve(KeyframedFloatAnimationCurve:
:create()); |
| 28 curve->addKeyframe(CCFloatKeyframe::create(0, 2, scoped_ptr<CCTimingFunction
>())); | 28 curve->addKeyframe(FloatKeyframe::create(0, 2, scoped_ptr<TimingFunction>())
); |
| 29 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); | 29 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); |
| 30 EXPECT_FLOAT_EQ(2, curve->getValue(0)); | 30 EXPECT_FLOAT_EQ(2, curve->getValue(0)); |
| 31 EXPECT_FLOAT_EQ(2, curve->getValue(0.5)); | 31 EXPECT_FLOAT_EQ(2, curve->getValue(0.5)); |
| 32 EXPECT_FLOAT_EQ(2, curve->getValue(1)); | 32 EXPECT_FLOAT_EQ(2, curve->getValue(1)); |
| 33 EXPECT_FLOAT_EQ(2, curve->getValue(2)); | 33 EXPECT_FLOAT_EQ(2, curve->getValue(2)); |
| 34 } | 34 } |
| 35 | 35 |
| 36 // Tests that a float animation with two keyframes works as expected. | 36 // Tests that a float animation with two keyframes works as expected. |
| 37 TEST(CCKeyframedAnimationCurveTest, TwoFloatKeyframe) | 37 TEST(KeyframedAnimationCurveTest, TwoFloatKeyframe) |
| 38 { | 38 { |
| 39 scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCu
rve::create()); | 39 scoped_ptr<KeyframedFloatAnimationCurve> curve(KeyframedFloatAnimationCurve:
:create()); |
| 40 curve->addKeyframe(CCFloatKeyframe::create(0, 2, scoped_ptr<CCTimingFunction
>())); | 40 curve->addKeyframe(FloatKeyframe::create(0, 2, scoped_ptr<TimingFunction>())
); |
| 41 curve->addKeyframe(CCFloatKeyframe::create(1, 4, scoped_ptr<CCTimingFunction
>())); | 41 curve->addKeyframe(FloatKeyframe::create(1, 4, scoped_ptr<TimingFunction>())
); |
| 42 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); | 42 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); |
| 43 EXPECT_FLOAT_EQ(2, curve->getValue(0)); | 43 EXPECT_FLOAT_EQ(2, curve->getValue(0)); |
| 44 EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); | 44 EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); |
| 45 EXPECT_FLOAT_EQ(4, curve->getValue(1)); | 45 EXPECT_FLOAT_EQ(4, curve->getValue(1)); |
| 46 EXPECT_FLOAT_EQ(4, curve->getValue(2)); | 46 EXPECT_FLOAT_EQ(4, curve->getValue(2)); |
| 47 } | 47 } |
| 48 | 48 |
| 49 // Tests that a float animation with three keyframes works as expected. | 49 // Tests that a float animation with three keyframes works as expected. |
| 50 TEST(CCKeyframedAnimationCurveTest, ThreeFloatKeyframe) | 50 TEST(KeyframedAnimationCurveTest, ThreeFloatKeyframe) |
| 51 { | 51 { |
| 52 scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCu
rve::create()); | 52 scoped_ptr<KeyframedFloatAnimationCurve> curve(KeyframedFloatAnimationCurve:
:create()); |
| 53 curve->addKeyframe(CCFloatKeyframe::create(0, 2, scoped_ptr<CCTimingFunction
>())); | 53 curve->addKeyframe(FloatKeyframe::create(0, 2, scoped_ptr<TimingFunction>())
); |
| 54 curve->addKeyframe(CCFloatKeyframe::create(1, 4, scoped_ptr<CCTimingFunction
>())); | 54 curve->addKeyframe(FloatKeyframe::create(1, 4, scoped_ptr<TimingFunction>())
); |
| 55 curve->addKeyframe(CCFloatKeyframe::create(2, 8, scoped_ptr<CCTimingFunction
>())); | 55 curve->addKeyframe(FloatKeyframe::create(2, 8, scoped_ptr<TimingFunction>())
); |
| 56 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); | 56 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); |
| 57 EXPECT_FLOAT_EQ(2, curve->getValue(0)); | 57 EXPECT_FLOAT_EQ(2, curve->getValue(0)); |
| 58 EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); | 58 EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); |
| 59 EXPECT_FLOAT_EQ(4, curve->getValue(1)); | 59 EXPECT_FLOAT_EQ(4, curve->getValue(1)); |
| 60 EXPECT_FLOAT_EQ(6, curve->getValue(1.5)); | 60 EXPECT_FLOAT_EQ(6, curve->getValue(1.5)); |
| 61 EXPECT_FLOAT_EQ(8, curve->getValue(2)); | 61 EXPECT_FLOAT_EQ(8, curve->getValue(2)); |
| 62 EXPECT_FLOAT_EQ(8, curve->getValue(3)); | 62 EXPECT_FLOAT_EQ(8, curve->getValue(3)); |
| 63 } | 63 } |
| 64 | 64 |
| 65 // Tests that a float animation with multiple keys at a given time works sanely. | 65 // Tests that a float animation with multiple keys at a given time works sanely. |
| 66 TEST(CCKeyframedAnimationCurveTest, RepeatedFloatKeyTimes) | 66 TEST(KeyframedAnimationCurveTest, RepeatedFloatKeyTimes) |
| 67 { | 67 { |
| 68 scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCu
rve::create()); | 68 scoped_ptr<KeyframedFloatAnimationCurve> curve(KeyframedFloatAnimationCurve:
:create()); |
| 69 curve->addKeyframe(CCFloatKeyframe::create(0, 4, scoped_ptr<CCTimingFunction
>())); | 69 curve->addKeyframe(FloatKeyframe::create(0, 4, scoped_ptr<TimingFunction>())
); |
| 70 curve->addKeyframe(CCFloatKeyframe::create(1, 4, scoped_ptr<CCTimingFunction
>())); | 70 curve->addKeyframe(FloatKeyframe::create(1, 4, scoped_ptr<TimingFunction>())
); |
| 71 curve->addKeyframe(CCFloatKeyframe::create(1, 6, scoped_ptr<CCTimingFunction
>())); | 71 curve->addKeyframe(FloatKeyframe::create(1, 6, scoped_ptr<TimingFunction>())
); |
| 72 curve->addKeyframe(CCFloatKeyframe::create(2, 6, scoped_ptr<CCTimingFunction
>())); | 72 curve->addKeyframe(FloatKeyframe::create(2, 6, scoped_ptr<TimingFunction>())
); |
| 73 | 73 |
| 74 EXPECT_FLOAT_EQ(4, curve->getValue(-1)); | 74 EXPECT_FLOAT_EQ(4, curve->getValue(-1)); |
| 75 EXPECT_FLOAT_EQ(4, curve->getValue(0)); | 75 EXPECT_FLOAT_EQ(4, curve->getValue(0)); |
| 76 EXPECT_FLOAT_EQ(4, curve->getValue(0.5)); | 76 EXPECT_FLOAT_EQ(4, curve->getValue(0.5)); |
| 77 | 77 |
| 78 // There is a discontinuity at 1. Any value between 4 and 6 is valid. | 78 // There is a discontinuity at 1. Any value between 4 and 6 is valid. |
| 79 float value = curve->getValue(1); | 79 float value = curve->getValue(1); |
| 80 EXPECT_TRUE(value >= 4 && value <= 6); | 80 EXPECT_TRUE(value >= 4 && value <= 6); |
| 81 | 81 |
| 82 EXPECT_FLOAT_EQ(6, curve->getValue(1.5)); | 82 EXPECT_FLOAT_EQ(6, curve->getValue(1.5)); |
| 83 EXPECT_FLOAT_EQ(6, curve->getValue(2)); | 83 EXPECT_FLOAT_EQ(6, curve->getValue(2)); |
| 84 EXPECT_FLOAT_EQ(6, curve->getValue(3)); | 84 EXPECT_FLOAT_EQ(6, curve->getValue(3)); |
| 85 } | 85 } |
| 86 | 86 |
| 87 | 87 |
| 88 // Tests that a transform animation with one keyframe works as expected. | 88 // Tests that a transform animation with one keyframe works as expected. |
| 89 TEST(CCKeyframedAnimationCurveTest, OneTransformKeyframe) | 89 TEST(KeyframedAnimationCurveTest, OneTransformKeyframe) |
| 90 { | 90 { |
| 91 scoped_ptr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAni
mationCurve::create()); | 91 scoped_ptr<KeyframedTransformAnimationCurve> curve(KeyframedTransformAnimati
onCurve::create()); |
| 92 WebKit::WebTransformOperations operations; | 92 WebKit::WebTransformOperations operations; |
| 93 operations.appendTranslate(2, 0, 0); | 93 operations.appendTranslate(2, 0, 0); |
| 94 curve->addKeyframe(CCTransformKeyframe::create(0, operations, scoped_ptr<CCT
imingFunction>())); | 94 curve->addKeyframe(TransformKeyframe::create(0, operations, scoped_ptr<Timin
gFunction>())); |
| 95 | 95 |
| 96 expectTranslateX(2, curve->getValue(-1)); | 96 expectTranslateX(2, curve->getValue(-1)); |
| 97 expectTranslateX(2, curve->getValue(0)); | 97 expectTranslateX(2, curve->getValue(0)); |
| 98 expectTranslateX(2, curve->getValue(0.5)); | 98 expectTranslateX(2, curve->getValue(0.5)); |
| 99 expectTranslateX(2, curve->getValue(1)); | 99 expectTranslateX(2, curve->getValue(1)); |
| 100 expectTranslateX(2, curve->getValue(2)); | 100 expectTranslateX(2, curve->getValue(2)); |
| 101 } | 101 } |
| 102 | 102 |
| 103 // Tests that a transform animation with two keyframes works as expected. | 103 // Tests that a transform animation with two keyframes works as expected. |
| 104 TEST(CCKeyframedAnimationCurveTest, TwoTransformKeyframe) | 104 TEST(KeyframedAnimationCurveTest, TwoTransformKeyframe) |
| 105 { | 105 { |
| 106 scoped_ptr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAni
mationCurve::create()); | 106 scoped_ptr<KeyframedTransformAnimationCurve> curve(KeyframedTransformAnimati
onCurve::create()); |
| 107 WebKit::WebTransformOperations operations1; | 107 WebKit::WebTransformOperations operations1; |
| 108 operations1.appendTranslate(2, 0, 0); | 108 operations1.appendTranslate(2, 0, 0); |
| 109 WebKit::WebTransformOperations operations2; | 109 WebKit::WebTransformOperations operations2; |
| 110 operations2.appendTranslate(4, 0, 0); | 110 operations2.appendTranslate(4, 0, 0); |
| 111 | 111 |
| 112 curve->addKeyframe(CCTransformKeyframe::create(0, operations1, scoped_ptr<CC
TimingFunction>())); | 112 curve->addKeyframe(TransformKeyframe::create(0, operations1, scoped_ptr<Timi
ngFunction>())); |
| 113 curve->addKeyframe(CCTransformKeyframe::create(1, operations2, scoped_ptr<CC
TimingFunction>())); | 113 curve->addKeyframe(TransformKeyframe::create(1, operations2, scoped_ptr<Timi
ngFunction>())); |
| 114 expectTranslateX(2, curve->getValue(-1)); | 114 expectTranslateX(2, curve->getValue(-1)); |
| 115 expectTranslateX(2, curve->getValue(0)); | 115 expectTranslateX(2, curve->getValue(0)); |
| 116 expectTranslateX(3, curve->getValue(0.5)); | 116 expectTranslateX(3, curve->getValue(0.5)); |
| 117 expectTranslateX(4, curve->getValue(1)); | 117 expectTranslateX(4, curve->getValue(1)); |
| 118 expectTranslateX(4, curve->getValue(2)); | 118 expectTranslateX(4, curve->getValue(2)); |
| 119 } | 119 } |
| 120 | 120 |
| 121 // Tests that a transform animation with three keyframes works as expected. | 121 // Tests that a transform animation with three keyframes works as expected. |
| 122 TEST(CCKeyframedAnimationCurveTest, ThreeTransformKeyframe) | 122 TEST(KeyframedAnimationCurveTest, ThreeTransformKeyframe) |
| 123 { | 123 { |
| 124 scoped_ptr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAni
mationCurve::create()); | 124 scoped_ptr<KeyframedTransformAnimationCurve> curve(KeyframedTransformAnimati
onCurve::create()); |
| 125 WebKit::WebTransformOperations operations1; | 125 WebKit::WebTransformOperations operations1; |
| 126 operations1.appendTranslate(2, 0, 0); | 126 operations1.appendTranslate(2, 0, 0); |
| 127 WebKit::WebTransformOperations operations2; | 127 WebKit::WebTransformOperations operations2; |
| 128 operations2.appendTranslate(4, 0, 0); | 128 operations2.appendTranslate(4, 0, 0); |
| 129 WebKit::WebTransformOperations operations3; | 129 WebKit::WebTransformOperations operations3; |
| 130 operations3.appendTranslate(8, 0, 0); | 130 operations3.appendTranslate(8, 0, 0); |
| 131 curve->addKeyframe(CCTransformKeyframe::create(0, operations1, scoped_ptr<CC
TimingFunction>())); | 131 curve->addKeyframe(TransformKeyframe::create(0, operations1, scoped_ptr<Timi
ngFunction>())); |
| 132 curve->addKeyframe(CCTransformKeyframe::create(1, operations2, scoped_ptr<CC
TimingFunction>())); | 132 curve->addKeyframe(TransformKeyframe::create(1, operations2, scoped_ptr<Timi
ngFunction>())); |
| 133 curve->addKeyframe(CCTransformKeyframe::create(2, operations3, scoped_ptr<CC
TimingFunction>())); | 133 curve->addKeyframe(TransformKeyframe::create(2, operations3, scoped_ptr<Timi
ngFunction>())); |
| 134 expectTranslateX(2, curve->getValue(-1)); | 134 expectTranslateX(2, curve->getValue(-1)); |
| 135 expectTranslateX(2, curve->getValue(0)); | 135 expectTranslateX(2, curve->getValue(0)); |
| 136 expectTranslateX(3, curve->getValue(0.5)); | 136 expectTranslateX(3, curve->getValue(0.5)); |
| 137 expectTranslateX(4, curve->getValue(1)); | 137 expectTranslateX(4, curve->getValue(1)); |
| 138 expectTranslateX(6, curve->getValue(1.5)); | 138 expectTranslateX(6, curve->getValue(1.5)); |
| 139 expectTranslateX(8, curve->getValue(2)); | 139 expectTranslateX(8, curve->getValue(2)); |
| 140 expectTranslateX(8, curve->getValue(3)); | 140 expectTranslateX(8, curve->getValue(3)); |
| 141 } | 141 } |
| 142 | 142 |
| 143 // Tests that a transform animation with multiple keys at a given time works san
ely. | 143 // Tests that a transform animation with multiple keys at a given time works san
ely. |
| 144 TEST(CCKeyframedAnimationCurveTest, RepeatedTransformKeyTimes) | 144 TEST(KeyframedAnimationCurveTest, RepeatedTransformKeyTimes) |
| 145 { | 145 { |
| 146 scoped_ptr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAni
mationCurve::create()); | 146 scoped_ptr<KeyframedTransformAnimationCurve> curve(KeyframedTransformAnimati
onCurve::create()); |
| 147 // A step function. | 147 // A step function. |
| 148 WebKit::WebTransformOperations operations1; | 148 WebKit::WebTransformOperations operations1; |
| 149 operations1.appendTranslate(4, 0, 0); | 149 operations1.appendTranslate(4, 0, 0); |
| 150 WebKit::WebTransformOperations operations2; | 150 WebKit::WebTransformOperations operations2; |
| 151 operations2.appendTranslate(4, 0, 0); | 151 operations2.appendTranslate(4, 0, 0); |
| 152 WebKit::WebTransformOperations operations3; | 152 WebKit::WebTransformOperations operations3; |
| 153 operations3.appendTranslate(6, 0, 0); | 153 operations3.appendTranslate(6, 0, 0); |
| 154 WebKit::WebTransformOperations operations4; | 154 WebKit::WebTransformOperations operations4; |
| 155 operations4.appendTranslate(6, 0, 0); | 155 operations4.appendTranslate(6, 0, 0); |
| 156 curve->addKeyframe(CCTransformKeyframe::create(0, operations1, scoped_ptr<CC
TimingFunction>())); | 156 curve->addKeyframe(TransformKeyframe::create(0, operations1, scoped_ptr<Timi
ngFunction>())); |
| 157 curve->addKeyframe(CCTransformKeyframe::create(1, operations2, scoped_ptr<CC
TimingFunction>())); | 157 curve->addKeyframe(TransformKeyframe::create(1, operations2, scoped_ptr<Timi
ngFunction>())); |
| 158 curve->addKeyframe(CCTransformKeyframe::create(1, operations3, scoped_ptr<CC
TimingFunction>())); | 158 curve->addKeyframe(TransformKeyframe::create(1, operations3, scoped_ptr<Timi
ngFunction>())); |
| 159 curve->addKeyframe(CCTransformKeyframe::create(2, operations4, scoped_ptr<CC
TimingFunction>())); | 159 curve->addKeyframe(TransformKeyframe::create(2, operations4, scoped_ptr<Timi
ngFunction>())); |
| 160 | 160 |
| 161 expectTranslateX(4, curve->getValue(-1)); | 161 expectTranslateX(4, curve->getValue(-1)); |
| 162 expectTranslateX(4, curve->getValue(0)); | 162 expectTranslateX(4, curve->getValue(0)); |
| 163 expectTranslateX(4, curve->getValue(0.5)); | 163 expectTranslateX(4, curve->getValue(0.5)); |
| 164 | 164 |
| 165 // There is a discontinuity at 1. Any value between 4 and 6 is valid. | 165 // There is a discontinuity at 1. Any value between 4 and 6 is valid. |
| 166 WebTransformationMatrix value = curve->getValue(1); | 166 WebTransformationMatrix value = curve->getValue(1); |
| 167 EXPECT_TRUE(value.m41() >= 4 && value.m41() <= 6); | 167 EXPECT_TRUE(value.m41() >= 4 && value.m41() <= 6); |
| 168 | 168 |
| 169 expectTranslateX(6, curve->getValue(1.5)); | 169 expectTranslateX(6, curve->getValue(1.5)); |
| 170 expectTranslateX(6, curve->getValue(2)); | 170 expectTranslateX(6, curve->getValue(2)); |
| 171 expectTranslateX(6, curve->getValue(3)); | 171 expectTranslateX(6, curve->getValue(3)); |
| 172 } | 172 } |
| 173 | 173 |
| 174 // Tests that the keyframes may be added out of order. | 174 // Tests that the keyframes may be added out of order. |
| 175 TEST(CCKeyframedAnimationCurveTest, UnsortedKeyframes) | 175 TEST(KeyframedAnimationCurveTest, UnsortedKeyframes) |
| 176 { | 176 { |
| 177 scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCu
rve::create()); | 177 scoped_ptr<KeyframedFloatAnimationCurve> curve(KeyframedFloatAnimationCurve:
:create()); |
| 178 curve->addKeyframe(CCFloatKeyframe::create(2, 8, scoped_ptr<CCTimingFunction
>())); | 178 curve->addKeyframe(FloatKeyframe::create(2, 8, scoped_ptr<TimingFunction>())
); |
| 179 curve->addKeyframe(CCFloatKeyframe::create(0, 2, scoped_ptr<CCTimingFunction
>())); | 179 curve->addKeyframe(FloatKeyframe::create(0, 2, scoped_ptr<TimingFunction>())
); |
| 180 curve->addKeyframe(CCFloatKeyframe::create(1, 4, scoped_ptr<CCTimingFunction
>())); | 180 curve->addKeyframe(FloatKeyframe::create(1, 4, scoped_ptr<TimingFunction>())
); |
| 181 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); | 181 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); |
| 182 EXPECT_FLOAT_EQ(2, curve->getValue(0)); | 182 EXPECT_FLOAT_EQ(2, curve->getValue(0)); |
| 183 EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); | 183 EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); |
| 184 EXPECT_FLOAT_EQ(4, curve->getValue(1)); | 184 EXPECT_FLOAT_EQ(4, curve->getValue(1)); |
| 185 EXPECT_FLOAT_EQ(6, curve->getValue(1.5)); | 185 EXPECT_FLOAT_EQ(6, curve->getValue(1.5)); |
| 186 EXPECT_FLOAT_EQ(8, curve->getValue(2)); | 186 EXPECT_FLOAT_EQ(8, curve->getValue(2)); |
| 187 EXPECT_FLOAT_EQ(8, curve->getValue(3)); | 187 EXPECT_FLOAT_EQ(8, curve->getValue(3)); |
| 188 } | 188 } |
| 189 | 189 |
| 190 // Tests that a cubic bezier timing function works as expected. | 190 // Tests that a cubic bezier timing function works as expected. |
| 191 TEST(CCKeyframedAnimationCurveTest, CubicBezierTimingFunction) | 191 TEST(KeyframedAnimationCurveTest, CubicBezierTimingFunction) |
| 192 { | 192 { |
| 193 scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCu
rve::create()); | 193 scoped_ptr<KeyframedFloatAnimationCurve> curve(KeyframedFloatAnimationCurve:
:create()); |
| 194 curve->addKeyframe(CCFloatKeyframe::create(0, 0, CCCubicBezierTimingFunction
::create(0.25, 0, 0.75, 1).PassAs<CCTimingFunction>())); | 194 curve->addKeyframe(FloatKeyframe::create(0, 0, CubicBezierTimingFunction::cr
eate(0.25, 0, 0.75, 1).PassAs<TimingFunction>())); |
| 195 curve->addKeyframe(CCFloatKeyframe::create(1, 1, scoped_ptr<CCTimingFunction
>())); | 195 curve->addKeyframe(FloatKeyframe::create(1, 1, scoped_ptr<TimingFunction>())
); |
| 196 | 196 |
| 197 EXPECT_FLOAT_EQ(0, curve->getValue(0)); | 197 EXPECT_FLOAT_EQ(0, curve->getValue(0)); |
| 198 EXPECT_LT(0, curve->getValue(0.25)); | 198 EXPECT_LT(0, curve->getValue(0.25)); |
| 199 EXPECT_GT(0.25, curve->getValue(0.25)); | 199 EXPECT_GT(0.25, curve->getValue(0.25)); |
| 200 EXPECT_FLOAT_EQ(0.5, curve->getValue(0.5)); | 200 EXPECT_FLOAT_EQ(0.5, curve->getValue(0.5)); |
| 201 EXPECT_LT(0.75, curve->getValue(0.75)); | 201 EXPECT_LT(0.75, curve->getValue(0.75)); |
| 202 EXPECT_GT(1, curve->getValue(0.75)); | 202 EXPECT_GT(1, curve->getValue(0.75)); |
| 203 EXPECT_FLOAT_EQ(1, curve->getValue(1)); | 203 EXPECT_FLOAT_EQ(1, curve->getValue(1)); |
| 204 } | 204 } |
| 205 | 205 |
| 206 } // namespace | 206 } // namespace |
| OLD | NEW |