diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/unit/accountTest.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/unit/accountTest.cpp new file mode 100644 index 000000000..d92e1aa29 --- /dev/null +++ b/src/sdks/manage/src/cpp/sdk/cpptest/unit/accountTest.cpp @@ -0,0 +1,26 @@ +#include "unit.h" + +class AccountTest : public ::testing::Test +{ +protected: + JsonEngine *jsonEngine; + Firebolt::Error error = Firebolt::Error::None; + + void SetUp() override + { + jsonEngine = new JsonEngine(); + } + + void TearDown() override + { + delete jsonEngine; + } +}; + +TEST_F(AccountTest, session) +{ + std::string token = "expiresIn"; + int32_t expiresIn = 84000; + Firebolt::IFireboltAccessor::Instance().AccountInterface().session(token, expiresIn, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling AccountInterface.session() method"; +} diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/unit/acknowledgeChallengeTest.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/unit/acknowledgeChallengeTest.cpp new file mode 100644 index 000000000..db36c5971 --- /dev/null +++ b/src/sdks/manage/src/cpp/sdk/cpptest/unit/acknowledgeChallengeTest.cpp @@ -0,0 +1,64 @@ +#include "unit.h" + +using namespace Firebolt::AcknowledgeChallenge; + +struct AcknowledgeChallengeProvider : public IAcknowledgeChallengeProvider +{ + AcknowledgeChallengeProvider(); + ~AcknowledgeChallengeProvider() override = default; + void SendMessage(bool response); + void challenge(const Challenge ¶meters, std::unique_ptr session) override; + +private: + void startAcknowledgeChallengeSession(const Challenge ¶meters, std::unique_ptr session); + +private: + std::unique_ptr _session; + Challenge _parameters; + bool _challengeInput; +}; + +class AcknowledgeChallengeTest : public ::testing::Test +{ +protected: + JsonEngine *jsonEngine; + Firebolt::Error error = Firebolt::Error::None; + AcknowledgeChallengeProvider _acknowledgeChallengeProvider; + + void SetUp() override + { + jsonEngine = new JsonEngine(); + } + + void TearDown() override + { + delete jsonEngine; + } +}; + +AcknowledgeChallengeProvider::AcknowledgeChallengeProvider() + : _session(nullptr), _parameters(), _challengeInput(false) +{ +} + +void AcknowledgeChallengeProvider::SendMessage(bool response) +{ +} + +void AcknowledgeChallengeProvider::startAcknowledgeChallengeSession(const Firebolt::AcknowledgeChallenge::Challenge ¶meters, std::unique_ptr session) +{ + _session = std::move(session); + _parameters = parameters; + _challengeInput = true; +} + +void AcknowledgeChallengeProvider::challenge(const Challenge ¶meters, std::unique_ptr session) +{ + std::cout << "AcknowledgeChallengeProvider challenge is invoked" << std::endl; + startAcknowledgeChallengeSession(parameters, std::move(session)); +} + +TEST_F(AcknowledgeChallengeTest, registerAcknowledgeChallengeProvider) +{ + Firebolt::IFireboltAccessor::Instance().AcknowledgeChallengeInterface().provide(_acknowledgeChallengeProvider); +} diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/unit/advertisingTest.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/unit/advertisingTest.cpp index 6c2dda5ff..e49abc504 100644 --- a/src/sdks/manage/src/cpp/sdk/cpptest/unit/advertisingTest.cpp +++ b/src/sdks/manage/src/cpp/sdk/cpptest/unit/advertisingTest.cpp @@ -3,22 +3,73 @@ class AdvertisingTest : public ::testing::Test { protected: + JsonEngine *jsonEngine; Firebolt::Error error = Firebolt::Error::None; + + void SetUp() override + { + jsonEngine = new JsonEngine(); + } + + void TearDown() override + { + delete jsonEngine; + } }; +TEST_F(AdvertisingTest, resetIdentifier) +{ + Firebolt::IFireboltAccessor::Instance().AdvertisingInterface().resetIdentifier(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling AdvertisingInterface.resetIdentifier() method"; +} + +TEST_F(AdvertisingTest, skipRestriction) +{ + std::string expectedValues = jsonEngine->get_value("Advertising.skipRestriction"); + Firebolt::Advertising::SkipRestriction restriction = Firebolt::IFireboltAccessor::Instance().AdvertisingInterface().skipRestriction(&error); + + std::string actual_skip_restriction; + switch (restriction) + { + case Firebolt::Advertising::SkipRestriction::NONE: + actual_skip_restriction = "none"; + break; + case Firebolt::Advertising::SkipRestriction::ADS_UNWATCHED: + actual_skip_restriction = "ads_unwatched"; + break; + case Firebolt::Advertising::SkipRestriction::ADS_ALL: + actual_skip_restriction = "ads_all"; + break; + case Firebolt::Advertising::SkipRestriction::ALL: + actual_skip_restriction = "all"; + break; + default: + actual_skip_restriction = "unknown"; + } + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling AdvertisingInterface.skipRestriction() method"; + EXPECT_EQ(REMOVE_QUOTES(expectedValues), actual_skip_restriction) << "Error: wrong skipRestriction returned by AdvertisingInterface.skipRestriction()"; +} + +TEST_F(AdvertisingTest, setSkipRestriction) +{ + Firebolt::Advertising::SkipRestriction expected_value = Firebolt::Advertising::SkipRestriction::ADS_ALL; // Replace with the appropriate enum value + Firebolt::IFireboltAccessor::Instance().AdvertisingInterface().setSkipRestriction(expected_value, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling AdvertisingInterface.setSkipRestriction() method"; +} + +// Events Tests struct SkipRestrictionChanged : public Firebolt::Advertising::IAdvertising::IOnSkipRestrictionChangedNotification { - void onSkipRestrictionChanged( const Firebolt::Advertising::SkipRestriction& ) override; + void onSkipRestrictionChanged(const Firebolt::Advertising::SkipRestriction &) override; }; Firebolt::Advertising::SkipRestriction newSkipRestriction; -void SkipRestrictionChanged::onSkipRestrictionChanged(const Firebolt::Advertising::SkipRestriction& skipRestriction) +void SkipRestrictionChanged::onSkipRestrictionChanged(const Firebolt::Advertising::SkipRestriction &skipRestriction) { std::cout << "onSkipRestrictionChanged event fired"; } - TEST_F(AdvertisingTest, subscribeOnSkipRestrictionChanged) { SkipRestrictionChanged skipRestrictionChanged; diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/unit/audioDescriptionsTest.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/unit/audioDescriptionsTest.cpp index 743a56b58..a3744386e 100644 --- a/src/sdks/manage/src/cpp/sdk/cpptest/unit/audioDescriptionsTest.cpp +++ b/src/sdks/manage/src/cpp/sdk/cpptest/unit/audioDescriptionsTest.cpp @@ -3,22 +3,46 @@ class AudioDescriptionsTest : public ::testing::Test { protected: + JsonEngine *jsonEngine; Firebolt::Error error = Firebolt::Error::None; + + void SetUp() override + { + jsonEngine = new JsonEngine(); + } + + void TearDown() override + { + delete jsonEngine; + } }; +TEST_F(AudioDescriptionsTest, enabled) +{ + auto expectedValues = jsonEngine->get_value("AudioDescriptions.enabled"); + bool enable = Firebolt::IFireboltAccessor::Instance().AudioDescriptionsInterface().enabled(&error); + + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling AudioDescriptions.enabled() method"; + EXPECT_EQ(expectedValues == "true", enable) << "Error: AudioDescriptions.enabled() dose not returns enabled"; +} + +TEST_F(AudioDescriptionsTest, setEnabled) +{ + Firebolt::IFireboltAccessor::Instance().AudioDescriptionsInterface().setEnabled(true, &error); + + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling AudioDescriptions.setEnabled() method"; +} struct EnabledChanged : public Firebolt::AudioDescriptions::IAudioDescriptions::IOnEnabledChangedNotification { - void onEnabledChanged( const bool ) override; + void onEnabledChanged(const bool) override; }; - void EnabledChanged::onEnabledChanged(const bool) { std::cout << "onAudioDescriptionEnabledChanged event fired"; } - TEST_F(AudioDescriptionsTest, subscribeonEnabledChanged) { EnabledChanged enabledChanged; diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/unit/closedCaptionsTest.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/unit/closedCaptionsTest.cpp index 4d35aa587..20a8dbcef 100644 --- a/src/sdks/manage/src/cpp/sdk/cpptest/unit/closedCaptionsTest.cpp +++ b/src/sdks/manage/src/cpp/sdk/cpptest/unit/closedCaptionsTest.cpp @@ -3,9 +3,287 @@ class ClosedCaptionsTest : public ::testing::Test { protected: + JsonEngine *jsonEngine; Firebolt::Error error = Firebolt::Error::None; + + void SetUp() override + { + jsonEngine = new JsonEngine(); + } + + void TearDown() override + { + delete jsonEngine; + } }; +TEST_F(ClosedCaptionsTest, backgroundColor) +{ + std::string expectedValues = jsonEngine->get_value("ClosedCaptions.backgroundColor"); + std::string color = Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().backgroundColor(&error); + + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.backgroundColor() method"; + EXPECT_EQ(REMOVE_QUOTES(expectedValues), color) << "Error: wrong color returned by ClosedCaptionsInterface.backgroundColor()"; +} + +TEST_F(ClosedCaptionsTest, setBackgroundColor) +{ + std::string expected_background_color = "#00002"; + Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().setBackgroundColor(expected_background_color, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.setBackgroundColor() method"; +} + +TEST_F(ClosedCaptionsTest, backgroundOpacity) +{ + std::string expectedValues = jsonEngine->get_value("ClosedCaptions.backgroundOpacity"); + float opacity = Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().backgroundOpacity(&error); + + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.backgroundOpacity() method"; + EXPECT_EQ(stof(expectedValues), opacity) << "Error: wrong backgroundOpacity returned by ClosedCaptionsInterface.backgroundOpacity()"; +} + +TEST_F(ClosedCaptionsTest, setBackgroundOpacity) +{ + float expected_background_opacity = 70; + Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().setBackgroundOpacity(expected_background_opacity, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.setBackgroundOpacity() method"; +} + +TEST_F(ClosedCaptionsTest, setEnabled) +{ + Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().setEnabled(true, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.setEnabled() method"; +} + +TEST_F(ClosedCaptionsTest, setFontColor) +{ + std::string expected_font_color = "#FFFFFF"; + Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().setFontColor(expected_font_color, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.setFontColor() method"; +} + +TEST_F(ClosedCaptionsTest, fontColor) +{ + std::string expectedValues = jsonEngine->get_value("ClosedCaptions.fontColor"); + std::string color = Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().fontColor(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.fontColor() method"; + EXPECT_EQ(REMOVE_QUOTES(expectedValues), color) << "Error: wrong fontColor returned by ClosedCaptionsInterface.fontColor()"; +} + +TEST_F(ClosedCaptionsTest, setFontEdge) +{ + Firebolt::Accessibility::FontEdge expected_edge = Firebolt::Accessibility::FontEdge::UNIFORM; + Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().setFontEdge(expected_edge, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.setFontEdge() method"; +} + +TEST_F(ClosedCaptionsTest, fontEdge) +{ + std::string expectedValues = jsonEngine->get_value("ClosedCaptions.fontEdge"); + Firebolt::Accessibility::FontEdge edge = Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().fontEdge(&error); + + std::string actual_font_edge = "unknown"; + switch (edge) + { + case Firebolt::Accessibility::FontEdge::NONE: + actual_font_edge = "none"; + break; + case Firebolt::Accessibility::FontEdge::RAISED: + actual_font_edge = "raised"; + break; + case Firebolt::Accessibility::FontEdge::DEPRESSED: + actual_font_edge = "depressed"; + break; + case Firebolt::Accessibility::FontEdge::UNIFORM: + actual_font_edge = "uniform"; + break; + case Firebolt::Accessibility::FontEdge::DROP_SHADOW_LEFT: + actual_font_edge = "drop_shadow_left"; + break; + case Firebolt::Accessibility::FontEdge::DROP_SHADOW_RIGHT: + actual_font_edge = "drop_shadow_right"; + break; + default: + actual_font_edge = "unknown"; + } + + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.fontEdge() method"; + EXPECT_EQ(REMOVE_QUOTES(expectedValues), actual_font_edge) << "Error: wrong fontEdge returned by ClosedCaptionsInterface.fontEdge()"; +} + +TEST_F(ClosedCaptionsTest, setFontEdgeColor) +{ + std::string expected_color = "#FF5733"; + Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().setFontEdgeColor(expected_color, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.setFontEdgeColor() method"; +} + +TEST_F(ClosedCaptionsTest, fontEdgeColor) +{ + std::string expectedValues = jsonEngine->get_value("ClosedCaptions.fontEdgeColor"); + std::string color = Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().fontEdgeColor(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.fontEdgeColor() method"; + EXPECT_EQ(REMOVE_QUOTES(expectedValues), color) << "Error: wrong fontEdgeColor returned by ClosedCaptionsInterface.fontEdgeColor()"; +} + +TEST_F(ClosedCaptionsTest, setFontFamily) +{ + Firebolt::Accessibility::FontFamily expected_family = Firebolt::Accessibility::FontFamily::MONOSPACED_SANSERIF; + Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().setFontFamily(expected_family, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.setFontFamily() method"; +} + +TEST_F(ClosedCaptionsTest, fontFamily) +{ + std::string expectedValues = jsonEngine->get_value("ClosedCaptions.fontFamily"); + Firebolt::Accessibility::FontFamily family = Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().fontFamily(&error); + std::string actual_family = "unknown"; + switch (family) + { + case Firebolt::Accessibility::FontFamily::MONOSPACED_SERIF: + actual_family = "monospaced_serif"; + break; + case Firebolt::Accessibility::FontFamily::PROPORTIONAL_SERIF: + actual_family = "proportional_serif"; + break; + case Firebolt::Accessibility::FontFamily::MONOSPACED_SANSERIF: + actual_family = "monospaced_sanserif"; + break; + case Firebolt::Accessibility::FontFamily::PROPORTIONAL_SANSERIF: + actual_family = "proportional_sanserif"; + break; + case Firebolt::Accessibility::FontFamily::SMALLCAPS: + actual_family = "smallcaps"; + break; + case Firebolt::Accessibility::FontFamily::CURSIVE: + actual_family = "cursive"; + break; + case Firebolt::Accessibility::FontFamily::CASUAL: + actual_family = "casual"; + break; + default: + actual_family = "unknown"; + } + + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.fontFamily() method"; + EXPECT_EQ(REMOVE_QUOTES(expectedValues), actual_family) << "Error: wrong fontFamily returned by ClosedCaptionsInterface.fontFamily()"; +} + +TEST_F(ClosedCaptionsTest, setFontOpacity) +{ + float expected_opacity = 0.75f; + Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().setFontOpacity(expected_opacity, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.setFontOpacity() method"; +} + +TEST_F(ClosedCaptionsTest, fontOpacity) +{ + std::string expectedValues = jsonEngine->get_value("ClosedCaptions.fontOpacity"); + float opacity = Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().fontOpacity(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.fontOpacity() method"; + EXPECT_EQ(stof(expectedValues), opacity) << "Error: wrong fontOpacity returned by ClosedCaptionsInterface.fontOpacity()"; +} + +TEST_F(ClosedCaptionsTest, setFontSize) +{ + float expected_size = 12.5f; + Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().setFontSize(expected_size, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.setFontSize() method"; +} + +TEST_F(ClosedCaptionsTest, fontSize) +{ + std::string expectedValues = jsonEngine->get_value("ClosedCaptions.fontSize"); + float size = Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().fontSize(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.fontSize() method"; + EXPECT_EQ(stof(expectedValues), size) << "Error: wrong fontSize returned by ClosedCaptionsInterface.fontSize()"; +} + +TEST_F(ClosedCaptionsTest, setPreferredLanguages) +{ + std::vector expected_languages = {"spa", "eng"}; + Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().setPreferredLanguages(expected_languages, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.setPreferredLanguages() method"; +} + +TEST_F(ClosedCaptionsTest, preferredLanguages) +{ + std::string expectedValues = jsonEngine->get_value("ClosedCaptions.preferredLanguages"); + std::vector languages = Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().preferredLanguages(&error); + + // Convert vector to a string for comparison + std::string actual_languages; + for (const auto &lang : languages) + { + actual_languages += "\"" + lang + "\","; + } + actual_languages = actual_languages.substr(0, actual_languages.size() - 1); // Remove trailing comma + + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.preferredLanguages() method"; + EXPECT_EQ(REMOVE_QUOTES(expectedValues), actual_languages) << "Error: wrong preferredLanguages returned by ClosedCaptionsInterface.preferredLanguages()"; +} + +TEST_F(ClosedCaptionsTest, setTextAlign) +{ + std::string expected_alignment = "center"; + Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().setTextAlign(expected_alignment, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.setTextAlign() method"; +} + +TEST_F(ClosedCaptionsTest, textAlign) +{ + std::string expectedValues = jsonEngine->get_value("ClosedCaptions.textAlign"); + std::string alignment = Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().textAlign(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.textAlign() method"; + EXPECT_EQ(REMOVE_QUOTES(expectedValues), alignment) << "Error: wrong textAlign returned by ClosedCaptionsInterface.textAlign()"; +} + +TEST_F(ClosedCaptionsTest, setTextAlignVertical) +{ + std::string expected_alignment = "middle"; + Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().setTextAlignVertical(expected_alignment, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.setTextAlignVertical() method"; +} + +TEST_F(ClosedCaptionsTest, textAlignVertical) +{ + std::string expectedValues = jsonEngine->get_value("ClosedCaptions.textAlignVertical"); + std::string alignment = Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().textAlignVertical(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.textAlignVertical() method"; + EXPECT_EQ(REMOVE_QUOTES(expectedValues), alignment) << "Error: wrong textAlignVertical returned by ClosedCaptionsInterface.textAlignVertical()"; +} + +TEST_F(ClosedCaptionsTest, setWindowColor) +{ + std::string expected_color = "#000000"; + Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().setWindowColor(expected_color, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.setWindowColor() method"; +} + +TEST_F(ClosedCaptionsTest, windowColor) +{ + std::string expectedValues = jsonEngine->get_value("ClosedCaptions.windowColor"); + std::string color = Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().windowColor(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.windowColor() method"; + EXPECT_EQ(REMOVE_QUOTES(expectedValues), color) << "Error: wrong windowColor returned by ClosedCaptionsInterface.windowColor()"; +} + +TEST_F(ClosedCaptionsTest, setWindowOpacity) +{ + float expected_opacity = 0.85f; + Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().setWindowOpacity(expected_opacity, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.setWindowOpacity() method"; +} + +TEST_F(ClosedCaptionsTest, windowOpacity) +{ + std::string expectedValues = jsonEngine->get_value("ClosedCaptions.windowOpacity"); + float opacity = Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().windowOpacity(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling ClosedCaptionsInterface.windowOpacity() method"; + EXPECT_EQ(stof(expectedValues), opacity) << "Error: wrong windowOpacity returned by ClosedCaptionsInterface.windowOpacity()"; +} + +// Events related tests struct BackgroundColorChanged : public Firebolt::ClosedCaptions::IClosedCaptions::IOnBackgroundColorChangedNotification { void onBackgroundColorChanged(const std::string &) override; diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/unit/deviceTest.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/unit/deviceTest.cpp index cbfe68250..068be753b 100644 --- a/src/sdks/manage/src/cpp/sdk/cpptest/unit/deviceTest.cpp +++ b/src/sdks/manage/src/cpp/sdk/cpptest/unit/deviceTest.cpp @@ -3,9 +3,45 @@ class DeviceTest : public ::testing::Test { protected: + JsonEngine *jsonEngine; Firebolt::Error error = Firebolt::Error::None; + + void SetUp() override + { + jsonEngine = new JsonEngine(); + } + + void TearDown() override + { + delete jsonEngine; + } }; + +TEST_F(DeviceTest, setName) { + std::string expected_name = "MyDevice"; + Firebolt::IFireboltAccessor::Instance().DeviceInterface().setName(expected_name, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling DeviceInterface.setName() method"; +} + +TEST_F(DeviceTest, name) { + std::string expectedValues = jsonEngine->get_value("Device.name"); + std::string name = Firebolt::IFireboltAccessor::Instance().DeviceInterface().name(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling DeviceInterface.name() method"; + EXPECT_EQ(REMOVE_QUOTES(expectedValues), name) << "Error: wrong name returned by DeviceInterface.name()"; +} + +TEST_F(DeviceTest, provision) { + std::string accountId = "12345"; + std::string deviceId = "67890"; + std::optional distributorId = "distributor1"; + + Firebolt::IFireboltAccessor::Instance().DeviceInterface().provision(accountId, deviceId, distributorId, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling DeviceInterface.provision() method"; +} + + +// Events related tests struct DeviceNameSettings : public Firebolt::Device::IDevice::IOnDeviceNameChangedNotification { void onDeviceNameChanged(const std::string &) override; diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/unit/discoveryTest.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/unit/discoveryTest.cpp index 1d5e02b83..b466bd48b 100644 --- a/src/sdks/manage/src/cpp/sdk/cpptest/unit/discoveryTest.cpp +++ b/src/sdks/manage/src/cpp/sdk/cpptest/unit/discoveryTest.cpp @@ -6,41 +6,49 @@ class DiscoveryTest : public ::testing::Test Firebolt::Error error = Firebolt::Error::None; }; -struct SignInSettings : public Firebolt::Discovery::IDiscovery::IOnSignInNotification { - void onSignIn(const Firebolt::Discovery::Event&) override; +struct SignInSettings : public Firebolt::Discovery::IDiscovery::IOnSignInNotification +{ + void onSignIn(const Firebolt::Discovery::Event &) override; }; -void SignInSettings::onSignIn(const Firebolt::Discovery::Event& event) { +void SignInSettings::onSignIn(const Firebolt::Discovery::Event &event) +{ std::cout << "onSignIn event fired"; } -TEST_F(DiscoveryTest, subscribeOnSignIn) { +TEST_F(DiscoveryTest, subscribeOnSignIn) +{ SignInSettings signInSettings; Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().subscribe(signInSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to SignInSettings"; } -TEST_F(DiscoveryTest, unsubscribeOnSignIn) { +TEST_F(DiscoveryTest, unsubscribeOnSignIn) +{ SignInSettings signInSettings; Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().unsubscribe(signInSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in unsubscribing to SignInSettings"; } -struct SignOutSettings : public Firebolt::Discovery::IDiscovery::IOnSignOutNotification { - void onSignOut(const Firebolt::Discovery::Event&) override; +struct SignOutSettings : public Firebolt::Discovery::IDiscovery::IOnSignOutNotification +{ + void onSignOut(const Firebolt::Discovery::Event &) override; }; -void SignOutSettings::onSignOut(const Firebolt::Discovery::Event& event) { +void SignOutSettings::onSignOut(const Firebolt::Discovery::Event &event) +{ std::cout << "onSignOut event fired"; } -TEST_F(DiscoveryTest, subscribeOnSignOut) { +TEST_F(DiscoveryTest, subscribeOnSignOut) +{ SignOutSettings signOutSettings; Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().subscribe(signOutSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to SignOutSettings"; } -TEST_F(DiscoveryTest, unsubscribeOnSignOut) { +TEST_F(DiscoveryTest, unsubscribeOnSignOut) +{ SignOutSettings signOutSettings; Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().unsubscribe(signOutSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in unsubscribing to SignOutSettings"; diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/unit/hdmiInputTest.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/unit/hdmiInputTest.cpp index ef886214a..9869c5ad0 100644 --- a/src/sdks/manage/src/cpp/sdk/cpptest/unit/hdmiInputTest.cpp +++ b/src/sdks/manage/src/cpp/sdk/cpptest/unit/hdmiInputTest.cpp @@ -1,11 +1,211 @@ #include "unit.h" -class HdmiInputTest : public ::testing::Test +class HDMIInputTest : public ::testing::Test { protected: + JsonEngine *jsonEngine; Firebolt::Error error = Firebolt::Error::None; + + void SetUp() override + { + jsonEngine = new JsonEngine(); + } + + void TearDown() override + { + delete jsonEngine; + } }; +TEST_F(HDMIInputTest, setAutoLowLatencyModeCapable) +{ + std::string port = "HDMI1"; + bool expected_value = true; + Firebolt::IFireboltAccessor::Instance().HDMIInputInterface().setAutoLowLatencyModeCapable(port, expected_value, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling HDMIInputInterface.setAutoLowLatencyModeCapable() method"; +} + +TEST_F(HDMIInputTest, autoLowLatencyModeCapable) +{ + std::string port = "HDMI1"; + std::string expectedValues = jsonEngine->get_value("HDMIInput.autoLowLatencyModeCapable"); + bool enabled = Firebolt::IFireboltAccessor::Instance().HDMIInputInterface().autoLowLatencyModeCapable(port, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling HDMIInputInterface.autoLowLatencyModeCapable() method"; + EXPECT_EQ(REMOVE_QUOTES(expectedValues) == "true", enabled) << "Error: wrong autoLowLatencyModeCapable returned by HDMIInputInterface.autoLowLatencyModeCapable()"; +} + +TEST_F(HDMIInputTest, close) +{ + Firebolt::IFireboltAccessor::Instance().HDMIInputInterface().close(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling HDMIInputInterface.close() method"; +} + +TEST_F(HDMIInputTest, edidVersion) +{ + std::string port = "HDMI1"; + std::string expectedValues = jsonEngine->get_value("HDMIInput.edidVersion"); + Firebolt::HDMIInput::EDIDVersion edidVersion = Firebolt::IFireboltAccessor::Instance().HDMIInputInterface().edidVersion(port, &error); + + std::string actual_version; + switch (edidVersion) + { + case Firebolt::HDMIInput::EDIDVersion::V1_4: + actual_version = "1.4"; + break; + case Firebolt::HDMIInput::EDIDVersion::V2_0: + actual_version = "2.0"; + break; + case Firebolt::HDMIInput::EDIDVersion::UNKNOWN: + actual_version = "unknown"; + break; + default: + actual_version = "invalid_version"; + } + + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling HDMIInputInterface.edidVersion() method"; + EXPECT_EQ(REMOVE_QUOTES(expectedValues), actual_version) << "Error: wrong edidVersion returned by HDMIInputInterface.edidVersion()"; +} + +TEST_F(HDMIInputTest, setEdidVersion) +{ + std::string port = "HDMI1"; + Firebolt::HDMIInput::EDIDVersion expected_version = Firebolt::HDMIInput::EDIDVersion::V1_4; // Replace with appropriate enum value + Firebolt::IFireboltAccessor::Instance().HDMIInputInterface().setEdidVersion(port, expected_version, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling HDMIInputInterface.setEdidVersion() method"; +} + +TEST_F(HDMIInputTest, lowLatencyMode) +{ + std::string expectedValues = jsonEngine->get_value("HDMIInput.lowLatencyMode"); + bool enabled = Firebolt::IFireboltAccessor::Instance().HDMIInputInterface().lowLatencyMode(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling HDMIInputInterface.lowLatencyMode() method"; + EXPECT_EQ(REMOVE_QUOTES(expectedValues) == "true", enabled) << "Error: wrong lowLatencyMode returned by HDMIInputInterface.lowLatencyMode()"; +} + +TEST_F(HDMIInputTest, setLowLatencyMode) +{ + bool expected_value = true; + Firebolt::IFireboltAccessor::Instance().HDMIInputInterface().setLowLatencyMode(expected_value, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling HDMIInputInterface.setLowLatencyMode() method"; +} + +TEST_F(HDMIInputTest, open) +{ + std::string portId = "HDMI1"; + Firebolt::IFireboltAccessor::Instance().HDMIInputInterface().open(portId, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling HDMIInputInterface.open() method"; +} + +TEST_F(HDMIInputTest, port) +{ + std::string portId = "HDMI1"; + std::string expectedValues = jsonEngine->get_value("HDMIInput.port"); + Firebolt::HDMIInput::HDMIInputPort port = Firebolt::IFireboltAccessor::Instance().HDMIInputInterface().port(portId, &error); + + std::string actual_settings; + actual_settings += "\"arcCapable\":" + std::string(port.arcCapable ? "true" : "false") + ","; + actual_settings += "\"arcConnected\":" + std::string(port.arcConnected ? "true" : "false") + ","; + actual_settings += "\"autoLowLatencyModeCapable\":" + std::string(port.autoLowLatencyModeCapable ? "true" : "false") + ","; + actual_settings += "\"autoLowLatencyModeSignalled\":" + std::string(port.autoLowLatencyModeSignalled ? "true" : "false") + ","; + actual_settings += "\"connected\":" + std::string(port.connected ? "true" : "false") + ","; + + switch (port.edidVersion) + { + case Firebolt::HDMIInput::EDIDVersion::V1_4: + actual_settings += "\"edidVersion\":\"1.4\","; + break; + case Firebolt::HDMIInput::EDIDVersion::V2_0: + actual_settings += "\"edidVersion\":\"2.0\","; + break; + case Firebolt::HDMIInput::EDIDVersion::UNKNOWN: + actual_settings += "\"edidVersion\":unknown,"; + break; + default: + actual_settings += "\"edidVersion\":invalid,"; + } + actual_settings += "\"port\":\"" + std::string(port.port) + "\","; + + switch (port.signal) + { + case Firebolt::HDMIInput::HDMISignalStatus::NONE: + actual_settings += "\"signal\":\"none\""; + break; + case Firebolt::HDMIInput::HDMISignalStatus::STABLE: + actual_settings += "\"signal\":\"stable\""; + break; + case Firebolt::HDMIInput::HDMISignalStatus::UNSTABLE: + actual_settings += "\"signal\":\"unstable\""; + break; + case Firebolt::HDMIInput::HDMISignalStatus::UNSUPPORTED: + actual_settings += "\"signal\":\"unsupported\""; + break; + case Firebolt::HDMIInput::HDMISignalStatus::UNKNOWN: + actual_settings += "\"signal\":\"unknown\""; + break; + default: + actual_settings += "\"signal\":\"invalid\""; + } + + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling HDMIInputInterface.port() method"; + EXPECT_EQ(REMOVE_QUOTES(expectedValues), actual_settings) << "Error: wrong port returned by HDMIInputInterface.port()"; +} + +TEST_F(HDMIInputTest, ports) +{ + std::string expectedValues = jsonEngine->get_value("HDMIInput.ports"); + std::vector ports = Firebolt::IFireboltAccessor::Instance().HDMIInputInterface().ports(&error); + + Firebolt::HDMIInput::HDMIInputPort port = ports[0]; + std::string actual_settings = "{"; + actual_settings += "\"arcCapable\":" + std::string(port.arcCapable ? "true" : "false") + ","; + actual_settings += "\"arcConnected\":" + std::string(port.arcConnected ? "true" : "false") + ","; + actual_settings += "\"autoLowLatencyModeCapable\":" + std::string(port.autoLowLatencyModeCapable ? "true" : "false") + ","; + actual_settings += "\"autoLowLatencyModeSignalled\":" + std::string(port.autoLowLatencyModeSignalled ? "true" : "false") + ","; + actual_settings += "\"connected\":" + std::string(port.connected ? "true" : "false") + ","; + + switch (port.edidVersion) + { + case Firebolt::HDMIInput::EDIDVersion::V1_4: + actual_settings += "\"edidVersion\":\"1.4\","; + break; + case Firebolt::HDMIInput::EDIDVersion::V2_0: + actual_settings += "\"edidVersion\":\"2.0\","; + break; + case Firebolt::HDMIInput::EDIDVersion::UNKNOWN: + actual_settings += "\"edidVersion\":unknown,"; + break; + default: + actual_settings += "\"edidVersion\":invalid,"; + } + actual_settings += "\"port\":\"" + std::string(port.port) + "\","; + + switch (port.signal) + { + case Firebolt::HDMIInput::HDMISignalStatus::NONE: + actual_settings += "\"signal\":\"none\""; + break; + case Firebolt::HDMIInput::HDMISignalStatus::STABLE: + actual_settings += "\"signal\":\"stable\""; + break; + case Firebolt::HDMIInput::HDMISignalStatus::UNSTABLE: + actual_settings += "\"signal\":\"unstable\""; + break; + case Firebolt::HDMIInput::HDMISignalStatus::UNSUPPORTED: + actual_settings += "\"signal\":\"unsupported\""; + break; + case Firebolt::HDMIInput::HDMISignalStatus::UNKNOWN: + actual_settings += "\"signal\":\"unknown\""; + break; + default: + actual_settings += "\"signal\":\"invalid\""; + } + actual_settings += "}"; + + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling HDMIInputInterface.ports() method"; + EXPECT_EQ(REMOVE_QUOTES(expectedValues), actual_settings) << "Error: wrong ports returned by HDMIInputInterface.ports()"; +} + +// Events related tests struct AutoLowLatencyModeCapableSettings : public Firebolt::HDMIInput::IHDMIInput::IOnAutoLowLatencyModeCapableChangedNotification { void onAutoLowLatencyModeCapableChanged(const Firebolt::HDMIInput::AutoLowLatencyModeCapableChangedInfo &) override; @@ -16,14 +216,14 @@ void AutoLowLatencyModeCapableSettings::onAutoLowLatencyModeCapableChanged(const std::cout << "onAutoLowLatencyModeCapableChanged event fired"; } -TEST_F(HdmiInputTest, subscribeOnAutoLowLatencyModeCapableChanged) +TEST_F(HDMIInputTest, subscribeOnAutoLowLatencyModeCapableChanged) { AutoLowLatencyModeCapableSettings autoLowLatencySettings; Firebolt::IFireboltAccessor::Instance().HDMIInputInterface().subscribe(autoLowLatencySettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to AutoLowLatencyModeCapableSettings"; } -TEST_F(HdmiInputTest, unsubscribeOnAutoLowLatencyModeCapableChanged) +TEST_F(HDMIInputTest, unsubscribeOnAutoLowLatencyModeCapableChanged) { AutoLowLatencyModeCapableSettings autoLowLatencySettings; Firebolt::IFireboltAccessor::Instance().HDMIInputInterface().unsubscribe(autoLowLatencySettings, &error); @@ -40,14 +240,14 @@ void AutoLowLatencyModeSignalSettings::onAutoLowLatencyModeSignalChanged(const F std::cout << "onAutoLowLatencyModeSignalChanged event fired"; } -TEST_F(HdmiInputTest, subscribeOnAutoLowLatencyModeSignalChanged) +TEST_F(HDMIInputTest, subscribeOnAutoLowLatencyModeSignalChanged) { AutoLowLatencyModeSignalSettings autoLowLatencySignalSettings; Firebolt::IFireboltAccessor::Instance().HDMIInputInterface().subscribe(autoLowLatencySignalSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to AutoLowLatencyModeSignalSettings"; } -TEST_F(HdmiInputTest, unsubscribeOnAutoLowLatencyModeSignalChanged) +TEST_F(HDMIInputTest, unsubscribeOnAutoLowLatencyModeSignalChanged) { AutoLowLatencyModeSignalSettings autoLowLatencySignalSettings; Firebolt::IFireboltAccessor::Instance().HDMIInputInterface().unsubscribe(autoLowLatencySignalSettings, &error); @@ -64,14 +264,14 @@ void ConnectionSettings::onConnectionChanged(const Firebolt::HDMIInput::Connecti std::cout << "onConnectionChanged event fired"; } -TEST_F(HdmiInputTest, subscribeOnConnectionChanged) +TEST_F(HDMIInputTest, subscribeOnConnectionChanged) { ConnectionSettings connectionSettings; Firebolt::IFireboltAccessor::Instance().HDMIInputInterface().subscribe(connectionSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to ConnectionSettings"; } -TEST_F(HdmiInputTest, unsubscribeOnConnectionChanged) +TEST_F(HDMIInputTest, unsubscribeOnConnectionChanged) { ConnectionSettings connectionSettings; Firebolt::IFireboltAccessor::Instance().HDMIInputInterface().unsubscribe(connectionSettings, &error); @@ -88,14 +288,14 @@ void EdidVersionSettings::onEdidVersionChanged(const Firebolt::HDMIInput::EDIDVe std::cout << "onEdidVersionChanged event fired"; } -TEST_F(HdmiInputTest, subscribeOnEdidVersionChanged) +TEST_F(HDMIInputTest, subscribeOnEdidVersionChanged) { EdidVersionSettings edidVersionSettings; Firebolt::IFireboltAccessor::Instance().HDMIInputInterface().subscribe("port_name", edidVersionSettings, &error); // Replace "port_name" with actual port name EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to EdidVersionSettings"; } -TEST_F(HdmiInputTest, unsubscribeOnEdidVersionChanged) +TEST_F(HDMIInputTest, unsubscribeOnEdidVersionChanged) { EdidVersionSettings edidVersionSettings; Firebolt::IFireboltAccessor::Instance().HDMIInputInterface().unsubscribe(edidVersionSettings, &error); @@ -112,14 +312,14 @@ void LowLatencyModeSettings::onLowLatencyModeChanged(const bool mode) std::cout << "onLowLatencyModeChanged event fired"; } -TEST_F(HdmiInputTest, subscribeOnLowLatencyModeChanged) +TEST_F(HDMIInputTest, subscribeOnLowLatencyModeChanged) { LowLatencyModeSettings lowLatencySettings; Firebolt::IFireboltAccessor::Instance().HDMIInputInterface().subscribe(lowLatencySettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to LowLatencyModeSettings"; } -TEST_F(HdmiInputTest, unsubscribeOnLowLatencyModeChanged) +TEST_F(HDMIInputTest, unsubscribeOnLowLatencyModeChanged) { LowLatencyModeSettings lowLatencySettings; Firebolt::IFireboltAccessor::Instance().HDMIInputInterface().unsubscribe(lowLatencySettings, &error); @@ -136,14 +336,14 @@ void SignalSettings::onSignalChanged(const Firebolt::HDMIInput::SignalChangedInf std::cout << "onSignalChanged event fired"; } -TEST_F(HdmiInputTest, subscribeOnSignalChanged) +TEST_F(HDMIInputTest, subscribeOnSignalChanged) { SignalSettings signalSettings; Firebolt::IFireboltAccessor::Instance().HDMIInputInterface().subscribe(signalSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to SignalSettings"; } -TEST_F(HdmiInputTest, unsubscribeOnSignalChanged) +TEST_F(HDMIInputTest, unsubscribeOnSignalChanged) { SignalSettings signalSettings; Firebolt::IFireboltAccessor::Instance().HDMIInputInterface().unsubscribe(signalSettings, &error); diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/unit/keyboardTest.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/unit/keyboardTest.cpp new file mode 100644 index 000000000..786af9db2 --- /dev/null +++ b/src/sdks/manage/src/cpp/sdk/cpptest/unit/keyboardTest.cpp @@ -0,0 +1,80 @@ +#include "unit.h" + +using namespace Firebolt::Keyboard; + +struct KeyboardProvider : public IKeyboardProvider +{ +public: + KeyboardProvider(); + ~KeyboardProvider() override = default; + void standard(const KeyboardParameters ¶meters, std::unique_ptr session) override; + void password(const KeyboardParameters ¶meters, std::unique_ptr session) override; + void email(const KeyboardParameters ¶meters, std::unique_ptr session) override; + void SendMessage(bool response); + +private: + void startKeyboardSession(const KeyboardParameters ¶meters, std::unique_ptr session); + +private: + std::unique_ptr _session; + KeyboardParameters _parameters; + bool _keyInput; +}; + +class KeyboardTest : public ::testing::Test +{ +protected: + JsonEngine *jsonEngine; + Firebolt::Error error = Firebolt::Error::None; + KeyboardProvider _keyboardProvider; + + void SetUp() override + { + jsonEngine = new JsonEngine(); + } + + void TearDown() override + { + delete jsonEngine; + } +}; + +KeyboardProvider::KeyboardProvider() + : _session(nullptr), _parameters(), _keyInput(false) +{ +} + +void KeyboardProvider::standard(const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr session) +{ + std::cout << "KeyboardProvider Standard is invoked" << std::endl; + startKeyboardSession(parameters, std::move(session)); +} + +void KeyboardProvider::password(const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr session) +{ + std::cout << "KeyboardProvider Password is invoked" << std::endl; + startKeyboardSession(parameters, std::move(session)); +} + +void KeyboardProvider::email(const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr session) +{ + std::cout << "KeyboardProvider Email is invoked" << std::endl; + startKeyboardSession(parameters, std::move(session)); +} + +void KeyboardProvider::SendMessage(bool response) +{ +} + +void KeyboardProvider::startKeyboardSession(const KeyboardParameters ¶meters, std::unique_ptr session) +{ + _session = std::move(session); + _parameters = parameters; + _keyInput = true; +} + +TEST_F(KeyboardTest, registerKeyboardProvider) +{ + Firebolt::IFireboltAccessor::Instance().KeyboardInterface().provide(_keyboardProvider); +} + diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/unit/localizationTest.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/unit/localizationTest.cpp index 003bddf12..fe813d3f1 100644 --- a/src/sdks/manage/src/cpp/sdk/cpptest/unit/localizationTest.cpp +++ b/src/sdks/manage/src/cpp/sdk/cpptest/unit/localizationTest.cpp @@ -3,148 +3,334 @@ class LocalizationTest : public ::testing::Test { protected: + JsonEngine *jsonEngine; Firebolt::Error error = Firebolt::Error::None; + + void SetUp() override + { + jsonEngine = new JsonEngine(); + } + + void TearDown() override + { + delete jsonEngine; + } }; -struct CountryCodeSettings : public Firebolt::Localization::ILocalization::IOnCountryCodeChangedNotification { +TEST_F(LocalizationTest, addAdditionalInfo) +{ + std::string key = "sampleKey"; + float value = 1.23f; + Firebolt::IFireboltAccessor::Instance().LocalizationInterface().addAdditionalInfo(key, value, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling LocalizationInterface.addAdditionalInfo() method"; +} + +TEST_F(LocalizationTest, additionalInfo) +{ + std::string expectedValues = jsonEngine->get_value("Localization.additionalInfo"); + Firebolt::Localization::Info info = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().additionalInfo(&error); + + std::string actual_info; + for (const auto &item : info) + { + actual_info += item.first + "=" + std::to_string(item.second) + ","; + } + actual_info = actual_info.substr(0, actual_info.size() - 1); + + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling LocalizationInterface.additionalInfo() method"; + EXPECT_EQ(REMOVE_QUOTES(expectedValues), actual_info) << "Error: wrong additionalInfo returned by LocalizationInterface.additionalInfo()"; +} + +TEST_F(LocalizationTest, setCountryCode) +{ + std::string expected_value = "US"; + Firebolt::IFireboltAccessor::Instance().LocalizationInterface().setCountryCode(expected_value, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling LocalizationInterface.setCountryCode() method"; +} + +TEST_F(LocalizationTest, countryCode) +{ + std::string expectedValues = jsonEngine->get_value("Localization.countryCode"); + std::string code = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().countryCode(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling LocalizationInterface.countryCode() method"; + EXPECT_EQ(REMOVE_QUOTES(expectedValues), code) << "Error: wrong countryCode returned by LocalizationInterface.countryCode()"; +} + +TEST_F(LocalizationTest, setLanguage) +{ + std::string expected_value = "en"; + Firebolt::IFireboltAccessor::Instance().LocalizationInterface().setLanguage(expected_value, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling LocalizationInterface.setLanguage() method"; +} + +TEST_F(LocalizationTest, language) +{ + std::string expectedValues = jsonEngine->get_value("Localization.language"); + std::string lang = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().language(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling LocalizationInterface.language() method"; + EXPECT_EQ(REMOVE_QUOTES(expectedValues), lang) << "Error: wrong language returned by LocalizationInterface.language()"; +} + +TEST_F(LocalizationTest, setLocale) +{ + std::string expected_value = "en-US"; + Firebolt::IFireboltAccessor::Instance().LocalizationInterface().setLocale(expected_value, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling LocalizationInterface.setLocale() method"; +} + +TEST_F(LocalizationTest, locale) +{ + std::string expectedValues = jsonEngine->get_value("Localization.locale"); + std::string locale = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().locale(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling LocalizationInterface.locale() method"; + EXPECT_EQ(REMOVE_QUOTES(expectedValues), locale) << "Error: wrong locale returned by LocalizationInterface.locale()"; +} + +TEST_F(LocalizationTest, setLocality) +{ + std::string expected_value = "Rockville"; + Firebolt::IFireboltAccessor::Instance().LocalizationInterface().setLocality(expected_value, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling LocalizationInterface.setLocality() method"; +} + +TEST_F(LocalizationTest, locality) +{ + std::string expectedValues = jsonEngine->get_value("Localization.locality"); + std::string locality = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().locality(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling LocalizationInterface.locality() method"; + EXPECT_EQ(REMOVE_QUOTES(expectedValues), locality) << "Error: wrong locality returned by LocalizationInterface.locality()"; +} + +TEST_F(LocalizationTest, setPostalCode) +{ + std::string expected_value = "20850"; + Firebolt::IFireboltAccessor::Instance().LocalizationInterface().setPostalCode(expected_value, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling LocalizationInterface.setPostalCode() method"; +} + +TEST_F(LocalizationTest, postalCode) +{ + std::string expectedValues = jsonEngine->get_value("Localization.postalCode"); + std::string postalCode = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().postalCode(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling LocalizationInterface.postalCode() method"; + EXPECT_EQ(REMOVE_QUOTES(expectedValues), postalCode) << "Error: wrong postalCode returned by LocalizationInterface.postalCode()"; +} + +TEST_F(LocalizationTest, setPreferredAudioLanguages) +{ + std::vector expected_languages = {"eng", "spa"}; + Firebolt::IFireboltAccessor::Instance().LocalizationInterface().setPreferredAudioLanguages(expected_languages, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling LocalizationInterface.setPreferredAudioLanguages() method"; +} + +TEST_F(LocalizationTest, preferredAudioLanguages) +{ + std::string expectedValues = jsonEngine->get_value("Localization.preferredAudioLanguages"); + std::vector languages = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().preferredAudioLanguages(&error); + + std::string actual_languages = "["; + for (const auto &lang : languages) + { + actual_languages += "\"" + lang + "\","; + } + actual_languages = actual_languages.substr(0, actual_languages.size() - 1); // Remove trailing comma + actual_languages += "]"; + + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling LocalizationInterface.preferredAudioLanguages() method"; + EXPECT_EQ(expectedValues, actual_languages) << "Error: wrong preferredAudioLanguages returned by LocalizationInterface.preferredAudioLanguages()"; +} + +TEST_F(LocalizationTest, removeAdditionalInfo) +{ + std::string key = "sampleKey"; + Firebolt::IFireboltAccessor::Instance().LocalizationInterface().removeAdditionalInfo(key, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling LocalizationInterface.removeAdditionalInfo() method"; +} + +TEST_F(LocalizationTest, setTimeZone) +{ + std::string expected_value = "America/Los_Angeles"; + Firebolt::IFireboltAccessor::Instance().LocalizationInterface().setTimeZone(expected_value, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling LocalizationInterface.setTimeZone() method"; +} + +TEST_F(LocalizationTest, timeZone) +{ + std::string expectedValues = jsonEngine->get_value("Localization.timeZone"); + std::string timeZone = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().timeZone(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling LocalizationInterface.timeZone() method"; + EXPECT_EQ(REMOVE_QUOTES(expectedValues), timeZone) << "Error: wrong timeZone returned by LocalizationInterface.timeZone()"; +} + +// Events tests +struct CountryCodeSettings : public Firebolt::Localization::ILocalization::IOnCountryCodeChangedNotification +{ void onCountryCodeChanged(const std::string &) override; }; -void CountryCodeSettings::onCountryCodeChanged(const std::string &code) { +void CountryCodeSettings::onCountryCodeChanged(const std::string &code) +{ std::cout << "onCountryCodeChanged event fired"; } -TEST_F(LocalizationTest, subscribeOnCountryCodeChanged) { +TEST_F(LocalizationTest, subscribeOnCountryCodeChanged) +{ CountryCodeSettings countryCodeSettings; Firebolt::IFireboltAccessor::Instance().LocalizationInterface().subscribe(countryCodeSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to CountryCodeSettings"; } -TEST_F(LocalizationTest, unsubscribeOnCountryCodeChanged) { +TEST_F(LocalizationTest, unsubscribeOnCountryCodeChanged) +{ CountryCodeSettings countryCodeSettings; Firebolt::IFireboltAccessor::Instance().LocalizationInterface().unsubscribe(countryCodeSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in unsubscribing to CountryCodeSettings"; } -struct LanguageSettings : public Firebolt::Localization::ILocalization::IOnLanguageChangedNotification { +struct LanguageSettings : public Firebolt::Localization::ILocalization::IOnLanguageChangedNotification +{ void onLanguageChanged(const std::string &) override; }; -void LanguageSettings::onLanguageChanged(const std::string &language) { +void LanguageSettings::onLanguageChanged(const std::string &language) +{ std::cout << "onLanguageChanged event fired with language: " << language; } -TEST_F(LocalizationTest, subscribeOnLanguageChanged) { +TEST_F(LocalizationTest, subscribeOnLanguageChanged) +{ LanguageSettings languageSettings; Firebolt::IFireboltAccessor::Instance().LocalizationInterface().subscribe(languageSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to LanguageSettings"; } -TEST_F(LocalizationTest, unsubscribeOnLanguageChanged) { +TEST_F(LocalizationTest, unsubscribeOnLanguageChanged) +{ LanguageSettings languageSettings; Firebolt::IFireboltAccessor::Instance().LocalizationInterface().unsubscribe(languageSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in unsubscribing to LanguageSettings"; } -struct LocaleSettings : public Firebolt::Localization::ILocalization::IOnLocaleChangedNotification { +struct LocaleSettings : public Firebolt::Localization::ILocalization::IOnLocaleChangedNotification +{ void onLocaleChanged(const std::string &) override; }; -void LocaleSettings::onLocaleChanged(const std::string &locale) { +void LocaleSettings::onLocaleChanged(const std::string &locale) +{ std::cout << "onLocaleChanged event fired with locale: " << locale; } -TEST_F(LocalizationTest, subscribeOnLocaleChanged) { +TEST_F(LocalizationTest, subscribeOnLocaleChanged) +{ LocaleSettings localeSettings; Firebolt::IFireboltAccessor::Instance().LocalizationInterface().subscribe(localeSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to LocaleSettings"; } -TEST_F(LocalizationTest, unsubscribeOnLocaleChanged) { +TEST_F(LocalizationTest, unsubscribeOnLocaleChanged) +{ LocaleSettings localeSettings; Firebolt::IFireboltAccessor::Instance().LocalizationInterface().unsubscribe(localeSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in unsubscribing to LocaleSettings"; } -struct LocalitySettings : public Firebolt::Localization::ILocalization::IOnLocalityChangedNotification { +struct LocalitySettings : public Firebolt::Localization::ILocalization::IOnLocalityChangedNotification +{ void onLocalityChanged(const std::string &) override; }; -void LocalitySettings::onLocalityChanged(const std::string &locality) { +void LocalitySettings::onLocalityChanged(const std::string &locality) +{ std::cout << "onLocalityChanged event fired with locality: " << locality; } -TEST_F(LocalizationTest, subscribeOnLocalityChanged) { +TEST_F(LocalizationTest, subscribeOnLocalityChanged) +{ LocalitySettings localitySettings; Firebolt::IFireboltAccessor::Instance().LocalizationInterface().subscribe(localitySettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to LocalitySettings"; } -TEST_F(LocalizationTest, unsubscribeOnLocalityChanged) { +TEST_F(LocalizationTest, unsubscribeOnLocalityChanged) +{ LocalitySettings localitySettings; Firebolt::IFireboltAccessor::Instance().LocalizationInterface().unsubscribe(localitySettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in unsubscribing to LocalitySettings"; } -struct PostalCodeSettings : public Firebolt::Localization::ILocalization::IOnPostalCodeChangedNotification { +struct PostalCodeSettings : public Firebolt::Localization::ILocalization::IOnPostalCodeChangedNotification +{ void onPostalCodeChanged(const std::string &) override; }; -void PostalCodeSettings::onPostalCodeChanged(const std::string &postalCode) { +void PostalCodeSettings::onPostalCodeChanged(const std::string &postalCode) +{ std::cout << "onPostalCodeChanged event fired with postal code: " << postalCode; } -TEST_F(LocalizationTest, subscribeOnPostalCodeChanged) { +TEST_F(LocalizationTest, subscribeOnPostalCodeChanged) +{ PostalCodeSettings postalCodeSettings; Firebolt::IFireboltAccessor::Instance().LocalizationInterface().subscribe(postalCodeSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to PostalCodeSettings"; } -TEST_F(LocalizationTest, unsubscribeOnPostalCodeChanged) { +TEST_F(LocalizationTest, unsubscribeOnPostalCodeChanged) +{ PostalCodeSettings postalCodeSettings; Firebolt::IFireboltAccessor::Instance().LocalizationInterface().unsubscribe(postalCodeSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in unsubscribing to PostalCodeSettings"; } -struct PreferredAudioLanguagesSettings : public Firebolt::Localization::ILocalization::IOnPreferredAudioLanguagesChangedNotification { - void onPreferredAudioLanguagesChanged(const std::vector&) override; +struct PreferredAudioLanguagesSettings : public Firebolt::Localization::ILocalization::IOnPreferredAudioLanguagesChangedNotification +{ + void onPreferredAudioLanguagesChanged(const std::vector &) override; }; -void PreferredAudioLanguagesSettings::onPreferredAudioLanguagesChanged(const std::vector& languages) { +void PreferredAudioLanguagesSettings::onPreferredAudioLanguagesChanged(const std::vector &languages) +{ std::cout << "onPreferredAudioLanguagesChanged event fired with languages: "; - for(const auto& lang : languages) { + for (const auto &lang : languages) + { std::cout << lang << " "; } std::cout << std::endl; } -TEST_F(LocalizationTest, subscribeOnPreferredAudioLanguagesChanged) { +TEST_F(LocalizationTest, subscribeOnPreferredAudioLanguagesChanged) +{ PreferredAudioLanguagesSettings preferredAudioLanguagesSettings; Firebolt::IFireboltAccessor::Instance().LocalizationInterface().subscribe(preferredAudioLanguagesSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to PreferredAudioLanguagesSettings"; } -TEST_F(LocalizationTest, unsubscribeOnPreferredAudioLanguagesChanged) { +TEST_F(LocalizationTest, unsubscribeOnPreferredAudioLanguagesChanged) +{ PreferredAudioLanguagesSettings preferredAudioLanguagesSettings; Firebolt::IFireboltAccessor::Instance().LocalizationInterface().unsubscribe(preferredAudioLanguagesSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in unsubscribing to PreferredAudioLanguagesSettings"; } -struct TimeZoneSettings : public Firebolt::Localization::ILocalization::IOnTimeZoneChangedNotification { +struct TimeZoneSettings : public Firebolt::Localization::ILocalization::IOnTimeZoneChangedNotification +{ void onTimeZoneChanged(const std::string &) override; }; -void TimeZoneSettings::onTimeZoneChanged(const std::string &timeZone) { +void TimeZoneSettings::onTimeZoneChanged(const std::string &timeZone) +{ std::cout << "onTimeZoneChanged event fired with time zone: " << timeZone; } -TEST_F(LocalizationTest, subscribeOnTimeZoneChanged) { +TEST_F(LocalizationTest, subscribeOnTimeZoneChanged) +{ TimeZoneSettings timeZoneSettings; Firebolt::IFireboltAccessor::Instance().LocalizationInterface().subscribe(timeZoneSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to TimeZoneSettings"; } -TEST_F(LocalizationTest, unsubscribeOnTimeZoneChanged) { +TEST_F(LocalizationTest, unsubscribeOnTimeZoneChanged) +{ TimeZoneSettings timeZoneSettings; Firebolt::IFireboltAccessor::Instance().LocalizationInterface().unsubscribe(timeZoneSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in unsubscribing to TimeZoneSettings"; diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/unit/metricsTest.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/unit/metricsTest.cpp new file mode 100644 index 000000000..1db1c8065 --- /dev/null +++ b/src/sdks/manage/src/cpp/sdk/cpptest/unit/metricsTest.cpp @@ -0,0 +1,28 @@ +#include "unit.h" + +class MetricsTest : public ::testing::Test +{ +protected: + JsonEngine *jsonEngine; + Firebolt::Error error = Firebolt::Error::None; + + void SetUp() override + { + jsonEngine = new JsonEngine(); + } + + void TearDown() override + { + delete jsonEngine; + } +}; + +TEST_F(MetricsTest, event) +{ + std::string schema = "http://example.com/schema"; + Firebolt::Metrics::EventObject data; + Firebolt::Error error = Firebolt::Error::None; + + Firebolt::IFireboltAccessor::Instance().MetricsInterface().event(schema, data, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling MetricsInterface.event() method"; +} diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/unit/pinChallengeTest.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/unit/pinChallengeTest.cpp new file mode 100644 index 000000000..c28a93ee0 --- /dev/null +++ b/src/sdks/manage/src/cpp/sdk/cpptest/unit/pinChallengeTest.cpp @@ -0,0 +1,65 @@ +#include "unit.h" + +using namespace Firebolt::PinChallenge; + +struct PinChallengeProvider : public IPinChallengeProvider +{ +public: + PinChallengeProvider(); + ~PinChallengeProvider() override = default; + void challenge(const PinChallenge ¶meters, std::unique_ptr session) override; + void SendMessage(bool response); + +private: + void startPinChallengeSession(const PinChallenge ¶meters, std::unique_ptr session); + +private: + std::unique_ptr _session; + PinChallenge _parameters; + bool _challengeInput; +}; + +class PinChallengeTest : public ::testing::Test +{ +protected: + JsonEngine *jsonEngine; + Firebolt::Error error = Firebolt::Error::None; + PinChallengeProvider _pinChallengeProvider; + + void SetUp() override + { + jsonEngine = new JsonEngine(); + } + + void TearDown() override + { + delete jsonEngine; + } +}; + +PinChallengeProvider::PinChallengeProvider() + : _session(nullptr), _parameters(), _challengeInput(false) +{ +} + +void PinChallengeProvider::SendMessage(bool response) +{ +} + +void PinChallengeProvider::challenge(const PinChallenge ¶meters, std::unique_ptr session) +{ + std::cout << "PinChallengeProvider challenge is invoked" << std::endl; + startPinChallengeSession(parameters, std::move(session)); +} + +void PinChallengeProvider::startPinChallengeSession(const PinChallenge ¶meters, std::unique_ptr session) +{ + _session = std::move(session); + _parameters = parameters; + _challengeInput = true; +} + +TEST_F(PinChallengeTest, registerPinChallengeProvider) +{ + Firebolt::IFireboltAccessor::Instance().PinChallengeInterface().provide(_pinChallengeProvider); +} \ No newline at end of file diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/unit/privacyTest.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/unit/privacyTest.cpp index d85c4c78d..d6717873c 100644 --- a/src/sdks/manage/src/cpp/sdk/cpptest/unit/privacyTest.cpp +++ b/src/sdks/manage/src/cpp/sdk/cpptest/unit/privacyTest.cpp @@ -3,244 +3,501 @@ class PrivacyTest : public ::testing::Test { protected: + JsonEngine *jsonEngine; Firebolt::Error error = Firebolt::Error::None; + + void SetUp() override + { + jsonEngine = new JsonEngine(); + } + + void TearDown() override + { + delete jsonEngine; + } }; -struct AllowACRCollectionSettings : public Firebolt::Privacy::IPrivacy::IOnAllowACRCollectionChangedNotification { +TEST_F(PrivacyTest, setAllowACRCollection) +{ + bool expected_value = true; + Firebolt::IFireboltAccessor::Instance().PrivacyInterface().setAllowACRCollection(expected_value, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling PrivacyInterface.setAllowACRCollection() method"; +} + +TEST_F(PrivacyTest, allowACRCollection) +{ + std::string expectedValues = jsonEngine->get_value("Privacy.allowACRCollection"); + bool allow = Firebolt::IFireboltAccessor::Instance().PrivacyInterface().allowACRCollection(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling PrivacyInterface.allowACRCollection() method"; + EXPECT_EQ(expectedValues == "true", allow) << "Error: wrong allowACRCollection returned by PrivacyInterface.allowACRCollection()"; +} + +TEST_F(PrivacyTest, setAllowAppContentAdTargeting) +{ + bool expected_value = true; + Firebolt::IFireboltAccessor::Instance().PrivacyInterface().setAllowAppContentAdTargeting(expected_value, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling PrivacyInterface.setAllowAppContentAdTargeting() method"; +} + +TEST_F(PrivacyTest, allowAppContentAdTargeting) +{ + std::string expectedValues = jsonEngine->get_value("Privacy.allowAppContentAdTargeting"); + bool allow = Firebolt::IFireboltAccessor::Instance().PrivacyInterface().allowAppContentAdTargeting(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling PrivacyInterface.allowAppContentAdTargeting() method"; + EXPECT_EQ(expectedValues == "true", allow) << "Error: wrong allowAppContentAdTargeting returned by PrivacyInterface.allowAppContentAdTargeting()"; +} + +TEST_F(PrivacyTest, setAllowCameraAnalytics) +{ + bool expected_value = true; + Firebolt::IFireboltAccessor::Instance().PrivacyInterface().setAllowCameraAnalytics(expected_value, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling PrivacyInterface.setAllowCameraAnalytics() method"; +} + +TEST_F(PrivacyTest, allowCameraAnalytics) +{ + std::string expectedValues = jsonEngine->get_value("Privacy.allowCameraAnalytics"); + bool allow = Firebolt::IFireboltAccessor::Instance().PrivacyInterface().allowCameraAnalytics(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling PrivacyInterface.allowCameraAnalytics() method"; + EXPECT_EQ(expectedValues == "true", allow) << "Error: wrong allowCameraAnalytics returned by PrivacyInterface.allowCameraAnalytics()"; +} + +TEST_F(PrivacyTest, setAllowPersonalization) +{ + bool expected_value = true; + Firebolt::IFireboltAccessor::Instance().PrivacyInterface().setAllowPersonalization(expected_value, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling PrivacyInterface.setAllowPersonalization() method"; +} + +TEST_F(PrivacyTest, allowPersonalization) +{ + std::string expectedValues = jsonEngine->get_value("Privacy.allowPersonalization"); + bool allow = Firebolt::IFireboltAccessor::Instance().PrivacyInterface().allowPersonalization(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling PrivacyInterface.allowPersonalization() method"; + EXPECT_EQ(expectedValues == "true", allow) << "Error: wrong allowPersonalization returned by PrivacyInterface.allowPersonalization()"; +} + +TEST_F(PrivacyTest, setAllowPrimaryBrowseAdTargeting) +{ + bool expected_value = true; + Firebolt::IFireboltAccessor::Instance().PrivacyInterface().setAllowPrimaryBrowseAdTargeting(expected_value, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling PrivacyInterface.setAllowPrimaryBrowseAdTargeting() method"; +} + +TEST_F(PrivacyTest, allowPrimaryBrowseAdTargeting) +{ + std::string expectedValues = jsonEngine->get_value("Privacy.allowPrimaryBrowseAdTargeting"); + bool allow = Firebolt::IFireboltAccessor::Instance().PrivacyInterface().allowPrimaryBrowseAdTargeting(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling PrivacyInterface.allowPrimaryBrowseAdTargeting() method"; + EXPECT_EQ(expectedValues == "true", allow) << "Error: wrong allowPrimaryBrowseAdTargeting returned by PrivacyInterface.allowPrimaryBrowseAdTargeting()"; +} + +TEST_F(PrivacyTest, setAllowPrimaryContentAdTargeting) +{ + bool expected_value = true; + Firebolt::IFireboltAccessor::Instance().PrivacyInterface().setAllowPrimaryContentAdTargeting(expected_value, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling PrivacyInterface.setAllowPrimaryContentAdTargeting() method"; +} + +TEST_F(PrivacyTest, allowPrimaryContentAdTargeting) +{ + std::string expectedValues = jsonEngine->get_value("Privacy.allowPrimaryContentAdTargeting"); + bool allow = Firebolt::IFireboltAccessor::Instance().PrivacyInterface().allowPrimaryContentAdTargeting(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling PrivacyInterface.allowPrimaryContentAdTargeting() method"; + EXPECT_EQ(expectedValues == "true", allow) << "Error: wrong allowPrimaryContentAdTargeting returned by PrivacyInterface.allowPrimaryContentAdTargeting()"; +} + +TEST_F(PrivacyTest, setAllowProductAnalytics) +{ + bool expected_value = true; + Firebolt::IFireboltAccessor::Instance().PrivacyInterface().setAllowProductAnalytics(expected_value, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling PrivacyInterface.setAllowProductAnalytics() method"; +} + +TEST_F(PrivacyTest, allowProductAnalytics) +{ + std::string expectedValues = jsonEngine->get_value("Privacy.allowProductAnalytics"); + bool allow = Firebolt::IFireboltAccessor::Instance().PrivacyInterface().allowProductAnalytics(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling PrivacyInterface.allowProductAnalytics() method"; + EXPECT_EQ(expectedValues == "true", allow) << "Error: wrong allowProductAnalytics returned by PrivacyInterface.allowProductAnalytics()"; +} + +TEST_F(PrivacyTest, setAllowRemoteDiagnostics) +{ + bool expected_value = true; + Firebolt::IFireboltAccessor::Instance().PrivacyInterface().setAllowRemoteDiagnostics(expected_value, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling PrivacyInterface.setAllowRemoteDiagnostics() method"; +} + +TEST_F(PrivacyTest, allowResumePoints) +{ + std::string expectedValues = jsonEngine->get_value("Privacy.allowResumePoints"); + bool allow = Firebolt::IFireboltAccessor::Instance().PrivacyInterface().allowResumePoints(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling PrivacyInterface.allowResumePoints() method"; + EXPECT_EQ(expectedValues == "true", allow) << "Error: wrong allowResumePoints returned by PrivacyInterface.allowResumePoints()"; +} + +TEST_F(PrivacyTest, setAllowResumePoints) +{ + bool expected_value = true; + Firebolt::IFireboltAccessor::Instance().PrivacyInterface().setAllowResumePoints(expected_value, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling PrivacyInterface.setAllowResumePoints() method"; +} + +TEST_F(PrivacyTest, allowUnentitledPersonalization) +{ + std::string expectedValues = jsonEngine->get_value("Privacy.allowUnentitledPersonalization"); + bool allow = Firebolt::IFireboltAccessor::Instance().PrivacyInterface().allowUnentitledPersonalization(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling PrivacyInterface.allowUnentitledPersonalization() method"; + EXPECT_EQ(expectedValues == "true", allow) << "Error: wrong allowUnentitledPersonalization returned by PrivacyInterface.allowUnentitledPersonalization()"; +} + +TEST_F(PrivacyTest, setAllowUnentitledPersonalization) +{ + bool expected_value = true; + Firebolt::IFireboltAccessor::Instance().PrivacyInterface().setAllowUnentitledPersonalization(expected_value, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling PrivacyInterface.setAllowUnentitledPersonalization() method"; +} + +TEST_F(PrivacyTest, allowUnentitledResumePoints) +{ + std::string expectedValues = jsonEngine->get_value("Privacy.allowUnentitledResumePoints"); + bool allow = Firebolt::IFireboltAccessor::Instance().PrivacyInterface().allowUnentitledResumePoints(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling PrivacyInterface.allowUnentitledResumePoints() method"; + EXPECT_EQ(expectedValues == "true", allow) << "Error: wrong allowUnentitledResumePoints returned by PrivacyInterface.allowUnentitledResumePoints()"; +} + +TEST_F(PrivacyTest, setAllowUnentitledResumePoints) +{ + bool expected_value = true; + Firebolt::IFireboltAccessor::Instance().PrivacyInterface().setAllowUnentitledResumePoints(expected_value, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling PrivacyInterface.setAllowUnentitledResumePoints() method"; +} + +TEST_F(PrivacyTest, allowWatchHistory) +{ + std::string expectedValues = jsonEngine->get_value("Privacy.allowWatchHistory"); + bool allow = Firebolt::IFireboltAccessor::Instance().PrivacyInterface().allowWatchHistory(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling PrivacyInterface.allowWatchHistory() method"; + EXPECT_EQ(expectedValues == "true", allow) << "Error: wrong allowWatchHistory returned by PrivacyInterface.allowWatchHistory()"; +} + +TEST_F(PrivacyTest, setAllowWatchHistory) +{ + bool expected_value = true; + Firebolt::IFireboltAccessor::Instance().PrivacyInterface().setAllowWatchHistory(expected_value, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling PrivacyInterface.setAllowWatchHistory() method"; +} + +TEST_F(PrivacyTest, settings) +{ + + std::string expectedValues = jsonEngine->get_value("Privacy.settings"); + + Firebolt::Privacy::PrivacySettings settings = Firebolt::IFireboltAccessor::Instance().PrivacyInterface().settings(&error); + + std::string actual_settings = "{"; + actual_settings += "\"allowACRCollection\":" + std::string(settings.allowACRCollection ? "true" : "false") + ","; + actual_settings += "\"allowAppContentAdTargeting\":" + std::string(settings.allowAppContentAdTargeting ? "true" : "false") + ","; + actual_settings += "\"allowCameraAnalytics\":" + std::string(settings.allowCameraAnalytics ? "true" : "false") + ","; + actual_settings += "\"allowPersonalization\":" + std::string(settings.allowPersonalization ? "true" : "false") + ","; + actual_settings += "\"allowPrimaryBrowseAdTargeting\":" + std::string(settings.allowPrimaryBrowseAdTargeting ? "true" : "false") + ","; + actual_settings += "\"allowPrimaryContentAdTargeting\":" + std::string(settings.allowPrimaryContentAdTargeting ? "true" : "false") + ","; + actual_settings += "\"allowProductAnalytics\":" + std::string(settings.allowProductAnalytics ? "true" : "false") + ","; + actual_settings += "\"allowRemoteDiagnostics\":" + std::string(settings.allowRemoteDiagnostics ? "true" : "false") + ","; + actual_settings += "\"allowResumePoints\":" + std::string(settings.allowResumePoints ? "true" : "false") + ","; + actual_settings += "\"allowUnentitledPersonalization\":" + std::string(settings.allowUnentitledPersonalization ? "true" : "false") + ","; + actual_settings += "\"allowUnentitledResumePoints\":" + std::string(settings.allowUnentitledResumePoints ? "true" : "false") + ","; + actual_settings += "\"allowWatchHistory\":" + std::string(settings.allowWatchHistory ? "true" : "false"); + actual_settings += "}"; + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling PrivacyInterface.settings() method"; + EXPECT_EQ(expectedValues, actual_settings) << "Error: wrong settings returned by PrivacyInterface.settings()"; +} + +// Events Tests +struct AllowACRCollectionSettings : public Firebolt::Privacy::IPrivacy::IOnAllowACRCollectionChangedNotification +{ void onAllowACRCollectionChanged(const bool) override; }; -void AllowACRCollectionSettings::onAllowACRCollectionChanged(const bool isAllowed) { +void AllowACRCollectionSettings::onAllowACRCollectionChanged(const bool isAllowed) +{ std::cout << "onAllowACRCollectionChanged event fired with isAllowed: " << isAllowed; } -TEST_F(PrivacyTest, subscribeOnAllowACRCollectionChanged) { +TEST_F(PrivacyTest, subscribeOnAllowACRCollectionChanged) +{ AllowACRCollectionSettings allowACRCollectionSettings; Firebolt::IFireboltAccessor::Instance().PrivacyInterface().subscribe(allowACRCollectionSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to AllowACRCollectionSettings"; } -TEST_F(PrivacyTest, unsubscribeOnAllowACRCollectionChanged) { +TEST_F(PrivacyTest, unsubscribeOnAllowACRCollectionChanged) +{ AllowACRCollectionSettings allowACRCollectionSettings; Firebolt::IFireboltAccessor::Instance().PrivacyInterface().unsubscribe(allowACRCollectionSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in unsubscribing to AllowACRCollectionSettings"; } -struct AllowAppContentAdTargetingSettings : public Firebolt::Privacy::IPrivacy::IOnAllowAppContentAdTargetingChangedNotification { +struct AllowAppContentAdTargetingSettings : public Firebolt::Privacy::IPrivacy::IOnAllowAppContentAdTargetingChangedNotification +{ void onAllowAppContentAdTargetingChanged(const bool) override; }; -void AllowAppContentAdTargetingSettings::onAllowAppContentAdTargetingChanged(const bool isAllowed) { +void AllowAppContentAdTargetingSettings::onAllowAppContentAdTargetingChanged(const bool isAllowed) +{ std::cout << "onAllowAppContentAdTargetingChanged event fired"; } -TEST_F(PrivacyTest, subscribeOnAllowAppContentAdTargetingChanged) { +TEST_F(PrivacyTest, subscribeOnAllowAppContentAdTargetingChanged) +{ AllowAppContentAdTargetingSettings allowAppContentAdTargetingSettings; Firebolt::IFireboltAccessor::Instance().PrivacyInterface().subscribe(allowAppContentAdTargetingSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to AllowAppContentAdTargetingSettings"; } -TEST_F(PrivacyTest, unsubscribeOnAllowAppContentAdTargetingChanged) { +TEST_F(PrivacyTest, unsubscribeOnAllowAppContentAdTargetingChanged) +{ AllowAppContentAdTargetingSettings allowAppContentAdTargetingSettings; Firebolt::IFireboltAccessor::Instance().PrivacyInterface().unsubscribe(allowAppContentAdTargetingSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in unsubscribing to AllowAppContentAdTargetingSettings"; } -struct AllowCameraAnalyticsSettings : public Firebolt::Privacy::IPrivacy::IOnAllowCameraAnalyticsChangedNotification { +struct AllowCameraAnalyticsSettings : public Firebolt::Privacy::IPrivacy::IOnAllowCameraAnalyticsChangedNotification +{ void onAllowCameraAnalyticsChanged(const bool) override; }; -void AllowCameraAnalyticsSettings::onAllowCameraAnalyticsChanged(const bool isAllowed) { +void AllowCameraAnalyticsSettings::onAllowCameraAnalyticsChanged(const bool isAllowed) +{ std::cout << "onAllowCameraAnalyticsChanged event fired"; } -TEST_F(PrivacyTest, subscribeOnAllowCameraAnalyticsChanged) { +TEST_F(PrivacyTest, subscribeOnAllowCameraAnalyticsChanged) +{ AllowCameraAnalyticsSettings allowCameraAnalyticsSettings; Firebolt::IFireboltAccessor::Instance().PrivacyInterface().subscribe(allowCameraAnalyticsSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to AllowCameraAnalyticsSettings"; } -TEST_F(PrivacyTest, unsubscribeOnAllowCameraAnalyticsChanged) { +TEST_F(PrivacyTest, unsubscribeOnAllowCameraAnalyticsChanged) +{ AllowCameraAnalyticsSettings allowCameraAnalyticsSettings; Firebolt::IFireboltAccessor::Instance().PrivacyInterface().unsubscribe(allowCameraAnalyticsSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in unsubscribing to AllowCameraAnalyticsSettings"; } -struct AllowPersonalizationSettings : public Firebolt::Privacy::IPrivacy::IOnAllowPersonalizationChangedNotification { +struct AllowPersonalizationSettings : public Firebolt::Privacy::IPrivacy::IOnAllowPersonalizationChangedNotification +{ void onAllowPersonalizationChanged(const bool) override; }; -void AllowPersonalizationSettings::onAllowPersonalizationChanged(const bool isAllowed) { +void AllowPersonalizationSettings::onAllowPersonalizationChanged(const bool isAllowed) +{ std::cout << "onAllowPersonalizationChanged event fired"; } -TEST_F(PrivacyTest, subscribeOnAllowPersonalizationChanged) { +TEST_F(PrivacyTest, subscribeOnAllowPersonalizationChanged) +{ AllowPersonalizationSettings allowPersonalizationSettings; Firebolt::IFireboltAccessor::Instance().PrivacyInterface().subscribe(allowPersonalizationSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to AllowPersonalizationSettings"; } -TEST_F(PrivacyTest, unsubscribeOnAllowPersonalizationChanged) { +TEST_F(PrivacyTest, unsubscribeOnAllowPersonalizationChanged) +{ AllowPersonalizationSettings allowPersonalizationSettings; Firebolt::IFireboltAccessor::Instance().PrivacyInterface().unsubscribe(allowPersonalizationSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in unsubscribing to AllowPersonalizationSettings"; } -struct AllowPrimaryBrowseAdTargetingSettings : public Firebolt::Privacy::IPrivacy::IOnAllowPrimaryBrowseAdTargetingChangedNotification { +struct AllowPrimaryBrowseAdTargetingSettings : public Firebolt::Privacy::IPrivacy::IOnAllowPrimaryBrowseAdTargetingChangedNotification +{ void onAllowPrimaryBrowseAdTargetingChanged(const bool) override; }; -void AllowPrimaryBrowseAdTargetingSettings::onAllowPrimaryBrowseAdTargetingChanged(const bool isAllowed) { +void AllowPrimaryBrowseAdTargetingSettings::onAllowPrimaryBrowseAdTargetingChanged(const bool isAllowed) +{ std::cout << "onAllowPrimaryBrowseAdTargetingChanged event fired"; } -TEST_F(PrivacyTest, subscribeOnAllowPrimaryBrowseAdTargetingChanged) { +TEST_F(PrivacyTest, subscribeOnAllowPrimaryBrowseAdTargetingChanged) +{ AllowPrimaryBrowseAdTargetingSettings allowPrimaryBrowseAdTargetingSettings; Firebolt::IFireboltAccessor::Instance().PrivacyInterface().subscribe(allowPrimaryBrowseAdTargetingSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to AllowPrimaryBrowseAdTargetingSettings"; } -TEST_F(PrivacyTest, unsubscribeOnAllowPrimaryBrowseAdTargetingChanged) { +TEST_F(PrivacyTest, unsubscribeOnAllowPrimaryBrowseAdTargetingChanged) +{ AllowPrimaryBrowseAdTargetingSettings allowPrimaryBrowseAdTargetingSettings; Firebolt::IFireboltAccessor::Instance().PrivacyInterface().unsubscribe(allowPrimaryBrowseAdTargetingSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in unsubscribing to AllowPrimaryBrowseAdTargetingSettings"; } -struct AllowPrimaryContentAdTargetingSettings : public Firebolt::Privacy::IPrivacy::IOnAllowPrimaryContentAdTargetingChangedNotification { +struct AllowPrimaryContentAdTargetingSettings : public Firebolt::Privacy::IPrivacy::IOnAllowPrimaryContentAdTargetingChangedNotification +{ void onAllowPrimaryContentAdTargetingChanged(const bool) override; }; -void AllowPrimaryContentAdTargetingSettings::onAllowPrimaryContentAdTargetingChanged(const bool isAllowed) { +void AllowPrimaryContentAdTargetingSettings::onAllowPrimaryContentAdTargetingChanged(const bool isAllowed) +{ std::cout << "onAllowPrimaryContentAdTargetingChanged event fired"; } -TEST_F(PrivacyTest, subscribeOnAllowPrimaryContentAdTargetingChanged) { +TEST_F(PrivacyTest, subscribeOnAllowPrimaryContentAdTargetingChanged) +{ AllowPrimaryContentAdTargetingSettings allowPrimaryContentAdTargetingSettings; Firebolt::IFireboltAccessor::Instance().PrivacyInterface().subscribe(allowPrimaryContentAdTargetingSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to AllowPrimaryContentAdTargetingSettings"; } -TEST_F(PrivacyTest, unsubscribeOnAllowPrimaryContentAdTargetingChanged) { +TEST_F(PrivacyTest, unsubscribeOnAllowPrimaryContentAdTargetingChanged) +{ AllowPrimaryContentAdTargetingSettings allowPrimaryContentAdTargetingSettings; Firebolt::IFireboltAccessor::Instance().PrivacyInterface().unsubscribe(allowPrimaryContentAdTargetingSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in unsubscribing to AllowPrimaryContentAdTargetingSettings"; } -struct AllowProductAnalyticsSettings : public Firebolt::Privacy::IPrivacy::IOnAllowProductAnalyticsChangedNotification { +struct AllowProductAnalyticsSettings : public Firebolt::Privacy::IPrivacy::IOnAllowProductAnalyticsChangedNotification +{ void onAllowProductAnalyticsChanged(const bool) override; }; -void AllowProductAnalyticsSettings::onAllowProductAnalyticsChanged(const bool isAllowed) { +void AllowProductAnalyticsSettings::onAllowProductAnalyticsChanged(const bool isAllowed) +{ std::cout << "onAllowProductAnalyticsChanged event fired"; } -TEST_F(PrivacyTest, subscribeOnAllowProductAnalyticsChanged) { +TEST_F(PrivacyTest, subscribeOnAllowProductAnalyticsChanged) +{ AllowProductAnalyticsSettings allowProductAnalyticsSettings; Firebolt::IFireboltAccessor::Instance().PrivacyInterface().subscribe(allowProductAnalyticsSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to AllowProductAnalyticsSettings"; } -TEST_F(PrivacyTest, unsubscribeOnAllowProductAnalyticsChanged) { +TEST_F(PrivacyTest, unsubscribeOnAllowProductAnalyticsChanged) +{ AllowProductAnalyticsSettings allowProductAnalyticsSettings; Firebolt::IFireboltAccessor::Instance().PrivacyInterface().unsubscribe(allowProductAnalyticsSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in unsubscribing to AllowProductAnalyticsSettings"; } -struct AllowRemoteDiagnosticsSettings : public Firebolt::Privacy::IPrivacy::IOnAllowRemoteDiagnosticsChangedNotification { +struct AllowRemoteDiagnosticsSettings : public Firebolt::Privacy::IPrivacy::IOnAllowRemoteDiagnosticsChangedNotification +{ void onAllowRemoteDiagnosticsChanged(const bool) override; }; -void AllowRemoteDiagnosticsSettings::onAllowRemoteDiagnosticsChanged(const bool isAllowed) { +void AllowRemoteDiagnosticsSettings::onAllowRemoteDiagnosticsChanged(const bool isAllowed) +{ std::cout << "onAllowRemoteDiagnosticsChanged event fired with isAllowed: " << isAllowed; } -TEST_F(PrivacyTest, subscribeOnAllowRemoteDiagnosticsChanged) { +TEST_F(PrivacyTest, subscribeOnAllowRemoteDiagnosticsChanged) +{ AllowRemoteDiagnosticsSettings allowRemoteDiagnosticsSettings; Firebolt::IFireboltAccessor::Instance().PrivacyInterface().subscribe(allowRemoteDiagnosticsSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to AllowRemoteDiagnosticsSettings"; } -TEST_F(PrivacyTest, unsubscribeOnAllowRemoteDiagnosticsChanged) { +TEST_F(PrivacyTest, unsubscribeOnAllowRemoteDiagnosticsChanged) +{ AllowRemoteDiagnosticsSettings allowRemoteDiagnosticsSettings; Firebolt::IFireboltAccessor::Instance().PrivacyInterface().unsubscribe(allowRemoteDiagnosticsSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in unsubscribing to AllowRemoteDiagnosticsSettings"; } -struct AllowResumePointsSettings : public Firebolt::Privacy::IPrivacy::IOnAllowResumePointsChangedNotification { +struct AllowResumePointsSettings : public Firebolt::Privacy::IPrivacy::IOnAllowResumePointsChangedNotification +{ void onAllowResumePointsChanged(const bool) override; }; -void AllowResumePointsSettings::onAllowResumePointsChanged(const bool isAllowed) { +void AllowResumePointsSettings::onAllowResumePointsChanged(const bool isAllowed) +{ std::cout << "onAllowResumePointsChanged event fired with isAllowed: " << isAllowed; } -TEST_F(PrivacyTest, subscribeOnAllowResumePointsChanged) { +TEST_F(PrivacyTest, subscribeOnAllowResumePointsChanged) +{ AllowResumePointsSettings allowResumePointsSettings; Firebolt::IFireboltAccessor::Instance().PrivacyInterface().subscribe(allowResumePointsSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to AllowResumePointsSettings"; } -TEST_F(PrivacyTest, unsubscribeOnAllowResumePointsChanged) { +TEST_F(PrivacyTest, unsubscribeOnAllowResumePointsChanged) +{ AllowResumePointsSettings allowResumePointsSettings; Firebolt::IFireboltAccessor::Instance().PrivacyInterface().unsubscribe(allowResumePointsSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in unsubscribing to AllowResumePointsSettings"; } -struct AllowUnentitledPersonalizationSettings : public Firebolt::Privacy::IPrivacy::IOnAllowUnentitledPersonalizationChangedNotification { +struct AllowUnentitledPersonalizationSettings : public Firebolt::Privacy::IPrivacy::IOnAllowUnentitledPersonalizationChangedNotification +{ void onAllowUnentitledPersonalizationChanged(const bool) override; }; -void AllowUnentitledPersonalizationSettings::onAllowUnentitledPersonalizationChanged(const bool isAllowed) { +void AllowUnentitledPersonalizationSettings::onAllowUnentitledPersonalizationChanged(const bool isAllowed) +{ std::cout << "onAllowUnentitledPersonalizationChanged event fired with isAllowed: " << isAllowed; } -TEST_F(PrivacyTest, subscribeOnAllowUnentitledPersonalizationChanged) { +TEST_F(PrivacyTest, subscribeOnAllowUnentitledPersonalizationChanged) +{ AllowUnentitledPersonalizationSettings allowUnentitledPersonalizationSettings; Firebolt::IFireboltAccessor::Instance().PrivacyInterface().subscribe(allowUnentitledPersonalizationSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to AllowUnentitledPersonalizationSettings"; } -TEST_F(PrivacyTest, unsubscribeOnAllowUnentitledPersonalizationChanged) { +TEST_F(PrivacyTest, unsubscribeOnAllowUnentitledPersonalizationChanged) +{ AllowUnentitledPersonalizationSettings allowUnentitledPersonalizationSettings; Firebolt::IFireboltAccessor::Instance().PrivacyInterface().unsubscribe(allowUnentitledPersonalizationSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in unsubscribing to AllowUnentitledPersonalizationSettings"; } -struct AllowUnentitledResumePointsSettings : public Firebolt::Privacy::IPrivacy::IOnAllowUnentitledResumePointsChangedNotification { +struct AllowUnentitledResumePointsSettings : public Firebolt::Privacy::IPrivacy::IOnAllowUnentitledResumePointsChangedNotification +{ void onAllowUnentitledResumePointsChanged(const bool) override; }; -void AllowUnentitledResumePointsSettings::onAllowUnentitledResumePointsChanged(const bool isAllowed) { +void AllowUnentitledResumePointsSettings::onAllowUnentitledResumePointsChanged(const bool isAllowed) +{ std::cout << "onAllowUnentitledResumePointsChanged event fired with isAllowed: " << isAllowed; } -TEST_F(PrivacyTest, subscribeOnAllowUnentitledResumePointsChanged) { +TEST_F(PrivacyTest, subscribeOnAllowUnentitledResumePointsChanged) +{ AllowUnentitledResumePointsSettings allowUnentitledResumePointsSettings; Firebolt::IFireboltAccessor::Instance().PrivacyInterface().subscribe(allowUnentitledResumePointsSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to AllowUnentitledResumePointsSettings"; } -TEST_F(PrivacyTest, unsubscribeOnAllowUnentitledResumePointsChanged) { +TEST_F(PrivacyTest, unsubscribeOnAllowUnentitledResumePointsChanged) +{ AllowUnentitledResumePointsSettings allowUnentitledResumePointsSettings; Firebolt::IFireboltAccessor::Instance().PrivacyInterface().unsubscribe(allowUnentitledResumePointsSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in unsubscribing to AllowUnentitledResumePointsSettings"; } -struct AllowWatchHistorySettings : public Firebolt::Privacy::IPrivacy::IOnAllowWatchHistoryChangedNotification { +struct AllowWatchHistorySettings : public Firebolt::Privacy::IPrivacy::IOnAllowWatchHistoryChangedNotification +{ void onAllowWatchHistoryChanged(const bool) override; }; -void AllowWatchHistorySettings::onAllowWatchHistoryChanged(const bool isAllowed) { +void AllowWatchHistorySettings::onAllowWatchHistoryChanged(const bool isAllowed) +{ std::cout << "onAllowWatchHistoryChanged event fired with isAllowed: " << isAllowed; } -TEST_F(PrivacyTest, subscribeOnAllowWatchHistoryChanged) { +TEST_F(PrivacyTest, subscribeOnAllowWatchHistoryChanged) +{ AllowWatchHistorySettings allowWatchHistorySettings; Firebolt::IFireboltAccessor::Instance().PrivacyInterface().subscribe(allowWatchHistorySettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in subscribing to AllowWatchHistorySettings"; } -TEST_F(PrivacyTest, unsubscribeOnAllowWatchHistoryChanged) { +TEST_F(PrivacyTest, unsubscribeOnAllowWatchHistoryChanged) +{ AllowWatchHistorySettings allowWatchHistorySettings; Firebolt::IFireboltAccessor::Instance().PrivacyInterface().unsubscribe(allowWatchHistorySettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in unsubscribing to AllowWatchHistorySettings"; diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/unit/secureStorageTest.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/unit/secureStorageTest.cpp new file mode 100644 index 000000000..51f648665 --- /dev/null +++ b/src/sdks/manage/src/cpp/sdk/cpptest/unit/secureStorageTest.cpp @@ -0,0 +1,44 @@ +#include "unit.h" + +class SecureStorageTest : public ::testing::Test +{ +protected: + JsonEngine *jsonEngine; + Firebolt::Error error = Firebolt::Error::None; + Firebolt::SecureStorage::StorageScope scope; + std::string appId = "exampleAppId"; + + void SetUp() override + { + jsonEngine = new JsonEngine(); + } + + void TearDown() override + { + delete jsonEngine; + } +}; + +TEST_F(SecureStorageTest, clearForApp) +{ + Firebolt::IFireboltAccessor::Instance().SecureStorageInterface().clearForApp(appId, scope, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling SecureStorageInterface.clearForApp() method"; +} + +TEST_F(SecureStorageTest, removeForApp) +{ + std::string key = "exampleKey"; + + Firebolt::IFireboltAccessor::Instance().SecureStorageInterface().removeForApp(appId, scope, key, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling SecureStorageInterface.removeForApp() method"; +} + +TEST_F(SecureStorageTest, setForApp) +{ + std::string key = "exampleKey"; + std::string value = "exampleValue"; + std::optional options = std::nullopt; + + Firebolt::IFireboltAccessor::Instance().SecureStorageInterface().setForApp(appId, scope, key, value, options, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling SecureStorageInterface.setForApp() method"; +} diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/unit/unit.h b/src/sdks/manage/src/cpp/sdk/cpptest/unit/unit.h index e5e0a7b2d..7f47caa06 100644 --- a/src/sdks/manage/src/cpp/sdk/cpptest/unit/unit.h +++ b/src/sdks/manage/src/cpp/sdk/cpptest/unit/unit.h @@ -1,4 +1,5 @@ #pragma once #include "gtest/gtest.h" -#include "../ManageSDKTest.h" \ No newline at end of file +#include "../ManageSDKTest.h" +#include "json_engine.h" \ No newline at end of file diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/unit/userGrantTest.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/unit/userGrantTest.cpp new file mode 100644 index 000000000..e63f9c30c --- /dev/null +++ b/src/sdks/manage/src/cpp/sdk/cpptest/unit/userGrantTest.cpp @@ -0,0 +1,172 @@ +#include "unit.h" + +using namespace Firebolt::UserGrants; +using namespace Firebolt::Capabilities; + +class UserGrantsTest : public ::testing::Test +{ +protected: + JsonEngine *jsonEngine; + Firebolt::Error error = Firebolt::Error::None; + std::string capability = "xrn:firebolt:capability:example-capability:sub-capability"; + Role role; + std::optional options = std::nullopt; + + void SetUp() override + { + jsonEngine = new JsonEngine(); + } + + void TearDown() override + { + delete jsonEngine; + } +}; + +std::string grantInfoLifespanToString(GrantInfoLifespan lifespan) +{ + switch (lifespan) + { + case GrantInfoLifespan::ONCE: + return "once"; + case GrantInfoLifespan::FOREVER: + return "forever"; + case GrantInfoLifespan::APP_ACTIVE: + return "appActive"; + case GrantInfoLifespan::POWER_ACTIVE: + return "powerActive"; + case GrantInfoLifespan::SECONDS: + return "seconds"; + default: + return "unknown"; + } +} + +std::string roleToString(Role role) +{ + switch (role) + { + case Role::USE: + return "use"; + case Role::MANAGE: + return "manage"; + case Role::PROVIDE: + return "provide"; + default: + return "unknown"; + } +} + +std::string grantStateToString(GrantState state) +{ + switch (state) + { + case GrantState::GRANTED: + return "granted"; + case GrantState::DENIED: + return "denied"; + default: + return "unknown"; + } +} + +std::string stringifyGrantInfo(const std::vector &grants) +{ + std::string result = "["; + for (const auto &grant : grants) + { + result += "{"; + if (grant.app.has_value()) + { + result += "\"app\":{\"id\":\"" + grant.app.value().id + "\","; + if (grant.app.value().title.has_value()) + { + result += "\"title\":\"" + grant.app.value().title.value() + "\""; + } + result += "},"; + } + result += "\"capability\":\"" + std::string(grant.capability) + "\","; + if (grant.expires.has_value()) + { + result += "\"expires\":\"" + grant.expires.value() + "\","; + } + result += "\"lifespan\":\"" + grantInfoLifespanToString(grant.lifespan) + "\","; + result += "\"role\":\"" + roleToString(grant.role) + "\","; + result += "\"state\":\"" + grantStateToString(grant.state) + "\""; + result += "},"; + } + if (!grants.empty()) + { + result.pop_back(); // Remove the last comma + } + result += "]"; + return result; +} + +TEST_F(UserGrantsTest, app) +{ + std::string expectedValues = jsonEngine->get_value("UserGrants.app"); + std::string appId = "appId"; + std::vector info = Firebolt::IFireboltAccessor::Instance().UserGrantsInterface().app(appId, &error); + + std::string info_string = stringifyGrantInfo(info); + + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling UserGrantsInterface.app() method"; + EXPECT_EQ(expectedValues, info_string) << "Error: wrong info returned by UserGrantsInterface.app()"; +} + +TEST_F(UserGrantsTest, capability) +{ + std::string expectedValues = jsonEngine->get_value("UserGrants.capability"); + std::vector info = Firebolt::IFireboltAccessor::Instance().UserGrantsInterface().capability(capability, &error); + + std::string info_string = stringifyGrantInfo(info); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling UserGrantsInterface.capability() method"; + EXPECT_EQ(expectedValues, info_string) << "Error: wrong info returned by UserGrantsInterface.capability()"; +} + +TEST_F(UserGrantsTest, clear) +{ + Firebolt::IFireboltAccessor::Instance().UserGrantsInterface().clear(role, capability, options, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling UserGrantsInterface.clear() method"; +} + +TEST_F(UserGrantsTest, deny) +{ + Firebolt::IFireboltAccessor::Instance().UserGrantsInterface().deny(role, capability, options, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling UserGrantsInterface.deny() method"; +} + +TEST_F(UserGrantsTest, device) +{ + std::string expectedValues = jsonEngine->get_value("UserGrants.device"); + std::vector info = Firebolt::IFireboltAccessor::Instance().UserGrantsInterface().device(&error); + + std::string info_string = stringifyGrantInfo(info); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling UserGrantsInterface.device() method"; + EXPECT_EQ(expectedValues, info_string) << "Error: wrong info returned by UserGrantsInterface.device()"; +} + +TEST_F(UserGrantsTest, grant) +{ + Firebolt::IFireboltAccessor::Instance().UserGrantsInterface().grant(role, capability, options, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling UserGrantsInterface.grant() method"; +} + +TEST_F(UserGrantsTest, request) +{ + std::string expectedValues = jsonEngine->get_value("UserGrants.request"); + + std::string appId = "appId"; + std::vector permissions = { + {std::make_optional(Role::USE), "xrn:firebolt:capability:example-capability:sub-capability"}, + {std::nullopt, "xrn:firebolt:capability:example-capability:sub-capability"}, + {std::make_optional(Role::MANAGE), "xrn:firebolt:capability:example-capability:sub-capability"}}; + std::optional req_options = std::nullopt; + + std::vector info = Firebolt::IFireboltAccessor::Instance().UserGrantsInterface().request(appId, permissions, req_options, &error); + + std::string info_string = stringifyGrantInfo(info); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling UserGrantsInterface.request() method"; + EXPECT_EQ(expectedValues, info_string) << "Error: wrong info returned by UserGrantsInterface.request()"; +} diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/unit/voiceGuidanceTest.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/unit/voiceGuidanceTest.cpp index 3dba5bd74..d62ce8374 100644 --- a/src/sdks/manage/src/cpp/sdk/cpptest/unit/voiceGuidanceTest.cpp +++ b/src/sdks/manage/src/cpp/sdk/cpptest/unit/voiceGuidanceTest.cpp @@ -3,44 +3,94 @@ class VoiceGuidanceTest : public ::testing::Test { protected: + JsonEngine *jsonEngine; Firebolt::Error error = Firebolt::Error::None; + + void SetUp() override + { + jsonEngine = new JsonEngine(); + } + + void TearDown() override + { + delete jsonEngine; + } }; -struct EnabledSettings : public Firebolt::VoiceGuidance::IVoiceGuidance::IOnEnabledChangedNotification { +TEST_F(VoiceGuidanceTest, setEnabled) +{ + bool expected_value = true; + Firebolt::IFireboltAccessor::Instance().VoiceGuidanceInterface().setEnabled(expected_value, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling VoiceGuidanceInterface.setEnabled() method"; +} + +TEST_F(VoiceGuidanceTest, enabled) +{ + std::string expectedValues = jsonEngine->get_value("VoiceGuidance.enabled"); + bool enabled = Firebolt::IFireboltAccessor::Instance().VoiceGuidanceInterface().enabled(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling VoiceGuidanceInterface.enabled() method"; + EXPECT_EQ(expectedValues == "true", enabled) << "Error: wrong enabled value returned by VoiceGuidanceInterface.enabled()"; +} + +TEST_F(VoiceGuidanceTest, setSpeed) +{ + float expected_value = 1.5f; + Firebolt::IFireboltAccessor::Instance().VoiceGuidanceInterface().setSpeed(expected_value, &error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling VoiceGuidanceInterface.setSpeed() method"; +} + +TEST_F(VoiceGuidanceTest, speed) +{ + std::string expectedValues = jsonEngine->get_value("VoiceGuidance.speed"); + float speed = Firebolt::IFireboltAccessor::Instance().VoiceGuidanceInterface().speed(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling VoiceGuidanceInterface.speed() method"; + EXPECT_EQ(stof(expectedValues), speed) << "Error: wrong speed value returned by VoiceGuidanceInterface.speed()"; +} + +// Events Tests +struct EnabledSettings : public Firebolt::VoiceGuidance::IVoiceGuidance::IOnEnabledChangedNotification +{ void onEnabledChanged(const bool) override; }; -void EnabledSettings::onEnabledChanged(const bool isEnabled) { +void EnabledSettings::onEnabledChanged(const bool isEnabled) +{ std::cout << "onEnabledChanged event fired with isEnabled: " << isEnabled; } -TEST_F(VoiceGuidanceTest, subscribeOnEnabledChanged) { +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) { +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 { +struct SpeedSettings : public Firebolt::VoiceGuidance::IVoiceGuidance::IOnSpeedChangedNotification +{ void onSpeedChanged(const float) override; }; -void SpeedSettings::onSpeedChanged(const float speed) { +void SpeedSettings::onSpeedChanged(const float speed) +{ std::cout << "onSpeedChanged event fired with speed: " << speed; } -TEST_F(VoiceGuidanceTest, subscribeOnSpeedChanged) { +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) { +TEST_F(VoiceGuidanceTest, unsubscribeOnSpeedChanged) +{ SpeedSettings speedSettings; Firebolt::IFireboltAccessor::Instance().VoiceGuidanceInterface().unsubscribe(speedSettings, &error); EXPECT_EQ(error, Firebolt::Error::None) << "Error in unsubscribing to SpeedSettings"; diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/unit/wifiTest.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/unit/wifiTest.cpp new file mode 100644 index 000000000..05fc1c29a --- /dev/null +++ b/src/sdks/manage/src/cpp/sdk/cpptest/unit/wifiTest.cpp @@ -0,0 +1,167 @@ +#include "unit.h" + +using namespace Firebolt::Wifi; + +class WifiTest : public ::testing::Test +{ +protected: + JsonEngine *jsonEngine; + Firebolt::Error error = Firebolt::Error::None; + + void SetUp() override + { + jsonEngine = new JsonEngine(); + } + + void TearDown() override + { + delete jsonEngine; + } +}; + +std::string wifiSecurityModeToString(WifiSecurityMode mode) +{ + switch (mode) + { + case WifiSecurityMode::NONE: + return "none"; + case WifiSecurityMode::WEP_64: + return "wep64"; + case WifiSecurityMode::WEP_128: + return "wep128"; + case WifiSecurityMode::WPA_PSK_TKIP: + return "wpaPskTkip"; + case WifiSecurityMode::WPA_PSK_AES: + return "wpaPskAes"; + case WifiSecurityMode::WPA_2PSK_TKIP: + return "wpa2PskTkip"; + case WifiSecurityMode::WPA_2PSK_AES: + return "wpa2PskAes"; + case WifiSecurityMode::WPA_ENTERPRISE_TKIP: + return "wpaEnterpriseTkip"; + case WifiSecurityMode::WPA_ENTERPRISE_AES: + return "wpaEnterpriseAes"; + case WifiSecurityMode::WPA_2ENTERPRISE_TKIP: + return "wpa2EnterpriseTkip"; + case WifiSecurityMode::WPA_2ENTERPRISE_AES: + return "wpa2EnterpriseAes"; + case WifiSecurityMode::WPA_2PSK: + return "wpa2Psk"; + case WifiSecurityMode::WPA_2ENTERPRISE: + return "wpa2Enterprise"; + case WifiSecurityMode::WPA_3PSK_AES: + return "wpa3PskAes"; + case WifiSecurityMode::WPA_3SAE: + return "wpa3Sae"; + default: + return "unknown"; + } +} + +std::string removeParentheses(const std::string &str) +{ + std::string result; + for (char ch : str) + { + if (ch != '(' && ch != ')') + { + result += ch; + } + } + return result; +} + +TEST_F(WifiTest, connect) +{ + json expectedValues = json::parse(jsonEngine->get_value("Wifi.connect")); + + std::optional ssid = "SSID"; + std::optional passphrase = "Passphrase"; + std::optional security = WifiSecurityMode::WPA_2PSK; + + AccessPoint connectedWifi = Firebolt::IFireboltAccessor::Instance().WifiInterface().connect(ssid, passphrase, security, &error); + + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling WifiInterface.connect() method"; + EXPECT_EQ(connectedWifi.ssid, expectedValues["ssid"]) << "SSID mismatch"; + if (connectedWifi.securityMode.has_value()) + { + EXPECT_EQ(wifiSecurityModeToString(connectedWifi.securityMode.value()), expectedValues["security"]) << "Security mode mismatch"; + } + EXPECT_EQ(connectedWifi.signalStrength, expectedValues["signalStrength"]) << "signalStrength mismatch"; + if (connectedWifi.frequency.has_value()) + { + EXPECT_EQ(connectedWifi.frequency, expectedValues["frequency"].get()) << "frequency mismatch"; + } +} + +TEST_F(WifiTest, disconnect) +{ + Firebolt::IFireboltAccessor::Instance().WifiInterface().disconnect(&error); + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling WifiInterface.disconnect() method"; +} + +TEST_F(WifiTest, scan) +{ + std::string expectedValues = jsonEngine->get_value("Wifi.scan"); + + std::optional timeout = 30; + + AccessPointList apl = Firebolt::IFireboltAccessor::Instance().WifiInterface().scan(timeout, &error); + + std::string apl_string = "{\"list\":["; + if (apl.list.has_value()) + { + for (const auto &ap : apl.list.value()) + { + apl_string += "{"; + + if (ap.frequency.has_value()) + { + std::string s = std::to_string(ap.frequency.value()); + auto pos = s.find('.'); + + apl_string += "\"frequency\":" + s.substr(0, pos + 2) + ","; + } + if (ap.securityMode.has_value()) + { + apl_string += "\"security\":\"" + wifiSecurityModeToString(ap.securityMode.value()) + "\","; + } + if (ap.signalStrength.has_value()) + { + apl_string += "\"signalStrength\":" + std::to_string(ap.signalStrength.value()) + ","; + } + if (ap.ssid.has_value()) + { + apl_string += "\"ssid\":\"" + ap.ssid.value() + "\","; + } + + apl_string.pop_back(); // Remove the last comma + apl_string += "},"; + } + apl_string.pop_back(); // Remove the last comma + } + apl_string += "]}"; + + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling WifiInterface.scan() method"; + EXPECT_EQ(expectedValues, apl_string) << "Scan should return at least one access point"; +} + +TEST_F(WifiTest, wps) +{ + json expectedValues = json::parse(jsonEngine->get_value("Wifi.wps")); + std::optional security = WPSSecurityPin::PIN; + + AccessPoint connectedWifi = Firebolt::IFireboltAccessor::Instance().WifiInterface().wps(security, &error); + + EXPECT_EQ(error, Firebolt::Error::None) << "Error on calling WifiInterface.connect() method"; + EXPECT_EQ(connectedWifi.ssid, expectedValues["ssid"]) << "SSID mismatch"; + if (connectedWifi.securityMode.has_value()) + { + EXPECT_EQ(wifiSecurityModeToString(connectedWifi.securityMode.value()), expectedValues["security"]) << "Security mode mismatch"; + } + EXPECT_EQ(connectedWifi.signalStrength, expectedValues["signalStrength"]) << "signalStrength mismatch"; + if (connectedWifi.frequency.has_value()) + { + EXPECT_EQ(connectedWifi.frequency, expectedValues["frequency"].get()) << "frequency mismatch"; + } +}