Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / cc / test / fake_external_begin_frame_source.cc
blobc1885c143429dafe1bc1a5ac7666e2d7aba77ab9
1 // Copyright 2014 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/fake_external_begin_frame_source.h"
7 #include "base/location.h"
8 #include "base/message_loop/message_loop.h"
9 #include "base/time/time.h"
10 #include "cc/test/begin_frame_args_test.h"
12 namespace cc {
14 FakeExternalBeginFrameSource::FakeExternalBeginFrameSource(double refresh_rate)
15 : milliseconds_per_frame_(1000.0 / refresh_rate),
16 is_ready_(false),
17 weak_ptr_factory_(this) {
18 DetachFromThread();
21 FakeExternalBeginFrameSource::~FakeExternalBeginFrameSource() {
22 DCHECK(CalledOnValidThread());
25 void FakeExternalBeginFrameSource::SetClientReady() {
26 DCHECK(CalledOnValidThread());
27 is_ready_ = true;
30 void FakeExternalBeginFrameSource::OnNeedsBeginFramesChange(
31 bool needs_begin_frames) {
32 DCHECK(CalledOnValidThread());
33 if (needs_begin_frames) {
34 PostTestOnBeginFrame();
38 void FakeExternalBeginFrameSource::TestOnBeginFrame() {
39 DCHECK(CalledOnValidThread());
40 CallOnBeginFrame(CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE));
42 if (NeedsBeginFrames()) {
43 PostTestOnBeginFrame();
47 void FakeExternalBeginFrameSource::PostTestOnBeginFrame() {
48 base::MessageLoop::current()->PostDelayedTask(
49 FROM_HERE, base::Bind(&FakeExternalBeginFrameSource::TestOnBeginFrame,
50 weak_ptr_factory_.GetWeakPtr()),
51 base::TimeDelta::FromMilliseconds(milliseconds_per_frame_));
54 } // namespace cc