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
3 // found in the LICENSE file.
5 #ifndef CC_TEST_SCHEDULER_TEST_COMMON_H_
6 #define CC_TEST_SCHEDULER_TEST_COMMON_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/time/time.h"
11 #include "cc/scheduler/delay_based_time_source.h"
12 #include "cc/scheduler/frame_rate_controller.h"
13 #include "testing/gtest/include/gtest/gtest.h"
17 class FakeTimeSourceClient : public cc::TimeSourceClient {
19 FakeTimeSourceClient() { Reset(); }
20 void Reset() { tick_called_ = false; }
21 bool TickCalled() const { return tick_called_; }
23 // TimeSourceClient implementation.
24 virtual void OnTimerTick() OVERRIDE;
30 class FakeDelayBasedTimeSource : public cc::DelayBasedTimeSource {
32 static scoped_refptr<FakeDelayBasedTimeSource> Create(
33 base::TimeDelta interval, base::SingleThreadTaskRunner* task_runner) {
34 return make_scoped_refptr(new FakeDelayBasedTimeSource(interval,
38 void SetNow(base::TimeTicks time) { now_ = time; }
39 virtual base::TimeTicks Now() const OVERRIDE;
42 FakeDelayBasedTimeSource(base::TimeDelta interval,
43 base::SingleThreadTaskRunner* task_runner)
44 : DelayBasedTimeSource(interval, task_runner) {}
45 virtual ~FakeDelayBasedTimeSource() {}
50 class FakeFrameRateController : public cc::FrameRateController {
52 explicit FakeFrameRateController(scoped_refptr<cc::TimeSource> timer)
53 : cc::FrameRateController(timer) {}
55 int NumFramesPending() const { return num_frames_pending_; }
60 #endif // CC_TEST_SCHEDULER_TEST_COMMON_H_