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