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

Side by Side Diff: cc/scheduler/scheduler_unittest.cc

Issue 619843002: cc: Make separate interface for BeginFrame ipc from OutputSurface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 unified diff | Download patch
« no previous file with comments | « cc/scheduler/scheduler.cc ('k') | cc/surfaces/display.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 #include "cc/scheduler/scheduler.h" 4 #include "cc/scheduler/scheduler.h"
5 5
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 29 matching lines...) Expand all
40 namespace cc { 40 namespace cc {
41 namespace { 41 namespace {
42 42
43 class FakeSchedulerClient; 43 class FakeSchedulerClient;
44 44
45 void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler, 45 void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler,
46 FakeSchedulerClient* client); 46 FakeSchedulerClient* client);
47 47
48 class FakeSchedulerClient : public SchedulerClient { 48 class FakeSchedulerClient : public SchedulerClient {
49 public: 49 public:
50 struct FakeBeginFrameSourceForFakeSchedulerClient 50 class FakeExternalBeginFrameSource : public BeginFrameSourceMixIn {
51 : public FakeBeginFrameSource { 51 public:
52 FakeSchedulerClient* client_; 52 explicit FakeExternalBeginFrameSource(FakeSchedulerClient* client)
53
54 explicit FakeBeginFrameSourceForFakeSchedulerClient(
55 FakeSchedulerClient* client)
56 : client_(client) {} 53 : client_(client) {}
54 virtual ~FakeExternalBeginFrameSource() {}
57 55
58 void OnNeedsBeginFramesChange(bool needs_begin_frames) override { 56 void OnNeedsBeginFramesChange(bool needs_begin_frames) override {
59 if (needs_begin_frames) { 57 if (needs_begin_frames) {
60 client_->actions_.push_back("SetNeedsBeginFrames(true)"); 58 client_->actions_.push_back("SetNeedsBeginFrames(true)");
61 } else { 59 } else {
62 client_->actions_.push_back("SetNeedsBeginFrames(false)"); 60 client_->actions_.push_back("SetNeedsBeginFrames(false)");
63 } 61 }
64 client_->states_.push_back(client_->scheduler_->AsValue()); 62 client_->states_.push_back(client_->scheduler_->AsValue());
65 } 63 }
64
65 void TestOnBeginFrame(const BeginFrameArgs& args) {
66 return CallOnBeginFrame(args);
67 }
68
69 private:
70 FakeSchedulerClient* client_;
66 }; 71 };
67 72
68 class FakePowerMonitorSource : public base::PowerMonitorSource { 73 class FakePowerMonitorSource : public base::PowerMonitorSource {
69 public: 74 public:
70 FakePowerMonitorSource() {} 75 FakePowerMonitorSource() {}
71 ~FakePowerMonitorSource() override {} 76 ~FakePowerMonitorSource() override {}
72 void GeneratePowerStateEvent(bool on_battery_power) { 77 void GeneratePowerStateEvent(bool on_battery_power) {
73 on_battery_power_impl_ = on_battery_power; 78 on_battery_power_impl_ = on_battery_power;
74 ProcessPowerEvent(POWER_STATE_EVENT); 79 ProcessPowerEvent(POWER_STATE_EVENT);
75 base::MessageLoop::current()->RunUntilIdle(); 80 base::MessageLoop::current()->RunUntilIdle();
76 } 81 }
77 bool IsOnBatteryPowerImpl() override { return on_battery_power_impl_; } 82 bool IsOnBatteryPowerImpl() override { return on_battery_power_impl_; }
78 83
79 private: 84 private:
80 bool on_battery_power_impl_; 85 bool on_battery_power_impl_;
81 }; 86 };
82 87
83 FakeSchedulerClient() 88 FakeSchedulerClient()
84 : automatic_swap_ack_(true), 89 : automatic_swap_ack_(true),
85 swap_contains_incomplete_tile_(false), 90 swap_contains_incomplete_tile_(false),
86 redraw_will_happen_if_update_visible_tiles_happens_(false), 91 redraw_will_happen_if_update_visible_tiles_happens_(false),
87 now_src_(TestNowSource::Create()), 92 now_src_(TestNowSource::Create()),
88 task_runner_(new OrderedSimpleTaskRunner(now_src_, true)), 93 task_runner_(new OrderedSimpleTaskRunner(now_src_, true)),
89 fake_frame_source_(this), 94 fake_external_begin_frame_source_(nullptr),
90 fake_power_monitor_source_(new FakePowerMonitorSource), 95 fake_power_monitor_source_(new FakePowerMonitorSource),
91 power_monitor_(make_scoped_ptr<base::PowerMonitorSource>( 96 power_monitor_(make_scoped_ptr<base::PowerMonitorSource>(
92 fake_power_monitor_source_)), 97 fake_power_monitor_source_)),
93 scheduler_(nullptr) { 98 scheduler_(nullptr) {
94 // A bunch of tests require Now() to be > BeginFrameArgs::DefaultInterval() 99 // A bunch of tests require Now() to be > BeginFrameArgs::DefaultInterval()
95 now_src_->AdvanceNow(base::TimeDelta::FromMilliseconds(100)); 100 now_src_->AdvanceNow(base::TimeDelta::FromMilliseconds(100));
96 // Fail if we need to run 100 tasks in a row. 101 // Fail if we need to run 100 tasks in a row.
97 task_runner_->SetRunTaskLimit(100); 102 task_runner_->SetRunTaskLimit(100);
98 Reset(); 103 Reset();
99 } 104 }
100 105
101 void Reset() { 106 void Reset() {
102 actions_.clear(); 107 actions_.clear();
103 states_.clear(); 108 states_.clear();
104 draw_will_happen_ = true; 109 draw_will_happen_ = true;
105 swap_will_happen_if_draw_happens_ = true; 110 swap_will_happen_if_draw_happens_ = true;
106 num_draws_ = 0; 111 num_draws_ = 0;
107 log_anticipated_draw_time_change_ = false; 112 log_anticipated_draw_time_change_ = false;
108 } 113 }
109 114
110 TestScheduler* CreateScheduler(const SchedulerSettings& settings) { 115 TestScheduler* CreateScheduler(const SchedulerSettings& settings) {
111 scheduler_ = TestScheduler::Create( 116 scoped_ptr<FakeExternalBeginFrameSource> fake_external_begin_frame_source;
112 now_src_, this, settings, 0, task_runner_, &power_monitor_); 117 if (settings.begin_frame_scheduling_enabled &&
118 settings.throttle_frame_production) {
119 fake_external_begin_frame_source.reset(
120 new FakeExternalBeginFrameSource(this));
121 fake_external_begin_frame_source_ =
122 fake_external_begin_frame_source.get();
123 }
124 scheduler_ = TestScheduler::Create(now_src_,
125 this,
126 settings,
127 0,
128 task_runner_,
129 &power_monitor_,
130 fake_external_begin_frame_source.Pass());
113 DCHECK(scheduler_); 131 DCHECK(scheduler_);
114 return scheduler_.get(); 132 return scheduler_.get();
115 } 133 }
116 134
117 // Most tests don't care about DidAnticipatedDrawTimeChange, so only record it 135 // Most tests don't care about DidAnticipatedDrawTimeChange, so only record it
118 // for tests that do. 136 // for tests that do.
119 void set_log_anticipated_draw_time_change(bool log) { 137 void set_log_anticipated_draw_time_change(bool log) {
120 log_anticipated_draw_time_change_ = log; 138 log_anticipated_draw_time_change_ = log;
121 } 139 }
122 bool needs_begin_frames() { return fake_frame_source_.NeedsBeginFrames(); } 140 bool needs_begin_frames() {
141 DCHECK(ExternalBeginFrame());
142 return fake_external_begin_frame_source_->NeedsBeginFrames();
143 }
123 int num_draws() const { return num_draws_; } 144 int num_draws() const { return num_draws_; }
124 int num_actions_() const { return static_cast<int>(actions_.size()); } 145 int num_actions_() const { return static_cast<int>(actions_.size()); }
125 const char* Action(int i) const { return actions_[i]; } 146 const char* Action(int i) const { return actions_[i]; }
126 std::string StateForAction(int i) const { return states_[i]->ToString(); } 147 std::string StateForAction(int i) const { return states_[i]->ToString(); }
127 base::TimeTicks posted_begin_impl_frame_deadline() const { 148 base::TimeTicks posted_begin_impl_frame_deadline() const {
128 return posted_begin_impl_frame_deadline_; 149 return posted_begin_impl_frame_deadline_;
129 } 150 }
130 151
131 bool ExternalBeginFrame() { 152 bool ExternalBeginFrame() {
132 return scheduler_->settings().begin_frame_scheduling_enabled && 153 return scheduler_->settings().begin_frame_scheduling_enabled &&
133 scheduler_->settings().throttle_frame_production; 154 scheduler_->settings().throttle_frame_production;
134 } 155 }
135 FakeBeginFrameSource* ExternalBeginFrameSource() override { 156
136 return &fake_frame_source_; 157 FakeExternalBeginFrameSource* fake_external_begin_frame_source() const {
158 return fake_external_begin_frame_source_;
137 } 159 }
138 160
139 base::PowerMonitor* PowerMonitor() { return &power_monitor_; } 161 base::PowerMonitor* PowerMonitor() { return &power_monitor_; }
140 162
141 FakePowerMonitorSource* PowerMonitorSource() { 163 FakePowerMonitorSource* PowerMonitorSource() {
142 return fake_power_monitor_source_; 164 return fake_power_monitor_source_;
143 } 165 }
144 166
145 void AdvanceFrame() { 167 void AdvanceFrame() {
146 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), 168 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"),
147 "FakeSchedulerClient::AdvanceFrame"); 169 "FakeSchedulerClient::AdvanceFrame");
148 // EXPECT_TRUE(needs_begin_frames());
149 if (ExternalBeginFrame()) { 170 if (ExternalBeginFrame()) {
150 // Creep the time forward so that any BeginFrameArgs is not equal to the 171 // Creep the time forward so that any BeginFrameArgs is not equal to the
151 // last one otherwise we violate the BeginFrameSource contract. 172 // last one otherwise we violate the BeginFrameSource contract.
152 now_src_->AdvanceNowMicroseconds(1); 173 now_src_->AdvanceNowMicroseconds(1);
153 fake_frame_source_.TestOnBeginFrame( 174 fake_external_begin_frame_source_->TestOnBeginFrame(
154 CreateBeginFrameArgsForTesting(now_src_)); 175 CreateBeginFrameArgsForTesting(now_src_));
155 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); 176 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
156 } 177 }
157 178
158 EXPECT_TRUE(task_runner().RunTasksWhile(ImplFrameDeadlinePending(false))); 179 EXPECT_TRUE(task_runner().RunTasksWhile(ImplFrameDeadlinePending(false)));
159 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); 180 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
160 } 181 }
161 182
162 OrderedSimpleTaskRunner& task_runner() { return *task_runner_; } 183 OrderedSimpleTaskRunner& task_runner() { return *task_runner_; }
163 TestNowSource* now_src() { return now_src_.get(); } 184 TestNowSource* now_src() { return now_src_.get(); }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 bool automatic_swap_ack_; 302 bool automatic_swap_ack_;
282 int num_draws_; 303 int num_draws_;
283 bool log_anticipated_draw_time_change_; 304 bool log_anticipated_draw_time_change_;
284 bool swap_contains_incomplete_tile_; 305 bool swap_contains_incomplete_tile_;
285 bool redraw_will_happen_if_update_visible_tiles_happens_; 306 bool redraw_will_happen_if_update_visible_tiles_happens_;
286 base::TimeTicks posted_begin_impl_frame_deadline_; 307 base::TimeTicks posted_begin_impl_frame_deadline_;
287 std::vector<const char*> actions_; 308 std::vector<const char*> actions_;
288 std::vector<scoped_refptr<base::debug::ConvertableToTraceFormat>> states_; 309 std::vector<scoped_refptr<base::debug::ConvertableToTraceFormat>> states_;
289 scoped_refptr<TestNowSource> now_src_; 310 scoped_refptr<TestNowSource> now_src_;
290 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; 311 scoped_refptr<OrderedSimpleTaskRunner> task_runner_;
291 FakeBeginFrameSourceForFakeSchedulerClient fake_frame_source_; 312 FakeExternalBeginFrameSource* fake_external_begin_frame_source_;
292 FakePowerMonitorSource* fake_power_monitor_source_; 313 FakePowerMonitorSource* fake_power_monitor_source_;
293 base::PowerMonitor power_monitor_; 314 base::PowerMonitor power_monitor_;
294 scoped_ptr<TestScheduler> scheduler_; 315 scoped_ptr<TestScheduler> scheduler_;
295 }; 316 };
296 317
297 void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler, 318 void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler,
298 FakeSchedulerClient* client) { 319 FakeSchedulerClient* client) {
299 TRACE_EVENT0("cc", 320 TRACE_EVENT0("cc",
300 "SchedulerUnitTest::InitializeOutputSurfaceAndFirstCommit"); 321 "SchedulerUnitTest::InitializeOutputSurfaceAndFirstCommit");
301 322
(...skipping 18 matching lines...) Expand all
320 SCOPED_TRACE( 341 SCOPED_TRACE(
321 "We need another BeginImplFrame so Scheduler calls " 342 "We need another BeginImplFrame so Scheduler calls "
322 "SetNeedsBeginFrame(false)."); 343 "SetNeedsBeginFrame(false).");
323 client->AdvanceFrame(); 344 client->AdvanceFrame();
324 } 345 }
325 346
326 // Run the posted deadline task. 347 // Run the posted deadline task.
327 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 348 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
328 client->task_runner().RunTasksWhile(client->ImplFrameDeadlinePending(true)); 349 client->task_runner().RunTasksWhile(client->ImplFrameDeadlinePending(true));
329 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 350 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
330
331 // EXPECT_FALSE(client->needs_begin_frames());
332 } 351 }
333 352
334 TEST(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) { 353 TEST(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) {
335 FakeSchedulerClient client; 354 FakeSchedulerClient client;
336 SchedulerSettings default_scheduler_settings; 355 SchedulerSettings default_scheduler_settings;
337 TestScheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 356 TestScheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
338 scheduler->SetCanStart(); 357 scheduler->SetCanStart();
339 scheduler->SetVisible(true); 358 scheduler->SetVisible(true);
340 scheduler->SetCanDraw(true); 359 scheduler->SetCanDraw(true);
341 360
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 scheduler->DidCreateAndInitializeOutputSurface(); 1191 scheduler->DidCreateAndInitializeOutputSurface();
1173 1192
1174 scheduler->SetNeedsCommit(); 1193 scheduler->SetNeedsCommit();
1175 EXPECT_TRUE(scheduler->CommitPending()); 1194 EXPECT_TRUE(scheduler->CommitPending());
1176 scheduler->NotifyBeginMainFrameStarted(); 1195 scheduler->NotifyBeginMainFrameStarted();
1177 scheduler->NotifyReadyToCommit(); 1196 scheduler->NotifyReadyToCommit();
1178 scheduler->SetNeedsRedraw(); 1197 scheduler->SetNeedsRedraw();
1179 1198
1180 BeginFrameArgs frame_args = CreateBeginFrameArgsForTesting(client.now_src()); 1199 BeginFrameArgs frame_args = CreateBeginFrameArgsForTesting(client.now_src());
1181 frame_args.interval = base::TimeDelta::FromMilliseconds(1000); 1200 frame_args.interval = base::TimeDelta::FromMilliseconds(1000);
1182 client.ExternalBeginFrameSource()->TestOnBeginFrame(frame_args); 1201 client.fake_external_begin_frame_source()->TestOnBeginFrame(frame_args);
1183 1202
1184 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1203 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1185 client.task_runner().RunPendingTasks(); // Run posted deadline. 1204 client.task_runner().RunPendingTasks(); // Run posted deadline.
1186 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1205 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1187 1206
1188 scheduler->DidSwapBuffers(); 1207 scheduler->DidSwapBuffers();
1189 scheduler->DidSwapBuffersComplete(); 1208 scheduler->DidSwapBuffersComplete();
1190 1209
1191 // At this point, we've drawn a frame. Start another commit, but hold off on 1210 // At this point, we've drawn a frame. Start another commit, but hold off on
1192 // the NotifyReadyToCommit for now. 1211 // the NotifyReadyToCommit for now.
1193 EXPECT_FALSE(scheduler->CommitPending()); 1212 EXPECT_FALSE(scheduler->CommitPending());
1194 scheduler->SetNeedsCommit(); 1213 scheduler->SetNeedsCommit();
1195 client.ExternalBeginFrameSource()->TestOnBeginFrame(frame_args); 1214 client.fake_external_begin_frame_source()->TestOnBeginFrame(frame_args);
1196 EXPECT_TRUE(scheduler->CommitPending()); 1215 EXPECT_TRUE(scheduler->CommitPending());
1197 1216
1198 // Draw and swap the frame, but don't ack the swap to simulate the Browser 1217 // Draw and swap the frame, but don't ack the swap to simulate the Browser
1199 // blocking on the renderer. 1218 // blocking on the renderer.
1200 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1219 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1201 client.task_runner().RunPendingTasks(); // Run posted deadline. 1220 client.task_runner().RunPendingTasks(); // Run posted deadline.
1202 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1221 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1203 scheduler->DidSwapBuffers(); 1222 scheduler->DidSwapBuffers();
1204 1223
1205 // Spin the event loop a few times and make sure we get more 1224 // Spin the event loop a few times and make sure we get more
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 // SetNeedsCommit should begin the frame on the next BeginImplFrame. 1263 // SetNeedsCommit should begin the frame on the next BeginImplFrame.
1245 client.Reset(); 1264 client.Reset();
1246 scheduler->SetNeedsCommit(); 1265 scheduler->SetNeedsCommit();
1247 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client); 1266 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client);
1248 client.Reset(); 1267 client.Reset();
1249 1268
1250 // Create a BeginFrame with a long deadline to avoid race conditions. 1269 // Create a BeginFrame with a long deadline to avoid race conditions.
1251 // This is the first BeginFrame, which will be handled immediately. 1270 // This is the first BeginFrame, which will be handled immediately.
1252 BeginFrameArgs args = CreateBeginFrameArgsForTesting(client.now_src()); 1271 BeginFrameArgs args = CreateBeginFrameArgsForTesting(client.now_src());
1253 args.deadline += base::TimeDelta::FromHours(1); 1272 args.deadline += base::TimeDelta::FromHours(1);
1254 client.ExternalBeginFrameSource()->TestOnBeginFrame(args); 1273 client.fake_external_begin_frame_source()->TestOnBeginFrame(args);
1255 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 1274 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1256 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 1275 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
1257 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1276 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1258 EXPECT_TRUE(client.needs_begin_frames()); 1277 EXPECT_TRUE(client.needs_begin_frames());
1259 client.Reset(); 1278 client.Reset();
1260 1279
1261 // Queue BeginFrames while we are still handling the previous BeginFrame. 1280 // Queue BeginFrames while we are still handling the previous BeginFrame.
1262 args.frame_time += base::TimeDelta::FromSeconds(1); 1281 args.frame_time += base::TimeDelta::FromSeconds(1);
1263 client.ExternalBeginFrameSource()->TestOnBeginFrame(args); 1282 client.fake_external_begin_frame_source()->TestOnBeginFrame(args);
1264 args.frame_time += base::TimeDelta::FromSeconds(1); 1283 args.frame_time += base::TimeDelta::FromSeconds(1);
1265 client.ExternalBeginFrameSource()->TestOnBeginFrame(args); 1284 client.fake_external_begin_frame_source()->TestOnBeginFrame(args);
1266 1285
1267 // If we don't swap on the deadline, we wait for the next BeginImplFrame. 1286 // If we don't swap on the deadline, we wait for the next BeginImplFrame.
1268 client.task_runner().RunPendingTasks(); // Run posted deadline. 1287 client.task_runner().RunPendingTasks(); // Run posted deadline.
1269 EXPECT_NO_ACTION(client); 1288 EXPECT_NO_ACTION(client);
1270 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1289 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1271 EXPECT_TRUE(client.needs_begin_frames()); 1290 EXPECT_TRUE(client.needs_begin_frames());
1272 client.Reset(); 1291 client.Reset();
1273 1292
1274 // NotifyReadyToCommit should trigger the commit. 1293 // NotifyReadyToCommit should trigger the commit.
1275 scheduler->NotifyBeginMainFrameStarted(); 1294 scheduler->NotifyBeginMainFrameStarted();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 // SetNeedsCommit should begin the frame on the next BeginImplFrame. 1340 // SetNeedsCommit should begin the frame on the next BeginImplFrame.
1322 client.Reset(); 1341 client.Reset();
1323 scheduler->SetNeedsCommit(); 1342 scheduler->SetNeedsCommit();
1324 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client); 1343 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client);
1325 client.Reset(); 1344 client.Reset();
1326 1345
1327 // Create a BeginFrame with a long deadline to avoid race conditions. 1346 // Create a BeginFrame with a long deadline to avoid race conditions.
1328 // This is the first BeginFrame, which will be handled immediately. 1347 // This is the first BeginFrame, which will be handled immediately.
1329 BeginFrameArgs args = CreateBeginFrameArgsForTesting(client.now_src()); 1348 BeginFrameArgs args = CreateBeginFrameArgsForTesting(client.now_src());
1330 args.deadline += base::TimeDelta::FromHours(1); 1349 args.deadline += base::TimeDelta::FromHours(1);
1331 client.ExternalBeginFrameSource()->TestOnBeginFrame(args); 1350 client.fake_external_begin_frame_source()->TestOnBeginFrame(args);
1332 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 1351 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1333 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 1352 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
1334 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1353 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1335 EXPECT_TRUE(client.needs_begin_frames()); 1354 EXPECT_TRUE(client.needs_begin_frames());
1336 client.Reset(); 1355 client.Reset();
1337 1356
1338 // Queue BeginFrame while we are still handling the previous BeginFrame. 1357 // Queue BeginFrame while we are still handling the previous BeginFrame.
1339 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1358 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1340 args.frame_time += base::TimeDelta::FromSeconds(1); 1359 args.frame_time += base::TimeDelta::FromSeconds(1);
1341 client.ExternalBeginFrameSource()->TestOnBeginFrame(args); 1360 client.fake_external_begin_frame_source()->TestOnBeginFrame(args);
1342 EXPECT_NO_ACTION(client); 1361 EXPECT_NO_ACTION(client);
1343 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1362 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1344 client.Reset(); 1363 client.Reset();
1345 1364
1346 // NotifyReadyToCommit should trigger the pending commit and draw. 1365 // NotifyReadyToCommit should trigger the pending commit and draw.
1347 scheduler->NotifyBeginMainFrameStarted(); 1366 scheduler->NotifyBeginMainFrameStarted();
1348 scheduler->NotifyReadyToCommit(); 1367 scheduler->NotifyReadyToCommit();
1349 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 1368 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
1350 EXPECT_TRUE(client.needs_begin_frames()); 1369 EXPECT_TRUE(client.needs_begin_frames());
1351 client.Reset(); 1370 client.Reset();
(...skipping 10 matching lines...) Expand all
1362 // but not a BeginMainFrame or draw. 1381 // but not a BeginMainFrame or draw.
1363 scheduler->SetNeedsCommit(); 1382 scheduler->SetNeedsCommit();
1364 client.task_runner().RunPendingTasks(); // Run posted BeginRetroFrame. 1383 client.task_runner().RunPendingTasks(); // Run posted BeginRetroFrame.
1365 EXPECT_ACTION("WillBeginImplFrame", client, 0, 1); 1384 EXPECT_ACTION("WillBeginImplFrame", client, 0, 1);
1366 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1385 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1367 EXPECT_TRUE(client.needs_begin_frames()); 1386 EXPECT_TRUE(client.needs_begin_frames());
1368 client.Reset(); 1387 client.Reset();
1369 1388
1370 // Queue BeginFrame while we are still handling the previous BeginFrame. 1389 // Queue BeginFrame while we are still handling the previous BeginFrame.
1371 args.frame_time += base::TimeDelta::FromSeconds(1); 1390 args.frame_time += base::TimeDelta::FromSeconds(1);
1372 client.ExternalBeginFrameSource()->TestOnBeginFrame(args); 1391 client.fake_external_begin_frame_source()->TestOnBeginFrame(args);
1373 EXPECT_NO_ACTION(client); 1392 EXPECT_NO_ACTION(client);
1374 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1393 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1375 EXPECT_TRUE(client.needs_begin_frames()); 1394 EXPECT_TRUE(client.needs_begin_frames());
1376 client.Reset(); 1395 client.Reset();
1377 1396
1378 // Take us out of a swap throttled state. 1397 // Take us out of a swap throttled state.
1379 scheduler->DidSwapBuffersComplete(); 1398 scheduler->DidSwapBuffersComplete();
1380 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 0, 1); 1399 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 0, 1);
1381 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1400 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1382 EXPECT_TRUE(client.needs_begin_frames()); 1401 EXPECT_TRUE(client.needs_begin_frames());
(...skipping 18 matching lines...) Expand all
1401 SchedulerSettings scheduler_settings; 1420 SchedulerSettings scheduler_settings;
1402 scheduler_settings.begin_frame_scheduling_enabled = 1421 scheduler_settings.begin_frame_scheduling_enabled =
1403 begin_frame_scheduling_enabled; 1422 begin_frame_scheduling_enabled;
1404 scheduler_settings.throttle_frame_production = throttle_frame_production; 1423 scheduler_settings.throttle_frame_production = throttle_frame_production;
1405 TestScheduler* scheduler = client.CreateScheduler(scheduler_settings); 1424 TestScheduler* scheduler = client.CreateScheduler(scheduler_settings);
1406 scheduler->SetCanStart(); 1425 scheduler->SetCanStart();
1407 scheduler->SetVisible(true); 1426 scheduler->SetVisible(true);
1408 scheduler->SetCanDraw(true); 1427 scheduler->SetCanDraw(true);
1409 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 1428 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
1410 1429
1430 DCHECK(!client.fake_external_begin_frame_source());
1431
1411 // SetNeedsCommit should begin the frame on the next BeginImplFrame 1432 // SetNeedsCommit should begin the frame on the next BeginImplFrame
1412 // without calling SetNeedsBeginFrame. 1433 // without calling SetNeedsBeginFrame.
1413 client.Reset(); 1434 client.Reset();
1414 scheduler->SetNeedsCommit(); 1435 scheduler->SetNeedsCommit();
1415 EXPECT_FALSE(client.needs_begin_frames());
1416 EXPECT_NO_ACTION(client); 1436 EXPECT_NO_ACTION(client);
1417 client.Reset(); 1437 client.Reset();
1418 1438
1419 // When the client-driven BeginFrame are disabled, the scheduler posts it's 1439 // When the client-driven BeginFrame are disabled, the scheduler posts it's
1420 // own BeginFrame tasks. 1440 // own BeginFrame tasks.
1421 client.task_runner().RunPendingTasks(); // Run posted BeginFrame. 1441 client.task_runner().RunPendingTasks(); // Run posted BeginFrame.
1422 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 1442 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1423 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 1443 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
1424 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1444 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1425 EXPECT_FALSE(client.needs_begin_frames());
1426 client.Reset(); 1445 client.Reset();
1427 1446
1428 // If we don't swap on the deadline, we wait for the next BeginFrame. 1447 // If we don't swap on the deadline, we wait for the next BeginFrame.
1429 client.task_runner().RunPendingTasks(); // Run posted deadline. 1448 client.task_runner().RunPendingTasks(); // Run posted deadline.
1430 EXPECT_NO_ACTION(client); 1449 EXPECT_NO_ACTION(client);
1431 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1450 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1432 EXPECT_FALSE(client.needs_begin_frames());
1433 client.Reset(); 1451 client.Reset();
1434 1452
1435 // NotifyReadyToCommit should trigger the commit. 1453 // NotifyReadyToCommit should trigger the commit.
1436 scheduler->NotifyBeginMainFrameStarted(); 1454 scheduler->NotifyBeginMainFrameStarted();
1437 scheduler->NotifyReadyToCommit(); 1455 scheduler->NotifyReadyToCommit();
1438 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 1456 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
1439 EXPECT_FALSE(client.needs_begin_frames());
1440 client.Reset(); 1457 client.Reset();
1441 1458
1442 // BeginImplFrame should prepare the draw. 1459 // BeginImplFrame should prepare the draw.
1443 client.task_runner().RunPendingTasks(); // Run posted BeginFrame. 1460 client.task_runner().RunPendingTasks(); // Run posted BeginFrame.
1444 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 1461 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1445 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); 1462 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
1446 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1463 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1447 EXPECT_FALSE(client.needs_begin_frames());
1448 client.Reset(); 1464 client.Reset();
1449 1465
1450 // BeginImplFrame deadline should draw. 1466 // BeginImplFrame deadline should draw.
1451 client.task_runner().RunTasksWhile(client.ImplFrameDeadlinePending(true)); 1467 client.task_runner().RunTasksWhile(client.ImplFrameDeadlinePending(true));
1452 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); 1468 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1);
1453 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1469 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1454 EXPECT_FALSE(client.needs_begin_frames());
1455 client.Reset(); 1470 client.Reset();
1456 1471
1457 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) 1472 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false)
1458 // to avoid excessive toggles. 1473 // to avoid excessive toggles.
1459 client.task_runner().RunPendingTasks(); // Run posted BeginFrame. 1474 client.task_runner().RunPendingTasks(); // Run posted BeginFrame.
1460 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); 1475 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client);
1461 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1476 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1462 client.Reset(); 1477 client.Reset();
1463 1478
1464 // Make sure SetNeedsBeginFrame isn't called on the client 1479 // Make sure SetNeedsBeginFrame isn't called on the client
1465 // when the BeginFrame is no longer needed. 1480 // when the BeginFrame is no longer needed.
1466 client.task_runner().RunPendingTasks(); // Run posted deadline. 1481 client.task_runner().RunPendingTasks(); // Run posted deadline.
1467 EXPECT_NO_ACTION(client); 1482 EXPECT_NO_ACTION(client);
1468 EXPECT_FALSE(client.needs_begin_frames());
1469 client.Reset(); 1483 client.Reset();
1470 } 1484 }
1471 1485
1472 TEST(SchedulerTest, SyntheticBeginFrames) { 1486 TEST(SchedulerTest, SyntheticBeginFrames) {
1473 bool begin_frame_scheduling_enabled = false; 1487 bool begin_frame_scheduling_enabled = false;
1474 bool throttle_frame_production = true; 1488 bool throttle_frame_production = true;
1475 BeginFramesNotFromClient(begin_frame_scheduling_enabled, 1489 BeginFramesNotFromClient(begin_frame_scheduling_enabled,
1476 throttle_frame_production); 1490 throttle_frame_production);
1477 } 1491 }
1478 1492
(...skipping 17 matching lines...) Expand all
1496 SchedulerSettings scheduler_settings; 1510 SchedulerSettings scheduler_settings;
1497 scheduler_settings.begin_frame_scheduling_enabled = 1511 scheduler_settings.begin_frame_scheduling_enabled =
1498 begin_frame_scheduling_enabled; 1512 begin_frame_scheduling_enabled;
1499 scheduler_settings.throttle_frame_production = throttle_frame_production; 1513 scheduler_settings.throttle_frame_production = throttle_frame_production;
1500 TestScheduler* scheduler = client.CreateScheduler(scheduler_settings); 1514 TestScheduler* scheduler = client.CreateScheduler(scheduler_settings);
1501 scheduler->SetCanStart(); 1515 scheduler->SetCanStart();
1502 scheduler->SetVisible(true); 1516 scheduler->SetVisible(true);
1503 scheduler->SetCanDraw(true); 1517 scheduler->SetCanDraw(true);
1504 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 1518 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
1505 1519
1520 DCHECK(!client.fake_external_begin_frame_source());
1521
1506 // To test swap ack throttling, this test disables automatic swap acks. 1522 // To test swap ack throttling, this test disables automatic swap acks.
1507 scheduler->SetMaxSwapsPending(1); 1523 scheduler->SetMaxSwapsPending(1);
1508 client.SetAutomaticSwapAck(false); 1524 client.SetAutomaticSwapAck(false);
1509 1525
1510 // SetNeedsCommit should begin the frame on the next BeginImplFrame. 1526 // SetNeedsCommit should begin the frame on the next BeginImplFrame.
1511 client.Reset(); 1527 client.Reset();
1512 scheduler->SetNeedsCommit(); 1528 scheduler->SetNeedsCommit();
1513 EXPECT_FALSE(client.needs_begin_frames());
1514 EXPECT_NO_ACTION(client); 1529 EXPECT_NO_ACTION(client);
1515 client.Reset(); 1530 client.Reset();
1516 1531
1517 // Trigger the first BeginImplFrame and BeginMainFrame 1532 // Trigger the first BeginImplFrame and BeginMainFrame
1518 client.task_runner().RunPendingTasks(); // Run posted BeginFrame. 1533 client.task_runner().RunPendingTasks(); // Run posted BeginFrame.
1519 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 1534 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1520 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 1535 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
1521 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1536 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1522 EXPECT_FALSE(client.needs_begin_frames());
1523 client.Reset(); 1537 client.Reset();
1524 1538
1525 // NotifyReadyToCommit should trigger the pending commit and draw. 1539 // NotifyReadyToCommit should trigger the pending commit and draw.
1526 scheduler->NotifyBeginMainFrameStarted(); 1540 scheduler->NotifyBeginMainFrameStarted();
1527 scheduler->NotifyReadyToCommit(); 1541 scheduler->NotifyReadyToCommit();
1528 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 1542 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
1529 EXPECT_FALSE(client.needs_begin_frames());
1530 client.Reset(); 1543 client.Reset();
1531 1544
1532 // Swapping will put us into a swap throttled state. 1545 // Swapping will put us into a swap throttled state.
1533 client.task_runner().RunPendingTasks(); // Run posted deadline. 1546 client.task_runner().RunPendingTasks(); // Run posted deadline.
1534 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); 1547 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2);
1535 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); 1548 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2);
1536 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1549 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1537 EXPECT_FALSE(client.needs_begin_frames());
1538 client.Reset(); 1550 client.Reset();
1539 1551
1540 // While swap throttled, BeginFrames should trigger BeginImplFrames, 1552 // While swap throttled, BeginFrames should trigger BeginImplFrames,
1541 // but not a BeginMainFrame or draw. 1553 // but not a BeginMainFrame or draw.
1542 scheduler->SetNeedsCommit(); 1554 scheduler->SetNeedsCommit();
1543 client.task_runner().RunPendingTasks(); // Run posted BeginFrame. 1555 client.task_runner().RunPendingTasks(); // Run posted BeginFrame.
1544 EXPECT_ACTION("WillBeginImplFrame", client, 0, 1); 1556 EXPECT_ACTION("WillBeginImplFrame", client, 0, 1);
1545 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1557 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1546 EXPECT_FALSE(client.needs_begin_frames());
1547 client.Reset(); 1558 client.Reset();
1548 1559
1549 // Take us out of a swap throttled state. 1560 // Take us out of a swap throttled state.
1550 scheduler->DidSwapBuffersComplete(); 1561 scheduler->DidSwapBuffersComplete();
1551 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 0, 1); 1562 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 0, 1);
1552 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1563 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1553 EXPECT_FALSE(client.needs_begin_frames());
1554 client.Reset(); 1564 client.Reset();
1555 1565
1556 // BeginImplFrame deadline should draw. 1566 // BeginImplFrame deadline should draw.
1557 scheduler->SetNeedsRedraw(); 1567 scheduler->SetNeedsRedraw();
1558 client.task_runner().RunPendingTasks(); // Run posted deadline. 1568 client.task_runner().RunPendingTasks(); // Run posted deadline.
1559 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); 1569 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2);
1560 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); 1570 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2);
1561 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1571 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1562 EXPECT_FALSE(client.needs_begin_frames());
1563 client.Reset(); 1572 client.Reset();
1564 } 1573 }
1565 1574
1566 TEST(SchedulerTest, SyntheticBeginFrames_SwapThrottled) { 1575 TEST(SchedulerTest, SyntheticBeginFrames_SwapThrottled) {
1567 bool begin_frame_scheduling_enabled = false; 1576 bool begin_frame_scheduling_enabled = false;
1568 bool throttle_frame_production = true; 1577 bool throttle_frame_production = true;
1569 BeginFramesNotFromClient_SwapThrottled(begin_frame_scheduling_enabled, 1578 BeginFramesNotFromClient_SwapThrottled(begin_frame_scheduling_enabled,
1570 throttle_frame_production); 1579 throttle_frame_production);
1571 } 1580 }
1572 1581
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1799 // SetNeedsCommit should begin the frame on the next BeginImplFrame. 1808 // SetNeedsCommit should begin the frame on the next BeginImplFrame.
1800 client.Reset(); 1809 client.Reset();
1801 scheduler->SetNeedsCommit(); 1810 scheduler->SetNeedsCommit();
1802 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client); 1811 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client);
1803 1812
1804 // Create a BeginFrame with a long deadline to avoid race conditions. 1813 // Create a BeginFrame with a long deadline to avoid race conditions.
1805 // This is the first BeginFrame, which will be handled immediately. 1814 // This is the first BeginFrame, which will be handled immediately.
1806 client.Reset(); 1815 client.Reset();
1807 BeginFrameArgs args = CreateBeginFrameArgsForTesting(client.now_src()); 1816 BeginFrameArgs args = CreateBeginFrameArgsForTesting(client.now_src());
1808 args.deadline += base::TimeDelta::FromHours(1); 1817 args.deadline += base::TimeDelta::FromHours(1);
1809 client.ExternalBeginFrameSource()->TestOnBeginFrame(args); 1818 client.fake_external_begin_frame_source()->TestOnBeginFrame(args);
1810 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 1819 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1811 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 1820 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
1812 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1821 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1813 EXPECT_TRUE(client.needs_begin_frames()); 1822 EXPECT_TRUE(client.needs_begin_frames());
1814 1823
1815 // Queue BeginFrames while we are still handling the previous BeginFrame. 1824 // Queue BeginFrames while we are still handling the previous BeginFrame.
1816 args.frame_time += base::TimeDelta::FromSeconds(1); 1825 args.frame_time += base::TimeDelta::FromSeconds(1);
1817 client.ExternalBeginFrameSource()->TestOnBeginFrame(args); 1826 client.fake_external_begin_frame_source()->TestOnBeginFrame(args);
1818 args.frame_time += base::TimeDelta::FromSeconds(1); 1827 args.frame_time += base::TimeDelta::FromSeconds(1);
1819 client.ExternalBeginFrameSource()->TestOnBeginFrame(args); 1828 client.fake_external_begin_frame_source()->TestOnBeginFrame(args);
1820 1829
1821 // If we don't swap on the deadline, we wait for the next BeginImplFrame. 1830 // If we don't swap on the deadline, we wait for the next BeginImplFrame.
1822 client.Reset(); 1831 client.Reset();
1823 client.task_runner().RunPendingTasks(); // Run posted deadline. 1832 client.task_runner().RunPendingTasks(); // Run posted deadline.
1824 EXPECT_NO_ACTION(client); 1833 EXPECT_NO_ACTION(client);
1825 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1834 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1826 EXPECT_TRUE(client.needs_begin_frames()); 1835 EXPECT_TRUE(client.needs_begin_frames());
1827 1836
1828 // NotifyReadyToCommit should trigger the commit. 1837 // NotifyReadyToCommit should trigger the commit.
1829 client.Reset(); 1838 client.Reset();
(...skipping 27 matching lines...) Expand all
1857 // SetNeedsCommit should begin the frame on the next BeginImplFrame. 1866 // SetNeedsCommit should begin the frame on the next BeginImplFrame.
1858 client.Reset(); 1867 client.Reset();
1859 scheduler->SetNeedsCommit(); 1868 scheduler->SetNeedsCommit();
1860 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client); 1869 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client);
1861 1870
1862 // Create a BeginFrame with a long deadline to avoid race conditions. 1871 // Create a BeginFrame with a long deadline to avoid race conditions.
1863 // This is the first BeginFrame, which will be handled immediately. 1872 // This is the first BeginFrame, which will be handled immediately.
1864 client.Reset(); 1873 client.Reset();
1865 BeginFrameArgs args = CreateBeginFrameArgsForTesting(client.now_src()); 1874 BeginFrameArgs args = CreateBeginFrameArgsForTesting(client.now_src());
1866 args.deadline += base::TimeDelta::FromHours(1); 1875 args.deadline += base::TimeDelta::FromHours(1);
1867 client.ExternalBeginFrameSource()->TestOnBeginFrame(args); 1876 client.fake_external_begin_frame_source()->TestOnBeginFrame(args);
1868 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 1877 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1869 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 1878 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
1870 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1879 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1871 EXPECT_TRUE(client.needs_begin_frames()); 1880 EXPECT_TRUE(client.needs_begin_frames());
1872 1881
1873 // Queue BeginFrames while we are still handling the previous BeginFrame. 1882 // Queue BeginFrames while we are still handling the previous BeginFrame.
1874 args.frame_time += base::TimeDelta::FromSeconds(1); 1883 args.frame_time += base::TimeDelta::FromSeconds(1);
1875 client.ExternalBeginFrameSource()->TestOnBeginFrame(args); 1884 client.fake_external_begin_frame_source()->TestOnBeginFrame(args);
1876 args.frame_time += base::TimeDelta::FromSeconds(1); 1885 args.frame_time += base::TimeDelta::FromSeconds(1);
1877 client.ExternalBeginFrameSource()->TestOnBeginFrame(args); 1886 client.fake_external_begin_frame_source()->TestOnBeginFrame(args);
1878 1887
1879 // If we don't swap on the deadline, we wait for the next BeginImplFrame. 1888 // If we don't swap on the deadline, we wait for the next BeginImplFrame.
1880 client.Reset(); 1889 client.Reset();
1881 client.task_runner().RunPendingTasks(); // Run posted deadline. 1890 client.task_runner().RunPendingTasks(); // Run posted deadline.
1882 EXPECT_NO_ACTION(client); 1891 EXPECT_NO_ACTION(client);
1883 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1892 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1884 EXPECT_TRUE(client.needs_begin_frames()); 1893 EXPECT_TRUE(client.needs_begin_frames());
1885 1894
1886 // NotifyReadyToCommit should trigger the commit. 1895 // NotifyReadyToCommit should trigger the commit.
1887 client.Reset(); 1896 client.Reset();
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
2136 2145
2137 // Deadline task is pending 2146 // Deadline task is pending
2138 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 2147 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
2139 client.task_runner().RunPendingTasks(); 2148 client.task_runner().RunPendingTasks();
2140 // Deadline task runs immediately 2149 // Deadline task runs immediately
2141 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 2150 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
2142 } 2151 }
2143 2152
2144 } // namespace 2153 } // namespace
2145 } // namespace cc 2154 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler.cc ('k') | cc/surfaces/display.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698