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

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

Issue 1121233005: Don't adjust deadline for children BeginFrames (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« cc/scheduler/scheduler.cc ('K') | « cc/scheduler/scheduler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/scheduler/scheduler.h" 5 #include "cc/scheduler/scheduler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 statements; \ 42 statements; \
43 } 43 }
44 44
45 namespace cc { 45 namespace cc {
46 namespace { 46 namespace {
47 47
48 class FakeSchedulerClient : public SchedulerClient { 48 class FakeSchedulerClient : public SchedulerClient {
49 public: 49 public:
50 FakeSchedulerClient() 50 FakeSchedulerClient()
51 : automatic_swap_ack_(true), 51 : automatic_swap_ack_(true),
52 begin_frame_is_sent_to_children_(false),
53 scheduler_(nullptr) { 52 scheduler_(nullptr) {
54 Reset(); 53 Reset();
55 } 54 }
56 55
57 void Reset() { 56 void Reset() {
58 actions_.clear(); 57 actions_.clear();
59 states_.clear(); 58 states_.clear();
60 draw_will_happen_ = true; 59 draw_will_happen_ = true;
61 swap_will_happen_if_draw_happens_ = true; 60 swap_will_happen_if_draw_happens_ = true;
62 num_draws_ = 0; 61 num_draws_ = 0;
63 log_anticipated_draw_time_change_ = false; 62 log_anticipated_draw_time_change_ = false;
64 begin_frame_is_sent_to_children_ = false; 63 begin_frame_args_sent_to_children_ = BeginFrameArgs();
65 } 64 }
66 65
67 void set_scheduler(TestScheduler* scheduler) { scheduler_ = scheduler; } 66 void set_scheduler(TestScheduler* scheduler) { scheduler_ = scheduler; }
68 67
69 // Most tests don't care about DidAnticipatedDrawTimeChange, so only record it 68 // Most tests don't care about DidAnticipatedDrawTimeChange, so only record it
70 // for tests that do. 69 // for tests that do.
71 void set_log_anticipated_draw_time_change(bool log) { 70 void set_log_anticipated_draw_time_change(bool log) {
72 log_anticipated_draw_time_change_ = log; 71 log_anticipated_draw_time_change_ = log;
73 } 72 }
74 bool needs_begin_frames() { 73 bool needs_begin_frames() {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 base::TimeDelta BeginMainFrameToCommitDurationEstimate() override { 152 base::TimeDelta BeginMainFrameToCommitDurationEstimate() override {
154 return base::TimeDelta(); 153 return base::TimeDelta();
155 } 154 }
156 base::TimeDelta CommitToActivateDurationEstimate() override { 155 base::TimeDelta CommitToActivateDurationEstimate() override {
157 return base::TimeDelta(); 156 return base::TimeDelta();
158 } 157 }
159 158
160 void DidBeginImplFrameDeadline() override {} 159 void DidBeginImplFrameDeadline() override {}
161 160
162 void SendBeginFramesToChildren(const BeginFrameArgs& args) override { 161 void SendBeginFramesToChildren(const BeginFrameArgs& args) override {
163 begin_frame_is_sent_to_children_ = true; 162 begin_frame_args_sent_to_children_ = args;
164 } 163 }
165 164
166 void SendBeginMainFrameNotExpectedSoon() override { 165 void SendBeginMainFrameNotExpectedSoon() override {
167 PushAction("SendBeginMainFrameNotExpectedSoon"); 166 PushAction("SendBeginMainFrameNotExpectedSoon");
168 } 167 }
169 168
170 base::Callback<bool(void)> ImplFrameDeadlinePending(bool state) { 169 base::Callback<bool(void)> ImplFrameDeadlinePending(bool state) {
171 return base::Bind(&FakeSchedulerClient::ImplFrameDeadlinePendingCallback, 170 return base::Bind(&FakeSchedulerClient::ImplFrameDeadlinePendingCallback,
172 base::Unretained(this), 171 base::Unretained(this),
173 state); 172 state);
174 } 173 }
175 174
176 bool begin_frame_is_sent_to_children() const { 175 bool begin_frame_is_sent_to_children() const {
177 return begin_frame_is_sent_to_children_; 176 return begin_frame_args_sent_to_children_.IsValid();
177 }
178
179 const BeginFrameArgs& begin_frame_args_sent_to_children() const {
180 return begin_frame_args_sent_to_children_;
178 } 181 }
179 182
180 void PushAction(const char* description) { 183 void PushAction(const char* description) {
181 actions_.push_back(description); 184 actions_.push_back(description);
182 states_.push_back(scheduler_->AsValue()); 185 states_.push_back(scheduler_->AsValue());
183 } 186 }
184 187
185 protected: 188 protected:
186 bool ImplFrameDeadlinePendingCallback(bool state) { 189 bool ImplFrameDeadlinePendingCallback(bool state) {
187 return scheduler_->BeginImplFrameDeadlinePending() == state; 190 return scheduler_->BeginImplFrameDeadlinePending() == state;
188 } 191 }
189 192
190 bool draw_will_happen_; 193 bool draw_will_happen_;
191 bool swap_will_happen_if_draw_happens_; 194 bool swap_will_happen_if_draw_happens_;
192 bool automatic_swap_ack_; 195 bool automatic_swap_ack_;
193 int num_draws_; 196 int num_draws_;
194 bool log_anticipated_draw_time_change_; 197 bool log_anticipated_draw_time_change_;
195 bool begin_frame_is_sent_to_children_; 198 BeginFrameArgs begin_frame_args_sent_to_children_;
196 base::TimeTicks posted_begin_impl_frame_deadline_; 199 base::TimeTicks posted_begin_impl_frame_deadline_;
197 std::vector<const char*> actions_; 200 std::vector<const char*> actions_;
198 std::vector<scoped_refptr<base::trace_event::ConvertableToTraceFormat>> 201 std::vector<scoped_refptr<base::trace_event::ConvertableToTraceFormat>>
199 states_; 202 states_;
200 TestScheduler* scheduler_; 203 TestScheduler* scheduler_;
201 }; 204 };
202 205
203 class FakeExternalBeginFrameSource : public BeginFrameSourceMixIn { 206 class FakeExternalBeginFrameSource : public BeginFrameSourceMixIn {
204 public: 207 public:
205 explicit FakeExternalBeginFrameSource(FakeSchedulerClient* client) 208 explicit FakeExternalBeginFrameSource(FakeSchedulerClient* client)
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 EXPECT_FALSE(client_->needs_begin_frames()); 450 EXPECT_FALSE(client_->needs_begin_frames());
448 scheduler_->SetChildrenNeedBeginFrames(true); 451 scheduler_->SetChildrenNeedBeginFrames(true);
449 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); 452 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_);
450 EXPECT_TRUE(client_->needs_begin_frames()); 453 EXPECT_TRUE(client_->needs_begin_frames());
451 454
452 client_->Reset(); 455 client_->Reset();
453 EXPECT_SCOPED(AdvanceFrame()); 456 EXPECT_SCOPED(AdvanceFrame());
454 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); 457 EXPECT_TRUE(client_->begin_frame_is_sent_to_children());
455 } 458 }
456 459
460 TEST_F(SchedulerTest, SendBeginFramesToChildrenDeadlineNotAdjusted) {
461 scheduler_settings_.use_external_begin_frame_source = true;
462 SetUpScheduler(true);
463
464 EXPECT_FALSE(client_->needs_begin_frames());
465 scheduler_->SetChildrenNeedBeginFrames(true);
466 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_);
467 EXPECT_TRUE(client_->needs_begin_frames());
468
469 client_->Reset();
470
471 BeginFrameArgs frame_args =
472 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src());
473 fake_external_begin_frame_source()->TestOnBeginFrame(frame_args);
474
475 EXPECT_TRUE(client_->begin_frame_is_sent_to_children());
476 EXPECT_EQ(client_->begin_frame_args_sent_to_children().deadline,
sunnyps 2015/05/05 01:00:42 I don't think this is test works. This would hold
brianderson 2015/05/05 01:53:29 Good catch. It didn't fail without this patch. I c
477 frame_args.deadline);
478 }
479
457 TEST_F(SchedulerTest, VideoNeedsBeginFrames) { 480 TEST_F(SchedulerTest, VideoNeedsBeginFrames) {
458 scheduler_settings_.use_external_begin_frame_source = true; 481 scheduler_settings_.use_external_begin_frame_source = true;
459 SetUpScheduler(true); 482 SetUpScheduler(true);
460 483
461 scheduler_->SetVideoNeedsBeginFrames(true); 484 scheduler_->SetVideoNeedsBeginFrames(true);
462 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); 485 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_);
463 EXPECT_TRUE(client_->needs_begin_frames()); 486 EXPECT_TRUE(client_->needs_begin_frames());
464 487
465 client_->Reset(); 488 client_->Reset();
466 EXPECT_SCOPED(AdvanceFrame()); 489 EXPECT_SCOPED(AdvanceFrame());
(...skipping 2143 matching lines...) Expand 10 before | Expand all | Expand 10 after
2610 2633
2611 // At the next BeginFrame, authoritative interval is used instead of previous 2634 // At the next BeginFrame, authoritative interval is used instead of previous
2612 // interval. 2635 // interval.
2613 EXPECT_NE(initial_interval, scheduler_->begin_impl_frame_args().interval); 2636 EXPECT_NE(initial_interval, scheduler_->begin_impl_frame_args().interval);
2614 EXPECT_EQ(authoritative_interval, 2637 EXPECT_EQ(authoritative_interval,
2615 scheduler_->begin_impl_frame_args().interval); 2638 scheduler_->begin_impl_frame_args().interval);
2616 } 2639 }
2617 2640
2618 } // namespace 2641 } // namespace
2619 } // namespace cc 2642 } // namespace cc
OLDNEW
« cc/scheduler/scheduler.cc ('K') | « cc/scheduler/scheduler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698