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

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

Issue 2948193002: Merge AnimationTimeline and DocumentTimeline (Closed)
Patch Set: Fix rebase error Created 3 years, 5 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 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "core/animation/Animation.h" 31 #include "core/animation/Animation.h"
32 32
33 #include <memory> 33 #include <memory>
34 #include "core/animation/AnimationClock.h" 34 #include "core/animation/AnimationClock.h"
35 #include "core/animation/AnimationTimeline.h"
36 #include "core/animation/CompositorPendingAnimations.h" 35 #include "core/animation/CompositorPendingAnimations.h"
36 #include "core/animation/DocumentTimeline.h"
37 #include "core/animation/ElementAnimations.h" 37 #include "core/animation/ElementAnimations.h"
38 #include "core/animation/KeyframeEffect.h" 38 #include "core/animation/KeyframeEffect.h"
39 #include "core/dom/DOMNodeIds.h" 39 #include "core/dom/DOMNodeIds.h"
40 #include "core/dom/Document.h" 40 #include "core/dom/Document.h"
41 #include "core/dom/QualifiedName.h" 41 #include "core/dom/QualifiedName.h"
42 #include "core/layout/LayoutTestHelper.h" 42 #include "core/layout/LayoutTestHelper.h"
43 #include "core/paint/PaintLayer.h" 43 #include "core/paint/PaintLayer.h"
44 #include "core/testing/DummyPageHolder.h" 44 #include "core/testing/DummyPageHolder.h"
45 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" 45 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
46 #include "platform/weborigin/KURL.h" 46 #include "platform/weborigin/KURL.h"
47 #include "testing/gtest/include/gtest/gtest.h" 47 #include "testing/gtest/include/gtest/gtest.h"
48 48
49 namespace blink { 49 namespace blink {
50 50
51 class AnimationAnimationTest : public RenderingTest { 51 class AnimationAnimationTest : public RenderingTest {
52 public: 52 public:
53 AnimationAnimationTest() 53 AnimationAnimationTest()
54 : RenderingTest(SingleChildLocalFrameClient::Create()) {} 54 : RenderingTest(SingleChildLocalFrameClient::Create()) {}
55 55
56 void SetUp() override { 56 void SetUp() override {
57 RenderingTest::SetUp(); 57 RenderingTest::SetUp();
58 SetUpWithoutStartingTimeline(); 58 SetUpWithoutStartingTimeline();
59 StartTimeline(); 59 StartTimeline();
60 } 60 }
61 61
62 void SetUpWithoutStartingTimeline() { 62 void SetUpWithoutStartingTimeline() {
63 page_holder = DummyPageHolder::Create(); 63 page_holder = DummyPageHolder::Create();
64 document = &page_holder->GetDocument(); 64 document = &page_holder->GetDocument();
65 document->GetAnimationClock().ResetTimeForTesting(); 65 document->GetAnimationClock().ResetTimeForTesting();
66 timeline = AnimationTimeline::Create(document.Get()); 66 timeline = DocumentTimeline::Create(document.Get());
67 timeline->ResetForTesting(); 67 timeline->ResetForTesting();
68 animation = timeline->Play(0); 68 animation = timeline->Play(0);
69 animation->setStartTime(0, false); 69 animation->setStartTime(0, false);
70 animation->setEffect(MakeAnimation()); 70 animation->setEffect(MakeAnimation());
71 } 71 }
72 72
73 void StartTimeline() { SimulateFrame(0); } 73 void StartTimeline() { SimulateFrame(0); }
74 74
75 KeyframeEffect* MakeAnimation(double duration = 30, 75 KeyframeEffect* MakeAnimation(double duration = 30,
76 double playback_rate = 1) { 76 double playback_rate = 1) {
77 Timing timing; 77 Timing timing;
78 timing.iteration_duration = duration; 78 timing.iteration_duration = duration;
79 timing.playback_rate = playback_rate; 79 timing.playback_rate = playback_rate;
80 return KeyframeEffect::Create(0, nullptr, timing); 80 return KeyframeEffect::Create(0, nullptr, timing);
81 } 81 }
82 82
83 bool SimulateFrame(double time, 83 bool SimulateFrame(double time,
84 Optional<CompositorElementIdSet> composited_element_ids = 84 Optional<CompositorElementIdSet> composited_element_ids =
85 Optional<CompositorElementIdSet>()) { 85 Optional<CompositorElementIdSet>()) {
86 document->GetAnimationClock().UpdateTime(time); 86 document->GetAnimationClock().UpdateTime(time);
87 document->GetCompositorPendingAnimations().Update(composited_element_ids, 87 document->GetCompositorPendingAnimations().Update(composited_element_ids,
88 false); 88 false);
89 // The timeline does not know about our animation, so we have to explicitly 89 // The timeline does not know about our animation, so we have to explicitly
90 // call update(). 90 // call update().
91 return animation->Update(kTimingUpdateForAnimationFrame); 91 return animation->Update(kTimingUpdateForAnimationFrame);
92 } 92 }
93 93
94 Persistent<Document> document; 94 Persistent<Document> document;
95 Persistent<AnimationTimeline> timeline; 95 Persistent<DocumentTimeline> timeline;
96 Persistent<Animation> animation; 96 Persistent<Animation> animation;
97 std::unique_ptr<DummyPageHolder> page_holder; 97 std::unique_ptr<DummyPageHolder> page_holder;
98 }; 98 };
99 99
100 TEST_F(AnimationAnimationTest, InitialState) { 100 TEST_F(AnimationAnimationTest, InitialState) {
101 SetUpWithoutStartingTimeline(); 101 SetUpWithoutStartingTimeline();
102 animation = timeline->Play(0); 102 animation = timeline->Play(0);
103 EXPECT_EQ(Animation::kPending, animation->PlayStateInternal()); 103 EXPECT_EQ(Animation::kPending, animation->PlayStateInternal());
104 EXPECT_EQ(0, animation->CurrentTimeInternal()); 104 EXPECT_EQ(0, animation->CurrentTimeInternal());
105 EXPECT_FALSE(animation->Paused()); 105 EXPECT_FALSE(animation->Paused());
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 animation_composited 828 animation_composited
829 ->CheckCanStartAnimationOnCompositorInternal(composited_element_ids) 829 ->CheckCanStartAnimationOnCompositorInternal(composited_element_ids)
830 .Ok()); 830 .Ok());
831 EXPECT_FALSE( 831 EXPECT_FALSE(
832 animation_not_composited 832 animation_not_composited
833 ->CheckCanStartAnimationOnCompositorInternal(composited_element_ids) 833 ->CheckCanStartAnimationOnCompositorInternal(composited_element_ids)
834 .Ok()); 834 .Ok());
835 } 835 }
836 836
837 } // namespace blink 837 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/animation/Animation.cpp ('k') | third_party/WebKit/Source/core/animation/AnimationTimeline.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698