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

Side by Side Diff: Source/core/animation/KeyframeEffectTest.cpp

Issue 1326443003: Web Animations: Enable additive animations in experimental (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update missed tests Created 5 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/animation/ElementAnimation.idl ('k') | Source/platform/RuntimeEnabledFeatures.in » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "core/animation/KeyframeEffect.h" 6 #include "core/animation/KeyframeEffect.h"
7 7
8 #include "bindings/core/v8/Dictionary.h" 8 #include "bindings/core/v8/Dictionary.h"
9 #include "bindings/core/v8/UnionTypesCore.h" 9 #include "bindings/core/v8/UnionTypesCore.h"
10 #include "bindings/core/v8/V8BindingForTesting.h" 10 #include "bindings/core/v8/V8BindingForTesting.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration)); 128 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration));
129 } 129 }
130 130
131 TEST_F(AnimationKeyframeEffectV8Test, NegativeDurationIsAuto) 131 TEST_F(AnimationKeyframeEffectV8Test, NegativeDurationIsAuto)
132 { 132 {
133 Vector<Dictionary, 0> jsKeyframes; 133 Vector<Dictionary, 0> jsKeyframes;
134 KeyframeEffect* animation = createAnimation(element.get(), jsKeyframes, -2, exceptionState); 134 KeyframeEffect* animation = createAnimation(element.get(), jsKeyframes, -2, exceptionState);
135 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration)); 135 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration));
136 } 136 }
137 137
138 TEST_F(AnimationKeyframeEffectV8Test, MismatchedKeyframePropertyRaisesException)
139 {
140 Vector<Dictionary> jsKeyframes;
141 v8::Local<v8::Object> keyframe1 = v8::Object::New(m_isolate);
142 v8::Local<v8::Object> keyframe2 = v8::Object::New(m_isolate);
143
144 setV8ObjectPropertyAsString(m_isolate, keyframe1, "width", "100px");
145 setV8ObjectPropertyAsString(m_isolate, keyframe1, "offset", "0");
146
147 // Height property appears only in keyframe2
148 setV8ObjectPropertyAsString(m_isolate, keyframe2, "height", "100px");
149 setV8ObjectPropertyAsString(m_isolate, keyframe2, "width", "0px");
150 setV8ObjectPropertyAsString(m_isolate, keyframe2, "offset", "1");
151
152 jsKeyframes.append(Dictionary(keyframe1, m_isolate, exceptionState));
153 jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState));
154
155 createAnimation(element.get(), jsKeyframes, 0, exceptionState);
156
157 EXPECT_TRUE(exceptionState.hadException());
158 EXPECT_EQ(NotSupportedError, exceptionState.code());
159 }
160
161 TEST_F(AnimationKeyframeEffectV8Test, MissingOffsetZeroRaisesException)
162 {
163 Vector<Dictionary> jsKeyframes;
164 v8::Local<v8::Object> keyframe1 = v8::Object::New(m_isolate);
165 v8::Local<v8::Object> keyframe2 = v8::Object::New(m_isolate);
166
167 setV8ObjectPropertyAsString(m_isolate, keyframe1, "width", "100px");
168 setV8ObjectPropertyAsString(m_isolate, keyframe1, "offset", "0.1");
169 setV8ObjectPropertyAsString(m_isolate, keyframe2, "width", "0px");
170 setV8ObjectPropertyAsString(m_isolate, keyframe2, "offset", "1");
171
172 jsKeyframes.append(Dictionary(keyframe1, m_isolate, exceptionState));
173 jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState));
174
175 createAnimation(element.get(), jsKeyframes, 0, exceptionState);
176
177 EXPECT_TRUE(exceptionState.hadException());
178 EXPECT_EQ(NotSupportedError, exceptionState.code());
179 }
180
181 TEST_F(AnimationKeyframeEffectV8Test, MissingOffsetOneRaisesException)
182 {
183 Vector<Dictionary> jsKeyframes;
184 v8::Local<v8::Object> keyframe1 = v8::Object::New(m_isolate);
185 v8::Local<v8::Object> keyframe2 = v8::Object::New(m_isolate);
186
187 setV8ObjectPropertyAsString(m_isolate, keyframe1, "width", "100px");
188 setV8ObjectPropertyAsString(m_isolate, keyframe1, "offset", "0");
189 setV8ObjectPropertyAsString(m_isolate, keyframe2, "width", "0px");
190 setV8ObjectPropertyAsString(m_isolate, keyframe2, "offset", "0.1");
191
192 jsKeyframes.append(Dictionary(keyframe1, m_isolate, exceptionState));
193 jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState));
194
195 createAnimation(element.get(), jsKeyframes, 0, exceptionState);
196
197 EXPECT_TRUE(exceptionState.hadException());
198 EXPECT_EQ(NotSupportedError, exceptionState.code());
199 }
200
201 TEST_F(AnimationKeyframeEffectV8Test, MissingOffsetZeroAndOneRaisesException)
202 {
203 Vector<Dictionary> jsKeyframes;
204 v8::Local<v8::Object> keyframe1 = v8::Object::New(m_isolate);
205 v8::Local<v8::Object> keyframe2 = v8::Object::New(m_isolate);
206
207 setV8ObjectPropertyAsString(m_isolate, keyframe1, "width", "100px");
208 setV8ObjectPropertyAsString(m_isolate, keyframe1, "offset", "0.1");
209 setV8ObjectPropertyAsString(m_isolate, keyframe2, "width", "0px");
210 setV8ObjectPropertyAsString(m_isolate, keyframe2, "offset", "0.2");
211
212 jsKeyframes.append(Dictionary(keyframe1, m_isolate, exceptionState));
213 jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState));
214
215 createAnimation(element.get(), jsKeyframes, 0, exceptionState);
216
217 EXPECT_TRUE(exceptionState.hadException());
218 EXPECT_EQ(NotSupportedError, exceptionState.code());
219 }
220
221 TEST_F(AnimationKeyframeEffectV8Test, SpecifiedGetters) 138 TEST_F(AnimationKeyframeEffectV8Test, SpecifiedGetters)
222 { 139 {
223 Vector<Dictionary, 0> jsKeyframes; 140 Vector<Dictionary, 0> jsKeyframes;
224 141
225 v8::Local<v8::Object> timingInput = v8::Object::New(m_isolate); 142 v8::Local<v8::Object> timingInput = v8::Object::New(m_isolate);
226 setV8ObjectPropertyAsNumber(m_isolate, timingInput, "delay", 2); 143 setV8ObjectPropertyAsNumber(m_isolate, timingInput, "delay", 2);
227 setV8ObjectPropertyAsNumber(m_isolate, timingInput, "endDelay", 0.5); 144 setV8ObjectPropertyAsNumber(m_isolate, timingInput, "endDelay", 0.5);
228 setV8ObjectPropertyAsString(m_isolate, timingInput, "fill", "backwards"); 145 setV8ObjectPropertyAsString(m_isolate, timingInput, "fill", "backwards");
229 setV8ObjectPropertyAsNumber(m_isolate, timingInput, "iterationStart", 2); 146 setV8ObjectPropertyAsNumber(m_isolate, timingInput, "iterationStart", 2);
230 setV8ObjectPropertyAsNumber(m_isolate, timingInput, "iterations", 10); 147 setV8ObjectPropertyAsNumber(m_isolate, timingInput, "iterations", 10);
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 Timing timing; 370 Timing timing;
454 timing.iterationDuration = 5; 371 timing.iterationDuration = 5;
455 KeyframeEffect* animation = KeyframeEffect::create(element.get(), nullptr, t iming); 372 KeyframeEffect* animation = KeyframeEffect::create(element.get(), nullptr, t iming);
456 EXPECT_EQ(element.get(), animation->target()); 373 EXPECT_EQ(element.get(), animation->target());
457 document.timeline().play(animation); 374 document.timeline().play(animation);
458 pageHolder.clear(); 375 pageHolder.clear();
459 element.clear(); 376 element.clear();
460 } 377 }
461 378
462 } // namespace blink 379 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/animation/ElementAnimation.idl ('k') | Source/platform/RuntimeEnabledFeatures.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698