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

Side by Side Diff: third_party/WebKit/Source/core/svg/graphics/SVGImageTest.cpp

Issue 2547053003: s/ passed(...) / WTF::passed(...) / to avoid future ambiguity w/ base::Passed. (Closed)
Patch Set: Rebasing... Created 4 years 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
OLDNEW
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 "<path class='spinner' fill='none' d='M 8,1.125 A 6.875,6.875 0 1 1 " 77 "<path class='spinner' fill='none' d='M 8,1.125 A 6.875,6.875 0 1 1 "
78 "1.125,8' stroke-width='2' stroke='blue'/>" 78 "1.125,8' stroke-width='2' stroke='blue'/>"
79 "</svg>"; 79 "</svg>";
80 80
81 TEST_F(SVGImageTest, TimelineSuspendAndResume) { 81 TEST_F(SVGImageTest, TimelineSuspendAndResume) {
82 const bool shouldPause = true; 82 const bool shouldPause = true;
83 load(kAnimatedDocument, shouldPause); 83 load(kAnimatedDocument, shouldPause);
84 SVGImageChromeClient& chromeClient = image().chromeClientForTesting(); 84 SVGImageChromeClient& chromeClient = image().chromeClientForTesting();
85 Timer<SVGImageChromeClient>* timer = new Timer<SVGImageChromeClient>( 85 Timer<SVGImageChromeClient>* timer = new Timer<SVGImageChromeClient>(
86 &chromeClient, &SVGImageChromeClient::animationTimerFired); 86 &chromeClient, &SVGImageChromeClient::animationTimerFired);
87 chromeClient.setTimer(wrapUnique(timer)); 87 chromeClient.setTimer(WTF::wrapUnique(timer));
88 88
89 // Simulate a draw. Cause a frame (timer) to be scheduled. 89 // Simulate a draw. Cause a frame (timer) to be scheduled.
90 pumpFrame(); 90 pumpFrame();
91 EXPECT_TRUE(image().hasAnimations()); 91 EXPECT_TRUE(image().hasAnimations());
92 EXPECT_TRUE(timer->isActive()); 92 EXPECT_TRUE(timer->isActive());
93 93
94 // Fire the timer/trigger a frame update. Since the observer always returns 94 // Fire the timer/trigger a frame update. Since the observer always returns
95 // true for shouldPauseAnimation, this will result in the timeline being 95 // true for shouldPauseAnimation, this will result in the timeline being
96 // suspended. 96 // suspended.
97 // TODO(alexclarke): Move over to using base::TimeDelta and base::TimeTicks so 97 // TODO(alexclarke): Move over to using base::TimeDelta and base::TimeTicks so
98 // we can avoid computations like this. 98 // we can avoid computations like this.
99 testing::runDelayedTasks(1.0 + timer->nextFireInterval() * 1000.0); 99 testing::runDelayedTasks(1.0 + timer->nextFireInterval() * 1000.0);
100 EXPECT_TRUE(chromeClient.isSuspended()); 100 EXPECT_TRUE(chromeClient.isSuspended());
101 EXPECT_FALSE(timer->isActive()); 101 EXPECT_FALSE(timer->isActive());
102 102
103 // Simulate a draw. This should resume the animation again. 103 // Simulate a draw. This should resume the animation again.
104 pumpFrame(); 104 pumpFrame();
105 EXPECT_TRUE(timer->isActive()); 105 EXPECT_TRUE(timer->isActive());
106 EXPECT_FALSE(chromeClient.isSuspended()); 106 EXPECT_FALSE(chromeClient.isSuspended());
107 } 107 }
108 108
109 TEST_F(SVGImageTest, ResetAnimation) { 109 TEST_F(SVGImageTest, ResetAnimation) {
110 const bool shouldPause = false; 110 const bool shouldPause = false;
111 load(kAnimatedDocument, shouldPause); 111 load(kAnimatedDocument, shouldPause);
112 SVGImageChromeClient& chromeClient = image().chromeClientForTesting(); 112 SVGImageChromeClient& chromeClient = image().chromeClientForTesting();
113 Timer<SVGImageChromeClient>* timer = new Timer<SVGImageChromeClient>( 113 Timer<SVGImageChromeClient>* timer = new Timer<SVGImageChromeClient>(
114 &chromeClient, &SVGImageChromeClient::animationTimerFired); 114 &chromeClient, &SVGImageChromeClient::animationTimerFired);
115 chromeClient.setTimer(wrapUnique(timer)); 115 chromeClient.setTimer(WTF::wrapUnique(timer));
116 116
117 // Simulate a draw. Cause a frame (timer) to be scheduled. 117 // Simulate a draw. Cause a frame (timer) to be scheduled.
118 pumpFrame(); 118 pumpFrame();
119 EXPECT_TRUE(image().hasAnimations()); 119 EXPECT_TRUE(image().hasAnimations());
120 EXPECT_TRUE(timer->isActive()); 120 EXPECT_TRUE(timer->isActive());
121 121
122 // Reset the animation. This will suspend the timeline but not cancel the 122 // Reset the animation. This will suspend the timeline but not cancel the
123 // timer. 123 // timer.
124 image().resetAnimation(); 124 image().resetAnimation();
125 EXPECT_TRUE(chromeClient.isSuspended()); 125 EXPECT_TRUE(chromeClient.isSuspended());
126 EXPECT_TRUE(timer->isActive()); 126 EXPECT_TRUE(timer->isActive());
127 127
128 // Fire the timer/trigger a frame update. The timeline will remain 128 // Fire the timer/trigger a frame update. The timeline will remain
129 // suspended and no frame will be scheduled. 129 // suspended and no frame will be scheduled.
130 // TODO(alexclarke): Move over to using base::TimeDelta and base::TimeTicks so 130 // TODO(alexclarke): Move over to using base::TimeDelta and base::TimeTicks so
131 // we can avoid computations like this. 131 // we can avoid computations like this.
132 testing::runDelayedTasks(1.0 + timer->nextFireInterval() * 1000.0); 132 testing::runDelayedTasks(1.0 + timer->nextFireInterval() * 1000.0);
133 EXPECT_TRUE(chromeClient.isSuspended()); 133 EXPECT_TRUE(chromeClient.isSuspended());
134 EXPECT_FALSE(timer->isActive()); 134 EXPECT_FALSE(timer->isActive());
135 135
136 // Simulate a draw. This should resume the animation again. 136 // Simulate a draw. This should resume the animation again.
137 pumpFrame(); 137 pumpFrame();
138 EXPECT_FALSE(chromeClient.isSuspended()); 138 EXPECT_FALSE(chromeClient.isSuspended());
139 EXPECT_TRUE(timer->isActive()); 139 EXPECT_TRUE(timer->isActive());
140 } 140 }
141 141
142 } // namespace blink 142 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698