forked from robotics-4-all/tektrain-robot-sw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_speaker.py
75 lines (62 loc) · 1.92 KB
/
test_speaker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import sys
import unittest
import time
from pidevices.actuators.speaker import Speaker
class TestSpeaker(unittest.TestCase):
def test_one(self):
speaker = Speaker()
speaker.write(cmd_par, times=1, file_flag=True)
def test_volume(self):
speaker = Speaker()
speaker.write(cmd_par, times=1, file_flag=True)
time.sleep(1)
speaker.volume = 30
self.assertEqual(speaker.volume[0], 30, "Must be 30")
speaker.write(cmd_par, times=1, file_flag=True)
time.sleep(1)
speaker.volume = 80
speaker.write(cmd_par, times=1, file_flag=True)
def test_async(self):
speaker = Speaker()
speaker.async_write(cmd_par, times=1, file_flag=True)
time.sleep(10)
def test_pause(self):
speaker = Speaker()
speaker.async_write(cmd_par, times=1, file_flag=True)
time.sleep(2)
speaker.pause()
print("Pause")
time.sleep(2)
print("continue")
speaker.pause(False)
time.sleep(6)
def test_multi(self):
speaker = Speaker()
speaker.async_write(cmd_par, times=1, file_flag=True)
#time.sleep(4)
while speaker.playing:
#time.sleep(0.1)
pass
speaker.async_write(cmd_par, times=1, file_flag=True)
while speaker.playing:
#time.sleep(0.1)
pass
def test_cancel(self):
speaker = Speaker()
speaker.async_write(cmd_par, times=3, file_flag=True)
time.sleep(4)
speaker.cancel()
#while speaker.playing:
# #time.sleep(0.1)
# pass
speaker.async_write(cmd_par, times=1, file_flag=True)
while speaker.playing:
#time.sleep(0.1)
pass
def test_path(self):
speaker = Speaker()
speaker._fix_path('f')
if __name__ == "__main__":
cmd_par = sys.argv[2]
del sys.argv[2:]
unittest.main()