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