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