OLD | NEW |
---|---|
(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 import numpy | |
21 import rtp_analyzer | |
22 | |
23 FakePoint = collections.namedtuple("FakePoint", | |
24 ["real_send_time_ms", "absdelay"]) | |
25 | |
26 | |
27 class TestDelay(unittest.TestCase): | |
28 | |
phoglund
2016/09/06 11:43:05
Remove blank line.
aleloi
2016/09/06 12:15:37
Ok! But gpylint complains if there is no blank lin
| |
29 def assertMaskEqual(self, masked_array, data, mask): | |
30 self.assertEqual(list(masked_array.data), data) | |
31 | |
32 if isinstance(masked_array.mask, numpy.bool_): | |
33 array_mask = masked_array.mask | |
34 else: | |
35 array_mask = list(masked_array.mask) | |
36 self.assertEqual(array_mask, mask) | |
37 | |
38 def testCalculateDelaySimple(self): | |
39 points = [FakePoint(0, 0), FakePoint(1, 0)] | |
40 mask = rtp_analyzer.calculate_delay(0, 1, 1, points) | |
41 self.assertMaskEqual(mask, [0, 0], False) | |
42 | |
43 def testCalculateDelayMissing(self): | |
44 points = [FakePoint(0, 0), FakePoint(2, 0)] | |
45 mask = rtp_analyzer.calculate_delay(0, 2, 1, points) | |
46 self.assertMaskEqual(mask, [0, -1, 0], [False, True, False]) | |
47 | |
48 def testCalculateDelayBorders(self): | |
49 points = [FakePoint(0, 0), FakePoint(2, 0)] | |
50 mask = rtp_analyzer.calculate_delay(0, 3, 2, points) | |
51 self.assertMaskEqual(mask, [0, 0, -1], [False, False, True]) | |
52 | |
53 | |
54 if __name__ == "__main__": | |
55 unittest.main() | |
aleloi
2016/09/06 11:08:11
If I rename this file to end with '_test', the pre
phoglund
2016/09/06 11:43:04
Umm, why not add numpy as a dependency? Your tool
| |
OLD | NEW |