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 26 matching lines...) Expand all Loading... |
37 #include "core/dom/Document.h" | 37 #include "core/dom/Document.h" |
38 #include "core/dom/Element.h" | 38 #include "core/dom/Element.h" |
39 #include "core/dom/QualifiedName.h" | 39 #include "core/dom/QualifiedName.h" |
40 #include "weborigin/KURL.h" | 40 #include "weborigin/KURL.h" |
41 #include <gtest/gtest.h> | 41 #include <gtest/gtest.h> |
42 | 42 |
43 using namespace WebCore; | 43 using namespace WebCore; |
44 | 44 |
45 namespace { | 45 namespace { |
46 | 46 |
47 class DocumentTimelineTest : public ::testing::Test { | 47 class CoreAnimationDocumentTimelineTest : public ::testing::Test { |
48 protected: | 48 protected: |
49 virtual void SetUp() | 49 virtual void SetUp() |
50 { | 50 { |
51 document = Document::create(); | 51 document = Document::create(); |
52 element = Element::create(nullQName() , document.get()); | 52 element = Element::create(nullQName() , document.get()); |
53 timeline = DocumentTimeline::create(document.get()); | 53 timeline = DocumentTimeline::create(document.get()); |
54 timeline->setZeroTimeAsPerfTime(0); | 54 timeline->setZeroTimeAsPerfTime(0); |
55 ASSERT_EQ(0, timeline->currentTime()); | 55 ASSERT_EQ(0, timeline->currentTime()); |
56 } | 56 } |
57 | 57 |
58 RefPtr<Document> document; | 58 RefPtr<Document> document; |
59 RefPtr<Element> element; | 59 RefPtr<Element> element; |
60 RefPtr<DocumentTimeline> timeline; | 60 RefPtr<DocumentTimeline> timeline; |
61 Timing timing; | 61 Timing timing; |
62 }; | 62 }; |
63 | 63 |
64 TEST_F(DocumentTimelineTest, EmptyKeyframeAnimation) | 64 TEST_F(CoreAnimationDocumentTimelineTest, EmptyKeyframeAnimation) |
65 { | 65 { |
66 RefPtr<KeyframeAnimationEffect> effect = KeyframeAnimationEffect::create(Key
frameAnimationEffect::KeyframeVector()); | 66 RefPtr<KeyframeAnimationEffect> effect = KeyframeAnimationEffect::create(Key
frameAnimationEffect::KeyframeVector()); |
67 RefPtr<Animation> anim = Animation::create(element.get(), effect, timing); | 67 RefPtr<Animation> anim = Animation::create(element.get(), effect, timing); |
68 | 68 |
69 timeline->play(anim.get()); | 69 timeline->play(anim.get()); |
70 | 70 |
71 timeline->serviceAnimations(0); | 71 timeline->serviceAnimations(0); |
72 EXPECT_FLOAT_EQ(0, timeline->currentTime()); | 72 EXPECT_FLOAT_EQ(0, timeline->currentTime()); |
73 EXPECT_TRUE(anim->compositableValues()->isEmpty()); | 73 EXPECT_TRUE(anim->compositableValues()->isEmpty()); |
74 | 74 |
75 timeline->serviceAnimations(100); | 75 timeline->serviceAnimations(100); |
76 EXPECT_FLOAT_EQ(100, timeline->currentTime()); | 76 EXPECT_FLOAT_EQ(100, timeline->currentTime()); |
77 } | 77 } |
78 | 78 |
79 TEST_F(DocumentTimelineTest, ZeroTimeAsPerfTime) | 79 TEST_F(CoreAnimationDocumentTimelineTest, ZeroTimeAsPerfTime) |
80 { | 80 { |
81 timeline = DocumentTimeline::create(document.get()); | 81 timeline = DocumentTimeline::create(document.get()); |
82 | 82 |
83 timeline->serviceAnimations(100); | 83 timeline->serviceAnimations(100); |
84 EXPECT_TRUE(isNull(timeline->currentTime())); | 84 EXPECT_TRUE(isNull(timeline->currentTime())); |
85 | 85 |
86 timeline->serviceAnimations(200); | 86 timeline->serviceAnimations(200); |
87 EXPECT_TRUE(isNull(timeline->currentTime())); | 87 EXPECT_TRUE(isNull(timeline->currentTime())); |
88 | 88 |
89 timeline->setZeroTimeAsPerfTime(300); | 89 timeline->setZeroTimeAsPerfTime(300); |
90 timeline->serviceAnimations(300); | 90 timeline->serviceAnimations(300); |
91 EXPECT_EQ(0, timeline->currentTime()); | 91 EXPECT_EQ(0, timeline->currentTime()); |
92 | 92 |
93 timeline->serviceAnimations(400); | 93 timeline->serviceAnimations(400); |
94 EXPECT_EQ(100, timeline->currentTime()); | 94 EXPECT_EQ(100, timeline->currentTime()); |
95 } | 95 } |
96 | 96 |
97 TEST_F(DocumentTimelineTest, PauseForTesting) | 97 TEST_F(CoreAnimationDocumentTimelineTest, PauseForTesting) |
98 { | 98 { |
99 float seekTime = 1; | 99 float seekTime = 1; |
100 RefPtr<Animation> anim1 = Animation::create(element.get(), KeyframeAnimation
Effect::create(KeyframeAnimationEffect::KeyframeVector()), timing); | 100 RefPtr<Animation> anim1 = Animation::create(element.get(), KeyframeAnimation
Effect::create(KeyframeAnimationEffect::KeyframeVector()), timing); |
101 RefPtr<Animation> anim2 = Animation::create(element.get(), KeyframeAnimatio
nEffect::create(KeyframeAnimationEffect::KeyframeVector()), timing); | 101 RefPtr<Animation> anim2 = Animation::create(element.get(), KeyframeAnimatio
nEffect::create(KeyframeAnimationEffect::KeyframeVector()), timing); |
102 RefPtr<Player> player1 = timeline->play(anim1.get()); | 102 RefPtr<Player> player1 = timeline->play(anim1.get()); |
103 RefPtr<Player> player2 = timeline->play(anim2.get()); | 103 RefPtr<Player> player2 = timeline->play(anim2.get()); |
104 timeline->pauseAnimationsForTesting(seekTime); | 104 timeline->pauseAnimationsForTesting(seekTime); |
105 | 105 |
106 EXPECT_FLOAT_EQ(seekTime, player1->currentTime()); | 106 EXPECT_FLOAT_EQ(seekTime, player1->currentTime()); |
107 EXPECT_FLOAT_EQ(seekTime, player2->currentTime()); | 107 EXPECT_FLOAT_EQ(seekTime, player2->currentTime()); |
108 } | 108 } |
109 | 109 |
110 TEST_F(DocumentTimelineTest, NumberOfActiveAnimations) | 110 TEST_F(CoreAnimationDocumentTimelineTest, NumberOfActiveAnimations) |
111 { | 111 { |
112 Timing timingForwardFill; | 112 Timing timingForwardFill; |
113 timingForwardFill.hasIterationDuration = true; | 113 timingForwardFill.hasIterationDuration = true; |
114 timingForwardFill.iterationDuration = 2; | 114 timingForwardFill.iterationDuration = 2; |
115 | 115 |
116 Timing timingNoFill; | 116 Timing timingNoFill; |
117 timingNoFill.hasIterationDuration = true; | 117 timingNoFill.hasIterationDuration = true; |
118 timingNoFill.iterationDuration = 2; | 118 timingNoFill.iterationDuration = 2; |
119 timingNoFill.fillMode = Timing::FillModeNone; | 119 timingNoFill.fillMode = Timing::FillModeNone; |
120 | 120 |
(...skipping 23 matching lines...) Expand all Loading... |
144 EXPECT_EQ(4U, timeline->numberOfActiveAnimationsForTesting()); | 144 EXPECT_EQ(4U, timeline->numberOfActiveAnimationsForTesting()); |
145 timeline->serviceAnimations(0.5); | 145 timeline->serviceAnimations(0.5); |
146 EXPECT_EQ(4U, timeline->numberOfActiveAnimationsForTesting()); | 146 EXPECT_EQ(4U, timeline->numberOfActiveAnimationsForTesting()); |
147 timeline->serviceAnimations(1.5); | 147 timeline->serviceAnimations(1.5); |
148 EXPECT_EQ(4U, timeline->numberOfActiveAnimationsForTesting()); | 148 EXPECT_EQ(4U, timeline->numberOfActiveAnimationsForTesting()); |
149 timeline->serviceAnimations(3); | 149 timeline->serviceAnimations(3); |
150 EXPECT_EQ(1U, timeline->numberOfActiveAnimationsForTesting()); | 150 EXPECT_EQ(1U, timeline->numberOfActiveAnimationsForTesting()); |
151 } | 151 } |
152 | 152 |
153 } | 153 } |
OLD | NEW |