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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 KeyframeEffect* makeAnimation(double duration = 30, double playbackRate = 1) { | 67 KeyframeEffect* makeAnimation(double duration = 30, double playbackRate = 1) { |
68 Timing timing; | 68 Timing timing; |
69 timing.iterationDuration = duration; | 69 timing.iterationDuration = duration; |
70 timing.playbackRate = playbackRate; | 70 timing.playbackRate = playbackRate; |
71 return KeyframeEffect::create(0, nullptr, timing); | 71 return KeyframeEffect::create(0, nullptr, timing); |
72 } | 72 } |
73 | 73 |
74 bool simulateFrame(double time) { | 74 bool simulateFrame(double time) { |
75 document->animationClock().updateTime(time); | 75 document->animationClock().updateTime(time); |
76 document->compositorPendingAnimations().update(false); | 76 document->compositorPendingAnimations().update(false); |
77 // The timeline does not know about our animation, so we have to explicitly
call update(). | 77 // The timeline does not know about our animation, so we have to explicitly |
| 78 // call update(). |
78 return animation->update(TimingUpdateForAnimationFrame); | 79 return animation->update(TimingUpdateForAnimationFrame); |
79 } | 80 } |
80 | 81 |
81 Persistent<Document> document; | 82 Persistent<Document> document; |
82 Persistent<AnimationTimeline> timeline; | 83 Persistent<AnimationTimeline> timeline; |
83 Persistent<Animation> animation; | 84 Persistent<Animation> animation; |
84 std::unique_ptr<DummyPageHolder> pageHolder; | 85 std::unique_ptr<DummyPageHolder> pageHolder; |
85 }; | 86 }; |
86 | 87 |
87 TEST_F(AnimationAnimationTest, InitialState) { | 88 TEST_F(AnimationAnimationTest, InitialState) { |
(...skipping 14 matching lines...) Expand all Loading... |
102 EXPECT_EQ(1, animation->playbackRate()); | 103 EXPECT_EQ(1, animation->playbackRate()); |
103 EXPECT_EQ(0, animation->startTimeInternal()); | 104 EXPECT_EQ(0, animation->startTimeInternal()); |
104 EXPECT_TRUE(animation->hasStartTime()); | 105 EXPECT_TRUE(animation->hasStartTime()); |
105 } | 106 } |
106 | 107 |
107 TEST_F(AnimationAnimationTest, CurrentTimeDoesNotSetOutdated) { | 108 TEST_F(AnimationAnimationTest, CurrentTimeDoesNotSetOutdated) { |
108 EXPECT_FALSE(animation->outdated()); | 109 EXPECT_FALSE(animation->outdated()); |
109 EXPECT_EQ(0, animation->currentTimeInternal()); | 110 EXPECT_EQ(0, animation->currentTimeInternal()); |
110 EXPECT_FALSE(animation->outdated()); | 111 EXPECT_FALSE(animation->outdated()); |
111 // FIXME: We should split simulateFrame into a version that doesn't update | 112 // FIXME: We should split simulateFrame into a version that doesn't update |
112 // the animation and one that does, as most of the tests don't require update(
) | 113 // the animation and one that does, as most of the tests don't require |
113 // to be called. | 114 // update() to be called. |
114 document->animationClock().updateTime(10); | 115 document->animationClock().updateTime(10); |
115 EXPECT_EQ(10, animation->currentTimeInternal()); | 116 EXPECT_EQ(10, animation->currentTimeInternal()); |
116 EXPECT_FALSE(animation->outdated()); | 117 EXPECT_FALSE(animation->outdated()); |
117 } | 118 } |
118 | 119 |
119 TEST_F(AnimationAnimationTest, SetCurrentTime) { | 120 TEST_F(AnimationAnimationTest, SetCurrentTime) { |
120 EXPECT_EQ(Animation::Running, animation->playStateInternal()); | 121 EXPECT_EQ(Animation::Running, animation->playStateInternal()); |
121 animation->setCurrentTimeInternal(10); | 122 animation->setCurrentTimeInternal(10); |
122 EXPECT_EQ(Animation::Running, animation->playStateInternal()); | 123 EXPECT_EQ(Animation::Running, animation->playStateInternal()); |
123 EXPECT_EQ(10, animation->currentTimeInternal()); | 124 EXPECT_EQ(10, animation->currentTimeInternal()); |
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 EXPECT_EQ(Animation::Idle, animation->playStateInternal()); | 777 EXPECT_EQ(Animation::Idle, animation->playStateInternal()); |
777 EXPECT_TRUE(std::isnan(animation->currentTime())); | 778 EXPECT_TRUE(std::isnan(animation->currentTime())); |
778 EXPECT_TRUE(std::isnan(animation->startTime())); | 779 EXPECT_TRUE(std::isnan(animation->startTime())); |
779 animation->pause(); | 780 animation->pause(); |
780 EXPECT_EQ(Animation::Pending, animation->playStateInternal()); | 781 EXPECT_EQ(Animation::Pending, animation->playStateInternal()); |
781 EXPECT_EQ(0, animation->currentTime()); | 782 EXPECT_EQ(0, animation->currentTime()); |
782 EXPECT_TRUE(std::isnan(animation->startTime())); | 783 EXPECT_TRUE(std::isnan(animation->startTime())); |
783 } | 784 } |
784 | 785 |
785 } // namespace blink | 786 } // namespace blink |
OLD | NEW |