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

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

Issue 1411663002: cc: Split Proxy to eliminate unnecessary dependencies on the impl side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update perf tests. Created 5 years, 2 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
« no previous file with comments | « cc/debug/frame_timing_tracker.cc ('k') | cc/debug/micro_benchmark_controller_unittest.cc » ('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 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" 12 #include "cc/test/fake_impl_task_runner_provider.h"
13 #include "cc/test/fake_layer_tree_host_impl.h" 13 #include "cc/test/fake_layer_tree_host_impl.h"
14 #include "cc/test/test_shared_bitmap_manager.h" 14 #include "cc/test/test_shared_bitmap_manager.h"
15 #include "cc/test/test_task_graph_runner.h" 15 #include "cc/test/test_task_graph_runner.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 namespace cc { 18 namespace cc {
19 namespace { 19 namespace {
20 20
21 std::string CompositeToString( 21 std::string CompositeToString(
22 scoped_ptr<FrameTimingTracker::CompositeTimingSet> timingset) { 22 scoped_ptr<FrameTimingTracker::CompositeTimingSet> timingset) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 value->EndDictionary(); 67 value->EndDictionary();
68 } 68 }
69 value->EndArray(); 69 value->EndArray();
70 value->EndDictionary(); 70 value->EndDictionary();
71 } 71 }
72 value->EndArray(); 72 value->EndArray();
73 return value->ToString(); 73 return value->ToString();
74 } 74 }
75 75
76 TEST(FrameTimingTrackerTest, DefaultTrackerIsEmpty) { 76 TEST(FrameTimingTrackerTest, DefaultTrackerIsEmpty) {
77 FakeImplProxy proxy; 77 FakeImplTaskRunnerProvider task_runner_provider;
78 TestSharedBitmapManager shared_bitmap_manager; 78 TestSharedBitmapManager shared_bitmap_manager;
79 TestTaskGraphRunner task_graph_runner; 79 TestTaskGraphRunner task_graph_runner;
80 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, 80 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
81 &task_graph_runner); 81 &task_graph_runner);
82 82
83 scoped_ptr<FrameTimingTracker> tracker( 83 scoped_ptr<FrameTimingTracker> tracker(
84 FrameTimingTracker::Create(&host_impl)); 84 FrameTimingTracker::Create(&host_impl));
85 EXPECT_EQ("{\"values\":[]}", 85 EXPECT_EQ("{\"values\":[]}",
86 CompositeToString(tracker->GroupCompositeCountsByRectId())); 86 CompositeToString(tracker->GroupCompositeCountsByRectId()));
87 EXPECT_EQ("{\"values\":[]}", 87 EXPECT_EQ("{\"values\":[]}",
88 MainFrameToString(tracker->GroupMainFrameCountsByRectId())); 88 MainFrameToString(tracker->GroupMainFrameCountsByRectId()));
89 } 89 }
90 90
91 TEST(FrameTimingTrackerTest, NoFrameIdsIsEmpty) { 91 TEST(FrameTimingTrackerTest, NoFrameIdsIsEmpty) {
92 FakeImplProxy proxy; 92 FakeImplTaskRunnerProvider task_runner_provider;
93 TestSharedBitmapManager shared_bitmap_manager; 93 TestSharedBitmapManager shared_bitmap_manager;
94 TestTaskGraphRunner task_graph_runner; 94 TestTaskGraphRunner task_graph_runner;
95 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, 95 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
96 &task_graph_runner); 96 &task_graph_runner);
97 97
98 scoped_ptr<FrameTimingTracker> tracker( 98 scoped_ptr<FrameTimingTracker> tracker(
99 FrameTimingTracker::Create(&host_impl)); 99 FrameTimingTracker::Create(&host_impl));
100 std::vector<std::pair<int, int64_t>> ids; 100 std::vector<std::pair<int, int64_t>> ids;
101 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(100), ids); 101 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(100), ids);
102 EXPECT_EQ("{\"values\":[]}", 102 EXPECT_EQ("{\"values\":[]}",
103 CompositeToString(tracker->GroupCompositeCountsByRectId())); 103 CompositeToString(tracker->GroupCompositeCountsByRectId()));
104 } 104 }
105 105
106 TEST(FrameTimingTrackerTest, NoRectIdsYieldsNoMainFrameEvents) { 106 TEST(FrameTimingTrackerTest, NoRectIdsYieldsNoMainFrameEvents) {
107 FakeImplProxy proxy; 107 FakeImplTaskRunnerProvider task_runner_provider;
108 TestSharedBitmapManager shared_bitmap_manager; 108 TestSharedBitmapManager shared_bitmap_manager;
109 TestTaskGraphRunner task_graph_runner; 109 TestTaskGraphRunner task_graph_runner;
110 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, 110 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
111 &task_graph_runner); 111 &task_graph_runner);
112 112
113 scoped_ptr<FrameTimingTracker> tracker( 113 scoped_ptr<FrameTimingTracker> tracker(
114 FrameTimingTracker::Create(&host_impl)); 114 FrameTimingTracker::Create(&host_impl));
115 tracker->SaveMainFrameTimeStamps(std::vector<int64_t>(), 115 tracker->SaveMainFrameTimeStamps(std::vector<int64_t>(),
116 base::TimeTicks::FromInternalValue(100), 116 base::TimeTicks::FromInternalValue(100),
117 base::TimeTicks::FromInternalValue(110), 1); 117 base::TimeTicks::FromInternalValue(110), 1);
118 EXPECT_EQ("{\"values\":[]}", 118 EXPECT_EQ("{\"values\":[]}",
119 MainFrameToString(tracker->GroupMainFrameCountsByRectId())); 119 MainFrameToString(tracker->GroupMainFrameCountsByRectId()));
120 } 120 }
121 121
122 TEST(FrameTimingTrackerTest, OneFrameId) { 122 TEST(FrameTimingTrackerTest, OneFrameId) {
123 FakeImplProxy proxy; 123 FakeImplTaskRunnerProvider task_runner_provider;
124 TestSharedBitmapManager shared_bitmap_manager; 124 TestSharedBitmapManager shared_bitmap_manager;
125 TestTaskGraphRunner task_graph_runner; 125 TestTaskGraphRunner task_graph_runner;
126 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, 126 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
127 &task_graph_runner); 127 &task_graph_runner);
128 128
129 scoped_ptr<FrameTimingTracker> tracker( 129 scoped_ptr<FrameTimingTracker> tracker(
130 FrameTimingTracker::Create(&host_impl)); 130 FrameTimingTracker::Create(&host_impl));
131 std::vector<std::pair<int, int64_t>> ids; 131 std::vector<std::pair<int, int64_t>> ids;
132 ids.push_back(std::make_pair(1, 2)); 132 ids.push_back(std::make_pair(1, 2));
133 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(100), ids); 133 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(100), ids);
134 EXPECT_EQ( 134 EXPECT_EQ(
135 "{\"values\":[{\"events\":[" 135 "{\"values\":[{\"events\":["
136 "{\"frame_id\":1,\"timestamp\":100}],\"rect_id\":2}]}", 136 "{\"frame_id\":1,\"timestamp\":100}],\"rect_id\":2}]}",
137 CompositeToString(tracker->GroupCompositeCountsByRectId())); 137 CompositeToString(tracker->GroupCompositeCountsByRectId()));
138 } 138 }
139 139
140 TEST(FrameTimingTrackerTest, OneMainFrameRect) { 140 TEST(FrameTimingTrackerTest, OneMainFrameRect) {
141 FakeImplProxy proxy; 141 FakeImplTaskRunnerProvider task_runner_provider;
142 TestSharedBitmapManager shared_bitmap_manager; 142 TestSharedBitmapManager shared_bitmap_manager;
143 TestTaskGraphRunner task_graph_runner; 143 TestTaskGraphRunner task_graph_runner;
144 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, 144 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
145 &task_graph_runner); 145 &task_graph_runner);
146 146
147 scoped_ptr<FrameTimingTracker> tracker( 147 scoped_ptr<FrameTimingTracker> tracker(
148 FrameTimingTracker::Create(&host_impl)); 148 FrameTimingTracker::Create(&host_impl));
149 std::vector<int64_t> rect_ids; 149 std::vector<int64_t> rect_ids;
150 rect_ids.push_back(1); 150 rect_ids.push_back(1);
151 tracker->SaveMainFrameTimeStamps(rect_ids, 151 tracker->SaveMainFrameTimeStamps(rect_ids,
152 base::TimeTicks::FromInternalValue(100), 152 base::TimeTicks::FromInternalValue(100),
153 base::TimeTicks::FromInternalValue(110), 2); 153 base::TimeTicks::FromInternalValue(110), 2);
154 EXPECT_EQ( 154 EXPECT_EQ(
155 "{\"values\":[{\"events\":[" 155 "{\"values\":[{\"events\":["
156 "{\"end_time\":110,\"frame_id\":2,\"timestamp\":100}],\"rect_id\":1}]}", 156 "{\"end_time\":110,\"frame_id\":2,\"timestamp\":100}],\"rect_id\":1}]}",
157 MainFrameToString(tracker->GroupMainFrameCountsByRectId())); 157 MainFrameToString(tracker->GroupMainFrameCountsByRectId()));
158 } 158 }
159 159
160 TEST(FrameTimingTrackerTest, UnsortedTimestampsIds) { 160 TEST(FrameTimingTrackerTest, UnsortedTimestampsIds) {
161 FakeImplProxy proxy; 161 FakeImplTaskRunnerProvider task_runner_provider;
162 TestSharedBitmapManager shared_bitmap_manager; 162 TestSharedBitmapManager shared_bitmap_manager;
163 TestTaskGraphRunner task_graph_runner; 163 TestTaskGraphRunner task_graph_runner;
164 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, 164 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
165 &task_graph_runner); 165 &task_graph_runner);
166 166
167 scoped_ptr<FrameTimingTracker> tracker( 167 scoped_ptr<FrameTimingTracker> tracker(
168 FrameTimingTracker::Create(&host_impl)); 168 FrameTimingTracker::Create(&host_impl));
169 std::vector<std::pair<int, int64_t>> ids; 169 std::vector<std::pair<int, int64_t>> ids;
170 ids.push_back(std::make_pair(1, 2)); 170 ids.push_back(std::make_pair(1, 2));
171 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(200), ids); 171 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(200), ids);
172 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(400), ids); 172 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(400), ids);
173 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(100), ids); 173 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(100), ids);
174 EXPECT_EQ( 174 EXPECT_EQ(
175 "{\"values\":[{\"events\":[" 175 "{\"values\":[{\"events\":["
176 "{\"frame_id\":1,\"timestamp\":100}," 176 "{\"frame_id\":1,\"timestamp\":100},"
177 "{\"frame_id\":1,\"timestamp\":200}," 177 "{\"frame_id\":1,\"timestamp\":200},"
178 "{\"frame_id\":1,\"timestamp\":400}],\"rect_id\":2}]}", 178 "{\"frame_id\":1,\"timestamp\":400}],\"rect_id\":2}]}",
179 CompositeToString(tracker->GroupCompositeCountsByRectId())); 179 CompositeToString(tracker->GroupCompositeCountsByRectId()));
180 } 180 }
181 181
182 TEST(FrameTimingTrackerTest, MainFrameUnsortedTimestamps) { 182 TEST(FrameTimingTrackerTest, MainFrameUnsortedTimestamps) {
183 FakeImplProxy proxy; 183 FakeImplTaskRunnerProvider task_runner_provider;
184 TestSharedBitmapManager shared_bitmap_manager; 184 TestSharedBitmapManager shared_bitmap_manager;
185 TestTaskGraphRunner task_graph_runner; 185 TestTaskGraphRunner task_graph_runner;
186 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, 186 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
187 &task_graph_runner); 187 &task_graph_runner);
188 188
189 scoped_ptr<FrameTimingTracker> tracker( 189 scoped_ptr<FrameTimingTracker> tracker(
190 FrameTimingTracker::Create(&host_impl)); 190 FrameTimingTracker::Create(&host_impl));
191 std::vector<int64_t> rect_ids; 191 std::vector<int64_t> rect_ids;
192 rect_ids.push_back(2); 192 rect_ids.push_back(2);
193 tracker->SaveMainFrameTimeStamps(rect_ids, 193 tracker->SaveMainFrameTimeStamps(rect_ids,
194 base::TimeTicks::FromInternalValue(200), 194 base::TimeTicks::FromInternalValue(200),
195 base::TimeTicks::FromInternalValue(280), 1); 195 base::TimeTicks::FromInternalValue(280), 1);
196 tracker->SaveMainFrameTimeStamps(rect_ids, 196 tracker->SaveMainFrameTimeStamps(rect_ids,
197 base::TimeTicks::FromInternalValue(400), 197 base::TimeTicks::FromInternalValue(400),
198 base::TimeTicks::FromInternalValue(470), 1); 198 base::TimeTicks::FromInternalValue(470), 1);
199 tracker->SaveMainFrameTimeStamps(rect_ids, 199 tracker->SaveMainFrameTimeStamps(rect_ids,
200 base::TimeTicks::FromInternalValue(100), 200 base::TimeTicks::FromInternalValue(100),
201 base::TimeTicks::FromInternalValue(160), 1); 201 base::TimeTicks::FromInternalValue(160), 1);
202 EXPECT_EQ( 202 EXPECT_EQ(
203 "{\"values\":[{\"events\":[" 203 "{\"values\":[{\"events\":["
204 "{\"end_time\":160,\"frame_id\":1,\"timestamp\":100}," 204 "{\"end_time\":160,\"frame_id\":1,\"timestamp\":100},"
205 "{\"end_time\":280,\"frame_id\":1,\"timestamp\":200}," 205 "{\"end_time\":280,\"frame_id\":1,\"timestamp\":200},"
206 "{\"end_time\":470,\"frame_id\":1,\"timestamp\":400}],\"rect_id\":2}]}", 206 "{\"end_time\":470,\"frame_id\":1,\"timestamp\":400}],\"rect_id\":2}]}",
207 MainFrameToString(tracker->GroupMainFrameCountsByRectId())); 207 MainFrameToString(tracker->GroupMainFrameCountsByRectId()));
208 } 208 }
209 209
210 TEST(FrameTimingTrackerTest, MultipleFrameIds) { 210 TEST(FrameTimingTrackerTest, MultipleFrameIds) {
211 FakeImplProxy proxy; 211 FakeImplTaskRunnerProvider task_runner_provider;
212 TestSharedBitmapManager shared_bitmap_manager; 212 TestSharedBitmapManager shared_bitmap_manager;
213 TestTaskGraphRunner task_graph_runner; 213 TestTaskGraphRunner task_graph_runner;
214 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, 214 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
215 &task_graph_runner); 215 &task_graph_runner);
216 216
217 scoped_ptr<FrameTimingTracker> tracker( 217 scoped_ptr<FrameTimingTracker> tracker(
218 FrameTimingTracker::Create(&host_impl)); 218 FrameTimingTracker::Create(&host_impl));
219 219
220 std::vector<std::pair<int, int64_t>> ids200; 220 std::vector<std::pair<int, int64_t>> ids200;
221 ids200.push_back(std::make_pair(1, 2)); 221 ids200.push_back(std::make_pair(1, 2));
222 ids200.push_back(std::make_pair(1, 3)); 222 ids200.push_back(std::make_pair(1, 3));
223 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(200), ids200); 223 tracker->SaveTimeStamps(base::TimeTicks::FromInternalValue(200), ids200);
224 224
(...skipping 15 matching lines...) Expand all
240 "{\"events\":[" 240 "{\"events\":["
241 "{\"frame_id\":2,\"timestamp\":100}," 241 "{\"frame_id\":2,\"timestamp\":100},"
242 "{\"frame_id\":1,\"timestamp\":200}],\"rect_id\":3}," 242 "{\"frame_id\":1,\"timestamp\":200}],\"rect_id\":3},"
243 "{\"events\":[" 243 "{\"events\":["
244 "{\"frame_id\":3,\"timestamp\":100}],\"rect_id\":4}" 244 "{\"frame_id\":3,\"timestamp\":100}],\"rect_id\":4}"
245 "]}", 245 "]}",
246 CompositeToString(tracker->GroupCompositeCountsByRectId())); 246 CompositeToString(tracker->GroupCompositeCountsByRectId()));
247 } 247 }
248 248
249 TEST(FrameTimingTrackerTest, MultipleMainFrameEvents) { 249 TEST(FrameTimingTrackerTest, MultipleMainFrameEvents) {
250 FakeImplProxy proxy; 250 FakeImplTaskRunnerProvider task_runner_provider;
251 TestSharedBitmapManager shared_bitmap_manager; 251 TestSharedBitmapManager shared_bitmap_manager;
252 TestTaskGraphRunner task_graph_runner; 252 TestTaskGraphRunner task_graph_runner;
253 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, 253 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
254 &task_graph_runner); 254 &task_graph_runner);
255 255
256 scoped_ptr<FrameTimingTracker> tracker( 256 scoped_ptr<FrameTimingTracker> tracker(
257 FrameTimingTracker::Create(&host_impl)); 257 FrameTimingTracker::Create(&host_impl));
258 258
259 std::vector<int64_t> rect_ids200; 259 std::vector<int64_t> rect_ids200;
260 rect_ids200.push_back(2); 260 rect_ids200.push_back(2);
261 rect_ids200.push_back(3); 261 rect_ids200.push_back(3);
262 tracker->SaveMainFrameTimeStamps(rect_ids200, 262 tracker->SaveMainFrameTimeStamps(rect_ids200,
263 base::TimeTicks::FromInternalValue(200), 263 base::TimeTicks::FromInternalValue(200),
(...skipping 22 matching lines...) Expand all
286 "{\"end_time\":110,\"frame_id\":3,\"timestamp\":100}," 286 "{\"end_time\":110,\"frame_id\":3,\"timestamp\":100},"
287 "{\"end_time\":220,\"frame_id\":1,\"timestamp\":200}],\"rect_id\":3}," 287 "{\"end_time\":220,\"frame_id\":1,\"timestamp\":200}],\"rect_id\":3},"
288 "{\"events\":[" 288 "{\"events\":["
289 "{\"end_time\":110,\"frame_id\":3,\"timestamp\":100}],\"rect_id\":4}" 289 "{\"end_time\":110,\"frame_id\":3,\"timestamp\":100}],\"rect_id\":4}"
290 "]}", 290 "]}",
291 MainFrameToString(tracker->GroupMainFrameCountsByRectId())); 291 MainFrameToString(tracker->GroupMainFrameCountsByRectId()));
292 } 292 }
293 293
294 } // namespace 294 } // namespace
295 } // namespace cc 295 } // namespace cc
OLDNEW
« no previous file with comments | « cc/debug/frame_timing_tracker.cc ('k') | cc/debug/micro_benchmark_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698