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

Side by Side Diff: webkit/compositor_bindings/web_transform_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: 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
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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "cc/timing_function.h" 6 #include "cc/timing_function.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMa trix.h" 8 #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMa trix.h"
9 #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformOperati ons.h" 9 #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformOperati ons.h"
10 #include "webkit/compositor_bindings/web_transform_animation_curve_impl.h" 10 #include "webkit/compositor_bindings/web_transform_animation_curve_impl.h"
11 #include "webkit/compositor_bindings/web_transform_operations_impl.h"
11 12
12 using namespace WebKit; 13 using namespace WebKit;
13 14
14 namespace { 15 namespace {
15 16
16 // Tests that a transform animation with one keyframe works as expected. 17 // Tests that a transform animation with one keyframe works as expected.
17 TEST(WebTransformAnimationCurveTest, OneTransformKeyframe) 18 TEST(WebTransformAnimationCurveTest, OneTransformKeyframe)
18 { 19 {
19 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl); 20 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl);
20 WebKit::WebTransformOperations operations; 21 #if WEB_TRANSFORM_OPERATIONS_IS_VIRTUAL
22 scoped_ptr<WebTransformOperations> operations(new WebTransformOperationsImpl ());
23 operations->appendTranslate(2, 0, 0);
24 curve->add(WebTransformKeyframe(0, operations.release()), WebAnimationCurve: :TimingFunctionTypeLinear);
25 #else
26 WebTransformOperations operations;
21 operations.appendTranslate(2, 0, 0); 27 operations.appendTranslate(2, 0, 0);
22 curve->add(WebTransformKeyframe(0, operations), WebAnimationCurve::TimingFun ctionTypeLinear); 28 curve->add(WebTransformKeyframe(0, operations), WebAnimationCurve::TimingFun ctionTypeLinear);
29 #endif
23 30
24 EXPECT_FLOAT_EQ(2, curve->getValue(-1).m41()); 31 EXPECT_FLOAT_EQ(2, curve->getValue(-1).m41());
25 EXPECT_FLOAT_EQ(2, curve->getValue(0).m41()); 32 EXPECT_FLOAT_EQ(2, curve->getValue(0).m41());
26 EXPECT_FLOAT_EQ(2, curve->getValue(0.5).m41()); 33 EXPECT_FLOAT_EQ(2, curve->getValue(0.5).m41());
27 EXPECT_FLOAT_EQ(2, curve->getValue(1).m41()); 34 EXPECT_FLOAT_EQ(2, curve->getValue(1).m41());
28 EXPECT_FLOAT_EQ(2, curve->getValue(2).m41()); 35 EXPECT_FLOAT_EQ(2, curve->getValue(2).m41());
29 } 36 }
30 37
31 // Tests that a transform animation with two keyframes works as expected. 38 // Tests that a transform animation with two keyframes works as expected.
32 TEST(WebTransformAnimationCurveTest, TwoTransformKeyframe) 39 TEST(WebTransformAnimationCurveTest, TwoTransformKeyframe)
33 { 40 {
34 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl); 41 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl);
35 WebKit::WebTransformOperations operations1; 42 #if WEB_TRANSFORM_OPERATIONS_IS_VIRTUAL
43 scoped_ptr<WebTransformOperations> operations1(new WebTransformOperationsImp l());
44 operations1->appendTranslate(2, 0, 0);
45 scoped_ptr<WebTransformOperations> operations2(new WebTransformOperationsImp l());
46 operations2->appendTranslate(4, 0, 0);
47 curve->add(WebTransformKeyframe(0, operations1.release()), WebAnimationCurve ::TimingFunctionTypeLinear);
48 curve->add(WebTransformKeyframe(1, operations2.release()), WebAnimationCurve ::TimingFunctionTypeLinear);
49 #else
50 WebTransformOperations operations1;
36 operations1.appendTranslate(2, 0, 0); 51 operations1.appendTranslate(2, 0, 0);
37 WebKit::WebTransformOperations operations2; 52 WebTransformOperations operations2;
38 operations2.appendTranslate(4, 0, 0); 53 operations2.appendTranslate(4, 0, 0);
39 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeLinear); 54 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeLinear);
40 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear); 55 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear);
56 #endif
41 EXPECT_FLOAT_EQ(2, curve->getValue(-1).m41()); 57 EXPECT_FLOAT_EQ(2, curve->getValue(-1).m41());
42 EXPECT_FLOAT_EQ(2, curve->getValue(0).m41()); 58 EXPECT_FLOAT_EQ(2, curve->getValue(0).m41());
43 EXPECT_FLOAT_EQ(3, curve->getValue(0.5).m41()); 59 EXPECT_FLOAT_EQ(3, curve->getValue(0.5).m41());
44 EXPECT_FLOAT_EQ(4, curve->getValue(1).m41()); 60 EXPECT_FLOAT_EQ(4, curve->getValue(1).m41());
45 EXPECT_FLOAT_EQ(4, curve->getValue(2).m41()); 61 EXPECT_FLOAT_EQ(4, curve->getValue(2).m41());
46 } 62 }
47 63
48 // Tests that a transform animation with three keyframes works as expected. 64 // Tests that a transform animation with three keyframes works as expected.
49 TEST(WebTransformAnimationCurveTest, ThreeTransformKeyframe) 65 TEST(WebTransformAnimationCurveTest, ThreeTransformKeyframe)
50 { 66 {
51 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl); 67 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl);
52 WebKit::WebTransformOperations operations1; 68 #if WEB_TRANSFORM_OPERATIONS_IS_VIRTUAL
69 scoped_ptr<WebTransformOperations> operations1(new WebTransformOperationsImp l());
70 operations1->appendTranslate(2, 0, 0);
71 scoped_ptr<WebTransformOperations> operations2(new WebTransformOperationsImp l());
72 operations2->appendTranslate(4, 0, 0);
73 scoped_ptr<WebTransformOperations> operations3(new WebTransformOperationsImp l());
74 operations3->appendTranslate(8, 0, 0);
75 curve->add(WebTransformKeyframe(0, operations1.release()), WebAnimationCurve ::TimingFunctionTypeLinear);
76 curve->add(WebTransformKeyframe(1, operations2.release()), WebAnimationCurve ::TimingFunctionTypeLinear);
77 curve->add(WebTransformKeyframe(2, operations3.release()), WebAnimationCurve ::TimingFunctionTypeLinear);
78 #else
79 WebTransformOperations operations1;
53 operations1.appendTranslate(2, 0, 0); 80 operations1.appendTranslate(2, 0, 0);
54 WebKit::WebTransformOperations operations2; 81 WebTransformOperations operations2;
55 operations2.appendTranslate(4, 0, 0); 82 operations2.appendTranslate(4, 0, 0);
56 WebKit::WebTransformOperations operations3; 83 WebTransformOperations operations3;
57 operations3.appendTranslate(8, 0, 0); 84 operations3.appendTranslate(8, 0, 0);
58 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeLinear); 85 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeLinear);
59 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear); 86 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear);
60 curve->add(WebTransformKeyframe(2, operations3), WebAnimationCurve::TimingFu nctionTypeLinear); 87 curve->add(WebTransformKeyframe(2, operations3), WebAnimationCurve::TimingFu nctionTypeLinear);
88 #endif
61 EXPECT_FLOAT_EQ(2, curve->getValue(-1).m41()); 89 EXPECT_FLOAT_EQ(2, curve->getValue(-1).m41());
62 EXPECT_FLOAT_EQ(2, curve->getValue(0).m41()); 90 EXPECT_FLOAT_EQ(2, curve->getValue(0).m41());
63 EXPECT_FLOAT_EQ(3, curve->getValue(0.5).m41()); 91 EXPECT_FLOAT_EQ(3, curve->getValue(0.5).m41());
64 EXPECT_FLOAT_EQ(4, curve->getValue(1).m41()); 92 EXPECT_FLOAT_EQ(4, curve->getValue(1).m41());
65 EXPECT_FLOAT_EQ(6, curve->getValue(1.5).m41()); 93 EXPECT_FLOAT_EQ(6, curve->getValue(1.5).m41());
66 EXPECT_FLOAT_EQ(8, curve->getValue(2).m41()); 94 EXPECT_FLOAT_EQ(8, curve->getValue(2).m41());
67 EXPECT_FLOAT_EQ(8, curve->getValue(3).m41()); 95 EXPECT_FLOAT_EQ(8, curve->getValue(3).m41());
68 } 96 }
69 97
70 // Tests that a transform animation with multiple keys at a given time works san ely. 98 // Tests that a transform animation with multiple keys at a given time works san ely.
71 TEST(WebTransformAnimationCurveTest, RepeatedTransformKeyTimes) 99 TEST(WebTransformAnimationCurveTest, RepeatedTransformKeyTimes)
72 { 100 {
73 // A step function. 101 // A step function.
74 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl); 102 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl);
75 WebKit::WebTransformOperations operations1; 103 #if WEB_TRANSFORM_OPERATIONS_IS_VIRTUAL
104 scoped_ptr<WebTransformOperations> operations1(new WebTransformOperationsImp l());
105 operations1->appendTranslate(4, 0, 0);
106 scoped_ptr<WebTransformOperations> operations2(new WebTransformOperationsImp l());
107 operations2->appendTranslate(4, 0, 0);
108 scoped_ptr<WebTransformOperations> operations3(new WebTransformOperationsImp l());
109 operations3->appendTranslate(6, 0, 0);
110 scoped_ptr<WebTransformOperations> operations4(new WebTransformOperationsImp l());
111 operations4->appendTranslate(6, 0, 0);
112 curve->add(WebTransformKeyframe(0, operations1.release()), WebAnimationCurve ::TimingFunctionTypeLinear);
113 curve->add(WebTransformKeyframe(1, operations2.release()), WebAnimationCurve ::TimingFunctionTypeLinear);
114 curve->add(WebTransformKeyframe(1, operations3.release()), WebAnimationCurve ::TimingFunctionTypeLinear);
115 curve->add(WebTransformKeyframe(2, operations4.release()), WebAnimationCurve ::TimingFunctionTypeLinear);
116 #else
117 WebTransformOperations operations1;
76 operations1.appendTranslate(4, 0, 0); 118 operations1.appendTranslate(4, 0, 0);
77 WebKit::WebTransformOperations operations2; 119 WebTransformOperations operations2;
78 operations2.appendTranslate(4, 0, 0); 120 operations2.appendTranslate(4, 0, 0);
79 WebKit::WebTransformOperations operations3; 121 WebTransformOperations operations3;
80 operations3.appendTranslate(6, 0, 0); 122 operations3.appendTranslate(6, 0, 0);
81 WebKit::WebTransformOperations operations4; 123 WebTransformOperations operations4;
82 operations4.appendTranslate(6, 0, 0); 124 operations4.appendTranslate(6, 0, 0);
83 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeLinear); 125 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeLinear);
84 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear); 126 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear);
85 curve->add(WebTransformKeyframe(1, operations3), WebAnimationCurve::TimingFu nctionTypeLinear); 127 curve->add(WebTransformKeyframe(1, operations3), WebAnimationCurve::TimingFu nctionTypeLinear);
86 curve->add(WebTransformKeyframe(2, operations4), WebAnimationCurve::TimingFu nctionTypeLinear); 128 curve->add(WebTransformKeyframe(2, operations4), WebAnimationCurve::TimingFu nctionTypeLinear);
129 #endif
87 130
88 EXPECT_FLOAT_EQ(4, curve->getValue(-1).m41()); 131 EXPECT_FLOAT_EQ(4, curve->getValue(-1).m41());
89 EXPECT_FLOAT_EQ(4, curve->getValue(0).m41()); 132 EXPECT_FLOAT_EQ(4, curve->getValue(0).m41());
90 EXPECT_FLOAT_EQ(4, curve->getValue(0.5).m41()); 133 EXPECT_FLOAT_EQ(4, curve->getValue(0.5).m41());
91 134
92 // There is a discontinuity at 1. Any value between 4 and 6 is valid. 135 // There is a discontinuity at 1. Any value between 4 and 6 is valid.
93 WebTransformationMatrix value = curve->getValue(1); 136 WebTransformationMatrix value = curve->getValue(1);
94 EXPECT_TRUE(value.m41() >= 4 && value.m41() <= 6); 137 EXPECT_TRUE(value.m41() >= 4 && value.m41() <= 6);
95 138
96 EXPECT_FLOAT_EQ(6, curve->getValue(1.5).m41()); 139 EXPECT_FLOAT_EQ(6, curve->getValue(1.5).m41());
97 EXPECT_FLOAT_EQ(6, curve->getValue(2).m41()); 140 EXPECT_FLOAT_EQ(6, curve->getValue(2).m41());
98 EXPECT_FLOAT_EQ(6, curve->getValue(3).m41()); 141 EXPECT_FLOAT_EQ(6, curve->getValue(3).m41());
99 } 142 }
100 143
101 // Tests that the keyframes may be added out of order. 144 // Tests that the keyframes may be added out of order.
102 TEST(WebTransformAnimationCurveTest, UnsortedKeyframes) 145 TEST(WebTransformAnimationCurveTest, UnsortedKeyframes)
103 { 146 {
104 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl); 147 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl);
105 WebKit::WebTransformOperations operations1; 148 #if WEB_TRANSFORM_OPERATIONS_IS_VIRTUAL
149 scoped_ptr<WebTransformOperations> operations1(new WebTransformOperationsImp l());
150 operations1->appendTranslate(2, 0, 0);
151 scoped_ptr<WebTransformOperations> operations2(new WebTransformOperationsImp l());
152 operations2->appendTranslate(4, 0, 0);
153 scoped_ptr<WebTransformOperations> operations3(new WebTransformOperationsImp l());
154 operations3->appendTranslate(8, 0, 0);
155 curve->add(WebTransformKeyframe(2, operations3.release()), WebAnimationCurve ::TimingFunctionTypeLinear);
156 curve->add(WebTransformKeyframe(0, operations1.release()), WebAnimationCurve ::TimingFunctionTypeLinear);
157 curve->add(WebTransformKeyframe(1, operations2.release()), WebAnimationCurve ::TimingFunctionTypeLinear);
158 #else
159 WebTransformOperations operations1;
106 operations1.appendTranslate(2, 0, 0); 160 operations1.appendTranslate(2, 0, 0);
107 WebKit::WebTransformOperations operations2; 161 WebTransformOperations operations2;
108 operations2.appendTranslate(4, 0, 0); 162 operations2.appendTranslate(4, 0, 0);
109 WebKit::WebTransformOperations operations3; 163 WebTransformOperations operations3;
110 operations3.appendTranslate(8, 0, 0); 164 operations3.appendTranslate(8, 0, 0);
111 curve->add(WebTransformKeyframe(2, operations3), WebAnimationCurve::TimingFu nctionTypeLinear); 165 curve->add(WebTransformKeyframe(2, operations3), WebAnimationCurve::TimingFu nctionTypeLinear);
112 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeLinear); 166 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeLinear);
113 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear); 167 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear);
168 #endif
114 169
115 EXPECT_FLOAT_EQ(2, curve->getValue(-1).m41()); 170 EXPECT_FLOAT_EQ(2, curve->getValue(-1).m41());
116 EXPECT_FLOAT_EQ(2, curve->getValue(0).m41()); 171 EXPECT_FLOAT_EQ(2, curve->getValue(0).m41());
117 EXPECT_FLOAT_EQ(3, curve->getValue(0.5).m41()); 172 EXPECT_FLOAT_EQ(3, curve->getValue(0.5).m41());
118 EXPECT_FLOAT_EQ(4, curve->getValue(1).m41()); 173 EXPECT_FLOAT_EQ(4, curve->getValue(1).m41());
119 EXPECT_FLOAT_EQ(6, curve->getValue(1.5).m41()); 174 EXPECT_FLOAT_EQ(6, curve->getValue(1.5).m41());
120 EXPECT_FLOAT_EQ(8, curve->getValue(2).m41()); 175 EXPECT_FLOAT_EQ(8, curve->getValue(2).m41());
121 EXPECT_FLOAT_EQ(8, curve->getValue(3).m41()); 176 EXPECT_FLOAT_EQ(8, curve->getValue(3).m41());
122 } 177 }
123 178
124 // Tests that a cubic bezier timing function works as expected. 179 // Tests that a cubic bezier timing function works as expected.
125 TEST(WebTransformAnimationCurveTest, CubicBezierTimingFunction) 180 TEST(WebTransformAnimationCurveTest, CubicBezierTimingFunction)
126 { 181 {
127 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl); 182 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl);
128 WebKit::WebTransformOperations operations1; 183 #if WEB_TRANSFORM_OPERATIONS_IS_VIRTUAL
184 scoped_ptr<WebTransformOperations> operations1(new WebTransformOperationsImp l());
185 operations1->appendTranslate(0, 0, 0);
186 scoped_ptr<WebTransformOperations> operations2(new WebTransformOperationsImp l());
187 operations2->appendTranslate(1, 0, 0);
188 curve->add(WebTransformKeyframe(0, operations1.release()), 0.25, 0, 0.75, 1) ;
189 curve->add(WebTransformKeyframe(1, operations2.release()), WebAnimationCurve ::TimingFunctionTypeLinear);
190 #else
191 WebTransformOperations operations1;
129 operations1.appendTranslate(0, 0, 0); 192 operations1.appendTranslate(0, 0, 0);
130 WebKit::WebTransformOperations operations2; 193 WebTransformOperations operations2;
131 operations2.appendTranslate(1, 0, 0); 194 operations2.appendTranslate(1, 0, 0);
132 curve->add(WebTransformKeyframe(0, operations1), 0.25, 0, 0.75, 1); 195 curve->add(WebTransformKeyframe(0, operations1), 0.25, 0, 0.75, 1);
133 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear); 196 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear);
197 #endif
134 EXPECT_FLOAT_EQ(0, curve->getValue(0).m41()); 198 EXPECT_FLOAT_EQ(0, curve->getValue(0).m41());
135 EXPECT_LT(0, curve->getValue(0.25).m41()); 199 EXPECT_LT(0, curve->getValue(0.25).m41());
136 EXPECT_GT(0.25, curve->getValue(0.25).m41()); 200 EXPECT_GT(0.25, curve->getValue(0.25).m41());
137 EXPECT_NEAR(curve->getValue(0.5).m41(), 0.5, 0.00015); 201 EXPECT_NEAR(curve->getValue(0.5).m41(), 0.5, 0.00015);
138 EXPECT_LT(0.75, curve->getValue(0.75).m41()); 202 EXPECT_LT(0.75, curve->getValue(0.75).m41());
139 EXPECT_GT(1, curve->getValue(0.75).m41()); 203 EXPECT_GT(1, curve->getValue(0.75).m41());
140 EXPECT_FLOAT_EQ(1, curve->getValue(1).m41()); 204 EXPECT_FLOAT_EQ(1, curve->getValue(1).m41());
141 } 205 }
142 206
143 // Tests that an ease timing function works as expected. 207 // Tests that an ease timing function works as expected.
144 TEST(WebTransformAnimationCurveTest, EaseTimingFunction) 208 TEST(WebTransformAnimationCurveTest, EaseTimingFunction)
145 { 209 {
146 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl); 210 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl);
147 WebKit::WebTransformOperations operations1; 211 #if WEB_TRANSFORM_OPERATIONS_IS_VIRTUAL
212 scoped_ptr<WebTransformOperations> operations1(new WebTransformOperationsImp l());
213 operations1->appendTranslate(0, 0, 0);
214 scoped_ptr<WebTransformOperations> operations2(new WebTransformOperationsImp l());
215 operations2->appendTranslate(1, 0, 0);
216 curve->add(WebTransformKeyframe(0, operations1.release()), WebAnimationCurve ::TimingFunctionTypeEase);
217 curve->add(WebTransformKeyframe(1, operations2.release()), WebAnimationCurve ::TimingFunctionTypeLinear);
218 #else
219 WebTransformOperations operations1;
148 operations1.appendTranslate(0, 0, 0); 220 operations1.appendTranslate(0, 0, 0);
149 WebKit::WebTransformOperations operations2; 221 WebTransformOperations operations2;
150 operations2.appendTranslate(1, 0, 0); 222 operations2.appendTranslate(1, 0, 0);
151 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeEase); 223 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeEase);
152 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear); 224 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear);
225 #endif
153 226
154 scoped_ptr<cc::TimingFunction> timingFunction(cc::EaseTimingFunction::create ()); 227 scoped_ptr<cc::TimingFunction> timingFunction(cc::EaseTimingFunction::create ());
155 for (int i = 0; i <= 4; ++i) { 228 for (int i = 0; i <= 4; ++i) {
156 const double time = i * 0.25; 229 const double time = i * 0.25;
157 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4 1()); 230 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4 1());
158 } 231 }
159 } 232 }
160 233
161 // Tests using a linear timing function. 234 // Tests using a linear timing function.
162 TEST(WebTransformAnimationCurveTest, LinearTimingFunction) 235 TEST(WebTransformAnimationCurveTest, LinearTimingFunction)
163 { 236 {
164 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl); 237 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl);
165 WebKit::WebTransformOperations operations1; 238 #if WEB_TRANSFORM_OPERATIONS_IS_VIRTUAL
239 scoped_ptr<WebTransformOperations> operations1(new WebTransformOperationsImp l());
240 operations1->appendTranslate(0, 0, 0);
241 scoped_ptr<WebTransformOperations> operations2(new WebTransformOperationsImp l());
242 operations2->appendTranslate(1, 0, 0);
243 curve->add(WebTransformKeyframe(0, operations1.release()), WebAnimationCurve ::TimingFunctionTypeLinear);
244 curve->add(WebTransformKeyframe(1, operations2.release()), WebAnimationCurve ::TimingFunctionTypeLinear);
245 #else
246 WebTransformOperations operations1;
166 operations1.appendTranslate(0, 0, 0); 247 operations1.appendTranslate(0, 0, 0);
167 WebKit::WebTransformOperations operations2; 248 WebTransformOperations operations2;
168 operations2.appendTranslate(1, 0, 0); 249 operations2.appendTranslate(1, 0, 0);
169 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeLinear); 250 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeLinear);
170 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear); 251 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear);
252 #endif
171 253
172 for (int i = 0; i <= 4; ++i) { 254 for (int i = 0; i <= 4; ++i) {
173 const double time = i * 0.25; 255 const double time = i * 0.25;
174 EXPECT_FLOAT_EQ(time, curve->getValue(time).m41()); 256 EXPECT_FLOAT_EQ(time, curve->getValue(time).m41());
175 } 257 }
176 } 258 }
177 259
178 // Tests that an ease in timing function works as expected. 260 // Tests that an ease in timing function works as expected.
179 TEST(WebTransformAnimationCurveTest, EaseInTimingFunction) 261 TEST(WebTransformAnimationCurveTest, EaseInTimingFunction)
180 { 262 {
181 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl); 263 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl);
182 WebKit::WebTransformOperations operations1; 264 #if WEB_TRANSFORM_OPERATIONS_IS_VIRTUAL
265 scoped_ptr<WebTransformOperations> operations1(new WebTransformOperationsImp l());
266 operations1->appendTranslate(0, 0, 0);
267 scoped_ptr<WebTransformOperations> operations2(new WebTransformOperationsImp l());
268 operations2->appendTranslate(1, 0, 0);
269 curve->add(WebTransformKeyframe(0, operations1.release()), WebAnimationCurve ::TimingFunctionTypeEaseIn);
270 curve->add(WebTransformKeyframe(1, operations2.release()), WebAnimationCurve ::TimingFunctionTypeLinear);
271 #else
272 WebTransformOperations operations1;
183 operations1.appendTranslate(0, 0, 0); 273 operations1.appendTranslate(0, 0, 0);
184 WebKit::WebTransformOperations operations2; 274 WebTransformOperations operations2;
185 operations2.appendTranslate(1, 0, 0); 275 operations2.appendTranslate(1, 0, 0);
186 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeEaseIn); 276 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeEaseIn);
187 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear); 277 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear);
278 #endif
188 279
189 scoped_ptr<cc::TimingFunction> timingFunction(cc::EaseInTimingFunction::crea te()); 280 scoped_ptr<cc::TimingFunction> timingFunction(cc::EaseInTimingFunction::crea te());
190 for (int i = 0; i <= 4; ++i) { 281 for (int i = 0; i <= 4; ++i) {
191 const double time = i * 0.25; 282 const double time = i * 0.25;
192 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4 1()); 283 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4 1());
193 } 284 }
194 } 285 }
195 286
196 // Tests that an ease in timing function works as expected. 287 // Tests that an ease in timing function works as expected.
197 TEST(WebTransformAnimationCurveTest, EaseOutTimingFunction) 288 TEST(WebTransformAnimationCurveTest, EaseOutTimingFunction)
198 { 289 {
199 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl); 290 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl);
200 WebKit::WebTransformOperations operations1; 291 #if WEB_TRANSFORM_OPERATIONS_IS_VIRTUAL
292 scoped_ptr<WebTransformOperations> operations1(new WebTransformOperationsImp l());
293 operations1->appendTranslate(0, 0, 0);
294 scoped_ptr<WebTransformOperations> operations2(new WebTransformOperationsImp l());
295 operations2->appendTranslate(1, 0, 0);
296 curve->add(WebTransformKeyframe(0, operations1.release()), WebAnimationCurve ::TimingFunctionTypeEaseOut);
297 curve->add(WebTransformKeyframe(1, operations2.release()), WebAnimationCurve ::TimingFunctionTypeLinear);
298 #else
299 WebTransformOperations operations1;
201 operations1.appendTranslate(0, 0, 0); 300 operations1.appendTranslate(0, 0, 0);
202 WebKit::WebTransformOperations operations2; 301 WebTransformOperations operations2;
203 operations2.appendTranslate(1, 0, 0); 302 operations2.appendTranslate(1, 0, 0);
204 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeEaseOut); 303 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeEaseOut);
205 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear); 304 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear);
305 #endif
206 306
207 scoped_ptr<cc::TimingFunction> timingFunction(cc::EaseOutTimingFunction::cre ate()); 307 scoped_ptr<cc::TimingFunction> timingFunction(cc::EaseOutTimingFunction::cre ate());
208 for (int i = 0; i <= 4; ++i) { 308 for (int i = 0; i <= 4; ++i) {
209 const double time = i * 0.25; 309 const double time = i * 0.25;
210 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4 1()); 310 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4 1());
211 } 311 }
212 } 312 }
213 313
214 // Tests that an ease in timing function works as expected. 314 // Tests that an ease in timing function works as expected.
215 TEST(WebTransformAnimationCurveTest, EaseInOutTimingFunction) 315 TEST(WebTransformAnimationCurveTest, EaseInOutTimingFunction)
216 { 316 {
217 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl); 317 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl);
218 WebKit::WebTransformOperations operations1; 318 #if WEB_TRANSFORM_OPERATIONS_IS_VIRTUAL
319 scoped_ptr<WebTransformOperations> operations1(new WebTransformOperationsImp l());
320 operations1->appendTranslate(0, 0, 0);
321 scoped_ptr<WebTransformOperations> operations2(new WebTransformOperationsImp l());
322 operations2->appendTranslate(1, 0, 0);
323 curve->add(WebTransformKeyframe(0, operations1.release()), WebAnimationCurve ::TimingFunctionTypeEaseInOut);
324 curve->add(WebTransformKeyframe(1, operations2.release()), WebAnimationCurve ::TimingFunctionTypeLinear);
325 #else
326 WebTransformOperations operations1;
219 operations1.appendTranslate(0, 0, 0); 327 operations1.appendTranslate(0, 0, 0);
220 WebKit::WebTransformOperations operations2; 328 WebTransformOperations operations2;
221 operations2.appendTranslate(1, 0, 0); 329 operations2.appendTranslate(1, 0, 0);
222 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeEaseInOut); 330 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeEaseInOut);
223 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear); 331 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear);
332 #endif
224 333
225 scoped_ptr<cc::TimingFunction> timingFunction(cc::EaseInOutTimingFunction::c reate()); 334 scoped_ptr<cc::TimingFunction> timingFunction(cc::EaseInOutTimingFunction::c reate());
226 for (int i = 0; i <= 4; ++i) { 335 for (int i = 0; i <= 4; ++i) {
227 const double time = i * 0.25; 336 const double time = i * 0.25;
228 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4 1()); 337 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4 1());
229 } 338 }
230 } 339 }
231 340
232 // Tests that an ease in timing function works as expected. 341 // Tests that an ease in timing function works as expected.
233 TEST(WebTransformAnimationCurveTest, CustomBezierTimingFunction) 342 TEST(WebTransformAnimationCurveTest, CustomBezierTimingFunction)
234 { 343 {
235 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl); 344 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl);
236 double x1 = 0.3; 345 double x1 = 0.3;
237 double y1 = 0.2; 346 double y1 = 0.2;
238 double x2 = 0.8; 347 double x2 = 0.8;
239 double y2 = 0.7; 348 double y2 = 0.7;
240 WebKit::WebTransformOperations operations1; 349 #if WEB_TRANSFORM_OPERATIONS_IS_VIRTUAL
350 scoped_ptr<WebTransformOperations> operations1(new WebTransformOperationsImp l());
351 operations1->appendTranslate(0, 0, 0);
352 scoped_ptr<WebTransformOperations> operations2(new WebTransformOperationsImp l());
353 operations2->appendTranslate(1, 0, 0);
354 curve->add(WebTransformKeyframe(0, operations1.release()), x1, y1, x2, y2);
355 curve->add(WebTransformKeyframe(1, operations2.release()), WebAnimationCurve ::TimingFunctionTypeLinear);
356 #else
357 WebTransformOperations operations1;
241 operations1.appendTranslate(0, 0, 0); 358 operations1.appendTranslate(0, 0, 0);
242 WebKit::WebTransformOperations operations2; 359 WebTransformOperations operations2;
243 operations2.appendTranslate(1, 0, 0); 360 operations2.appendTranslate(1, 0, 0);
244 curve->add(WebTransformKeyframe(0, operations1), x1, y1, x2, y2); 361 curve->add(WebTransformKeyframe(0, operations1), x1, y1, x2, y2);
245 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear); 362 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear);
363 #endif
246 364
247 scoped_ptr<cc::TimingFunction> timingFunction(cc::CubicBezierTimingFunction: :create(x1, y1, x2, y2)); 365 scoped_ptr<cc::TimingFunction> timingFunction(cc::CubicBezierTimingFunction: :create(x1, y1, x2, y2));
248 for (int i = 0; i <= 4; ++i) { 366 for (int i = 0; i <= 4; ++i) {
249 const double time = i * 0.25; 367 const double time = i * 0.25;
250 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4 1()); 368 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4 1());
251 } 369 }
252 } 370 }
253 371
254 // Tests that the default timing function is indeed ease. 372 // Tests that the default timing function is indeed ease.
255 TEST(WebTransformAnimationCurveTest, DefaultTimingFunction) 373 TEST(WebTransformAnimationCurveTest, DefaultTimingFunction)
256 { 374 {
257 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl); 375 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl);
258 WebKit::WebTransformOperations operations1; 376 #if WEB_TRANSFORM_OPERATIONS_IS_VIRTUAL
377 scoped_ptr<WebTransformOperations> operations1(new WebTransformOperationsImp l());
378 operations1->appendTranslate(0, 0, 0);
379 scoped_ptr<WebTransformOperations> operations2(new WebTransformOperationsImp l());
380 operations2->appendTranslate(1, 0, 0);
381 curve->add(WebTransformKeyframe(0, operations1.release()));
382 curve->add(WebTransformKeyframe(1, operations2.release()), WebAnimationCurve ::TimingFunctionTypeLinear);
383 #else
384 WebTransformOperations operations1;
259 operations1.appendTranslate(0, 0, 0); 385 operations1.appendTranslate(0, 0, 0);
260 WebKit::WebTransformOperations operations2; 386 WebTransformOperations operations2;
261 operations2.appendTranslate(1, 0, 0); 387 operations2.appendTranslate(1, 0, 0);
262 curve->add(WebTransformKeyframe(0, operations1)); 388 curve->add(WebTransformKeyframe(0, operations1));
263 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear); 389 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear);
390 #endif
264 391
265 scoped_ptr<cc::TimingFunction> timingFunction(cc::EaseTimingFunction::create ()); 392 scoped_ptr<cc::TimingFunction> timingFunction(cc::EaseTimingFunction::create ());
266 for (int i = 0; i <= 4; ++i) { 393 for (int i = 0; i <= 4; ++i) {
267 const double time = i * 0.25; 394 const double time = i * 0.25;
268 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4 1()); 395 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4 1());
269 } 396 }
270 } 397 }
271 398
272 } // namespace 399 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698