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

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

Issue 182063005: Web Animations API: Refactor IDL input conversion out of Animation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Move timing input conversion from Animation into Timing Created 6 years, 9 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
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/AnimationTestHelper.h" 12 #include "core/animation/AnimationTestHelper.h"
13 #include "core/animation/DocumentTimeline.h" 13 #include "core/animation/DocumentTimeline.h"
14 #include "core/animation/KeyframeEffectModel.h" 14 #include "core/animation/KeyframeEffectModel.h"
15 #include "core/animation/Timing.h"
15 #include "platform/animation/TimingFunctionTestHelper.h" 16 #include "platform/animation/TimingFunctionTestHelper.h"
16 17
17 #include <gtest/gtest.h> 18 #include <gtest/gtest.h>
18 19
19 namespace WebCore { 20 namespace WebCore {
20 21
21 class AnimationAnimationTest : public ::testing::Test { 22 class AnimationAnimationTest : public ::testing::Test {
22 protected: 23 protected:
23 AnimationAnimationTest() 24 AnimationAnimationTest()
24 : document(Document::create()) 25 : document(Document::create())
(...skipping 11 matching lines...) Expand all
36 class AnimationAnimationV8Test : public AnimationAnimationTest { 37 class AnimationAnimationV8Test : public AnimationAnimationTest {
37 protected: 38 protected:
38 AnimationAnimationV8Test() 39 AnimationAnimationV8Test()
39 : isolate(v8::Isolate::GetCurrent()) 40 : isolate(v8::Isolate::GetCurrent())
40 , scope(isolate) 41 , scope(isolate)
41 , context(v8::Context::New(isolate)) 42 , context(v8::Context::New(isolate))
42 , contextScope(context) 43 , contextScope(context)
43 { 44 {
44 } 45 }
45 46
47 template<typename T = double>
48 static PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictio nary> keyframeDictionaryVector, T timingInput = Timing::initialIterationDuration ())
49 {
50 return Animation::create(element, Animation::convertEffectInput(element, keyframeDictionaryVector, true), timingInput);
51 }
52
46 v8::Isolate* isolate; 53 v8::Isolate* isolate;
47 v8::HandleScope scope; 54 v8::HandleScope scope;
48 v8::Local<v8::Context> context; 55 v8::Local<v8::Context> context;
49 v8::Context::Scope contextScope; 56 v8::Context::Scope contextScope;
50
51 PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictionary> k eyframeDictionaryVector, Dictionary timingInput)
52 {
53 return Animation::createUnsafe(element, keyframeDictionaryVector, timing Input);
54 }
55
56 PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictionary> k eyframeDictionaryVector, double timingInput)
57 {
58 return Animation::createUnsafe(element, keyframeDictionaryVector, timing Input);
59 }
60
61 PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictionary> k eyframeDictionaryVector)
62 {
63 return Animation::createUnsafe(element, keyframeDictionaryVector);
64 }
65 }; 57 };
66 58
67 TEST_F(AnimationAnimationV8Test, CanCreateAnAnimation) 59 TEST_F(AnimationAnimationV8Test, CanCreateAnAnimation)
68 { 60 {
69 Vector<Dictionary> jsKeyframes; 61 Vector<Dictionary> jsKeyframes;
70 v8::Handle<v8::Object> keyframe1 = v8::Object::New(isolate); 62 v8::Handle<v8::Object> keyframe1 = v8::Object::New(isolate);
71 v8::Handle<v8::Object> keyframe2 = v8::Object::New(isolate); 63 v8::Handle<v8::Object> keyframe2 = v8::Object::New(isolate);
72 64
73 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); 65 setV8ObjectPropertyAsString(keyframe1, "width", "100px");
74 setV8ObjectPropertyAsString(keyframe1, "offset", "0"); 66 setV8ObjectPropertyAsString(keyframe1, "offset", "0");
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 player->setCurrentTime(150); 361 player->setCurrentTime(150);
370 EXPECT_EQ(inf, animation->timeToForwardsEffectChange()); 362 EXPECT_EQ(inf, animation->timeToForwardsEffectChange());
371 EXPECT_EQ(0, animation->timeToReverseEffectChange()); 363 EXPECT_EQ(0, animation->timeToReverseEffectChange());
372 364
373 player->setCurrentTime(200); 365 player->setCurrentTime(200);
374 EXPECT_EQ(inf, animation->timeToForwardsEffectChange()); 366 EXPECT_EQ(inf, animation->timeToForwardsEffectChange());
375 EXPECT_EQ(50, animation->timeToReverseEffectChange()); 367 EXPECT_EQ(50, animation->timeToReverseEffectChange());
376 } 368 }
377 369
378 } // namespace WebCore 370 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698