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

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

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

Powered by Google App Engine
This is Rietveld 408576698