OLD | NEW |
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 """Tests for the Chromium Performance Dashboard data format implementation.""" | 5 """Tests for the Chromium Performance Dashboard data format implementation.""" |
6 | 6 |
7 import imp | 7 import imp |
8 import os.path | 8 import os.path |
9 import sys | 9 import sys |
10 import unittest | 10 import unittest |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 self.assertEquals(1, len(charts['chart1'])) | 66 self.assertEquals(1, len(charts['chart1'])) |
67 self.assertEquals({ | 67 self.assertEquals({ |
68 'type': 'scalar', | 68 'type': 'scalar', |
69 'units': 'ms', | 69 'units': 'ms', |
70 'value': 1}, charts['chart1']['val1']) | 70 'value': 1}, charts['chart1']['val1']) |
71 self.assertEquals(1, len(charts['chart2'])) | 71 self.assertEquals(1, len(charts['chart2'])) |
72 self.assertEquals({ | 72 self.assertEquals({ |
73 'type': 'scalar', | 73 'type': 'scalar', |
74 'units': 'ms', | 74 'units': 'ms', |
75 'value': 2}, charts['chart2']['val2']) | 75 'value': 2}, charts['chart2']['val2']) |
| 76 |
| 77 def test_vectors(self): |
| 78 """Test recording a list of scalar values.""" |
| 79 recorder = ChartDataRecorder('benchmark') |
| 80 recorder.record_vector('chart1', 'val1', 'ms', [1, 2]) |
| 81 recorder.record_vector('chart2', 'val2', 'ms', []) |
| 82 |
| 83 result = recorder.get_chart_data() |
| 84 self.assertEquals('1.0', result['format_version']) |
| 85 self.assertEquals('benchmark', result['benchmark_name']) |
| 86 |
| 87 charts = result['charts'] |
| 88 self.assertEquals(2, len(charts)) |
| 89 self.assertEquals(1, len(charts['chart1'])) |
| 90 self.assertEquals({ |
| 91 'type': 'list_of_scalar_values', |
| 92 'units': 'ms', |
| 93 'values': [1, 2]}, charts['chart1']['val1']) |
| 94 self.assertEquals(1, len(charts['chart2'])) |
| 95 self.assertEquals({ |
| 96 'type': 'list_of_scalar_values', |
| 97 'units': 'ms', |
| 98 'values': []}, charts['chart2']['val2']) |
OLD | NEW |