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/range.html"> | 8 <link rel="import" href="/tracing/base/range.html"> |
9 <link rel="import" href="/tracing/value/numeric.html"> | 9 <link rel="import" href="/tracing/value/numeric.html"> |
10 <link rel="import" href="/tracing/value/unit.html"> | 10 <link rel="import" href="/tracing/value/unit.html"> |
11 <link rel="import" href="/tracing/value/value_set.html"> | 11 <link rel="import" href="/tracing/value/value_set.html"> |
12 | 12 |
13 <script> | 13 <script> |
14 'use strict'; | 14 'use strict'; |
15 | 15 |
16 tr.b.unittest.testSuite(function() { | 16 tr.b.unittest.testSuite(function() { |
| 17 test('addValuesFromDicts', function() { |
| 18 var n = tr.v.NumericBuilder.createLinear( |
| 19 tr.v.Unit.byName.timeDurationInMs, tr.b.Range.fromExplicitRange(0, 100), |
| 20 100).build(); |
| 21 n.add(10); |
| 22 n.customizeSummaryOptions({ |
| 23 count: true, |
| 24 min: false, |
| 25 max: false, |
| 26 sum: true, |
| 27 avg: false, |
| 28 std: false |
| 29 }); |
| 30 |
| 31 var values = new tr.v.ValueSet([new tr.v.NumericValue('foo', n)]); |
| 32 var values2 = new tr.v.ValueSet(); |
| 33 values2.addValuesFromDicts(values.valueDicts); |
| 34 // foo, foo_count, foo_sum |
| 35 assert.lengthOf(values2.getValuesWithName('foo'), 3); |
| 36 assert.lengthOf(values2.getValuesNamed('foo'), 1); |
| 37 }); |
| 38 |
17 test('computeSummaryValuesForNumericValue', function() { | 39 test('computeSummaryValuesForNumericValue', function() { |
18 var n = tr.v.NumericBuilder.createLinear( | 40 var n = tr.v.NumericBuilder.createLinear( |
19 tr.v.Unit.byName.timeDurationInMs, tr.b.Range.fromExplicitRange(0, 100), | 41 tr.v.Unit.byName.timeDurationInMs, tr.b.Range.fromExplicitRange(0, 100), |
20 100).build(); | 42 100).build(); |
21 | 43 |
22 n.add(50); | 44 n.add(50); |
23 n.add(60); | 45 n.add(60); |
24 n.add(70); | 46 n.add(70); |
25 | 47 |
26 n.customizeSummaryOptions({ | 48 n.customizeSummaryOptions({ |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 assert.notStrictEqual(c2, c); | 193 assert.notStrictEqual(c2, c); |
172 | 194 |
173 // b2 should still be in a2's RelatedValueMap. | 195 // b2 should still be in a2's RelatedValueMap. |
174 assert.strictEqual(rvm2.get('y'), b2); | 196 assert.strictEqual(rvm2.get('y'), b2); |
175 | 197 |
176 // Now a real c2 Value should be in a2's RelatedValueMap. | 198 // Now a real c2 Value should be in a2's RelatedValueMap. |
177 assert.strictEqual(rvm2.get('z'), c2); | 199 assert.strictEqual(rvm2.get('z'), c2); |
178 }); | 200 }); |
179 }); | 201 }); |
180 </script> | 202 </script> |
OLD | NEW |