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

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

Issue 2775143002: Implement frames() timing function (Closed)
Patch Set: Created 3 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
OLDNEW
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #include <memory> 59 #include <memory>
60 60
61 namespace blink { 61 namespace blink {
62 62
63 class AnimationCompositorAnimationsTest : public ::testing::Test { 63 class AnimationCompositorAnimationsTest : public ::testing::Test {
64 protected: 64 protected:
65 RefPtr<TimingFunction> m_linearTimingFunction; 65 RefPtr<TimingFunction> m_linearTimingFunction;
66 RefPtr<TimingFunction> m_cubicEaseTimingFunction; 66 RefPtr<TimingFunction> m_cubicEaseTimingFunction;
67 RefPtr<TimingFunction> m_cubicCustomTimingFunction; 67 RefPtr<TimingFunction> m_cubicCustomTimingFunction;
68 RefPtr<TimingFunction> m_stepTimingFunction; 68 RefPtr<TimingFunction> m_stepTimingFunction;
69 RefPtr<TimingFunction> m_framesTimingFunction;
69 70
70 Timing m_timing; 71 Timing m_timing;
71 CompositorAnimations::CompositorTiming m_compositorTiming; 72 CompositorAnimations::CompositorTiming m_compositorTiming;
72 std::unique_ptr<AnimatableValueKeyframeVector> m_keyframeVector2; 73 std::unique_ptr<AnimatableValueKeyframeVector> m_keyframeVector2;
73 Persistent<AnimatableValueKeyframeEffectModel> m_keyframeAnimationEffect2; 74 Persistent<AnimatableValueKeyframeEffectModel> m_keyframeAnimationEffect2;
74 std::unique_ptr<AnimatableValueKeyframeVector> m_keyframeVector5; 75 std::unique_ptr<AnimatableValueKeyframeVector> m_keyframeVector5;
75 Persistent<AnimatableValueKeyframeEffectModel> m_keyframeAnimationEffect5; 76 Persistent<AnimatableValueKeyframeEffectModel> m_keyframeAnimationEffect5;
76 77
77 Persistent<Document> m_document; 78 Persistent<Document> m_document;
78 Persistent<Element> m_element; 79 Persistent<Element> m_element;
79 Persistent<AnimationTimeline> m_timeline; 80 Persistent<AnimationTimeline> m_timeline;
80 std::unique_ptr<DummyPageHolder> m_pageHolder; 81 std::unique_ptr<DummyPageHolder> m_pageHolder;
81 82
82 void SetUp() override { 83 void SetUp() override {
83 m_linearTimingFunction = LinearTimingFunction::shared(); 84 m_linearTimingFunction = LinearTimingFunction::shared();
84 m_cubicEaseTimingFunction = CubicBezierTimingFunction::preset( 85 m_cubicEaseTimingFunction = CubicBezierTimingFunction::preset(
85 CubicBezierTimingFunction::EaseType::EASE); 86 CubicBezierTimingFunction::EaseType::EASE);
86 m_cubicCustomTimingFunction = CubicBezierTimingFunction::create(1, 2, 3, 4); 87 m_cubicCustomTimingFunction = CubicBezierTimingFunction::create(1, 2, 3, 4);
87 m_stepTimingFunction = 88 m_stepTimingFunction =
88 StepsTimingFunction::create(1, StepsTimingFunction::StepPosition::END); 89 StepsTimingFunction::create(1, StepsTimingFunction::StepPosition::END);
90 m_framesTimingFunction = FramesTimingFunction::create(2);
89 91
90 m_timing = createCompositableTiming(); 92 m_timing = createCompositableTiming();
91 m_compositorTiming = CompositorAnimations::CompositorTiming(); 93 m_compositorTiming = CompositorAnimations::CompositorTiming();
92 // Make sure the CompositableTiming is really compositable, otherwise 94 // Make sure the CompositableTiming is really compositable, otherwise
93 // most other tests will fail. 95 // most other tests will fail.
94 ASSERT_TRUE(convertTimingForCompositor(m_timing, m_compositorTiming)); 96 ASSERT_TRUE(convertTimingForCompositor(m_timing, m_compositorTiming));
95 97
96 m_keyframeVector2 = createCompositableFloatKeyframeVector(2); 98 m_keyframeVector2 = createCompositableFloatKeyframeVector(2);
97 m_keyframeAnimationEffect2 = 99 m_keyframeAnimationEffect2 =
98 AnimatableValueKeyframeEffectModel::create(*m_keyframeVector2); 100 AnimatableValueKeyframeEffectModel::create(*m_keyframeVector2);
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 TEST_F(AnimationCompositorAnimationsTest, 600 TEST_F(AnimationCompositorAnimationsTest,
599 isCandidateForAnimationOnCompositorTimingFunctionSteps) { 601 isCandidateForAnimationOnCompositorTimingFunctionSteps) {
600 m_timing.timingFunction = m_stepTimingFunction; 602 m_timing.timingFunction = m_stepTimingFunction;
601 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, 603 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing,
602 *m_keyframeAnimationEffect2)); 604 *m_keyframeAnimationEffect2));
603 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, 605 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing,
604 *m_keyframeAnimationEffect5)); 606 *m_keyframeAnimationEffect5));
605 } 607 }
606 608
607 TEST_F(AnimationCompositorAnimationsTest, 609 TEST_F(AnimationCompositorAnimationsTest,
610 isCandidateForAnimationOnCompositorTimingFunctionFrames) {
611 m_timing.timingFunction = m_framesTimingFunction;
612 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing,
613 *m_keyframeAnimationEffect2));
614 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing,
615 *m_keyframeAnimationEffect5));
616 }
617
618 TEST_F(AnimationCompositorAnimationsTest,
608 isCandidateForAnimationOnCompositorTimingFunctionChainedLinear) { 619 isCandidateForAnimationOnCompositorTimingFunctionChainedLinear) {
609 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, 620 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing,
610 *m_keyframeAnimationEffect2)); 621 *m_keyframeAnimationEffect2));
611 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, 622 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing,
612 *m_keyframeAnimationEffect5)); 623 *m_keyframeAnimationEffect5));
613 } 624 }
614 625
615 TEST_F( 626 TEST_F(
616 AnimationCompositorAnimationsTest, 627 AnimationCompositorAnimationsTest,
617 isCandidateForAnimationOnCompositorNonLinearTimingFunctionOnFirstOrLastFrame ) { 628 isCandidateForAnimationOnCompositorNonLinearTimingFunctionOnFirstOrLastFrame ) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 (*m_keyframeVector5)[1]->setEasing(m_cubicEaseTimingFunction.get()); 678 (*m_keyframeVector5)[1]->setEasing(m_cubicEaseTimingFunction.get());
668 (*m_keyframeVector5)[2]->setEasing(m_cubicEaseTimingFunction.get()); 679 (*m_keyframeVector5)[2]->setEasing(m_cubicEaseTimingFunction.get());
669 (*m_keyframeVector5)[3]->setEasing(m_linearTimingFunction.get()); 680 (*m_keyframeVector5)[3]->setEasing(m_linearTimingFunction.get());
670 m_keyframeAnimationEffect5 = 681 m_keyframeAnimationEffect5 =
671 AnimatableValueKeyframeEffectModel::create(*m_keyframeVector5); 682 AnimatableValueKeyframeEffectModel::create(*m_keyframeVector5);
672 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, 683 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing,
673 *m_keyframeAnimationEffect5)); 684 *m_keyframeAnimationEffect5));
674 } 685 }
675 686
676 TEST_F(AnimationCompositorAnimationsTest, 687 TEST_F(AnimationCompositorAnimationsTest,
677 isCandidateForAnimationOnCompositorTimingFunctionWithStepOkay) { 688 isCandidateForAnimationOnCompositorTimingFunctionWithStepOrFrameOkay) {
678 (*m_keyframeVector2)[0]->setEasing(m_stepTimingFunction.get()); 689 (*m_keyframeVector2)[0]->setEasing(m_stepTimingFunction.get());
679 m_keyframeAnimationEffect2 = 690 m_keyframeAnimationEffect2 =
680 AnimatableValueKeyframeEffectModel::create(*m_keyframeVector2); 691 AnimatableValueKeyframeEffectModel::create(*m_keyframeVector2);
681 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, 692 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing,
682 *m_keyframeAnimationEffect2)); 693 *m_keyframeAnimationEffect2));
683 694
695 (*m_keyframeVector2)[0]->setEasing(m_framesTimingFunction.get());
696 m_keyframeAnimationEffect2 =
697 AnimatableValueKeyframeEffectModel::create(*m_keyframeVector2);
698 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing,
699 *m_keyframeAnimationEffect2));
700
684 (*m_keyframeVector5)[0]->setEasing(m_stepTimingFunction.get()); 701 (*m_keyframeVector5)[0]->setEasing(m_stepTimingFunction.get());
685 (*m_keyframeVector5)[1]->setEasing(m_linearTimingFunction.get()); 702 (*m_keyframeVector5)[1]->setEasing(m_linearTimingFunction.get());
686 (*m_keyframeVector5)[2]->setEasing(m_cubicEaseTimingFunction.get()); 703 (*m_keyframeVector5)[2]->setEasing(m_cubicEaseTimingFunction.get());
687 (*m_keyframeVector5)[3]->setEasing(m_linearTimingFunction.get()); 704 (*m_keyframeVector5)[3]->setEasing(m_framesTimingFunction.get());
688 m_keyframeAnimationEffect5 = 705 m_keyframeAnimationEffect5 =
689 AnimatableValueKeyframeEffectModel::create(*m_keyframeVector5); 706 AnimatableValueKeyframeEffectModel::create(*m_keyframeVector5);
690 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, 707 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing,
691 *m_keyframeAnimationEffect5)); 708 *m_keyframeAnimationEffect5));
692 709
693 (*m_keyframeVector5)[0]->setEasing(m_linearTimingFunction.get()); 710 (*m_keyframeVector5)[0]->setEasing(m_framesTimingFunction.get());
694 (*m_keyframeVector5)[1]->setEasing(m_stepTimingFunction.get()); 711 (*m_keyframeVector5)[1]->setEasing(m_stepTimingFunction.get());
695 (*m_keyframeVector5)[2]->setEasing(m_cubicEaseTimingFunction.get()); 712 (*m_keyframeVector5)[2]->setEasing(m_cubicEaseTimingFunction.get());
696 (*m_keyframeVector5)[3]->setEasing(m_linearTimingFunction.get()); 713 (*m_keyframeVector5)[3]->setEasing(m_linearTimingFunction.get());
697 m_keyframeAnimationEffect5 = 714 m_keyframeAnimationEffect5 =
698 AnimatableValueKeyframeEffectModel::create(*m_keyframeVector5); 715 AnimatableValueKeyframeEffectModel::create(*m_keyframeVector5);
699 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, 716 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing,
700 *m_keyframeAnimationEffect5)); 717 *m_keyframeAnimationEffect5));
701 718
702 (*m_keyframeVector5)[0]->setEasing(m_linearTimingFunction.get()); 719 (*m_keyframeVector5)[0]->setEasing(m_linearTimingFunction.get());
703 (*m_keyframeVector5)[1]->setEasing(m_cubicEaseTimingFunction.get()); 720 (*m_keyframeVector5)[1]->setEasing(m_framesTimingFunction.get());
704 (*m_keyframeVector5)[2]->setEasing(m_cubicEaseTimingFunction.get()); 721 (*m_keyframeVector5)[2]->setEasing(m_cubicEaseTimingFunction.get());
705 (*m_keyframeVector5)[3]->setEasing(m_stepTimingFunction.get()); 722 (*m_keyframeVector5)[3]->setEasing(m_stepTimingFunction.get());
706 m_keyframeAnimationEffect5 = 723 m_keyframeAnimationEffect5 =
707 AnimatableValueKeyframeEffectModel::create(*m_keyframeVector5); 724 AnimatableValueKeyframeEffectModel::create(*m_keyframeVector5);
708 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, 725 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing,
709 *m_keyframeAnimationEffect5)); 726 *m_keyframeAnimationEffect5));
710 } 727 }
711 728
712 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositor) { 729 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositor) {
713 AnimatableValueKeyframeVector basicFramesVector; 730 AnimatableValueKeyframeVector basicFramesVector;
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 1313
1297 // Clearing the effect node entirely should also produce false. 1314 // Clearing the effect node entirely should also produce false.
1298 properties.clearEffect(); 1315 properties.clearEffect();
1299 EXPECT_FALSE(CompositorAnimations::canStartAnimationOnCompositor(*element)); 1316 EXPECT_FALSE(CompositorAnimations::canStartAnimationOnCompositor(*element));
1300 1317
1301 element->setLayoutObject(nullptr); 1318 element->setLayoutObject(nullptr);
1302 LayoutObjectProxy::dispose(layoutObject); 1319 LayoutObjectProxy::dispose(layoutObject);
1303 } 1320 }
1304 1321
1305 } // namespace blink 1322 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698