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

Side by Side Diff: third_party/WebKit/Source/platform/TimerTest.cpp

Issue 1550563002: Blink Platform: Remove time functions from Platform. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merrrge agaaain. Created 4 years, 10 months 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "platform/Timer.h" 5 #include "platform/Timer.h"
6 6
7 #include "platform/testing/TestingPlatformSupport.h" 7 #include "platform/testing/TestingPlatformSupport.h"
8 #include "public/platform/Platform.h" 8 #include "public/platform/Platform.h"
9 #include "public/platform/WebScheduler.h" 9 #include "public/platform/WebScheduler.h"
10 #include "public/platform/WebThread.h" 10 #include "public/platform/WebThread.h"
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 return static_cast<MockWebScheduler*>(m_webThread->scheduler()); 273 return static_cast<MockWebScheduler*>(m_webThread->scheduler());
274 } 274 }
275 275
276 OwnPtr<FakeWebThread> m_webThread; 276 OwnPtr<FakeWebThread> m_webThread;
277 }; 277 };
278 278
279 class TimerTest : public testing::Test { 279 class TimerTest : public testing::Test {
280 public: 280 public:
281 void SetUp() override 281 void SetUp() override
282 { 282 {
283 WTF::setMonotonicallyIncreasingTimeFunction(currentTime); 283 m_originalTimeFunction = setTimeFunctionsForTesting(currentTime);
284 284
285 m_runTimes.clear(); 285 m_runTimes.clear();
286 gCurrentTimeSecs = 10.0; 286 gCurrentTimeSecs = 10.0;
287 m_startTime = gCurrentTimeSecs; 287 m_startTime = gCurrentTimeSecs;
288 } 288 }
289 289
290 void TearDown() override
291 {
292 setTimeFunctionsForTesting(m_originalTimeFunction);
293 }
294
290 void countingTask(Timer<TimerTest>*) 295 void countingTask(Timer<TimerTest>*)
291 { 296 {
292 m_runTimes.append(monotonicallyIncreasingTime()); 297 m_runTimes.append(monotonicallyIncreasingTime());
293 } 298 }
294 299
295 void recordNextFireTimeTask(Timer<TimerTest>* timer) 300 void recordNextFireTimeTask(Timer<TimerTest>* timer)
296 { 301 {
297 m_nextFireTimes.append(monotonicallyIncreasingTime() + timer->nextFireIn terval()); 302 m_nextFireTimes.append(monotonicallyIncreasingTime() + timer->nextFireIn terval());
298 } 303 }
299 304
(...skipping 27 matching lines...) Expand all
327 return m_platform.nextTimerTaskDelaySecs(); 332 return m_platform.nextTimerTaskDelaySecs();
328 } 333 }
329 334
330 protected: 335 protected:
331 double m_startTime; 336 double m_startTime;
332 WTF::Vector<double> m_runTimes; 337 WTF::Vector<double> m_runTimes;
333 WTF::Vector<double> m_nextFireTimes; 338 WTF::Vector<double> m_nextFireTimes;
334 339
335 private: 340 private:
336 TimerTestPlatform m_platform; 341 TimerTestPlatform m_platform;
342 TimeFunction m_originalTimeFunction;
337 }; 343 };
338 344
339 TEST_F(TimerTest, StartOneShot_Zero) 345 TEST_F(TimerTest, StartOneShot_Zero)
340 { 346 {
341 Timer<TimerTest> timer(this, &TimerTest::countingTask); 347 Timer<TimerTest> timer(this, &TimerTest::countingTask);
342 timer.startOneShot(0, BLINK_FROM_HERE); 348 timer.startOneShot(0, BLINK_FROM_HERE);
343 349
344 ASSERT(hasOneTimerTask()); 350 ASSERT(hasOneTimerTask());
345 EXPECT_FLOAT_EQ(0.0, nextTimerTaskDelaySecs()); 351 EXPECT_FLOAT_EQ(0.0, nextTimerTaskDelaySecs());
346 352
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 TimerForTest<TimerTest> timer(this, &TimerTest::countingTask, &taskRunner); 760 TimerForTest<TimerTest> timer(this, &TimerTest::countingTask, &taskRunner);
755 timer.startOneShot(0, BLINK_FROM_HERE); 761 timer.startOneShot(0, BLINK_FROM_HERE);
756 762
757 // Make sure the task was posted on taskRunner. 763 // Make sure the task was posted on taskRunner.
758 EXPECT_FALSE(timerTasks.empty()); 764 EXPECT_FALSE(timerTasks.empty());
759 } 765 }
760 766
761 767
762 } // namespace 768 } // namespace
763 } // namespace blink 769 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/Timer.h ('k') | third_party/WebKit/Source/platform/graphics/PictureSnapshot.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698