forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscheduler_test_common.cc
82 lines (64 loc) · 1.4 KB
/
scheduler_test_common.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cc/test/scheduler_test_common.h"
#include "base/logging.h"
namespace WebKitTests {
void FakeTimeSourceClient::onTimerTick()
{
m_tickCalled = true;
}
FakeThread::FakeThread()
{
reset();
}
FakeThread::~FakeThread()
{
}
void FakeThread::runPendingTask()
{
ASSERT_TRUE(m_pendingTask);
scoped_ptr<base::Closure> task = m_pendingTask.Pass();
task->Run();
}
void FakeThread::postTask(base::Closure cb)
{
postDelayedTask(cb, 0);
}
void FakeThread::postDelayedTask(base::Closure cb, long long delay)
{
if (m_runPendingTaskOnOverwrite && hasPendingTask())
runPendingTask();
ASSERT_FALSE(hasPendingTask());
m_pendingTask.reset(new base::Closure(cb));
m_pendingTaskDelay = delay;
}
bool FakeThread::belongsToCurrentThread() const
{
return true;
}
void FakeTimeSource::setClient(cc::TimeSourceClient* client)
{
m_client = client;
}
void FakeTimeSource::setActive(bool b)
{
m_active = b;
}
bool FakeTimeSource::active() const
{
return m_active;
}
base::TimeTicks FakeTimeSource::lastTickTime()
{
return base::TimeTicks();
}
base::TimeTicks FakeTimeSource::nextTickTime()
{
return base::TimeTicks();
}
base::TimeTicks FakeDelayBasedTimeSource::now() const
{
return m_now;
}
}