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

Unified Diff: cc/scheduler/frame_rate_controller_unittest.cc

Issue 67023003: cc: Don't double-tick unthrottled FrameRateController (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pull out change to disable deadline scheduling. Created 7 years, 1 month 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/scheduler/frame_rate_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/scheduler/frame_rate_controller_unittest.cc
diff --git a/cc/scheduler/frame_rate_controller_unittest.cc b/cc/scheduler/frame_rate_controller_unittest.cc
index 353d9844caf5e2639a5ad74e8a5bb4faa272b50e..ea5f52f2e0346771ceff7dd32c85821e3735fc40 100644
--- a/cc/scheduler/frame_rate_controller_unittest.cc
+++ b/cc/scheduler/frame_rate_controller_unittest.cc
@@ -15,16 +15,17 @@ class FakeFrameRateControllerClient : public cc::FrameRateControllerClient {
public:
FakeFrameRateControllerClient() { Reset(); }
- void Reset() { began_frame_ = false; }
- bool BeganFrame() const { return began_frame_; }
+ void Reset() { frame_count_ = 0; }
+ bool BeganFrame() const { return frame_count_ > 0; }
+ int frame_count() const { return frame_count_; }
virtual void FrameRateControllerTick(
bool throttled, const BeginFrameArgs& args) OVERRIDE {
- began_frame_ = !throttled;
+ frame_count_ += throttled ? 0 : 1;
}
protected:
- bool began_frame_;
+ int frame_count_;
};
TEST(FrameRateControllerTest, TestFrameThrottling_ImmediateAck) {
@@ -182,5 +183,29 @@ TEST(FrameRateControllerTest, TestFrameThrottling_Unthrottled) {
EXPECT_TRUE(client.BeganFrame());
}
+TEST(FrameRateControllerTest, TestFrameThrottling_NoDoubleTicking) {
+ scoped_refptr<base::TestSimpleTaskRunner> task_runner =
+ new base::TestSimpleTaskRunner;
+ FakeFrameRateControllerClient client;
+ FrameRateController controller(task_runner.get());
+ controller.SetClient(&client);
+
+ // SetActive triggers 1st frame and queues another tick task since the time
+ // source isn't throttling.
+ controller.SetActive(true);
+ task_runner->RunPendingTasks();
+ EXPECT_TRUE(client.BeganFrame());
+ client.Reset();
+ EXPECT_TRUE(task_runner->HasPendingTask());
+
+ // Simulate a frame swap. This shouldn't queue a second tick task.
+ controller.DidSwapBuffers();
+ controller.DidSwapBuffersComplete();
+
+ // The client should only be ticked once.
+ task_runner->RunPendingTasks();
+ EXPECT_EQ(1, client.frame_count());
+}
+
} // namespace
} // namespace cc
« no previous file with comments | « cc/scheduler/frame_rate_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698