summaryrefslogtreecommitdiff
path: root/Source/WebKit/chromium/tests/CCFrameRateControllerTest.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-05-07 11:21:11 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-05-07 11:21:11 +0200
commit2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47 (patch)
tree988e8c5b116dd0466244ae2fe5af8ee9be926d76 /Source/WebKit/chromium/tests/CCFrameRateControllerTest.cpp
parentdd91e772430dc294e3bf478c119ef8d43c0a3358 (diff)
downloadqtwebkit-2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47.tar.gz
Imported WebKit commit 7e538425aa020340619e927792f3d895061fb54b (http://svn.webkit.org/repository/webkit/trunk@116286)
Diffstat (limited to 'Source/WebKit/chromium/tests/CCFrameRateControllerTest.cpp')
-rw-r--r--Source/WebKit/chromium/tests/CCFrameRateControllerTest.cpp62
1 files changed, 31 insertions, 31 deletions
diff --git a/Source/WebKit/chromium/tests/CCFrameRateControllerTest.cpp b/Source/WebKit/chromium/tests/CCFrameRateControllerTest.cpp
index ae43d41c1..c9a60cfaa 100644
--- a/Source/WebKit/chromium/tests/CCFrameRateControllerTest.cpp
+++ b/Source/WebKit/chromium/tests/CCFrameRateControllerTest.cpp
@@ -39,13 +39,13 @@ class FakeCCFrameRateControllerClient : public WebCore::CCFrameRateControllerCli
public:
FakeCCFrameRateControllerClient() { reset(); }
- void reset() { m_frameBegun = false; }
- bool frameBegun() const { return m_frameBegun; }
+ void reset() { m_vsyncTicked = false; }
+ bool vsyncTicked() const { return m_vsyncTicked; }
- virtual void beginFrame() { m_frameBegun = true; }
+ virtual void vsyncTick() { m_vsyncTicked = true; }
protected:
- bool m_frameBegun;
+ bool m_vsyncTicked;
};
@@ -53,7 +53,7 @@ TEST(CCFrameRateControllerTest, TestFrameThrottling_ImmediateAck)
{
FakeCCThread thread;
FakeCCFrameRateControllerClient client;
- RefPtr<FakeCCDelayBasedTimeSource> timeSource = FakeCCDelayBasedTimeSource::create(1000.0 / 60.0, &thread);
+ RefPtr<FakeCCDelayBasedTimeSource> timeSource = FakeCCDelayBasedTimeSource::create(1.0 / 60.0, &thread);
CCFrameRateController controller(timeSource);
controller.setClient(&client);
@@ -62,32 +62,32 @@ TEST(CCFrameRateControllerTest, TestFrameThrottling_ImmediateAck)
double elapsed = 0; // Muck around with time a bit
// Trigger one frame, make sure the vsync callback is called
- elapsed += thread.pendingDelay();
- timeSource->setMonotonicallyIncreasingTimeMs(elapsed);
+ elapsed += thread.pendingDelayMs() / 1000.0;
+ timeSource->setMonotonicallyIncreasingTime(elapsed);
thread.runPendingTask();
- EXPECT_TRUE(client.frameBegun());
+ EXPECT_TRUE(client.vsyncTicked());
client.reset();
// Tell the controller we drew
controller.didBeginFrame();
// Tell the controller the frame ended 5ms later
- timeSource->setMonotonicallyIncreasingTimeMs(timeSource->monotonicallyIncreasingTimeMs() + 5);
+ timeSource->setMonotonicallyIncreasingTime(timeSource->monotonicallyIncreasingTime() + 0.005);
controller.didFinishFrame();
// Trigger another frame, make sure vsync runs again
- elapsed += thread.pendingDelay();
- EXPECT_TRUE(elapsed >= timeSource->monotonicallyIncreasingTimeMs()); // Sanity check that previous code didn't move time backward.
- timeSource->setMonotonicallyIncreasingTimeMs(elapsed);
+ elapsed += thread.pendingDelayMs() / 1000.0;
+ EXPECT_TRUE(elapsed >= timeSource->monotonicallyIncreasingTime()); // Sanity check that previous code didn't move time backward.
+ timeSource->setMonotonicallyIncreasingTime(elapsed);
thread.runPendingTask();
- EXPECT_TRUE(client.frameBegun());
+ EXPECT_TRUE(client.vsyncTicked());
}
TEST(CCFrameRateControllerTest, TestFrameThrottling_TwoFramesInFlight)
{
FakeCCThread thread;
FakeCCFrameRateControllerClient client;
- RefPtr<FakeCCDelayBasedTimeSource> timeSource = FakeCCDelayBasedTimeSource::create(1000.0 / 60.0, &thread);
+ RefPtr<FakeCCDelayBasedTimeSource> timeSource = FakeCCDelayBasedTimeSource::create(1.0 / 60.0, &thread);
CCFrameRateController controller(timeSource);
controller.setClient(&client);
@@ -97,46 +97,46 @@ TEST(CCFrameRateControllerTest, TestFrameThrottling_TwoFramesInFlight)
double elapsed = 0; // Muck around with time a bit
// Trigger one frame, make sure the vsync callback is called
- elapsed += thread.pendingDelay();
- timeSource->setMonotonicallyIncreasingTimeMs(elapsed);
+ elapsed += thread.pendingDelayMs() / 1000.0;
+ timeSource->setMonotonicallyIncreasingTime(elapsed);
thread.runPendingTask();
- EXPECT_TRUE(client.frameBegun());
+ EXPECT_TRUE(client.vsyncTicked());
client.reset();
// Tell the controller we drew
controller.didBeginFrame();
// Trigger another frame, make sure vsync callback runs again
- elapsed += thread.pendingDelay();
- EXPECT_TRUE(elapsed >= timeSource->monotonicallyIncreasingTimeMs()); // Sanity check that previous code didn't move time backward.
- timeSource->setMonotonicallyIncreasingTimeMs(elapsed);
+ elapsed += thread.pendingDelayMs() / 1000.0;
+ EXPECT_TRUE(elapsed >= timeSource->monotonicallyIncreasingTime()); // Sanity check that previous code didn't move time backward.
+ timeSource->setMonotonicallyIncreasingTime(elapsed);
thread.runPendingTask();
- EXPECT_TRUE(client.frameBegun());
+ EXPECT_TRUE(client.vsyncTicked());
client.reset();
// Tell the controller we drew, again.
controller.didBeginFrame();
// Trigger another frame. Since two frames are pending, we should not draw.
- elapsed += thread.pendingDelay();
- EXPECT_TRUE(elapsed >= timeSource->monotonicallyIncreasingTimeMs()); // Sanity check that previous code didn't move time backward.
- timeSource->setMonotonicallyIncreasingTimeMs(elapsed);
+ elapsed += thread.pendingDelayMs() / 1000.0;
+ EXPECT_TRUE(elapsed >= timeSource->monotonicallyIncreasingTime()); // Sanity check that previous code didn't move time backward.
+ timeSource->setMonotonicallyIncreasingTime(elapsed);
thread.runPendingTask();
- EXPECT_FALSE(client.frameBegun());
+ EXPECT_FALSE(client.vsyncTicked());
// Tell the controller the first frame ended 5ms later
- timeSource->setMonotonicallyIncreasingTimeMs(timeSource->monotonicallyIncreasingTimeMs() + 5);
+ timeSource->setMonotonicallyIncreasingTime(timeSource->monotonicallyIncreasingTime() + 0.005);
controller.didFinishFrame();
// Tick should not have been called
- EXPECT_FALSE(client.frameBegun());
+ EXPECT_FALSE(client.vsyncTicked());
// Trigger yet another frame. Since one frames is pending, another vsync callback should run.
- elapsed += thread.pendingDelay();
- EXPECT_TRUE(elapsed >= timeSource->monotonicallyIncreasingTimeMs()); // Sanity check that previous code didn't move time backward.
- timeSource->setMonotonicallyIncreasingTimeMs(elapsed);
+ elapsed += thread.pendingDelayMs() / 1000.0;
+ EXPECT_TRUE(elapsed >= timeSource->monotonicallyIncreasingTime()); // Sanity check that previous code didn't move time backward.
+ timeSource->setMonotonicallyIncreasingTime(elapsed);
thread.runPendingTask();
- EXPECT_TRUE(client.frameBegun());
+ EXPECT_TRUE(client.vsyncTicked());
}
}