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

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

Issue 619843002: cc: Make separate interface for BeginFrame ipc from OutputSurface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 #include "cc/scheduler/scheduler.h" 4 #include "cc/scheduler/scheduler.h"
5 5
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 void Reset() { 75 void Reset() {
76 actions_.clear(); 76 actions_.clear();
77 states_.clear(); 77 states_.clear();
78 draw_will_happen_ = true; 78 draw_will_happen_ = true;
79 swap_will_happen_if_draw_happens_ = true; 79 swap_will_happen_if_draw_happens_ = true;
80 num_draws_ = 0; 80 num_draws_ = 0;
81 log_anticipated_draw_time_change_ = false; 81 log_anticipated_draw_time_change_ = false;
82 } 82 }
83 83
84 TestScheduler* CreateScheduler(const SchedulerSettings& settings) { 84 TestScheduler* CreateScheduler(const SchedulerSettings& settings,
85 scheduler_ = TestScheduler::Create(now_src_, this, settings, 0); 85 bool use_external_begin_frame_source) {
86 scheduler_ = TestScheduler::Create(now_src_,
87 this,
88 settings,
89 0,
90 use_external_begin_frame_source);
86 DCHECK(scheduler_); 91 DCHECK(scheduler_);
87 // Fail if we need to run 100 tasks in a row. 92 // Fail if we need to run 100 tasks in a row.
88 task_runner().SetRunTaskLimit(100); 93 task_runner().SetRunTaskLimit(100);
89 return scheduler_.get(); 94 return scheduler_.get();
90 } 95 }
91 96
92 // Most tests don't care about DidAnticipatedDrawTimeChange, so only record it 97 // Most tests don't care about DidAnticipatedDrawTimeChange, so only record it
93 // for tests that do. 98 // for tests that do.
94 void set_log_anticipated_draw_time_change(bool log) { 99 void set_log_anticipated_draw_time_change(bool log) {
95 log_anticipated_draw_time_change_ = log; 100 log_anticipated_draw_time_change_ = log;
96 } 101 }
97 bool needs_begin_frames() { return fake_frame_source_.NeedsBeginFrames(); } 102 bool needs_begin_frames() { return fake_frame_source_.NeedsBeginFrames(); }
98 int num_draws() const { return num_draws_; } 103 int num_draws() const { return num_draws_; }
99 int num_actions_() const { return static_cast<int>(actions_.size()); } 104 int num_actions_() const { return static_cast<int>(actions_.size()); }
100 const char* Action(int i) const { return actions_[i]; } 105 const char* Action(int i) const { return actions_[i]; }
101 std::string StateForAction(int i) const { return states_[i]->ToString(); } 106 std::string StateForAction(int i) const { return states_[i]->ToString(); }
102 base::TimeTicks posted_begin_impl_frame_deadline() const { 107 base::TimeTicks posted_begin_impl_frame_deadline() const {
103 return posted_begin_impl_frame_deadline_; 108 return posted_begin_impl_frame_deadline_;
104 } 109 }
105 110
106 bool ExternalBeginFrame() { 111 bool ExternalBeginFrame() {
107 return scheduler_->settings().begin_frame_scheduling_enabled && 112 return scheduler_->settings().begin_frame_scheduling_enabled &&
108 scheduler_->settings().throttle_frame_production; 113 scheduler_->settings().throttle_frame_production;
109 } 114 }
110 virtual FakeBeginFrameSource* ExternalBeginFrameSource() override {
111 return &fake_frame_source_;
112 }
113 115
114 void AdvanceFrame() { 116 void AdvanceFrame() {
115 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), 117 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"),
116 "FakeSchedulerClient::AdvanceFrame"); 118 "FakeSchedulerClient::AdvanceFrame");
117 // EXPECT_TRUE(needs_begin_frames());
118 if (ExternalBeginFrame()) { 119 if (ExternalBeginFrame()) {
119 // Creep the time forward so that any BeginFrameArgs is not equal to the 120 // Creep the time forward so that any BeginFrameArgs is not equal to the
120 // last one otherwise we violate the BeginFrameSource contract. 121 // last one otherwise we violate the BeginFrameSource contract.
121 now_src_->AdvanceNowMicroseconds(1); 122 now_src_->AdvanceNowMicroseconds(1);
122 fake_frame_source_.TestOnBeginFrame( 123 fake_frame_source_.TestOnBeginFrame(
123 CreateBeginFrameArgsForTesting(now_src_)); 124 CreateBeginFrameArgsForTesting(now_src_));
124 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); 125 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
125 } 126 }
126 127
127 EXPECT_TRUE(task_runner().RunTasksWhile(ImplFrameDeadlinePending(false))); 128 EXPECT_TRUE(task_runner().RunTasksWhile(ImplFrameDeadlinePending(false)));
(...skipping 1836 matching lines...) Expand 10 before | Expand all | Expand 10 after
1964 1965
1965 client.Reset(); 1966 client.Reset();
1966 scheduler->SetVisible(false); 1967 scheduler->SetVisible(false);
1967 // Sync tree should be forced to activate. 1968 // Sync tree should be forced to activate.
1968 EXPECT_ACTION("SetNeedsBeginFrames(false)", client, 0, 2); 1969 EXPECT_ACTION("SetNeedsBeginFrames(false)", client, 0, 2);
1969 EXPECT_ACTION("ScheduledActionActivateSyncTree", client, 1, 2); 1970 EXPECT_ACTION("ScheduledActionActivateSyncTree", client, 1, 2);
1970 } 1971 }
1971 1972
1972 } // namespace 1973 } // namespace
1973 } // namespace cc 1974 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698