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

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

Issue 1841083007: Remove SendBeginFramesToChildren plumbing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scheduler_output_surface_client_set_beginframesource
Patch Set: Remove some comments Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/scheduler/scheduler.h" 5 #include "cc/scheduler/scheduler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 } 59 }
60 60
61 void Reset() { 61 void Reset() {
62 actions_.clear(); 62 actions_.clear();
63 states_.clear(); 63 states_.clear();
64 will_begin_impl_frame_causes_redraw_ = false; 64 will_begin_impl_frame_causes_redraw_ = false;
65 will_begin_impl_frame_requests_one_begin_impl_frame_ = false; 65 will_begin_impl_frame_requests_one_begin_impl_frame_ = false;
66 draw_will_happen_ = true; 66 draw_will_happen_ = true;
67 swap_will_happen_if_draw_happens_ = true; 67 swap_will_happen_if_draw_happens_ = true;
68 num_draws_ = 0; 68 num_draws_ = 0;
69 begin_frame_args_sent_to_children_ = BeginFrameArgs();
70 last_begin_main_frame_args_ = BeginFrameArgs(); 69 last_begin_main_frame_args_ = BeginFrameArgs();
71 } 70 }
72 71
73 void set_scheduler(TestScheduler* scheduler) { scheduler_ = scheduler; } 72 void set_scheduler(TestScheduler* scheduler) { scheduler_ = scheduler; }
74 73
75 bool needs_begin_frames() { return scheduler_->begin_frames_expected(); } 74 bool needs_begin_frames() { return scheduler_->begin_frames_expected(); }
76 int num_draws() const { return num_draws_; } 75 int num_draws() const { return num_draws_; }
77 int num_actions_() const { return static_cast<int>(actions_.size()); } 76 int num_actions_() const { return static_cast<int>(actions_.size()); }
78 const char* Action(int i) const { return actions_[i]; } 77 const char* Action(int i) const { return actions_[i]; }
79 std::string StateForAction(int i) const { return states_[i]->ToString(); } 78 std::string StateForAction(int i) const { return states_[i]->ToString(); }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 void ScheduledActionPrepareTiles() override { 157 void ScheduledActionPrepareTiles() override {
159 PushAction("ScheduledActionPrepareTiles"); 158 PushAction("ScheduledActionPrepareTiles");
160 scheduler_->WillPrepareTiles(); 159 scheduler_->WillPrepareTiles();
161 scheduler_->DidPrepareTiles(); 160 scheduler_->DidPrepareTiles();
162 } 161 }
163 void ScheduledActionInvalidateOutputSurface() override { 162 void ScheduledActionInvalidateOutputSurface() override {
164 actions_.push_back("ScheduledActionInvalidateOutputSurface"); 163 actions_.push_back("ScheduledActionInvalidateOutputSurface");
165 states_.push_back(scheduler_->AsValue()); 164 states_.push_back(scheduler_->AsValue());
166 } 165 }
167 166
168 void SendBeginFramesToChildren(const BeginFrameArgs& args) override {
169 begin_frame_args_sent_to_children_ = args;
170 }
171
172 void SendBeginMainFrameNotExpectedSoon() override { 167 void SendBeginMainFrameNotExpectedSoon() override {
173 PushAction("SendBeginMainFrameNotExpectedSoon"); 168 PushAction("SendBeginMainFrameNotExpectedSoon");
174 } 169 }
175 170
176 base::Callback<bool(void)> ImplFrameDeadlinePending(bool state) { 171 base::Callback<bool(void)> ImplFrameDeadlinePending(bool state) {
177 return base::Bind(&FakeSchedulerClient::ImplFrameDeadlinePendingCallback, 172 return base::Bind(&FakeSchedulerClient::ImplFrameDeadlinePendingCallback,
178 base::Unretained(this), 173 base::Unretained(this),
179 state); 174 state);
180 } 175 }
181 176
182 bool begin_frame_is_sent_to_children() const {
183 return begin_frame_args_sent_to_children_.IsValid();
184 }
185
186 const BeginFrameArgs& begin_frame_args_sent_to_children() const {
187 return begin_frame_args_sent_to_children_;
188 }
189
190 void PushAction(const char* description) { 177 void PushAction(const char* description) {
191 actions_.push_back(description); 178 actions_.push_back(description);
192 states_.push_back(scheduler_->AsValue()); 179 states_.push_back(scheduler_->AsValue());
193 } 180 }
194 181
195 protected: 182 protected:
196 bool ImplFrameDeadlinePendingCallback(bool state) { 183 bool ImplFrameDeadlinePendingCallback(bool state) {
197 return scheduler_->BeginImplFrameDeadlinePending() == state; 184 return scheduler_->BeginImplFrameDeadlinePending() == state;
198 } 185 }
199 186
200 bool will_begin_impl_frame_causes_redraw_; 187 bool will_begin_impl_frame_causes_redraw_;
201 bool will_begin_impl_frame_requests_one_begin_impl_frame_; 188 bool will_begin_impl_frame_requests_one_begin_impl_frame_;
202 bool draw_will_happen_; 189 bool draw_will_happen_;
203 bool swap_will_happen_if_draw_happens_; 190 bool swap_will_happen_if_draw_happens_;
204 bool automatic_swap_ack_; 191 bool automatic_swap_ack_;
205 int num_draws_; 192 int num_draws_;
206 BeginFrameArgs begin_frame_args_sent_to_children_;
207 BeginFrameArgs last_begin_main_frame_args_; 193 BeginFrameArgs last_begin_main_frame_args_;
208 base::TimeTicks posted_begin_impl_frame_deadline_; 194 base::TimeTicks posted_begin_impl_frame_deadline_;
209 std::vector<const char*> actions_; 195 std::vector<const char*> actions_;
210 std::vector<scoped_ptr<base::trace_event::ConvertableToTraceFormat>> states_; 196 std::vector<scoped_ptr<base::trace_event::ConvertableToTraceFormat>> states_;
211 TestScheduler* scheduler_; 197 TestScheduler* scheduler_;
212 }; 198 };
213 199
214 class FakeExternalBeginFrameSource : public BeginFrameSourceBase { 200 class FakeExternalBeginFrameSource : public BeginFrameSourceBase {
215 public: 201 public:
216 explicit FakeExternalBeginFrameSource(FakeSchedulerClient* client) 202 explicit FakeExternalBeginFrameSource(FakeSchedulerClient* client)
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 SetUpScheduler(false); 439 SetUpScheduler(false);
454 scheduler_->SetVisible(true); 440 scheduler_->SetVisible(true);
455 scheduler_->SetCanDraw(true); 441 scheduler_->SetCanDraw(true);
456 442
457 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); 443 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_);
458 client_->Reset(); 444 client_->Reset();
459 scheduler_->DidCreateAndInitializeOutputSurface(); 445 scheduler_->DidCreateAndInitializeOutputSurface();
460 EXPECT_NO_ACTION(client_); 446 EXPECT_NO_ACTION(client_);
461 } 447 }
462 448
463 TEST_F(SchedulerTest, SendBeginFramesToChildren) {
464 scheduler_settings_.use_external_begin_frame_source = true;
465 SetUpScheduler(true);
466
467 EXPECT_FALSE(client_->begin_frame_is_sent_to_children());
468 scheduler_->SetNeedsBeginMainFrame();
469 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
470 EXPECT_TRUE(scheduler_->begin_frames_expected());
471
472 scheduler_->SetChildrenNeedBeginFrames(true);
473
474 client_->Reset();
475 EXPECT_SCOPED(AdvanceFrame());
476 EXPECT_TRUE(client_->begin_frame_is_sent_to_children());
477 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
478 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
479 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
480 EXPECT_TRUE(scheduler_->begin_frames_expected());
481 }
482
483 TEST_F(SchedulerTest, SendBeginFramesToChildrenWithoutCommit) {
484 scheduler_settings_.use_external_begin_frame_source = true;
485 SetUpScheduler(true);
486
487 EXPECT_FALSE(scheduler_->begin_frames_expected());
488 scheduler_->SetChildrenNeedBeginFrames(true);
489 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
490 EXPECT_TRUE(scheduler_->begin_frames_expected());
491
492 client_->Reset();
493 EXPECT_SCOPED(AdvanceFrame());
494 EXPECT_TRUE(client_->begin_frame_is_sent_to_children());
495 }
496
497 TEST_F(SchedulerTest, SendBeginFramesToChildrenDeadlineNotAdjusted) {
498 // Set up client with specified estimates.
499 scheduler_settings_.use_external_begin_frame_source = true;
500 SetUpScheduler(true);
501
502 fake_compositor_timing_history_
503 ->SetBeginMainFrameStartToCommitDurationEstimate(
504 base::TimeDelta::FromMilliseconds(2));
505 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate(
506 base::TimeDelta::FromMilliseconds(4));
507 fake_compositor_timing_history_->SetDrawDurationEstimate(
508 base::TimeDelta::FromMilliseconds(1));
509
510 EXPECT_FALSE(scheduler_->begin_frames_expected());
511 scheduler_->SetChildrenNeedBeginFrames(true);
512 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
513 EXPECT_TRUE(scheduler_->begin_frames_expected());
514
515 client_->Reset();
516
517 BeginFrameArgs frame_args =
518 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src());
519 fake_external_begin_frame_source()->TestOnBeginFrame(frame_args);
520
521 EXPECT_TRUE(client_->begin_frame_is_sent_to_children());
522 EXPECT_EQ(client_->begin_frame_args_sent_to_children().deadline,
523 frame_args.deadline);
524 }
525
526 TEST_F(SchedulerTest, VideoNeedsBeginFrames) { 449 TEST_F(SchedulerTest, VideoNeedsBeginFrames) {
527 scheduler_settings_.use_external_begin_frame_source = true; 450 scheduler_settings_.use_external_begin_frame_source = true;
528 SetUpScheduler(true); 451 SetUpScheduler(true);
529 452
530 scheduler_->SetVideoNeedsBeginFrames(true); 453 scheduler_->SetVideoNeedsBeginFrames(true);
531 EXPECT_SINGLE_ACTION("AddObserver(this)", client_); 454 EXPECT_SINGLE_ACTION("AddObserver(this)", client_);
532 EXPECT_TRUE(scheduler_->begin_frames_expected()); 455 EXPECT_TRUE(scheduler_->begin_frames_expected());
533 456
534 client_->Reset(); 457 client_->Reset();
535 EXPECT_SCOPED(AdvanceFrame()); 458 EXPECT_SCOPED(AdvanceFrame());
(...skipping 3314 matching lines...) Expand 10 before | Expand all | Expand 10 after
3850 } 3773 }
3851 3774
3852 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { 3775 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) {
3853 EXPECT_FALSE(BeginMainFrameOnCriticalPath( 3776 EXPECT_FALSE(BeginMainFrameOnCriticalPath(
3854 SMOOTHNESS_TAKES_PRIORITY, 3777 SMOOTHNESS_TAKES_PRIORITY,
3855 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); 3778 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration));
3856 } 3779 }
3857 3780
3858 } // namespace 3781 } // namespace
3859 } // namespace cc 3782 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698