OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 ASSERT_EQ(0, document->timeline()->currentTime()); | 68 ASSERT_EQ(0, document->timeline()->currentTime()); |
69 } | 69 } |
70 | 70 |
71 RefPtr<Document> document; | 71 RefPtr<Document> document; |
72 RefPtr<Element> element; | 72 RefPtr<Element> element; |
73 | 73 |
74 void startAnimation(Element* element, Vector<Dictionary> keyframesDictionary
Vector) | 74 void startAnimation(Element* element, Vector<Dictionary> keyframesDictionary
Vector) |
75 { | 75 { |
76 ElementAnimation::startAnimation(element, keyframesDictionaryVector); | 76 ElementAnimation::startAnimation(element, keyframesDictionaryVector); |
77 } | 77 } |
78 | 78 void startAnimation(Element* element, Vector<Dictionary> keyframesDictionary
Vector, v8::Handle<v8::Value> timingInput) |
79 void startAnimationWithSpecifiedDuration(Element* element, Vector<Dictionary
> keyframesDictionaryVector, double duration) | |
80 { | 79 { |
81 ElementAnimation::startAnimation(element, keyframesDictionaryVector, dur
ation); | 80 ElementAnimation::startAnimation(element, keyframesDictionaryVector, tim
ingInput); |
82 } | 81 } |
83 }; | 82 }; |
84 | 83 |
85 TEST_F(AnimationElementAnimationTest, CanStartAnAnimation) | 84 TEST_F(AnimationElementAnimationTest, CanStartAnAnimation) |
86 { | 85 { |
87 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 86 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
88 v8::HandleScope scope(isolate); | 87 v8::HandleScope scope(isolate); |
89 v8::Local<v8::Context> context = v8::Context::New(isolate); | 88 v8::Local<v8::Context> context = v8::Context::New(isolate); |
90 v8::Context::Scope contextScope(context); | 89 v8::Context::Scope contextScope(context); |
91 | 90 |
(...skipping 10 matching lines...) Expand all Loading... |
102 jsKeyframes.append(Dictionary(keyframe2, isolate)); | 101 jsKeyframes.append(Dictionary(keyframe2, isolate)); |
103 | 102 |
104 String value1; | 103 String value1; |
105 ASSERT_TRUE(jsKeyframes[0].get("width", value1)); | 104 ASSERT_TRUE(jsKeyframes[0].get("width", value1)); |
106 ASSERT_EQ("100px", value1); | 105 ASSERT_EQ("100px", value1); |
107 | 106 |
108 String value2; | 107 String value2; |
109 ASSERT_TRUE(jsKeyframes[1].get("width", value2)); | 108 ASSERT_TRUE(jsKeyframes[1].get("width", value2)); |
110 ASSERT_EQ("0px", value2); | 109 ASSERT_EQ("0px", value2); |
111 | 110 |
112 startAnimationWithSpecifiedDuration(element.get(), jsKeyframes, 0); | 111 v8::Handle<v8::Value> durationValue = v8::Handle<v8::Value>::Cast(v8::Number
::New(isolate, 0)); |
| 112 startAnimation(element.get(), jsKeyframes, durationValue); |
113 | 113 |
114 Player* player = document->timeline()->players().at(0).get(); | 114 Player* player = document->timeline()->players().at(0).get(); |
115 | 115 |
116 Animation* animation = toAnimation(player->source()); | 116 Animation* animation = toAnimation(player->source()); |
117 | 117 |
118 Element* target = animation->target(); | 118 Element* target = animation->target(); |
119 EXPECT_EQ(*element.get(), *target); | 119 EXPECT_EQ(*element.get(), *target); |
120 | 120 |
121 const KeyframeAnimationEffect::KeyframeVector keyframes = | 121 const KeyframeAnimationEffect::KeyframeVector keyframes = |
122 toKeyframeAnimationEffect(animation->effect())->getFrames(); | 122 toKeyframeAnimationEffect(animation->effect())->getFrames(); |
(...skipping 26 matching lines...) Expand all Loading... |
149 } | 149 } |
150 | 150 |
151 TEST_F(AnimationElementAnimationTest, CanSetDuration) | 151 TEST_F(AnimationElementAnimationTest, CanSetDuration) |
152 { | 152 { |
153 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 153 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
154 v8::HandleScope scope(isolate); | 154 v8::HandleScope scope(isolate); |
155 v8::Local<v8::Context> context = v8::Context::New(isolate); | 155 v8::Local<v8::Context> context = v8::Context::New(isolate); |
156 v8::Context::Scope contextScope(context); | 156 v8::Context::Scope contextScope(context); |
157 | 157 |
158 Vector<Dictionary, 0> jsKeyframes; | 158 Vector<Dictionary, 0> jsKeyframes; |
| 159 |
159 double duration = 2; | 160 double duration = 2; |
160 | 161 v8::Handle<v8::Value> durationValue = v8::Handle<v8::Value>::Cast(v8::Number
::New(isolate, duration)); |
161 startAnimationWithSpecifiedDuration(element.get(), jsKeyframes, duration); | 162 startAnimation(element.get(), jsKeyframes, durationValue); |
162 | 163 |
163 Player* player = document->timeline()->players().at(0).get(); | 164 Player* player = document->timeline()->players().at(0).get(); |
164 | 165 |
165 EXPECT_TRUE(player->source()->specified().hasIterationDuration); | 166 EXPECT_TRUE(player->source()->specified().hasIterationDuration); |
166 EXPECT_EQ(duration, player->source()->specified().iterationDuration); | 167 EXPECT_EQ(duration, player->source()->specified().iterationDuration); |
167 } | 168 } |
168 | 169 |
169 TEST_F(AnimationElementAnimationTest, CanOmitSpecifiedDuration) | 170 TEST_F(AnimationElementAnimationTest, CanOmitSpecifiedDuration) |
170 { | 171 { |
171 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 172 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
172 v8::HandleScope scope(isolate); | 173 v8::HandleScope scope(isolate); |
173 v8::Local<v8::Context> context = v8::Context::New(isolate); | 174 v8::Local<v8::Context> context = v8::Context::New(isolate); |
174 v8::Context::Scope contextScope(context); | 175 v8::Context::Scope contextScope(context); |
175 | 176 |
176 Vector<Dictionary, 0> jsKeyframes; | 177 Vector<Dictionary, 0> jsKeyframes; |
177 | 178 |
178 startAnimation(element.get(), jsKeyframes); | 179 startAnimation(element.get(), jsKeyframes); |
179 | 180 |
180 Player* player = document->timeline()->players().at(0).get(); | 181 Player* player = document->timeline()->players().at(0).get(); |
181 | 182 |
182 // FIXME: This is correct for the moment, as using c++ default arguments mea
ns | 183 EXPECT_FALSE(player->source()->specified().hasIterationDuration); |
183 // there is no way to tell whether a duration has been specified by the user
. | |
184 // Once we implment timing object arguments we should be able to tell, and t
his | |
185 // check should be changed to EXPECT_FALSE. | |
186 EXPECT_TRUE(player->source()->specified().hasIterationDuration); | |
187 EXPECT_EQ(0, player->source()->specified().iterationDuration); | 184 EXPECT_EQ(0, player->source()->specified().iterationDuration); |
188 } | 185 } |
189 | 186 |
190 TEST_F(AnimationElementAnimationTest, ClipNegativeDurationToZero) | 187 TEST_F(AnimationElementAnimationTest, ClipNegativeDurationToZero) |
191 { | 188 { |
192 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 189 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
193 v8::HandleScope scope(isolate); | 190 v8::HandleScope scope(isolate); |
194 v8::Local<v8::Context> context = v8::Context::New(isolate); | 191 v8::Local<v8::Context> context = v8::Context::New(isolate); |
195 v8::Context::Scope contextScope(context); | 192 v8::Context::Scope contextScope(context); |
196 | 193 |
197 Vector<Dictionary, 0> jsKeyframes; | 194 Vector<Dictionary, 0> jsKeyframes; |
198 double duration = -2; | |
199 | 195 |
200 startAnimationWithSpecifiedDuration(element.get(), jsKeyframes, duration); | 196 v8::Handle<v8::Value> durationValue = v8::Handle<v8::Value>::Cast(v8::Number
::New(isolate, -2)); |
| 197 startAnimation(element.get(), jsKeyframes, durationValue); |
201 | 198 |
202 Player* player = document->timeline()->players().at(0).get(); | 199 Player* player = document->timeline()->players().at(0).get(); |
203 | 200 |
204 EXPECT_TRUE(player->source()->specified().hasIterationDuration); | 201 EXPECT_TRUE(player->source()->specified().hasIterationDuration); |
205 EXPECT_EQ(0, player->source()->specified().iterationDuration); | 202 EXPECT_EQ(0, player->source()->specified().iterationDuration); |
206 } | 203 } |
207 | 204 |
208 } // namespace WebCore | 205 } // namespace WebCore |
OLD | NEW |