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

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

Issue 183803017: Revert of Ensure DOMWrapperWorld always exists in all webkit_unit_tests (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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"
(...skipping 18 matching lines...) Expand all
29 EXPECT_EQ(0, document->timeline().currentTime()); 29 EXPECT_EQ(0, document->timeline().currentTime());
30 } 30 }
31 31
32 RefPtr<Document> document; 32 RefPtr<Document> document;
33 RefPtr<Element> element; 33 RefPtr<Element> element;
34 }; 34 };
35 35
36 class AnimationAnimationV8Test : public AnimationAnimationTest { 36 class AnimationAnimationV8Test : public AnimationAnimationTest {
37 protected: 37 protected:
38 AnimationAnimationV8Test() 38 AnimationAnimationV8Test()
39 : m_isolate(v8::Isolate::GetCurrent()) 39 : isolate(v8::Isolate::GetCurrent())
40 , m_scope(V8BindingTestScope::create(m_isolate)) 40 , scope(isolate)
41 , context(v8::Context::New(isolate))
42 , contextScope(context)
41 { 43 {
42 } 44 }
43 45
46 v8::Isolate* isolate;
47 v8::HandleScope scope;
48 v8::Local<v8::Context> context;
49 v8::Context::Scope contextScope;
50
44 PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictionary> k eyframeDictionaryVector, Dictionary timingInput) 51 PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictionary> k eyframeDictionaryVector, Dictionary timingInput)
45 { 52 {
46 return Animation::createUnsafe(element, keyframeDictionaryVector, timing Input); 53 return Animation::createUnsafe(element, keyframeDictionaryVector, timing Input);
47 } 54 }
48 55
49 PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictionary> k eyframeDictionaryVector, double timingInput) 56 PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictionary> k eyframeDictionaryVector, double timingInput)
50 { 57 {
51 return Animation::createUnsafe(element, keyframeDictionaryVector, timing Input); 58 return Animation::createUnsafe(element, keyframeDictionaryVector, timing Input);
52 } 59 }
53 60
54 PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictionary> k eyframeDictionaryVector) 61 PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictionary> k eyframeDictionaryVector)
55 { 62 {
56 return Animation::createUnsafe(element, keyframeDictionaryVector); 63 return Animation::createUnsafe(element, keyframeDictionaryVector);
57 } 64 }
58
59 v8::Isolate* m_isolate;
60
61 private:
62 OwnPtr<V8BindingTestScope> m_scope;
63 }; 65 };
64 66
65 TEST_F(AnimationAnimationV8Test, CanCreateAnAnimation) 67 TEST_F(AnimationAnimationV8Test, CanCreateAnAnimation)
66 { 68 {
67 Vector<Dictionary> jsKeyframes; 69 Vector<Dictionary> jsKeyframes;
68 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); 70 v8::Handle<v8::Object> keyframe1 = v8::Object::New(isolate);
69 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); 71 v8::Handle<v8::Object> keyframe2 = v8::Object::New(isolate);
70 72
71 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); 73 setV8ObjectPropertyAsString(keyframe1, "width", "100px");
72 setV8ObjectPropertyAsString(keyframe1, "offset", "0"); 74 setV8ObjectPropertyAsString(keyframe1, "offset", "0");
73 setV8ObjectPropertyAsString(keyframe1, "easing", "ease-in-out"); 75 setV8ObjectPropertyAsString(keyframe1, "easing", "ease-in-out");
74 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); 76 setV8ObjectPropertyAsString(keyframe2, "width", "0px");
75 setV8ObjectPropertyAsString(keyframe2, "offset", "1"); 77 setV8ObjectPropertyAsString(keyframe2, "offset", "1");
76 setV8ObjectPropertyAsString(keyframe2, "easing", "cubic-bezier(1, 1, 0.3, 0. 3)"); 78 setV8ObjectPropertyAsString(keyframe2, "easing", "cubic-bezier(1, 1, 0.3, 0. 3)");
77 79
78 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); 80 jsKeyframes.append(Dictionary(keyframe1, isolate));
79 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); 81 jsKeyframes.append(Dictionary(keyframe2, isolate));
80 82
81 String value1; 83 String value1;
82 ASSERT_TRUE(jsKeyframes[0].get("width", value1)); 84 ASSERT_TRUE(jsKeyframes[0].get("width", value1));
83 ASSERT_EQ("100px", value1); 85 ASSERT_EQ("100px", value1);
84 86
85 String value2; 87 String value2;
86 ASSERT_TRUE(jsKeyframes[1].get("width", value2)); 88 ASSERT_TRUE(jsKeyframes[1].get("width", value2));
87 ASSERT_EQ("0px", value2); 89 ASSERT_EQ("0px", value2);
88 90
89 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, 0) ; 91 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, 0) ;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 { 135 {
134 Vector<Dictionary, 0> jsKeyframes; 136 Vector<Dictionary, 0> jsKeyframes;
135 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, -2 ); 137 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, -2 );
136 EXPECT_EQ(0, animation->specifiedTiming().iterationDuration); 138 EXPECT_EQ(0, animation->specifiedTiming().iterationDuration);
137 } 139 }
138 140
139 TEST_F(AnimationAnimationV8Test, SpecifiedGetters) 141 TEST_F(AnimationAnimationV8Test, SpecifiedGetters)
140 { 142 {
141 Vector<Dictionary, 0> jsKeyframes; 143 Vector<Dictionary, 0> jsKeyframes;
142 144
143 v8::Handle<v8::Object> timingInput = v8::Object::New(m_isolate); 145 v8::Handle<v8::Object> timingInput = v8::Object::New(isolate);
144 setV8ObjectPropertyAsNumber(timingInput, "delay", 2); 146 setV8ObjectPropertyAsNumber(timingInput, "delay", 2);
145 setV8ObjectPropertyAsNumber(timingInput, "endDelay", 0.5); 147 setV8ObjectPropertyAsNumber(timingInput, "endDelay", 0.5);
146 setV8ObjectPropertyAsString(timingInput, "fill", "backwards"); 148 setV8ObjectPropertyAsString(timingInput, "fill", "backwards");
147 setV8ObjectPropertyAsNumber(timingInput, "iterationStart", 2); 149 setV8ObjectPropertyAsNumber(timingInput, "iterationStart", 2);
148 setV8ObjectPropertyAsNumber(timingInput, "iterations", 10); 150 setV8ObjectPropertyAsNumber(timingInput, "iterations", 10);
149 setV8ObjectPropertyAsNumber(timingInput, "playbackRate", 2); 151 setV8ObjectPropertyAsNumber(timingInput, "playbackRate", 2);
150 setV8ObjectPropertyAsString(timingInput, "direction", "reverse"); 152 setV8ObjectPropertyAsString(timingInput, "direction", "reverse");
151 setV8ObjectPropertyAsString(timingInput, "easing", "step-start"); 153 setV8ObjectPropertyAsString(timingInput, "easing", "step-start");
152 Dictionary timingInputDictionary = Dictionary(v8::Handle<v8::Value>::Cast(ti mingInput), m_isolate); 154 Dictionary timingInputDictionary = Dictionary(v8::Handle<v8::Value>::Cast(ti mingInput), isolate);
153 155
154 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, ti mingInputDictionary); 156 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, ti mingInputDictionary);
155 157
156 RefPtr<TimedItemTiming> specified = animation->specified(); 158 RefPtr<TimedItemTiming> specified = animation->specified();
157 EXPECT_EQ(2, specified->delay()); 159 EXPECT_EQ(2, specified->delay());
158 EXPECT_EQ(0.5, specified->endDelay()); 160 EXPECT_EQ(0.5, specified->endDelay());
159 EXPECT_EQ("backwards", specified->fill()); 161 EXPECT_EQ("backwards", specified->fill());
160 EXPECT_EQ(2, specified->iterationStart()); 162 EXPECT_EQ(2, specified->iterationStart());
161 EXPECT_EQ(10, specified->iterations()); 163 EXPECT_EQ(10, specified->iterations());
162 EXPECT_EQ(2, specified->playbackRate()); 164 EXPECT_EQ(2, specified->playbackRate());
163 EXPECT_EQ("reverse", specified->direction()); 165 EXPECT_EQ("reverse", specified->direction());
164 EXPECT_EQ("step-start", specified->easing()); 166 EXPECT_EQ("step-start", specified->easing());
165 } 167 }
166 168
167 TEST_F(AnimationAnimationV8Test, SpecifiedDurationGetter) 169 TEST_F(AnimationAnimationV8Test, SpecifiedDurationGetter)
168 { 170 {
169 Vector<Dictionary, 0> jsKeyframes; 171 Vector<Dictionary, 0> jsKeyframes;
170 172
171 v8::Handle<v8::Object> timingInputWithDuration = v8::Object::New(m_isolate); 173 v8::Handle<v8::Object> timingInputWithDuration = v8::Object::New(isolate);
172 setV8ObjectPropertyAsNumber(timingInputWithDuration, "duration", 2.5); 174 setV8ObjectPropertyAsNumber(timingInputWithDuration, "duration", 2.5);
173 Dictionary timingInputDictionaryWithDuration = Dictionary(v8::Handle<v8::Val ue>::Cast(timingInputWithDuration), m_isolate); 175 Dictionary timingInputDictionaryWithDuration = Dictionary(v8::Handle<v8::Val ue>::Cast(timingInputWithDuration), isolate);
174 176
175 RefPtr<Animation> animationWithDuration = createAnimation(element.get(), jsK eyframes, timingInputDictionaryWithDuration); 177 RefPtr<Animation> animationWithDuration = createAnimation(element.get(), jsK eyframes, timingInputDictionaryWithDuration);
176 178
177 RefPtr<TimedItemTiming> specifiedWithDuration = animationWithDuration->speci fied(); 179 RefPtr<TimedItemTiming> specifiedWithDuration = animationWithDuration->speci fied();
178 bool isNumber = false; 180 bool isNumber = false;
179 double numberDuration = std::numeric_limits<double>::quiet_NaN(); 181 double numberDuration = std::numeric_limits<double>::quiet_NaN();
180 bool isString = false; 182 bool isString = false;
181 String stringDuration = ""; 183 String stringDuration = "";
182 specifiedWithDuration->getDuration("duration", isNumber, numberDuration, isS tring, stringDuration); 184 specifiedWithDuration->getDuration("duration", isNumber, numberDuration, isS tring, stringDuration);
183 EXPECT_TRUE(isNumber); 185 EXPECT_TRUE(isNumber);
184 EXPECT_EQ(2.5, numberDuration); 186 EXPECT_EQ(2.5, numberDuration);
185 EXPECT_FALSE(isString); 187 EXPECT_FALSE(isString);
186 EXPECT_EQ("", stringDuration); 188 EXPECT_EQ("", stringDuration);
187 189
188 190
189 v8::Handle<v8::Object> timingInputNoDuration = v8::Object::New(m_isolate); 191 v8::Handle<v8::Object> timingInputNoDuration = v8::Object::New(isolate);
190 Dictionary timingInputDictionaryNoDuration = Dictionary(v8::Handle<v8::Value >::Cast(timingInputNoDuration), m_isolate); 192 Dictionary timingInputDictionaryNoDuration = Dictionary(v8::Handle<v8::Value >::Cast(timingInputNoDuration), isolate);
191 193
192 RefPtr<Animation> animationNoDuration = createAnimation(element.get(), jsKey frames, timingInputDictionaryNoDuration); 194 RefPtr<Animation> animationNoDuration = createAnimation(element.get(), jsKey frames, timingInputDictionaryNoDuration);
193 195
194 RefPtr<TimedItemTiming> specifiedNoDuration = animationNoDuration->specified (); 196 RefPtr<TimedItemTiming> specifiedNoDuration = animationNoDuration->specified ();
195 isNumber = false; 197 isNumber = false;
196 numberDuration = std::numeric_limits<double>::quiet_NaN(); 198 numberDuration = std::numeric_limits<double>::quiet_NaN();
197 isString = false; 199 isString = false;
198 stringDuration = ""; 200 stringDuration = "";
199 specifiedNoDuration->getDuration("duration", isNumber, numberDuration, isStr ing, stringDuration); 201 specifiedNoDuration->getDuration("duration", isNumber, numberDuration, isStr ing, stringDuration);
200 EXPECT_FALSE(isNumber); 202 EXPECT_FALSE(isNumber);
201 EXPECT_TRUE(std::isnan(numberDuration)); 203 EXPECT_TRUE(std::isnan(numberDuration));
202 EXPECT_TRUE(isString); 204 EXPECT_TRUE(isString);
203 EXPECT_EQ("auto", stringDuration); 205 EXPECT_EQ("auto", stringDuration);
204 } 206 }
205 207
206 TEST_F(AnimationAnimationV8Test, SpecifiedSetters) 208 TEST_F(AnimationAnimationV8Test, SpecifiedSetters)
207 { 209 {
208 Vector<Dictionary, 0> jsKeyframes; 210 Vector<Dictionary, 0> jsKeyframes;
209 v8::Handle<v8::Object> timingInput = v8::Object::New(m_isolate); 211 v8::Handle<v8::Object> timingInput = v8::Object::New(isolate);
210 Dictionary timingInputDictionary = Dictionary(v8::Handle<v8::Value>::Cast(ti mingInput), m_isolate); 212 Dictionary timingInputDictionary = Dictionary(v8::Handle<v8::Value>::Cast(ti mingInput), isolate);
211 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, ti mingInputDictionary); 213 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, ti mingInputDictionary);
212 214
213 RefPtr<TimedItemTiming> specified = animation->specified(); 215 RefPtr<TimedItemTiming> specified = animation->specified();
214 216
215 EXPECT_EQ(0, specified->delay()); 217 EXPECT_EQ(0, specified->delay());
216 specified->setDelay(2); 218 specified->setDelay(2);
217 EXPECT_EQ(2, specified->delay()); 219 EXPECT_EQ(2, specified->delay());
218 220
219 EXPECT_EQ(0, specified->endDelay()); 221 EXPECT_EQ(0, specified->endDelay());
220 specified->setEndDelay(0.5); 222 specified->setEndDelay(0.5);
(...skipping 20 matching lines...) Expand all
241 EXPECT_EQ("reverse", specified->direction()); 243 EXPECT_EQ("reverse", specified->direction());
242 244
243 EXPECT_EQ("linear", specified->easing()); 245 EXPECT_EQ("linear", specified->easing());
244 specified->setEasing("step-start"); 246 specified->setEasing("step-start");
245 EXPECT_EQ("step-start", specified->easing()); 247 EXPECT_EQ("step-start", specified->easing());
246 } 248 }
247 249
248 TEST_F(AnimationAnimationV8Test, SetSpecifiedDuration) 250 TEST_F(AnimationAnimationV8Test, SetSpecifiedDuration)
249 { 251 {
250 Vector<Dictionary, 0> jsKeyframes; 252 Vector<Dictionary, 0> jsKeyframes;
251 v8::Handle<v8::Object> timingInput = v8::Object::New(m_isolate); 253 v8::Handle<v8::Object> timingInput = v8::Object::New(isolate);
252 Dictionary timingInputDictionary = Dictionary(v8::Handle<v8::Value>::Cast(ti mingInput), m_isolate); 254 Dictionary timingInputDictionary = Dictionary(v8::Handle<v8::Value>::Cast(ti mingInput), isolate);
253 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, ti mingInputDictionary); 255 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, ti mingInputDictionary);
254 256
255 RefPtr<TimedItemTiming> specified = animation->specified(); 257 RefPtr<TimedItemTiming> specified = animation->specified();
256 258
257 bool isNumber = false; 259 bool isNumber = false;
258 double numberDuration = std::numeric_limits<double>::quiet_NaN(); 260 double numberDuration = std::numeric_limits<double>::quiet_NaN();
259 bool isString = false; 261 bool isString = false;
260 String stringDuration = ""; 262 String stringDuration = "";
261 specified->getDuration("duration", isNumber, numberDuration, isString, strin gDuration); 263 specified->getDuration("duration", isNumber, numberDuration, isString, strin gDuration);
262 EXPECT_FALSE(isNumber); 264 EXPECT_FALSE(isNumber);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 player->setCurrentTime(150); 369 player->setCurrentTime(150);
368 EXPECT_EQ(inf, animation->timeToForwardsEffectChange()); 370 EXPECT_EQ(inf, animation->timeToForwardsEffectChange());
369 EXPECT_EQ(0, animation->timeToReverseEffectChange()); 371 EXPECT_EQ(0, animation->timeToReverseEffectChange());
370 372
371 player->setCurrentTime(200); 373 player->setCurrentTime(200);
372 EXPECT_EQ(inf, animation->timeToForwardsEffectChange()); 374 EXPECT_EQ(inf, animation->timeToForwardsEffectChange());
373 EXPECT_EQ(50, animation->timeToReverseEffectChange()); 375 EXPECT_EQ(50, animation->timeToReverseEffectChange());
374 } 376 }
375 377
376 } // namespace WebCore 378 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/WorkerScriptController.cpp ('k') | Source/core/animation/AnimationTimingInputTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698