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 <public/WebTransformOperations.h> | |
danakj
2012/11/24 02:34:54
can undo all the changes in this file
| |
8 | |
7 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
9 #include <public/WebTransformOperations.h> | 11 #include "ui/gfx/transform.h" |
10 #include <public/WebTransformationMatrix.h> | |
11 | 12 |
12 using WebKit::WebTransformationMatrix; | 13 using gfx::Transform; |
13 | 14 |
14 namespace cc { | 15 namespace cc { |
15 namespace { | 16 namespace { |
16 | 17 |
17 void expectTranslateX(double translateX, const WebTransformationMatrix& matrix) | 18 void expectTranslateX(double translateX, const WebKit::WebTransformationMatrix& matrix) |
18 { | 19 { |
19 EXPECT_FLOAT_EQ(translateX, matrix.m41()); | 20 EXPECT_FLOAT_EQ(translateX, matrix.m41()); |
20 } | 21 } |
21 | 22 |
22 // Tests that a float animation with one keyframe works as expected. | 23 // Tests that a float animation with one keyframe works as expected. |
23 TEST(KeyframedAnimationCurveTest, OneFloatKeyframe) | 24 TEST(KeyframedAnimationCurveTest, OneFloatKeyframe) |
24 { | 25 { |
25 scoped_ptr<KeyframedFloatAnimationCurve> curve(KeyframedFloatAnimationCurve: :create()); | 26 scoped_ptr<KeyframedFloatAnimationCurve> curve(KeyframedFloatAnimationCurve: :create()); |
26 curve->addKeyframe(FloatKeyframe::create(0, 2, scoped_ptr<TimingFunction>()) ); | 27 curve->addKeyframe(FloatKeyframe::create(0, 2, scoped_ptr<TimingFunction>()) ); |
27 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); | 28 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 curve->addKeyframe(TransformKeyframe::create(0, operations1, scoped_ptr<Timi ngFunction>())); | 155 curve->addKeyframe(TransformKeyframe::create(0, operations1, scoped_ptr<Timi ngFunction>())); |
155 curve->addKeyframe(TransformKeyframe::create(1, operations2, scoped_ptr<Timi ngFunction>())); | 156 curve->addKeyframe(TransformKeyframe::create(1, operations2, scoped_ptr<Timi ngFunction>())); |
156 curve->addKeyframe(TransformKeyframe::create(1, operations3, scoped_ptr<Timi ngFunction>())); | 157 curve->addKeyframe(TransformKeyframe::create(1, operations3, scoped_ptr<Timi ngFunction>())); |
157 curve->addKeyframe(TransformKeyframe::create(2, operations4, scoped_ptr<Timi ngFunction>())); | 158 curve->addKeyframe(TransformKeyframe::create(2, operations4, scoped_ptr<Timi ngFunction>())); |
158 | 159 |
159 expectTranslateX(4, curve->getValue(-1)); | 160 expectTranslateX(4, curve->getValue(-1)); |
160 expectTranslateX(4, curve->getValue(0)); | 161 expectTranslateX(4, curve->getValue(0)); |
161 expectTranslateX(4, curve->getValue(0.5)); | 162 expectTranslateX(4, curve->getValue(0.5)); |
162 | 163 |
163 // There is a discontinuity at 1. Any value between 4 and 6 is valid. | 164 // There is a discontinuity at 1. Any value between 4 and 6 is valid. |
164 WebTransformationMatrix value = curve->getValue(1); | 165 WebKit::WebTransformationMatrix value = curve->getValue(1); |
165 EXPECT_TRUE(value.m41() >= 4 && value.m41() <= 6); | 166 EXPECT_TRUE(value.m41() >= 4 && value.m41() <= 6); |
166 | 167 |
167 expectTranslateX(6, curve->getValue(1.5)); | 168 expectTranslateX(6, curve->getValue(1.5)); |
168 expectTranslateX(6, curve->getValue(2)); | 169 expectTranslateX(6, curve->getValue(2)); |
169 expectTranslateX(6, curve->getValue(3)); | 170 expectTranslateX(6, curve->getValue(3)); |
170 } | 171 } |
171 | 172 |
172 // Tests that the keyframes may be added out of order. | 173 // Tests that the keyframes may be added out of order. |
173 TEST(KeyframedAnimationCurveTest, UnsortedKeyframes) | 174 TEST(KeyframedAnimationCurveTest, UnsortedKeyframes) |
174 { | 175 { |
(...skipping 21 matching lines...) Expand all Loading... | |
196 EXPECT_LT(0, curve->getValue(0.25)); | 197 EXPECT_LT(0, curve->getValue(0.25)); |
197 EXPECT_GT(0.25, curve->getValue(0.25)); | 198 EXPECT_GT(0.25, curve->getValue(0.25)); |
198 EXPECT_NEAR(curve->getValue(0.5), 0.5, 0.00015); | 199 EXPECT_NEAR(curve->getValue(0.5), 0.5, 0.00015); |
199 EXPECT_LT(0.75, curve->getValue(0.75)); | 200 EXPECT_LT(0.75, curve->getValue(0.75)); |
200 EXPECT_GT(1, curve->getValue(0.75)); | 201 EXPECT_GT(1, curve->getValue(0.75)); |
201 EXPECT_FLOAT_EQ(1, curve->getValue(1)); | 202 EXPECT_FLOAT_EQ(1, curve->getValue(1)); |
202 } | 203 } |
203 | 204 |
204 } // namespace | 205 } // namespace |
205 } // namespace cc | 206 } // namespace cc |
OLD | NEW |