Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / cc / test / scheduler_test_common.cc
blob7f730debe117fdd16036c31bab0892f5f1a68395
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "cc/test/scheduler_test_common.h"
7 #include <string>
9 #include "base/logging.h"
11 namespace cc {
13 void FakeTimeSourceClient::OnTimerTick() {
14 tick_called_ = true;
17 base::TimeTicks FakeDelayBasedTimeSource::Now() const { return now_; }
19 TestDelayBasedTimeSource::TestDelayBasedTimeSource(
20 scoped_refptr<TestNowSource> now_src,
21 base::TimeDelta interval,
22 OrderedSimpleTaskRunner* task_runner)
23 : DelayBasedTimeSource(interval, task_runner), now_src_(now_src) {
26 base::TimeTicks TestDelayBasedTimeSource::Now() const {
27 return now_src_->Now();
30 std::string TestDelayBasedTimeSource::TypeString() const {
31 return "TestDelayBasedTimeSource";
34 TestDelayBasedTimeSource::~TestDelayBasedTimeSource() {
37 void FakeBeginFrameSource::DidFinishFrame(size_t remaining_frames) {
38 remaining_frames_ = remaining_frames;
40 void FakeBeginFrameSource::AsValueInto(
41 base::trace_event::TracedValue* dict) const {
42 dict->SetString("type", "FakeBeginFrameSource");
43 BeginFrameSourceMixIn::AsValueInto(dict);
46 TestBackToBackBeginFrameSource::TestBackToBackBeginFrameSource(
47 scoped_refptr<TestNowSource> now_src,
48 base::SingleThreadTaskRunner* task_runner)
49 : BackToBackBeginFrameSource(task_runner), now_src_(now_src) {
52 TestBackToBackBeginFrameSource::~TestBackToBackBeginFrameSource() {
55 base::TimeTicks TestBackToBackBeginFrameSource::Now() {
56 return now_src_->Now();
59 TestSyntheticBeginFrameSource::TestSyntheticBeginFrameSource(
60 scoped_refptr<DelayBasedTimeSource> time_source)
61 : SyntheticBeginFrameSource(time_source) {
64 TestSyntheticBeginFrameSource::~TestSyntheticBeginFrameSource() {
67 TestSchedulerFrameSourcesConstructor::TestSchedulerFrameSourcesConstructor(
68 OrderedSimpleTaskRunner* test_task_runner,
69 TestNowSource* now_src)
70 : test_task_runner_(test_task_runner), now_src_(now_src) {
72 TestSchedulerFrameSourcesConstructor::~TestSchedulerFrameSourcesConstructor() {
75 BeginFrameSource*
76 TestSchedulerFrameSourcesConstructor::ConstructPrimaryFrameSource(
77 Scheduler* scheduler) {
78 if (scheduler->settings_.use_external_begin_frame_source) {
79 return SchedulerFrameSourcesConstructor::ConstructPrimaryFrameSource(
80 scheduler);
81 } else {
82 TRACE_EVENT1(
83 "cc",
84 "TestSchedulerFrameSourcesConstructor::ConstructPrimaryFrameSource",
85 "source",
86 "TestSyntheticBeginFrameSource");
87 scoped_ptr<TestSyntheticBeginFrameSource> synthetic_source =
88 TestSyntheticBeginFrameSource::Create(
89 now_src_, test_task_runner_, BeginFrameArgs::DefaultInterval());
91 DCHECK(!scheduler->vsync_observer_);
92 scheduler->vsync_observer_ = synthetic_source.get();
94 DCHECK(!scheduler->primary_frame_source_internal_);
95 scheduler->primary_frame_source_internal_ = synthetic_source.Pass();
96 return scheduler->primary_frame_source_internal_.get();
100 BeginFrameSource*
101 TestSchedulerFrameSourcesConstructor::ConstructUnthrottledFrameSource(
102 Scheduler* scheduler) {
103 TRACE_EVENT1(
104 "cc",
105 "TestSchedulerFrameSourcesConstructor::ConstructUnthrottledFrameSource",
106 "source", "TestBackToBackBeginFrameSource");
107 DCHECK(!scheduler->unthrottled_frame_source_internal_);
108 scheduler->unthrottled_frame_source_internal_ =
109 TestBackToBackBeginFrameSource::Create(now_src_, test_task_runner_);
110 return scheduler->unthrottled_frame_source_internal_.get();
113 TestScheduler::TestScheduler(
114 scoped_refptr<TestNowSource> now_src,
115 SchedulerClient* client,
116 const SchedulerSettings& scheduler_settings,
117 int layer_tree_host_id,
118 const scoped_refptr<OrderedSimpleTaskRunner>& test_task_runner,
119 TestSchedulerFrameSourcesConstructor* frame_sources_constructor,
120 scoped_ptr<BeginFrameSource> external_begin_frame_source)
121 : Scheduler(client,
122 scheduler_settings,
123 layer_tree_host_id,
124 test_task_runner,
125 external_begin_frame_source.Pass(),
126 frame_sources_constructor),
127 now_src_(now_src) {
130 base::TimeTicks TestScheduler::Now() const {
131 return now_src_->Now();
134 TestScheduler::~TestScheduler() {
137 } // namespace cc