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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 void Reset() { | 66 void Reset() { |
67 actions_.clear(); | 67 actions_.clear(); |
68 states_.clear(); | 68 states_.clear(); |
69 will_begin_impl_frame_causes_redraw_ = false; | 69 will_begin_impl_frame_causes_redraw_ = false; |
70 will_begin_impl_frame_requests_one_begin_impl_frame_ = false; | 70 will_begin_impl_frame_requests_one_begin_impl_frame_ = false; |
71 draw_will_happen_ = true; | 71 draw_will_happen_ = true; |
72 swap_will_happen_if_draw_happens_ = true; | 72 swap_will_happen_if_draw_happens_ = true; |
73 num_draws_ = 0; | 73 num_draws_ = 0; |
74 last_begin_main_frame_args_ = BeginFrameArgs(); | 74 last_begin_main_frame_args_ = BeginFrameArgs(); |
| 75 last_begin_frame_ack_ = BeginFrameAck(); |
75 } | 76 } |
76 | 77 |
77 void set_scheduler(TestScheduler* scheduler) { scheduler_ = scheduler; } | 78 void set_scheduler(TestScheduler* scheduler) { scheduler_ = scheduler; } |
78 | 79 |
79 bool needs_begin_frames() { return scheduler_->begin_frames_expected(); } | 80 bool needs_begin_frames() { return scheduler_->begin_frames_expected(); } |
80 int num_draws() const { return num_draws_; } | 81 int num_draws() const { return num_draws_; } |
81 int num_actions_() const { return static_cast<int>(actions_.size()); } | 82 int num_actions_() const { return static_cast<int>(actions_.size()); } |
82 const char* Action(int i) const { return actions_[i]; } | 83 const char* Action(int i) const { return actions_[i]; } |
83 std::string StateForAction(int i) const { return states_[i]->ToString(); } | 84 std::string StateForAction(int i) const { return states_[i]->ToString(); } |
84 base::TimeTicks posted_begin_impl_frame_deadline() const { | 85 base::TimeTicks posted_begin_impl_frame_deadline() const { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 PushAction("WillBeginImplFrame"); | 117 PushAction("WillBeginImplFrame"); |
117 if (will_begin_impl_frame_requests_one_begin_impl_frame_) | 118 if (will_begin_impl_frame_requests_one_begin_impl_frame_) |
118 scheduler_->SetNeedsOneBeginImplFrame(); | 119 scheduler_->SetNeedsOneBeginImplFrame(); |
119 if (will_begin_impl_frame_causes_redraw_) | 120 if (will_begin_impl_frame_causes_redraw_) |
120 scheduler_->SetNeedsRedraw(); | 121 scheduler_->SetNeedsRedraw(); |
121 } | 122 } |
122 void DidFinishImplFrame() override { | 123 void DidFinishImplFrame() override { |
123 EXPECT_TRUE(inside_begin_impl_frame_); | 124 EXPECT_TRUE(inside_begin_impl_frame_); |
124 inside_begin_impl_frame_ = false; | 125 inside_begin_impl_frame_ = false; |
125 } | 126 } |
126 void DidNotProduceFrame(const BeginFrameAck& ack) override {} | 127 void DidNotProduceFrame(const BeginFrameAck& ack) override { |
| 128 last_begin_frame_ack_ = ack; |
| 129 } |
127 | 130 |
128 void ScheduledActionSendBeginMainFrame(const BeginFrameArgs& args) override { | 131 void ScheduledActionSendBeginMainFrame(const BeginFrameArgs& args) override { |
129 PushAction("ScheduledActionSendBeginMainFrame"); | 132 PushAction("ScheduledActionSendBeginMainFrame"); |
130 last_begin_main_frame_args_ = args; | 133 last_begin_main_frame_args_ = args; |
131 } | 134 } |
132 | 135 |
133 const BeginFrameArgs& last_begin_main_frame_args() { | 136 const BeginFrameArgs& last_begin_main_frame_args() { |
134 return last_begin_main_frame_args_; | 137 return last_begin_main_frame_args_; |
135 } | 138 } |
136 | 139 |
| 140 const BeginFrameAck& last_begin_frame_ack() { return last_begin_frame_ack_; } |
| 141 |
137 DrawResult ScheduledActionDrawIfPossible() override { | 142 DrawResult ScheduledActionDrawIfPossible() override { |
138 PushAction("ScheduledActionDrawIfPossible"); | 143 PushAction("ScheduledActionDrawIfPossible"); |
139 num_draws_++; | 144 num_draws_++; |
140 DrawResult result = | 145 DrawResult result = |
141 draw_will_happen_ ? DRAW_SUCCESS : DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; | 146 draw_will_happen_ ? DRAW_SUCCESS : DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; |
142 bool swap_will_happen = | 147 bool swap_will_happen = |
143 draw_will_happen_ && swap_will_happen_if_draw_happens_; | 148 draw_will_happen_ && swap_will_happen_if_draw_happens_; |
144 if (swap_will_happen) { | 149 if (swap_will_happen) { |
| 150 last_begin_frame_ack_ = scheduler_->CurrentBeginFrameAckForActiveTree(); |
145 scheduler_->DidSubmitCompositorFrame(); | 151 scheduler_->DidSubmitCompositorFrame(); |
146 | 152 |
147 if (automatic_ack_) | 153 if (automatic_ack_) |
148 scheduler_->DidReceiveCompositorFrameAck(); | 154 scheduler_->DidReceiveCompositorFrameAck(); |
149 } | 155 } |
150 return result; | 156 return result; |
151 } | 157 } |
152 DrawResult ScheduledActionDrawForced() override { | 158 DrawResult ScheduledActionDrawForced() override { |
153 PushAction("ScheduledActionDrawForced"); | 159 PushAction("ScheduledActionDrawForced"); |
| 160 last_begin_frame_ack_ = scheduler_->CurrentBeginFrameAckForActiveTree(); |
154 return DRAW_SUCCESS; | 161 return DRAW_SUCCESS; |
155 } | 162 } |
156 void ScheduledActionCommit() override { | 163 void ScheduledActionCommit() override { |
157 PushAction("ScheduledActionCommit"); | 164 PushAction("ScheduledActionCommit"); |
158 scheduler_->DidCommit(); | 165 scheduler_->DidCommit(); |
159 } | 166 } |
160 void ScheduledActionActivateSyncTree() override { | 167 void ScheduledActionActivateSyncTree() override { |
161 PushAction("ScheduledActionActivateSyncTree"); | 168 PushAction("ScheduledActionActivateSyncTree"); |
162 } | 169 } |
163 void ScheduledActionBeginCompositorFrameSinkCreation() override { | 170 void ScheduledActionBeginCompositorFrameSinkCreation() override { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 } | 228 } |
222 | 229 |
223 bool inside_begin_impl_frame_; | 230 bool inside_begin_impl_frame_; |
224 bool will_begin_impl_frame_causes_redraw_; | 231 bool will_begin_impl_frame_causes_redraw_; |
225 bool will_begin_impl_frame_requests_one_begin_impl_frame_; | 232 bool will_begin_impl_frame_requests_one_begin_impl_frame_; |
226 bool draw_will_happen_; | 233 bool draw_will_happen_; |
227 bool swap_will_happen_if_draw_happens_; | 234 bool swap_will_happen_if_draw_happens_; |
228 bool automatic_ack_; | 235 bool automatic_ack_; |
229 int num_draws_; | 236 int num_draws_; |
230 BeginFrameArgs last_begin_main_frame_args_; | 237 BeginFrameArgs last_begin_main_frame_args_; |
| 238 BeginFrameAck last_begin_frame_ack_; |
231 base::TimeTicks posted_begin_impl_frame_deadline_; | 239 base::TimeTicks posted_begin_impl_frame_deadline_; |
232 std::vector<const char*> actions_; | 240 std::vector<const char*> actions_; |
233 std::vector<std::unique_ptr<base::trace_event::ConvertableToTraceFormat>> | 241 std::vector<std::unique_ptr<base::trace_event::ConvertableToTraceFormat>> |
234 states_; | 242 states_; |
235 TestScheduler* scheduler_; | 243 TestScheduler* scheduler_; |
236 }; | 244 }; |
237 | 245 |
238 enum BeginFrameSourceType { | 246 enum BeginFrameSourceType { |
239 EXTERNAL_BFS, | 247 EXTERNAL_BFS, |
240 UNTHROTTLED_BFS, | 248 UNTHROTTLED_BFS, |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 if (!scheduler_settings_.using_synchronous_renderer_compositor) { | 390 if (!scheduler_settings_.using_synchronous_renderer_compositor) { |
383 // Run the posted deadline task. | 391 // Run the posted deadline task. |
384 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 392 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
385 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true)); | 393 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true)); |
386 } | 394 } |
387 | 395 |
388 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 396 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
389 } | 397 } |
390 | 398 |
391 EXPECT_FALSE(scheduler_->begin_frames_expected()); | 399 EXPECT_FALSE(scheduler_->begin_frames_expected()); |
| 400 |
| 401 if (scheduler_->begin_frame_source() == |
| 402 fake_external_begin_frame_source_.get()) { |
| 403 // Expect the last BeginFrameAck to be for last BeginFrame, which didn't |
| 404 // cause damage. |
| 405 uint64_t last_begin_frame_number = |
| 406 fake_external_begin_frame_source_->next_begin_frame_number() - 1; |
| 407 bool has_damage = false; |
| 408 EXPECT_EQ(BeginFrameAck(fake_external_begin_frame_source_->source_id(), |
| 409 last_begin_frame_number, last_begin_frame_number, |
| 410 has_damage), |
| 411 client_->last_begin_frame_ack()); |
| 412 } |
| 413 |
392 client_->Reset(); | 414 client_->Reset(); |
393 } | 415 } |
394 | 416 |
395 // As this function contains EXPECT macros, to allow debugging it should be | 417 // As this function contains EXPECT macros, to allow debugging it should be |
396 // called inside EXPECT_SCOPED like so; | 418 // called inside EXPECT_SCOPED like so; |
397 // EXPECT_SCOPED(client.AdvanceFrame()); | 419 // EXPECT_SCOPED(client.AdvanceFrame()); |
398 void AdvanceFrame() { | 420 void AdvanceFrame() { |
399 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), | 421 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), |
400 "FakeSchedulerClient::AdvanceFrame"); | 422 "FakeSchedulerClient::AdvanceFrame"); |
401 | 423 |
(...skipping 2531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2933 | 2955 |
2934 // Scheduler shuts down the source now that no begin frame is requested. | 2956 // Scheduler shuts down the source now that no begin frame is requested. |
2935 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); | 2957 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); |
2936 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); | 2958 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
2937 } | 2959 } |
2938 | 2960 |
2939 TEST_F(SchedulerTest, SynchronousCompositorCommitAndVerifyBeginFrameAcks) { | 2961 TEST_F(SchedulerTest, SynchronousCompositorCommitAndVerifyBeginFrameAcks) { |
2940 scheduler_settings_.using_synchronous_renderer_compositor = true; | 2962 scheduler_settings_.using_synchronous_renderer_compositor = true; |
2941 SetUpScheduler(EXTERNAL_BFS); | 2963 SetUpScheduler(EXTERNAL_BFS); |
2942 | 2964 |
2943 // Expect the last ack to be for last BeginFrame, which didn't cause damage. | 2965 // The last BeginFrame was confirmed. |
2944 uint64_t last_begin_frame_number = | 2966 uint64_t latest_confirmed_sequence_number = |
2945 fake_external_begin_frame_source_->next_begin_frame_number() - 1; | 2967 fake_external_begin_frame_source_->next_begin_frame_number() - 1; |
2946 uint64_t latest_confirmed_sequence_number = last_begin_frame_number; | |
2947 bool has_damage = false; | |
2948 EXPECT_EQ( | |
2949 BeginFrameAck(fake_external_begin_frame_source_->source_id(), | |
2950 last_begin_frame_number, latest_confirmed_sequence_number, | |
2951 has_damage), | |
2952 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | |
2953 | 2968 |
2954 scheduler_->SetNeedsBeginMainFrame(); | 2969 scheduler_->SetNeedsBeginMainFrame(); |
2955 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 2970 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
2956 client_->Reset(); | 2971 client_->Reset(); |
2957 | 2972 |
2958 // Next vsync. | 2973 // Next vsync. |
2959 BeginFrameArgs args = SendNextBeginFrame(); | 2974 BeginFrameArgs args = SendNextBeginFrame(); |
2960 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 2975 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
2961 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 2976 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
2962 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 2977 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
| 2978 |
| 2979 bool has_damage = false; |
| 2980 EXPECT_EQ(BeginFrameAck(args.source_id, args.sequence_number, |
| 2981 latest_confirmed_sequence_number, has_damage), |
| 2982 client_->last_begin_frame_ack()); |
2963 client_->Reset(); | 2983 client_->Reset(); |
2964 | 2984 |
2965 has_damage = false; | |
2966 EXPECT_EQ( | |
2967 BeginFrameAck(args.source_id, args.sequence_number, | |
2968 latest_confirmed_sequence_number, has_damage), | |
2969 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | |
2970 | |
2971 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); | 2985 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); |
2972 EXPECT_NO_ACTION(client_); | 2986 EXPECT_NO_ACTION(client_); |
2973 | 2987 |
2974 // Next vsync. | 2988 // Next vsync. |
2975 args = SendNextBeginFrame(); | 2989 args = SendNextBeginFrame(); |
2976 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | 2990 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); |
2977 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 2991 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
2978 client_->Reset(); | |
2979 | 2992 |
2980 has_damage = false; | 2993 has_damage = false; |
2981 EXPECT_EQ( | 2994 EXPECT_EQ(BeginFrameAck(args.source_id, args.sequence_number, |
2982 BeginFrameAck(args.source_id, args.sequence_number, | 2995 latest_confirmed_sequence_number, has_damage), |
2983 latest_confirmed_sequence_number, has_damage), | 2996 client_->last_begin_frame_ack()); |
2984 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | 2997 client_->Reset(); |
2985 | 2998 |
2986 scheduler_->NotifyReadyToCommit(); | 2999 scheduler_->NotifyReadyToCommit(); |
2987 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 1); | 3000 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 1); |
2988 client_->Reset(); | 3001 client_->Reset(); |
2989 | 3002 |
2990 scheduler_->NotifyReadyToActivate(); | 3003 scheduler_->NotifyReadyToActivate(); |
2991 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); | 3004 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); |
2992 client_->Reset(); | 3005 client_->Reset(); |
2993 | 3006 |
2994 // Next vsync. | 3007 // Next vsync. |
2995 args = SendNextBeginFrame(); | 3008 args = SendNextBeginFrame(); |
2996 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); | 3009 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); |
2997 EXPECT_ACTION("ScheduledActionInvalidateCompositorFrameSink", client_, 1, 3); | 3010 EXPECT_ACTION("ScheduledActionInvalidateCompositorFrameSink", client_, 1, 3); |
2998 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 2, 3); | 3011 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 2, 3); |
2999 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3012 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
3000 client_->Reset(); | |
3001 | 3013 |
3002 // Not confirmed yet and no damage, since not drawn yet. | 3014 // Not confirmed yet and no damage, since not drawn yet. |
3003 // TODO(eseckler): In the future, |has_damage = false| will prevent us from | 3015 // TODO(eseckler): In the future, |has_damage = false| will prevent us from |
3004 // filtering this ack (in CompositorExternalBeginFrameSource) and instead | 3016 // filtering this ack (in CompositorExternalBeginFrameSource) and instead |
3005 // forwarding the one attached to the later submitted CompositorFrame. | 3017 // forwarding the one attached to the later submitted CompositorFrame. |
3006 has_damage = false; | 3018 has_damage = false; |
3007 EXPECT_EQ( | 3019 EXPECT_EQ(BeginFrameAck(args.source_id, args.sequence_number, |
3008 BeginFrameAck(args.source_id, args.sequence_number, | 3020 latest_confirmed_sequence_number, has_damage), |
3009 latest_confirmed_sequence_number, has_damage), | 3021 client_->last_begin_frame_ack()); |
3010 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | 3022 client_->Reset(); |
3011 | 3023 |
3012 // Android onDraw. | 3024 // Android onDraw. |
3013 scheduler_->SetNeedsRedraw(); | 3025 scheduler_->SetNeedsRedraw(); |
3014 bool resourceless_software_draw = false; | 3026 bool resourceless_software_draw = false; |
3015 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw); | 3027 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw); |
3016 EXPECT_SINGLE_ACTION("ScheduledActionDrawIfPossible", client_); | 3028 EXPECT_SINGLE_ACTION("ScheduledActionDrawIfPossible", client_); |
3017 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3029 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
3018 client_->Reset(); | 3030 client_->Reset(); |
3019 | 3031 |
3020 // Idle on next vsync. | 3032 // Idle on next vsync. |
3021 args = SendNextBeginFrame(); | 3033 args = SendNextBeginFrame(); |
3022 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 4); | 3034 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 4); |
3023 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 4); | 3035 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 4); |
3024 EXPECT_ACTION("RemoveObserver(this)", client_, 2, 4); | 3036 EXPECT_ACTION("RemoveObserver(this)", client_, 2, 4); |
3025 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 3, 4); | 3037 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 3, 4); |
3026 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3038 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
3027 client_->Reset(); | |
3028 | 3039 |
3029 latest_confirmed_sequence_number = args.sequence_number; | 3040 latest_confirmed_sequence_number = args.sequence_number; |
3030 has_damage = false; | 3041 has_damage = false; |
3031 EXPECT_EQ( | 3042 EXPECT_EQ(BeginFrameAck(args.source_id, args.sequence_number, |
3032 BeginFrameAck(args.source_id, args.sequence_number, | 3043 latest_confirmed_sequence_number, has_damage), |
3033 latest_confirmed_sequence_number, has_damage), | 3044 client_->last_begin_frame_ack()); |
3034 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | 3045 client_->Reset(); |
3035 } | 3046 } |
3036 | 3047 |
3037 TEST_F(SchedulerTest, SynchronousCompositorDoubleCommitWithoutDraw) { | 3048 TEST_F(SchedulerTest, SynchronousCompositorDoubleCommitWithoutDraw) { |
3038 scheduler_settings_.using_synchronous_renderer_compositor = true; | 3049 scheduler_settings_.using_synchronous_renderer_compositor = true; |
3039 SetUpScheduler(EXTERNAL_BFS); | 3050 SetUpScheduler(EXTERNAL_BFS); |
3040 | 3051 |
3041 scheduler_->SetNeedsBeginMainFrame(); | 3052 scheduler_->SetNeedsBeginMainFrame(); |
3042 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); | 3053 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); |
3043 client_->Reset(); | 3054 client_->Reset(); |
3044 | 3055 |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3458 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { | 3469 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { |
3459 EXPECT_FALSE(BeginMainFrameOnCriticalPath( | 3470 EXPECT_FALSE(BeginMainFrameOnCriticalPath( |
3460 SMOOTHNESS_TAKES_PRIORITY, | 3471 SMOOTHNESS_TAKES_PRIORITY, |
3461 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); | 3472 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); |
3462 } | 3473 } |
3463 | 3474 |
3464 TEST_F(SchedulerTest, BeginFrameAckForFinishedImplFrame) { | 3475 TEST_F(SchedulerTest, BeginFrameAckForFinishedImplFrame) { |
3465 // Sets up scheduler and sends two BeginFrames, both finished. | 3476 // Sets up scheduler and sends two BeginFrames, both finished. |
3466 SetUpScheduler(EXTERNAL_BFS); | 3477 SetUpScheduler(EXTERNAL_BFS); |
3467 | 3478 |
3468 // Expect the last ack to be for last BeginFrame, which didn't cause damage. | 3479 // The last BeginFrame was confirmed. |
3469 uint64_t last_begin_frame_number = | 3480 uint64_t latest_confirmed_sequence_number = |
3470 fake_external_begin_frame_source_->next_begin_frame_number() - 1; | 3481 fake_external_begin_frame_source_->next_begin_frame_number() - 1; |
3471 uint64_t latest_confirmed_sequence_number = last_begin_frame_number; | |
3472 bool has_damage = false; | |
3473 EXPECT_EQ( | |
3474 BeginFrameAck(fake_external_begin_frame_source_->source_id(), | |
3475 last_begin_frame_number, latest_confirmed_sequence_number, | |
3476 has_damage), | |
3477 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | |
3478 | 3482 |
3479 // Run a successful redraw and verify that a new ack is sent. | 3483 // Run a successful redraw and verify that a new ack is sent. |
3480 scheduler_->SetNeedsRedraw(); | 3484 scheduler_->SetNeedsRedraw(); |
3481 client_->Reset(); | 3485 client_->Reset(); |
3482 | 3486 |
3483 BeginFrameArgs args = SendNextBeginFrame(); | 3487 BeginFrameArgs args = SendNextBeginFrame(); |
3484 EXPECT_LT(latest_confirmed_sequence_number, args.sequence_number); | 3488 EXPECT_LT(latest_confirmed_sequence_number, args.sequence_number); |
3485 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 3489 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
3486 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); | 3490 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
3487 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 3491 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
3488 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 3492 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
3489 client_->Reset(); | 3493 client_->Reset(); |
3490 | 3494 |
3491 task_runner().RunPendingTasks(); // Run posted deadline. | 3495 task_runner().RunPendingTasks(); // Run posted deadline. |
3492 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); | 3496 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); |
3493 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3497 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
3494 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 3498 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
3495 client_->Reset(); | |
3496 | 3499 |
3497 // Successful draw caused damage. | 3500 // Successful draw caused damage. |
3498 latest_confirmed_sequence_number = args.sequence_number; | 3501 latest_confirmed_sequence_number = args.sequence_number; |
3499 has_damage = true; | 3502 bool has_damage = true; |
3500 EXPECT_EQ( | 3503 EXPECT_EQ(BeginFrameAck(args.source_id, args.sequence_number, |
3501 BeginFrameAck(args.source_id, args.sequence_number, | 3504 latest_confirmed_sequence_number, has_damage), |
3502 latest_confirmed_sequence_number, has_damage), | 3505 client_->last_begin_frame_ack()); |
3503 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | 3506 client_->Reset(); |
3504 | 3507 |
3505 // Request another redraw, but fail it. Verify that a new ack is sent, but | 3508 // Request another redraw, but fail it. Verify that a new ack is sent, but |
3506 // that its |latest_confirmed_sequence_number| didn't change. | 3509 // that its |latest_confirmed_sequence_number| didn't change. |
3507 scheduler_->SetNeedsRedraw(); | 3510 scheduler_->SetNeedsRedraw(); |
3508 client_->Reset(); | 3511 client_->Reset(); |
3509 | 3512 |
3510 args = SendNextBeginFrame(); | 3513 args = SendNextBeginFrame(); |
3511 EXPECT_LT(latest_confirmed_sequence_number, args.sequence_number); | 3514 EXPECT_LT(latest_confirmed_sequence_number, args.sequence_number); |
3512 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 3515 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
3513 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); | 3516 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
3514 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 3517 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
3515 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 3518 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
3516 client_->Reset(); | 3519 client_->Reset(); |
3517 | 3520 |
3518 client_->SetDrawWillHappen(false); | 3521 client_->SetDrawWillHappen(false); |
3519 task_runner().RunPendingTasks(); // Run posted deadline. | 3522 task_runner().RunPendingTasks(); // Run posted deadline. |
3520 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 2); | 3523 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 2); |
3521 // Failed draw triggers SendBeginMainFrame. | 3524 // Failed draw triggers SendBeginMainFrame. |
3522 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 3525 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
3523 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3526 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
3524 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 3527 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
3525 client_->Reset(); | |
3526 | 3528 |
3527 // Failed draw: no damage and unconfirmed frame. | 3529 // Failed draw: no damage and unconfirmed frame. |
3528 has_damage = false; | 3530 has_damage = false; |
3529 EXPECT_EQ( | 3531 EXPECT_EQ(BeginFrameAck(args.source_id, args.sequence_number, |
3530 BeginFrameAck(args.source_id, args.sequence_number, | 3532 latest_confirmed_sequence_number, has_damage), |
3531 latest_confirmed_sequence_number, has_damage), | 3533 client_->last_begin_frame_ack()); |
3532 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | 3534 client_->Reset(); |
3533 } | 3535 } |
3534 | 3536 |
3535 TEST_F(SchedulerTest, BeginFrameAckForSkippedImplFrame) { | 3537 TEST_F(SchedulerTest, BeginFrameAckForSkippedImplFrame) { |
3536 SetUpScheduler(EXTERNAL_BFS); | 3538 SetUpScheduler(EXTERNAL_BFS); |
3537 | 3539 |
3538 // To get into a high latency state, this test disables automatic swap acks. | 3540 // To get into a high latency state, this test disables automatic swap acks. |
3539 client_->SetAutomaticSubmitCompositorFrameAck(false); | 3541 client_->SetAutomaticSubmitCompositorFrameAck(false); |
3540 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); | 3542 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); |
3541 | 3543 |
3542 // Run a successful redraw that submits a compositor frame but doesn't receive | 3544 // Run a successful redraw that submits a compositor frame but doesn't receive |
3543 // a swap ack. Verify that a BeginFrameAck is sent for it. | 3545 // a swap ack. Verify that a BeginFrameAck is sent for it. |
3544 scheduler_->SetNeedsRedraw(); | 3546 scheduler_->SetNeedsRedraw(); |
3545 client_->Reset(); | 3547 client_->Reset(); |
3546 | 3548 |
3547 BeginFrameArgs args = SendNextBeginFrame(); | 3549 BeginFrameArgs args = SendNextBeginFrame(); |
3548 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 3550 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
3549 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); | 3551 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
3550 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 3552 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
3551 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 3553 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
3552 client_->Reset(); | 3554 client_->Reset(); |
3553 | 3555 |
3554 task_runner().RunPendingTasks(); // Run posted deadline. | 3556 task_runner().RunPendingTasks(); // Run posted deadline. |
3555 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); | 3557 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); |
3556 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3558 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
3557 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 3559 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
3558 client_->Reset(); | |
3559 | 3560 |
3560 // Successful draw caused damage. | 3561 // Successful draw caused damage. |
3561 uint64_t latest_confirmed_sequence_number = args.sequence_number; | 3562 uint64_t latest_confirmed_sequence_number = args.sequence_number; |
3562 bool has_damage = true; | 3563 bool has_damage = true; |
3563 EXPECT_EQ( | 3564 EXPECT_EQ(BeginFrameAck(args.source_id, args.sequence_number, |
3564 BeginFrameAck(args.source_id, args.sequence_number, | 3565 latest_confirmed_sequence_number, has_damage), |
3565 latest_confirmed_sequence_number, has_damage), | 3566 client_->last_begin_frame_ack()); |
3566 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | 3567 client_->Reset(); |
3567 | 3568 |
3568 // Request another redraw that will be skipped because the swap ack is still | 3569 // Request another redraw that will be skipped because the swap ack is still |
3569 // missing. Verify that a new BeginFrameAck is sent. | 3570 // missing. Verify that a new BeginFrameAck is sent. |
3570 scheduler_->SetNeedsRedraw(); | 3571 scheduler_->SetNeedsRedraw(); |
3571 client_->Reset(); | 3572 client_->Reset(); |
3572 | 3573 |
3573 args = SendNextBeginFrame(); | 3574 args = SendNextBeginFrame(); |
3574 EXPECT_LT(latest_confirmed_sequence_number, args.sequence_number); | 3575 EXPECT_LT(latest_confirmed_sequence_number, args.sequence_number); |
3575 EXPECT_NO_ACTION(client_); | 3576 EXPECT_NO_ACTION(client_); |
3576 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3577 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
3577 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 3578 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
3578 client_->Reset(); | |
3579 | 3579 |
3580 // Skipped draw: no damage and unconfirmed frame. | 3580 // Skipped draw: no damage and unconfirmed frame. |
3581 has_damage = false; | 3581 has_damage = false; |
3582 EXPECT_EQ( | 3582 EXPECT_EQ(BeginFrameAck(args.source_id, args.sequence_number, |
3583 BeginFrameAck(args.source_id, args.sequence_number, | 3583 latest_confirmed_sequence_number, has_damage), |
3584 latest_confirmed_sequence_number, has_damage), | 3584 client_->last_begin_frame_ack()); |
3585 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | 3585 client_->Reset(); |
3586 } | 3586 } |
3587 | 3587 |
3588 TEST_F(SchedulerTest, BeginFrameAckForBeginFrameBeforeLastDeadline) { | 3588 TEST_F(SchedulerTest, BeginFrameAckForBeginFrameBeforeLastDeadline) { |
3589 SetUpScheduler(EXTERNAL_BFS); | 3589 SetUpScheduler(EXTERNAL_BFS); |
3590 | 3590 |
3591 // Request tile preparation to schedule a proactive BeginFrame. | 3591 // Request tile preparation to schedule a proactive BeginFrame. |
3592 scheduler_->SetNeedsPrepareTiles(); | 3592 scheduler_->SetNeedsPrepareTiles(); |
3593 client_->Reset(); | 3593 client_->Reset(); |
3594 | 3594 |
3595 SendNextBeginFrame(); | 3595 SendNextBeginFrame(); |
3596 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 3596 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
3597 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); | 3597 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
3598 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 3598 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
3599 // Until tiles were prepared, further proactive BeginFrames are expected. | 3599 // Until tiles were prepared, further proactive BeginFrames are expected. |
3600 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 3600 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
3601 client_->Reset(); | 3601 client_->Reset(); |
3602 | 3602 |
3603 // Send the next BeginFrame before the previous one's deadline was executed. | 3603 // Send the next BeginFrame before the previous one's deadline was executed. |
3604 // This should trigger the previous BeginFrame's deadline synchronously, | 3604 // This should trigger the previous BeginFrame's deadline synchronously, |
3605 // during which tiles will be prepared. As a result of that, no further | 3605 // during which tiles will be prepared. As a result of that, no further |
3606 // BeginFrames will be needed, and the new BeginFrame should be dropped. | 3606 // BeginFrames will be needed, and the new BeginFrame should be dropped. |
3607 BeginFrameArgs args = SendNextBeginFrame(); | 3607 BeginFrameArgs args = SendNextBeginFrame(); |
3608 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 0, 3); | 3608 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 0, 3); |
3609 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); | 3609 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); |
3610 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); | 3610 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); |
3611 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3611 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
3612 EXPECT_FALSE(scheduler_->begin_frames_expected()); | 3612 EXPECT_FALSE(scheduler_->begin_frames_expected()); |
3613 client_->Reset(); | |
3614 | 3613 |
3615 // Latest ack should be for the dropped BeginFrame. Since we don't have | 3614 // Latest ack should be for the dropped BeginFrame. Since we don't have |
3616 // further updates, its |latest_confirmed_sequence_number| should be for the | 3615 // further updates, its |latest_confirmed_sequence_number| should be for the |
3617 // dropped BeginFrame, too. | 3616 // dropped BeginFrame, too. |
3618 uint64_t latest_confirmed_sequence_number = args.sequence_number; | 3617 uint64_t latest_confirmed_sequence_number = args.sequence_number; |
3619 bool has_damage = false; | 3618 bool has_damage = false; |
3620 EXPECT_EQ( | 3619 EXPECT_EQ(BeginFrameAck(args.source_id, args.sequence_number, |
3621 BeginFrameAck(args.source_id, args.sequence_number, | 3620 latest_confirmed_sequence_number, has_damage), |
3622 latest_confirmed_sequence_number, has_damage), | 3621 client_->last_begin_frame_ack()); |
3623 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | 3622 client_->Reset(); |
3624 } | 3623 } |
3625 | 3624 |
3626 TEST_F(SchedulerTest, BeginFrameAckForDroppedBeginFrame) { | 3625 TEST_F(SchedulerTest, BeginFrameAckForDroppedBeginFrame) { |
3627 SetUpScheduler(EXTERNAL_BFS); | 3626 SetUpScheduler(EXTERNAL_BFS); |
3628 | 3627 |
3629 // Last confirmed frame was last BeginFrame. | 3628 // Last confirmed frame was last BeginFrame. |
3630 uint64_t latest_confirmed_sequence_number = | 3629 uint64_t latest_confirmed_sequence_number = |
3631 fake_external_begin_frame_source_->next_begin_frame_number() - 1; | 3630 fake_external_begin_frame_source_->next_begin_frame_number() - 1; |
3632 | 3631 |
3633 // Request a single BeginFrame. | 3632 // Request a single BeginFrame. |
(...skipping 10 matching lines...) Expand all Loading... |
3644 // still observing the source. | 3643 // still observing the source. |
3645 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 3644 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
3646 EXPECT_FALSE(scheduler_->BeginFrameNeeded()); | 3645 EXPECT_FALSE(scheduler_->BeginFrameNeeded()); |
3647 client_->Reset(); | 3646 client_->Reset(); |
3648 | 3647 |
3649 // Send the next BeginFrame before the previous one's deadline was executed. | 3648 // Send the next BeginFrame before the previous one's deadline was executed. |
3650 // The BeginFrame should be dropped immediately, since the state machine is | 3649 // The BeginFrame should be dropped immediately, since the state machine is |
3651 // not expecting any BeginFrames. | 3650 // not expecting any BeginFrames. |
3652 BeginFrameArgs second_args = SendNextBeginFrame(); | 3651 BeginFrameArgs second_args = SendNextBeginFrame(); |
3653 EXPECT_NO_ACTION(client_); | 3652 EXPECT_NO_ACTION(client_); |
3654 client_->Reset(); | |
3655 | 3653 |
3656 // Latest ack should be for the dropped (and unconfirmed) BeginFrame. | 3654 // Latest ack should be for the dropped (and unconfirmed) BeginFrame. |
3657 bool has_damage = false; | 3655 bool has_damage = false; |
3658 EXPECT_EQ( | 3656 EXPECT_EQ(BeginFrameAck(second_args.source_id, second_args.sequence_number, |
3659 BeginFrameAck(second_args.source_id, second_args.sequence_number, | 3657 latest_confirmed_sequence_number, has_damage), |
3660 latest_confirmed_sequence_number, has_damage), | 3658 client_->last_begin_frame_ack()); |
3661 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | 3659 client_->Reset(); |
3662 | 3660 |
3663 task_runner().RunPendingTasks(); // Run deadline of prior BeginFrame. | 3661 task_runner().RunPendingTasks(); // Run deadline of prior BeginFrame. |
3664 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); | 3662 EXPECT_ACTION("RemoveObserver(this)", client_, 0, 2); |
3665 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); | 3663 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
3666 client_->Reset(); | |
3667 | 3664 |
3668 // We'd expect an out-of-order ack for the prior BeginFrame, confirming it. | 3665 // We'd expect an out-of-order ack for the prior BeginFrame, confirming it. |
3669 latest_confirmed_sequence_number = first_args.sequence_number; | 3666 latest_confirmed_sequence_number = first_args.sequence_number; |
3670 has_damage = false; | 3667 has_damage = false; |
3671 EXPECT_EQ( | 3668 EXPECT_EQ(BeginFrameAck(first_args.source_id, first_args.sequence_number, |
3672 BeginFrameAck(first_args.source_id, first_args.sequence_number, | 3669 latest_confirmed_sequence_number, has_damage), |
3673 latest_confirmed_sequence_number, has_damage), | 3670 client_->last_begin_frame_ack()); |
3674 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | 3671 client_->Reset(); |
3675 } | 3672 } |
3676 | 3673 |
3677 TEST_F(SchedulerTest, BeginFrameAckForLateMissedBeginFrame) { | 3674 TEST_F(SchedulerTest, BeginFrameAckForLateMissedBeginFrame) { |
3678 SetUpScheduler(EXTERNAL_BFS); | 3675 SetUpScheduler(EXTERNAL_BFS); |
3679 | 3676 |
3680 // Last confirmed frame was last BeginFrame. | 3677 // Last confirmed frame was last BeginFrame. |
3681 uint64_t latest_confirmed_sequence_number = | 3678 uint64_t latest_confirmed_sequence_number = |
3682 fake_external_begin_frame_source_->next_begin_frame_number() - 1; | 3679 fake_external_begin_frame_source_->next_begin_frame_number() - 1; |
3683 | 3680 |
3684 scheduler_->SetNeedsRedraw(); | 3681 scheduler_->SetNeedsRedraw(); |
3685 client_->Reset(); | 3682 client_->Reset(); |
3686 | 3683 |
3687 // Send a missed BeginFrame with a passed deadline. | 3684 // Send a missed BeginFrame with a passed deadline. |
3688 now_src_->Advance(BeginFrameArgs::DefaultInterval()); | 3685 now_src_->Advance(BeginFrameArgs::DefaultInterval()); |
3689 BeginFrameArgs args = fake_external_begin_frame_source_->CreateBeginFrameArgs( | 3686 BeginFrameArgs args = fake_external_begin_frame_source_->CreateBeginFrameArgs( |
3690 BEGINFRAME_FROM_HERE, now_src()); | 3687 BEGINFRAME_FROM_HERE, now_src()); |
3691 args.type = BeginFrameArgs::MISSED; | 3688 args.type = BeginFrameArgs::MISSED; |
3692 now_src_->Advance(BeginFrameArgs::DefaultInterval()); | 3689 now_src_->Advance(BeginFrameArgs::DefaultInterval()); |
3693 EXPECT_GT(now_src_->NowTicks(), args.deadline); | 3690 EXPECT_GT(now_src_->NowTicks(), args.deadline); |
3694 fake_external_begin_frame_source_->TestOnBeginFrame(args); | 3691 fake_external_begin_frame_source_->TestOnBeginFrame(args); |
3695 | 3692 |
3696 EXPECT_NO_ACTION(client_); | 3693 EXPECT_NO_ACTION(client_); |
3697 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3694 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
3698 client_->Reset(); | |
3699 | 3695 |
3700 // Latest ack should be for the missed BeginFrame that was too late: no damage | 3696 // Latest ack should be for the missed BeginFrame that was too late: no damage |
3701 // and unconfirmed frame. | 3697 // and unconfirmed frame. |
3702 bool has_damage = false; | 3698 bool has_damage = false; |
3703 EXPECT_EQ( | 3699 EXPECT_EQ(BeginFrameAck(args.source_id, args.sequence_number, |
3704 BeginFrameAck(args.source_id, args.sequence_number, | 3700 latest_confirmed_sequence_number, has_damage), |
3705 latest_confirmed_sequence_number, has_damage), | 3701 client_->last_begin_frame_ack()); |
3706 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | 3702 client_->Reset(); |
3707 } | 3703 } |
3708 | 3704 |
3709 TEST_F(SchedulerTest, BeginFrameAckForFinishedBeginFrameWithNewSourceId) { | 3705 TEST_F(SchedulerTest, BeginFrameAckForFinishedBeginFrameWithNewSourceId) { |
3710 SetUpScheduler(EXTERNAL_BFS); | 3706 SetUpScheduler(EXTERNAL_BFS); |
3711 | 3707 |
3712 scheduler_->SetNeedsRedraw(); | 3708 scheduler_->SetNeedsRedraw(); |
3713 client_->Reset(); | 3709 client_->Reset(); |
3714 | 3710 |
3715 // Send a BeginFrame with a different source_id. | 3711 // Send a BeginFrame with a different source_id. |
3716 now_src_->Advance(BeginFrameArgs::DefaultInterval()); | 3712 now_src_->Advance(BeginFrameArgs::DefaultInterval()); |
3717 uint32_t source_id = fake_external_begin_frame_source_->source_id() + 1; | 3713 uint32_t source_id = fake_external_begin_frame_source_->source_id() + 1; |
3718 BeginFrameArgs args = CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, | 3714 BeginFrameArgs args = CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, |
3719 source_id, 1, now_src()); | 3715 source_id, 1, now_src()); |
3720 fake_external_begin_frame_source_->TestOnBeginFrame(args); | 3716 fake_external_begin_frame_source_->TestOnBeginFrame(args); |
3721 | 3717 |
3722 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 3718 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
3723 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); | 3719 EXPECT_ACTION("ScheduledActionBeginMainFrameNotExpectedUntil", client_, 1, 2); |
3724 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); | 3720 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); |
3725 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 3721 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
3726 client_->Reset(); | 3722 client_->Reset(); |
3727 | 3723 |
3728 task_runner().RunPendingTasks(); // Run posted deadline. | 3724 task_runner().RunPendingTasks(); // Run posted deadline. |
3729 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); | 3725 EXPECT_ACTION("ScheduledActionDrawIfPossible", client_, 0, 1); |
3730 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3726 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
3731 EXPECT_TRUE(scheduler_->begin_frames_expected()); | 3727 EXPECT_TRUE(scheduler_->begin_frames_expected()); |
3732 client_->Reset(); | |
3733 | 3728 |
3734 // Successful draw caused damage. | 3729 // Successful draw caused damage. |
3735 uint64_t latest_confirmed_sequence_number = args.sequence_number; | 3730 uint64_t latest_confirmed_sequence_number = args.sequence_number; |
3736 bool has_damage = true; | 3731 bool has_damage = true; |
3737 EXPECT_EQ( | 3732 EXPECT_EQ(BeginFrameAck(args.source_id, args.sequence_number, |
3738 BeginFrameAck(args.source_id, args.sequence_number, | 3733 latest_confirmed_sequence_number, has_damage), |
3739 latest_confirmed_sequence_number, has_damage), | 3734 client_->last_begin_frame_ack()); |
3740 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | 3735 client_->Reset(); |
3741 } | 3736 } |
3742 | 3737 |
3743 TEST_F(SchedulerTest, | 3738 TEST_F(SchedulerTest, |
3744 BeginFrameAckForLateMissedBeginFrameWithDifferentSourceId) { | 3739 BeginFrameAckForLateMissedBeginFrameWithDifferentSourceId) { |
3745 SetUpScheduler(EXTERNAL_BFS); | 3740 SetUpScheduler(EXTERNAL_BFS); |
3746 | 3741 |
3747 scheduler_->SetNeedsRedraw(); | 3742 scheduler_->SetNeedsRedraw(); |
3748 client_->Reset(); | 3743 client_->Reset(); |
3749 | 3744 |
3750 // Send a missed BeginFrame with a passed deadline and different source_id. | 3745 // Send a missed BeginFrame with a passed deadline and different source_id. |
3751 now_src_->Advance(BeginFrameArgs::DefaultInterval()); | 3746 now_src_->Advance(BeginFrameArgs::DefaultInterval()); |
3752 uint32_t source_id = fake_external_begin_frame_source_->source_id() + 1; | 3747 uint32_t source_id = fake_external_begin_frame_source_->source_id() + 1; |
3753 BeginFrameArgs args = CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, | 3748 BeginFrameArgs args = CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, |
3754 source_id, 1, now_src()); | 3749 source_id, 1, now_src()); |
3755 args.type = BeginFrameArgs::MISSED; | 3750 args.type = BeginFrameArgs::MISSED; |
3756 now_src_->Advance(BeginFrameArgs::DefaultInterval()); | 3751 now_src_->Advance(BeginFrameArgs::DefaultInterval()); |
3757 EXPECT_GT(now_src_->NowTicks(), args.deadline); | 3752 EXPECT_GT(now_src_->NowTicks(), args.deadline); |
3758 fake_external_begin_frame_source_->TestOnBeginFrame(args); | 3753 fake_external_begin_frame_source_->TestOnBeginFrame(args); |
3759 | 3754 |
3760 EXPECT_NO_ACTION(client_); | 3755 EXPECT_NO_ACTION(client_); |
3761 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); | 3756 EXPECT_FALSE(client_->IsInsideBeginImplFrame()); |
3762 client_->Reset(); | |
3763 | 3757 |
3764 // Latest ack should be for the missed BeginFrame that was too late: no damage | 3758 // Latest ack should be for the missed BeginFrame that was too late: no damage |
3765 // and unconfirmed frame. Because the source_id changed, the | 3759 // and unconfirmed frame. Because the source_id changed, the |
3766 // |latest_confirmed_sequence_number| should be set to invalid. | 3760 // |latest_confirmed_sequence_number| should be set to invalid. |
3767 uint64_t latest_confirmed_sequence_number = | 3761 uint64_t latest_confirmed_sequence_number = |
3768 BeginFrameArgs::kInvalidFrameNumber; | 3762 BeginFrameArgs::kInvalidFrameNumber; |
3769 bool has_damage = false; | 3763 bool has_damage = false; |
3770 EXPECT_EQ( | 3764 EXPECT_EQ(BeginFrameAck(args.source_id, args.sequence_number, |
3771 BeginFrameAck(args.source_id, args.sequence_number, | 3765 latest_confirmed_sequence_number, has_damage), |
3772 latest_confirmed_sequence_number, has_damage), | 3766 client_->last_begin_frame_ack()); |
3773 fake_external_begin_frame_source_->LastAckForObserver(scheduler_.get())); | 3767 client_->Reset(); |
3774 } | 3768 } |
3775 | 3769 |
3776 } // namespace | 3770 } // namespace |
3777 } // namespace cc | 3771 } // namespace cc |
OLD | NEW |