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

Unified Diff: cc/CCFrameRateControllerTest.cpp

Issue 10956006: Convert CC scheduler logic to use base::TimeTicks/Delta instead of doubles (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/CCFrameRateController.cpp ('k') | cc/CCLayerTreeHostImpl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/CCFrameRateControllerTest.cpp
diff --git a/cc/CCFrameRateControllerTest.cpp b/cc/CCFrameRateControllerTest.cpp
index 34291a26b8b9135f68e649b5584036b0b82c2d3c..87f24c7f7f7ebd679531bccb822af23b61a8631f 100644
--- a/cc/CCFrameRateControllerTest.cpp
+++ b/cc/CCFrameRateControllerTest.cpp
@@ -33,17 +33,18 @@ TEST(CCFrameRateControllerTest, TestFrameThrottling_ImmediateAck)
{
FakeCCThread thread;
FakeCCFrameRateControllerClient client;
- RefPtr<FakeCCDelayBasedTimeSource> timeSource = FakeCCDelayBasedTimeSource::create(1.0 / 60.0, &thread);
+ base::TimeDelta interval = base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond / 60);
+ RefPtr<FakeCCDelayBasedTimeSource> timeSource = FakeCCDelayBasedTimeSource::create(interval, &thread);
CCFrameRateController controller(timeSource);
controller.setClient(&client);
controller.setActive(true);
- double elapsed = 0; // Muck around with time a bit
+ base::TimeTicks elapsed; // Muck around with time a bit
// Trigger one frame, make sure the vsync callback is called
- elapsed += thread.pendingDelayMs() / 1000.0;
- timeSource->setMonotonicTimeNow(elapsed);
+ elapsed += base::TimeDelta::FromMilliseconds(thread.pendingDelayMs());
+ timeSource->setNow(elapsed);
thread.runPendingTask();
EXPECT_TRUE(client.vsyncTicked());
client.reset();
@@ -52,13 +53,13 @@ TEST(CCFrameRateControllerTest, TestFrameThrottling_ImmediateAck)
controller.didBeginFrame();
// Tell the controller the frame ended 5ms later
- timeSource->setMonotonicTimeNow(timeSource->monotonicTimeNow() + 0.005);
+ timeSource->setNow(timeSource->now() + base::TimeDelta::FromMilliseconds(5));
controller.didFinishFrame();
// Trigger another frame, make sure vsync runs again
- elapsed += thread.pendingDelayMs() / 1000.0;
- EXPECT_TRUE(elapsed >= timeSource->monotonicTimeNow()); // Sanity check that previous code didn't move time backward.
- timeSource->setMonotonicTimeNow(elapsed);
+ elapsed += base::TimeDelta::FromMilliseconds(thread.pendingDelayMs());
+ EXPECT_TRUE(elapsed >= timeSource->now()); // Sanity check that previous code didn't move time backward.
+ timeSource->setNow(elapsed);
thread.runPendingTask();
EXPECT_TRUE(client.vsyncTicked());
}
@@ -67,18 +68,19 @@ TEST(CCFrameRateControllerTest, TestFrameThrottling_TwoFramesInFlight)
{
FakeCCThread thread;
FakeCCFrameRateControllerClient client;
- RefPtr<FakeCCDelayBasedTimeSource> timeSource = FakeCCDelayBasedTimeSource::create(1.0 / 60.0, &thread);
+ base::TimeDelta interval = base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond / 60);
+ RefPtr<FakeCCDelayBasedTimeSource> timeSource = FakeCCDelayBasedTimeSource::create(interval, &thread);
CCFrameRateController controller(timeSource);
controller.setClient(&client);
controller.setActive(true);
controller.setMaxFramesPending(2);
- double elapsed = 0; // Muck around with time a bit
+ base::TimeTicks elapsed; // Muck around with time a bit
// Trigger one frame, make sure the vsync callback is called
- elapsed += thread.pendingDelayMs() / 1000.0;
- timeSource->setMonotonicTimeNow(elapsed);
+ elapsed += base::TimeDelta::FromMilliseconds(thread.pendingDelayMs());
+ timeSource->setNow(elapsed);
thread.runPendingTask();
EXPECT_TRUE(client.vsyncTicked());
client.reset();
@@ -87,9 +89,9 @@ TEST(CCFrameRateControllerTest, TestFrameThrottling_TwoFramesInFlight)
controller.didBeginFrame();
// Trigger another frame, make sure vsync callback runs again
- elapsed += thread.pendingDelayMs() / 1000.0;
- EXPECT_TRUE(elapsed >= timeSource->monotonicTimeNow()); // Sanity check that previous code didn't move time backward.
- timeSource->setMonotonicTimeNow(elapsed);
+ elapsed += base::TimeDelta::FromMilliseconds(thread.pendingDelayMs());
+ EXPECT_TRUE(elapsed >= timeSource->now()); // Sanity check that previous code didn't move time backward.
+ timeSource->setNow(elapsed);
thread.runPendingTask();
EXPECT_TRUE(client.vsyncTicked());
client.reset();
@@ -98,23 +100,23 @@ TEST(CCFrameRateControllerTest, TestFrameThrottling_TwoFramesInFlight)
controller.didBeginFrame();
// Trigger another frame. Since two frames are pending, we should not draw.
- elapsed += thread.pendingDelayMs() / 1000.0;
- EXPECT_TRUE(elapsed >= timeSource->monotonicTimeNow()); // Sanity check that previous code didn't move time backward.
- timeSource->setMonotonicTimeNow(elapsed);
+ elapsed += base::TimeDelta::FromMilliseconds(thread.pendingDelayMs());
+ EXPECT_TRUE(elapsed >= timeSource->now()); // Sanity check that previous code didn't move time backward.
+ timeSource->setNow(elapsed);
thread.runPendingTask();
EXPECT_FALSE(client.vsyncTicked());
// Tell the controller the first frame ended 5ms later
- timeSource->setMonotonicTimeNow(timeSource->monotonicTimeNow() + 0.005);
+ timeSource->setNow(timeSource->now() + base::TimeDelta::FromMilliseconds(5));
controller.didFinishFrame();
// Tick should not have been called
EXPECT_FALSE(client.vsyncTicked());
// Trigger yet another frame. Since one frames is pending, another vsync callback should run.
- elapsed += thread.pendingDelayMs() / 1000.0;
- EXPECT_TRUE(elapsed >= timeSource->monotonicTimeNow()); // Sanity check that previous code didn't move time backward.
- timeSource->setMonotonicTimeNow(elapsed);
+ elapsed += base::TimeDelta::FromMilliseconds(thread.pendingDelayMs());
+ EXPECT_TRUE(elapsed >= timeSource->now()); // Sanity check that previous code didn't move time backward.
+ timeSource->setNow(elapsed);
thread.runPendingTask();
EXPECT_TRUE(client.vsyncTicked());
}
« no previous file with comments | « cc/CCFrameRateController.cpp ('k') | cc/CCLayerTreeHostImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698