Adding Peter Thatcher to the owners file.
[chromium-blink-merge.git] / cc / test / begin_frame_args_test.cc
blob7b2974867469d3803d029dedc483dff233290edb
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"
9 #include "ui/gfx/frame_time.h"
11 namespace cc {
13 BeginFrameArgs CreateBeginFrameArgsForTesting(
14 BeginFrameArgs::CreationLocation location) {
15 return CreateBeginFrameArgsForTesting(location, gfx::FrameTime::Now());
18 BeginFrameArgs CreateBeginFrameArgsForTesting(
19 BeginFrameArgs::CreationLocation location,
20 base::TimeTicks frame_time) {
21 return BeginFrameArgs::Create(
22 location, frame_time,
23 frame_time + (BeginFrameArgs::DefaultInterval() / 2),
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 = gfx::FrameTime::Now();
53 return BeginFrameArgs::Create(
54 location, now, now - BeginFrameArgs::DefaultInterval(),
55 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL);
58 BeginFrameArgs CreateBeginFrameArgsForTesting(
59 BeginFrameArgs::CreationLocation location,
60 scoped_refptr<TestNowSource> now_src) {
61 base::TimeTicks now = now_src->Now();
62 return BeginFrameArgs::Create(
63 location, now, now + (BeginFrameArgs::DefaultInterval() / 2),
64 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL);
67 BeginFrameArgs CreateExpiredBeginFrameArgsForTesting(
68 BeginFrameArgs::CreationLocation location,
69 scoped_refptr<TestNowSource> now_src) {
70 base::TimeTicks now = now_src->Now();
71 return BeginFrameArgs::Create(
72 location, now, now - BeginFrameArgs::DefaultInterval(),
73 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL);
76 bool operator==(const BeginFrameArgs& lhs, const BeginFrameArgs& rhs) {
77 return (lhs.type == rhs.type) && (lhs.frame_time == rhs.frame_time) &&
78 (lhs.deadline == rhs.deadline) && (lhs.interval == rhs.interval);
81 ::std::ostream& operator<<(::std::ostream& os, const BeginFrameArgs& args) {
82 PrintTo(args, &os);
83 return os;
86 void PrintTo(const BeginFrameArgs& args, ::std::ostream* os) {
87 *os << "BeginFrameArgs(" << BeginFrameArgs::TypeToString(args.type) << ", "
88 << args.frame_time.ToInternalValue() << ", "
89 << args.deadline.ToInternalValue() << ", "
90 << args.interval.InMicroseconds() << "us)";
93 } // namespace cc