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

Side by Side Diff: cc/debug/frame_timing_tracker_unittest.cc

Issue 1152153003: [WIP] cc: Plumb frame timing info without using a commit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <set> 5 #include <set>
6 #include <string> 6 #include <string>
7 7
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "base/trace_event/trace_event_argument.h" 9 #include "base/trace_event/trace_event_argument.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "cc/debug/frame_timing_tracker.h" 11 #include "cc/debug/frame_timing_tracker.h"
12 #include "cc/test/fake_impl_proxy.h"
13 #include "cc/test/fake_layer_tree_host_impl.h"
14 #include "cc/test/test_shared_bitmap_manager.h"
12 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
13 16
14 namespace cc { 17 namespace cc {
15 namespace { 18 namespace {
16 19
17 std::string CompositeToString( 20 std::string CompositeToString(
18 scoped_ptr<FrameTimingTracker::CompositeTimingSet> timingset) { 21 scoped_ptr<FrameTimingTracker::CompositeTimingSet> timingset) {
19 scoped_refptr<base::trace_event::TracedValue> value = 22 scoped_refptr<base::trace_event::TracedValue> value =
20 new base::trace_event::TracedValue(); 23 new base::trace_event::TracedValue();
21 value->BeginArray("values"); 24 value->BeginArray("values");
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 value->EndDictionary(); 66 value->EndDictionary();
64 } 67 }
65 value->EndArray(); 68 value->EndArray();
66 value->EndDictionary(); 69 value->EndDictionary();
67 } 70 }
68 value->EndArray(); 71 value->EndArray();
69 return value->ToString(); 72 return value->ToString();
70 } 73 }
71 74
72 TEST(FrameTimingTrackerTest, DefaultTrackerIsEmpty) { 75 TEST(FrameTimingTrackerTest, DefaultTrackerIsEmpty) {
73 scoped_ptr<FrameTimingTracker> tracker(FrameTimingTracker::Create()); 76 FakeImplProxy proxy;
77 TestSharedBitmapManager shared_bitmap_manager;
78 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
79
80 scoped_ptr<FrameTimingTracker> tracker(
81 FrameTimingTracker::Create(&host_impl));
74 EXPECT_EQ("{\"values\":[]}", 82 EXPECT_EQ("{\"values\":[]}",
75 CompositeToString(tracker->GroupCompositeCountsByRectId())); 83 CompositeToString(tracker->GroupCompositeCountsByRectId()));
76 EXPECT_EQ("{\"values\":[]}", 84 EXPECT_EQ("{\"values\":[]}",
77 MainFrameToString(tracker->GroupMainFrameCountsByRectId())); 85 MainFrameToString(tracker->GroupMainFrameCountsByRectId()));
78 } 86 }
79 87
80 TEST(FrameTimingTrackerTest, NoFrameIdsIsEmpty) { 88 TEST(FrameTimingTrackerTest, NoFrameIdsIsEmpty) {
81 scoped_ptr<FrameTimingTracker> tracker(FrameTimingTracker::Create()); 89 FakeImplProxy proxy;
90 TestSharedBitmapManager shared_bitmap_manager;
91 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
92
93 scoped_ptr<FrameTimingTracker> tracker(
94 FrameTimingTracker::Create(&host_impl));
82 std::vector<std::pair<int, int64_t>> ids; 95 std::vector<std::pair<int, int64_t>> ids;
83 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(100), ids); 96 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(100), ids);
84 EXPECT_EQ("{\"values\":[]}", 97 EXPECT_EQ("{\"values\":[]}",
85 CompositeToString(tracker->GroupCompositeCountsByRectId())); 98 CompositeToString(tracker->GroupCompositeCountsByRectId()));
86 } 99 }
87 100
88 TEST(FrameTimingTrackerTest, NoRectIdsYieldsNoMainFrameEvents) { 101 TEST(FrameTimingTrackerTest, NoRectIdsYieldsNoMainFrameEvents) {
89 scoped_ptr<FrameTimingTracker> tracker(FrameTimingTracker::Create()); 102 FakeImplProxy proxy;
103 TestSharedBitmapManager shared_bitmap_manager;
104 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
105
106 scoped_ptr<FrameTimingTracker> tracker(
107 FrameTimingTracker::Create(&host_impl));
90 tracker->SaveMainFrameTimeStamps(std::vector<int64_t>(), 108 tracker->SaveMainFrameTimeStamps(std::vector<int64_t>(),
91 base::TimeTicks::FromInternalValue(100), 109 base::TimeTicks::FromInternalValue(100),
92 base::TimeTicks::FromInternalValue(110), 1); 110 base::TimeTicks::FromInternalValue(110), 1);
93 EXPECT_EQ("{\"values\":[]}", 111 EXPECT_EQ("{\"values\":[]}",
94 MainFrameToString(tracker->GroupMainFrameCountsByRectId())); 112 MainFrameToString(tracker->GroupMainFrameCountsByRectId()));
95 } 113 }
96 114
97 TEST(FrameTimingTrackerTest, OneFrameId) { 115 TEST(FrameTimingTrackerTest, OneFrameId) {
98 scoped_ptr<FrameTimingTracker> tracker(FrameTimingTracker::Create()); 116 FakeImplProxy proxy;
117 TestSharedBitmapManager shared_bitmap_manager;
118 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
119
120 scoped_ptr<FrameTimingTracker> tracker(
121 FrameTimingTracker::Create(&host_impl));
99 std::vector<std::pair<int, int64_t>> ids; 122 std::vector<std::pair<int, int64_t>> ids;
100 ids.push_back(std::make_pair(1, 2)); 123 ids.push_back(std::make_pair(1, 2));
101 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(100), ids); 124 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(100), ids);
102 EXPECT_EQ( 125 EXPECT_EQ(
103 "{\"values\":[{\"events\":[" 126 "{\"values\":[{\"events\":["
104 "{\"frame_id\":1,\"timestamp\":100}],\"rect_id\":2}]}", 127 "{\"frame_id\":1,\"timestamp\":100}],\"rect_id\":2}]}",
105 CompositeToString(tracker->GroupCompositeCountsByRectId())); 128 CompositeToString(tracker->GroupCompositeCountsByRectId()));
106 } 129 }
107 130
108 TEST(FrameTimingTrackerTest, OneMainFrameRect) { 131 TEST(FrameTimingTrackerTest, OneMainFrameRect) {
109 scoped_ptr<FrameTimingTracker> tracker(FrameTimingTracker::Create()); 132 FakeImplProxy proxy;
133 TestSharedBitmapManager shared_bitmap_manager;
134 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
135
136 scoped_ptr<FrameTimingTracker> tracker(
137 FrameTimingTracker::Create(&host_impl));
110 std::vector<int64_t> rect_ids; 138 std::vector<int64_t> rect_ids;
111 rect_ids.push_back(1); 139 rect_ids.push_back(1);
112 tracker->SaveMainFrameTimeStamps(rect_ids, 140 tracker->SaveMainFrameTimeStamps(rect_ids,
113 base::TimeTicks::FromInternalValue(100), 141 base::TimeTicks::FromInternalValue(100),
114 base::TimeTicks::FromInternalValue(110), 2); 142 base::TimeTicks::FromInternalValue(110), 2);
115 EXPECT_EQ( 143 EXPECT_EQ(
116 "{\"values\":[{\"events\":[" 144 "{\"values\":[{\"events\":["
117 "{\"end_time\":110,\"frame_id\":2,\"timestamp\":100}],\"rect_id\":1}]}", 145 "{\"end_time\":110,\"frame_id\":2,\"timestamp\":100}],\"rect_id\":1}]}",
118 MainFrameToString(tracker->GroupMainFrameCountsByRectId())); 146 MainFrameToString(tracker->GroupMainFrameCountsByRectId()));
119 } 147 }
120 148
121 TEST(FrameTimingTrackerTest, UnsortedTimestampsIds) { 149 TEST(FrameTimingTrackerTest, UnsortedTimestampsIds) {
122 scoped_ptr<FrameTimingTracker> tracker(FrameTimingTracker::Create()); 150 FakeImplProxy proxy;
151 TestSharedBitmapManager shared_bitmap_manager;
152 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
153
154 scoped_ptr<FrameTimingTracker> tracker(
155 FrameTimingTracker::Create(&host_impl));
123 std::vector<std::pair<int, int64_t>> ids; 156 std::vector<std::pair<int, int64_t>> ids;
124 ids.push_back(std::make_pair(1, 2)); 157 ids.push_back(std::make_pair(1, 2));
125 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(200), ids); 158 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(200), ids);
126 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(400), ids); 159 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(400), ids);
127 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(100), ids); 160 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(100), ids);
128 EXPECT_EQ( 161 EXPECT_EQ(
129 "{\"values\":[{\"events\":[" 162 "{\"values\":[{\"events\":["
130 "{\"frame_id\":1,\"timestamp\":100}," 163 "{\"frame_id\":1,\"timestamp\":100},"
131 "{\"frame_id\":1,\"timestamp\":200}," 164 "{\"frame_id\":1,\"timestamp\":200},"
132 "{\"frame_id\":1,\"timestamp\":400}],\"rect_id\":2}]}", 165 "{\"frame_id\":1,\"timestamp\":400}],\"rect_id\":2}]}",
133 CompositeToString(tracker->GroupCompositeCountsByRectId())); 166 CompositeToString(tracker->GroupCompositeCountsByRectId()));
134 } 167 }
135 168
136 TEST(FrameTimingTrackerTest, MainFrameUnsortedTimestamps) { 169 TEST(FrameTimingTrackerTest, MainFrameUnsortedTimestamps) {
137 scoped_ptr<FrameTimingTracker> tracker(FrameTimingTracker::Create()); 170 FakeImplProxy proxy;
171 TestSharedBitmapManager shared_bitmap_manager;
172 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
173
174 scoped_ptr<FrameTimingTracker> tracker(
175 FrameTimingTracker::Create(&host_impl));
138 std::vector<int64_t> rect_ids; 176 std::vector<int64_t> rect_ids;
139 rect_ids.push_back(2); 177 rect_ids.push_back(2);
140 tracker->SaveMainFrameTimeStamps(rect_ids, 178 tracker->SaveMainFrameTimeStamps(rect_ids,
141 base::TimeTicks::FromInternalValue(200), 179 base::TimeTicks::FromInternalValue(200),
142 base::TimeTicks::FromInternalValue(280), 1); 180 base::TimeTicks::FromInternalValue(280), 1);
143 tracker->SaveMainFrameTimeStamps(rect_ids, 181 tracker->SaveMainFrameTimeStamps(rect_ids,
144 base::TimeTicks::FromInternalValue(400), 182 base::TimeTicks::FromInternalValue(400),
145 base::TimeTicks::FromInternalValue(470), 1); 183 base::TimeTicks::FromInternalValue(470), 1);
146 tracker->SaveMainFrameTimeStamps(rect_ids, 184 tracker->SaveMainFrameTimeStamps(rect_ids,
147 base::TimeTicks::FromInternalValue(100), 185 base::TimeTicks::FromInternalValue(100),
148 base::TimeTicks::FromInternalValue(160), 1); 186 base::TimeTicks::FromInternalValue(160), 1);
149 EXPECT_EQ( 187 EXPECT_EQ(
150 "{\"values\":[{\"events\":[" 188 "{\"values\":[{\"events\":["
151 "{\"end_time\":160,\"frame_id\":1,\"timestamp\":100}," 189 "{\"end_time\":160,\"frame_id\":1,\"timestamp\":100},"
152 "{\"end_time\":280,\"frame_id\":1,\"timestamp\":200}," 190 "{\"end_time\":280,\"frame_id\":1,\"timestamp\":200},"
153 "{\"end_time\":470,\"frame_id\":1,\"timestamp\":400}],\"rect_id\":2}]}", 191 "{\"end_time\":470,\"frame_id\":1,\"timestamp\":400}],\"rect_id\":2}]}",
154 MainFrameToString(tracker->GroupMainFrameCountsByRectId())); 192 MainFrameToString(tracker->GroupMainFrameCountsByRectId()));
155 } 193 }
156 194
157 TEST(FrameTimingTrackerTest, MultipleFrameIds) { 195 TEST(FrameTimingTrackerTest, MultipleFrameIds) {
158 scoped_ptr<FrameTimingTracker> tracker(FrameTimingTracker::Create()); 196 FakeImplProxy proxy;
197 TestSharedBitmapManager shared_bitmap_manager;
198 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
199
200 scoped_ptr<FrameTimingTracker> tracker(
201 FrameTimingTracker::Create(&host_impl));
159 202
160 std::vector<std::pair<int, int64_t>> ids200; 203 std::vector<std::pair<int, int64_t>> ids200;
161 ids200.push_back(std::make_pair(1, 2)); 204 ids200.push_back(std::make_pair(1, 2));
162 ids200.push_back(std::make_pair(1, 3)); 205 ids200.push_back(std::make_pair(1, 3));
163 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(200), ids200); 206 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(200), ids200);
164 207
165 std::vector<std::pair<int, int64_t>> ids400; 208 std::vector<std::pair<int, int64_t>> ids400;
166 ids400.push_back(std::make_pair(2, 2)); 209 ids400.push_back(std::make_pair(2, 2));
167 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(400), ids400); 210 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(400), ids400);
168 211
(...skipping 11 matching lines...) Expand all
180 "{\"events\":[" 223 "{\"events\":["
181 "{\"frame_id\":2,\"timestamp\":100}," 224 "{\"frame_id\":2,\"timestamp\":100},"
182 "{\"frame_id\":1,\"timestamp\":200}],\"rect_id\":3}," 225 "{\"frame_id\":1,\"timestamp\":200}],\"rect_id\":3},"
183 "{\"events\":[" 226 "{\"events\":["
184 "{\"frame_id\":3,\"timestamp\":100}],\"rect_id\":4}" 227 "{\"frame_id\":3,\"timestamp\":100}],\"rect_id\":4}"
185 "]}", 228 "]}",
186 CompositeToString(tracker->GroupCompositeCountsByRectId())); 229 CompositeToString(tracker->GroupCompositeCountsByRectId()));
187 } 230 }
188 231
189 TEST(FrameTimingTrackerTest, MultipleMainFrameEvents) { 232 TEST(FrameTimingTrackerTest, MultipleMainFrameEvents) {
190 scoped_ptr<FrameTimingTracker> tracker(FrameTimingTracker::Create()); 233 FakeImplProxy proxy;
234 TestSharedBitmapManager shared_bitmap_manager;
235 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, nullptr);
236
237 scoped_ptr<FrameTimingTracker> tracker(
238 FrameTimingTracker::Create(&host_impl));
191 239
192 std::vector<int64_t> rect_ids200; 240 std::vector<int64_t> rect_ids200;
193 rect_ids200.push_back(2); 241 rect_ids200.push_back(2);
194 rect_ids200.push_back(3); 242 rect_ids200.push_back(3);
195 tracker->SaveMainFrameTimeStamps(rect_ids200, 243 tracker->SaveMainFrameTimeStamps(rect_ids200,
196 base::TimeTicks::FromInternalValue(200), 244 base::TimeTicks::FromInternalValue(200),
197 base::TimeTicks::FromInternalValue(220), 1); 245 base::TimeTicks::FromInternalValue(220), 1);
198 246
199 std::vector<int64_t> rect_ids400; 247 std::vector<int64_t> rect_ids400;
200 rect_ids400.push_back(2); 248 rect_ids400.push_back(2);
(...skipping 18 matching lines...) Expand all
219 "{\"end_time\":110,\"frame_id\":3,\"timestamp\":100}," 267 "{\"end_time\":110,\"frame_id\":3,\"timestamp\":100},"
220 "{\"end_time\":220,\"frame_id\":1,\"timestamp\":200}],\"rect_id\":3}," 268 "{\"end_time\":220,\"frame_id\":1,\"timestamp\":200}],\"rect_id\":3},"
221 "{\"events\":[" 269 "{\"events\":["
222 "{\"end_time\":110,\"frame_id\":3,\"timestamp\":100}],\"rect_id\":4}" 270 "{\"end_time\":110,\"frame_id\":3,\"timestamp\":100}],\"rect_id\":4}"
223 "]}", 271 "]}",
224 MainFrameToString(tracker->GroupMainFrameCountsByRectId())); 272 MainFrameToString(tracker->GroupMainFrameCountsByRectId()));
225 } 273 }
226 274
227 } // namespace 275 } // namespace
228 } // namespace cc 276 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698