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

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: Rebased 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
« no previous file with comments | « Source/core/animation/Animation.cpp ('k') | Source/core/animation/AnimationTimingInputTest.cpp » ('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/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 16
16 #include <gtest/gtest.h> 17 #include <gtest/gtest.h>
17 18
18 namespace WebCore { 19 namespace WebCore {
19 20
20 class AnimationAnimationTest : public ::testing::Test { 21 class AnimationAnimationTest : public ::testing::Test {
21 protected: 22 protected:
22 AnimationAnimationTest() 23 AnimationAnimationTest()
23 : document(Document::create()) 24 : document(Document::create())
24 , element(document->createElement("foo", ASSERT_NO_EXCEPTION)) 25 , element(document->createElement("foo", ASSERT_NO_EXCEPTION))
25 { 26 {
26 document->animationClock().resetTimeForTesting(); 27 document->animationClock().resetTimeForTesting();
27 document->timeline().setZeroTime(0); 28 document->timeline().setZeroTime(0);
28 EXPECT_EQ(0, document->timeline().currentTime()); 29 EXPECT_EQ(0, document->timeline().currentTime());
29 } 30 }
30 31
31 RefPtr<Document> document; 32 RefPtr<Document> document;
32 RefPtr<Element> element; 33 RefPtr<Element> element;
33 }; 34 };
34 35
35 class AnimationAnimationV8Test : public AnimationAnimationTest { 36 class AnimationAnimationV8Test : public AnimationAnimationTest {
36 protected: 37 protected:
37 AnimationAnimationV8Test() 38 AnimationAnimationV8Test()
38 : m_isolate(v8::Isolate::GetCurrent()) 39 : m_isolate(v8::Isolate::GetCurrent())
39 , m_scope(V8BindingTestScope::create(m_isolate)) 40 , m_scope(V8BindingTestScope::create(m_isolate))
40 { 41 {
41 } 42 }
42 43
43 PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictionary> k eyframeDictionaryVector, Dictionary timingInput) 44 template<typename T>
45 static PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictio nary> keyframeDictionaryVector, T timingInput)
44 { 46 {
45 return Animation::createUnsafe(element, keyframeDictionaryVector, timing Input); 47 return Animation::create(element, EffectInput::convert(element, keyframe DictionaryVector, true), timingInput);
46 } 48 }
47 49 static PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictio nary> keyframeDictionaryVector)
48 PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictionary> k eyframeDictionaryVector, double timingInput)
49 { 50 {
50 return Animation::createUnsafe(element, keyframeDictionaryVector, timing Input); 51 return Animation::create(element, EffectInput::convert(element, keyframe DictionaryVector, true));
51 }
52
53 PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictionary> k eyframeDictionaryVector)
54 {
55 return Animation::createUnsafe(element, keyframeDictionaryVector);
56 } 52 }
57 53
58 v8::Isolate* m_isolate; 54 v8::Isolate* m_isolate;
59 55
60 private: 56 private:
61 OwnPtr<V8BindingTestScope> m_scope; 57 OwnPtr<V8BindingTestScope> m_scope;
62 }; 58 };
63 59
64 TEST_F(AnimationAnimationV8Test, CanCreateAnAnimation) 60 TEST_F(AnimationAnimationV8Test, CanCreateAnAnimation)
65 { 61 {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 EXPECT_EQ(duration, animation->specifiedTiming().iterationDuration); 117 EXPECT_EQ(duration, animation->specifiedTiming().iterationDuration);
122 } 118 }
123 119
124 TEST_F(AnimationAnimationV8Test, CanOmitSpecifiedDuration) 120 TEST_F(AnimationAnimationV8Test, CanOmitSpecifiedDuration)
125 { 121 {
126 Vector<Dictionary, 0> jsKeyframes; 122 Vector<Dictionary, 0> jsKeyframes;
127 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes); 123 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes);
128 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration)); 124 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration));
129 } 125 }
130 126
131 TEST_F(AnimationAnimationV8Test, ClipNegativeDurationToZero) 127 TEST_F(AnimationAnimationV8Test, NegativeDurationIsAuto)
132 { 128 {
133 Vector<Dictionary, 0> jsKeyframes; 129 Vector<Dictionary, 0> jsKeyframes;
134 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, -2 ); 130 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, -2 );
135 EXPECT_EQ(0, animation->specifiedTiming().iterationDuration); 131 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration));
136 } 132 }
137 133
138 TEST_F(AnimationAnimationV8Test, SpecifiedGetters) 134 TEST_F(AnimationAnimationV8Test, SpecifiedGetters)
139 { 135 {
140 Vector<Dictionary, 0> jsKeyframes; 136 Vector<Dictionary, 0> jsKeyframes;
141 137
142 v8::Handle<v8::Object> timingInput = v8::Object::New(m_isolate); 138 v8::Handle<v8::Object> timingInput = v8::Object::New(m_isolate);
143 setV8ObjectPropertyAsNumber(timingInput, "delay", 2); 139 setV8ObjectPropertyAsNumber(timingInput, "delay", 2);
144 setV8ObjectPropertyAsNumber(timingInput, "endDelay", 0.5); 140 setV8ObjectPropertyAsNumber(timingInput, "endDelay", 0.5);
145 setV8ObjectPropertyAsString(timingInput, "fill", "backwards"); 141 setV8ObjectPropertyAsString(timingInput, "fill", "backwards");
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 player->setCurrentTime(150); 362 player->setCurrentTime(150);
367 EXPECT_EQ(inf, animation->timeToForwardsEffectChange()); 363 EXPECT_EQ(inf, animation->timeToForwardsEffectChange());
368 EXPECT_EQ(0, animation->timeToReverseEffectChange()); 364 EXPECT_EQ(0, animation->timeToReverseEffectChange());
369 365
370 player->setCurrentTime(200); 366 player->setCurrentTime(200);
371 EXPECT_EQ(inf, animation->timeToForwardsEffectChange()); 367 EXPECT_EQ(inf, animation->timeToForwardsEffectChange());
372 EXPECT_EQ(50, animation->timeToReverseEffectChange()); 368 EXPECT_EQ(50, animation->timeToReverseEffectChange());
373 } 369 }
374 370
375 } // namespace WebCore 371 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/animation/Animation.cpp ('k') | Source/core/animation/AnimationTimingInputTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698