OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 TEST(CCActiveAnimationTest, TrimTimeInfiniteIterations) | 63 TEST(CCActiveAnimationTest, TrimTimeInfiniteIterations) |
64 { | 64 { |
65 OwnPtr<CCActiveAnimation> anim(createActiveAnimation(-1)); | 65 OwnPtr<CCActiveAnimation> anim(createActiveAnimation(-1)); |
66 EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); | 66 EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); |
67 EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5)); | 67 EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5)); |
68 EXPECT_EQ(0, anim->trimTimeToCurrentIteration(1)); | 68 EXPECT_EQ(0, anim->trimTimeToCurrentIteration(1)); |
69 EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(1.5)); | 69 EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(1.5)); |
70 } | 70 } |
71 | 71 |
| 72 TEST(CCActiveAnimationTest, TrimTimeAlternating) |
| 73 { |
| 74 OwnPtr<CCActiveAnimation> anim(createActiveAnimation(-1)); |
| 75 anim->setAlternatesDirection(true); |
| 76 EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); |
| 77 EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5)); |
| 78 EXPECT_EQ(1, anim->trimTimeToCurrentIteration(1)); |
| 79 EXPECT_EQ(0.75, anim->trimTimeToCurrentIteration(1.25)); |
| 80 } |
| 81 |
72 TEST(CCActiveAnimationTest, TrimTimeStartTime) | 82 TEST(CCActiveAnimationTest, TrimTimeStartTime) |
73 { | 83 { |
74 OwnPtr<CCActiveAnimation> anim(createActiveAnimation(1)); | 84 OwnPtr<CCActiveAnimation> anim(createActiveAnimation(1)); |
75 anim->setStartTime(4); | 85 anim->setStartTime(4); |
76 EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); | 86 EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); |
77 EXPECT_EQ(0, anim->trimTimeToCurrentIteration(4)); | 87 EXPECT_EQ(0, anim->trimTimeToCurrentIteration(4)); |
78 EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(4.5)); | 88 EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(4.5)); |
79 EXPECT_EQ(1, anim->trimTimeToCurrentIteration(5)); | 89 EXPECT_EQ(1, anim->trimTimeToCurrentIteration(5)); |
80 EXPECT_EQ(1, anim->trimTimeToCurrentIteration(6)); | 90 EXPECT_EQ(1, anim->trimTimeToCurrentIteration(6)); |
81 } | 91 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 anim->suspend(0); | 219 anim->suspend(0); |
210 EXPECT_EQ(CCActiveAnimation::Paused, anim->runState()); | 220 EXPECT_EQ(CCActiveAnimation::Paused, anim->runState()); |
211 anim->setRunState(CCActiveAnimation::Running, 0); | 221 anim->setRunState(CCActiveAnimation::Running, 0); |
212 EXPECT_EQ(CCActiveAnimation::Paused, anim->runState()); | 222 EXPECT_EQ(CCActiveAnimation::Paused, anim->runState()); |
213 anim->resume(0); | 223 anim->resume(0); |
214 anim->setRunState(CCActiveAnimation::Running, 0); | 224 anim->setRunState(CCActiveAnimation::Running, 0); |
215 EXPECT_EQ(CCActiveAnimation::Running, anim->runState()); | 225 EXPECT_EQ(CCActiveAnimation::Running, anim->runState()); |
216 } | 226 } |
217 | 227 |
218 } // namespace | 228 } // namespace |
OLD | NEW |