From 45ef90a4f03b42be8971d378d9082b667373673a Mon Sep 17 00:00:00 2001 From: AdityaKasar Date: Thu, 17 Oct 2024 12:38:21 +0530 Subject: [PATCH] test(manage): VoiceGuidance events unit tests --- .../sdk/cpptest/unit/voiceGuidanceTest.cpp | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/sdks/manage/src/cpp/sdk/cpptest/unit/voiceGuidanceTest.cpp diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/unit/voiceGuidanceTest.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/unit/voiceGuidanceTest.cpp new file mode 100644 index 000000000..3dba5bd74 --- /dev/null +++ b/src/sdks/manage/src/cpp/sdk/cpptest/unit/voiceGuidanceTest.cpp @@ -0,0 +1,47 @@ +#include "unit.h" + +class VoiceGuidanceTest : public ::testing::Test +{ +protected: + Firebolt::Error error = Firebolt::Error::None; +}; + +struct EnabledSettings : public Firebolt::VoiceGuidance::IVoiceGuidance::IOnEnabledChangedNotification { + void onEnabledChanged(const bool) override; +}; + +void EnabledSettings::onEnabledChanged(const bool isEnabled) { + std::cout << "onEnabledChanged event fired with isEnabled: " << isEnabled; +} + +TEST_F(VoiceGuidanceTest, subscribeOnEnabledChanged) { + EnabledSettings enabledSettings; + Firebolt::IFireboltAccessor::Instance().VoiceGuidanceInterface().subscribe(enabledSettings, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to EnabledSettings"; +} + +TEST_F(VoiceGuidanceTest, unsubscribeOnEnabledChanged) { + EnabledSettings enabledSettings; + Firebolt::IFireboltAccessor::Instance().VoiceGuidanceInterface().unsubscribe(enabledSettings, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error in unsubscribing to EnabledSettings"; +} + +struct SpeedSettings : public Firebolt::VoiceGuidance::IVoiceGuidance::IOnSpeedChangedNotification { + void onSpeedChanged(const float) override; +}; + +void SpeedSettings::onSpeedChanged(const float speed) { + std::cout << "onSpeedChanged event fired with speed: " << speed; +} + +TEST_F(VoiceGuidanceTest, subscribeOnSpeedChanged) { + SpeedSettings speedSettings; + Firebolt::IFireboltAccessor::Instance().VoiceGuidanceInterface().subscribe(speedSettings, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to SpeedSettings"; +} + +TEST_F(VoiceGuidanceTest, unsubscribeOnSpeedChanged) { + SpeedSettings speedSettings; + Firebolt::IFireboltAccessor::Instance().VoiceGuidanceInterface().unsubscribe(speedSettings, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error in unsubscribing to SpeedSettings"; +}