| 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 states_.push_back(scheduler_->AsValue()); | 172 states_.push_back(scheduler_->AsValue()); |
| 173 } | 173 } |
| 174 void ScheduledActionPerformImplSideInvalidation() override { | 174 void ScheduledActionPerformImplSideInvalidation() override { |
| 175 PushAction("ScheduledActionPerformImplSideInvalidation"); | 175 PushAction("ScheduledActionPerformImplSideInvalidation"); |
| 176 } | 176 } |
| 177 | 177 |
| 178 void SendBeginMainFrameNotExpectedSoon() override { | 178 void SendBeginMainFrameNotExpectedSoon() override { |
| 179 PushAction("SendBeginMainFrameNotExpectedSoon"); | 179 PushAction("SendBeginMainFrameNotExpectedSoon"); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void ScheduledActionBeginMainFrameNotExpectedUntil( |
| 183 base::TimeTicks time) override { |
| 184 PushAction("ScheduledActionBeginMainFrameNotExpectedUntil"); |
| 185 } |
| 186 |
| 182 bool IsInsideBeginImplFrame() const { return inside_begin_impl_frame_; } | 187 bool IsInsideBeginImplFrame() const { return inside_begin_impl_frame_; } |
| 183 | 188 |
| 184 base::Callback<bool(void)> InsideBeginImplFrame(bool state) { | 189 base::Callback<bool(void)> InsideBeginImplFrame(bool state) { |
| 185 return base::Bind(&FakeSchedulerClient::InsideBeginImplFrameCallback, | 190 return base::Bind(&FakeSchedulerClient::InsideBeginImplFrameCallback, |
| 186 base::Unretained(this), state); | 191 base::Unretained(this), state); |
| 187 } | 192 } |
| 188 | 193 |
| 189 bool IsCurrentFrame(int last_frame_number) const { | 194 bool IsCurrentFrame(int last_frame_number) const { |
| 190 return scheduler_->current_frame_number() == last_frame_number; | 195 return scheduler_->current_frame_number() == last_frame_number; |
| 191 } | 196 } |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 SetUpScheduler(EXTERNAL_BFS); | 479 SetUpScheduler(EXTERNAL_BFS); |
| 475 | 480 |
| 476 scheduler_->SetVideoNeedsBeginFrames(true); | 481 scheduler_->SetVideoNeedsBeginFrames(true); |
| 477 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 482 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 478 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 483 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| 479 | 484 |
| 480 client_->Reset(); | 485 client_->Reset(); |
| 481 EXPECT_SCOPED(AdvanceFrame()); | 486 EXPECT_SCOPED(AdvanceFrame()); |
| 482 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 487 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 483 // WillBeginImplFrame is responsible for sending BeginFrames to video. | 488 // WillBeginImplFrame is responsible for sending BeginFrames to video. |
| 484 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | 489 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 490 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 485 | 491 |
| 486 client_->Reset(); | 492 client_->Reset(); |
| 487 EXPECT_SCOPED(AdvanceFrame()); | 493 EXPECT_SCOPED(AdvanceFrame()); |
| 488 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 494 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 489 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | 495 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 496 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 490 | 497 |
| 491 client_->Reset(); | 498 client_->Reset(); |
| 492 scheduler_->SetVideoNeedsBeginFrames(false); | 499 scheduler_->SetVideoNeedsBeginFrames(false); |
| 493 EXPECT_NO_ACTION(client_); | 500 EXPECT_NO_ACTION(client_); |
| 494 | 501 |
| 495 client_->Reset(); | 502 client_->Reset(); |
| 496 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true)); | 503 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true)); |
| 497 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 504 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 498 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); | 505 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); |
| 499 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); | 506 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 530 client_->Reset(); | 537 client_->Reset(); |
| 531 | 538 |
| 532 // NotifyReadyToActivate should trigger the activation. | 539 // NotifyReadyToActivate should trigger the activation. |
| 533 scheduler_->NotifyReadyToActivate(); | 540 scheduler_->NotifyReadyToActivate(); |
| 534 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); | 541 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); |
| 535 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 542 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| 536 client_->Reset(); | 543 client_->Reset(); |
| 537 | 544 |
| 538 // BeginImplFrame should prepare the draw. | 545 // BeginImplFrame should prepare the draw. |
| 539 EXPECT_SCOPED(AdvanceFrame()); | 546 EXPECT_SCOPED(AdvanceFrame()); |
| 540 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 547 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 548 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 541 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 549 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 542 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 550 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| 543 client_->Reset(); | 551 client_->Reset(); |
| 544 | 552 |
| 545 // BeginImplFrame deadline should draw. | 553 // BeginImplFrame deadline should draw. |
| 546 task_runner().RunPendingTasks(); // Run posted deadline. | 554 task_runner().RunPendingTasks(); // Run posted deadline. |
| 547 EXPECT_SINGLE_ACTION("ScheduledActionDrawIfPossible", client_); | 555 EXPECT_SINGLE_ACTION("ScheduledActionDrawIfPossible", client_); |
| 548 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 556 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 549 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 557 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| 550 client_->Reset(); | 558 client_->Reset(); |
| 551 | 559 |
| 552 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) | 560 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) |
| 553 // to avoid excessive toggles. | 561 // to avoid excessive toggles. |
| 554 EXPECT_SCOPED(AdvanceFrame()); | 562 EXPECT_SCOPED(AdvanceFrame()); |
| 555 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | 563 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 564 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 556 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 565 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 557 client_->Reset(); | 566 client_->Reset(); |
| 558 | 567 |
| 559 task_runner().RunPendingTasks(); // Run posted deadline. | 568 task_runner().RunPendingTasks(); // Run posted deadline. |
| 560 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); | 569 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); |
| 561 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); | 570 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
| 562 client_->Reset(); | 571 client_->Reset(); |
| 563 } | 572 } |
| 564 | 573 |
| 565 TEST_F(SchedulerTest, RequestCommitAfterSetDeferCommit) { | 574 TEST_F(SchedulerTest, RequestCommitAfterSetDeferCommit) { |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 EXPECT_TRUE(scheduler_->PrepareTilesPending()); | 974 EXPECT_TRUE(scheduler_->PrepareTilesPending()); |
| 966 EXPECT_TRUE(client->needs_begin_frames()); | 975 EXPECT_TRUE(client->needs_begin_frames()); |
| 967 EXPECT_EQ(0, client->num_draws()); | 976 EXPECT_EQ(0, client->num_draws()); |
| 968 EXPECT_FALSE(client->HasAction("ScheduledActionPrepareTiles")); | 977 EXPECT_FALSE(client->HasAction("ScheduledActionPrepareTiles")); |
| 969 EXPECT_FALSE(client->HasAction("ScheduledActionDrawIfPossible")); | 978 EXPECT_FALSE(client->HasAction("ScheduledActionDrawIfPossible")); |
| 970 | 979 |
| 971 // We have no immediate actions to perform, so the BeginImplFrame should post | 980 // We have no immediate actions to perform, so the BeginImplFrame should post |
| 972 // the deadline task. | 981 // the deadline task. |
| 973 client->Reset(); | 982 client->Reset(); |
| 974 EXPECT_SCOPED(AdvanceFrame()); | 983 EXPECT_SCOPED(AdvanceFrame()); |
| 975 EXPECT_ACTION("WillBeginImplFrame", client, 0, 1); | 984 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| 985 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client, 1, 2); |
| 976 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 986 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 977 | 987 |
| 978 // On the deadline, the actions should have occured in the right order. | 988 // On the deadline, the actions should have occured in the right order. |
| 979 client->Reset(); | 989 client->Reset(); |
| 980 task_runner().RunPendingTasks(); // Run posted deadline. | 990 task_runner().RunPendingTasks(); // Run posted deadline. |
| 981 EXPECT_EQ(1, client->num_draws()); | 991 EXPECT_EQ(1, client->num_draws()); |
| 982 EXPECT_TRUE(client->HasAction("ScheduledActionDrawIfPossible")); | 992 EXPECT_TRUE(client->HasAction("ScheduledActionDrawIfPossible")); |
| 983 EXPECT_TRUE(client->HasAction("ScheduledActionPrepareTiles")); | 993 EXPECT_TRUE(client->HasAction("ScheduledActionPrepareTiles")); |
| 984 EXPECT_LT(client->ActionIndex("ScheduledActionDrawIfPossible"), | 994 EXPECT_LT(client->ActionIndex("ScheduledActionDrawIfPossible"), |
| 985 client->ActionIndex("ScheduledActionPrepareTiles")); | 995 client->ActionIndex("ScheduledActionPrepareTiles")); |
| 986 EXPECT_FALSE(scheduler_->RedrawPending()); | 996 EXPECT_FALSE(scheduler_->RedrawPending()); |
| 987 EXPECT_FALSE(scheduler_->PrepareTilesPending()); | 997 EXPECT_FALSE(scheduler_->PrepareTilesPending()); |
| 988 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 998 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 989 | 999 |
| 990 // Request a draw. We don't need a PrepareTiles yet. | 1000 // Request a draw. We don't need a PrepareTiles yet. |
| 991 client->Reset(); | 1001 client->Reset(); |
| 992 scheduler_->SetNeedsRedraw(); | 1002 scheduler_->SetNeedsRedraw(); |
| 993 EXPECT_TRUE(scheduler_->RedrawPending()); | 1003 EXPECT_TRUE(scheduler_->RedrawPending()); |
| 994 EXPECT_FALSE(scheduler_->PrepareTilesPending()); | 1004 EXPECT_FALSE(scheduler_->PrepareTilesPending()); |
| 995 EXPECT_TRUE(client->needs_begin_frames()); | 1005 EXPECT_TRUE(client->needs_begin_frames()); |
| 996 EXPECT_EQ(0, client->num_draws()); | 1006 EXPECT_EQ(0, client->num_draws()); |
| 997 | 1007 |
| 998 // We have no immediate actions to perform, so the BeginImplFrame should post | 1008 // We have no immediate actions to perform, so the BeginImplFrame should post |
| 999 // the deadline task. | 1009 // the deadline task. |
| 1000 client->Reset(); | 1010 client->Reset(); |
| 1001 EXPECT_SCOPED(AdvanceFrame()); | 1011 EXPECT_SCOPED(AdvanceFrame()); |
| 1002 EXPECT_ACTION("WillBeginImplFrame", client, 0, 1); | 1012 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| 1013 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client, 1, 2); |
| 1003 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 1014 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 1004 | 1015 |
| 1005 // Draw. The draw will trigger SetNeedsPrepareTiles, and | 1016 // Draw. The draw will trigger SetNeedsPrepareTiles, and |
| 1006 // then the PrepareTiles action will be triggered after the Draw. | 1017 // then the PrepareTiles action will be triggered after the Draw. |
| 1007 // Afterwards, neither a draw nor PrepareTiles are pending. | 1018 // Afterwards, neither a draw nor PrepareTiles are pending. |
| 1008 client->Reset(); | 1019 client->Reset(); |
| 1009 task_runner().RunPendingTasks(); // Run posted deadline. | 1020 task_runner().RunPendingTasks(); // Run posted deadline. |
| 1010 EXPECT_EQ(1, client->num_draws()); | 1021 EXPECT_EQ(1, client->num_draws()); |
| 1011 EXPECT_TRUE(client->HasAction("ScheduledActionDrawIfPossible")); | 1022 EXPECT_TRUE(client->HasAction("ScheduledActionDrawIfPossible")); |
| 1012 EXPECT_TRUE(client->HasAction("ScheduledActionPrepareTiles")); | 1023 EXPECT_TRUE(client->HasAction("ScheduledActionPrepareTiles")); |
| 1013 EXPECT_LT(client->ActionIndex("ScheduledActionDrawIfPossible"), | 1024 EXPECT_LT(client->ActionIndex("ScheduledActionDrawIfPossible"), |
| 1014 client->ActionIndex("ScheduledActionPrepareTiles")); | 1025 client->ActionIndex("ScheduledActionPrepareTiles")); |
| 1015 EXPECT_FALSE(scheduler_->RedrawPending()); | 1026 EXPECT_FALSE(scheduler_->RedrawPending()); |
| 1016 EXPECT_FALSE(scheduler_->PrepareTilesPending()); | 1027 EXPECT_FALSE(scheduler_->PrepareTilesPending()); |
| 1017 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 1028 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 1018 | 1029 |
| 1019 // We need a BeginImplFrame where we don't swap to go idle. | 1030 // We need a BeginImplFrame where we don't swap to go idle. |
| 1020 client->Reset(); | 1031 client->Reset(); |
| 1021 EXPECT_SCOPED(AdvanceFrame()); | 1032 EXPECT_SCOPED(AdvanceFrame()); |
| 1022 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); | 1033 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| 1034 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client, 1, 2); |
| 1023 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 1035 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 1024 client->Reset(); | 1036 client->Reset(); |
| 1025 task_runner().RunPendingTasks(); // Run posted deadline. | 1037 task_runner().RunPendingTasks(); // Run posted deadline. |
| 1026 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); | 1038 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); |
| 1027 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); | 1039 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
| 1028 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 1040 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 1029 EXPECT_EQ(0, client->num_draws()); | 1041 EXPECT_EQ(0, client->num_draws()); |
| 1030 | 1042 |
| 1031 // Now trigger a PrepareTiles outside of a draw. We will then need | 1043 // Now trigger a PrepareTiles outside of a draw. We will then need |
| 1032 // a begin-frame for the PrepareTiles, but we don't need a draw. | 1044 // a begin-frame for the PrepareTiles, but we don't need a draw. |
| 1033 client->Reset(); | 1045 client->Reset(); |
| 1034 EXPECT_FALSE(client->needs_begin_frames()); | 1046 EXPECT_FALSE(client->needs_begin_frames()); |
| 1035 scheduler_->SetNeedsPrepareTiles(); | 1047 scheduler_->SetNeedsPrepareTiles(); |
| 1036 EXPECT_TRUE(client->needs_begin_frames()); | 1048 EXPECT_TRUE(client->needs_begin_frames()); |
| 1037 EXPECT_TRUE(scheduler_->PrepareTilesPending()); | 1049 EXPECT_TRUE(scheduler_->PrepareTilesPending()); |
| 1038 EXPECT_FALSE(scheduler_->RedrawPending()); | 1050 EXPECT_FALSE(scheduler_->RedrawPending()); |
| 1039 | 1051 |
| 1040 // BeginImplFrame. There will be no draw, only PrepareTiles. | 1052 // BeginImplFrame. There will be no draw, only PrepareTiles. |
| 1041 client->Reset(); | 1053 client->Reset(); |
| 1042 EXPECT_SCOPED(AdvanceFrame()); | 1054 EXPECT_SCOPED(AdvanceFrame()); |
| 1043 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); | 1055 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| 1056 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client, 1, 2); |
| 1044 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 1057 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 1045 client->Reset(); | 1058 client->Reset(); |
| 1046 task_runner().RunPendingTasks(); // Run posted deadline. | 1059 task_runner().RunPendingTasks(); // Run posted deadline. |
| 1047 EXPECT_EQ(0, client->num_draws()); | 1060 EXPECT_EQ(0, client->num_draws()); |
| 1048 EXPECT_FALSE(client->HasAction("ScheduledActionDrawIfPossible")); | 1061 EXPECT_FALSE(client->HasAction("ScheduledActionDrawIfPossible")); |
| 1049 EXPECT_TRUE(client->HasAction("ScheduledActionPrepareTiles")); | 1062 EXPECT_TRUE(client->HasAction("ScheduledActionPrepareTiles")); |
| 1050 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 1063 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 1051 } | 1064 } |
| 1052 | 1065 |
| 1053 // Test that PrepareTiles only happens once per frame. If an external caller | 1066 // Test that PrepareTiles only happens once per frame. If an external caller |
| 1054 // initiates it, then the state machine should not PrepareTiles on that frame. | 1067 // initiates it, then the state machine should not PrepareTiles on that frame. |
| 1055 TEST_F(SchedulerTest, PrepareTilesOncePerFrame) { | 1068 TEST_F(SchedulerTest, PrepareTilesOncePerFrame) { |
| 1056 SetUpScheduler(EXTERNAL_BFS); | 1069 SetUpScheduler(EXTERNAL_BFS); |
| 1057 | 1070 |
| 1058 // If DidPrepareTiles during a frame, then PrepareTiles should not occur | 1071 // If DidPrepareTiles during a frame, then PrepareTiles should not occur |
| 1059 // again. | 1072 // again. |
| 1060 scheduler_->SetNeedsPrepareTiles(); | 1073 scheduler_->SetNeedsPrepareTiles(); |
| 1061 scheduler_->SetNeedsRedraw(); | 1074 scheduler_->SetNeedsRedraw(); |
| 1062 client_->Reset(); | 1075 client_->Reset(); |
| 1063 EXPECT_SCOPED(AdvanceFrame()); | 1076 EXPECT_SCOPED(AdvanceFrame()); |
| 1064 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 1077 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 1078 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 1065 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 1079 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 1066 | 1080 |
| 1067 EXPECT_TRUE(scheduler_->PrepareTilesPending()); | 1081 EXPECT_TRUE(scheduler_->PrepareTilesPending()); |
| 1068 scheduler_->WillPrepareTiles(); | 1082 scheduler_->WillPrepareTiles(); |
| 1069 scheduler_->DidPrepareTiles(); // An explicit PrepareTiles. | 1083 scheduler_->DidPrepareTiles(); // An explicit PrepareTiles. |
| 1070 EXPECT_FALSE(scheduler_->PrepareTilesPending()); | 1084 EXPECT_FALSE(scheduler_->PrepareTilesPending()); |
| 1071 | 1085 |
| 1072 client_->Reset(); | 1086 client_->Reset(); |
| 1073 task_runner().RunPendingTasks(); // Run posted deadline. | 1087 task_runner().RunPendingTasks(); // Run posted deadline. |
| 1074 EXPECT_EQ(1, client_->num_draws()); | 1088 EXPECT_EQ(1, client_->num_draws()); |
| 1075 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawIfPossible")); | 1089 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawIfPossible")); |
| 1076 EXPECT_FALSE(client_->HasAction("ScheduledActionPrepareTiles")); | 1090 EXPECT_FALSE(client_->HasAction("ScheduledActionPrepareTiles")); |
| 1077 EXPECT_FALSE(scheduler_->RedrawPending()); | 1091 EXPECT_FALSE(scheduler_->RedrawPending()); |
| 1078 EXPECT_FALSE(scheduler_->PrepareTilesPending()); | 1092 EXPECT_FALSE(scheduler_->PrepareTilesPending()); |
| 1079 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 1093 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 1080 | 1094 |
| 1081 // Next frame without DidPrepareTiles should PrepareTiles with draw. | 1095 // Next frame without DidPrepareTiles should PrepareTiles with draw. |
| 1082 scheduler_->SetNeedsPrepareTiles(); | 1096 scheduler_->SetNeedsPrepareTiles(); |
| 1083 scheduler_->SetNeedsRedraw(); | 1097 scheduler_->SetNeedsRedraw(); |
| 1084 client_->Reset(); | 1098 client_->Reset(); |
| 1085 EXPECT_SCOPED(AdvanceFrame()); | 1099 EXPECT_SCOPED(AdvanceFrame()); |
| 1086 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 1100 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 1101 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 1087 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 1102 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 1088 | 1103 |
| 1089 client_->Reset(); | 1104 client_->Reset(); |
| 1090 task_runner().RunPendingTasks(); // Run posted deadline. | 1105 task_runner().RunPendingTasks(); // Run posted deadline. |
| 1091 EXPECT_EQ(1, client_->num_draws()); | 1106 EXPECT_EQ(1, client_->num_draws()); |
| 1092 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawIfPossible")); | 1107 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawIfPossible")); |
| 1093 EXPECT_TRUE(client_->HasAction("ScheduledActionPrepareTiles")); | 1108 EXPECT_TRUE(client_->HasAction("ScheduledActionPrepareTiles")); |
| 1094 EXPECT_LT(client_->ActionIndex("ScheduledActionDrawIfPossible"), | 1109 EXPECT_LT(client_->ActionIndex("ScheduledActionDrawIfPossible"), |
| 1095 client_->ActionIndex("ScheduledActionPrepareTiles")); | 1110 client_->ActionIndex("ScheduledActionPrepareTiles")); |
| 1096 EXPECT_FALSE(scheduler_->RedrawPending()); | 1111 EXPECT_FALSE(scheduler_->RedrawPending()); |
| 1097 EXPECT_FALSE(scheduler_->PrepareTilesPending()); | 1112 EXPECT_FALSE(scheduler_->PrepareTilesPending()); |
| 1098 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 1113 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 1099 | 1114 |
| 1100 // If we get another DidPrepareTiles within the same frame, we should | 1115 // If we get another DidPrepareTiles within the same frame, we should |
| 1101 // not PrepareTiles on the next frame. | 1116 // not PrepareTiles on the next frame. |
| 1102 scheduler_->WillPrepareTiles(); | 1117 scheduler_->WillPrepareTiles(); |
| 1103 scheduler_->DidPrepareTiles(); // An explicit PrepareTiles. | 1118 scheduler_->DidPrepareTiles(); // An explicit PrepareTiles. |
| 1104 scheduler_->SetNeedsPrepareTiles(); | 1119 scheduler_->SetNeedsPrepareTiles(); |
| 1105 scheduler_->SetNeedsRedraw(); | 1120 scheduler_->SetNeedsRedraw(); |
| 1106 client_->Reset(); | 1121 client_->Reset(); |
| 1107 EXPECT_SCOPED(AdvanceFrame()); | 1122 EXPECT_SCOPED(AdvanceFrame()); |
| 1108 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 1123 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 1124 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 1109 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 1125 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 1110 | 1126 |
| 1111 EXPECT_TRUE(scheduler_->PrepareTilesPending()); | 1127 EXPECT_TRUE(scheduler_->PrepareTilesPending()); |
| 1112 | 1128 |
| 1113 client_->Reset(); | 1129 client_->Reset(); |
| 1114 task_runner().RunPendingTasks(); // Run posted deadline. | 1130 task_runner().RunPendingTasks(); // Run posted deadline. |
| 1115 EXPECT_EQ(1, client_->num_draws()); | 1131 EXPECT_EQ(1, client_->num_draws()); |
| 1116 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawIfPossible")); | 1132 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawIfPossible")); |
| 1117 EXPECT_FALSE(client_->HasAction("ScheduledActionPrepareTiles")); | 1133 EXPECT_FALSE(client_->HasAction("ScheduledActionPrepareTiles")); |
| 1118 EXPECT_FALSE(scheduler_->RedrawPending()); | 1134 EXPECT_FALSE(scheduler_->RedrawPending()); |
| 1119 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 1135 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 1120 | 1136 |
| 1121 // If we get another DidPrepareTiles, we should not PrepareTiles on the next | 1137 // If we get another DidPrepareTiles, we should not PrepareTiles on the next |
| 1122 // frame. This verifies we don't alternate calling PrepareTiles once and | 1138 // frame. This verifies we don't alternate calling PrepareTiles once and |
| 1123 // twice. | 1139 // twice. |
| 1124 EXPECT_TRUE(scheduler_->PrepareTilesPending()); | 1140 EXPECT_TRUE(scheduler_->PrepareTilesPending()); |
| 1125 scheduler_->WillPrepareTiles(); | 1141 scheduler_->WillPrepareTiles(); |
| 1126 scheduler_->DidPrepareTiles(); // An explicit PrepareTiles. | 1142 scheduler_->DidPrepareTiles(); // An explicit PrepareTiles. |
| 1127 EXPECT_FALSE(scheduler_->PrepareTilesPending()); | 1143 EXPECT_FALSE(scheduler_->PrepareTilesPending()); |
| 1128 scheduler_->SetNeedsPrepareTiles(); | 1144 scheduler_->SetNeedsPrepareTiles(); |
| 1129 scheduler_->SetNeedsRedraw(); | 1145 scheduler_->SetNeedsRedraw(); |
| 1130 client_->Reset(); | 1146 client_->Reset(); |
| 1131 EXPECT_SCOPED(AdvanceFrame()); | 1147 EXPECT_SCOPED(AdvanceFrame()); |
| 1132 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 1148 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 1149 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 1133 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 1150 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 1134 | 1151 |
| 1135 EXPECT_TRUE(scheduler_->PrepareTilesPending()); | 1152 EXPECT_TRUE(scheduler_->PrepareTilesPending()); |
| 1136 | 1153 |
| 1137 client_->Reset(); | 1154 client_->Reset(); |
| 1138 task_runner().RunPendingTasks(); // Run posted deadline. | 1155 task_runner().RunPendingTasks(); // Run posted deadline. |
| 1139 EXPECT_EQ(1, client_->num_draws()); | 1156 EXPECT_EQ(1, client_->num_draws()); |
| 1140 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawIfPossible")); | 1157 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawIfPossible")); |
| 1141 EXPECT_FALSE(client_->HasAction("ScheduledActionPrepareTiles")); | 1158 EXPECT_FALSE(client_->HasAction("ScheduledActionPrepareTiles")); |
| 1142 EXPECT_FALSE(scheduler_->RedrawPending()); | 1159 EXPECT_FALSE(scheduler_->RedrawPending()); |
| 1143 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 1160 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 1144 | 1161 |
| 1145 // Next frame without DidPrepareTiles should PrepareTiles with draw. | 1162 // Next frame without DidPrepareTiles should PrepareTiles with draw. |
| 1146 scheduler_->SetNeedsPrepareTiles(); | 1163 scheduler_->SetNeedsPrepareTiles(); |
| 1147 scheduler_->SetNeedsRedraw(); | 1164 scheduler_->SetNeedsRedraw(); |
| 1148 client_->Reset(); | 1165 client_->Reset(); |
| 1149 EXPECT_SCOPED(AdvanceFrame()); | 1166 EXPECT_SCOPED(AdvanceFrame()); |
| 1150 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 1167 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 1168 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 1151 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 1169 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 1152 | 1170 |
| 1153 client_->Reset(); | 1171 client_->Reset(); |
| 1154 task_runner().RunPendingTasks(); // Run posted deadline. | 1172 task_runner().RunPendingTasks(); // Run posted deadline. |
| 1155 EXPECT_EQ(1, client_->num_draws()); | 1173 EXPECT_EQ(1, client_->num_draws()); |
| 1156 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawIfPossible")); | 1174 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawIfPossible")); |
| 1157 EXPECT_TRUE(client_->HasAction("ScheduledActionPrepareTiles")); | 1175 EXPECT_TRUE(client_->HasAction("ScheduledActionPrepareTiles")); |
| 1158 EXPECT_LT(client_->ActionIndex("ScheduledActionDrawIfPossible"), | 1176 EXPECT_LT(client_->ActionIndex("ScheduledActionDrawIfPossible"), |
| 1159 client_->ActionIndex("ScheduledActionPrepareTiles")); | 1177 client_->ActionIndex("ScheduledActionPrepareTiles")); |
| 1160 EXPECT_FALSE(scheduler_->RedrawPending()); | 1178 EXPECT_FALSE(scheduler_->RedrawPending()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1177 scheduler_->WillPrepareTiles(); | 1195 scheduler_->WillPrepareTiles(); |
| 1178 scheduler_->DidPrepareTiles(); | 1196 scheduler_->DidPrepareTiles(); |
| 1179 } | 1197 } |
| 1180 | 1198 |
| 1181 client_->Reset(); | 1199 client_->Reset(); |
| 1182 scheduler_->SetNeedsRedraw(); | 1200 scheduler_->SetNeedsRedraw(); |
| 1183 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 1201 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 1184 | 1202 |
| 1185 client_->Reset(); | 1203 client_->Reset(); |
| 1186 AdvanceFrame(); | 1204 AdvanceFrame(); |
| 1187 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 1205 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 1206 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 1188 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 1207 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 1189 | 1208 |
| 1190 client_->Reset(); | 1209 client_->Reset(); |
| 1191 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); | 1210 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); |
| 1192 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 1211 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 1193 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 2); | 1212 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 2); |
| 1194 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 1, 2); | 1213 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 1, 2); |
| 1195 } | 1214 } |
| 1196 | 1215 |
| 1197 TEST_F(SchedulerTest, TriggerBeginFrameDeadlineEarly) { | 1216 TEST_F(SchedulerTest, TriggerBeginFrameDeadlineEarly) { |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1664 // still expect to recover impl thread latency if there are no commits from | 1683 // still expect to recover impl thread latency if there are no commits from |
| 1665 // the main thread. | 1684 // the main thread. |
| 1666 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration); | 1685 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration); |
| 1667 fake_compositor_timing_history_->SetDrawDurationEstimate(kFastDuration); | 1686 fake_compositor_timing_history_->SetDrawDurationEstimate(kFastDuration); |
| 1668 | 1687 |
| 1669 // Draw and swap for first BeginFrame | 1688 // Draw and swap for first BeginFrame |
| 1670 client_->Reset(); | 1689 client_->Reset(); |
| 1671 scheduler_->SetNeedsRedraw(); | 1690 scheduler_->SetNeedsRedraw(); |
| 1672 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); | 1691 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1673 SendNextBeginFrame(); | 1692 SendNextBeginFrame(); |
| 1674 EXPECT_ACTION("AddObserver(this)", client_, 0, 2); | 1693 EXPECT_ACTION("AddObserver(this)", client_, 0, 3); |
| 1675 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 2); | 1694 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 3); |
| 1695 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 2, 3); |
| 1676 | 1696 |
| 1677 client_->Reset(); | 1697 client_->Reset(); |
| 1678 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); | 1698 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1679 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); | 1699 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); |
| 1680 EXPECT_SINGLE_ACTION("ScheduledActionDrawIfPossible", client_); | 1700 EXPECT_SINGLE_ACTION("ScheduledActionDrawIfPossible", client_); |
| 1681 | 1701 |
| 1682 // Verify we skip every other frame if the swap ack consistently | 1702 // Verify we skip every other frame if the swap ack consistently |
| 1683 // comes back late. | 1703 // comes back late. |
| 1684 for (int i = 0; i < 10; i++) { | 1704 for (int i = 0; i < 10; i++) { |
| 1685 // Not calling scheduler_->DidReceiveCompositorFrameAck() until after next | 1705 // Not calling scheduler_->DidReceiveCompositorFrameAck() until after next |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1697 // swap throttled. | 1717 // swap throttled. |
| 1698 client_->Reset(); | 1718 client_->Reset(); |
| 1699 scheduler_->DidReceiveCompositorFrameAck(); | 1719 scheduler_->DidReceiveCompositorFrameAck(); |
| 1700 EXPECT_NO_ACTION(client_); | 1720 EXPECT_NO_ACTION(client_); |
| 1701 | 1721 |
| 1702 // Verify that we start the next BeginImplFrame and continue normally | 1722 // Verify that we start the next BeginImplFrame and continue normally |
| 1703 // after having just skipped a BeginImplFrame. | 1723 // after having just skipped a BeginImplFrame. |
| 1704 client_->Reset(); | 1724 client_->Reset(); |
| 1705 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); | 1725 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1706 SendNextBeginFrame(); | 1726 SendNextBeginFrame(); |
| 1707 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 1727 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 1728 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, |
| 1729 2); |
| 1708 | 1730 |
| 1709 client_->Reset(); | 1731 client_->Reset(); |
| 1710 // Deadline should be immediate. | 1732 // Deadline should be immediate. |
| 1711 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 1733 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 1712 task_runner().RunUntilTime(now_src_->NowTicks()); | 1734 task_runner().RunUntilTime(now_src_->NowTicks()); |
| 1713 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 1735 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 1714 EXPECT_SINGLE_ACTION("ScheduledActionDrawIfPossible", client_); | 1736 EXPECT_SINGLE_ACTION("ScheduledActionDrawIfPossible", client_); |
| 1715 } | 1737 } |
| 1716 } | 1738 } |
| 1717 | 1739 |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2075 // Can't run the deadline task because it can race with begin frame for the | 2097 // Can't run the deadline task because it can race with begin frame for the |
| 2076 // SyntheticBFS case. | 2098 // SyntheticBFS case. |
| 2077 EXPECT_SCOPED(AdvanceFrame()); | 2099 EXPECT_SCOPED(AdvanceFrame()); |
| 2078 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 2100 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); |
| 2079 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2101 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 2080 client_->Reset(); | 2102 client_->Reset(); |
| 2081 | 2103 |
| 2082 // NotifyReadyToCommit should trigger the commit. | 2104 // NotifyReadyToCommit should trigger the commit. |
| 2083 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); | 2105 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); |
| 2084 scheduler_->NotifyReadyToCommit(); | 2106 scheduler_->NotifyReadyToCommit(); |
| 2085 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); | 2107 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 1); |
| 2086 client_->Reset(); | 2108 client_->Reset(); |
| 2087 | 2109 |
| 2088 // NotifyReadyToActivate should trigger the activation. | 2110 // NotifyReadyToActivate should trigger the activation. |
| 2089 scheduler_->NotifyReadyToActivate(); | 2111 scheduler_->NotifyReadyToActivate(); |
| 2090 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); | 2112 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); |
| 2091 client_->Reset(); | 2113 client_->Reset(); |
| 2092 | 2114 |
| 2093 // BeginImplFrame deadline should draw. The following BeginImplFrame deadline | 2115 // BeginImplFrame deadline should draw. The following BeginImplFrame deadline |
| 2094 // should SetNeedsBeginFrame(false) to avoid excessive toggles. | 2116 // should SetNeedsBeginFrame(false) to avoid excessive toggles. |
| 2095 EXPECT_SCOPED(AdvanceFrame()); | 2117 EXPECT_SCOPED(AdvanceFrame()); |
| 2096 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 2); | 2118 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 3); |
| 2097 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 2); | 2119 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 3); |
| 2120 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 2, 3); |
| 2098 client_->Reset(); | 2121 client_->Reset(); |
| 2099 | 2122 |
| 2100 // Make sure SetNeedsBeginFrame isn't called on the client | 2123 // Make sure SetNeedsBeginFrame isn't called on the client |
| 2101 // when the BeginFrame is no longer needed. | 2124 // when the BeginFrame is no longer needed. |
| 2102 task_runner().RunPendingTasks(); // Run posted deadline. | 2125 task_runner().RunPendingTasks(); // Run posted deadline. |
| 2103 EXPECT_SINGLE_ACTION("SendBeginMainFrameNotExpectedSoon", client_); | 2126 EXPECT_SINGLE_ACTION("SendBeginMainFrameNotExpectedSoon", client_); |
| 2104 client_->Reset(); | 2127 client_->Reset(); |
| 2105 } | 2128 } |
| 2106 | 2129 |
| 2107 TEST_F(SchedulerTest, SyntheticBeginFrames) { | 2130 TEST_F(SchedulerTest, SyntheticBeginFrames) { |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2338 | 2361 |
| 2339 TEST_F(SchedulerTest, DidLoseCompositorFrameSinkAfterSetNeedsPrepareTiles) { | 2362 TEST_F(SchedulerTest, DidLoseCompositorFrameSinkAfterSetNeedsPrepareTiles) { |
| 2340 SetUpScheduler(EXTERNAL_BFS); | 2363 SetUpScheduler(EXTERNAL_BFS); |
| 2341 | 2364 |
| 2342 scheduler_->SetNeedsPrepareTiles(); | 2365 scheduler_->SetNeedsPrepareTiles(); |
| 2343 scheduler_->SetNeedsRedraw(); | 2366 scheduler_->SetNeedsRedraw(); |
| 2344 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2367 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 2345 | 2368 |
| 2346 client_->Reset(); | 2369 client_->Reset(); |
| 2347 EXPECT_SCOPED(AdvanceFrame()); | 2370 EXPECT_SCOPED(AdvanceFrame()); |
| 2348 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 2371 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 2372 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 2349 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2373 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 2350 | 2374 |
| 2351 client_->Reset(); | 2375 client_->Reset(); |
| 2352 scheduler_->DidLoseCompositorFrameSink(); | 2376 scheduler_->DidLoseCompositorFrameSink(); |
| 2353 // RemoveObserver(this) is not called until the end of the frame. | 2377 // RemoveObserver(this) is not called until the end of the frame. |
| 2354 EXPECT_NO_ACTION(client_); | 2378 EXPECT_NO_ACTION(client_); |
| 2355 | 2379 |
| 2356 client_->Reset(); | 2380 client_->Reset(); |
| 2357 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); | 2381 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); |
| 2358 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 0, 4); | 2382 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 0, 4); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2499 // Tests to ensure frame sources can be successfully changed while drawing. | 2523 // Tests to ensure frame sources can be successfully changed while drawing. |
| 2500 TEST_F(SchedulerTest, SwitchFrameSourceToUnthrottled) { | 2524 TEST_F(SchedulerTest, SwitchFrameSourceToUnthrottled) { |
| 2501 SetUpScheduler(EXTERNAL_BFS); | 2525 SetUpScheduler(EXTERNAL_BFS); |
| 2502 | 2526 |
| 2503 // SetNeedsRedraw should begin the frame on the next BeginImplFrame. | 2527 // SetNeedsRedraw should begin the frame on the next BeginImplFrame. |
| 2504 scheduler_->SetNeedsRedraw(); | 2528 scheduler_->SetNeedsRedraw(); |
| 2505 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2529 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 2506 client_->Reset(); | 2530 client_->Reset(); |
| 2507 | 2531 |
| 2508 EXPECT_SCOPED(AdvanceFrame()); | 2532 EXPECT_SCOPED(AdvanceFrame()); |
| 2509 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 2533 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 2534 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 2510 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2535 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 2511 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 2536 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| 2512 client_->Reset(); | 2537 client_->Reset(); |
| 2513 task_runner().RunPendingTasks(); // Run posted deadline. | 2538 task_runner().RunPendingTasks(); // Run posted deadline. |
| 2514 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); | 2539 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); |
| 2515 scheduler_->SetNeedsRedraw(); | 2540 scheduler_->SetNeedsRedraw(); |
| 2516 | 2541 |
| 2517 // Switch to an unthrottled frame source. | 2542 // Switch to an unthrottled frame source. |
| 2518 scheduler_->SetBeginFrameSource(unthrottled_frame_source_.get()); | 2543 scheduler_->SetBeginFrameSource(unthrottled_frame_source_.get()); |
| 2519 client_->Reset(); | 2544 client_->Reset(); |
| 2520 | 2545 |
| 2521 // Unthrottled frame source will immediately begin a new frame. | 2546 // Unthrottled frame source will immediately begin a new frame. |
| 2522 task_runner().RunPendingTasks(); // Run posted BeginFrame. | 2547 task_runner().RunPendingTasks(); // Run posted BeginFrame. |
| 2523 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 2548 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 2549 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 2524 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2550 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 2525 client_->Reset(); | 2551 client_->Reset(); |
| 2526 | 2552 |
| 2527 // If we don't swap on the deadline, we wait for the next BeginFrame. | 2553 // If we don't swap on the deadline, we wait for the next BeginFrame. |
| 2528 task_runner().RunPendingTasks(); // Run posted deadline. | 2554 task_runner().RunPendingTasks(); // Run posted deadline. |
| 2529 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); | 2555 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); |
| 2530 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 2556 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 2531 client_->Reset(); | 2557 client_->Reset(); |
| 2532 } | 2558 } |
| 2533 | 2559 |
| 2534 // Tests to ensure frame sources can be successfully changed while a frame | 2560 // Tests to ensure frame sources can be successfully changed while a frame |
| 2535 // deadline is pending. | 2561 // deadline is pending. |
| 2536 TEST_F(SchedulerTest, SwitchFrameSourceToUnthrottledBeforeDeadline) { | 2562 TEST_F(SchedulerTest, SwitchFrameSourceToUnthrottledBeforeDeadline) { |
| 2537 SetUpScheduler(EXTERNAL_BFS); | 2563 SetUpScheduler(EXTERNAL_BFS); |
| 2538 | 2564 |
| 2539 // SetNeedsRedraw should begin the frame on the next BeginImplFrame. | 2565 // SetNeedsRedraw should begin the frame on the next BeginImplFrame. |
| 2540 scheduler_->SetNeedsRedraw(); | 2566 scheduler_->SetNeedsRedraw(); |
| 2541 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2567 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 2542 client_->Reset(); | 2568 client_->Reset(); |
| 2543 | 2569 |
| 2544 EXPECT_SCOPED(AdvanceFrame()); | 2570 EXPECT_SCOPED(AdvanceFrame()); |
| 2545 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | 2571 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 2572 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 2546 | 2573 |
| 2547 // Switch to an unthrottled frame source before the frame deadline is hit. | 2574 // Switch to an unthrottled frame source before the frame deadline is hit. |
| 2548 scheduler_->SetBeginFrameSource(unthrottled_frame_source_.get()); | 2575 scheduler_->SetBeginFrameSource(unthrottled_frame_source_.get()); |
| 2549 client_->Reset(); | 2576 client_->Reset(); |
| 2550 | 2577 |
| 2551 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2578 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 2552 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 2579 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| 2553 client_->Reset(); | 2580 client_->Reset(); |
| 2554 | 2581 |
| 2555 task_runner().RunPendingTasks(); // Run posted deadline. | 2582 task_runner().RunPendingTasks(); // Run posted deadline. |
| 2556 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 2); | 2583 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 3); |
| 2557 // Unthrottled frame source will immediately begin a new frame. | 2584 // Unthrottled frame source will immediately begin a new frame. |
| 2558 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 2); | 2585 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 3); |
| 2586 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 2, 3); |
| 2559 scheduler_->SetNeedsRedraw(); | 2587 scheduler_->SetNeedsRedraw(); |
| 2560 client_->Reset(); | 2588 client_->Reset(); |
| 2561 | 2589 |
| 2562 task_runner().RunPendingTasks(); // Run posted deadline. | 2590 task_runner().RunPendingTasks(); // Run posted deadline. |
| 2563 EXPECT_SINGLE_ACTION("ScheduledActionDrawIfPossible", client_); | 2591 EXPECT_SINGLE_ACTION("ScheduledActionDrawIfPossible", client_); |
| 2564 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 2592 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 2565 client_->Reset(); | 2593 client_->Reset(); |
| 2566 } | 2594 } |
| 2567 | 2595 |
| 2568 // Tests to ensure that the active frame source can successfully be changed from | 2596 // Tests to ensure that the active frame source can successfully be changed from |
| 2569 // unthrottled to throttled. | 2597 // unthrottled to throttled. |
| 2570 TEST_F(SchedulerTest, SwitchFrameSourceToThrottled) { | 2598 TEST_F(SchedulerTest, SwitchFrameSourceToThrottled) { |
| 2571 SetUpScheduler(UNTHROTTLED_BFS); | 2599 SetUpScheduler(UNTHROTTLED_BFS); |
| 2572 | 2600 |
| 2573 scheduler_->SetNeedsRedraw(); | 2601 scheduler_->SetNeedsRedraw(); |
| 2574 EXPECT_NO_ACTION(client_); | 2602 EXPECT_NO_ACTION(client_); |
| 2575 client_->Reset(); | 2603 client_->Reset(); |
| 2576 | 2604 |
| 2577 task_runner().RunPendingTasks(); // Run posted BeginFrame. | 2605 task_runner().RunPendingTasks(); // Run posted BeginFrame. |
| 2578 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 2606 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 2607 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 2579 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2608 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 2580 client_->Reset(); | 2609 client_->Reset(); |
| 2581 | 2610 |
| 2582 task_runner().RunPendingTasks(); // Run posted deadline. | 2611 task_runner().RunPendingTasks(); // Run posted deadline. |
| 2583 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); | 2612 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); |
| 2584 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 2613 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 2585 client_->Reset(); | 2614 client_->Reset(); |
| 2586 | 2615 |
| 2587 // Switch to a throttled frame source. | 2616 // Switch to a throttled frame source. |
| 2588 scheduler_->SetBeginFrameSource(fake_external_begin_frame_source_.get()); | 2617 scheduler_->SetBeginFrameSource(fake_external_begin_frame_source_.get()); |
| 2589 client_->Reset(); | 2618 client_->Reset(); |
| 2590 | 2619 |
| 2591 // SetNeedsRedraw should begin the frame on the next BeginImplFrame. | 2620 // SetNeedsRedraw should begin the frame on the next BeginImplFrame. |
| 2592 scheduler_->SetNeedsRedraw(); | 2621 scheduler_->SetNeedsRedraw(); |
| 2593 task_runner().RunPendingTasks(); | 2622 task_runner().RunPendingTasks(); |
| 2594 EXPECT_NO_ACTION(client_); | 2623 EXPECT_NO_ACTION(client_); |
| 2595 client_->Reset(); | 2624 client_->Reset(); |
| 2596 | 2625 |
| 2597 EXPECT_SCOPED(AdvanceFrame()); | 2626 EXPECT_SCOPED(AdvanceFrame()); |
| 2598 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 2627 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 2628 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 2599 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2629 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 2600 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 2630 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| 2601 client_->Reset(); | 2631 client_->Reset(); |
| 2602 task_runner().RunPendingTasks(); // Run posted deadline. | 2632 task_runner().RunPendingTasks(); // Run posted deadline. |
| 2603 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); | 2633 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); |
| 2604 } | 2634 } |
| 2605 | 2635 |
| 2606 TEST_F(SchedulerTest, SwitchFrameSourceToNullInsideDeadline) { | 2636 TEST_F(SchedulerTest, SwitchFrameSourceToNullInsideDeadline) { |
| 2607 SetUpScheduler(EXTERNAL_BFS); | 2637 SetUpScheduler(EXTERNAL_BFS); |
| 2608 | 2638 |
| 2609 scheduler_->SetNeedsRedraw(); | 2639 scheduler_->SetNeedsRedraw(); |
| 2610 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2640 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 2611 client_->Reset(); | 2641 client_->Reset(); |
| 2612 | 2642 |
| 2613 EXPECT_SCOPED(AdvanceFrame()); | 2643 EXPECT_SCOPED(AdvanceFrame()); |
| 2614 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | 2644 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 2645 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 2615 client_->Reset(); | 2646 client_->Reset(); |
| 2616 | 2647 |
| 2617 // Switch to a null frame source. | 2648 // Switch to a null frame source. |
| 2618 scheduler_->SetBeginFrameSource(nullptr); | 2649 scheduler_->SetBeginFrameSource(nullptr); |
| 2619 EXPECT_SINGLE_ACTION("RemoveObserver(this)", client_); | 2650 EXPECT_SINGLE_ACTION("RemoveObserver(this)", client_); |
| 2620 client_->Reset(); | 2651 client_->Reset(); |
| 2621 | 2652 |
| 2622 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2653 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 2623 task_runner().RunPendingTasks(); // Run posted deadline. | 2654 task_runner().RunPendingTasks(); // Run posted deadline. |
| 2624 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); | 2655 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2701 client_->Reset(); | 2732 client_->Reset(); |
| 2702 scheduler_->SetNeedsBeginMainFrame(); | 2733 scheduler_->SetNeedsBeginMainFrame(); |
| 2703 EXPECT_NO_ACTION(client_); | 2734 EXPECT_NO_ACTION(client_); |
| 2704 | 2735 |
| 2705 client_->Reset(); | 2736 client_->Reset(); |
| 2706 EXPECT_SCOPED(AdvanceFrame()); | 2737 EXPECT_SCOPED(AdvanceFrame()); |
| 2707 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 2738 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 2708 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 2739 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 2709 } | 2740 } |
| 2710 | 2741 |
| 2742 // Tests to ensure that we send a ScheduledActionBeginMainFrameNotExpectedUntil |
| 2743 // when expected. |
| 2744 TEST_F(SchedulerTest, ScheduledActionBeginMainFrameNotExpectedUntil) { |
| 2745 SetUpScheduler(EXTERNAL_BFS); |
| 2746 |
| 2747 scheduler_->SetNeedsRedraw(); |
| 2748 EXPECT_ACTION("AddObserver(this)", client_, 0, 1); |
| 2749 client_->Reset(); |
| 2750 |
| 2751 EXPECT_SCOPED(AdvanceFrame()); |
| 2752 task_runner().RunPendingTasks(); |
| 2753 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); |
| 2754 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 3); |
| 2755 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 2, 3); |
| 2756 client_->Reset(); |
| 2757 } |
| 2758 |
| 2711 // Tests to ensure that we send a BeginMainFrameNotExpectedSoon when expected. | 2759 // Tests to ensure that we send a BeginMainFrameNotExpectedSoon when expected. |
| 2712 TEST_F(SchedulerTest, SendBeginMainFrameNotExpectedSoon) { | 2760 TEST_F(SchedulerTest, SendBeginMainFrameNotExpectedSoon) { |
| 2713 SetUpScheduler(EXTERNAL_BFS); | 2761 SetUpScheduler(EXTERNAL_BFS); |
| 2714 | 2762 |
| 2715 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. | 2763 // SetNeedsBeginMainFrame should begin the frame on the next BeginImplFrame. |
| 2716 scheduler_->SetNeedsBeginMainFrame(); | 2764 scheduler_->SetNeedsBeginMainFrame(); |
| 2717 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2765 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 2718 client_->Reset(); | 2766 client_->Reset(); |
| 2719 | 2767 |
| 2720 // Trigger a frame draw. | 2768 // Trigger a frame draw. |
| 2721 EXPECT_SCOPED(AdvanceFrame()); | 2769 EXPECT_SCOPED(AdvanceFrame()); |
| 2722 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); | 2770 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); |
| 2723 scheduler_->NotifyReadyToCommit(); | 2771 scheduler_->NotifyReadyToCommit(); |
| 2724 scheduler_->NotifyReadyToActivate(); | 2772 scheduler_->NotifyReadyToActivate(); |
| 2725 task_runner().RunPendingTasks(); | 2773 task_runner().RunPendingTasks(); |
| 2726 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 5); | 2774 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 5); |
| 2727 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 5); | 2775 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 5); |
| 2728 EXPECT_ACTION("ScheduledActionCommit", client_, 2, 5); | 2776 EXPECT_ACTION("ScheduledActionCommit", client_, 2, 5); |
| 2729 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 3, 5); | 2777 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 3, 5); |
| 2730 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 4, 5); | 2778 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 4, 5); |
| 2731 client_->Reset(); | 2779 client_->Reset(); |
| 2732 | 2780 |
| 2733 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) | 2781 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) |
| 2734 // and send a SendBeginMainFrameNotExpectedSoon. | 2782 // and send a SendBeginMainFrameNotExpectedSoon. |
| 2735 EXPECT_SCOPED(AdvanceFrame()); | 2783 EXPECT_SCOPED(AdvanceFrame()); |
| 2736 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | 2784 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 2785 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 2737 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2786 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 2738 client_->Reset(); | 2787 client_->Reset(); |
| 2739 | 2788 |
| 2740 task_runner().RunPendingTasks(); // Run posted deadline. | 2789 task_runner().RunPendingTasks(); // Run posted deadline. |
| 2741 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); | 2790 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); |
| 2742 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); | 2791 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
| 2743 client_->Reset(); | 2792 client_->Reset(); |
| 2744 } | 2793 } |
| 2745 | 2794 |
| 2746 TEST_F(SchedulerTest, SynchronousCompositorAnimation) { | 2795 TEST_F(SchedulerTest, SynchronousCompositorAnimation) { |
| 2747 scheduler_settings_.using_synchronous_renderer_compositor = true; | 2796 scheduler_settings_.using_synchronous_renderer_compositor = true; |
| 2748 SetUpScheduler(EXTERNAL_BFS); | 2797 SetUpScheduler(EXTERNAL_BFS); |
| 2749 | 2798 |
| 2750 scheduler_->SetNeedsOneBeginImplFrame(); | 2799 scheduler_->SetNeedsOneBeginImplFrame(); |
| 2751 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2800 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 2752 client_->Reset(); | 2801 client_->Reset(); |
| 2753 | 2802 |
| 2754 // Testing the case where animation ticks a fling scroll. | 2803 // Testing the case where animation ticks a fling scroll. |
| 2755 client_->SetWillBeginImplFrameCausesRedraw(true); | 2804 client_->SetWillBeginImplFrameCausesRedraw(true); |
| 2756 // The animation isn't done so it'll cause another tick in the future. | 2805 // The animation isn't done so it'll cause another tick in the future. |
| 2757 client_->SetWillBeginImplFrameRequestsOneBeginImplFrame(true); | 2806 client_->SetWillBeginImplFrameRequestsOneBeginImplFrame(true); |
| 2758 | 2807 |
| 2759 // Next vsync. | 2808 // Next vsync. |
| 2760 AdvanceFrame(); | 2809 AdvanceFrame(); |
| 2761 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 2810 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); |
| 2762 EXPECT_ACTION("ScheduledActionInvalidateCompositorFrameSink", client_, 1, 2); | 2811 EXPECT_ACTION("ScheduledActionInvalidateCompositorFrameSink", client_, 2, 3); |
| 2812 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 3); |
| 2763 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 2813 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 2764 client_->Reset(); | 2814 client_->Reset(); |
| 2765 | 2815 |
| 2766 // Android onDraw. This doesn't consume the single begin frame request. | 2816 // Android onDraw. This doesn't consume the single begin frame request. |
| 2767 scheduler_->SetNeedsRedraw(); | 2817 scheduler_->SetNeedsRedraw(); |
| 2768 bool resourceless_software_draw = false; | 2818 bool resourceless_software_draw = false; |
| 2769 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw); | 2819 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw); |
| 2770 EXPECT_SINGLE_ACTION("ScheduledActionDrawIfPossible", client_); | 2820 EXPECT_SINGLE_ACTION("ScheduledActionDrawIfPossible", client_); |
| 2771 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 2821 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 2772 client_->Reset(); | 2822 client_->Reset(); |
| 2773 | 2823 |
| 2774 // The animation inside of WillBeginImplFrame changes stuff on the screen, but | 2824 // The animation inside of WillBeginImplFrame changes stuff on the screen, but |
| 2775 // ends here, so does not cause another frame to happen. | 2825 // ends here, so does not cause another frame to happen. |
| 2776 client_->SetWillBeginImplFrameCausesRedraw(true); | 2826 client_->SetWillBeginImplFrameCausesRedraw(true); |
| 2777 | 2827 |
| 2778 // Next vsync. | 2828 // Next vsync. |
| 2779 AdvanceFrame(); | 2829 AdvanceFrame(); |
| 2780 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 2830 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); |
| 2781 EXPECT_ACTION("ScheduledActionInvalidateCompositorFrameSink", client_, 1, 2); | 2831 EXPECT_ACTION("ScheduledActionInvalidateCompositorFrameSink", client_, 1, 3); |
| 2832 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 2, 3); |
| 2782 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 2833 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 2783 client_->Reset(); | 2834 client_->Reset(); |
| 2784 | 2835 |
| 2785 // Android onDraw. | 2836 // Android onDraw. |
| 2786 scheduler_->SetNeedsRedraw(); | 2837 scheduler_->SetNeedsRedraw(); |
| 2787 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw); | 2838 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw); |
| 2788 EXPECT_SINGLE_ACTION("ScheduledActionDrawIfPossible", client_); | 2839 EXPECT_SINGLE_ACTION("ScheduledActionDrawIfPossible", client_); |
| 2789 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 2840 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 2790 client_->Reset(); | 2841 client_->Reset(); |
| 2791 | 2842 |
| 2792 // Idle on next vsync, as the animation has completed. | 2843 // Idle on next vsync, as the animation has completed. |
| 2793 AdvanceFrame(); | 2844 AdvanceFrame(); |
| 2794 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); | 2845 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 4); |
| 2795 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); | 2846 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 4); |
| 2796 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); | 2847 EXPECT_ACTION("RemoveObserver(this)", client_, 2, 4); |
| 2848 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 3, 4); |
| 2797 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 2849 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 2798 client_->Reset(); | 2850 client_->Reset(); |
| 2799 } | 2851 } |
| 2800 | 2852 |
| 2801 TEST_F(SchedulerTest, SynchronousCompositorOnDrawDuringIdle) { | 2853 TEST_F(SchedulerTest, SynchronousCompositorOnDrawDuringIdle) { |
| 2802 scheduler_settings_.using_synchronous_renderer_compositor = true; | 2854 scheduler_settings_.using_synchronous_renderer_compositor = true; |
| 2803 SetUpScheduler(EXTERNAL_BFS); | 2855 SetUpScheduler(EXTERNAL_BFS); |
| 2804 | 2856 |
| 2805 scheduler_->SetNeedsRedraw(); | 2857 scheduler_->SetNeedsRedraw(); |
| 2806 bool resourceless_software_draw = false; | 2858 bool resourceless_software_draw = false; |
| 2807 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw); | 2859 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw); |
| 2808 EXPECT_ACTION("AddObserver(this)", client_, 0, 2); | 2860 EXPECT_ACTION("AddObserver(this)", client_, 0, 2); |
| 2809 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 1, 2); | 2861 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 1, 2); |
| 2810 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 2862 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 2811 client_->Reset(); | 2863 client_->Reset(); |
| 2812 | 2864 |
| 2813 // Idle on next vsync. | 2865 // Idle on next vsync. |
| 2814 AdvanceFrame(); | 2866 AdvanceFrame(); |
| 2815 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); | 2867 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 4); |
| 2816 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); | 2868 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 4); |
| 2817 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); | 2869 EXPECT_ACTION("RemoveObserver(this)", client_, 2, 4); |
| 2870 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 3, 4); |
| 2818 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 2871 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 2819 client_->Reset(); | 2872 client_->Reset(); |
| 2820 } | 2873 } |
| 2821 | 2874 |
| 2822 TEST_F(SchedulerTest, SetNeedsOneBeginImplFrame) { | 2875 TEST_F(SchedulerTest, SetNeedsOneBeginImplFrame) { |
| 2823 SetUpScheduler(EXTERNAL_BFS); | 2876 SetUpScheduler(EXTERNAL_BFS); |
| 2824 | 2877 |
| 2825 EXPECT_FALSE(scheduler_->begin_frames_expected()); | 2878 EXPECT_FALSE(scheduler_->begin_frames_expected()); |
| 2826 | 2879 |
| 2827 // Request a frame, should kick the source. | 2880 // Request a frame, should kick the source. |
| 2828 scheduler_->SetNeedsOneBeginImplFrame(); | 2881 scheduler_->SetNeedsOneBeginImplFrame(); |
| 2829 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2882 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 2830 client_->Reset(); | 2883 client_->Reset(); |
| 2831 | 2884 |
| 2832 // The incoming WillBeginImplFrame will request another one. | 2885 // The incoming WillBeginImplFrame will request another one. |
| 2833 client_->SetWillBeginImplFrameRequestsOneBeginImplFrame(true); | 2886 client_->SetWillBeginImplFrameRequestsOneBeginImplFrame(true); |
| 2834 | 2887 |
| 2835 // Next vsync, the first requested frame happens. | 2888 // Next vsync, the first requested frame happens. |
| 2836 EXPECT_SCOPED(AdvanceFrame()); | 2889 EXPECT_SCOPED(AdvanceFrame()); |
| 2837 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 2890 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 2891 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 2838 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2892 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 2839 client_->Reset(); | 2893 client_->Reset(); |
| 2840 | 2894 |
| 2841 // We don't request another frame here. | 2895 // We don't request another frame here. |
| 2842 | 2896 |
| 2843 // Next vsync, the second requested frame happens (the one requested inside | 2897 // Next vsync, the second requested frame happens (the one requested inside |
| 2844 // the previous frame's begin impl frame step). | 2898 // the previous frame's begin impl frame step). |
| 2845 EXPECT_SCOPED(AdvanceFrame()); | 2899 EXPECT_SCOPED(AdvanceFrame()); |
| 2846 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 2900 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 2901 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 2847 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 2902 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 2848 client_->Reset(); | 2903 client_->Reset(); |
| 2849 | 2904 |
| 2850 // End that frame's deadline. | 2905 // End that frame's deadline. |
| 2851 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true)); | 2906 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true)); |
| 2852 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 2907 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 2853 | 2908 |
| 2854 // Scheduler shuts down the source now that no begin frame is requested. | 2909 // Scheduler shuts down the source now that no begin frame is requested. |
| 2855 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); | 2910 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); |
| 2856 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); | 2911 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2897 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 2952 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 2898 client_->Reset(); | 2953 client_->Reset(); |
| 2899 | 2954 |
| 2900 has_damage = false; | 2955 has_damage = false; |
| 2901 EXPECT_EQ( | 2956 EXPECT_EQ( |
| 2902 BeginFrameAck(args.source_id, args.sequence_number, | 2957 BeginFrameAck(args.source_id, args.sequence_number, |
| 2903 latest_confirmed_sequence_number, has_damage), | 2958 latest_confirmed_sequence_number, has_damage), |
| 2904 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | 2959 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); |
| 2905 | 2960 |
| 2906 scheduler_->NotifyReadyToCommit(); | 2961 scheduler_->NotifyReadyToCommit(); |
| 2907 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); | 2962 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 1); |
| 2908 client_->Reset(); | 2963 client_->Reset(); |
| 2909 | 2964 |
| 2910 scheduler_->NotifyReadyToActivate(); | 2965 scheduler_->NotifyReadyToActivate(); |
| 2911 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); | 2966 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); |
| 2912 client_->Reset(); | 2967 client_->Reset(); |
| 2913 | 2968 |
| 2914 // Next vsync. | 2969 // Next vsync. |
| 2915 args = SendNextBeginFrame(); | 2970 args = SendNextBeginFrame(); |
| 2916 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 2971 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); |
| 2917 EXPECT_ACTION("ScheduledActionInvalidateCompositorFrameSink", client_, 1, 2); | 2972 EXPECT_ACTION("ScheduledActionInvalidateCompositorFrameSink", client_, 1, 3); |
| 2973 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 2, 3); |
| 2918 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 2974 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 2919 client_->Reset(); | 2975 client_->Reset(); |
| 2920 | 2976 |
| 2921 // Not confirmed yet and no damage, since not drawn yet. | 2977 // Not confirmed yet and no damage, since not drawn yet. |
| 2922 // TODO(eseckler): In the future, |has_damage = false| will prevent us from | 2978 // TODO(eseckler): In the future, |has_damage = false| will prevent us from |
| 2923 // filtering this ack (in CompositorExternalBeginFrameSource) and instead | 2979 // filtering this ack (in CompositorExternalBeginFrameSource) and instead |
| 2924 // forwarding the one attached to the later submitted CompositorFrame. | 2980 // forwarding the one attached to the later submitted CompositorFrame. |
| 2925 has_damage = false; | 2981 has_damage = false; |
| 2926 EXPECT_EQ( | 2982 EXPECT_EQ( |
| 2927 BeginFrameAck(args.source_id, args.sequence_number, | 2983 BeginFrameAck(args.source_id, args.sequence_number, |
| 2928 latest_confirmed_sequence_number, has_damage), | 2984 latest_confirmed_sequence_number, has_damage), |
| 2929 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | 2985 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); |
| 2930 | 2986 |
| 2931 // Android onDraw. | 2987 // Android onDraw. |
| 2932 scheduler_->SetNeedsRedraw(); | 2988 scheduler_->SetNeedsRedraw(); |
| 2933 bool resourceless_software_draw = false; | 2989 bool resourceless_software_draw = false; |
| 2934 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw); | 2990 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw); |
| 2935 EXPECT_SINGLE_ACTION("ScheduledActionDrawIfPossible", client_); | 2991 EXPECT_SINGLE_ACTION("ScheduledActionDrawIfPossible", client_); |
| 2936 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 2992 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 2937 client_->Reset(); | 2993 client_->Reset(); |
| 2938 | 2994 |
| 2939 // Idle on next vsync. | 2995 // Idle on next vsync. |
| 2940 args = SendNextBeginFrame(); | 2996 args = SendNextBeginFrame(); |
| 2941 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); | 2997 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 4); |
| 2942 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); | 2998 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 4); |
| 2943 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); | 2999 EXPECT_ACTION("RemoveObserver(this)", client_, 2, 4); |
| 3000 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 3, 4); |
| 2944 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3001 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 2945 client_->Reset(); | 3002 client_->Reset(); |
| 2946 | 3003 |
| 2947 latest_confirmed_sequence_number = args.sequence_number; | 3004 latest_confirmed_sequence_number = args.sequence_number; |
| 2948 has_damage = false; | 3005 has_damage = false; |
| 2949 EXPECT_EQ( | 3006 EXPECT_EQ( |
| 2950 BeginFrameAck(args.source_id, args.sequence_number, | 3007 BeginFrameAck(args.source_id, args.sequence_number, |
| 2951 latest_confirmed_sequence_number, has_damage), | 3008 latest_confirmed_sequence_number, has_damage), |
| 2952 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | 3009 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); |
| 2953 } | 3010 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3014 std::unique_ptr<FakeSchedulerClient> client = | 3071 std::unique_ptr<FakeSchedulerClient> client = |
| 3015 base::WrapUnique(new SchedulerClientSetNeedsPrepareTilesOnDraw); | 3072 base::WrapUnique(new SchedulerClientSetNeedsPrepareTilesOnDraw); |
| 3016 SetUpScheduler(EXTERNAL_BFS, std::move(client)); | 3073 SetUpScheduler(EXTERNAL_BFS, std::move(client)); |
| 3017 | 3074 |
| 3018 scheduler_->SetNeedsRedraw(); | 3075 scheduler_->SetNeedsRedraw(); |
| 3019 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 3076 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 3020 client_->Reset(); | 3077 client_->Reset(); |
| 3021 | 3078 |
| 3022 // Next vsync. | 3079 // Next vsync. |
| 3023 EXPECT_SCOPED(AdvanceFrame()); | 3080 EXPECT_SCOPED(AdvanceFrame()); |
| 3024 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 3081 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); |
| 3025 EXPECT_ACTION("ScheduledActionInvalidateCompositorFrameSink", client_, 1, 2); | 3082 EXPECT_ACTION("ScheduledActionInvalidateCompositorFrameSink", client_, 1, 3); |
| 3083 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 2, 3); |
| 3026 client_->Reset(); | 3084 client_->Reset(); |
| 3027 | 3085 |
| 3028 // Android onDraw. | 3086 // Android onDraw. |
| 3029 scheduler_->SetNeedsRedraw(); | 3087 scheduler_->SetNeedsRedraw(); |
| 3030 bool resourceless_software_draw = false; | 3088 bool resourceless_software_draw = false; |
| 3031 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw); | 3089 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw); |
| 3032 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 2); | 3090 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 2); |
| 3033 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 1, 2); | 3091 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 1, 2); |
| 3034 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3092 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 3035 EXPECT_FALSE(scheduler_->PrepareTilesPending()); | 3093 EXPECT_FALSE(scheduler_->PrepareTilesPending()); |
| 3036 client_->Reset(); | 3094 client_->Reset(); |
| 3037 | 3095 |
| 3038 // Android onDraw. | 3096 // Android onDraw. |
| 3039 scheduler_->SetNeedsRedraw(); | 3097 scheduler_->SetNeedsRedraw(); |
| 3040 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw); | 3098 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw); |
| 3041 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 2); | 3099 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 2); |
| 3042 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 1, 2); | 3100 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 1, 2); |
| 3043 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3101 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 3044 EXPECT_FALSE(scheduler_->PrepareTilesPending()); | 3102 EXPECT_FALSE(scheduler_->PrepareTilesPending()); |
| 3045 client_->Reset(); | 3103 client_->Reset(); |
| 3046 | 3104 |
| 3047 // Next vsync. | 3105 // Next vsync. |
| 3048 EXPECT_SCOPED(AdvanceFrame()); | 3106 EXPECT_SCOPED(AdvanceFrame()); |
| 3049 EXPECT_FALSE(scheduler_->PrepareTilesPending()); | 3107 EXPECT_FALSE(scheduler_->PrepareTilesPending()); |
| 3050 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); | 3108 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 4); |
| 3051 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); | 3109 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 4); |
| 3052 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); | 3110 EXPECT_ACTION("RemoveObserver(this)", client_, 2, 4); |
| 3111 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 3, 4); |
| 3053 EXPECT_FALSE(scheduler_->begin_frames_expected()); | 3112 EXPECT_FALSE(scheduler_->begin_frames_expected()); |
| 3054 client_->Reset(); | 3113 client_->Reset(); |
| 3055 } | 3114 } |
| 3056 | 3115 |
| 3057 TEST_F(SchedulerTest, SynchronousCompositorSendBeginMainFrameWhileIdle) { | 3116 TEST_F(SchedulerTest, SynchronousCompositorSendBeginMainFrameWhileIdle) { |
| 3058 scheduler_settings_.using_synchronous_renderer_compositor = true; | 3117 scheduler_settings_.using_synchronous_renderer_compositor = true; |
| 3059 SetUpScheduler(EXTERNAL_BFS); | 3118 SetUpScheduler(EXTERNAL_BFS); |
| 3060 | 3119 |
| 3061 scheduler_->SetNeedsRedraw(); | 3120 scheduler_->SetNeedsRedraw(); |
| 3062 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 3121 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
| 3063 client_->Reset(); | 3122 client_->Reset(); |
| 3064 | 3123 |
| 3065 // Next vsync. | 3124 // Next vsync. |
| 3066 EXPECT_SCOPED(AdvanceFrame()); | 3125 EXPECT_SCOPED(AdvanceFrame()); |
| 3067 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 3126 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); |
| 3068 EXPECT_ACTION("ScheduledActionInvalidateCompositorFrameSink", client_, 1, 2); | 3127 EXPECT_ACTION("ScheduledActionInvalidateCompositorFrameSink", client_, 1, 3); |
| 3128 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 2, 3); |
| 3069 client_->Reset(); | 3129 client_->Reset(); |
| 3070 | 3130 |
| 3071 // Android onDraw. | 3131 // Android onDraw. |
| 3072 scheduler_->SetNeedsRedraw(); | 3132 scheduler_->SetNeedsRedraw(); |
| 3073 bool resourceless_software_draw = false; | 3133 bool resourceless_software_draw = false; |
| 3074 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw); | 3134 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw); |
| 3075 EXPECT_SINGLE_ACTION("ScheduledActionDrawIfPossible", client_); | 3135 EXPECT_SINGLE_ACTION("ScheduledActionDrawIfPossible", client_); |
| 3076 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3136 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 3077 EXPECT_FALSE(scheduler_->PrepareTilesPending()); | 3137 EXPECT_FALSE(scheduler_->PrepareTilesPending()); |
| 3078 client_->Reset(); | 3138 client_->Reset(); |
| 3079 | 3139 |
| 3080 // Simulate SetNeedsBeginMainFrame due to input event. | 3140 // Simulate SetNeedsBeginMainFrame due to input event. |
| 3081 scheduler_->SetNeedsBeginMainFrame(); | 3141 scheduler_->SetNeedsBeginMainFrame(); |
| 3082 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client_); | 3142 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client_); |
| 3083 client_->Reset(); | 3143 client_->Reset(); |
| 3084 | 3144 |
| 3085 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); | 3145 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); |
| 3086 scheduler_->NotifyReadyToCommit(); | 3146 scheduler_->NotifyReadyToCommit(); |
| 3087 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); | 3147 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); |
| 3088 client_->Reset(); | 3148 client_->Reset(); |
| 3089 | 3149 |
| 3090 scheduler_->NotifyReadyToActivate(); | 3150 scheduler_->NotifyReadyToActivate(); |
| 3091 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); | 3151 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); |
| 3092 client_->Reset(); | 3152 client_->Reset(); |
| 3093 | 3153 |
| 3094 // Next vsync. | 3154 // Next vsync. |
| 3095 EXPECT_SCOPED(AdvanceFrame()); | 3155 EXPECT_SCOPED(AdvanceFrame()); |
| 3096 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 3156 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); |
| 3097 EXPECT_ACTION("ScheduledActionInvalidateCompositorFrameSink", client_, 1, 2); | 3157 EXPECT_ACTION("ScheduledActionInvalidateCompositorFrameSink", client_, 1, 3); |
| 3158 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 2, 3); |
| 3098 client_->Reset(); | 3159 client_->Reset(); |
| 3099 | 3160 |
| 3100 // Android onDraw. | 3161 // Android onDraw. |
| 3101 scheduler_->SetNeedsRedraw(); | 3162 scheduler_->SetNeedsRedraw(); |
| 3102 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw); | 3163 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw); |
| 3103 EXPECT_SINGLE_ACTION("ScheduledActionDrawIfPossible", client_); | 3164 EXPECT_SINGLE_ACTION("ScheduledActionDrawIfPossible", client_); |
| 3104 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3165 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 3105 EXPECT_FALSE(scheduler_->PrepareTilesPending()); | 3166 EXPECT_FALSE(scheduler_->PrepareTilesPending()); |
| 3106 client_->Reset(); | 3167 client_->Reset(); |
| 3107 | 3168 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3222 } | 3283 } |
| 3223 | 3284 |
| 3224 TEST_F(SchedulerTest, ImplSideInvalidationsInDeadline) { | 3285 TEST_F(SchedulerTest, ImplSideInvalidationsInDeadline) { |
| 3225 SetUpScheduler(EXTERNAL_BFS); | 3286 SetUpScheduler(EXTERNAL_BFS); |
| 3226 | 3287 |
| 3227 // Request an impl-side invalidation and trigger the deadline. Ensure that the | 3288 // Request an impl-side invalidation and trigger the deadline. Ensure that the |
| 3228 // invalidation runs inside the deadline. | 3289 // invalidation runs inside the deadline. |
| 3229 scheduler_->SetNeedsImplSideInvalidation(); | 3290 scheduler_->SetNeedsImplSideInvalidation(); |
| 3230 client_->Reset(); | 3291 client_->Reset(); |
| 3231 EXPECT_SCOPED(AdvanceFrame()); | 3292 EXPECT_SCOPED(AdvanceFrame()); |
| 3232 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | 3293 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 3294 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 3233 | 3295 |
| 3234 // Deadline. | 3296 // Deadline. |
| 3235 client_->Reset(); | 3297 client_->Reset(); |
| 3236 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true)); | 3298 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true)); |
| 3237 EXPECT_SINGLE_ACTION("ScheduledActionPerformImplSideInvalidation", client_); | 3299 EXPECT_SINGLE_ACTION("ScheduledActionPerformImplSideInvalidation", client_); |
| 3238 } | 3300 } |
| 3239 | 3301 |
| 3240 TEST_F(SchedulerTest, ImplSideInvalidationsMergedWithCommit) { | 3302 TEST_F(SchedulerTest, ImplSideInvalidationsMergedWithCommit) { |
| 3241 SetUpScheduler(EXTERNAL_BFS); | 3303 SetUpScheduler(EXTERNAL_BFS); |
| 3242 | 3304 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3388 last_begin_frame_number, latest_confirmed_sequence_number, | 3450 last_begin_frame_number, latest_confirmed_sequence_number, |
| 3389 has_damage), | 3451 has_damage), |
| 3390 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | 3452 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); |
| 3391 | 3453 |
| 3392 // Run a successful redraw and verify that a new ack is sent. | 3454 // Run a successful redraw and verify that a new ack is sent. |
| 3393 scheduler_->SetNeedsRedraw(); | 3455 scheduler_->SetNeedsRedraw(); |
| 3394 client_->Reset(); | 3456 client_->Reset(); |
| 3395 | 3457 |
| 3396 BeginFrameArgs args = SendNextBeginFrame(); | 3458 BeginFrameArgs args = SendNextBeginFrame(); |
| 3397 EXPECT_LT(latest_confirmed_sequence_number, args.sequence_number); | 3459 EXPECT_LT(latest_confirmed_sequence_number, args.sequence_number); |
| 3398 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 3460 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 3461 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 3399 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 3462 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 3400 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 3463 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| 3401 client_->Reset(); | 3464 client_->Reset(); |
| 3402 | 3465 |
| 3403 task_runner().RunPendingTasks(); // Run posted deadline. | 3466 task_runner().RunPendingTasks(); // Run posted deadline. |
| 3404 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); | 3467 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); |
| 3405 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3468 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 3406 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 3469 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| 3407 client_->Reset(); | 3470 client_->Reset(); |
| 3408 | 3471 |
| 3409 // Successful draw caused damage. | 3472 // Successful draw caused damage. |
| 3410 latest_confirmed_sequence_number = args.sequence_number; | 3473 latest_confirmed_sequence_number = args.sequence_number; |
| 3411 has_damage = true; | 3474 has_damage = true; |
| 3412 EXPECT_EQ( | 3475 EXPECT_EQ( |
| 3413 BeginFrameAck(args.source_id, args.sequence_number, | 3476 BeginFrameAck(args.source_id, args.sequence_number, |
| 3414 latest_confirmed_sequence_number, has_damage), | 3477 latest_confirmed_sequence_number, has_damage), |
| 3415 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | 3478 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); |
| 3416 | 3479 |
| 3417 // Request another redraw, but fail it. Verify that a new ack is sent, but | 3480 // Request another redraw, but fail it. Verify that a new ack is sent, but |
| 3418 // that its |latest_confirmed_sequence_number| didn't change. | 3481 // that its |latest_confirmed_sequence_number| didn't change. |
| 3419 scheduler_->SetNeedsRedraw(); | 3482 scheduler_->SetNeedsRedraw(); |
| 3420 client_->Reset(); | 3483 client_->Reset(); |
| 3421 | 3484 |
| 3422 args = SendNextBeginFrame(); | 3485 args = SendNextBeginFrame(); |
| 3423 EXPECT_LT(latest_confirmed_sequence_number, args.sequence_number); | 3486 EXPECT_LT(latest_confirmed_sequence_number, args.sequence_number); |
| 3424 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 3487 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 3488 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 3425 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 3489 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 3426 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 3490 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| 3427 client_->Reset(); | 3491 client_->Reset(); |
| 3428 | 3492 |
| 3429 client_->SetDrawWillHappen(false); | 3493 client_->SetDrawWillHappen(false); |
| 3430 task_runner().RunPendingTasks(); // Run posted deadline. | 3494 task_runner().RunPendingTasks(); // Run posted deadline. |
| 3431 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 2); | 3495 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 2); |
| 3432 // Failed draw triggers SendBeginMainFrame. | 3496 // Failed draw triggers SendBeginMainFrame. |
| 3433 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 3497 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 3434 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3498 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3449 // To get into a high latency state, this test disables automatic swap acks. | 3513 // To get into a high latency state, this test disables automatic swap acks. |
| 3450 client_->SetAutomaticSubmitCompositorFrameAck(false); | 3514 client_->SetAutomaticSubmitCompositorFrameAck(false); |
| 3451 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); | 3515 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
| 3452 | 3516 |
| 3453 // Run a successful redraw that submits a compositor frame but doesn't receive | 3517 // Run a successful redraw that submits a compositor frame but doesn't receive |
| 3454 // a swap ack. Verify that a BeginFrameAck is sent for it. | 3518 // a swap ack. Verify that a BeginFrameAck is sent for it. |
| 3455 scheduler_->SetNeedsRedraw(); | 3519 scheduler_->SetNeedsRedraw(); |
| 3456 client_->Reset(); | 3520 client_->Reset(); |
| 3457 | 3521 |
| 3458 BeginFrameArgs args = SendNextBeginFrame(); | 3522 BeginFrameArgs args = SendNextBeginFrame(); |
| 3459 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 3523 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 3524 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 3460 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 3525 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 3461 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 3526 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| 3462 client_->Reset(); | 3527 client_->Reset(); |
| 3463 | 3528 |
| 3464 task_runner().RunPendingTasks(); // Run posted deadline. | 3529 task_runner().RunPendingTasks(); // Run posted deadline. |
| 3465 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); | 3530 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); |
| 3466 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3531 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 3467 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 3532 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| 3468 client_->Reset(); | 3533 client_->Reset(); |
| 3469 | 3534 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3496 } | 3561 } |
| 3497 | 3562 |
| 3498 TEST_F(SchedulerTest, BeginFrameAckForBeginFrameBeforeLastDeadline) { | 3563 TEST_F(SchedulerTest, BeginFrameAckForBeginFrameBeforeLastDeadline) { |
| 3499 SetUpScheduler(EXTERNAL_BFS); | 3564 SetUpScheduler(EXTERNAL_BFS); |
| 3500 | 3565 |
| 3501 // Request tile preparation to schedule a proactive BeginFrame. | 3566 // Request tile preparation to schedule a proactive BeginFrame. |
| 3502 scheduler_->SetNeedsPrepareTiles(); | 3567 scheduler_->SetNeedsPrepareTiles(); |
| 3503 client_->Reset(); | 3568 client_->Reset(); |
| 3504 | 3569 |
| 3505 SendNextBeginFrame(); | 3570 SendNextBeginFrame(); |
| 3506 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 3571 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 3572 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 3507 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 3573 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 3508 // Until tiles were prepared, further proactive BeginFrames are expected. | 3574 // Until tiles were prepared, further proactive BeginFrames are expected. |
| 3509 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 3575 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| 3510 client_->Reset(); | 3576 client_->Reset(); |
| 3511 | 3577 |
| 3512 // Send the next BeginFrame before the previous one's deadline was executed. | 3578 // Send the next BeginFrame before the previous one's deadline was executed. |
| 3513 // This should trigger the previous BeginFrame's deadline synchronously, | 3579 // This should trigger the previous BeginFrame's deadline synchronously, |
| 3514 // during which tiles will be prepared. As a result of that, no further | 3580 // during which tiles will be prepared. As a result of that, no further |
| 3515 // BeginFrames will be needed, and the new BeginFrame should be dropped. | 3581 // BeginFrames will be needed, and the new BeginFrame should be dropped. |
| 3516 BeginFrameArgs args = SendNextBeginFrame(); | 3582 BeginFrameArgs args = SendNextBeginFrame(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3539 uint64_t latest_confirmed_sequence_number = | 3605 uint64_t latest_confirmed_sequence_number = |
| 3540 fake_external_begin_frame_source_->next_begin_frame_number() - 1; | 3606 fake_external_begin_frame_source_->next_begin_frame_number() - 1; |
| 3541 | 3607 |
| 3542 // Request a single BeginFrame. | 3608 // Request a single BeginFrame. |
| 3543 scheduler_->SetNeedsOneBeginImplFrame(); | 3609 scheduler_->SetNeedsOneBeginImplFrame(); |
| 3544 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 3610 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| 3545 client_->Reset(); | 3611 client_->Reset(); |
| 3546 | 3612 |
| 3547 // First BeginFrame is handled by StateMachine. | 3613 // First BeginFrame is handled by StateMachine. |
| 3548 BeginFrameArgs first_args = SendNextBeginFrame(); | 3614 BeginFrameArgs first_args = SendNextBeginFrame(); |
| 3549 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 3615 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 3616 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 3550 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 3617 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 3551 // State machine is no longer interested in BeginFrames, but scheduler is | 3618 // State machine is no longer interested in BeginFrames, but scheduler is |
| 3552 // still observing the source. | 3619 // still observing the source. |
| 3553 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 3620 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| 3554 EXPECT_FALSE(scheduler_->BeginFrameNeeded()); | 3621 EXPECT_FALSE(scheduler_->BeginFrameNeeded()); |
| 3555 client_->Reset(); | 3622 client_->Reset(); |
| 3556 | 3623 |
| 3557 // Send the next BeginFrame before the previous one's deadline was executed. | 3624 // Send the next BeginFrame before the previous one's deadline was executed. |
| 3558 // The BeginFrame should be dropped immediately, since the state machine is | 3625 // The BeginFrame should be dropped immediately, since the state machine is |
| 3559 // not expecting any BeginFrames. | 3626 // not expecting any BeginFrames. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3620 scheduler_->SetNeedsRedraw(); | 3687 scheduler_->SetNeedsRedraw(); |
| 3621 client_->Reset(); | 3688 client_->Reset(); |
| 3622 | 3689 |
| 3623 // Send a BeginFrame with a different source_id. | 3690 // Send a BeginFrame with a different source_id. |
| 3624 now_src_->Advance(BeginFrameArgs::DefaultInterval()); | 3691 now_src_->Advance(BeginFrameArgs::DefaultInterval()); |
| 3625 uint32_t source_id = fake_external_begin_frame_source_->source_id() + 1; | 3692 uint32_t source_id = fake_external_begin_frame_source_->source_id() + 1; |
| 3626 BeginFrameArgs args = CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, | 3693 BeginFrameArgs args = CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, |
| 3627 source_id, 1, now_src()); | 3694 source_id, 1, now_src()); |
| 3628 fake_external_begin_frame_source_->TestOnBeginFrame(args); | 3695 fake_external_begin_frame_source_->TestOnBeginFrame(args); |
| 3629 | 3696 |
| 3630 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 1); | 3697 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 3698 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
| 3631 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 3699 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
| 3632 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 3700 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| 3633 client_->Reset(); | 3701 client_->Reset(); |
| 3634 | 3702 |
| 3635 task_runner().RunPendingTasks(); // Run posted deadline. | 3703 task_runner().RunPendingTasks(); // Run posted deadline. |
| 3636 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); | 3704 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); |
| 3637 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3705 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 3638 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 3706 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
| 3639 client_->Reset(); | 3707 client_->Reset(); |
| 3640 | 3708 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3675 BeginFrameArgs::kInvalidFrameNumber; | 3743 BeginFrameArgs::kInvalidFrameNumber; |
| 3676 bool has_damage = false; | 3744 bool has_damage = false; |
| 3677 EXPECT_EQ( | 3745 EXPECT_EQ( |
| 3678 BeginFrameAck(args.source_id, args.sequence_number, | 3746 BeginFrameAck(args.source_id, args.sequence_number, |
| 3679 latest_confirmed_sequence_number, has_damage), | 3747 latest_confirmed_sequence_number, has_damage), |
| 3680 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | 3748 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); |
| 3681 } | 3749 } |
| 3682 | 3750 |
| 3683 } // namespace | 3751 } // namespace |
| 3684 } // namespace cc | 3752 } // namespace cc |
| OLD | NEW |