From eb0724d7e3bff078f803d45d5d305b5f793c8f22 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Wed, 1 Dec 2021 03:31:46 +0800 Subject: [PATCH] soundd: fix test case (#23075) * init sound_stats * send deviceState msg --- selfdrive/ui/tests/test_sound.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/selfdrive/ui/tests/test_sound.cc b/selfdrive/ui/tests/test_sound.cc index 62aa35cb2b..43599f3828 100644 --- a/selfdrive/ui/tests/test_sound.cc +++ b/selfdrive/ui/tests/test_sound.cc @@ -9,6 +9,7 @@ class TestSound : public Sound { public: TestSound() : Sound() { for (auto i = sounds.constBegin(); i != sounds.constEnd(); ++i) { + sound_stats[i.key()] = {0, 0}; QObject::connect(i.value().first, &QSoundEffect::playingChanged, [=, s = i.value().first, a = i.key()]() { if (s->isPlaying()) { sound_stats[a].first++; @@ -23,7 +24,11 @@ public: }; void controls_thread(int loop_cnt) { - PubMaster pm({"controlsState"}); + PubMaster pm({"controlsState", "deviceState"}); + MessageBuilder deviceStateMsg; + auto deviceState = deviceStateMsg.initEvent().initDeviceState(); + deviceState.setStarted(true); + const int DT_CTRL = 10; // ms for (int i = 0; i < loop_cnt; ++i) { for (auto &[alert, fn, loops] : sound_list) { @@ -34,6 +39,7 @@ void controls_thread(int loop_cnt) { cs.setAlertSound(alert); cs.setAlertType(fn.toStdString()); pm.send("controlsState", msg); + pm.send("deviceState", deviceStateMsg); QThread::msleep(DT_CTRL); } }