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/begin_frame_args_test.h"
7 #include "base/time/time.h"
8 #include "cc/output/begin_frame_args.h"
12 BeginFrameArgs
CreateBeginFrameArgsForTesting(
13 BeginFrameArgs::CreationLocation location
) {
14 return CreateBeginFrameArgsForTesting(location
, base::TimeTicks::Now());
17 BeginFrameArgs
CreateBeginFrameArgsForTesting(
18 BeginFrameArgs::CreationLocation location
,
19 base::TimeTicks frame_time
) {
20 return BeginFrameArgs::Create(
22 frame_time
+ (BeginFrameArgs::DefaultInterval() / 2),
23 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL
);
26 BeginFrameArgs
CreateBeginFrameArgsForTesting(
27 BeginFrameArgs::CreationLocation location
,
31 return BeginFrameArgs::Create(
32 location
, base::TimeTicks::FromInternalValue(frame_time
),
33 base::TimeTicks::FromInternalValue(deadline
),
34 base::TimeDelta::FromInternalValue(interval
), BeginFrameArgs::NORMAL
);
37 BeginFrameArgs
CreateBeginFrameArgsForTesting(
38 BeginFrameArgs::CreationLocation location
,
42 BeginFrameArgs::BeginFrameArgsType type
) {
43 return BeginFrameArgs::Create(
44 location
, base::TimeTicks::FromInternalValue(frame_time
),
45 base::TimeTicks::FromInternalValue(deadline
),
46 base::TimeDelta::FromInternalValue(interval
), type
);
49 BeginFrameArgs
CreateExpiredBeginFrameArgsForTesting(
50 BeginFrameArgs::CreationLocation location
) {
51 base::TimeTicks now
= base::TimeTicks::Now();
52 return BeginFrameArgs::Create(
53 location
, now
, now
- BeginFrameArgs::DefaultInterval(),
54 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL
);
57 BeginFrameArgs
CreateBeginFrameArgsForTesting(
58 BeginFrameArgs::CreationLocation location
,
59 scoped_refptr
<TestNowSource
> now_src
) {
60 base::TimeTicks now
= now_src
->Now();
61 return BeginFrameArgs::Create(
62 location
, now
, now
+ (BeginFrameArgs::DefaultInterval() / 2),
63 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL
);
66 BeginFrameArgs
CreateExpiredBeginFrameArgsForTesting(
67 BeginFrameArgs::CreationLocation location
,
68 scoped_refptr
<TestNowSource
> now_src
) {
69 base::TimeTicks now
= now_src
->Now();
70 return BeginFrameArgs::Create(
71 location
, now
, now
- BeginFrameArgs::DefaultInterval(),
72 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL
);
75 bool operator==(const BeginFrameArgs
& lhs
, const BeginFrameArgs
& rhs
) {
76 return (lhs
.type
== rhs
.type
) && (lhs
.frame_time
== rhs
.frame_time
) &&
77 (lhs
.deadline
== rhs
.deadline
) && (lhs
.interval
== rhs
.interval
);
80 ::std::ostream
& operator<<(::std::ostream
& os
, const BeginFrameArgs
& args
) {
85 void PrintTo(const BeginFrameArgs
& args
, ::std::ostream
* os
) {
86 *os
<< "BeginFrameArgs(" << BeginFrameArgs::TypeToString(args
.type
) << ", "
87 << args
.frame_time
.ToInternalValue() << ", "
88 << args
.deadline
.ToInternalValue() << ", "
89 << args
.interval
.InMicroseconds() << "us)";