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

Side by Side Diff: cc/output/begin_frame_args_unittest.cc

Issue 2527283003: cc: Introduce BeginFrame sequence numbers and acknowledgements.
Patch Set: Address Brian's comments. Created 4 years 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/output/begin_frame_args.cc ('k') | cc/output/compositor_frame_metadata.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 <string> 5 #include <string>
6 6
7 #include "cc/output/begin_frame_args.h" 7 #include "cc/output/begin_frame_args.h"
8 #include "cc/test/begin_frame_args_test.h" 8 #include "cc/test/begin_frame_args_test.h"
9 #include "testing/gtest/include/gtest/gtest-spi.h" 9 #include "testing/gtest/include/gtest/gtest-spi.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 namespace cc { 12 namespace cc {
13 namespace { 13 namespace {
14 14
15 TEST(BeginFrameArgsTest, Helpers) { 15 TEST(BeginFrameArgsTest, Helpers) {
16 // Quick create methods work 16 // Quick create methods work
17 BeginFrameArgs args0 = CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); 17 BeginFrameArgs args0 =
18 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1);
18 EXPECT_TRUE(args0.IsValid()) << args0; 19 EXPECT_TRUE(args0.IsValid()) << args0;
19 20
20 BeginFrameArgs args1 = 21 BeginFrameArgs args1 =
21 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 0, -1); 22 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1, 0, 0, -1);
22 EXPECT_FALSE(args1.IsValid()) << args1; 23 EXPECT_FALSE(args1.IsValid()) << args1;
23 24
24 BeginFrameArgs args2 = 25 BeginFrameArgs args2 =
25 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 1, 2, 3); 26 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 123, 10, 1, 2, 3);
26 EXPECT_TRUE(args2.IsValid()) << args2; 27 EXPECT_TRUE(args2.IsValid()) << args2;
28 EXPECT_EQ(123u, args2.source_id);
29 EXPECT_EQ(10u, args2.sequence_number);
27 EXPECT_EQ(1, args2.frame_time.ToInternalValue()); 30 EXPECT_EQ(1, args2.frame_time.ToInternalValue());
28 EXPECT_EQ(2, args2.deadline.ToInternalValue()); 31 EXPECT_EQ(2, args2.deadline.ToInternalValue());
29 EXPECT_EQ(3, args2.interval.ToInternalValue()); 32 EXPECT_EQ(3, args2.interval.ToInternalValue());
30 EXPECT_EQ(BeginFrameArgs::NORMAL, args2.type); 33 EXPECT_EQ(BeginFrameArgs::NORMAL, args2.type);
31 34
32 BeginFrameArgs args4 = CreateBeginFrameArgsForTesting( 35 BeginFrameArgs args4 = CreateBeginFrameArgsForTesting(
33 BEGINFRAME_FROM_HERE, 1, 2, 3, BeginFrameArgs::MISSED); 36 BEGINFRAME_FROM_HERE, 234, 20, 1, 2, 3, BeginFrameArgs::MISSED);
34 EXPECT_TRUE(args4.IsValid()) << args4; 37 EXPECT_TRUE(args4.IsValid()) << args4;
38 EXPECT_EQ(234u, args4.source_id);
39 EXPECT_EQ(20u, args4.sequence_number);
35 EXPECT_EQ(1, args4.frame_time.ToInternalValue()); 40 EXPECT_EQ(1, args4.frame_time.ToInternalValue());
36 EXPECT_EQ(2, args4.deadline.ToInternalValue()); 41 EXPECT_EQ(2, args4.deadline.ToInternalValue());
37 EXPECT_EQ(3, args4.interval.ToInternalValue()); 42 EXPECT_EQ(3, args4.interval.ToInternalValue());
38 EXPECT_EQ(BeginFrameArgs::MISSED, args4.type); 43 EXPECT_EQ(BeginFrameArgs::MISSED, args4.type);
39 44
40 // operator== 45 // operator==
41 EXPECT_EQ(CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 4, 5, 6), 46 EXPECT_EQ(
42 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 4, 5, 6)); 47 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 123, 20, 4, 5, 6),
48 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 123, 20, 4, 5, 6));
43 49
44 EXPECT_NONFATAL_FAILURE( 50 EXPECT_NONFATAL_FAILURE(
45 EXPECT_EQ(CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 7, 8, 9, 51 EXPECT_EQ(CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 123, 30, 7,
46 BeginFrameArgs::MISSED), 52 8, 9, BeginFrameArgs::MISSED),
47 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 7, 8, 9)), 53 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 123, 30, 7,
54 8, 9)),
48 ""); 55 "");
49 56
50 EXPECT_NONFATAL_FAILURE( 57 EXPECT_NONFATAL_FAILURE(
51 EXPECT_EQ(CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 4, 5, 6), 58 EXPECT_EQ(CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 123, 30, 4,
52 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 7, 8, 9)), 59 5, 6),
60 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 123, 30, 7,
61 8, 9)),
62 "");
63
64 EXPECT_NONFATAL_FAILURE(
65 EXPECT_EQ(CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 123, 30, 7,
66 8, 9),
67 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 123, 40, 7,
68 8, 9)),
69 "");
70
71 EXPECT_NONFATAL_FAILURE(
72 EXPECT_EQ(CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 123, 30, 7,
73 8, 9),
74 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 234, 30, 7,
75 8, 9)),
53 ""); 76 "");
54 77
55 // operator<< 78 // operator<<
56 std::stringstream out1; 79 std::stringstream out1;
57 out1 << args1; 80 out1 << args1;
58 EXPECT_EQ("BeginFrameArgs(NORMAL, 0, 0, -1us)", out1.str()); 81 EXPECT_EQ("BeginFrameArgs(NORMAL, 0, 1, 0, 0, -1us)", out1.str());
59 std::stringstream out2; 82 std::stringstream out2;
60 out2 << args2; 83 out2 << args2;
61 EXPECT_EQ("BeginFrameArgs(NORMAL, 1, 2, 3us)", out2.str()); 84 EXPECT_EQ("BeginFrameArgs(NORMAL, 123, 10, 1, 2, 3us)", out2.str());
62 85
63 // PrintTo 86 // PrintTo
64 EXPECT_EQ(std::string("BeginFrameArgs(NORMAL, 0, 0, -1us)"), 87 EXPECT_EQ(std::string("BeginFrameArgs(NORMAL, 0, 1, 0, 0, -1us)"),
65 ::testing::PrintToString(args1)); 88 ::testing::PrintToString(args1));
66 EXPECT_EQ(std::string("BeginFrameArgs(NORMAL, 1, 2, 3us)"), 89 EXPECT_EQ(std::string("BeginFrameArgs(NORMAL, 123, 10, 1, 2, 3us)"),
67 ::testing::PrintToString(args2)); 90 ::testing::PrintToString(args2));
68 } 91 }
69 92
70 TEST(BeginFrameArgsTest, Create) { 93 TEST(BeginFrameArgsTest, Create) {
71 // BeginFrames are not valid by default 94 // BeginFrames are not valid by default
72 BeginFrameArgs args1; 95 BeginFrameArgs args1;
73 EXPECT_FALSE(args1.IsValid()) << args1; 96 EXPECT_FALSE(args1.IsValid()) << args1;
74 EXPECT_TRUE(args1.on_critical_path); 97 EXPECT_TRUE(args1.on_critical_path);
75 98
76 BeginFrameArgs args2 = BeginFrameArgs::Create( 99 BeginFrameArgs args2 = BeginFrameArgs::Create(
77 BEGINFRAME_FROM_HERE, base::TimeTicks::FromInternalValue(1), 100 BEGINFRAME_FROM_HERE, 123, 10, base::TimeTicks::FromInternalValue(1),
78 base::TimeTicks::FromInternalValue(2), 101 base::TimeTicks::FromInternalValue(2),
79 base::TimeDelta::FromInternalValue(3), BeginFrameArgs::NORMAL); 102 base::TimeDelta::FromInternalValue(3), BeginFrameArgs::NORMAL);
80 EXPECT_TRUE(args2.IsValid()) << args2; 103 EXPECT_TRUE(args2.IsValid()) << args2;
104 EXPECT_EQ(123u, args2.source_id) << args2;
105 EXPECT_EQ(10u, args2.sequence_number) << args2;
81 EXPECT_EQ(1, args2.frame_time.ToInternalValue()) << args2; 106 EXPECT_EQ(1, args2.frame_time.ToInternalValue()) << args2;
82 EXPECT_EQ(2, args2.deadline.ToInternalValue()) << args2; 107 EXPECT_EQ(2, args2.deadline.ToInternalValue()) << args2;
83 EXPECT_EQ(3, args2.interval.ToInternalValue()) << args2; 108 EXPECT_EQ(3, args2.interval.ToInternalValue()) << args2;
84 EXPECT_EQ(BeginFrameArgs::NORMAL, args2.type) << args2; 109 EXPECT_EQ(BeginFrameArgs::NORMAL, args2.type) << args2;
85 } 110 }
86 111
87 #ifndef NDEBUG 112 #ifndef NDEBUG
88 TEST(BeginFrameArgsTest, Location) { 113 TEST(BeginFrameArgsTest, Location) {
89 tracked_objects::Location expected_location = BEGINFRAME_FROM_HERE; 114 tracked_objects::Location expected_location = BEGINFRAME_FROM_HERE;
90 115
91 BeginFrameArgs args = CreateBeginFrameArgsForTesting(expected_location); 116 BeginFrameArgs args = CreateBeginFrameArgsForTesting(expected_location, 0, 1);
92 EXPECT_EQ(expected_location.ToString(), args.created_from.ToString()); 117 EXPECT_EQ(expected_location.ToString(), args.created_from.ToString());
93 } 118 }
94 #endif 119 #endif
95 120
96 } // namespace 121 } // namespace
97 } // namespace cc 122 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/begin_frame_args.cc ('k') | cc/output/compositor_frame_metadata.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698