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

Side by Side Diff: webrtc/tools/py_event_log_analyzer/rtp_analyzer_test.py

Issue 2316573003: Python event log analyzer tool: fix of indexing issue. (Closed)
Patch Set: Presubmit complaint. Created 4 years, 3 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
« no previous file with comments | « webrtc/tools/py_event_log_analyzer/rtp_analyzer.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 #
4 # Use of this source code is governed by a BSD-style license
5 # that can be found in the LICENSE file in the root of the source
6 # tree. An additional intellectual property rights grant can be found
7 # in the file PATENTS. All contributing project authors may
8 # be found in the AUTHORS file in the root of the source tree.
9
10 """Run the tests with
11
12 python rtp_analyzer_test.py
13 or
14 python3 rtp_analyzer_test.py
15 """
16
17 import collections
18 import unittest
19
20 missing_numpy = False
21 try:
22 import numpy
23 import rtp_analyzer
24 except ImportError:
25 missing_numpy = True
26
27 FakePoint = collections.namedtuple("FakePoint",
28 ["real_send_time_ms", "absdelay"])
29
30
31 class TestDelay(unittest.TestCase):
32 def assertMaskEqual(self, masked_array, data, mask):
33 self.assertEqual(list(masked_array.data), data)
34
35 if isinstance(masked_array.mask, numpy.bool_):
36 array_mask = masked_array.mask
37 else:
38 array_mask = list(masked_array.mask)
39 self.assertEqual(array_mask, mask)
40
41 def testCalculateDelaySimple(self):
42 points = [FakePoint(0, 0), FakePoint(1, 0)]
43 mask = rtp_analyzer.calculate_delay(0, 1, 1, points)
44 self.assertMaskEqual(mask, [0, 0], False)
45
46 def testCalculateDelayMissing(self):
47 points = [FakePoint(0, 0), FakePoint(2, 0)]
48 mask = rtp_analyzer.calculate_delay(0, 2, 1, points)
49 self.assertMaskEqual(mask, [0, -1, 0], [False, True, False])
50
51 def testCalculateDelayBorders(self):
52 points = [FakePoint(0, 0), FakePoint(2, 0)]
53 mask = rtp_analyzer.calculate_delay(0, 3, 2, points)
54 self.assertMaskEqual(mask, [0, 0, -1], [False, False, True])
55
56
57 if __name__ == "__main__":
58 if missing_numpy:
59 # pylint: disable=superfluous-parens
60 print("Missing numpy, skipping test.")
61 else:
62 unittest.main()
OLDNEW
« no previous file with comments | « webrtc/tools/py_event_log_analyzer/rtp_analyzer.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698