Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Side by Side Diff: cc/keyframed_animation_curve_unittest.cc

Issue 11876016: Define cc::TransformOperations and webkit::WebTransformOperationsImpl (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Put TransformOperation into its own header Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/keyframed_animation_curve.cc ('k') | cc/test/animation_test_common.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
8 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
9 #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformOperati ons.h" 10 #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformOperati ons.h"
10 #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMa trix.h" 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMa trix.h"
11 12
12 using WebKit::WebTransformationMatrix; 13 using WebKit::WebTransformationMatrix;
13 14
14 namespace cc { 15 namespace cc {
15 namespace { 16 namespace {
16 17
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 EXPECT_FLOAT_EQ(6, curve->getValue(1.5)); 81 EXPECT_FLOAT_EQ(6, curve->getValue(1.5));
81 EXPECT_FLOAT_EQ(6, curve->getValue(2)); 82 EXPECT_FLOAT_EQ(6, curve->getValue(2));
82 EXPECT_FLOAT_EQ(6, curve->getValue(3)); 83 EXPECT_FLOAT_EQ(6, curve->getValue(3));
83 } 84 }
84 85
85 86
86 // Tests that a transform animation with one keyframe works as expected. 87 // Tests that a transform animation with one keyframe works as expected.
87 TEST(KeyframedAnimationCurveTest, OneTransformKeyframe) 88 TEST(KeyframedAnimationCurveTest, OneTransformKeyframe)
88 { 89 {
89 scoped_ptr<KeyframedTransformAnimationCurve> curve(KeyframedTransformAnimati onCurve::create()); 90 scoped_ptr<KeyframedTransformAnimationCurve> curve(KeyframedTransformAnimati onCurve::create());
91 #if WEB_TRANSFORM_OPERATIONS_IS_VIRTUAL
92 TransformOperations operations;
93 operations.AppendTranslate(2, 0, 0);
94 #else
90 WebKit::WebTransformOperations operations; 95 WebKit::WebTransformOperations operations;
91 operations.appendTranslate(2, 0, 0); 96 operations.appendTranslate(2, 0, 0);
97 #endif
92 curve->addKeyframe(TransformKeyframe::create(0, operations, scoped_ptr<Timin gFunction>())); 98 curve->addKeyframe(TransformKeyframe::create(0, operations, scoped_ptr<Timin gFunction>()));
93 99
94 expectTranslateX(2, curve->getValue(-1)); 100 expectTranslateX(2, curve->getValue(-1));
95 expectTranslateX(2, curve->getValue(0)); 101 expectTranslateX(2, curve->getValue(0));
96 expectTranslateX(2, curve->getValue(0.5)); 102 expectTranslateX(2, curve->getValue(0.5));
97 expectTranslateX(2, curve->getValue(1)); 103 expectTranslateX(2, curve->getValue(1));
98 expectTranslateX(2, curve->getValue(2)); 104 expectTranslateX(2, curve->getValue(2));
99 } 105 }
100 106
101 // Tests that a transform animation with two keyframes works as expected. 107 // Tests that a transform animation with two keyframes works as expected.
102 TEST(KeyframedAnimationCurveTest, TwoTransformKeyframe) 108 TEST(KeyframedAnimationCurveTest, TwoTransformKeyframe)
103 { 109 {
104 scoped_ptr<KeyframedTransformAnimationCurve> curve(KeyframedTransformAnimati onCurve::create()); 110 scoped_ptr<KeyframedTransformAnimationCurve> curve(KeyframedTransformAnimati onCurve::create());
111 #if WEB_TRANSFORM_OPERATIONS_IS_VIRTUAL
112 TransformOperations operations1;
113 operations1.AppendTranslate(2, 0, 0);
114 TransformOperations operations2;
115 operations2.AppendTranslate(4, 0, 0);
116 #else
105 WebKit::WebTransformOperations operations1; 117 WebKit::WebTransformOperations operations1;
106 operations1.appendTranslate(2, 0, 0); 118 operations1.appendTranslate(2, 0, 0);
107 WebKit::WebTransformOperations operations2; 119 WebKit::WebTransformOperations operations2;
108 operations2.appendTranslate(4, 0, 0); 120 operations2.appendTranslate(4, 0, 0);
121 #endif
109 122
110 curve->addKeyframe(TransformKeyframe::create(0, operations1, scoped_ptr<Timi ngFunction>())); 123 curve->addKeyframe(TransformKeyframe::create(0, operations1, scoped_ptr<Timi ngFunction>()));
111 curve->addKeyframe(TransformKeyframe::create(1, operations2, scoped_ptr<Timi ngFunction>())); 124 curve->addKeyframe(TransformKeyframe::create(1, operations2, scoped_ptr<Timi ngFunction>()));
112 expectTranslateX(2, curve->getValue(-1)); 125 expectTranslateX(2, curve->getValue(-1));
113 expectTranslateX(2, curve->getValue(0)); 126 expectTranslateX(2, curve->getValue(0));
114 expectTranslateX(3, curve->getValue(0.5)); 127 expectTranslateX(3, curve->getValue(0.5));
115 expectTranslateX(4, curve->getValue(1)); 128 expectTranslateX(4, curve->getValue(1));
116 expectTranslateX(4, curve->getValue(2)); 129 expectTranslateX(4, curve->getValue(2));
117 } 130 }
118 131
119 // Tests that a transform animation with three keyframes works as expected. 132 // Tests that a transform animation with three keyframes works as expected.
120 TEST(KeyframedAnimationCurveTest, ThreeTransformKeyframe) 133 TEST(KeyframedAnimationCurveTest, ThreeTransformKeyframe)
121 { 134 {
122 scoped_ptr<KeyframedTransformAnimationCurve> curve(KeyframedTransformAnimati onCurve::create()); 135 scoped_ptr<KeyframedTransformAnimationCurve> curve(KeyframedTransformAnimati onCurve::create());
136 #if WEB_TRANSFORM_OPERATIONS_IS_VIRTUAL
137 TransformOperations operations1;
138 operations1.AppendTranslate(2, 0, 0);
139 TransformOperations operations2;
140 operations2.AppendTranslate(4, 0, 0);
141 TransformOperations operations3;
142 operations3.AppendTranslate(8, 0, 0);
143 #else
123 WebKit::WebTransformOperations operations1; 144 WebKit::WebTransformOperations operations1;
124 operations1.appendTranslate(2, 0, 0); 145 operations1.appendTranslate(2, 0, 0);
125 WebKit::WebTransformOperations operations2; 146 WebKit::WebTransformOperations operations2;
126 operations2.appendTranslate(4, 0, 0); 147 operations2.appendTranslate(4, 0, 0);
127 WebKit::WebTransformOperations operations3; 148 WebKit::WebTransformOperations operations3;
128 operations3.appendTranslate(8, 0, 0); 149 operations3.appendTranslate(8, 0, 0);
150 #endif
129 curve->addKeyframe(TransformKeyframe::create(0, operations1, scoped_ptr<Timi ngFunction>())); 151 curve->addKeyframe(TransformKeyframe::create(0, operations1, scoped_ptr<Timi ngFunction>()));
130 curve->addKeyframe(TransformKeyframe::create(1, operations2, scoped_ptr<Timi ngFunction>())); 152 curve->addKeyframe(TransformKeyframe::create(1, operations2, scoped_ptr<Timi ngFunction>()));
131 curve->addKeyframe(TransformKeyframe::create(2, operations3, scoped_ptr<Timi ngFunction>())); 153 curve->addKeyframe(TransformKeyframe::create(2, operations3, scoped_ptr<Timi ngFunction>()));
132 expectTranslateX(2, curve->getValue(-1)); 154 expectTranslateX(2, curve->getValue(-1));
133 expectTranslateX(2, curve->getValue(0)); 155 expectTranslateX(2, curve->getValue(0));
134 expectTranslateX(3, curve->getValue(0.5)); 156 expectTranslateX(3, curve->getValue(0.5));
135 expectTranslateX(4, curve->getValue(1)); 157 expectTranslateX(4, curve->getValue(1));
136 expectTranslateX(6, curve->getValue(1.5)); 158 expectTranslateX(6, curve->getValue(1.5));
137 expectTranslateX(8, curve->getValue(2)); 159 expectTranslateX(8, curve->getValue(2));
138 expectTranslateX(8, curve->getValue(3)); 160 expectTranslateX(8, curve->getValue(3));
139 } 161 }
140 162
141 // Tests that a transform animation with multiple keys at a given time works san ely. 163 // Tests that a transform animation with multiple keys at a given time works san ely.
142 TEST(KeyframedAnimationCurveTest, RepeatedTransformKeyTimes) 164 TEST(KeyframedAnimationCurveTest, RepeatedTransformKeyTimes)
143 { 165 {
144 scoped_ptr<KeyframedTransformAnimationCurve> curve(KeyframedTransformAnimati onCurve::create()); 166 scoped_ptr<KeyframedTransformAnimationCurve> curve(KeyframedTransformAnimati onCurve::create());
145 // A step function. 167 // A step function.
168 #if WEB_TRANSFORM_OPERATIONS_IS_VIRTUAL
169 TransformOperations operations1;
170 operations1.AppendTranslate(4, 0, 0);
171 TransformOperations operations2;
172 operations2.AppendTranslate(4, 0, 0);
173 TransformOperations operations3;
174 operations3.AppendTranslate(6, 0, 0);
175 TransformOperations operations4;
176 operations4.AppendTranslate(6, 0, 0);
177 #else
146 WebKit::WebTransformOperations operations1; 178 WebKit::WebTransformOperations operations1;
147 operations1.appendTranslate(4, 0, 0); 179 operations1.appendTranslate(4, 0, 0);
148 WebKit::WebTransformOperations operations2; 180 WebKit::WebTransformOperations operations2;
149 operations2.appendTranslate(4, 0, 0); 181 operations2.appendTranslate(4, 0, 0);
150 WebKit::WebTransformOperations operations3; 182 WebKit::WebTransformOperations operations3;
151 operations3.appendTranslate(6, 0, 0); 183 operations3.appendTranslate(6, 0, 0);
152 WebKit::WebTransformOperations operations4; 184 WebKit::WebTransformOperations operations4;
153 operations4.appendTranslate(6, 0, 0); 185 operations4.appendTranslate(6, 0, 0);
186 #endif
154 curve->addKeyframe(TransformKeyframe::create(0, operations1, scoped_ptr<Timi ngFunction>())); 187 curve->addKeyframe(TransformKeyframe::create(0, operations1, scoped_ptr<Timi ngFunction>()));
155 curve->addKeyframe(TransformKeyframe::create(1, operations2, scoped_ptr<Timi ngFunction>())); 188 curve->addKeyframe(TransformKeyframe::create(1, operations2, scoped_ptr<Timi ngFunction>()));
156 curve->addKeyframe(TransformKeyframe::create(1, operations3, scoped_ptr<Timi ngFunction>())); 189 curve->addKeyframe(TransformKeyframe::create(1, operations3, scoped_ptr<Timi ngFunction>()));
157 curve->addKeyframe(TransformKeyframe::create(2, operations4, scoped_ptr<Timi ngFunction>())); 190 curve->addKeyframe(TransformKeyframe::create(2, operations4, scoped_ptr<Timi ngFunction>()));
158 191
159 expectTranslateX(4, curve->getValue(-1)); 192 expectTranslateX(4, curve->getValue(-1));
160 expectTranslateX(4, curve->getValue(0)); 193 expectTranslateX(4, curve->getValue(0));
161 expectTranslateX(4, curve->getValue(0.5)); 194 expectTranslateX(4, curve->getValue(0.5));
162 195
163 // There is a discontinuity at 1. Any value between 4 and 6 is valid. 196 // There is a discontinuity at 1. Any value between 4 and 6 is valid.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 EXPECT_LT(0, curve->getValue(0.25)); 229 EXPECT_LT(0, curve->getValue(0.25));
197 EXPECT_GT(0.25, curve->getValue(0.25)); 230 EXPECT_GT(0.25, curve->getValue(0.25));
198 EXPECT_NEAR(curve->getValue(0.5), 0.5, 0.00015); 231 EXPECT_NEAR(curve->getValue(0.5), 0.5, 0.00015);
199 EXPECT_LT(0.75, curve->getValue(0.75)); 232 EXPECT_LT(0.75, curve->getValue(0.75));
200 EXPECT_GT(1, curve->getValue(0.75)); 233 EXPECT_GT(1, curve->getValue(0.75));
201 EXPECT_FLOAT_EQ(1, curve->getValue(1)); 234 EXPECT_FLOAT_EQ(1, curve->getValue(1));
202 } 235 }
203 236
204 } // namespace 237 } // namespace
205 } // namespace cc 238 } // namespace cc
OLDNEW
« no previous file with comments | « cc/keyframed_animation_curve.cc ('k') | cc/test/animation_test_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698