mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-08-16 13:43:40 +08:00
dd9d5d4528
* add pytest-asyncio * switch common * switch selfdrive * switch system * switch tools * small fixes * fix setUp and valgrind pytest * switch to setup * fix random * switch mock * switch test_lateral_limits * revert test_ui * fix poetry.lock * add unittest to banned-api * add inline ignores to remaining unittest imports * revert test_models * revert check_can_parser_performance * one more skip --------- Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
38 lines
883 B
Python
Executable File
38 lines
883 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
from cereal import car
|
|
from cereal import messaging
|
|
from cereal.messaging import SubMaster, PubMaster
|
|
from openpilot.selfdrive.ui.soundd import CONTROLS_TIMEOUT, check_controls_timeout_alert
|
|
|
|
import time
|
|
|
|
AudibleAlert = car.CarControl.HUDControl.AudibleAlert
|
|
|
|
|
|
class TestSoundd:
|
|
def test_check_controls_timeout_alert(self):
|
|
sm = SubMaster(['controlsState'])
|
|
pm = PubMaster(['controlsState'])
|
|
|
|
for _ in range(100):
|
|
cs = messaging.new_message('controlsState')
|
|
cs.controlsState.enabled = True
|
|
|
|
pm.send("controlsState", cs)
|
|
|
|
time.sleep(0.01)
|
|
|
|
sm.update(0)
|
|
|
|
assert not check_controls_timeout_alert(sm)
|
|
|
|
for _ in range(CONTROLS_TIMEOUT * 110):
|
|
sm.update(0)
|
|
time.sleep(0.01)
|
|
|
|
assert check_controls_timeout_alert(sm)
|
|
|
|
# TODO: add test with micd for checking that soundd actually outputs sounds
|
|
|