Update V8 to version 4.7.21.
[chromium-blink-merge.git] / cc / test / begin_frame_args_test.cc
blob64e2e7d1580529c61f3628480eed89d9c9a53f43
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"
10 namespace cc {
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(
21 location, frame_time,
22 frame_time + BeginFrameArgs::DefaultInterval() -
23 BeginFrameArgs::DefaultEstimatedParentDrawTime(),
24 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL);
27 BeginFrameArgs CreateBeginFrameArgsForTesting(
28 BeginFrameArgs::CreationLocation location,
29 int64 frame_time,
30 int64 deadline,
31 int64 interval) {
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,
40 int64 frame_time,
41 int64 deadline,
42 int64 interval,
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) {
83 PrintTo(args, &os);
84 return os;
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)";
94 } // namespace cc