Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 UNTHROTTLED_BFS, | 231 UNTHROTTLED_BFS, |
| 232 THROTTLED_BFS, | 232 THROTTLED_BFS, |
| 233 }; | 233 }; |
| 234 | 234 |
| 235 class SchedulerTest : public testing::Test { | 235 class SchedulerTest : public testing::Test { |
| 236 public: | 236 public: |
| 237 SchedulerTest() | 237 SchedulerTest() |
| 238 : now_src_(new base::SimpleTestTickClock()), | 238 : now_src_(new base::SimpleTestTickClock()), |
| 239 task_runner_(new OrderedSimpleTaskRunner(now_src_.get(), true)), | 239 task_runner_(new OrderedSimpleTaskRunner(now_src_.get(), true)), |
| 240 fake_external_begin_frame_source_(nullptr), | 240 fake_external_begin_frame_source_(nullptr), |
| 241 fake_compositor_timing_history_(nullptr), | 241 fake_compositor_timing_history_(nullptr) { |
| 242 next_begin_frame_number_(BeginFrameArgs::kStartingFrameNumber) { | |
| 243 now_src_->Advance(base::TimeDelta::FromMicroseconds(10000)); | 242 now_src_->Advance(base::TimeDelta::FromMicroseconds(10000)); |
| 244 // A bunch of tests require NowTicks() | 243 // A bunch of tests require NowTicks() |
| 245 // to be > BeginFrameArgs::DefaultInterval() | 244 // to be > BeginFrameArgs::DefaultInterval() |
| 246 now_src_->Advance(base::TimeDelta::FromMilliseconds(100)); | 245 now_src_->Advance(base::TimeDelta::FromMilliseconds(100)); |
| 247 // Fail if we need to run 100 tasks in a row. | 246 // Fail if we need to run 100 tasks in a row. |
| 248 task_runner_->SetRunTaskLimit(100); | 247 task_runner_->SetRunTaskLimit(100); |
| 249 } | 248 } |
| 250 | 249 |
| 251 ~SchedulerTest() override {} | 250 ~SchedulerTest() override {} |
| 252 | 251 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 401 task_runner_->RunTasksWhile(client_->FrameHasNotAdvancedCallback()); | 400 task_runner_->RunTasksWhile(client_->FrameHasNotAdvancedCallback()); |
| 402 } | 401 } |
| 403 } | 402 } |
| 404 | 403 |
| 405 BeginFrameArgs SendNextBeginFrame() { | 404 BeginFrameArgs SendNextBeginFrame() { |
| 406 DCHECK_EQ(scheduler_->begin_frame_source(), | 405 DCHECK_EQ(scheduler_->begin_frame_source(), |
| 407 fake_external_begin_frame_source_.get()); | 406 fake_external_begin_frame_source_.get()); |
| 408 // Creep the time forward so that any BeginFrameArgs is not equal to the | 407 // Creep the time forward so that any BeginFrameArgs is not equal to the |
| 409 // last one otherwise we violate the BeginFrameSource contract. | 408 // last one otherwise we violate the BeginFrameSource contract. |
| 410 now_src_->Advance(BeginFrameArgs::DefaultInterval()); | 409 now_src_->Advance(BeginFrameArgs::DefaultInterval()); |
| 411 BeginFrameArgs args = CreateBeginFrameArgsForTesting( | 410 BeginFrameArgs args = |
| 412 BEGINFRAME_FROM_HERE, fake_external_begin_frame_source_->source_id(), | 411 fake_external_begin_frame_source_->CreateBeginFrameArgs( |
| 413 next_begin_frame_number_, now_src()); | 412 BEGINFRAME_FROM_HERE, now_src()); |
| 414 next_begin_frame_number_++; | |
| 415 fake_external_begin_frame_source_->TestOnBeginFrame(args); | 413 fake_external_begin_frame_source_->TestOnBeginFrame(args); |
| 416 return args; | 414 return args; |
| 417 } | 415 } |
| 418 | 416 |
| 419 FakeExternalBeginFrameSource* fake_external_begin_frame_source() const { | 417 FakeExternalBeginFrameSource* fake_external_begin_frame_source() const { |
| 420 return fake_external_begin_frame_source_.get(); | 418 return fake_external_begin_frame_source_.get(); |
| 421 } | 419 } |
| 422 | 420 |
| 423 void AdvanceAndMissOneFrame(); | 421 void AdvanceAndMissOneFrame(); |
| 424 void CheckMainFrameSkippedAfterLateCommit(bool expect_send_begin_main_frame); | 422 void CheckMainFrameSkippedAfterLateCommit(bool expect_send_begin_main_frame); |
| 425 void ImplFrameSkippedAfterLateAck(bool receive_ack_before_deadline); | 423 void ImplFrameSkippedAfterLateAck(bool receive_ack_before_deadline); |
| 426 void ImplFrameNotSkippedAfterLateAck(); | 424 void ImplFrameNotSkippedAfterLateAck(); |
| 427 void BeginFramesNotFromClient(BeginFrameSourceType bfs_type); | 425 void BeginFramesNotFromClient(BeginFrameSourceType bfs_type); |
| 428 void BeginFramesNotFromClient_IsDrawThrottled(BeginFrameSourceType bfs_type); | 426 void BeginFramesNotFromClient_IsDrawThrottled(BeginFrameSourceType bfs_type); |
| 429 bool BeginMainFrameOnCriticalPath(TreePriority tree_priority, | 427 bool BeginMainFrameOnCriticalPath(TreePriority tree_priority, |
| 430 ScrollHandlerState scroll_handler_state, | 428 ScrollHandlerState scroll_handler_state, |
| 431 base::TimeDelta durations); | 429 base::TimeDelta durations); |
| 432 | 430 |
| 433 std::unique_ptr<base::SimpleTestTickClock> now_src_; | 431 std::unique_ptr<base::SimpleTestTickClock> now_src_; |
| 434 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; | 432 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; |
| 435 std::unique_ptr<FakeExternalBeginFrameSource> | 433 std::unique_ptr<FakeExternalBeginFrameSource> |
| 436 fake_external_begin_frame_source_; | 434 fake_external_begin_frame_source_; |
| 437 std::unique_ptr<SyntheticBeginFrameSource> synthetic_frame_source_; | 435 std::unique_ptr<SyntheticBeginFrameSource> synthetic_frame_source_; |
| 438 std::unique_ptr<SyntheticBeginFrameSource> unthrottled_frame_source_; | 436 std::unique_ptr<SyntheticBeginFrameSource> unthrottled_frame_source_; |
| 439 SchedulerSettings scheduler_settings_; | 437 SchedulerSettings scheduler_settings_; |
| 440 std::unique_ptr<FakeSchedulerClient> client_; | 438 std::unique_ptr<FakeSchedulerClient> client_; |
| 441 std::unique_ptr<TestScheduler> scheduler_; | 439 std::unique_ptr<TestScheduler> scheduler_; |
| 442 FakeCompositorTimingHistory* fake_compositor_timing_history_; | 440 FakeCompositorTimingHistory* fake_compositor_timing_history_; |
| 443 uint64_t next_begin_frame_number_; | |
| 444 }; | 441 }; |
| 445 | 442 |
| 446 TEST_F(SchedulerTest, InitializeCompositorFrameSinkDoesNotBeginImplFrame) { | 443 TEST_F(SchedulerTest, InitializeCompositorFrameSinkDoesNotBeginImplFrame) { |
| 447 SetUpSchedulerWithNoCompositorFrameSink(EXTERNAL_BFS); | 444 SetUpSchedulerWithNoCompositorFrameSink(EXTERNAL_BFS); |
| 448 scheduler_->SetVisible(true); | 445 scheduler_->SetVisible(true); |
| 449 scheduler_->SetCanDraw(true); | 446 scheduler_->SetCanDraw(true); |
| 450 | 447 |
| 451 EXPECT_SINGLE_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", | 448 EXPECT_SINGLE_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", |
| 452 client_); | 449 client_); |
| 453 client_->Reset(); | 450 client_->Reset(); |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1331 // if it can activate before the deadline. | 1328 // if it can activate before the deadline. |
| 1332 SetUpScheduler(EXTERNAL_BFS); | 1329 SetUpScheduler(EXTERNAL_BFS); |
| 1333 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); | 1330 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 1334 | 1331 |
| 1335 AdvanceAndMissOneFrame(); | 1332 AdvanceAndMissOneFrame(); |
| 1336 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); | 1333 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1337 scheduler_->SetNeedsBeginMainFrame(); | 1334 scheduler_->SetNeedsBeginMainFrame(); |
| 1338 | 1335 |
| 1339 // Advance frame and create a begin frame. | 1336 // Advance frame and create a begin frame. |
| 1340 now_src_->Advance(BeginFrameArgs::DefaultInterval()); | 1337 now_src_->Advance(BeginFrameArgs::DefaultInterval()); |
| 1341 BeginFrameArgs args = CreateBeginFrameArgsForTesting( | 1338 BeginFrameArgs args = fake_external_begin_frame_source_->CreateBeginFrameArgs( |
| 1342 BEGINFRAME_FROM_HERE, fake_external_begin_frame_source_->source_id(), | 1339 BEGINFRAME_FROM_HERE, now_src()); |
| 1343 next_begin_frame_number_, now_src()); | |
| 1344 next_begin_frame_number_++; | |
| 1345 | 1340 |
| 1346 // Deliver this begin frame super late. | 1341 // Deliver this begin frame super late. |
| 1347 now_src_->Advance(BeginFrameArgs::DefaultInterval() * 100); | 1342 now_src_->Advance(BeginFrameArgs::DefaultInterval() * 100); |
| 1348 fake_external_begin_frame_source_->TestOnBeginFrame(args); | 1343 fake_external_begin_frame_source_->TestOnBeginFrame(args); |
| 1349 | 1344 |
| 1350 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); | 1345 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); |
| 1351 EXPECT_EQ(true, scheduler_->MainThreadMissedLastDeadline()); | 1346 EXPECT_EQ(true, scheduler_->MainThreadMissedLastDeadline()); |
| 1352 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); | 1347 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); |
| 1353 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 3); | 1348 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 3); |
| 1354 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 2, 3); | 1349 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 2, 3); |
| (...skipping 1922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3277 SMOOTHNESS_TAKES_PRIORITY, | 3272 SMOOTHNESS_TAKES_PRIORITY, |
| 3278 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kFastDuration)); | 3273 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kFastDuration)); |
| 3279 } | 3274 } |
| 3280 | 3275 |
| 3281 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { | 3276 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { |
| 3282 EXPECT_FALSE(BeginMainFrameOnCriticalPath( | 3277 EXPECT_FALSE(BeginMainFrameOnCriticalPath( |
| 3283 SMOOTHNESS_TAKES_PRIORITY, | 3278 SMOOTHNESS_TAKES_PRIORITY, |
| 3284 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); | 3279 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); |
| 3285 } | 3280 } |
| 3286 | 3281 |
| 3282 TEST_F(SchedulerTest, BeginFrameAckForFinishedImplFrame) { | |
| 3283 // Sets up scheduler and sends two BeginFrames, both finished. | |
| 3284 SetUpScheduler(EXTERNAL_BFS); | |
| 3285 | |
| 3286 // Expect the last ack to be for last BeginFrame, which didn't cause damage. | |
| 3287 uint64_t last_begin_frame_number = | |
| 3288 fake_external_begin_frame_source_->next_begin_frame_number() - 1; | |
| 3289 uint64_t latest_confirmed_frame = last_begin_frame_number; | |
| 3290 bool has_damage = false; | |
| 3291 EXPECT_EQ( | |
| 3292 BeginFrameAck(fake_external_begin_frame_source_->source_id(), | |
| 3293 last_begin_frame_number, latest_confirmed_frame, 0, | |
| 3294 has_damage), | |
| 3295 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | |
| 3296 | |
| 3297 // Run a successful redraw and verify that a new ack is sent. | |
| 3298 scheduler_->SetNeedsRedraw(); | |
| 3299 client_->Reset(); | |
| 3300 | |
| 3301 BeginFrameArgs args = SendNextBeginFrame(); | |
| 3302 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | |
| 3303 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | |
| 3304 EXPECT_TRUE(scheduler_->begin_frames_expected()); | |
| 3305 client_->Reset(); | |
| 3306 | |
| 3307 task_runner().RunPendingTasks(); // Run posted deadline. | |
| 3308 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); | |
| 3309 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | |
| 3310 EXPECT_TRUE(scheduler_->begin_frames_expected()); | |
| 3311 client_->Reset(); | |
| 3312 | |
| 3313 // Successful draw caused damage. | |
| 3314 latest_confirmed_frame = args.sequence_number; | |
| 3315 has_damage = true; | |
| 3316 EXPECT_EQ( | |
| 3317 BeginFrameAck(args.source_id, args.sequence_number, | |
| 3318 latest_confirmed_frame, 0, has_damage), | |
| 3319 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | |
| 3320 | |
| 3321 // Request another redraw, but fail it. Verify that a new ack is sent, but | |
| 3322 // that its |latest_confirmed_frame| didn't change. | |
| 3323 scheduler_->SetNeedsRedraw(); | |
| 3324 client_->Reset(); | |
| 3325 | |
| 3326 args = SendNextBeginFrame(); | |
| 3327 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | |
| 3328 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | |
| 3329 EXPECT_TRUE(scheduler_->begin_frames_expected()); | |
| 3330 client_->Reset(); | |
| 3331 | |
| 3332 client_->SetSwapWillHappenIfDrawHappens(false); | |
| 3333 task_runner().RunPendingTasks(); // Run posted deadline. | |
| 3334 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); | |
| 3335 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | |
| 3336 EXPECT_TRUE(scheduler_->begin_frames_expected()); | |
| 3337 client_->Reset(); | |
| 3338 | |
| 3339 // Failed draw: no damage and unconfirmed frame. | |
| 3340 has_damage = false; | |
| 3341 EXPECT_EQ( | |
| 3342 BeginFrameAck(args.source_id, args.sequence_number, | |
| 3343 latest_confirmed_frame, 0, has_damage), | |
| 3344 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | |
| 3345 } | |
| 3346 | |
| 3347 TEST_F(SchedulerTest, BeginFrameAckForSkippedImplFrame) { | |
| 3348 SetUpScheduler(EXTERNAL_BFS); | |
| 3349 | |
| 3350 // To get into a high latency state, this test disables automatic swap acks. | |
| 3351 client_->SetAutomaticSubmitCompositorFrameAck(false); | |
| 3352 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); | |
| 3353 | |
| 3354 // Run a successful redraw that submits a compositor frame but doesn't receive | |
| 3355 // a swap ack. Verify that a BeginFrameAck is sent for it. | |
| 3356 scheduler_->SetNeedsRedraw(); | |
| 3357 client_->Reset(); | |
| 3358 | |
| 3359 BeginFrameArgs args = SendNextBeginFrame(); | |
| 3360 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | |
| 3361 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | |
| 3362 EXPECT_TRUE(scheduler_->begin_frames_expected()); | |
| 3363 client_->Reset(); | |
| 3364 | |
| 3365 task_runner().RunPendingTasks(); // Run posted deadline. | |
| 3366 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); | |
| 3367 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | |
| 3368 EXPECT_TRUE(scheduler_->begin_frames_expected()); | |
| 3369 client_->Reset(); | |
| 3370 | |
| 3371 // Successful draw caused damage. | |
| 3372 uint64_t latest_confirmed_frame = args.sequence_number; | |
| 3373 bool has_damage = true; | |
| 3374 EXPECT_EQ( | |
| 3375 BeginFrameAck(args.source_id, args.sequence_number, | |
| 3376 latest_confirmed_frame, 0, has_damage), | |
| 3377 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | |
| 3378 | |
| 3379 // Request another redraw that will be skipped because the swap ack is still | |
| 3380 // missing. Verify that a new BeginFrameAck is sent. | |
| 3381 scheduler_->SetNeedsRedraw(); | |
| 3382 client_->Reset(); | |
| 3383 | |
| 3384 args = SendNextBeginFrame(); | |
| 3385 EXPECT_NO_ACTION(client_); | |
| 3386 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | |
| 3387 EXPECT_TRUE(scheduler_->begin_frames_expected()); | |
| 3388 client_->Reset(); | |
| 3389 | |
| 3390 // Skipped draw: no damage and unconfirmed frame. | |
| 3391 has_damage = false; | |
| 3392 EXPECT_EQ( | |
| 3393 BeginFrameAck(args.source_id, args.sequence_number, | |
| 3394 latest_confirmed_frame, 0, has_damage), | |
| 3395 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | |
| 3396 } | |
| 3397 | |
| 3398 TEST_F(SchedulerTest, BeginFrameAckForBeginFrameBeforeLastDeadline) { | |
| 3399 SetUpScheduler(EXTERNAL_BFS); | |
| 3400 | |
| 3401 // Run a successful redraw, verify that an ack is sent for it. | |
| 3402 scheduler_->SetNeedsRedraw(); | |
| 3403 client_->Reset(); | |
| 3404 | |
| 3405 BeginFrameArgs args = SendNextBeginFrame(); | |
| 3406 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | |
| 3407 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | |
| 3408 EXPECT_TRUE(scheduler_->begin_frames_expected()); | |
| 3409 client_->Reset(); | |
| 3410 | |
| 3411 task_runner().RunPendingTasks(); // Run posted deadline. | |
| 3412 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); | |
| 3413 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | |
| 3414 EXPECT_TRUE(scheduler_->begin_frames_expected()); | |
| 3415 client_->Reset(); | |
| 3416 | |
| 3417 // Successful draw caused damage. | |
| 3418 uint64_t latest_confirmed_frame = args.sequence_number; | |
| 3419 bool has_damage = true; | |
| 3420 EXPECT_EQ( | |
| 3421 BeginFrameAck(args.source_id, args.sequence_number, | |
| 3422 latest_confirmed_frame, 0, has_damage), | |
| 3423 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | |
| 3424 | |
| 3425 // State machine still wants a proactive BeginFrame, so issue another one | |
| 3426 // without updates, but don't execute its deadline yet. | |
| 3427 SendNextBeginFrame(); | |
| 3428 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | |
| 3429 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | |
| 3430 EXPECT_TRUE(scheduler_->begin_frames_expected()); | |
| 3431 client_->Reset(); | |
| 3432 | |
| 3433 // Send the next BeginFrame before the previous one's deadline was executed. | |
| 3434 // This should trigger the previous BeginFrame's deadline synchronously and | |
| 3435 // the new BeginFrame should be dropped because no further redraw is needed. | |
| 3436 // TODO(eseckler): This doesn't actually work, because | |
|
Eric Seckler
2017/01/18 18:13:03
Here's my current attempt at creating a situation
| |
| 3437 // OnBeginFrameDerivedImpl() discards the new BeginFrame | |
| 3438 // (!state_machine_.BeginFrameNeeded()). | |
| 3439 args = SendNextBeginFrame(); | |
| 3440 EXPECT_NO_ACTION(client_); | |
| 3441 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | |
| 3442 EXPECT_FALSE(scheduler_->begin_frames_expected()); | |
| 3443 client_->Reset(); | |
| 3444 | |
| 3445 // Latest ack should be for the dropped BeginFrame. Since we don't have | |
| 3446 // further updates, its |latest_confirmed_frame| should be updated too. | |
| 3447 latest_confirmed_frame = args.sequence_number; | |
| 3448 has_damage = false; | |
| 3449 EXPECT_EQ( | |
| 3450 BeginFrameAck(args.source_id, args.sequence_number, | |
| 3451 latest_confirmed_frame, 0, has_damage), | |
| 3452 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | |
| 3453 } | |
| 3454 | |
| 3455 TEST_F(SchedulerTest, BeginFrameAckForLateMissedBeginFrame) { | |
| 3456 SetUpScheduler(EXTERNAL_BFS); | |
| 3457 | |
| 3458 // Last confirmed frame was last BeginFrame. | |
| 3459 uint64_t latest_confirmed_frame = | |
| 3460 fake_external_begin_frame_source_->next_begin_frame_number() - 1; | |
| 3461 | |
| 3462 scheduler_->SetNeedsRedraw(); | |
| 3463 client_->Reset(); | |
| 3464 | |
| 3465 // Send a missed BeginFrame with a passed deadline. | |
| 3466 now_src_->Advance(BeginFrameArgs::DefaultInterval()); | |
| 3467 BeginFrameArgs args = fake_external_begin_frame_source_->CreateBeginFrameArgs( | |
| 3468 BEGINFRAME_FROM_HERE, now_src()); | |
| 3469 args.type = BeginFrameArgs::MISSED; | |
| 3470 now_src_->Advance(BeginFrameArgs::DefaultInterval()); | |
| 3471 EXPECT_GT(now_src_->NowTicks(), args.deadline); | |
| 3472 fake_external_begin_frame_source_->TestOnBeginFrame(args); | |
| 3473 | |
| 3474 EXPECT_NO_ACTION(client_); | |
| 3475 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | |
| 3476 client_->Reset(); | |
| 3477 | |
| 3478 // Latest ack should be for the missed BeginFrame that was too late: no damage | |
| 3479 // and unconfirmed frame. | |
| 3480 bool has_damage = false; | |
| 3481 EXPECT_EQ( | |
| 3482 BeginFrameAck(args.source_id, args.sequence_number, | |
| 3483 latest_confirmed_frame, 0, has_damage), | |
| 3484 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | |
| 3485 } | |
| 3486 | |
| 3487 TEST_F(SchedulerTest, BeginFrameAckForFinishedBeginFrameWithNewSourceId) { | |
| 3488 SetUpScheduler(EXTERNAL_BFS); | |
| 3489 | |
| 3490 scheduler_->SetNeedsRedraw(); | |
| 3491 client_->Reset(); | |
| 3492 | |
| 3493 // Send a BeginFrame with a different source_id. | |
| 3494 now_src_->Advance(BeginFrameArgs::DefaultInterval()); | |
| 3495 uint32_t source_id = fake_external_begin_frame_source_->source_id() + 1; | |
| 3496 BeginFrameArgs args = CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, | |
| 3497 source_id, 1, now_src()); | |
| 3498 fake_external_begin_frame_source_->TestOnBeginFrame(args); | |
| 3499 | |
| 3500 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | |
| 3501 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | |
| 3502 EXPECT_TRUE(scheduler_->begin_frames_expected()); | |
| 3503 client_->Reset(); | |
| 3504 | |
| 3505 task_runner().RunPendingTasks(); // Run posted deadline. | |
| 3506 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); | |
| 3507 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | |
| 3508 EXPECT_TRUE(scheduler_->begin_frames_expected()); | |
| 3509 client_->Reset(); | |
| 3510 | |
| 3511 // Successful draw caused damage. | |
| 3512 uint64_t latest_confirmed_frame = args.sequence_number; | |
| 3513 bool has_damage = true; | |
| 3514 EXPECT_EQ( | |
| 3515 BeginFrameAck(args.source_id, args.sequence_number, | |
| 3516 latest_confirmed_frame, 0, has_damage), | |
| 3517 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | |
| 3518 } | |
| 3519 | |
| 3520 TEST_F(SchedulerTest, | |
| 3521 BeginFrameAckForLateMissedBeginFrameWithDifferentSourceId) { | |
| 3522 SetUpScheduler(EXTERNAL_BFS); | |
| 3523 | |
| 3524 scheduler_->SetNeedsRedraw(); | |
| 3525 client_->Reset(); | |
| 3526 | |
| 3527 // Send a missed BeginFrame with a passed deadline and different source_id. | |
| 3528 now_src_->Advance(BeginFrameArgs::DefaultInterval()); | |
| 3529 uint32_t source_id = fake_external_begin_frame_source_->source_id() + 1; | |
| 3530 BeginFrameArgs args = CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, | |
| 3531 source_id, 1, now_src()); | |
| 3532 args.type = BeginFrameArgs::MISSED; | |
| 3533 now_src_->Advance(BeginFrameArgs::DefaultInterval()); | |
| 3534 EXPECT_GT(now_src_->NowTicks(), args.deadline); | |
| 3535 fake_external_begin_frame_source_->TestOnBeginFrame(args); | |
| 3536 | |
| 3537 EXPECT_NO_ACTION(client_); | |
| 3538 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | |
| 3539 client_->Reset(); | |
| 3540 | |
| 3541 // Latest ack should be for the missed BeginFrame that was too late: no damage | |
| 3542 // and unconfirmed frame. Because the source_id changed, the | |
| 3543 // |latest_confirmed_frame| should be set to invalid. | |
| 3544 uint64_t latest_confirmed_frame = BeginFrameArgs::kInvalidFrameNumber; | |
| 3545 bool has_damage = false; | |
| 3546 EXPECT_EQ( | |
| 3547 BeginFrameAck(args.source_id, args.sequence_number, | |
| 3548 latest_confirmed_frame, 0, has_damage), | |
| 3549 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | |
| 3550 } | |
| 3551 | |
| 3287 } // namespace | 3552 } // namespace |
| 3288 } // namespace cc | 3553 } // namespace cc |
| OLD | NEW |