OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 import unittest | 5 import unittest |
6 | 6 |
7 from telemetry.testing import simple_mock | 7 from telemetry.testing import simple_mock |
8 | 8 |
9 from metrics import webrtc_stats | 9 from metrics import webrtc_stats |
10 | 10 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 | 107 |
108 class WebRtcStatsUnittest(unittest.TestCase): | 108 class WebRtcStatsUnittest(unittest.TestCase): |
109 | 109 |
110 def _RunMetricOnJson(self, json_to_return, stats_metric): | 110 def _RunMetricOnJson(self, json_to_return, stats_metric): |
111 tab = simple_mock.MockObject() | 111 tab = simple_mock.MockObject() |
112 page = simple_mock.MockObject() | 112 page = simple_mock.MockObject() |
113 | 113 |
114 stats_metric.Start(page, tab) | 114 stats_metric.Start(page, tab) |
115 | 115 |
116 tab.ExpectCall('EvaluateJavaScript2', | 116 tab.ExpectCall('EvaluateJavaScript', |
117 simple_mock.DONT_CARE).WillReturn(json_to_return) | 117 simple_mock.DONT_CARE).WillReturn(json_to_return) |
118 stats_metric.Stop(page, tab) | 118 stats_metric.Stop(page, tab) |
119 | 119 |
120 page.url = simple_mock.MockObject() | 120 page.url = simple_mock.MockObject() |
121 results = FakeResults(page) | 121 results = FakeResults(page) |
122 stats_metric.AddResults(tab, results) | 122 stats_metric.AddResults(tab, results) |
123 return results | 123 return results |
124 | 124 |
125 def testExtractsValuesAsTimeSeries(self): | 125 def testExtractsValuesAsTimeSeries(self): |
126 stats_metric = webrtc_stats.WebRtcStatisticsMetric() | 126 stats_metric = webrtc_stats.WebRtcStatisticsMetric() |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 expected_names = ['peer_connection_0_audio_goog_rtt', | 169 expected_names = ['peer_connection_0_audio_goog_rtt', |
170 'peer_connection_0_video_goog_rtt', | 170 'peer_connection_0_video_goog_rtt', |
171 'peer_connection_1_video_goog_max_decode_ms', | 171 'peer_connection_1_video_goog_max_decode_ms', |
172 'peer_connection_1_video_goog_rtt'] | 172 'peer_connection_1_video_goog_rtt'] |
173 self.assertEqual(expected_names, received_names) | 173 self.assertEqual(expected_names, received_names) |
174 | 174 |
175 def testReturnsIfJsonIsEmpty(self): | 175 def testReturnsIfJsonIsEmpty(self): |
176 stats_metric = webrtc_stats.WebRtcStatisticsMetric() | 176 stats_metric = webrtc_stats.WebRtcStatisticsMetric() |
177 results = self._RunMetricOnJson('[]', stats_metric) | 177 results = self._RunMetricOnJson('[]', stats_metric) |
178 self.assertFalse(results.received_values) | 178 self.assertFalse(results.received_values) |
OLD | NEW |