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