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

Unified Diff: cc/scheduler/scheduler_unittest.cc

Issue 303573002: cc: Add Scheduler test for SetSwapUsedIncompleteTile (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/scheduler/scheduler_unittest.cc
diff --git a/cc/scheduler/scheduler_unittest.cc b/cc/scheduler/scheduler_unittest.cc
index 071fa58a066aea14ff4c3158d3ab47dac747b187..9de0bb8b0d33ffaf46cf2f4b110bce1c336b8936 100644
--- a/cc/scheduler/scheduler_unittest.cc
+++ b/cc/scheduler/scheduler_unittest.cc
@@ -40,7 +40,9 @@ void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler,
class FakeSchedulerClient : public SchedulerClient {
public:
- FakeSchedulerClient() : needs_begin_frame_(false), automatic_swap_ack_(true) {
+ FakeSchedulerClient() : needs_begin_frame_(false),
+ automatic_swap_ack_(true),
+ contain_incomplete_tile_(false) {
brianderson 2014/05/27 21:15:57 swap_contains_incomplete_tile_
simonhong 2014/05/28 00:09:35 Done.
Reset();
}
@@ -82,6 +84,10 @@ class FakeSchedulerClient : public SchedulerClient {
return -1;
}
+ void set_contain_incomplete_tile(bool contain) {
brianderson 2014/05/27 21:15:57 SetSwapContainsIncompleteTile
simonhong 2014/05/28 00:09:35 Done.
+ contain_incomplete_tile_ = contain;
+ }
+
bool HasAction(const char* action) const {
return ActionIndex(action) >= 0;
}
@@ -177,6 +183,7 @@ class FakeSchedulerClient : public SchedulerClient {
bool automatic_swap_ack_;
int num_draws_;
bool log_anticipated_draw_time_change_;
+ bool contain_incomplete_tile_;
brianderson 2014/05/27 21:15:57 This isn't used by the base class. Can you put it
simonhong 2014/05/28 00:09:35 Ah.. yes. SchedulerClientNeedsUpdateVisibleTiles i
base::TimeTicks posted_begin_impl_frame_deadline_;
std::vector<const char*> actions_;
ScopedVector<base::Value> states_;
@@ -875,6 +882,68 @@ TEST(SchedulerTest, ManageTilesOncePerFrame) {
scheduler->DidManageTiles(); // Corresponds to ScheduledActionManageTiles
}
+class SchedulerClientNeedsUpdateVisibleTiles : public FakeSchedulerClient {
+ public:
+ virtual DrawResult ScheduledActionDrawAndSwapIfPossible()
+ OVERRIDE {
+ actions_.push_back("ScheduledActionDrawAndSwapIfPossible");
+ states_.push_back(scheduler_->AsValue().release());
+ num_draws_++;
+ DrawResult result =
+ draw_will_happen_ ? DRAW_SUCCESS : DRAW_ABORTED_CHECKERBOARD_ANIMATIONS;
+ bool swap_will_happen =
+ draw_will_happen_ && swap_will_happen_if_draw_happens_;
+ if (swap_will_happen) {
+ scheduler_->DidSwapBuffers();
+ if (contain_incomplete_tile_) {
+ scheduler_->SetSwapUsedIncompleteTile(true);
+ contain_incomplete_tile_ = false;
+ }
+ if (automatic_swap_ack_)
+ scheduler_->DidSwapBuffersComplete();
+ }
+ return result;
+ }
+};
+
+TEST(SchedulerTest, ShouldUpdateVisibleTiles) {
+ SchedulerClientNeedsUpdateVisibleTiles client;
+ SchedulerSettings scheduler_settings;
+ scheduler_settings.impl_side_painting = true;
+ Scheduler* scheduler = client.CreateScheduler(scheduler_settings);
+ scheduler->SetCanStart();
+ scheduler->SetVisible(true);
+ scheduler->SetCanDraw(true);
+ InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
+
+ // SetNeedsCommit should begin the frame.
+ client.Reset();
+ scheduler->SetNeedsCommit();
+ EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client);
+
+ client.Reset();
+ scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
+ EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
+ EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
+ EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
+
+ client.Reset();
+ scheduler->NotifyBeginMainFrameStarted();
+ scheduler->NotifyReadyToCommit();
+ EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
+
+ client.Reset();
+ scheduler->NotifyReadyToActivate();
+ EXPECT_SINGLE_ACTION("ScheduledActionActivatePendingTree", client);
+
+ client.Reset();
+ client.set_contain_incomplete_tile(true);
+ client.task_runner().RunPendingTasks(); // Run posted deadline.
+ EXPECT_ACTION("ScheduledActionAnimate", client, 0, 3);
+ EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 3);
+ EXPECT_ACTION("ScheduledActionUpdateVisibleTiles", client, 2, 3);
brianderson 2014/05/27 21:15:57 After this point, can you check that needs_redraw
+}
+
TEST(SchedulerTest, TriggerBeginFrameDeadlineEarly) {
SchedulerClientNeedsManageTilesInDraw client;
SchedulerSettings default_scheduler_settings;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698