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

Side by Side Diff: tools/telemetry/telemetry/web_perf/metrics/webrtc_rendering_stats_unittest.py

Issue 1416533003: Handle corrupted data in Telemetry WebRtcRendering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added more checks to testCorruptData test Created 5 years, 2 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 import unittest 4 import unittest
5 5
6 from telemetry.web_perf.metrics import webrtc_rendering_stats as stats_helper 6 from telemetry.web_perf.metrics import webrtc_rendering_stats as stats_helper
7 7
8 8
9 class FakeEvent(object): 9 class FakeEvent(object):
10 """Fake event class to mock rendering events.""" 10 """Fake event class to mock rendering events."""
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 ideal_instant=1663780361998, serial=self.remote_stream), 107 ideal_instant=1663780361998, serial=self.remote_stream),
108 FakeEvent(actual_begin=1663780395575, actual_end=1663780412241, 108 FakeEvent(actual_begin=1663780395575, actual_end=1663780412241,
109 ideal_instant=1663780361998, serial=self.remote_stream), 109 ideal_instant=1663780361998, serial=self.remote_stream),
110 FakeEvent(actual_begin=1663780412241, actual_end=1663780428907, 110 FakeEvent(actual_begin=1663780412241, actual_end=1663780428907,
111 ideal_instant=1663780361998, serial=self.remote_stream), 111 ideal_instant=1663780361998, serial=self.remote_stream),
112 FakeEvent(actual_begin=1663780428907, actual_end=1663780445573, 112 FakeEvent(actual_begin=1663780428907, actual_end=1663780445573,
113 ideal_instant=1663780412998, serial=self.remote_stream)] 113 ideal_instant=1663780412998, serial=self.remote_stream)]
114 114
115 return fake_events 115 return fake_events
116 116
117 def _GetCorruptEvents(self):
118 # The events below are corrupt data because the |ideal_instant|
119 # parameter is zero, which makes all computation meaningless.
120 # Indeed, the ideal_instant (aka Ideal Render Instant) indicates
121 # when the frame should be rendered ideally.
122 corrupt_events = [
123 FakeEvent(actual_begin=1663780195583, actual_end=1663780212249,
124 ideal_instant=0, serial=self.remote_stream),
125 FakeEvent(actual_begin=1663780212249, actual_end=1663780228915,
126 ideal_instant=0, serial=self.remote_stream),
127 FakeEvent(actual_begin=1663780228915, actual_end=1663780245581,
128 ideal_instant=0, serial=self.remote_stream),
129 FakeEvent(actual_begin=1663780245581, actual_end=1663780262247,
130 ideal_instant=0, serial=self.remote_stream)]
131 return corrupt_events
132
117 def testGetCadence(self): 133 def testGetCadence(self):
118 fake_events = self._GetFakeEvents() 134 fake_events = self._GetFakeEvents()
119 stats_parser = stats_helper.WebMediaPlayerMsRenderingStats(fake_events) 135 stats_parser = stats_helper.WebMediaPlayerMsRenderingStats(fake_events)
120 # The events defined in _GetFakeEvents above show that the first source 136 # The events defined in _GetFakeEvents above show that the first source
121 # framee of ideal_instant=1663780179998 is rendered twice, then 137 # framee of ideal_instant=1663780179998 is rendered twice, then
122 # the second source frame of ideal_instant=1663780197998 is rendered once 138 # the second source frame of ideal_instant=1663780197998 is rendered once
123 # the third source frame of ideal_instant=1663780215998 is rendered twice 139 # the third source frame of ideal_instant=1663780215998 is rendered twice
124 # and so on. The expected cadence will therefore be [2 1 2 etc..] 140 # and so on. The expected cadence will therefore be [2 1 2 etc..]
125 expected_cadence = [2, 1, 2, 3, 3, 3, 1] 141 expected_cadence = [2, 1, 2, 3, 3, 3, 1]
126 self.assertEqual(expected_cadence, stats_parser._GetCadence(fake_events)) 142 self.assertEqual(expected_cadence, stats_parser._GetCadence(fake_events))
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 stats.percent_badly_out_of_sync) 248 stats.percent_badly_out_of_sync)
233 self.assertEqual(expected_stats.percent_out_of_sync, 249 self.assertEqual(expected_stats.percent_out_of_sync,
234 stats.percent_out_of_sync) 250 stats.percent_out_of_sync)
235 self.assertEqual(expected_stats.smoothness_score, stats.smoothness_score) 251 self.assertEqual(expected_stats.smoothness_score, stats.smoothness_score)
236 self.assertEqual(expected_stats.freezing_score, stats.freezing_score) 252 self.assertEqual(expected_stats.freezing_score, stats.freezing_score)
237 self.assertEqual(expected_stats.rendering_length_error, 253 self.assertEqual(expected_stats.rendering_length_error,
238 stats.rendering_length_error) 254 stats.rendering_length_error)
239 self.assertEqual(expected_stats.fps, stats.fps) 255 self.assertEqual(expected_stats.fps, stats.fps)
240 self.assertEqual(expected_stats.frame_distribution, 256 self.assertEqual(expected_stats.frame_distribution,
241 stats.frame_distribution) 257 stats.frame_distribution)
258
259 def testCorruptData(self):
260 corrupt_events = self._GetCorruptEvents()
261 stats_parser = stats_helper.WebMediaPlayerMsRenderingStats(corrupt_events)
262 stats = stats_parser.GetTimeStats()
263 self.assertTrue(stats.invalid_data)
264 self.assertIsNone(stats.drift_time)
265 self.assertIsNone(stats.percent_badly_out_of_sync)
266 self.assertIsNone(stats.percent_out_of_sync)
267 self.assertIsNone(stats.smoothness_score)
268 self.assertIsNone(stats.freezing_score)
269 self.assertIsNone(stats.rendering_length_error)
270 self.assertIsNone(stats.fps)
271 self.assertIsNone(stats.frame_distribution)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698