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

Side by Side Diff: cc/animation/animation_unittest.cc

Issue 693883004: Make cc::animation::TrimTimeToCurrentIteration,cc::AnimationCurve::Duration use TimeTicks/TimeDelta (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 | « cc/animation/animation_curve.h ('k') | cc/animation/keyframed_animation_curve.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/animation/animation.h" 5 #include "cc/animation/animation.h"
6 6
7 #include "cc/test/animation_test_common.h" 7 #include "cc/test/animation_test_common.h"
8 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 23 matching lines...) Expand all
34 scoped_ptr<Animation> CreateAnimation(double iterations, double duration) { 34 scoped_ptr<Animation> CreateAnimation(double iterations, double duration) {
35 return CreateAnimation(iterations, duration, 1); 35 return CreateAnimation(iterations, duration, 1);
36 } 36 }
37 37
38 scoped_ptr<Animation> CreateAnimation(double iterations) { 38 scoped_ptr<Animation> CreateAnimation(double iterations) {
39 return CreateAnimation(iterations, 1, 1); 39 return CreateAnimation(iterations, 1, 1);
40 } 40 }
41 41
42 TEST(AnimationTest, TrimTimeZeroIterations) { 42 TEST(AnimationTest, TrimTimeZeroIterations) {
43 scoped_ptr<Animation> anim(CreateAnimation(0)); 43 scoped_ptr<Animation> anim(CreateAnimation(0));
44 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))); 44 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))
45 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 45 .InSecondsF());
46 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 46 EXPECT_EQ(
47 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0)).InSecondsF());
48 EXPECT_EQ(
49 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0)).InSecondsF());
47 } 50 }
48 51
49 TEST(AnimationTest, TrimTimeOneIteration) { 52 TEST(AnimationTest, TrimTimeOneIteration) {
50 scoped_ptr<Animation> anim(CreateAnimation(1)); 53 scoped_ptr<Animation> anim(CreateAnimation(1));
51 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))); 54 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))
52 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 55 .InSecondsF());
53 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 56 EXPECT_EQ(
54 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))); 57 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0)).InSecondsF());
58 EXPECT_EQ(
59 1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0)).InSecondsF());
60 EXPECT_EQ(
61 1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0)).InSecondsF());
55 } 62 }
56 63
57 TEST(AnimationTest, TrimTimeOneHalfIteration) { 64 TEST(AnimationTest, TrimTimeOneHalfIteration) {
58 scoped_ptr<Animation> anim(CreateAnimation(1.5)); 65 scoped_ptr<Animation> anim(CreateAnimation(1.5));
59 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))); 66 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))
60 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 67 .InSecondsF());
61 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 68 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
62 EXPECT_EQ(0.9, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.9))); 69 .InSecondsF());
63 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 70 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
64 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))); 71 .InSecondsF());
65 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))); 72 EXPECT_EQ(0.9, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.9))
73 .InSecondsF());
74 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
75 .InSecondsF());
76 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))
77 .InSecondsF());
78 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))
79 .InSecondsF());
66 } 80 }
67 81
68 TEST(AnimationTest, TrimTimeInfiniteIterations) { 82 TEST(AnimationTest, TrimTimeInfiniteIterations) {
69 scoped_ptr<Animation> anim(CreateAnimation(-1)); 83 scoped_ptr<Animation> anim(CreateAnimation(-1));
70 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 84 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
71 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 85 .InSecondsF());
72 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 86 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
73 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))); 87 .InSecondsF());
88 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
89 .InSecondsF());
90 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))
91 .InSecondsF());
74 } 92 }
75 93
76 TEST(AnimationTest, TrimTimeReverse) { 94 TEST(AnimationTest, TrimTimeReverse) {
77 scoped_ptr<Animation> anim(CreateAnimation(-1)); 95 scoped_ptr<Animation> anim(CreateAnimation(-1));
78 anim->set_direction(Animation::Reverse); 96 anim->set_direction(Animation::Reverse);
79 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0))); 97 EXPECT_EQ(
80 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))); 98 1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0)).InSecondsF());
81 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 99 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))
82 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))); 100 .InSecondsF());
83 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 101 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
84 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.25))); 102 .InSecondsF());
103 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))
104 .InSecondsF());
105 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
106 .InSecondsF());
107 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.25))
108 .InSecondsF());
85 } 109 }
86 110
87 TEST(AnimationTest, TrimTimeAlternateInfiniteIterations) { 111 TEST(AnimationTest, TrimTimeAlternateInfiniteIterations) {
88 scoped_ptr<Animation> anim(CreateAnimation(-1)); 112 scoped_ptr<Animation> anim(CreateAnimation(-1));
89 anim->set_direction(Animation::Alternate); 113 anim->set_direction(Animation::Alternate);
90 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 114 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
91 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))); 115 .InSecondsF());
92 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 116 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))
93 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))); 117 .InSecondsF());
94 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 118 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
95 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.25))); 119 .InSecondsF());
120 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))
121 .InSecondsF());
122 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
123 .InSecondsF());
124 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.25))
125 .InSecondsF());
96 } 126 }
97 127
98 TEST(AnimationTest, TrimTimeAlternateOneIteration) { 128 TEST(AnimationTest, TrimTimeAlternateOneIteration) {
99 scoped_ptr<Animation> anim(CreateAnimation(1)); 129 scoped_ptr<Animation> anim(CreateAnimation(1));
100 anim->set_direction(Animation::Alternate); 130 anim->set_direction(Animation::Alternate);
101 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 131 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
102 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))); 132 .InSecondsF());
103 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 133 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))
104 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))); 134 .InSecondsF());
105 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 135 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
106 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.25))); 136 .InSecondsF());
137 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))
138 .InSecondsF());
139 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
140 .InSecondsF());
141 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.25))
142 .InSecondsF());
107 } 143 }
108 144
109 TEST(AnimationTest, TrimTimeAlternateTwoIterations) { 145 TEST(AnimationTest, TrimTimeAlternateTwoIterations) {
110 scoped_ptr<Animation> anim(CreateAnimation(2)); 146 scoped_ptr<Animation> anim(CreateAnimation(2));
111 anim->set_direction(Animation::Alternate); 147 anim->set_direction(Animation::Alternate);
112 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 148 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
113 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))); 149 .InSecondsF());
114 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 150 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))
115 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))); 151 .InSecondsF());
116 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 152 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
117 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.25))); 153 .InSecondsF());
118 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.75))); 154 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))
119 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))); 155 .InSecondsF());
120 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.25))); 156 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
157 .InSecondsF());
158 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.25))
159 .InSecondsF());
160 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.75))
161 .InSecondsF());
162 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))
163 .InSecondsF());
164 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.25))
165 .InSecondsF());
121 } 166 }
122 167
123 TEST(AnimationTest, TrimTimeAlternateTwoHalfIterations) { 168 TEST(AnimationTest, TrimTimeAlternateTwoHalfIterations) {
124 scoped_ptr<Animation> anim(CreateAnimation(2.5)); 169 scoped_ptr<Animation> anim(CreateAnimation(2.5));
125 anim->set_direction(Animation::Alternate); 170 anim->set_direction(Animation::Alternate);
126 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 171 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
127 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))); 172 .InSecondsF());
128 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 173 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))
129 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))); 174 .InSecondsF());
130 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 175 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
131 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.25))); 176 .InSecondsF());
132 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.75))); 177 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))
133 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))); 178 .InSecondsF());
134 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.25))); 179 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
135 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.50))); 180 .InSecondsF());
136 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.75))); 181 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.25))
182 .InSecondsF());
183 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.75))
184 .InSecondsF());
185 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))
186 .InSecondsF());
187 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.25))
188 .InSecondsF());
189 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.50))
190 .InSecondsF());
191 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.75))
192 .InSecondsF());
137 } 193 }
138 194
139 TEST(AnimationTest, TrimTimeAlternateReverseInfiniteIterations) { 195 TEST(AnimationTest, TrimTimeAlternateReverseInfiniteIterations) {
140 scoped_ptr<Animation> anim(CreateAnimation(-1)); 196 scoped_ptr<Animation> anim(CreateAnimation(-1));
141 anim->set_direction(Animation::AlternateReverse); 197 anim->set_direction(Animation::AlternateReverse);
142 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 198 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
143 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))); 199 .InSecondsF());
144 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 200 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))
145 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))); 201 .InSecondsF());
146 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 202 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
147 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.25))); 203 .InSecondsF());
204 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))
205 .InSecondsF());
206 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
207 .InSecondsF());
208 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.25))
209 .InSecondsF());
148 } 210 }
149 211
150 TEST(AnimationTest, TrimTimeAlternateReverseOneIteration) { 212 TEST(AnimationTest, TrimTimeAlternateReverseOneIteration) {
151 scoped_ptr<Animation> anim(CreateAnimation(1)); 213 scoped_ptr<Animation> anim(CreateAnimation(1));
152 anim->set_direction(Animation::AlternateReverse); 214 anim->set_direction(Animation::AlternateReverse);
153 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 215 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
154 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))); 216 .InSecondsF());
155 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 217 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))
156 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))); 218 .InSecondsF());
157 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 219 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
158 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.25))); 220 .InSecondsF());
221 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))
222 .InSecondsF());
223 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
224 .InSecondsF());
225 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.25))
226 .InSecondsF());
159 } 227 }
160 228
161 TEST(AnimationTest, TrimTimeAlternateReverseTwoIterations) { 229 TEST(AnimationTest, TrimTimeAlternateReverseTwoIterations) {
162 scoped_ptr<Animation> anim(CreateAnimation(2)); 230 scoped_ptr<Animation> anim(CreateAnimation(2));
163 anim->set_direction(Animation::AlternateReverse); 231 anim->set_direction(Animation::AlternateReverse);
164 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 232 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
165 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))); 233 .InSecondsF());
166 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 234 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))
167 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))); 235 .InSecondsF());
168 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 236 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
169 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.25))); 237 .InSecondsF());
170 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.75))); 238 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))
171 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))); 239 .InSecondsF());
172 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.25))); 240 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
241 .InSecondsF());
242 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.25))
243 .InSecondsF());
244 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.75))
245 .InSecondsF());
246 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))
247 .InSecondsF());
248 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.25))
249 .InSecondsF());
173 } 250 }
174 251
175 TEST(AnimationTest, TrimTimeStartTime) { 252 TEST(AnimationTest, TrimTimeStartTime) {
176 scoped_ptr<Animation> anim(CreateAnimation(1)); 253 scoped_ptr<Animation> anim(CreateAnimation(1));
177 anim->set_start_time(TicksFromSecondsF(4)); 254 anim->set_start_time(TicksFromSecondsF(4));
178 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 255 EXPECT_EQ(
179 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(4.0))); 256 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0)).InSecondsF());
180 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(4.5))); 257 EXPECT_EQ(
181 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(5.0))); 258 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(4.0)).InSecondsF());
182 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(6.0))); 259 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(4.5))
260 .InSecondsF());
261 EXPECT_EQ(
262 1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(5.0)).InSecondsF());
263 EXPECT_EQ(
264 1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(6.0)).InSecondsF());
183 } 265 }
184 266
185 TEST(AnimationTest, TrimTimeStartTimeReverse) { 267 TEST(AnimationTest, TrimTimeStartTimeReverse) {
186 scoped_ptr<Animation> anim(CreateAnimation(1)); 268 scoped_ptr<Animation> anim(CreateAnimation(1));
187 anim->set_start_time(TicksFromSecondsF(4)); 269 anim->set_start_time(TicksFromSecondsF(4));
188 anim->set_direction(Animation::Reverse); 270 anim->set_direction(Animation::Reverse);
189 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 271 EXPECT_EQ(
190 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(4.0))); 272 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0)).InSecondsF());
191 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(4.5))); 273 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(4.0))
192 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(5.0))); 274 .InSecondsF());
193 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(6.0))); 275 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(4.5))
276 .InSecondsF());
277 EXPECT_EQ(
278 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(5.0)).InSecondsF());
279 EXPECT_EQ(
280 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(6.0)).InSecondsF());
194 } 281 }
195 282
196 TEST(AnimationTest, TrimTimeTimeOffset) { 283 TEST(AnimationTest, TrimTimeTimeOffset) {
197 scoped_ptr<Animation> anim(CreateAnimation(1)); 284 scoped_ptr<Animation> anim(CreateAnimation(1));
198 anim->set_time_offset(TimeDelta::FromMilliseconds(4000)); 285 anim->set_time_offset(TimeDelta::FromMilliseconds(4000));
199 anim->set_start_time(TicksFromSecondsF(4)); 286 anim->set_start_time(TicksFromSecondsF(4));
200 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 287 EXPECT_EQ(
201 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 288 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0)).InSecondsF());
202 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 289 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
203 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 290 .InSecondsF());
291 EXPECT_EQ(
292 1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0)).InSecondsF());
293 EXPECT_EQ(
294 1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0)).InSecondsF());
204 } 295 }
205 296
206 TEST(AnimationTest, TrimTimeTimeOffsetReverse) { 297 TEST(AnimationTest, TrimTimeTimeOffsetReverse) {
207 scoped_ptr<Animation> anim(CreateAnimation(1)); 298 scoped_ptr<Animation> anim(CreateAnimation(1));
208 anim->set_time_offset(TimeDelta::FromMilliseconds(4000)); 299 anim->set_time_offset(TimeDelta::FromMilliseconds(4000));
209 anim->set_start_time(TicksFromSecondsF(4)); 300 anim->set_start_time(TicksFromSecondsF(4));
210 anim->set_direction(Animation::Reverse); 301 anim->set_direction(Animation::Reverse);
211 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 302 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
212 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 303 .InSecondsF());
213 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 304 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
214 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 305 .InSecondsF());
306 EXPECT_EQ(
307 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0)).InSecondsF());
308 EXPECT_EQ(
309 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0)).InSecondsF());
215 } 310 }
216 311
217 TEST(AnimationTest, TrimTimeNegativeTimeOffset) { 312 TEST(AnimationTest, TrimTimeNegativeTimeOffset) {
218 scoped_ptr<Animation> anim(CreateAnimation(1)); 313 scoped_ptr<Animation> anim(CreateAnimation(1));
219 anim->set_time_offset(TimeDelta::FromMilliseconds(-4000)); 314 anim->set_time_offset(TimeDelta::FromMilliseconds(-4000));
220 315
221 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 316 EXPECT_EQ(
222 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(4.0))); 317 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0)).InSecondsF());
223 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(4.5))); 318 EXPECT_EQ(
224 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(5.0))); 319 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(4.0)).InSecondsF());
320 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(4.5))
321 .InSecondsF());
322 EXPECT_EQ(
323 1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(5.0)).InSecondsF());
225 } 324 }
226 325
227 TEST(AnimationTest, TrimTimeNegativeTimeOffsetReverse) { 326 TEST(AnimationTest, TrimTimeNegativeTimeOffsetReverse) {
228 scoped_ptr<Animation> anim(CreateAnimation(1)); 327 scoped_ptr<Animation> anim(CreateAnimation(1));
229 anim->set_time_offset(TimeDelta::FromMilliseconds(-4000)); 328 anim->set_time_offset(TimeDelta::FromMilliseconds(-4000));
230 anim->set_direction(Animation::Reverse); 329 anim->set_direction(Animation::Reverse);
231 330
232 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 331 EXPECT_EQ(
233 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(4.0))); 332 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0)).InSecondsF());
234 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(4.5))); 333 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(4.0))
235 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(5.0))); 334 .InSecondsF());
335 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(4.5))
336 .InSecondsF());
337 EXPECT_EQ(
338 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(5.0)).InSecondsF());
236 } 339 }
237 340
238 TEST(AnimationTest, TrimTimePauseResume) { 341 TEST(AnimationTest, TrimTimePauseResume) {
239 scoped_ptr<Animation> anim(CreateAnimation(1)); 342 scoped_ptr<Animation> anim(CreateAnimation(1));
240 anim->SetRunState(Animation::Running, TicksFromSecondsF(0.0)); 343 anim->SetRunState(Animation::Running, TicksFromSecondsF(0.0));
241 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 344 EXPECT_EQ(
242 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 345 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0)).InSecondsF());
346 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
347 .InSecondsF());
243 anim->SetRunState(Animation::Paused, TicksFromSecondsF(0.5)); 348 anim->SetRunState(Animation::Paused, TicksFromSecondsF(0.5));
244 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1024.0))); 349 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1024.0))
350 .InSecondsF());
245 anim->SetRunState(Animation::Running, TicksFromSecondsF(1024.0)); 351 anim->SetRunState(Animation::Running, TicksFromSecondsF(1024.0));
246 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1024.0))); 352 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1024.0))
247 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1024.5))); 353 .InSecondsF());
354 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1024.5))
355 .InSecondsF());
248 } 356 }
249 357
250 TEST(AnimationTest, TrimTimePauseResumeReverse) { 358 TEST(AnimationTest, TrimTimePauseResumeReverse) {
251 scoped_ptr<Animation> anim(CreateAnimation(1)); 359 scoped_ptr<Animation> anim(CreateAnimation(1));
252 anim->set_direction(Animation::Reverse); 360 anim->set_direction(Animation::Reverse);
253 anim->SetRunState(Animation::Running, TicksFromSecondsF(0.0)); 361 anim->SetRunState(Animation::Running, TicksFromSecondsF(0.0));
254 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 362 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
255 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 363 .InSecondsF());
364 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
365 .InSecondsF());
256 anim->SetRunState(Animation::Paused, TicksFromSecondsF(0.25)); 366 anim->SetRunState(Animation::Paused, TicksFromSecondsF(0.25));
257 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1024.0))); 367 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1024.0))
368 .InSecondsF());
258 anim->SetRunState(Animation::Running, TicksFromSecondsF(1024.0)); 369 anim->SetRunState(Animation::Running, TicksFromSecondsF(1024.0));
259 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1024.0))); 370 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1024.0))
260 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1024.75))); 371 .InSecondsF());
372 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1024.75))
373 .InSecondsF());
261 } 374 }
262 375
263 TEST(AnimationTest, TrimTimeSuspendResume) { 376 TEST(AnimationTest, TrimTimeSuspendResume) {
264 scoped_ptr<Animation> anim(CreateAnimation(1)); 377 scoped_ptr<Animation> anim(CreateAnimation(1));
265 anim->SetRunState(Animation::Running, TicksFromSecondsF(0.0)); 378 anim->SetRunState(Animation::Running, TicksFromSecondsF(0.0));
266 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 379 EXPECT_EQ(
267 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 380 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0)).InSecondsF());
381 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
382 .InSecondsF());
268 anim->Suspend(TicksFromSecondsF(0.5)); 383 anim->Suspend(TicksFromSecondsF(0.5));
269 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1024.0))); 384 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1024.0))
385 .InSecondsF());
270 anim->Resume(TicksFromSecondsF(1024)); 386 anim->Resume(TicksFromSecondsF(1024));
271 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1024.0))); 387 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1024.0))
272 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1024.5))); 388 .InSecondsF());
389 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1024.5))
390 .InSecondsF());
273 } 391 }
274 392
275 TEST(AnimationTest, TrimTimeSuspendResumeReverse) { 393 TEST(AnimationTest, TrimTimeSuspendResumeReverse) {
276 scoped_ptr<Animation> anim(CreateAnimation(1)); 394 scoped_ptr<Animation> anim(CreateAnimation(1));
277 anim->set_direction(Animation::Reverse); 395 anim->set_direction(Animation::Reverse);
278 anim->SetRunState(Animation::Running, TicksFromSecondsF(0.0)); 396 anim->SetRunState(Animation::Running, TicksFromSecondsF(0.0));
279 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 397 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
280 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))); 398 .InSecondsF());
399 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))
400 .InSecondsF());
281 anim->Suspend(TicksFromSecondsF(0.75)); 401 anim->Suspend(TicksFromSecondsF(0.75));
282 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1024.0))); 402 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1024.0))
403 .InSecondsF());
283 anim->Resume(TicksFromSecondsF(1024)); 404 anim->Resume(TicksFromSecondsF(1024));
284 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1024.0))); 405 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1024.0))
285 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1024.25))); 406 .InSecondsF());
407 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1024.25))
408 .InSecondsF());
286 } 409 }
287 410
288 TEST(AnimationTest, TrimTimeZeroDuration) { 411 TEST(AnimationTest, TrimTimeZeroDuration) {
289 scoped_ptr<Animation> anim(CreateAnimation(0, 0)); 412 scoped_ptr<Animation> anim(CreateAnimation(0, 0));
290 anim->SetRunState(Animation::Running, TicksFromSecondsF(0.0)); 413 anim->SetRunState(Animation::Running, TicksFromSecondsF(0.0));
291 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))); 414 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))
292 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 415 .InSecondsF());
293 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 416 EXPECT_EQ(
417 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0)).InSecondsF());
418 EXPECT_EQ(
419 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0)).InSecondsF());
294 } 420 }
295 421
296 TEST(AnimationTest, TrimTimeStarting) { 422 TEST(AnimationTest, TrimTimeStarting) {
297 scoped_ptr<Animation> anim(CreateAnimation(1, 5.0)); 423 scoped_ptr<Animation> anim(CreateAnimation(1, 5.0));
298 anim->SetRunState(Animation::Starting, TicksFromSecondsF(0.0)); 424 anim->SetRunState(Animation::Starting, TicksFromSecondsF(0.0));
299 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))); 425 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))
300 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 426 .InSecondsF());
301 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 427 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
428 .InSecondsF());
429 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
430 .InSecondsF());
302 anim->set_time_offset(TimeDelta::FromMilliseconds(2000)); 431 anim->set_time_offset(TimeDelta::FromMilliseconds(2000));
303 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))); 432 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))
304 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 433 .InSecondsF());
305 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 434 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
435 .InSecondsF());
436 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
437 .InSecondsF());
306 anim->set_start_time(TicksFromSecondsF(1.0)); 438 anim->set_start_time(TicksFromSecondsF(1.0));
307 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))); 439 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))
308 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 440 .InSecondsF());
309 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 441 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
310 EXPECT_EQ(3.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))); 442 .InSecondsF());
443 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
444 .InSecondsF());
445 EXPECT_EQ(3.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))
446 .InSecondsF());
311 } 447 }
312 448
313 TEST(AnimationTest, TrimTimeNeedsSynchronizedStartTime) { 449 TEST(AnimationTest, TrimTimeNeedsSynchronizedStartTime) {
314 scoped_ptr<Animation> anim(CreateAnimation(1, 5.0)); 450 scoped_ptr<Animation> anim(CreateAnimation(1, 5.0));
315 anim->SetRunState(Animation::Running, TicksFromSecondsF(0.0)); 451 anim->SetRunState(Animation::Running, TicksFromSecondsF(0.0));
316 anim->set_needs_synchronized_start_time(true); 452 anim->set_needs_synchronized_start_time(true);
317 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))); 453 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))
318 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 454 .InSecondsF());
319 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 455 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
456 .InSecondsF());
457 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
458 .InSecondsF());
320 anim->set_time_offset(TimeDelta::FromMilliseconds(2000)); 459 anim->set_time_offset(TimeDelta::FromMilliseconds(2000));
321 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))); 460 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))
322 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 461 .InSecondsF());
323 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 462 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
463 .InSecondsF());
464 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
465 .InSecondsF());
324 anim->set_start_time(TicksFromSecondsF(1.0)); 466 anim->set_start_time(TicksFromSecondsF(1.0));
325 anim->set_needs_synchronized_start_time(false); 467 anim->set_needs_synchronized_start_time(false);
326 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 468 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
327 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 469 .InSecondsF());
328 EXPECT_EQ(3.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))); 470 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
471 .InSecondsF());
472 EXPECT_EQ(3.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))
473 .InSecondsF());
329 } 474 }
330 475
331 TEST(AnimationTest, IsFinishedAtZeroIterations) { 476 TEST(AnimationTest, IsFinishedAtZeroIterations) {
332 scoped_ptr<Animation> anim(CreateAnimation(0)); 477 scoped_ptr<Animation> anim(CreateAnimation(0));
333 anim->SetRunState(Animation::Running, TicksFromSecondsF(0.0)); 478 anim->SetRunState(Animation::Running, TicksFromSecondsF(0.0));
334 EXPECT_FALSE(anim->IsFinishedAt(TicksFromSecondsF(-1.0))); 479 EXPECT_FALSE(anim->IsFinishedAt(TicksFromSecondsF(-1.0)));
335 EXPECT_TRUE(anim->IsFinishedAt(TicksFromSecondsF(0.0))); 480 EXPECT_TRUE(anim->IsFinishedAt(TicksFromSecondsF(0.0)));
336 EXPECT_TRUE(anim->IsFinishedAt(TicksFromSecondsF(1.0))); 481 EXPECT_TRUE(anim->IsFinishedAt(TicksFromSecondsF(1.0)));
337 } 482 }
338 483
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 EXPECT_EQ(Animation::Paused, anim->run_state()); 575 EXPECT_EQ(Animation::Paused, anim->run_state());
431 anim->SetRunState(Animation::Running, TicksFromSecondsF(0.0)); 576 anim->SetRunState(Animation::Running, TicksFromSecondsF(0.0));
432 EXPECT_EQ(Animation::Paused, anim->run_state()); 577 EXPECT_EQ(Animation::Paused, anim->run_state());
433 anim->Resume(TicksFromSecondsF(0)); 578 anim->Resume(TicksFromSecondsF(0));
434 anim->SetRunState(Animation::Running, TicksFromSecondsF(0.0)); 579 anim->SetRunState(Animation::Running, TicksFromSecondsF(0.0));
435 EXPECT_EQ(Animation::Running, anim->run_state()); 580 EXPECT_EQ(Animation::Running, anim->run_state());
436 } 581 }
437 582
438 TEST(AnimationTest, TrimTimePlaybackNormal) { 583 TEST(AnimationTest, TrimTimePlaybackNormal) {
439 scoped_ptr<Animation> anim(CreateAnimation(1, 1, 1)); 584 scoped_ptr<Animation> anim(CreateAnimation(1, 1, 1));
440 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))); 585 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))
441 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 586 .InSecondsF());
442 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 587 EXPECT_EQ(
443 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 588 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0)).InSecondsF());
444 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))); 589 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
590 .InSecondsF());
591 EXPECT_EQ(
592 1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0)).InSecondsF());
593 EXPECT_EQ(
594 1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0)).InSecondsF());
445 } 595 }
446 596
447 TEST(AnimationTest, TrimTimePlaybackSlow) { 597 TEST(AnimationTest, TrimTimePlaybackSlow) {
448 scoped_ptr<Animation> anim(CreateAnimation(1, 1, 0.5)); 598 scoped_ptr<Animation> anim(CreateAnimation(1, 1, 0.5));
449 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))); 599 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))
450 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 600 .InSecondsF());
451 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 601 EXPECT_EQ(
452 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 602 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0)).InSecondsF());
453 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))); 603 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
454 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3.0))); 604 .InSecondsF());
605 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
606 .InSecondsF());
607 EXPECT_EQ(
608 1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0)).InSecondsF());
609 EXPECT_EQ(
610 1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3.0)).InSecondsF());
455 } 611 }
456 612
457 TEST(AnimationTest, TrimTimePlaybackFast) { 613 TEST(AnimationTest, TrimTimePlaybackFast) {
458 scoped_ptr<Animation> anim(CreateAnimation(1, 4, 2)); 614 scoped_ptr<Animation> anim(CreateAnimation(1, 4, 2));
459 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))); 615 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))
460 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 616 .InSecondsF());
461 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 617 EXPECT_EQ(
462 EXPECT_EQ(2, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 618 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0)).InSecondsF());
463 EXPECT_EQ(3, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))); 619 EXPECT_EQ(
464 EXPECT_EQ(4, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))); 620 1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5)).InSecondsF());
465 EXPECT_EQ(4, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.5))); 621 EXPECT_EQ(
622 2, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0)).InSecondsF());
623 EXPECT_EQ(
624 3, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5)).InSecondsF());
625 EXPECT_EQ(
626 4, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0)).InSecondsF());
627 EXPECT_EQ(
628 4, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.5)).InSecondsF());
466 } 629 }
467 630
468 TEST(AnimationTest, TrimTimePlaybackNormalReverse) { 631 TEST(AnimationTest, TrimTimePlaybackNormalReverse) {
469 scoped_ptr<Animation> anim(CreateAnimation(1, 2, -1)); 632 scoped_ptr<Animation> anim(CreateAnimation(1, 2, -1));
470 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))); 633 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))
471 EXPECT_EQ(2, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0))); 634 .InSecondsF());
472 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 635 EXPECT_EQ(
473 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 636 2, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0)).InSecondsF());
474 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))); 637 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
475 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))); 638 .InSecondsF());
476 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.5))); 639 EXPECT_EQ(
640 1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0)).InSecondsF());
641 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))
642 .InSecondsF());
643 EXPECT_EQ(
644 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0)).InSecondsF());
645 EXPECT_EQ(
646 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.5)).InSecondsF());
477 } 647 }
478 648
479 TEST(AnimationTest, TrimTimePlaybackSlowReverse) { 649 TEST(AnimationTest, TrimTimePlaybackSlowReverse) {
480 scoped_ptr<Animation> anim(CreateAnimation(1, 2, -0.5)); 650 scoped_ptr<Animation> anim(CreateAnimation(1, 2, -0.5));
481 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))); 651 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))
482 EXPECT_EQ(2, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0))); 652 .InSecondsF());
483 EXPECT_EQ(1.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 653 EXPECT_EQ(
484 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 654 2, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0)).InSecondsF());
485 EXPECT_EQ(1.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))); 655 EXPECT_EQ(1.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
486 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))); 656 .InSecondsF());
487 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.5))); 657 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
488 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3))); 658 .InSecondsF());
489 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3.5))); 659 EXPECT_EQ(1.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))
490 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(4))); 660 .InSecondsF());
491 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(4.5))); 661 EXPECT_EQ(
662 1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0)).InSecondsF());
663 EXPECT_EQ(0.75, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.5))
664 .InSecondsF());
665 EXPECT_EQ(
666 0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3)).InSecondsF());
667 EXPECT_EQ(0.25, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3.5))
668 .InSecondsF());
669 EXPECT_EQ(
670 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(4)).InSecondsF());
671 EXPECT_EQ(
672 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(4.5)).InSecondsF());
492 } 673 }
493 674
494 TEST(AnimationTest, TrimTimePlaybackFastReverse) { 675 TEST(AnimationTest, TrimTimePlaybackFastReverse) {
495 scoped_ptr<Animation> anim(CreateAnimation(1, 2, -2)); 676 scoped_ptr<Animation> anim(CreateAnimation(1, 2, -2));
496 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))); 677 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))
497 EXPECT_EQ(2, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0))); 678 .InSecondsF());
498 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))); 679 EXPECT_EQ(
499 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 680 2, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0)).InSecondsF());
500 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))); 681 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))
501 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 682 .InSecondsF());
502 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))); 683 EXPECT_EQ(
684 1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5)).InSecondsF());
685 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))
686 .InSecondsF());
687 EXPECT_EQ(
688 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0)).InSecondsF());
689 EXPECT_EQ(
690 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5)).InSecondsF());
503 } 691 }
504 692
505 TEST(AnimationTest, TrimTimePlaybackFastInfiniteIterations) { 693 TEST(AnimationTest, TrimTimePlaybackFastInfiniteIterations) {
506 scoped_ptr<Animation> anim(CreateAnimation(-1, 4, 4)); 694 scoped_ptr<Animation> anim(CreateAnimation(-1, 4, 4));
507 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 695 EXPECT_EQ(
508 EXPECT_EQ(2, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 696 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0)).InSecondsF());
509 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 697 EXPECT_EQ(
510 EXPECT_EQ(2, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))); 698 2, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5)).InSecondsF());
511 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1000.0))); 699 EXPECT_EQ(
512 EXPECT_EQ(2, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1000.5))); 700 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0)).InSecondsF());
701 EXPECT_EQ(
702 2, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5)).InSecondsF());
703 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1000.0))
704 .InSecondsF());
705 EXPECT_EQ(2, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1000.5))
706 .InSecondsF());
513 } 707 }
514 708
515 TEST(AnimationTest, TrimTimePlaybackNormalDoubleReverse) { 709 TEST(AnimationTest, TrimTimePlaybackNormalDoubleReverse) {
516 scoped_ptr<Animation> anim(CreateAnimation(1, 1, -1)); 710 scoped_ptr<Animation> anim(CreateAnimation(1, 1, -1));
517 anim->set_direction(Animation::Reverse); 711 anim->set_direction(Animation::Reverse);
518 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))); 712 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))
519 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 713 .InSecondsF());
520 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 714 EXPECT_EQ(
521 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 715 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0)).InSecondsF());
522 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))); 716 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
717 .InSecondsF());
718 EXPECT_EQ(
719 1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0)).InSecondsF());
720 EXPECT_EQ(
721 1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0)).InSecondsF());
523 } 722 }
524 723
525 TEST(AnimationTest, TrimTimePlaybackFastDoubleReverse) { 724 TEST(AnimationTest, TrimTimePlaybackFastDoubleReverse) {
526 scoped_ptr<Animation> anim(CreateAnimation(1, 4, -2)); 725 scoped_ptr<Animation> anim(CreateAnimation(1, 4, -2));
527 anim->set_direction(Animation::Reverse); 726 anim->set_direction(Animation::Reverse);
528 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))); 727 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))
529 EXPECT_EQ(0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 728 .InSecondsF());
530 EXPECT_EQ(1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 729 EXPECT_EQ(
531 EXPECT_EQ(2, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 730 0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0)).InSecondsF());
532 EXPECT_EQ(3, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))); 731 EXPECT_EQ(
533 EXPECT_EQ(4, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))); 732 1, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5)).InSecondsF());
534 EXPECT_EQ(4, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.5))); 733 EXPECT_EQ(
734 2, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0)).InSecondsF());
735 EXPECT_EQ(
736 3, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5)).InSecondsF());
737 EXPECT_EQ(
738 4, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0)).InSecondsF());
739 EXPECT_EQ(
740 4, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.5)).InSecondsF());
535 } 741 }
536 742
537 TEST(AnimationTest, TrimTimeAlternateTwoIterationsPlaybackFast) { 743 TEST(AnimationTest, TrimTimeAlternateTwoIterationsPlaybackFast) {
538 scoped_ptr<Animation> anim(CreateAnimation(2, 2, 2)); 744 scoped_ptr<Animation> anim(CreateAnimation(2, 2, 2));
539 anim->set_direction(Animation::Alternate); 745 anim->set_direction(Animation::Alternate);
540 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 746 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
541 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))); 747 .InSecondsF());
542 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 748 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))
543 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))); 749 .InSecondsF());
544 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 750 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
545 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.25))); 751 .InSecondsF());
546 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))); 752 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))
547 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.75))); 753 .InSecondsF());
548 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))); 754 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
549 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.25))); 755 .InSecondsF());
756 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.25))
757 .InSecondsF());
758 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))
759 .InSecondsF());
760 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.75))
761 .InSecondsF());
762 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))
763 .InSecondsF());
764 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.25))
765 .InSecondsF());
550 } 766 }
551 767
552 TEST(AnimationTest, TrimTimeAlternateTwoIterationsPlaybackFastReverse) { 768 TEST(AnimationTest, TrimTimeAlternateTwoIterationsPlaybackFastReverse) {
553 scoped_ptr<Animation> anim(CreateAnimation(2, 2, 2)); 769 scoped_ptr<Animation> anim(CreateAnimation(2, 2, 2));
554 anim->set_direction(Animation::AlternateReverse); 770 anim->set_direction(Animation::AlternateReverse);
555 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))); 771 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))
556 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 772 .InSecondsF());
557 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))); 773 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
558 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 774 .InSecondsF());
559 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))); 775 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))
560 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 776 .InSecondsF());
561 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.25))); 777 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
562 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))); 778 .InSecondsF());
563 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.75))); 779 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))
564 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))); 780 .InSecondsF());
565 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.25))); 781 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
782 .InSecondsF());
783 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.25))
784 .InSecondsF());
785 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))
786 .InSecondsF());
787 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.75))
788 .InSecondsF());
789 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))
790 .InSecondsF());
791 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.25))
792 .InSecondsF());
566 } 793 }
567 794
568 TEST(AnimationTest, TrimTimeAlternateTwoIterationsPlaybackFastDoubleReverse) { 795 TEST(AnimationTest, TrimTimeAlternateTwoIterationsPlaybackFastDoubleReverse) {
569 scoped_ptr<Animation> anim(CreateAnimation(2, 2, -2)); 796 scoped_ptr<Animation> anim(CreateAnimation(2, 2, -2));
570 anim->set_direction(Animation::AlternateReverse); 797 anim->set_direction(Animation::AlternateReverse);
571 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 798 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
572 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))); 799 .InSecondsF());
573 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 800 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))
574 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))); 801 .InSecondsF());
575 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 802 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
576 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.25))); 803 .InSecondsF());
577 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))); 804 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))
578 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.75))); 805 .InSecondsF());
579 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))); 806 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
580 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.25))); 807 .InSecondsF());
808 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.25))
809 .InSecondsF());
810 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))
811 .InSecondsF());
812 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.75))
813 .InSecondsF());
814 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))
815 .InSecondsF());
816 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.25))
817 .InSecondsF());
581 } 818 }
582 819
583 TEST(AnimationTest, 820 TEST(AnimationTest,
584 TrimTimeAlternateReverseThreeIterationsPlaybackFastAlternateReverse) { 821 TrimTimeAlternateReverseThreeIterationsPlaybackFastAlternateReverse) {
585 scoped_ptr<Animation> anim(CreateAnimation(3, 2, -2)); 822 scoped_ptr<Animation> anim(CreateAnimation(3, 2, -2));
586 anim->set_direction(Animation::AlternateReverse); 823 anim->set_direction(Animation::AlternateReverse);
587 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 824 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
588 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))); 825 .InSecondsF());
589 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 826 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.25))
590 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))); 827 .InSecondsF());
591 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 828 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
592 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.25))); 829 .InSecondsF());
593 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))); 830 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.75))
594 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.75))); 831 .InSecondsF());
595 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))); 832 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
596 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.25))); 833 .InSecondsF());
597 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.5))); 834 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.25))
598 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.75))); 835 .InSecondsF());
599 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3.0))); 836 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))
600 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3.25))); 837 .InSecondsF());
838 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.75))
839 .InSecondsF());
840 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))
841 .InSecondsF());
842 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.25))
843 .InSecondsF());
844 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.5))
845 .InSecondsF());
846 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.75))
847 .InSecondsF());
848 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3.0))
849 .InSecondsF());
850 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3.25))
851 .InSecondsF());
601 } 852 }
602 853
603 TEST(AnimationTest, 854 TEST(AnimationTest,
604 TrimTimeAlternateReverseTwoIterationsPlaybackNormalAlternate) { 855 TrimTimeAlternateReverseTwoIterationsPlaybackNormalAlternate) {
605 scoped_ptr<Animation> anim(CreateAnimation(2, 2, -1)); 856 scoped_ptr<Animation> anim(CreateAnimation(2, 2, -1));
606 anim->set_direction(Animation::Alternate); 857 anim->set_direction(Animation::Alternate);
607 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 858 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
608 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 859 .InSecondsF());
609 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 860 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
610 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))); 861 .InSecondsF());
611 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))); 862 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
612 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.5))); 863 .InSecondsF());
613 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3.0))); 864 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))
614 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3.5))); 865 .InSecondsF());
615 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(4.0))); 866 EXPECT_EQ(2.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))
616 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(4.5))); 867 .InSecondsF());
868 EXPECT_EQ(1.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.5))
869 .InSecondsF());
870 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3.0))
871 .InSecondsF());
872 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3.5))
873 .InSecondsF());
874 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(4.0))
875 .InSecondsF());
876 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(4.5))
877 .InSecondsF());
617 } 878 }
618 879
619 TEST(AnimationTest, TrimTimeIterationStart) { 880 TEST(AnimationTest, TrimTimeIterationStart) {
620 scoped_ptr<Animation> anim(CreateAnimation(2, 1, 1)); 881 scoped_ptr<Animation> anim(CreateAnimation(2, 1, 1));
621 anim->set_iteration_start(0.5); 882 anim->set_iteration_start(0.5);
622 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))); 883 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))
623 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 884 .InSecondsF());
624 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 885 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
625 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 886 .InSecondsF());
626 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))); 887 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
627 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))); 888 .InSecondsF());
628 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.5))); 889 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
890 .InSecondsF());
891 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))
892 .InSecondsF());
893 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))
894 .InSecondsF());
895 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.5))
896 .InSecondsF());
629 } 897 }
630 898
631 TEST(AnimationTest, TrimTimeIterationStartAlternate) { 899 TEST(AnimationTest, TrimTimeIterationStartAlternate) {
632 scoped_ptr<Animation> anim(CreateAnimation(2, 1, 1)); 900 scoped_ptr<Animation> anim(CreateAnimation(2, 1, 1));
633 anim->set_direction(Animation::Alternate); 901 anim->set_direction(Animation::Alternate);
634 anim->set_iteration_start(0.3); 902 anim->set_iteration_start(0.3);
635 EXPECT_EQ(0.3, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))); 903 EXPECT_EQ(0.3, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))
636 EXPECT_EQ(0.3, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 904 .InSecondsF());
637 EXPECT_EQ(0.8, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 905 EXPECT_EQ(0.3, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
638 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.7))); 906 .InSecondsF());
639 EXPECT_EQ(0.7, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 907 EXPECT_EQ(0.8, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
640 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.2))); 908 .InSecondsF());
641 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.7))); 909 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.7))
910 .InSecondsF());
911 EXPECT_EQ(0.7, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
912 .InSecondsF());
913 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.2))
914 .InSecondsF());
915 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.7))
916 .InSecondsF());
642 } 917 }
643 918
644 TEST(AnimationTest, TrimTimeIterationStartAlternateThreeIterations) { 919 TEST(AnimationTest, TrimTimeIterationStartAlternateThreeIterations) {
645 scoped_ptr<Animation> anim(CreateAnimation(3, 1, 1)); 920 scoped_ptr<Animation> anim(CreateAnimation(3, 1, 1));
646 anim->set_direction(Animation::Alternate); 921 anim->set_direction(Animation::Alternate);
647 anim->set_iteration_start(1); 922 anim->set_iteration_start(1);
648 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))); 923 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(-1.0))
649 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 924 .InSecondsF());
650 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))); 925 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
651 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 926 .InSecondsF());
652 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))); 927 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.5))
653 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))); 928 .InSecondsF());
654 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.5))); 929 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
655 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3.0))); 930 .InSecondsF());
656 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3.5))); 931 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.5))
932 .InSecondsF());
933 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))
934 .InSecondsF());
935 EXPECT_EQ(0.5, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.5))
936 .InSecondsF());
937 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3.0))
938 .InSecondsF());
939 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3.5))
940 .InSecondsF());
657 } 941 }
658 942
659 TEST(AnimationTest, 943 TEST(AnimationTest,
660 TrimTimeIterationStartAlternateThreeIterationsPlaybackReverse) { 944 TrimTimeIterationStartAlternateThreeIterationsPlaybackReverse) {
661 scoped_ptr<Animation> anim(CreateAnimation(3, 1, -1)); 945 scoped_ptr<Animation> anim(CreateAnimation(3, 1, -1));
662 anim->set_direction(Animation::Alternate); 946 anim->set_direction(Animation::Alternate);
663 anim->set_iteration_start(1); 947 anim->set_iteration_start(1);
664 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))); 948 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(0.0))
665 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))); 949 .InSecondsF());
666 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))); 950 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(1.0))
667 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3.0))); 951 .InSecondsF());
668 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3.5))); 952 EXPECT_EQ(0.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(2.0))
953 .InSecondsF());
954 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3.0))
955 .InSecondsF());
956 EXPECT_EQ(1.0, anim->TrimTimeToCurrentIteration(TicksFromSecondsF(3.5))
957 .InSecondsF());
669 } 958 }
670 959
671 TEST(AnimationTest, InEffectFillMode) { 960 TEST(AnimationTest, InEffectFillMode) {
672 scoped_ptr<Animation> anim(CreateAnimation(1)); 961 scoped_ptr<Animation> anim(CreateAnimation(1));
673 anim->set_fill_mode(Animation::FillModeNone); 962 anim->set_fill_mode(Animation::FillModeNone);
674 EXPECT_FALSE(anim->InEffect(TicksFromSecondsF(-1.0))); 963 EXPECT_FALSE(anim->InEffect(TicksFromSecondsF(-1.0)));
675 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(0.0))); 964 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(0.0)));
676 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(1.0))); 965 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(1.0)));
677 966
678 anim->set_fill_mode(Animation::FillModeForwards); 967 anim->set_fill_mode(Animation::FillModeForwards);
(...skipping 30 matching lines...) Expand all
709 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(1.0))); 998 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(1.0)));
710 999
711 anim->set_fill_mode(Animation::FillModeBoth); 1000 anim->set_fill_mode(Animation::FillModeBoth);
712 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(-1.0))); 1001 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(-1.0)));
713 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(0.0))); 1002 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(0.0)));
714 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(1.0))); 1003 EXPECT_TRUE(anim->InEffect(TicksFromSecondsF(1.0)));
715 } 1004 }
716 1005
717 } // namespace 1006 } // namespace
718 } // namespace cc 1007 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/animation_curve.h ('k') | cc/animation/keyframed_animation_curve.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698