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

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

Issue 152853003: Web Animations API: Bindings for TimedItem.specified with readonly attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix timed-item-specified-getters.html (mashed in rebase) Created 6 years, 10 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 | « Source/core/animation/Animation.cpp ('k') | Source/core/animation/TimedItem.h » ('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/Animation.h" 6 #include "core/animation/Animation.h"
7 7
8 #include "bindings/v8/Dictionary.h" 8 #include "bindings/v8/Dictionary.h"
9 #include "core/animation/AnimatableLength.h" 9 #include "core/animation/AnimatableLength.h"
10 #include "core/animation/AnimationClock.h" 10 #include "core/animation/AnimationClock.h"
11 #include "core/animation/AnimationHelpers.h" 11 #include "core/animation/AnimationHelpers.h"
12 #include "core/animation/DocumentTimeline.h" 12 #include "core/animation/DocumentTimeline.h"
13 #include "core/animation/KeyframeEffectModel.h" 13 #include "core/animation/KeyframeEffectModel.h"
14 #include "core/animation/TimedItemTiming.h"
14 #include "platform/animation/TimingFunctionTestHelper.h" 15 #include "platform/animation/TimingFunctionTestHelper.h"
15 16
16 #include <gtest/gtest.h> 17 #include <gtest/gtest.h>
17 18
18 namespace WebCore { 19 namespace WebCore {
19 20
20 namespace { 21 namespace {
21 22
22 v8::Handle<v8::Value> stringToV8Value(String string) 23 v8::Handle<v8::Value> stringToV8Value(String string)
23 { 24 {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 153 v8::Isolate* isolate = v8::Isolate::GetCurrent();
153 v8::HandleScope scope(isolate); 154 v8::HandleScope scope(isolate);
154 v8::Local<v8::Context> context = v8::Context::New(isolate); 155 v8::Local<v8::Context> context = v8::Context::New(isolate);
155 v8::Context::Scope contextScope(context); 156 v8::Context::Scope contextScope(context);
156 157
157 Vector<Dictionary, 0> jsKeyframes; 158 Vector<Dictionary, 0> jsKeyframes;
158 double duration = 2; 159 double duration = 2;
159 160
160 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, du ration); 161 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, du ration);
161 162
162 EXPECT_EQ(duration, animation->specified().iterationDuration); 163 EXPECT_EQ(duration, animation->specifiedTiming().iterationDuration);
163 } 164 }
164 165
165 TEST_F(AnimationAnimationTest, CanOmitSpecifiedDuration) 166 TEST_F(AnimationAnimationTest, CanOmitSpecifiedDuration)
166 { 167 {
167 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 168 v8::Isolate* isolate = v8::Isolate::GetCurrent();
168 v8::HandleScope scope(isolate); 169 v8::HandleScope scope(isolate);
169 v8::Local<v8::Context> context = v8::Context::New(isolate); 170 v8::Local<v8::Context> context = v8::Context::New(isolate);
170 v8::Context::Scope contextScope(context); 171 v8::Context::Scope contextScope(context);
171 172
172 Vector<Dictionary, 0> jsKeyframes; 173 Vector<Dictionary, 0> jsKeyframes;
173 174
174 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes); 175 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes);
175 176
176 EXPECT_TRUE(std::isnan(animation->specified().iterationDuration)); 177 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration));
177 } 178 }
178 179
179 TEST_F(AnimationAnimationTest, ClipNegativeDurationToZero) 180 TEST_F(AnimationAnimationTest, ClipNegativeDurationToZero)
180 { 181 {
181 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 182 v8::Isolate* isolate = v8::Isolate::GetCurrent();
182 v8::HandleScope scope(isolate); 183 v8::HandleScope scope(isolate);
183 v8::Local<v8::Context> context = v8::Context::New(isolate); 184 v8::Local<v8::Context> context = v8::Context::New(isolate);
184 v8::Context::Scope contextScope(context); 185 v8::Context::Scope contextScope(context);
185 186
186 Vector<Dictionary, 0> jsKeyframes; 187 Vector<Dictionary, 0> jsKeyframes;
187 188
188 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, -2 ); 189 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, -2 );
189 190
190 EXPECT_EQ(0, animation->specified().iterationDuration); 191 EXPECT_EQ(0, animation->specifiedTiming().iterationDuration);
192 }
193
194 TEST_F(AnimationAnimationTest, SpecifiedGetters)
195 {
196 v8::Isolate* isolate = v8::Isolate::GetCurrent();
197 v8::HandleScope scope(isolate);
198 v8::Local<v8::Context> context = v8::Context::New(isolate);
199 v8::Context::Scope contextScope(context);
200
201 Vector<Dictionary, 0> jsKeyframes;
202
203 v8::Handle<v8::Object> timingInput = v8::Object::New(isolate);
204 setV8ObjectPropertyAsNumber(timingInput, "delay", 2);
205 setV8ObjectPropertyAsNumber(timingInput, "endDelay", 0.5);
206 setV8ObjectPropertyAsString(timingInput, "fill", "backwards");
207 setV8ObjectPropertyAsNumber(timingInput, "iterationStart", 2);
208 setV8ObjectPropertyAsNumber(timingInput, "iterations", 10);
209 setV8ObjectPropertyAsNumber(timingInput, "playbackRate", 2);
210 setV8ObjectPropertyAsString(timingInput, "direction", "reverse");
211 setV8ObjectPropertyAsString(timingInput, "easing", "step-start");
212 Dictionary timingInputDictionary = Dictionary(v8::Handle<v8::Value>::Cast(ti mingInput), isolate);
213
214 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, ti mingInputDictionary);
215
216 RefPtr<TimedItemTiming> specified = animation->specified();
217 EXPECT_EQ(2, specified->delay());
218 EXPECT_EQ(0.5, specified->endDelay());
219 EXPECT_EQ("backwards", specified->fill());
220 EXPECT_EQ(2, specified->iterationStart());
221 EXPECT_EQ(10, specified->iterations());
222 EXPECT_EQ(2, specified->playbackRate());
223 EXPECT_EQ("reverse", specified->direction());
224 EXPECT_EQ("step-start", specified->easing());
225 }
226
227 TEST_F(AnimationAnimationTest, SpecifiedDurationGetter)
228 {
229 v8::Isolate* isolate = v8::Isolate::GetCurrent();
230 v8::HandleScope scope(isolate);
231 v8::Local<v8::Context> context = v8::Context::New(isolate);
232 v8::Context::Scope contextScope(context);
233
234 Vector<Dictionary, 0> jsKeyframes;
235
236 v8::Handle<v8::Object> timingInputWithDuration = v8::Object::New(isolate);
237 setV8ObjectPropertyAsNumber(timingInputWithDuration, "duration", 2.5);
238 Dictionary timingInputDictionaryWithDuration = Dictionary(v8::Handle<v8::Val ue>::Cast(timingInputWithDuration), isolate);
239
240 RefPtr<Animation> animationWithDuration = createAnimation(element.get(), jsK eyframes, timingInputDictionaryWithDuration);
241
242 RefPtr<TimedItemTiming> specifiedWithDuration = animationWithDuration->speci fied();
243 bool isNumber = false;
244 double numberDuration = std::numeric_limits<double>::quiet_NaN();
245 bool isString = false;
246 String stringDuration = "";
247 specifiedWithDuration->duration("duration", isNumber, numberDuration, isStri ng, stringDuration);
248 EXPECT_TRUE(isNumber);
249 EXPECT_EQ(2.5, numberDuration);
250 EXPECT_FALSE(isString);
251 EXPECT_EQ("", stringDuration);
252
253
254 v8::Handle<v8::Object> timingInputNoDuration = v8::Object::New(isolate);
255 Dictionary timingInputDictionaryNoDuration = Dictionary(v8::Handle<v8::Value >::Cast(timingInputNoDuration), isolate);
256
257 RefPtr<Animation> animationNoDuration = createAnimation(element.get(), jsKey frames, timingInputDictionaryNoDuration);
258
259 RefPtr<TimedItemTiming> specifiedNoDuration = animationNoDuration->specified ();
260 isNumber = false;
261 numberDuration = std::numeric_limits<double>::quiet_NaN();
262 isString = false;
263 stringDuration = "";
264 specifiedNoDuration->duration("duration", isNumber, numberDuration, isString , stringDuration);
265 EXPECT_FALSE(isNumber);
266 EXPECT_TRUE(std::isnan(numberDuration));
267 EXPECT_TRUE(isString);
268 EXPECT_EQ("auto", stringDuration);
191 } 269 }
192 270
193 TEST_F(AnimationAnimationTest, TimingInputStartDelay) 271 TEST_F(AnimationAnimationTest, TimingInputStartDelay)
194 { 272 {
195 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 273 v8::Isolate* isolate = v8::Isolate::GetCurrent();
196 v8::HandleScope scope(isolate); 274 v8::HandleScope scope(isolate);
197 v8::Local<v8::Context> context = v8::Context::New(isolate); 275 v8::Local<v8::Context> context = v8::Context::New(isolate);
198 v8::Context::Scope contextScope(context); 276 v8::Context::Scope contextScope(context);
199 277
200 Timing timing; 278 Timing timing;
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 EXPECT_EQ(controlTiming.fillMode, updatedTiming.fillMode); 648 EXPECT_EQ(controlTiming.fillMode, updatedTiming.fillMode);
571 EXPECT_EQ(controlTiming.iterationStart, updatedTiming.iterationStart); 649 EXPECT_EQ(controlTiming.iterationStart, updatedTiming.iterationStart);
572 EXPECT_EQ(controlTiming.iterationCount, updatedTiming.iterationCount); 650 EXPECT_EQ(controlTiming.iterationCount, updatedTiming.iterationCount);
573 EXPECT_TRUE(std::isnan(updatedTiming.iterationDuration)); 651 EXPECT_TRUE(std::isnan(updatedTiming.iterationDuration));
574 EXPECT_EQ(controlTiming.playbackRate, updatedTiming.playbackRate); 652 EXPECT_EQ(controlTiming.playbackRate, updatedTiming.playbackRate);
575 EXPECT_EQ(controlTiming.direction, updatedTiming.direction); 653 EXPECT_EQ(controlTiming.direction, updatedTiming.direction);
576 EXPECT_EQ(*controlTiming.timingFunction.get(), *updatedTiming.timingFunction .get()); 654 EXPECT_EQ(*controlTiming.timingFunction.get(), *updatedTiming.timingFunction .get());
577 } 655 }
578 656
579 } // namespace WebCore 657 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/animation/Animation.cpp ('k') | Source/core/animation/TimedItem.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698