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

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

Issue 1906463002: Web Animations: Throw TypeErrors for invalid timing parameters (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit tests Created 4 years, 7 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 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 "core/animation/KeyframeEffect.h" 5 #include "core/animation/KeyframeEffect.h"
6 6
7 #include "bindings/core/v8/Dictionary.h" 7 #include "bindings/core/v8/Dictionary.h"
8 #include "bindings/core/v8/UnionTypesCore.h" 8 #include "bindings/core/v8/UnionTypesCore.h"
9 #include "bindings/core/v8/V8BindingForTesting.h" 9 #include "bindings/core/v8/V8BindingForTesting.h"
10 #include "bindings/core/v8/V8KeyframeEffectOptions.h" 10 #include "bindings/core/v8/V8KeyframeEffectOptions.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 EXPECT_EQ(duration / 1000, animation->specifiedTiming().iterationDuration); 120 EXPECT_EQ(duration / 1000, animation->specifiedTiming().iterationDuration);
121 } 121 }
122 122
123 TEST_F(AnimationKeyframeEffectV8Test, CanOmitSpecifiedDuration) 123 TEST_F(AnimationKeyframeEffectV8Test, CanOmitSpecifiedDuration)
124 { 124 {
125 Vector<Dictionary, 0> jsKeyframes; 125 Vector<Dictionary, 0> jsKeyframes;
126 KeyframeEffect* animation = createAnimation(element.get(), jsKeyframes, exce ptionState); 126 KeyframeEffect* animation = createAnimation(element.get(), jsKeyframes, exce ptionState);
127 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration)); 127 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration));
128 } 128 }
129 129
130 TEST_F(AnimationKeyframeEffectV8Test, NegativeDurationIsAuto)
131 {
132 Vector<Dictionary, 0> jsKeyframes;
133 KeyframeEffect* animation = createAnimation(element.get(), jsKeyframes, -2, exceptionState);
134 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration));
135 }
136
137 TEST_F(AnimationKeyframeEffectV8Test, SpecifiedGetters) 130 TEST_F(AnimationKeyframeEffectV8Test, SpecifiedGetters)
138 { 131 {
139 Vector<Dictionary, 0> jsKeyframes; 132 Vector<Dictionary, 0> jsKeyframes;
140 133
141 v8::Local<v8::Object> timingInput = v8::Object::New(m_isolate); 134 v8::Local<v8::Object> timingInput = v8::Object::New(m_isolate);
142 setV8ObjectPropertyAsNumber(m_isolate, timingInput, "delay", 2); 135 setV8ObjectPropertyAsNumber(m_isolate, timingInput, "delay", 2);
143 setV8ObjectPropertyAsNumber(m_isolate, timingInput, "endDelay", 0.5); 136 setV8ObjectPropertyAsNumber(m_isolate, timingInput, "endDelay", 0.5);
144 setV8ObjectPropertyAsString(m_isolate, timingInput, "fill", "backwards"); 137 setV8ObjectPropertyAsString(m_isolate, timingInput, "fill", "backwards");
145 setV8ObjectPropertyAsNumber(m_isolate, timingInput, "iterationStart", 2); 138 setV8ObjectPropertyAsNumber(m_isolate, timingInput, "iterationStart", 2);
146 setV8ObjectPropertyAsNumber(m_isolate, timingInput, "iterations", 10); 139 setV8ObjectPropertyAsNumber(m_isolate, timingInput, "iterations", 10);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 205
213 EXPECT_EQ(0, specified->endDelay()); 206 EXPECT_EQ(0, specified->endDelay());
214 specified->setEndDelay(0.5); 207 specified->setEndDelay(0.5);
215 EXPECT_EQ(0.5, specified->endDelay()); 208 EXPECT_EQ(0.5, specified->endDelay());
216 209
217 EXPECT_EQ("auto", specified->fill()); 210 EXPECT_EQ("auto", specified->fill());
218 specified->setFill("backwards"); 211 specified->setFill("backwards");
219 EXPECT_EQ("backwards", specified->fill()); 212 EXPECT_EQ("backwards", specified->fill());
220 213
221 EXPECT_EQ(0, specified->iterationStart()); 214 EXPECT_EQ(0, specified->iterationStart());
222 specified->setIterationStart(2); 215 specified->setIterationStart(2, exceptionState);
216 ASSERT_FALSE(exceptionState.hadException());
223 EXPECT_EQ(2, specified->iterationStart()); 217 EXPECT_EQ(2, specified->iterationStart());
224 218
225 EXPECT_EQ(1, specified->iterations()); 219 EXPECT_EQ(1, specified->iterations());
226 specified->setIterations(10); 220 specified->setIterations(10, exceptionState);
221 ASSERT_FALSE(exceptionState.hadException());
227 EXPECT_EQ(10, specified->iterations()); 222 EXPECT_EQ(10, specified->iterations());
228 223
229 EXPECT_EQ(1, specified->playbackRate()); 224 EXPECT_EQ(1, specified->playbackRate());
230 specified->setPlaybackRate(2); 225 specified->setPlaybackRate(2);
231 EXPECT_EQ(2, specified->playbackRate()); 226 EXPECT_EQ(2, specified->playbackRate());
232 227
233 EXPECT_EQ("normal", specified->direction()); 228 EXPECT_EQ("normal", specified->direction());
234 specified->setDirection("reverse"); 229 specified->setDirection("reverse");
235 EXPECT_EQ("reverse", specified->direction()); 230 EXPECT_EQ("reverse", specified->direction());
236 231
(...skipping 14 matching lines...) Expand all
251 AnimationEffectTiming* specified = animation->timing(); 246 AnimationEffectTiming* specified = animation->timing();
252 247
253 UnrestrictedDoubleOrString duration; 248 UnrestrictedDoubleOrString duration;
254 specified->duration(duration); 249 specified->duration(duration);
255 EXPECT_FALSE(duration.isUnrestrictedDouble()); 250 EXPECT_FALSE(duration.isUnrestrictedDouble());
256 EXPECT_TRUE(duration.isString()); 251 EXPECT_TRUE(duration.isString());
257 EXPECT_EQ("auto", duration.getAsString()); 252 EXPECT_EQ("auto", duration.getAsString());
258 253
259 UnrestrictedDoubleOrString inDuration; 254 UnrestrictedDoubleOrString inDuration;
260 inDuration.setUnrestrictedDouble(2.5); 255 inDuration.setUnrestrictedDouble(2.5);
261 specified->setDuration(inDuration); 256 specified->setDuration(inDuration, exceptionState);
257 ASSERT_FALSE(exceptionState.hadException());
262 UnrestrictedDoubleOrString duration2; 258 UnrestrictedDoubleOrString duration2;
263 specified->duration(duration2); 259 specified->duration(duration2);
264 EXPECT_TRUE(duration2.isUnrestrictedDouble()); 260 EXPECT_TRUE(duration2.isUnrestrictedDouble());
265 EXPECT_EQ(2.5, duration2.getAsUnrestrictedDouble()); 261 EXPECT_EQ(2.5, duration2.getAsUnrestrictedDouble());
266 EXPECT_FALSE(duration2.isString()); 262 EXPECT_FALSE(duration2.isString());
267 } 263 }
268 264
269 TEST_F(KeyframeEffectTest, TimeToEffectChange) 265 TEST_F(KeyframeEffectTest, TimeToEffectChange)
270 { 266 {
271 Timing timing; 267 Timing timing;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 Timing timing; 366 Timing timing;
371 timing.iterationDuration = 5; 367 timing.iterationDuration = 5;
372 KeyframeEffect* animation = KeyframeEffect::create(element.get(), nullptr, t iming); 368 KeyframeEffect* animation = KeyframeEffect::create(element.get(), nullptr, t iming);
373 EXPECT_EQ(element.get(), animation->target()); 369 EXPECT_EQ(element.get(), animation->target());
374 document().timeline().play(animation); 370 document().timeline().play(animation);
375 pageHolder.clear(); 371 pageHolder.clear();
376 element.clear(); 372 element.clear();
377 } 373 }
378 374
379 } // namespace blink 375 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/animation/KeyframeEffect.cpp ('k') | third_party/WebKit/Source/core/animation/Timing.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698