mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-09-28 02:23:42 +08:00
0b7bd2561d
* unittest speedups * fix deleter test helper signature * document small deleter test files * test uploader clears locks on startup
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
import threading
|
|
|
|
from openpilot.common.test import OpenpilotTestCase
|
|
from openpilot.cereal import log, messaging
|
|
from openpilot.cereal.messaging import SubMaster, PubMaster
|
|
from openpilot.selfdrive.ui.soundd import SELFDRIVE_STATE_TIMEOUT, check_selfdrive_timeout_alert
|
|
|
|
AudibleAlert = log.SelfdriveState.AudibleAlert
|
|
|
|
|
|
class TestSoundd(OpenpilotTestCase):
|
|
def test_check_selfdrive_timeout_alert(self, mocker):
|
|
sm = SubMaster(['selfdriveState'])
|
|
pm = PubMaster(['selfdriveState'])
|
|
|
|
cs = messaging.new_message('selfdriveState')
|
|
cs.selfdriveState.enabled = True
|
|
threading.Timer(0.01, pm.send, args=("selfdriveState", cs)).start()
|
|
sm.update(100)
|
|
assert sm.updated['selfdriveState']
|
|
|
|
received_at = sm.recv_time['selfdriveState']
|
|
clock = mocker.patch("openpilot.selfdrive.ui.soundd.time.monotonic", return_value=received_at + SELFDRIVE_STATE_TIMEOUT)
|
|
assert not check_selfdrive_timeout_alert(sm)
|
|
|
|
clock.return_value = received_at + SELFDRIVE_STATE_TIMEOUT + 0.1
|
|
assert check_selfdrive_timeout_alert(sm)
|
|
|
|
clock.return_value = received_at + SELFDRIVE_STATE_TIMEOUT + 10
|
|
assert not check_selfdrive_timeout_alert(sm)
|
|
|
|
# TODO: add test with micd for checking that soundd actually outputs sounds
|