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() -
23 BeginFrameArgs::DefaultEstimatedParentDrawTime(),
24 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL
);
27 BeginFrameArgs
CreateBeginFrameArgsForTesting(
28 BeginFrameArgs::CreationLocation location
,
32 return BeginFrameArgs::Create(
33 location
, base::TimeTicks::FromInternalValue(frame_time
),
34 base::TimeTicks::FromInternalValue(deadline
),
35 base::TimeDelta::FromInternalValue(interval
), BeginFrameArgs::NORMAL
);
38 BeginFrameArgs
CreateBeginFrameArgsForTesting(
39 BeginFrameArgs::CreationLocation location
,
43 BeginFrameArgs::BeginFrameArgsType type
) {
44 return BeginFrameArgs::Create(
45 location
, base::TimeTicks::FromInternalValue(frame_time
),
46 base::TimeTicks::FromInternalValue(deadline
),
47 base::TimeDelta::FromInternalValue(interval
), type
);
50 BeginFrameArgs
CreateExpiredBeginFrameArgsForTesting(
51 BeginFrameArgs::CreationLocation location
) {
52 base::TimeTicks now
= base::TimeTicks::Now();
53 return BeginFrameArgs::Create(
54 location
, now
, now
- BeginFrameArgs::DefaultInterval(),
55 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL
);
58 BeginFrameArgs
CreateBeginFrameArgsForTesting(
59 BeginFrameArgs::CreationLocation location
,
60 base::SimpleTestTickClock
* now_src
) {
61 base::TimeTicks now
= now_src
->NowTicks();
62 return BeginFrameArgs::Create(
63 location
, now
, now
+ BeginFrameArgs::DefaultInterval() -
64 BeginFrameArgs::DefaultEstimatedParentDrawTime(),
65 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL
);
68 BeginFrameArgs
CreateExpiredBeginFrameArgsForTesting(
69 BeginFrameArgs::CreationLocation location
,
70 base::SimpleTestTickClock
* now_src
) {
71 base::TimeTicks now
= now_src
->NowTicks();
72 return BeginFrameArgs::Create(
73 location
, now
, now
- BeginFrameArgs::DefaultInterval(),
74 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL
);
77 bool operator==(const BeginFrameArgs
& lhs
, const BeginFrameArgs
& rhs
) {
78 return (lhs
.type
== rhs
.type
) && (lhs
.frame_time
== rhs
.frame_time
) &&
79 (lhs
.deadline
== rhs
.deadline
) && (lhs
.interval
== rhs
.interval
);
82 ::std::ostream
& operator<<(::std::ostream
& os
, const BeginFrameArgs
& args
) {
87 void PrintTo(const BeginFrameArgs
& args
, ::std::ostream
* os
) {
88 *os
<< "BeginFrameArgs(" << BeginFrameArgs::TypeToString(args
.type
) << ", "
89 << args
.frame_time
.ToInternalValue() << ", "
90 << args
.deadline
.ToInternalValue() << ", "
91 << args
.interval
.InMicroseconds() << "us)";