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

Side by Side Diff: third_party/WebKit/Source/platform/scroll/ScrollAnimatorTest.cpp

Issue 2006103004: Send takeover msg from MT to CC using the animation path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: jbroman nits Created 4 years, 7 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
« no previous file with comments | « third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.cpp ('k') | 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 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 { 307 {
308 MockScrollableArea* scrollableArea = MockScrollableArea::create(true); 308 MockScrollableArea* scrollableArea = MockScrollableArea::create(true);
309 TestScrollAnimator* scrollAnimator = new TestScrollAnimator(scrollableArea, getMockedTime); 309 TestScrollAnimator* scrollAnimator = new TestScrollAnimator(scrollableArea, getMockedTime);
310 310
311 EXPECT_CALL(*scrollableArea, minimumScrollPosition()).Times(AtLeast(1)) 311 EXPECT_CALL(*scrollableArea, minimumScrollPosition()).Times(AtLeast(1))
312 .WillRepeatedly(Return(IntPoint())); 312 .WillRepeatedly(Return(IntPoint()));
313 EXPECT_CALL(*scrollableArea, maximumScrollPosition()).Times(AtLeast(1)) 313 EXPECT_CALL(*scrollableArea, maximumScrollPosition()).Times(AtLeast(1))
314 .WillRepeatedly(Return(IntPoint(1000, 1000))); 314 .WillRepeatedly(Return(IntPoint(1000, 1000)));
315 EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(2); 315 EXPECT_CALL(*scrollableArea, setScrollOffset(_, _)).Times(2);
316 // Called from userScroll, updateCompositorAnimations, then 316 // Called from userScroll, updateCompositorAnimations, then
317 // takeoverCompositorAnimation (to re-register after RunningOnCompositor). 317 // takeOverCompositorAnimation (to re-register after RunningOnCompositor).
318 EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(3); 318 EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(3);
319 EXPECT_CALL(*scrollableArea, scheduleAnimation()).Times(AtLeast(1)) 319 EXPECT_CALL(*scrollableArea, scheduleAnimation()).Times(AtLeast(1))
320 .WillRepeatedly(Return(true)); 320 .WillRepeatedly(Return(true));
321 321
322 EXPECT_FALSE(scrollAnimator->hasAnimationThatRequiresService()); 322 EXPECT_FALSE(scrollAnimator->hasAnimationThatRequiresService());
323 323
324 // Smooth scroll. 324 // Smooth scroll.
325 ScrollResult result = scrollAnimator->userScroll(ScrollByLine, FloatSize(100 , 0)); 325 ScrollResult result = scrollAnimator->userScroll(ScrollByLine, FloatSize(100 , 0));
326 EXPECT_TRUE(scrollAnimator->hasAnimationThatRequiresService()); 326 EXPECT_TRUE(scrollAnimator->hasAnimationThatRequiresService());
327 EXPECT_TRUE(result.didScrollX); 327 EXPECT_TRUE(result.didScrollX);
328 EXPECT_FLOAT_EQ(0.0, result.unusedScrollDeltaX); 328 EXPECT_FLOAT_EQ(0.0, result.unusedScrollDeltaX);
329 EXPECT_TRUE(scrollAnimator->hasRunningAnimation()); 329 EXPECT_TRUE(scrollAnimator->hasRunningAnimation());
330 330
331 // Update compositor animation. 331 // Update compositor animation.
332 gMockedTime += 0.05; 332 gMockedTime += 0.05;
333 scrollAnimator->setShouldSendToCompositor(true); 333 scrollAnimator->setShouldSendToCompositor(true);
334 scrollAnimator->updateCompositorAnimations(); 334 scrollAnimator->updateCompositorAnimations();
335 EXPECT_EQ(scrollAnimator->m_runState, 335 EXPECT_EQ(scrollAnimator->m_runState,
336 ScrollAnimatorCompositorCoordinator::RunState::RunningOnCompositor); 336 ScrollAnimatorCompositorCoordinator::RunState::RunningOnCompositor);
337 337
338 // Takeover. 338 // Takeover.
339 scrollAnimator->takeoverCompositorAnimation(); 339 scrollAnimator->takeOverCompositorAnimation();
340 EXPECT_EQ(scrollAnimator->m_runState, 340 EXPECT_EQ(scrollAnimator->m_runState,
341 ScrollAnimatorCompositorCoordinator::RunState::RunningOnCompositorButNee dsTakeover); 341 ScrollAnimatorCompositorCoordinator::RunState::RunningOnCompositorButNee dsTakeover);
342 342
343 // Animation should now be running on the main thread. 343 // Animation should now be running on the main thread.
344 scrollAnimator->setShouldSendToCompositor(false); 344 scrollAnimator->setShouldSendToCompositor(false);
345 scrollAnimator->updateCompositorAnimations(); 345 scrollAnimator->updateCompositorAnimations();
346 EXPECT_EQ(scrollAnimator->m_runState, 346 EXPECT_EQ(scrollAnimator->m_runState,
347 ScrollAnimatorCompositorCoordinator::RunState::RunningOnMainThread); 347 ScrollAnimatorCompositorCoordinator::RunState::RunningOnMainThread);
348 scrollAnimator->tickAnimation(getMockedTime()); 348 scrollAnimator->tickAnimation(getMockedTime());
349 EXPECT_NE(100, scrollAnimator->currentPosition().x()); 349 EXPECT_NE(100, scrollAnimator->currentPosition().x());
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 EXPECT_EQ(scrollAnimator->m_runState, 512 EXPECT_EQ(scrollAnimator->m_runState,
513 ScrollAnimatorCompositorCoordinator::RunState::RunningOnCompositorButNee dsUpdate); 513 ScrollAnimatorCompositorCoordinator::RunState::RunningOnCompositorButNee dsUpdate);
514 EXPECT_EQ(250, scrollAnimator->desiredTargetPosition().x()); 514 EXPECT_EQ(250, scrollAnimator->desiredTargetPosition().x());
515 EXPECT_EQ(0, scrollAnimator->desiredTargetPosition().y()); 515 EXPECT_EQ(0, scrollAnimator->desiredTargetPosition().y());
516 reset(*scrollAnimator); 516 reset(*scrollAnimator);
517 517
518 // Forced GC in order to finalize objects depending on the mock object. 518 // Forced GC in order to finalize objects depending on the mock object.
519 ThreadHeap::collectAllGarbage(); 519 ThreadHeap::collectAllGarbage();
520 } 520 }
521 521
522 // This test verifies that ImplOnlyAnimationUpdate gets cleared once its 522 // This test verifies that impl only animation updates get cleared once they
523 // pushed to compositor animation host. 523 // are pushed to compositor animation host.
524 TEST(ScrollAnimatorTest, ImplOnlyAnimationUpdatesCleared) 524 TEST(ScrollAnimatorTest, ImplOnlyAnimationUpdatesCleared)
525 { 525 {
526 MockScrollableArea* scrollableArea = MockScrollableArea::create(true); 526 MockScrollableArea* scrollableArea = MockScrollableArea::create(true);
527 TestScrollAnimator* animator = new TestScrollAnimator(scrollableArea, getMoc kedTime); 527 TestScrollAnimator* animator = new TestScrollAnimator(scrollableArea, getMoc kedTime);
528 528
529 EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(2); 529 // From calls to adjust/takeoverImplOnlyScrollOffsetAnimation.
530 EXPECT_CALL(*scrollableArea, registerForAnimation()).Times(3);
530 531
532 // Verify that the adjustment update is cleared.
531 EXPECT_EQ(animator->m_runState, ScrollAnimatorCompositorCoordinator::RunStat e::Idle); 533 EXPECT_EQ(animator->m_runState, ScrollAnimatorCompositorCoordinator::RunStat e::Idle);
532 EXPECT_FALSE(animator->hasAnimationThatRequiresService()); 534 EXPECT_FALSE(animator->hasAnimationThatRequiresService());
533 EXPECT_TRUE(animator->implOnlyAnimationAdjustmentForTesting().isZero()); 535 EXPECT_TRUE(animator->implOnlyAnimationAdjustmentForTesting().isZero());
534 536
535 animator->updateImplOnlyScrollOffsetAnimation(FloatSize(100.f, 100.f)); 537 animator->adjustImplOnlyScrollOffsetAnimation(FloatSize(100.f, 100.f));
536 animator->updateImplOnlyScrollOffsetAnimation(FloatSize(10.f, -10.f)); 538 animator->adjustImplOnlyScrollOffsetAnimation(FloatSize(10.f, -10.f));
537 539
538 EXPECT_TRUE(animator->hasAnimationThatRequiresService()); 540 EXPECT_TRUE(animator->hasAnimationThatRequiresService());
539 EXPECT_EQ(FloatSize(110.f, 90.f), animator->implOnlyAnimationAdjustmentForTe sting()); 541 EXPECT_EQ(FloatSize(110.f, 90.f), animator->implOnlyAnimationAdjustmentForTe sting());
540 542
541 animator->updateCompositorAnimations(); 543 animator->updateCompositorAnimations();
542 544
543 EXPECT_EQ(animator->m_runState, ScrollAnimatorCompositorCoordinator::RunStat e::Idle); 545 EXPECT_EQ(animator->m_runState, ScrollAnimatorCompositorCoordinator::RunStat e::Idle);
544 EXPECT_FALSE(animator->hasAnimationThatRequiresService()); 546 EXPECT_FALSE(animator->hasAnimationThatRequiresService());
545 EXPECT_TRUE(animator->implOnlyAnimationAdjustmentForTesting().isZero()); 547 EXPECT_TRUE(animator->implOnlyAnimationAdjustmentForTesting().isZero());
546 548
549 // Verify that the takeover update is cleared.
550 animator->takeOverImplOnlyScrollOffsetAnimation();
551 EXPECT_TRUE(animator->hasAnimationThatRequiresService());
552 animator->updateCompositorAnimations();
553 EXPECT_FALSE(animator->hasAnimationThatRequiresService());
554
547 // Forced GC in order to finalize objects depending on the mock object. 555 // Forced GC in order to finalize objects depending on the mock object.
548 ThreadHeap::collectAllGarbage(); 556 ThreadHeap::collectAllGarbage();
549 } 557 }
550 558
551 } // namespace blink 559 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/scroll/ScrollAnimatorCompositorCoordinator.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698