| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/svg/graphics/SVGImage.h" | 5 #include "core/svg/graphics/SVGImage.h" |
| 6 | 6 |
| 7 #include "core/svg/graphics/SVGImageChromeClient.h" | 7 #include "core/svg/graphics/SVGImageChromeClient.h" |
| 8 #include "platform/SharedBuffer.h" | 8 #include "platform/SharedBuffer.h" |
| 9 #include "platform/Timer.h" | 9 #include "platform/Timer.h" |
| 10 #include "platform/geometry/FloatRect.h" | 10 #include "platform/geometry/FloatRect.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 chromeClient.setTimer(wrapUnique(timer)); | 88 chromeClient.setTimer(wrapUnique(timer)); |
| 89 | 89 |
| 90 // Simulate a draw. Cause a frame (timer) to be scheduled. | 90 // Simulate a draw. Cause a frame (timer) to be scheduled. |
| 91 pumpFrame(); | 91 pumpFrame(); |
| 92 EXPECT_TRUE(image().hasAnimations()); | 92 EXPECT_TRUE(image().hasAnimations()); |
| 93 EXPECT_TRUE(timer->isActive()); | 93 EXPECT_TRUE(timer->isActive()); |
| 94 | 94 |
| 95 // Fire the timer/trigger a frame update. Since the observer always returns | 95 // Fire the timer/trigger a frame update. Since the observer always returns |
| 96 // true for shouldPauseAnimation, this will result in the timeline being | 96 // true for shouldPauseAnimation, this will result in the timeline being |
| 97 // suspended. | 97 // suspended. |
| 98 // TODO(alexclarke): Move over to using base::TimeDelta and base::TimeTicks so
we can avoid computations like this. | 98 // TODO(alexclarke): Move over to using base::TimeDelta and base::TimeTicks so |
| 99 // we can avoid computations like this. |
| 99 testing::runDelayedTasks(1.0 + timer->nextFireInterval() * 1000.0); | 100 testing::runDelayedTasks(1.0 + timer->nextFireInterval() * 1000.0); |
| 100 EXPECT_TRUE(chromeClient.isSuspended()); | 101 EXPECT_TRUE(chromeClient.isSuspended()); |
| 101 EXPECT_FALSE(timer->isActive()); | 102 EXPECT_FALSE(timer->isActive()); |
| 102 | 103 |
| 103 // Simulate a draw. This should resume the animation again. | 104 // Simulate a draw. This should resume the animation again. |
| 104 pumpFrame(); | 105 pumpFrame(); |
| 105 EXPECT_TRUE(timer->isActive()); | 106 EXPECT_TRUE(timer->isActive()); |
| 106 EXPECT_FALSE(chromeClient.isSuspended()); | 107 EXPECT_FALSE(chromeClient.isSuspended()); |
| 107 } | 108 } |
| 108 | 109 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 120 EXPECT_TRUE(timer->isActive()); | 121 EXPECT_TRUE(timer->isActive()); |
| 121 | 122 |
| 122 // Reset the animation. This will suspend the timeline but not cancel the | 123 // Reset the animation. This will suspend the timeline but not cancel the |
| 123 // timer. | 124 // timer. |
| 124 image().resetAnimation(); | 125 image().resetAnimation(); |
| 125 EXPECT_TRUE(chromeClient.isSuspended()); | 126 EXPECT_TRUE(chromeClient.isSuspended()); |
| 126 EXPECT_TRUE(timer->isActive()); | 127 EXPECT_TRUE(timer->isActive()); |
| 127 | 128 |
| 128 // Fire the timer/trigger a frame update. The timeline will remain | 129 // Fire the timer/trigger a frame update. The timeline will remain |
| 129 // suspended and no frame will be scheduled. | 130 // suspended and no frame will be scheduled. |
| 130 // TODO(alexclarke): Move over to using base::TimeDelta and base::TimeTicks so
we can avoid computations like this. | 131 // TODO(alexclarke): Move over to using base::TimeDelta and base::TimeTicks so |
| 132 // we can avoid computations like this. |
| 131 testing::runDelayedTasks(1.0 + timer->nextFireInterval() * 1000.0); | 133 testing::runDelayedTasks(1.0 + timer->nextFireInterval() * 1000.0); |
| 132 EXPECT_TRUE(chromeClient.isSuspended()); | 134 EXPECT_TRUE(chromeClient.isSuspended()); |
| 133 EXPECT_FALSE(timer->isActive()); | 135 EXPECT_FALSE(timer->isActive()); |
| 134 | 136 |
| 135 // Simulate a draw. This should resume the animation again. | 137 // Simulate a draw. This should resume the animation again. |
| 136 pumpFrame(); | 138 pumpFrame(); |
| 137 EXPECT_FALSE(chromeClient.isSuspended()); | 139 EXPECT_FALSE(chromeClient.isSuspended()); |
| 138 EXPECT_TRUE(timer->isActive()); | 140 EXPECT_TRUE(timer->isActive()); |
| 139 } | 141 } |
| 140 | 142 |
| 141 } // namespace blink | 143 } // namespace blink |
| OLD | NEW |