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

Side by Side Diff: third_party/WebKit/Source/core/animation/KeyframeEffectTest.cpp

Issue 1452613002: KeyframeEffectTest: avoid keeping unnecessary Document reference. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | 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/KeyframeEffect.h" 6 #include "core/animation/KeyframeEffect.h"
7 7
8 #include "bindings/core/v8/Dictionary.h" 8 #include "bindings/core/v8/Dictionary.h"
9 #include "bindings/core/v8/UnionTypesCore.h" 9 #include "bindings/core/v8/UnionTypesCore.h"
10 #include "bindings/core/v8/V8BindingForTesting.h" 10 #include "bindings/core/v8/V8BindingForTesting.h"
11 #include "bindings/core/v8/V8KeyframeEffectOptions.h" 11 #include "bindings/core/v8/V8KeyframeEffectOptions.h"
12 #include "core/animation/AnimationClock.h" 12 #include "core/animation/AnimationClock.h"
13 #include "core/animation/AnimationEffectTiming.h" 13 #include "core/animation/AnimationEffectTiming.h"
14 #include "core/animation/AnimationTestHelper.h" 14 #include "core/animation/AnimationTestHelper.h"
15 #include "core/animation/AnimationTimeline.h" 15 #include "core/animation/AnimationTimeline.h"
16 #include "core/animation/KeyframeEffectModel.h" 16 #include "core/animation/KeyframeEffectModel.h"
17 #include "core/animation/Timing.h" 17 #include "core/animation/Timing.h"
18 #include "core/dom/Document.h" 18 #include "core/dom/Document.h"
19 #include "core/dom/ExceptionCode.h" 19 #include "core/dom/ExceptionCode.h"
20 #include "core/testing/DummyPageHolder.h" 20 #include "core/testing/DummyPageHolder.h"
21 #include <gtest/gtest.h> 21 #include <gtest/gtest.h>
22 #include <v8.h> 22 #include <v8.h>
23 23
24 namespace blink { 24 namespace blink {
25 25
26 class KeyframeEffectTest : public ::testing::Test { 26 class KeyframeEffectTest : public ::testing::Test {
27 protected: 27 protected:
28 KeyframeEffectTest() 28 KeyframeEffectTest()
29 : pageHolder(DummyPageHolder::create()) 29 : pageHolder(DummyPageHolder::create())
30 , document(pageHolder->document())
31 , element(document.createElement("foo", ASSERT_NO_EXCEPTION))
32 { 30 {
33 document.animationClock().resetTimeForTesting(document.timeline().zeroTi me()); 31 element = document().createElement("foo", ASSERT_NO_EXCEPTION);
34 document.documentElement()->appendChild(element.get()); 32
35 EXPECT_EQ(0, document.timeline().currentTime()); 33 document().animationClock().resetTimeForTesting(document().timeline().ze roTime());
34 document().documentElement()->appendChild(element.get());
35 EXPECT_EQ(0, document().timeline().currentTime());
36 } 36 }
37 37
38 Document& document() const { return pageHolder->document(); }
39
38 OwnPtr<DummyPageHolder> pageHolder; 40 OwnPtr<DummyPageHolder> pageHolder;
39 Document& document;
40 RefPtrWillBePersistent<Element> element; 41 RefPtrWillBePersistent<Element> element;
41 TrackExceptionState exceptionState; 42 TrackExceptionState exceptionState;
42 }; 43 };
43 44
44 class AnimationKeyframeEffectV8Test : public KeyframeEffectTest { 45 class AnimationKeyframeEffectV8Test : public KeyframeEffectTest {
45 protected: 46 protected:
46 AnimationKeyframeEffectV8Test() 47 AnimationKeyframeEffectV8Test()
47 : m_isolate(v8::Isolate::GetCurrent()) 48 : m_isolate(v8::Isolate::GetCurrent())
48 , m_scope(m_isolate) 49 , m_scope(m_isolate)
49 { 50 {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 } 268 }
268 269
269 TEST_F(KeyframeEffectTest, TimeToEffectChange) 270 TEST_F(KeyframeEffectTest, TimeToEffectChange)
270 { 271 {
271 Timing timing; 272 Timing timing;
272 timing.iterationDuration = 100; 273 timing.iterationDuration = 100;
273 timing.startDelay = 100; 274 timing.startDelay = 100;
274 timing.endDelay = 100; 275 timing.endDelay = 100;
275 timing.fillMode = Timing::FillModeNone; 276 timing.fillMode = Timing::FillModeNone;
276 KeyframeEffect* animation = KeyframeEffect::create(0, nullptr, timing); 277 KeyframeEffect* animation = KeyframeEffect::create(0, nullptr, timing);
277 Animation* player = document.timeline().play(animation); 278 Animation* player = document().timeline().play(animation);
278 double inf = std::numeric_limits<double>::infinity(); 279 double inf = std::numeric_limits<double>::infinity();
279 280
280 EXPECT_EQ(100, animation->timeToForwardsEffectChange()); 281 EXPECT_EQ(100, animation->timeToForwardsEffectChange());
281 EXPECT_EQ(inf, animation->timeToReverseEffectChange()); 282 EXPECT_EQ(inf, animation->timeToReverseEffectChange());
282 283
283 player->setCurrentTimeInternal(100); 284 player->setCurrentTimeInternal(100);
284 EXPECT_EQ(100, animation->timeToForwardsEffectChange()); 285 EXPECT_EQ(100, animation->timeToForwardsEffectChange());
285 EXPECT_EQ(0, animation->timeToReverseEffectChange()); 286 EXPECT_EQ(0, animation->timeToReverseEffectChange());
286 287
287 player->setCurrentTimeInternal(199); 288 player->setCurrentTimeInternal(199);
(...skipping 12 matching lines...) Expand all
300 301
301 TEST_F(KeyframeEffectTest, TimeToEffectChangeWithPlaybackRate) 302 TEST_F(KeyframeEffectTest, TimeToEffectChangeWithPlaybackRate)
302 { 303 {
303 Timing timing; 304 Timing timing;
304 timing.iterationDuration = 100; 305 timing.iterationDuration = 100;
305 timing.startDelay = 100; 306 timing.startDelay = 100;
306 timing.endDelay = 100; 307 timing.endDelay = 100;
307 timing.playbackRate = 2; 308 timing.playbackRate = 2;
308 timing.fillMode = Timing::FillModeNone; 309 timing.fillMode = Timing::FillModeNone;
309 KeyframeEffect* animation = KeyframeEffect::create(0, nullptr, timing); 310 KeyframeEffect* animation = KeyframeEffect::create(0, nullptr, timing);
310 Animation* player = document.timeline().play(animation); 311 Animation* player = document().timeline().play(animation);
311 double inf = std::numeric_limits<double>::infinity(); 312 double inf = std::numeric_limits<double>::infinity();
312 313
313 EXPECT_EQ(100, animation->timeToForwardsEffectChange()); 314 EXPECT_EQ(100, animation->timeToForwardsEffectChange());
314 EXPECT_EQ(inf, animation->timeToReverseEffectChange()); 315 EXPECT_EQ(inf, animation->timeToReverseEffectChange());
315 316
316 player->setCurrentTimeInternal(100); 317 player->setCurrentTimeInternal(100);
317 EXPECT_EQ(50, animation->timeToForwardsEffectChange()); 318 EXPECT_EQ(50, animation->timeToForwardsEffectChange());
318 EXPECT_EQ(0, animation->timeToReverseEffectChange()); 319 EXPECT_EQ(0, animation->timeToReverseEffectChange());
319 320
320 player->setCurrentTimeInternal(149); 321 player->setCurrentTimeInternal(149);
(...skipping 12 matching lines...) Expand all
333 334
334 TEST_F(KeyframeEffectTest, TimeToEffectChangeWithNegativePlaybackRate) 335 TEST_F(KeyframeEffectTest, TimeToEffectChangeWithNegativePlaybackRate)
335 { 336 {
336 Timing timing; 337 Timing timing;
337 timing.iterationDuration = 100; 338 timing.iterationDuration = 100;
338 timing.startDelay = 100; 339 timing.startDelay = 100;
339 timing.endDelay = 100; 340 timing.endDelay = 100;
340 timing.playbackRate = -2; 341 timing.playbackRate = -2;
341 timing.fillMode = Timing::FillModeNone; 342 timing.fillMode = Timing::FillModeNone;
342 KeyframeEffect* animation = KeyframeEffect::create(0, nullptr, timing); 343 KeyframeEffect* animation = KeyframeEffect::create(0, nullptr, timing);
343 Animation* player = document.timeline().play(animation); 344 Animation* player = document().timeline().play(animation);
344 double inf = std::numeric_limits<double>::infinity(); 345 double inf = std::numeric_limits<double>::infinity();
345 346
346 EXPECT_EQ(100, animation->timeToForwardsEffectChange()); 347 EXPECT_EQ(100, animation->timeToForwardsEffectChange());
347 EXPECT_EQ(inf, animation->timeToReverseEffectChange()); 348 EXPECT_EQ(inf, animation->timeToReverseEffectChange());
348 349
349 player->setCurrentTimeInternal(100); 350 player->setCurrentTimeInternal(100);
350 EXPECT_EQ(50, animation->timeToForwardsEffectChange()); 351 EXPECT_EQ(50, animation->timeToForwardsEffectChange());
351 EXPECT_EQ(0, animation->timeToReverseEffectChange()); 352 EXPECT_EQ(0, animation->timeToReverseEffectChange());
352 353
353 player->setCurrentTimeInternal(149); 354 player->setCurrentTimeInternal(149);
(...skipping 10 matching lines...) Expand all
364 } 365 }
365 366
366 TEST_F(KeyframeEffectTest, ElementDestructorClearsAnimationTarget) 367 TEST_F(KeyframeEffectTest, ElementDestructorClearsAnimationTarget)
367 { 368 {
368 // This test expects incorrect behaviour should be removed once Element 369 // This test expects incorrect behaviour should be removed once Element
369 // and KeyframeEffect are moved to Oilpan. See crbug.com/362404 for context. 370 // and KeyframeEffect are moved to Oilpan. See crbug.com/362404 for context.
370 Timing timing; 371 Timing timing;
371 timing.iterationDuration = 5; 372 timing.iterationDuration = 5;
372 KeyframeEffect* animation = KeyframeEffect::create(element.get(), nullptr, t iming); 373 KeyframeEffect* animation = KeyframeEffect::create(element.get(), nullptr, t iming);
373 EXPECT_EQ(element.get(), animation->target()); 374 EXPECT_EQ(element.get(), animation->target());
374 document.timeline().play(animation); 375 document().timeline().play(animation);
375 pageHolder.clear(); 376 pageHolder.clear();
376 element.clear(); 377 element.clear();
377 } 378 }
378 379
379 } // namespace blink 380 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698