Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(606)

Side by Side Diff: cc/test/begin_frame_args_test.cc

Issue 754433003: Update from https://crrev.com/305340 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/test/begin_frame_args_test.h ('k') | cc/test/fake_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/test/begin_frame_args_test.h" 5 #include "cc/test/begin_frame_args_test.h"
6 6
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "cc/output/begin_frame_args.h" 8 #include "cc/output/begin_frame_args.h"
9 #include "ui/gfx/frame_time.h" 9 #include "ui/gfx/frame_time.h"
10 10
11 namespace cc { 11 namespace cc {
12 12
13 BeginFrameArgs CreateBeginFrameArgsForTesting() { 13 BeginFrameArgs CreateBeginFrameArgsForTesting() {
14 return CreateBeginFrameArgsForTesting(gfx::FrameTime::Now()); 14 return CreateBeginFrameArgsForTesting(gfx::FrameTime::Now());
15 } 15 }
16 16
17 BeginFrameArgs CreateBeginFrameArgsForTesting(base::TimeTicks frame_time) { 17 BeginFrameArgs CreateBeginFrameArgsForTesting(base::TimeTicks frame_time) {
18 return BeginFrameArgs::Create( 18 return BeginFrameArgs::Create(
19 frame_time, 19 frame_time, frame_time + (BeginFrameArgs::DefaultInterval() / 2),
20 frame_time + (BeginFrameArgs::DefaultInterval() / 2), 20 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL);
21 BeginFrameArgs::DefaultInterval());
22 } 21 }
23 22
24 BeginFrameArgs CreateBeginFrameArgsForTesting(int64 frame_time, 23 BeginFrameArgs CreateBeginFrameArgsForTesting(int64 frame_time,
25 int64 deadline, 24 int64 deadline,
26 int64 interval) { 25 int64 interval) {
27 return BeginFrameArgs::Create(base::TimeTicks::FromInternalValue(frame_time), 26 return BeginFrameArgs::Create(base::TimeTicks::FromInternalValue(frame_time),
28 base::TimeTicks::FromInternalValue(deadline), 27 base::TimeTicks::FromInternalValue(deadline),
29 base::TimeDelta::FromInternalValue(interval)); 28 base::TimeDelta::FromInternalValue(interval),
29 BeginFrameArgs::NORMAL);
30 } 30 }
31 31
32 BeginFrameArgs CreateTypedBeginFrameArgsForTesting( 32 BeginFrameArgs CreateBeginFrameArgsForTesting(
33 int64 frame_time, 33 int64 frame_time,
34 int64 deadline, 34 int64 deadline,
35 int64 interval, 35 int64 interval,
36 BeginFrameArgs::BeginFrameArgsType type) { 36 BeginFrameArgs::BeginFrameArgsType type) {
37 return BeginFrameArgs::CreateTyped( 37 return BeginFrameArgs::Create(base::TimeTicks::FromInternalValue(frame_time),
38 base::TimeTicks::FromInternalValue(frame_time), 38 base::TimeTicks::FromInternalValue(deadline),
39 base::TimeTicks::FromInternalValue(deadline), 39 base::TimeDelta::FromInternalValue(interval),
40 base::TimeDelta::FromInternalValue(interval), 40 type);
41 type);
42 } 41 }
43 42
44 BeginFrameArgs CreateExpiredBeginFrameArgsForTesting() { 43 BeginFrameArgs CreateExpiredBeginFrameArgsForTesting() {
45 base::TimeTicks now = gfx::FrameTime::Now(); 44 base::TimeTicks now = gfx::FrameTime::Now();
46 return BeginFrameArgs::Create(now, 45 return BeginFrameArgs::Create(now, now - BeginFrameArgs::DefaultInterval(),
47 now - BeginFrameArgs::DefaultInterval(), 46 BeginFrameArgs::DefaultInterval(),
48 BeginFrameArgs::DefaultInterval()); 47 BeginFrameArgs::NORMAL);
49 } 48 }
50 49
51 BeginFrameArgs CreateBeginFrameArgsForTesting( 50 BeginFrameArgs CreateBeginFrameArgsForTesting(
52 scoped_refptr<TestNowSource> now_src) { 51 scoped_refptr<TestNowSource> now_src) {
53 base::TimeTicks now = now_src->Now(); 52 base::TimeTicks now = now_src->Now();
54 return BeginFrameArgs::Create(now, 53 return BeginFrameArgs::Create(
55 now + (BeginFrameArgs::DefaultInterval() / 2), 54 now, now + (BeginFrameArgs::DefaultInterval() / 2),
56 BeginFrameArgs::DefaultInterval()); 55 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL);
57 } 56 }
58 57
59 BeginFrameArgs CreateExpiredBeginFrameArgsForTesting( 58 BeginFrameArgs CreateExpiredBeginFrameArgsForTesting(
60 scoped_refptr<TestNowSource> now_src) { 59 scoped_refptr<TestNowSource> now_src) {
61 base::TimeTicks now = now_src->Now(); 60 base::TimeTicks now = now_src->Now();
62 return BeginFrameArgs::Create(now, 61 return BeginFrameArgs::Create(now, now - BeginFrameArgs::DefaultInterval(),
63 now - BeginFrameArgs::DefaultInterval(), 62 BeginFrameArgs::DefaultInterval(),
64 BeginFrameArgs::DefaultInterval()); 63 BeginFrameArgs::NORMAL);
65 } 64 }
66 65
67 bool operator==(const BeginFrameArgs& lhs, const BeginFrameArgs& rhs) { 66 bool operator==(const BeginFrameArgs& lhs, const BeginFrameArgs& rhs) {
68 return (lhs.frame_time == rhs.frame_time) && (lhs.deadline == rhs.deadline) && 67 return (lhs.type == rhs.type) && (lhs.frame_time == rhs.frame_time) &&
69 (lhs.interval == rhs.interval); 68 (lhs.deadline == rhs.deadline) && (lhs.interval == rhs.interval);
70 } 69 }
71 70
72 ::std::ostream& operator<<(::std::ostream& os, const BeginFrameArgs& args) { 71 ::std::ostream& operator<<(::std::ostream& os, const BeginFrameArgs& args) {
73 PrintTo(args, &os); 72 PrintTo(args, &os);
74 return os; 73 return os;
75 } 74 }
76 75
77 void PrintTo(const BeginFrameArgs& args, ::std::ostream* os) { 76 void PrintTo(const BeginFrameArgs& args, ::std::ostream* os) {
78 *os << "BeginFrameArgs(" << args.frame_time.ToInternalValue() << ", " 77 *os << "BeginFrameArgs(" << BeginFrameArgs::TypeToString(args.type) << ", "
78 << args.frame_time.ToInternalValue() << ", "
79 << args.deadline.ToInternalValue() << ", " 79 << args.deadline.ToInternalValue() << ", "
80 << args.interval.InMicroseconds() << "us)"; 80 << args.interval.InMicroseconds() << "us)";
81 } 81 }
82 82
83 } // namespace cc 83 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/begin_frame_args_test.h ('k') | cc/test/fake_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698