OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright 2016 The Chromium Authors. All rights reserved. | 3 Copyright 2016 The Chromium Authors. All rights reserved. |
4 Use of this source code is governed by a BSD-style license that can be | 4 Use of this source code is governed by a BSD-style license that can be |
5 found in the LICENSE file. | 5 found in the LICENSE file. |
6 --> | 6 --> |
7 | 7 |
8 <link rel="import" href="/tracing/base/iteration_helpers.html"> | 8 <link rel="import" href="/tracing/base/iteration_helpers.html"> |
| 9 <link rel="import" href="/tracing/base/math/range.html"> |
9 <link rel="import" href="/tracing/base/raf.html"> | 10 <link rel="import" href="/tracing/base/raf.html"> |
10 <link rel="import" href="/tracing/base/range.html"> | |
11 <link rel="import" href="/tracing/value/ui/scalar_context_controller.html"> | 11 <link rel="import" href="/tracing/value/ui/scalar_context_controller.html"> |
12 | 12 |
13 <dom-module id='tr-v-ui-scalar-context-controller-mock-host'> | 13 <dom-module id='tr-v-ui-scalar-context-controller-mock-host'> |
14 <template> | 14 <template> |
15 <tr-v-ui-scalar-context-controller id="controller"> | 15 <tr-v-ui-scalar-context-controller id="controller"> |
16 </tr-v-ui-scalar-context-controller> | 16 </tr-v-ui-scalar-context-controller> |
17 <content></content> | 17 <content></content> |
18 </template> | 18 </template> |
19 </dom-module> | 19 </dom-module> |
20 | 20 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 }); | 196 }); |
197 } | 197 } |
198 | 198 |
199 contextTest('singleGroup', function(c) { | 199 contextTest('singleGroup', function(c) { |
200 assert.isUndefined(c.getContext('G')); | 200 assert.isUndefined(c.getContext('G')); |
201 | 201 |
202 let s1 = {value: 10}; | 202 let s1 = {value: 10}; |
203 c.onScalarSpanAdded('G', s1); | 203 c.onScalarSpanAdded('G', s1); |
204 c.expectContextUpdatedEventForTesting(['G']); | 204 c.expectContextUpdatedEventForTesting(['G']); |
205 assert.isTrue(c.getContext('G').range.equals( | 205 assert.isTrue(c.getContext('G').range.equals( |
206 tr.b.Range.fromExplicitRange(10, 10))); | 206 tr.b.math.Range.fromExplicitRange(10, 10))); |
207 assert.sameMembers(tr.b.asArray(c.getContext('G').spans), [s1]); | 207 assert.sameMembers(tr.b.asArray(c.getContext('G').spans), [s1]); |
208 | 208 |
209 let s2 = {value: 15}; | 209 let s2 = {value: 15}; |
210 c.onScalarSpanAdded('G', s2); | 210 c.onScalarSpanAdded('G', s2); |
211 c.expectContextUpdatedEventForTesting(['G']); | 211 c.expectContextUpdatedEventForTesting(['G']); |
212 assert.isTrue(c.getContext('G').range.equals( | 212 assert.isTrue(c.getContext('G').range.equals( |
213 tr.b.Range.fromExplicitRange(10, 15))); | 213 tr.b.math.Range.fromExplicitRange(10, 15))); |
214 assert.sameMembers(tr.b.asArray(c.getContext('G').spans), [s1, s2]); | 214 assert.sameMembers(tr.b.asArray(c.getContext('G').spans), [s1, s2]); |
215 | 215 |
216 s1.value = 5; | 216 s1.value = 5; |
217 c.onScalarSpanUpdated('G', s1); | 217 c.onScalarSpanUpdated('G', s1); |
218 c.expectContextUpdatedEventForTesting(['G']); | 218 c.expectContextUpdatedEventForTesting(['G']); |
219 assert.isTrue(c.getContext('G').range.equals( | 219 assert.isTrue(c.getContext('G').range.equals( |
220 tr.b.Range.fromExplicitRange(5, 15))); | 220 tr.b.math.Range.fromExplicitRange(5, 15))); |
221 assert.sameMembers(tr.b.asArray(c.getContext('G').spans), [s1, s2]); | 221 assert.sameMembers(tr.b.asArray(c.getContext('G').spans), [s1, s2]); |
222 | 222 |
223 c.onScalarSpanRemoved('G', s2); | 223 c.onScalarSpanRemoved('G', s2); |
224 c.expectContextUpdatedEventForTesting(['G']); | 224 c.expectContextUpdatedEventForTesting(['G']); |
225 assert.isTrue(c.getContext('G').range.equals( | 225 assert.isTrue(c.getContext('G').range.equals( |
226 tr.b.Range.fromExplicitRange(5, 5))); | 226 tr.b.math.Range.fromExplicitRange(5, 5))); |
227 assert.sameMembers(tr.b.asArray(c.getContext('G').spans), [s1]); | 227 assert.sameMembers(tr.b.asArray(c.getContext('G').spans), [s1]); |
228 | 228 |
229 let s3 = {value: 0}; | 229 let s3 = {value: 0}; |
230 c.onScalarSpanAdded('G', s3); | 230 c.onScalarSpanAdded('G', s3); |
231 s2.value = 14; | 231 s2.value = 14; |
232 c.onScalarSpanAdded('G', s2); | 232 c.onScalarSpanAdded('G', s2); |
233 c.expectContextUpdatedEventForTesting(['G']); | 233 c.expectContextUpdatedEventForTesting(['G']); |
234 assert.isTrue(c.getContext('G').range.equals( | 234 assert.isTrue(c.getContext('G').range.equals( |
235 tr.b.Range.fromExplicitRange(0, 14))); | 235 tr.b.math.Range.fromExplicitRange(0, 14))); |
236 assert.sameMembers(tr.b.asArray(c.getContext('G').spans), [s1, s2, s3]); | 236 assert.sameMembers(tr.b.asArray(c.getContext('G').spans), [s1, s2, s3]); |
237 | 237 |
238 c.onScalarSpanRemoved('G', s1); | 238 c.onScalarSpanRemoved('G', s1); |
239 c.onScalarSpanRemoved('G', s2); | 239 c.onScalarSpanRemoved('G', s2); |
240 c.onScalarSpanRemoved('G', s3); | 240 c.onScalarSpanRemoved('G', s3); |
241 c.expectContextUpdatedEventForTesting(['G']); | 241 c.expectContextUpdatedEventForTesting(['G']); |
242 assert.isUndefined(c.getContext('G')); | 242 assert.isUndefined(c.getContext('G')); |
243 | 243 |
244 c.onScalarSpanAdded('G', s2); | 244 c.onScalarSpanAdded('G', s2); |
245 c.expectContextUpdatedEventForTesting(['G']); | 245 c.expectContextUpdatedEventForTesting(['G']); |
246 assert.isTrue(c.getContext('G').range.equals( | 246 assert.isTrue(c.getContext('G').range.equals( |
247 tr.b.Range.fromExplicitRange(14, 14))); | 247 tr.b.math.Range.fromExplicitRange(14, 14))); |
248 assert.sameMembers(tr.b.asArray(c.getContext('G').spans), [s2]); | 248 assert.sameMembers(tr.b.asArray(c.getContext('G').spans), [s2]); |
249 }); | 249 }); |
250 | 250 |
251 contextTest('multipleGroups', function(c) { | 251 contextTest('multipleGroups', function(c) { |
252 assert.isUndefined(c.getContext('G1')); | 252 assert.isUndefined(c.getContext('G1')); |
253 assert.isUndefined(c.getContext('G2')); | 253 assert.isUndefined(c.getContext('G2')); |
254 | 254 |
255 let s1 = {value: 0}; | 255 let s1 = {value: 0}; |
256 c.onScalarSpanAdded('G1', s1); | 256 c.onScalarSpanAdded('G1', s1); |
257 c.expectContextUpdatedEventForTesting(['G1']); | 257 c.expectContextUpdatedEventForTesting(['G1']); |
258 assert.isTrue(c.getContext('G1').range.equals( | 258 assert.isTrue(c.getContext('G1').range.equals( |
259 tr.b.Range.fromExplicitRange(0, 0))); | 259 tr.b.math.Range.fromExplicitRange(0, 0))); |
260 assert.sameMembers(tr.b.asArray(c.getContext('G1').spans), [s1]); | 260 assert.sameMembers(tr.b.asArray(c.getContext('G1').spans), [s1]); |
261 | 261 |
262 let s2 = {value: 1}; | 262 let s2 = {value: 1}; |
263 c.onScalarSpanAdded('G2', s2); | 263 c.onScalarSpanAdded('G2', s2); |
264 c.expectContextUpdatedEventForTesting(['G2']); | 264 c.expectContextUpdatedEventForTesting(['G2']); |
265 assert.isTrue(c.getContext('G2').range.equals( | 265 assert.isTrue(c.getContext('G2').range.equals( |
266 tr.b.Range.fromExplicitRange(1, 1))); | 266 tr.b.math.Range.fromExplicitRange(1, 1))); |
267 assert.sameMembers(tr.b.asArray(c.getContext('G2').spans), [s2]); | 267 assert.sameMembers(tr.b.asArray(c.getContext('G2').spans), [s2]); |
268 | 268 |
269 let s3 = {value: 2}; | 269 let s3 = {value: 2}; |
270 let s4 = {value: -1}; | 270 let s4 = {value: -1}; |
271 c.onScalarSpanAdded('G2', s3); | 271 c.onScalarSpanAdded('G2', s3); |
272 c.onScalarSpanAdded('G1', s4); | 272 c.onScalarSpanAdded('G1', s4); |
273 c.expectContextUpdatedEventForTesting(['G1', 'G2']); | 273 c.expectContextUpdatedEventForTesting(['G1', 'G2']); |
274 assert.isTrue(c.getContext('G1').range.equals( | 274 assert.isTrue(c.getContext('G1').range.equals( |
275 tr.b.Range.fromExplicitRange(-1, 0))); | 275 tr.b.math.Range.fromExplicitRange(-1, 0))); |
276 assert.sameMembers(tr.b.asArray(c.getContext('G1').spans), [s1, s4]); | 276 assert.sameMembers(tr.b.asArray(c.getContext('G1').spans), [s1, s4]); |
277 assert.isTrue(c.getContext('G2').range.equals( | 277 assert.isTrue(c.getContext('G2').range.equals( |
278 tr.b.Range.fromExplicitRange(1, 2))); | 278 tr.b.math.Range.fromExplicitRange(1, 2))); |
279 assert.sameMembers(tr.b.asArray(c.getContext('G2').spans), [s2, s3]); | 279 assert.sameMembers(tr.b.asArray(c.getContext('G2').spans), [s2, s3]); |
280 | 280 |
281 c.onScalarSpanRemoved('G2', s3); | 281 c.onScalarSpanRemoved('G2', s3); |
282 c.onScalarSpanAdded('G1', s3); | 282 c.onScalarSpanAdded('G1', s3); |
283 c.expectContextUpdatedEventForTesting(['G1', 'G2']); | 283 c.expectContextUpdatedEventForTesting(['G1', 'G2']); |
284 assert.isTrue(c.getContext('G1').range.equals( | 284 assert.isTrue(c.getContext('G1').range.equals( |
285 tr.b.Range.fromExplicitRange(-1, 2))); | 285 tr.b.math.Range.fromExplicitRange(-1, 2))); |
286 assert.sameMembers(tr.b.asArray(c.getContext('G1').spans), [s1, s3, s4]); | 286 assert.sameMembers(tr.b.asArray(c.getContext('G1').spans), [s1, s3, s4]); |
287 assert.isTrue(c.getContext('G2').range.equals( | 287 assert.isTrue(c.getContext('G2').range.equals( |
288 tr.b.Range.fromExplicitRange(1, 1))); | 288 tr.b.math.Range.fromExplicitRange(1, 1))); |
289 assert.sameMembers(tr.b.asArray(c.getContext('G2').spans), [s2]); | 289 assert.sameMembers(tr.b.asArray(c.getContext('G2').spans), [s2]); |
290 | 290 |
291 s4.value = 3; | 291 s4.value = 3; |
292 c.onScalarSpanUpdated('G1', s4); | 292 c.onScalarSpanUpdated('G1', s4); |
293 s1.value = 1; | 293 s1.value = 1; |
294 c.onScalarSpanUpdated('G1', s1); | 294 c.onScalarSpanUpdated('G1', s1); |
295 c.expectContextUpdatedEventForTesting(['G1']); | 295 c.expectContextUpdatedEventForTesting(['G1']); |
296 assert.isTrue(c.getContext('G1').range.equals( | 296 assert.isTrue(c.getContext('G1').range.equals( |
297 tr.b.Range.fromExplicitRange(1, 3))); | 297 tr.b.math.Range.fromExplicitRange(1, 3))); |
298 assert.sameMembers(tr.b.asArray(c.getContext('G1').spans), [s1, s3, s4]); | 298 assert.sameMembers(tr.b.asArray(c.getContext('G1').spans), [s1, s3, s4]); |
299 assert.isTrue(c.getContext('G2').range.equals( | 299 assert.isTrue(c.getContext('G2').range.equals( |
300 tr.b.Range.fromExplicitRange(1, 1))); | 300 tr.b.math.Range.fromExplicitRange(1, 1))); |
301 assert.sameMembers(tr.b.asArray(c.getContext('G2').spans), [s2]); | 301 assert.sameMembers(tr.b.asArray(c.getContext('G2').spans), [s2]); |
302 | 302 |
303 c.onScalarSpanRemoved('G2', s2); | 303 c.onScalarSpanRemoved('G2', s2); |
304 c.expectContextUpdatedEventForTesting(['G2']); | 304 c.expectContextUpdatedEventForTesting(['G2']); |
305 assert.isTrue(c.getContext('G1').range.equals( | 305 assert.isTrue(c.getContext('G1').range.equals( |
306 tr.b.Range.fromExplicitRange(1, 3))); | 306 tr.b.math.Range.fromExplicitRange(1, 3))); |
307 assert.sameMembers(tr.b.asArray(c.getContext('G1').spans), [s1, s3, s4]); | 307 assert.sameMembers(tr.b.asArray(c.getContext('G1').spans), [s1, s3, s4]); |
308 assert.isUndefined(c.getContext('G2')); | 308 assert.isUndefined(c.getContext('G2')); |
309 }); | 309 }); |
310 }); | 310 }); |
311 </script> | 311 </script> |
OLD | NEW |