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

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

Issue 1184863004: cc: Move timing history to the Scheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add cc:: Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « cc/scheduler/scheduler.cc ('k') | cc/test/scheduler_test_common.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 4
5 #include "cc/scheduler/scheduler.h" 5 #include "cc/scheduler/scheduler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 void ScheduledActionBeginOutputSurfaceCreation() override { 134 void ScheduledActionBeginOutputSurfaceCreation() override {
135 PushAction("ScheduledActionBeginOutputSurfaceCreation"); 135 PushAction("ScheduledActionBeginOutputSurfaceCreation");
136 } 136 }
137 void ScheduledActionPrepareTiles() override { 137 void ScheduledActionPrepareTiles() override {
138 PushAction("ScheduledActionPrepareTiles"); 138 PushAction("ScheduledActionPrepareTiles");
139 } 139 }
140 void ScheduledActionInvalidateOutputSurface() override { 140 void ScheduledActionInvalidateOutputSurface() override {
141 actions_.push_back("ScheduledActionInvalidateOutputSurface"); 141 actions_.push_back("ScheduledActionInvalidateOutputSurface");
142 states_.push_back(scheduler_->AsValue()); 142 states_.push_back(scheduler_->AsValue());
143 } 143 }
144 base::TimeDelta DrawDurationEstimate() override { return base::TimeDelta(); }
145 base::TimeDelta BeginMainFrameToCommitDurationEstimate() override {
146 return base::TimeDelta();
147 }
148 base::TimeDelta CommitToActivateDurationEstimate() override {
149 return base::TimeDelta();
150 }
151 144
152 void SendBeginFramesToChildren(const BeginFrameArgs& args) override { 145 void SendBeginFramesToChildren(const BeginFrameArgs& args) override {
153 begin_frame_args_sent_to_children_ = args; 146 begin_frame_args_sent_to_children_ = args;
154 } 147 }
155 148
156 void SendBeginMainFrameNotExpectedSoon() override { 149 void SendBeginMainFrameNotExpectedSoon() override {
157 PushAction("SendBeginMainFrameNotExpectedSoon"); 150 PushAction("SendBeginMainFrameNotExpectedSoon");
158 } 151 }
159 152
160 base::Callback<bool(void)> ImplFrameDeadlinePending(bool state) { 153 base::Callback<bool(void)> ImplFrameDeadlinePending(bool state) {
(...skipping 25 matching lines...) Expand all
186 bool automatic_swap_ack_; 179 bool automatic_swap_ack_;
187 int num_draws_; 180 int num_draws_;
188 BeginFrameArgs begin_frame_args_sent_to_children_; 181 BeginFrameArgs begin_frame_args_sent_to_children_;
189 base::TimeTicks posted_begin_impl_frame_deadline_; 182 base::TimeTicks posted_begin_impl_frame_deadline_;
190 std::vector<const char*> actions_; 183 std::vector<const char*> actions_;
191 std::vector<scoped_refptr<base::trace_event::ConvertableToTraceFormat>> 184 std::vector<scoped_refptr<base::trace_event::ConvertableToTraceFormat>>
192 states_; 185 states_;
193 TestScheduler* scheduler_; 186 TestScheduler* scheduler_;
194 }; 187 };
195 188
196 class SchedulerClientWithFixedEstimates : public FakeSchedulerClient {
197 public:
198 SchedulerClientWithFixedEstimates(
199 base::TimeDelta draw_duration,
200 base::TimeDelta begin_main_frame_to_commit_duration,
201 base::TimeDelta commit_to_activate_duration)
202 : draw_duration_(draw_duration),
203 begin_main_frame_to_commit_duration_(
204 begin_main_frame_to_commit_duration),
205 commit_to_activate_duration_(commit_to_activate_duration) {}
206
207 base::TimeDelta DrawDurationEstimate() override { return draw_duration_; }
208 base::TimeDelta BeginMainFrameToCommitDurationEstimate() override {
209 return begin_main_frame_to_commit_duration_;
210 }
211 base::TimeDelta CommitToActivateDurationEstimate() override {
212 return commit_to_activate_duration_;
213 }
214
215 private:
216 base::TimeDelta draw_duration_;
217 base::TimeDelta begin_main_frame_to_commit_duration_;
218 base::TimeDelta commit_to_activate_duration_;
219 };
220
221 class FakeExternalBeginFrameSource : public BeginFrameSourceBase { 189 class FakeExternalBeginFrameSource : public BeginFrameSourceBase {
222 public: 190 public:
223 explicit FakeExternalBeginFrameSource(FakeSchedulerClient* client) 191 explicit FakeExternalBeginFrameSource(FakeSchedulerClient* client)
224 : client_(client) {} 192 : client_(client) {}
225 ~FakeExternalBeginFrameSource() override {} 193 ~FakeExternalBeginFrameSource() override {}
226 194
227 void OnNeedsBeginFramesChange(bool needs_begin_frames) override { 195 void OnNeedsBeginFramesChange(bool needs_begin_frames) override {
228 if (needs_begin_frames) { 196 if (needs_begin_frames) {
229 client_->PushAction("SetNeedsBeginFrames(true)"); 197 client_->PushAction("SetNeedsBeginFrames(true)");
230 } else { 198 } else {
(...skipping 24 matching lines...) Expand all
255 } 223 }
256 224
257 ~SchedulerTest() override {} 225 ~SchedulerTest() override {}
258 226
259 protected: 227 protected:
260 TestScheduler* CreateScheduler() { 228 TestScheduler* CreateScheduler() {
261 if (scheduler_settings_.use_external_begin_frame_source) { 229 if (scheduler_settings_.use_external_begin_frame_source) {
262 fake_external_begin_frame_source_.reset( 230 fake_external_begin_frame_source_.reset(
263 new FakeExternalBeginFrameSource(client_.get())); 231 new FakeExternalBeginFrameSource(client_.get()));
264 } 232 }
233
234 scoped_ptr<FakeCompositorTimingHistory> fake_compositor_timing_history =
235 FakeCompositorTimingHistory::Create();
236 fake_compositor_timing_history_ = fake_compositor_timing_history.get();
237
265 scheduler_ = TestScheduler::Create( 238 scheduler_ = TestScheduler::Create(
266 now_src_.get(), client_.get(), scheduler_settings_, 0, 239 now_src_.get(), client_.get(), scheduler_settings_, 0,
267 task_runner_.get(), fake_external_begin_frame_source_.get()); 240 task_runner_.get(), fake_external_begin_frame_source_.get(),
241 fake_compositor_timing_history.Pass());
268 DCHECK(scheduler_); 242 DCHECK(scheduler_);
269 client_->set_scheduler(scheduler_.get()); 243 client_->set_scheduler(scheduler_.get());
270 return scheduler_.get(); 244 return scheduler_.get();
271 } 245 }
272 246
273 void CreateSchedulerAndInitSurface() { 247 void CreateSchedulerAndInitSurface() {
274 CreateScheduler(); 248 CreateScheduler();
275 EXPECT_SCOPED(InitializeOutputSurfaceAndFirstCommit()); 249 EXPECT_SCOPED(InitializeOutputSurfaceAndFirstCommit());
276 } 250 }
277 251
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 void BeginFramesNotFromClient_SwapThrottled( 389 void BeginFramesNotFromClient_SwapThrottled(
416 bool use_external_begin_frame_source, 390 bool use_external_begin_frame_source,
417 bool throttle_frame_production); 391 bool throttle_frame_production);
418 392
419 scoped_ptr<base::SimpleTestTickClock> now_src_; 393 scoped_ptr<base::SimpleTestTickClock> now_src_;
420 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; 394 scoped_refptr<OrderedSimpleTaskRunner> task_runner_;
421 scoped_ptr<FakeExternalBeginFrameSource> fake_external_begin_frame_source_; 395 scoped_ptr<FakeExternalBeginFrameSource> fake_external_begin_frame_source_;
422 SchedulerSettings scheduler_settings_; 396 SchedulerSettings scheduler_settings_;
423 scoped_ptr<FakeSchedulerClient> client_; 397 scoped_ptr<FakeSchedulerClient> client_;
424 scoped_ptr<TestScheduler> scheduler_; 398 scoped_ptr<TestScheduler> scheduler_;
399 FakeCompositorTimingHistory* fake_compositor_timing_history_;
425 }; 400 };
426 401
427 TEST_F(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) { 402 TEST_F(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) {
428 scheduler_settings_.use_external_begin_frame_source = true; 403 scheduler_settings_.use_external_begin_frame_source = true;
429 SetUpScheduler(false); 404 SetUpScheduler(false);
430 scheduler_->SetCanStart(); 405 scheduler_->SetCanStart();
431 scheduler_->SetVisible(true); 406 scheduler_->SetVisible(true);
432 scheduler_->SetCanDraw(true); 407 scheduler_->SetCanDraw(true);
433 408
434 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); 409 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); 441 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_);
467 EXPECT_TRUE(client_->needs_begin_frames()); 442 EXPECT_TRUE(client_->needs_begin_frames());
468 443
469 client_->Reset(); 444 client_->Reset();
470 EXPECT_SCOPED(AdvanceFrame()); 445 EXPECT_SCOPED(AdvanceFrame());
471 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); 446 EXPECT_TRUE(client_->begin_frame_is_sent_to_children());
472 } 447 }
473 448
474 TEST_F(SchedulerTest, SendBeginFramesToChildrenDeadlineNotAdjusted) { 449 TEST_F(SchedulerTest, SendBeginFramesToChildrenDeadlineNotAdjusted) {
475 // Set up client with specified estimates. 450 // Set up client with specified estimates.
476 SchedulerClientWithFixedEstimates* client =
477 new SchedulerClientWithFixedEstimates(
478 base::TimeDelta::FromMilliseconds(1),
479 base::TimeDelta::FromMilliseconds(2),
480 base::TimeDelta::FromMilliseconds(4));
481 scheduler_settings_.use_external_begin_frame_source = true; 451 scheduler_settings_.use_external_begin_frame_source = true;
482 SetUpScheduler(make_scoped_ptr(client).Pass(), true); 452 SetUpScheduler(true);
453 fake_compositor_timing_history_->SetDrawDurationEstimate(
454 base::TimeDelta::FromMilliseconds(1));
455 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate(
456 base::TimeDelta::FromMilliseconds(2));
457 fake_compositor_timing_history_->SetCommitToActivateDurationEstimate(
458 base::TimeDelta::FromMilliseconds(4));
483 459
484 EXPECT_FALSE(client_->needs_begin_frames()); 460 EXPECT_FALSE(client_->needs_begin_frames());
485 scheduler_->SetChildrenNeedBeginFrames(true); 461 scheduler_->SetChildrenNeedBeginFrames(true);
486 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); 462 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_);
487 EXPECT_TRUE(client_->needs_begin_frames()); 463 EXPECT_TRUE(client_->needs_begin_frames());
488 464
489 client_->Reset(); 465 client_->Reset();
490 466
491 BeginFrameArgs frame_args = 467 BeginFrameArgs frame_args =
492 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); 468 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src());
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3); 1287 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3);
1312 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 1, 3); 1288 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 1, 3);
1313 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); 1289 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
1314 } 1290 }
1315 1291
1316 void SchedulerTest::MainFrameInHighLatencyMode( 1292 void SchedulerTest::MainFrameInHighLatencyMode(
1317 int64 begin_main_frame_to_commit_estimate_in_ms, 1293 int64 begin_main_frame_to_commit_estimate_in_ms,
1318 int64 commit_to_activate_estimate_in_ms, 1294 int64 commit_to_activate_estimate_in_ms,
1319 bool impl_latency_takes_priority, 1295 bool impl_latency_takes_priority,
1320 bool should_send_begin_main_frame) { 1296 bool should_send_begin_main_frame) {
1321 // Set up client with specified estimates (draw duration is set to 1). 1297 scheduler_settings_.use_external_begin_frame_source = true;
1322 SchedulerClientWithFixedEstimates* client = 1298 SetUpScheduler(true);
1323 new SchedulerClientWithFixedEstimates(
1324 base::TimeDelta::FromMilliseconds(1),
1325 base::TimeDelta::FromMilliseconds(
1326 begin_main_frame_to_commit_estimate_in_ms),
1327 base::TimeDelta::FromMilliseconds(commit_to_activate_estimate_in_ms));
1328 1299
1329 scheduler_settings_.use_external_begin_frame_source = true; 1300 fake_compositor_timing_history_->SetDrawDurationEstimate(
1330 SetUpScheduler(make_scoped_ptr(client).Pass(), true); 1301 base::TimeDelta::FromMilliseconds(1));
1302 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate(
1303 base::TimeDelta::FromMilliseconds(
1304 begin_main_frame_to_commit_estimate_in_ms));
1305 fake_compositor_timing_history_->SetCommitToActivateDurationEstimate(
1306 base::TimeDelta::FromMilliseconds(commit_to_activate_estimate_in_ms));
1331 1307
1332 scheduler_->SetImplLatencyTakesPriority(impl_latency_takes_priority); 1308 scheduler_->SetImplLatencyTakesPriority(impl_latency_takes_priority);
1333 1309
1334 // Impl thread hits deadline before commit finishes. 1310 // Impl thread hits deadline before commit finishes.
1335 scheduler_->SetNeedsCommit(); 1311 scheduler_->SetNeedsCommit();
1336 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); 1312 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode());
1337 EXPECT_SCOPED(AdvanceFrame()); 1313 EXPECT_SCOPED(AdvanceFrame());
1338 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); 1314 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode());
1339 task_runner().RunPendingTasks(); // Run posted deadline. 1315 task_runner().RunPendingTasks(); // Run posted deadline.
1340 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); 1316 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode());
1341 scheduler_->NotifyBeginMainFrameStarted(); 1317 scheduler_->NotifyBeginMainFrameStarted();
1342 scheduler_->NotifyReadyToCommit(); 1318 scheduler_->NotifyReadyToCommit();
1343 scheduler_->NotifyReadyToActivate(); 1319 scheduler_->NotifyReadyToActivate();
1344 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); 1320 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode());
1345 EXPECT_TRUE(client->HasAction("ScheduledActionSendBeginMainFrame")); 1321 EXPECT_TRUE(client_->HasAction("ScheduledActionSendBeginMainFrame"));
1346 1322
1347 client->Reset(); 1323 client_->Reset();
1348 scheduler_->SetNeedsCommit(); 1324 scheduler_->SetNeedsCommit();
1349 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); 1325 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode());
1350 EXPECT_SCOPED(AdvanceFrame()); 1326 EXPECT_SCOPED(AdvanceFrame());
1351 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); 1327 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode());
1352 task_runner().RunPendingTasks(); // Run posted deadline. 1328 task_runner().RunPendingTasks(); // Run posted deadline.
1353 EXPECT_EQ(scheduler_->MainThreadIsInHighLatencyMode(), 1329 EXPECT_EQ(scheduler_->MainThreadIsInHighLatencyMode(),
1354 should_send_begin_main_frame); 1330 should_send_begin_main_frame);
1355 EXPECT_EQ(client->HasAction("ScheduledActionSendBeginMainFrame"), 1331 EXPECT_EQ(client_->HasAction("ScheduledActionSendBeginMainFrame"),
1356 should_send_begin_main_frame); 1332 should_send_begin_main_frame);
1357 } 1333 }
1358 1334
1359 TEST_F(SchedulerTest, 1335 TEST_F(SchedulerTest,
1360 SkipMainFrameIfHighLatencyAndCanCommitAndActivateBeforeDeadline) { 1336 SkipMainFrameIfHighLatencyAndCanCommitAndActivateBeforeDeadline) {
1361 // Set up client so that estimates indicate that we can commit and activate 1337 // Set up client so that estimates indicate that we can commit and activate
1362 // before the deadline (~8ms by default). 1338 // before the deadline (~8ms by default).
1363 EXPECT_SCOPED(MainFrameInHighLatencyMode(1, 1, false, false)); 1339 EXPECT_SCOPED(MainFrameInHighLatencyMode(1, 1, false, false));
1364 } 1340 }
1365 1341
(...skipping 17 matching lines...) Expand all
1383 } 1359 }
1384 1360
1385 TEST_F( 1361 TEST_F(
1386 SchedulerTest, 1362 SchedulerTest,
1387 Deadlock_CommitMakesProgressWhileSwapTrottledAndActiveTreeNeedsFirstDraw) { 1363 Deadlock_CommitMakesProgressWhileSwapTrottledAndActiveTreeNeedsFirstDraw) {
1388 // NPAPI plugins on Windows block the Browser UI thread on the Renderer main 1364 // NPAPI plugins on Windows block the Browser UI thread on the Renderer main
1389 // thread. This prevents the scheduler from receiving any pending swap acks. 1365 // thread. This prevents the scheduler from receiving any pending swap acks.
1390 1366
1391 // Since we are simulating a long commit, set up a client with draw duration 1367 // Since we are simulating a long commit, set up a client with draw duration
1392 // estimates that prevent skipping main frames to get to low latency mode. 1368 // estimates that prevent skipping main frames to get to low latency mode.
1393 SchedulerClientWithFixedEstimates* client =
1394 new SchedulerClientWithFixedEstimates(
1395 base::TimeDelta::FromMilliseconds(1),
1396 base::TimeDelta::FromMilliseconds(32),
1397 base::TimeDelta::FromMilliseconds(32));
1398 scheduler_settings_.use_external_begin_frame_source = true; 1369 scheduler_settings_.use_external_begin_frame_source = true;
1399 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; 1370 scheduler_settings_.main_frame_while_swap_throttled_enabled = true;
1400 SetUpScheduler(make_scoped_ptr(client).Pass(), true); 1371 SetUpScheduler(true);
1372
1373 fake_compositor_timing_history_->SetDrawDurationEstimate(
1374 base::TimeDelta::FromMilliseconds(1));
1375 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate(
1376 base::TimeDelta::FromMilliseconds(32));
1377 fake_compositor_timing_history_->SetCommitToActivateDurationEstimate(
1378 base::TimeDelta::FromMilliseconds(32));
1401 1379
1402 // Disables automatic swap acks so this test can force swap ack throttling 1380 // Disables automatic swap acks so this test can force swap ack throttling
1403 // to simulate a blocked Browser ui thread. 1381 // to simulate a blocked Browser ui thread.
1404 scheduler_->SetMaxSwapsPending(1); 1382 scheduler_->SetMaxSwapsPending(1);
1405 client_->SetAutomaticSwapAck(false); 1383 client_->SetAutomaticSwapAck(false);
1406 1384
1407 // Get a new active tree in main-thread high latency mode and put us 1385 // Get a new active tree in main-thread high latency mode and put us
1408 // in a swap throttled state. 1386 // in a swap throttled state.
1409 client_->Reset(); 1387 client_->Reset();
1410 EXPECT_FALSE(scheduler_->CommitPending()); 1388 EXPECT_FALSE(scheduler_->CommitPending());
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 Deadlock_NoBeginMainFrameWhileSwapTrottledAndPipelineFull) { 1438 Deadlock_NoBeginMainFrameWhileSwapTrottledAndPipelineFull) {
1461 // NPAPI plugins on Windows block the Browser UI thread on the Renderer main 1439 // NPAPI plugins on Windows block the Browser UI thread on the Renderer main
1462 // thread. This prevents the scheduler from receiving any pending swap acks. 1440 // thread. This prevents the scheduler from receiving any pending swap acks.
1463 1441
1464 // This particular test makes sure we do not send a BeginMainFrame while 1442 // This particular test makes sure we do not send a BeginMainFrame while
1465 // swap trottled and we have a pending tree and active tree that 1443 // swap trottled and we have a pending tree and active tree that
1466 // still needs to be drawn for the first time. 1444 // still needs to be drawn for the first time.
1467 1445
1468 // Since we are simulating a long commit, set up a client with draw duration 1446 // Since we are simulating a long commit, set up a client with draw duration
1469 // estimates that prevent skipping main frames to get to low latency mode. 1447 // estimates that prevent skipping main frames to get to low latency mode.
1470 SchedulerClientWithFixedEstimates* client =
1471 new SchedulerClientWithFixedEstimates(
1472 base::TimeDelta::FromMilliseconds(1),
1473 base::TimeDelta::FromMilliseconds(32),
1474 base::TimeDelta::FromMilliseconds(32));
1475 scheduler_settings_.use_external_begin_frame_source = true; 1448 scheduler_settings_.use_external_begin_frame_source = true;
1476 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; 1449 scheduler_settings_.main_frame_while_swap_throttled_enabled = true;
1477 scheduler_settings_.main_frame_before_activation_enabled = true; 1450 scheduler_settings_.main_frame_before_activation_enabled = true;
1478 SetUpScheduler(make_scoped_ptr(client).Pass(), true); 1451 SetUpScheduler(true);
1452
1453 fake_compositor_timing_history_->SetDrawDurationEstimate(
1454 base::TimeDelta::FromMilliseconds(1));
1455 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate(
1456 base::TimeDelta::FromMilliseconds(32));
1457 fake_compositor_timing_history_->SetCommitToActivateDurationEstimate(
1458 base::TimeDelta::FromMilliseconds(32));
1479 1459
1480 // Disables automatic swap acks so this test can force swap ack throttling 1460 // Disables automatic swap acks so this test can force swap ack throttling
1481 // to simulate a blocked Browser ui thread. 1461 // to simulate a blocked Browser ui thread.
1482 scheduler_->SetMaxSwapsPending(1); 1462 scheduler_->SetMaxSwapsPending(1);
1483 client_->SetAutomaticSwapAck(false); 1463 client_->SetAutomaticSwapAck(false);
1484 1464
1485 // Start a new commit in main-thread high latency mode and hold off on 1465 // Start a new commit in main-thread high latency mode and hold off on
1486 // activation. 1466 // activation.
1487 client_->Reset(); 1467 client_->Reset();
1488 EXPECT_FALSE(scheduler_->CommitPending()); 1468 EXPECT_FALSE(scheduler_->CommitPending());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 } 1526 }
1547 1527
1548 TEST_F( 1528 TEST_F(
1549 SchedulerTest, 1529 SchedulerTest,
1550 CommitMakesProgressWhenIdleAndHasPendingTreeAndActiveTreeNeedsFirstDraw) { 1530 CommitMakesProgressWhenIdleAndHasPendingTreeAndActiveTreeNeedsFirstDraw) {
1551 // This verifies we don't block commits longer than we need to 1531 // This verifies we don't block commits longer than we need to
1552 // for performance reasons - not deadlock reasons. 1532 // for performance reasons - not deadlock reasons.
1553 1533
1554 // Since we are simulating a long commit, set up a client with draw duration 1534 // Since we are simulating a long commit, set up a client with draw duration
1555 // estimates that prevent skipping main frames to get to low latency mode. 1535 // estimates that prevent skipping main frames to get to low latency mode.
1556 SchedulerClientWithFixedEstimates* client =
1557 new SchedulerClientWithFixedEstimates(
1558 base::TimeDelta::FromMilliseconds(1),
1559 base::TimeDelta::FromMilliseconds(32),
1560 base::TimeDelta::FromMilliseconds(32));
1561 scheduler_settings_.use_external_begin_frame_source = true; 1536 scheduler_settings_.use_external_begin_frame_source = true;
1562 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; 1537 scheduler_settings_.main_frame_while_swap_throttled_enabled = true;
1563 scheduler_settings_.main_frame_before_activation_enabled = true; 1538 scheduler_settings_.main_frame_before_activation_enabled = true;
1564 SetUpScheduler(make_scoped_ptr(client).Pass(), true); 1539 SetUpScheduler(true);
1540
1541 fake_compositor_timing_history_->SetDrawDurationEstimate(
1542 base::TimeDelta::FromMilliseconds(1));
1543 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate(
1544 base::TimeDelta::FromMilliseconds(32));
1545 fake_compositor_timing_history_->SetCommitToActivateDurationEstimate(
1546 base::TimeDelta::FromMilliseconds(32));
1565 1547
1566 // Disables automatic swap acks so this test can force swap ack throttling 1548 // Disables automatic swap acks so this test can force swap ack throttling
1567 // to simulate a blocked Browser ui thread. 1549 // to simulate a blocked Browser ui thread.
1568 scheduler_->SetMaxSwapsPending(1); 1550 scheduler_->SetMaxSwapsPending(1);
1569 client_->SetAutomaticSwapAck(false); 1551 client_->SetAutomaticSwapAck(false);
1570 1552
1571 // Start a new commit in main-thread high latency mode and hold off on 1553 // Start a new commit in main-thread high latency mode and hold off on
1572 // activation. 1554 // activation.
1573 client_->Reset(); 1555 client_->Reset();
1574 EXPECT_FALSE(scheduler_->CommitPending()); 1556 EXPECT_FALSE(scheduler_->CommitPending());
(...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after
2978 scheduler_->SetImplLatencyTakesPriority(true); 2960 scheduler_->SetImplLatencyTakesPriority(true);
2979 scheduler_->SetChildrenNeedBeginFrames(true); 2961 scheduler_->SetChildrenNeedBeginFrames(true);
2980 2962
2981 EXPECT_SCOPED(AdvanceFrame()); 2963 EXPECT_SCOPED(AdvanceFrame());
2982 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); 2964 EXPECT_TRUE(client_->begin_frame_is_sent_to_children());
2983 EXPECT_FALSE(client_->begin_frame_args_sent_to_children().on_critical_path); 2965 EXPECT_FALSE(client_->begin_frame_args_sent_to_children().on_critical_path);
2984 } 2966 }
2985 2967
2986 } // namespace 2968 } // namespace
2987 } // namespace cc 2969 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler.cc ('k') | cc/test/scheduler_test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698