diff --git a/src/sdks/core/src/cpp/sdk/cpptest/CMakeLists.txt b/src/sdks/core/src/cpp/sdk/cpptest/CMakeLists.txt index c542cf6cc..7e4ef7ef7 100644 --- a/src/sdks/core/src/cpp/sdk/cpptest/CMakeLists.txt +++ b/src/sdks/core/src/cpp/sdk/cpptest/CMakeLists.txt @@ -42,21 +42,64 @@ find_package(${NAMESPACE}Core CONFIG REQUIRED) find_package(Firebolt CONFIG REQUIRED) find_package(${FIREBOLT_NAMESPACE}SDK CONFIG REQUIRED) +# Manually add the library +add_library(nlohmann_json_schema_validator SHARED IMPORTED) +set_target_properties(nlohmann_json_schema_validator PROPERTIES + IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/../build/build/_deps/nlohmann_json_schema_validator-src/libnlohmann_json_schema_validator.a +) +add_library(gmock_main SHARED IMPORTED) +set_target_properties(gmock_main PROPERTIES + IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/../build/lib/libgmock.a +) +add_library(gtest SHARED IMPORTED) +set_target_properties(gtest PROPERTIES + IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/../build/lib/libgtest.a +) + +add_library(gtest_main SHARED IMPORTED) +set_target_properties(gtest_main PROPERTIES + IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/../build/lib/libgtest_main.a +) + +include_directories(${CMAKE_SOURCE_DIR}/build/_deps/json-src/include) + set(TESTAPP TestFireboltCore) message("Setup ${TESTAPP}") -add_executable(${TESTAPP} CoreSDKTest.cpp Main.cpp) +if(UNIT_TEST STREQUAL "ON") + add_definitions(-DUNIT_TEST) + + file(GLOB UNIT_TESTS "unit/*") + + add_executable(${TESTAPP} + CoreSDKTest.cpp + Unit.cpp + ${UNIT_TESTS} + ) +else() + add_executable(${TESTAPP} + CoreSDKTest.cpp + Main.cpp + ) +endif() target_link_libraries(${TESTAPP} PRIVATE ${NAMESPACE}Core::${NAMESPACE}Core ${FIREBOLT_NAMESPACE}SDK::${FIREBOLT_NAMESPACE}SDK + nlohmann_json_schema_validator + gmock_main + gtest_main + gtest ) target_include_directories(${TESTAPP} PRIVATE $ + $ + $ + $ $ $ ) @@ -78,4 +121,4 @@ add_custom_command( COMMENT "=================== Installing TestApp ======================" COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/${FIREBOLT_NAMESPACE}/usr/bin COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${TESTAPP} ${CMAKE_BINARY_DIR}/${FIREBOLT_NAMESPACE}/usr/bin -) +) \ No newline at end of file diff --git a/src/sdks/core/src/cpp/sdk/cpptest/Unit.cpp b/src/sdks/core/src/cpp/sdk/cpptest/Unit.cpp new file mode 100644 index 000000000..d4fef024c --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/cpptest/Unit.cpp @@ -0,0 +1,9 @@ +#include "gtest/gtest.h" +#include "CoreSDKTest.h" + +int main(int argc, char** argv) { + std::string url = "ws://localhost:9998"; + CoreSDKTest::CreateFireboltInstance(url); + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} \ No newline at end of file diff --git a/src/sdks/core/src/cpp/sdk/cpptest/build.sh b/src/sdks/core/src/cpp/sdk/cpptest/build.sh index b404a78f3..1abe98156 100755 --- a/src/sdks/core/src/cpp/sdk/cpptest/build.sh +++ b/src/sdks/core/src/cpp/sdk/cpptest/build.sh @@ -16,13 +16,14 @@ TestPath="." FireboltPath=${FIREBOLT_PATH} SysrootPath=${SYSROOT_PATH} ClearBuild="N" -while getopts t:s:f:ch flag +while getopts t:s:f:c:uh flag do case "${flag}" in t) TestPath="${OPTARG}";; s) SysrootPath="${OPTARG}";; f) FireboltPath="${OPTARG}";; c) ClearBuild="Y";; + u) UnitTest="ON";; h) usage && exit 1;; esac done @@ -36,6 +37,6 @@ echo "TestPath" echo "${TestPath}" echo "FireboltPath" echo ${FireboltPath} -cmake -B${TestPath}/build -S${TestPath} -DSYSROOT_PATH=${SysrootPath} -DFIREBOLT_PATH=${FireboltPath} +cmake -B${TestPath}/build -S${TestPath} -DSYSROOT_PATH=${SysrootPath} -DFIREBOLT_PATH=${FireboltPath} -DUNIT_TEST=${UnitTest} # -DPOLYMORPHICS_METHODS=ON // Enable this to test cmake --build ${TestPath}/build diff --git a/src/sdks/core/src/cpp/sdk/cpptest/unit/accessibilityTest.cpp b/src/sdks/core/src/cpp/sdk/cpptest/unit/accessibilityTest.cpp new file mode 100644 index 000000000..88ea5f111 --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/cpptest/unit/accessibilityTest.cpp @@ -0,0 +1,186 @@ +#include "unit.h" + + +class AccessibilityTest : 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 fontFamilyToString(Firebolt::Accessibility::FontFamily fontFamily) { + std::string str = ""; + switch(fontFamily) { + case Firebolt::Accessibility::FontFamily::MONOSPACED_SERIF: str = "monospaced_serif"; break; + case Firebolt::Accessibility::FontFamily::PROPORTIONAL_SERIF: str = "proportional_serif"; break; + case Firebolt::Accessibility::FontFamily::MONOSPACED_SANSERIF: str = "monospaced_sanserif"; break; + case Firebolt::Accessibility::FontFamily::PROPORTIONAL_SANSERIF: str = "proportional_sanserif"; break; + case Firebolt::Accessibility::FontFamily::SMALLCAPS: str = "smallcaps"; break; + case Firebolt::Accessibility::FontFamily::CURSIVE: str = "cursive"; break; + case Firebolt::Accessibility::FontFamily::CASUAL: str = "casual"; break; + default: str = "unknown"; + } + return str; + } + + std::string fontEdgeToString(Firebolt::Accessibility::FontEdge fontEdge) + { + std::string str = ""; + switch(fontEdge) + { + case Firebolt::Accessibility::FontEdge::NONE: str = "none"; break; + case Firebolt::Accessibility::FontEdge::RAISED: str = "raised"; break; + case Firebolt::Accessibility::FontEdge::DEPRESSED: str = "depressed"; break; + case Firebolt::Accessibility::FontEdge::UNIFORM: str = "uniform"; break; + case Firebolt::Accessibility::FontEdge::DROP_SHADOW_LEFT: str = "drop_shadow_left"; break; + case Firebolt::Accessibility::FontEdge::DROP_SHADOW_RIGHT: str = "drop_shadow_right"; break; + default: str = "unknown"; + } + return str; + } + +}; + +TEST_F(AccessibilityTest, ClosedCaptions) +{ + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Accessibility.closedCaptions")); + + auto closedCaptionSettings = Firebolt::IFireboltAccessor::Instance().AccessibilityInterface().closedCaptions(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(closedCaptionSettings.enabled, expectedValues["enabled"]); + + EXPECT_EQ(closedCaptionSettings.styles.backgroundColor.value(), expectedValues["styles"]["backgroundColor"]); + EXPECT_EQ(closedCaptionSettings.styles.backgroundOpacity.value(), expectedValues["styles"]["backgroundOpacity"]); + EXPECT_EQ(closedCaptionSettings.styles.fontColor.value(), expectedValues["styles"]["fontColor"]); + + if(closedCaptionSettings.styles.fontEdge.has_value()) + EXPECT_EQ(fontEdgeToString(closedCaptionSettings.styles.fontEdge.value()), expectedValues["styles"]["fontEdge"]); + + EXPECT_EQ(closedCaptionSettings.styles.fontEdgeColor.value(), expectedValues["styles"]["fontEdgeColor"]); + + if(closedCaptionSettings.styles.fontFamily.has_value()) + EXPECT_EQ(fontFamilyToString(closedCaptionSettings.styles.fontFamily.value()), expectedValues["styles"]["fontFamily"]); + + EXPECT_EQ(closedCaptionSettings.styles.fontOpacity.value(), expectedValues["styles"]["fontOpacity"]); + EXPECT_EQ(closedCaptionSettings.styles.fontSize.value(), expectedValues["styles"]["fontSize"]); + EXPECT_EQ(closedCaptionSettings.styles.textAlign.value(), expectedValues["styles"]["textAlign"]); + EXPECT_EQ(closedCaptionSettings.styles.textAlignVertical.value(), expectedValues["styles"]["textAlignVertical"]); + EXPECT_EQ(closedCaptionSettings.styles.windowColor.value(), expectedValues["styles"]["windowColor"]); + EXPECT_EQ(closedCaptionSettings.styles.windowOpacity.value(), expectedValues["styles"]["windowOpacity"]); + + EXPECT_EQ(closedCaptionSettings.preferredLanguages.value()[0], expectedValues["preferredLanguages"][0]); + EXPECT_EQ(closedCaptionSettings.preferredLanguages.value()[1], expectedValues["preferredLanguages"][1]); +} + + +TEST_F(AccessibilityTest, ClosedCaptionsSettings) +{ + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Accessibility.closedCaptionsSettings")); + + auto closedCaptionSettings = Firebolt::IFireboltAccessor::Instance().AccessibilityInterface().closedCaptionsSettings(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(closedCaptionSettings.enabled, expectedValues["enabled"]); + + EXPECT_EQ(closedCaptionSettings.styles.backgroundColor.value(), expectedValues["styles"]["backgroundColor"]); + EXPECT_EQ(closedCaptionSettings.styles.backgroundOpacity.value(), expectedValues["styles"]["backgroundOpacity"]); + EXPECT_EQ(closedCaptionSettings.styles.fontColor.value(), expectedValues["styles"]["fontColor"]); + + if(closedCaptionSettings.styles.fontEdge.has_value()) + EXPECT_EQ(fontEdgeToString(closedCaptionSettings.styles.fontEdge.value()), expectedValues["styles"]["fontEdge"]); + + EXPECT_EQ(closedCaptionSettings.styles.fontEdgeColor.value(), expectedValues["styles"]["fontEdgeColor"]); + + if(closedCaptionSettings.styles.fontFamily.has_value()) + EXPECT_EQ(fontFamilyToString(closedCaptionSettings.styles.fontFamily.value()), expectedValues["styles"]["fontFamily"]); + + EXPECT_EQ(closedCaptionSettings.styles.fontOpacity.value(), expectedValues["styles"]["fontOpacity"]); + EXPECT_EQ(closedCaptionSettings.styles.fontSize.value(), expectedValues["styles"]["fontSize"]); + EXPECT_EQ(closedCaptionSettings.styles.textAlign.value(), expectedValues["styles"]["textAlign"]); + EXPECT_EQ(closedCaptionSettings.styles.textAlignVertical.value(), expectedValues["styles"]["textAlignVertical"]); + EXPECT_EQ(closedCaptionSettings.styles.windowColor.value(), expectedValues["styles"]["windowColor"]); + EXPECT_EQ(closedCaptionSettings.styles.windowOpacity.value(), expectedValues["styles"]["windowOpacity"]); + + EXPECT_EQ(closedCaptionSettings.preferredLanguages.value()[0], expectedValues["preferredLanguages"][0]); + EXPECT_EQ(closedCaptionSettings.preferredLanguages.value()[1], expectedValues["preferredLanguages"][1]); +} + + +TEST_F(AccessibilityTest, VoiceGuidance) +{ + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Accessibility.voiceGuidance")); + + auto voiceGuidanceSettings = Firebolt::IFireboltAccessor::Instance().AccessibilityInterface().voiceGuidance(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + + EXPECT_EQ(voiceGuidanceSettings.enabled, expectedValues["enabled"]); + EXPECT_EQ(voiceGuidanceSettings.speed, expectedValues["speed"]); +} + + +TEST_F(AccessibilityTest, VoiceGuidanceSettings) +{ + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Accessibility.voiceGuidanceSettings")); + + auto voiceGuidanceSettings = Firebolt::IFireboltAccessor::Instance().AccessibilityInterface().voiceGuidanceSettings(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + + EXPECT_EQ(voiceGuidanceSettings.enabled, expectedValues["enabled"]); + EXPECT_EQ(voiceGuidanceSettings.speed, expectedValues["speed"]); +} + + +TEST_F(AccessibilityTest, AudioDescriptionSettings) +{ + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Accessibility.audioDescriptionSettings")); + + auto audioDescriptionSettings = Firebolt::IFireboltAccessor::Instance().AccessibilityInterface().audioDescriptionSettings(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + + EXPECT_EQ(audioDescriptionSettings.enabled, expectedValues["enabled"]); +} + + +// TEST_F(AccessibilityTest, onClosedCaptionsSettingsChanged) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Accessibility.onClosedCaptionsSettingsChanged"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().AccessibilityInterface().onClosedCaptionsSettingsChanged(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(AccessibilityTest, onVoiceGuidanceSettingsChanged) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Accessibility.onVoiceGuidanceSettingsChanged"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().AccessibilityInterface().onVoiceGuidanceSettingsChanged(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(AccessibilityTest, onAudioDescriptionSettingsChanged) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Accessibility.onAudioDescriptionSettingsChanged"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().AccessibilityInterface().onAudioDescriptionSettingsChanged(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } \ No newline at end of file diff --git a/src/sdks/core/src/cpp/sdk/cpptest/unit/accountTest.cpp b/src/sdks/core/src/cpp/sdk/cpptest/unit/accountTest.cpp new file mode 100644 index 000000000..fcf623211 --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/cpptest/unit/accountTest.cpp @@ -0,0 +1,40 @@ +#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, Id) +{ + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Account.id")); + + std::string value = Firebolt::IFireboltAccessor::Instance().AccountInterface().id(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, expectedValues); +} + + +TEST_F(AccountTest, Uid) +{ + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Account.uid")); + + std::string value = Firebolt::IFireboltAccessor::Instance().AccountInterface().uid(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, expectedValues); +} \ No newline at end of file diff --git a/src/sdks/core/src/cpp/sdk/cpptest/unit/advertisingTest.cpp b/src/sdks/core/src/cpp/sdk/cpptest/unit/advertisingTest.cpp new file mode 100644 index 000000000..ab63a55d2 --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/cpptest/unit/advertisingTest.cpp @@ -0,0 +1,109 @@ +#include "unit.h" + + +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; + } + + std::string skipRestrictionToString(Firebolt::Advertising::SkipRestriction skipRestriction) + { + std::string str = ""; + switch(skipRestriction) + { + case Firebolt::Advertising::SkipRestriction::NONE: str = "none"; break; + case Firebolt::Advertising::SkipRestriction::ADS_UNWATCHED: str = "adsUnwatched"; break; + case Firebolt::Advertising::SkipRestriction::ADS_ALL: str = "adsAll"; break; + case Firebolt::Advertising::SkipRestriction::ALL: str = "all"; break; + default: str = "unknown"; + } + return str; + } + +}; + + +TEST_F(AdvertisingTest, Config) +{ + std::string expectedValues = jsonEngine->get_value("Advertising.config"); + + Firebolt::Advertising::AdConfigurationOptions options; + std::string adFrameworkConfig = Firebolt::IFireboltAccessor::Instance().AdvertisingInterface().config(options, &error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ((nlohmann::json::parse(adFrameworkConfig)).dump(), expectedValues); +} + + +TEST_F(AdvertisingTest, Policy) +{ + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Advertising.policy")); + + Firebolt::Advertising::AdPolicy adPolicy = Firebolt::IFireboltAccessor::Instance().AdvertisingInterface().policy(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + + if(adPolicy.limitAdTracking.has_value()) + EXPECT_EQ(adPolicy.limitAdTracking, expectedValues["limitAdTracking"]); + + if(adPolicy.skipRestriction.has_value()) + EXPECT_EQ(skipRestrictionToString(adPolicy.skipRestriction.value()), expectedValues["skipRestriction"]); +} + + +TEST_F(AdvertisingTest, Id) { + nlohmann::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Advertising.advertisingId")); + + std::optional options = std::nullopt; // Assuming options are not provided + + Firebolt::Advertising::AdvertisingId actualValues= Firebolt::IFireboltAccessor::Instance().AdvertisingInterface().advertisingId(options, &error); + + ASSERT_EQ(error, Firebolt::Error::None) << "Error occurred during advertisingId call"; + + EXPECT_EQ(actualValues.ifa, expectedValues["ifa"]); + EXPECT_EQ(actualValues.ifa_type, expectedValues["ifa_type"]); + EXPECT_EQ(actualValues.lmt, expectedValues["lmt"]); +} + + +TEST_F(AdvertisingTest, DeviceAttributes) +{ + std::string expectedValues = jsonEngine->get_value("Advertising.deviceAttributes"); + + std::string deviceAttributes = Firebolt::IFireboltAccessor::Instance().AdvertisingInterface().deviceAttributes(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(deviceAttributes, expectedValues); +} + + +TEST_F(AdvertisingTest, TestAdvertisingAppBundleId) +{ + + auto actual_value = jsonEngine->get_value("Advertising.appBundleId"); + + auto value = Firebolt::IFireboltAccessor::Instance().AdvertisingInterface().appBundleId(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, REMOVE_QUOTES(actual_value)); +} + + +// TEST_F(AdvertisingTest, TestAdvertisingonPolicyChanged) +// { +// auto expectedValues = jsonEngine->get_value("Advertising.onPolicyChanged"); + +// auto value = Firebolt::IFireboltAccessor::Instance().AdvertisingInterface().onPolicyChanged(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, expectedValues); +// } \ No newline at end of file diff --git a/src/sdks/core/src/cpp/sdk/cpptest/unit/authenticationTest.cpp b/src/sdks/core/src/cpp/sdk/cpptest/unit/authenticationTest.cpp new file mode 100644 index 000000000..61b2554d0 --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/cpptest/unit/authenticationTest.cpp @@ -0,0 +1,64 @@ +#include "unit.h" + + +class AuthenticationTest : 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(AuthenticationTest, Token) + { + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Authentication.token")); + + Firebolt::Authentication::TokenType type = Firebolt::Authentication::TokenType::DEVICE; + std::optional options; + + auto actualValues = Firebolt::IFireboltAccessor::Instance().AuthenticationInterface().token(type, options, &error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(actualValues.value, expectedValues["value"]); +} + + +TEST_F(AuthenticationTest, Device) +{ + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Authentication.device")); + + std::string value = Firebolt::IFireboltAccessor::Instance().AuthenticationInterface().device(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, expectedValues); +} + + +TEST_F(AuthenticationTest, Session) +{ + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Authentication.session")); + + std::string value = Firebolt::IFireboltAccessor::Instance().AuthenticationInterface().session(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, expectedValues); +} + + +TEST_F(AuthenticationTest, Root) +{ + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Authentication.root")); + + std::string value = Firebolt::IFireboltAccessor::Instance().AuthenticationInterface().root(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, expectedValues); +} \ No newline at end of file diff --git a/src/sdks/core/src/cpp/sdk/cpptest/unit/capabilitiesTest.cpp b/src/sdks/core/src/cpp/sdk/cpptest/unit/capabilitiesTest.cpp new file mode 100644 index 000000000..f273b5845 --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/cpptest/unit/capabilitiesTest.cpp @@ -0,0 +1,211 @@ +#include "unit.h" + + +class CapabilitiesTest : 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(CapabilitiesTest, Supported) +{ + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Capabilities.supported")); + + + bool supported = Firebolt::IFireboltAccessor::Instance().CapabilitiesInterface().supported("xrn:firebolt:capability:wifi:scan", &error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(supported, expectedValues); +} + + +TEST_F(CapabilitiesTest, CapabilitiesSupported) +{ + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Capabilities.supported")); + + std::string capability = "xrn:firebolt:capability:wifi:scan"; + + bool status = Firebolt::IFireboltAccessor::Instance().CapabilitiesInterface().supported(capability, &error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(status, expectedValues); +} + +TEST_F(CapabilitiesTest, Available) +{ + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Capabilities.available")); + + std::string capability = "xrn:firebolt:capability:token:device"; + + bool status = Firebolt::IFireboltAccessor::Instance().CapabilitiesInterface().available(capability, &error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(status, expectedValues); +} + + + +TEST_F(CapabilitiesTest, Permitted) +{ + nlohmann::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Capabilities.permitted")); + + std::string capability = "xrn:firebolt:capability:input:keyboard"; + + // Initialize options with a role + std::optional options; + options.emplace(); // Initialize the optional + options->role = Firebolt::Capabilities::Role::MANAGE; + + // Call the permitted function + bool status = Firebolt::IFireboltAccessor::Instance().CapabilitiesInterface().permitted(capability, options, &error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(status, expectedValues); +} + +TEST_F(CapabilitiesTest, Granted) +{ + nlohmann::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Capabilities.granted")); + std::string capability = "xrn:firebolt:capability:localization:postal-code"; + + std::optional options; + bool status = Firebolt::IFireboltAccessor::Instance().CapabilitiesInterface().granted(capability, options, &error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(status, expectedValues); +} + + +TEST_F(CapabilitiesTest, TestCapabilitiesinfo) { + // Parse the expected values from the JSON + nlohmann::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Capabilities.info")); + + // Extract the expected result for the specific capability + nlohmann::json expectedValue; + for (const auto& item : expectedValues) { + if (item["capability"] == "xrn:firebolt:capability:device:model") { + expectedValue = item; + break; + } + } + // Define the capabilities to query + std::vector capabilities = { + "xrn:firebolt:capability:device:model" + }; + + // Call the method to get actual results + Firebolt::Error error; + std::vector actualValues = Firebolt::IFireboltAccessor::Instance().CapabilitiesInterface().info(capabilities, &error); + + // Ensure there's at least one result + ASSERT_FALSE(actualValues.empty()); + + // Compare the first actual value with the expected value + Firebolt::Capabilities::CapabilityInfo actualValue = actualValues[0]; + + // Compare each field + EXPECT_EQ(actualValue.capability, expectedValue["capability"].get()); + EXPECT_EQ(actualValue.supported, expectedValue["supported"].get()); + EXPECT_EQ(actualValue.available, expectedValue["available"].get()); + + if (expectedValue.contains("use")) { + if (expectedValue["use"].contains("permitted")) { + auto expectedPermitted = expectedValue["use"]["permitted"].is_null() ? std::optional{} : std::make_optional(expectedValue["use"]["permitted"].get()); + EXPECT_EQ(actualValue.use.permitted, expectedPermitted); + } + if (expectedValue["use"].contains("granted")) { + auto expectedGranted = expectedValue["use"]["granted"].is_null() ? std::optional{} : std::make_optional(expectedValue["use"]["granted"].get()); + EXPECT_EQ(actualValue.use.granted, expectedGranted); + } + } + + if (expectedValue.contains("manage")) { + if (expectedValue["manage"].contains("permitted")) { + auto expectedPermitted = expectedValue["manage"]["permitted"].is_null() ? std::optional{} : std::make_optional(expectedValue["manage"]["permitted"].get()); + EXPECT_EQ(actualValue.manage.permitted, expectedPermitted); + } + if (expectedValue["manage"].contains("granted")) { + auto expectedGranted = expectedValue["manage"]["granted"].is_null() ? std::optional{} : std::make_optional(expectedValue["manage"]["granted"].get()); + EXPECT_EQ(actualValue.manage.granted, expectedGranted); + } + } + + if (expectedValue.contains("provide")) { + if (expectedValue["provide"].contains("permitted")) { + auto expectedPermitted = expectedValue["provide"]["permitted"].is_null() ? std::optional{} : std::make_optional(expectedValue["provide"]["permitted"].get()); + EXPECT_EQ(actualValue.provide.permitted, expectedPermitted); + } + if (expectedValue["provide"].contains("granted")) { + auto expectedGranted = expectedValue["provide"]["granted"].is_null() ? std::optional{} : std::make_optional(expectedValue["provide"]["granted"].get()); + EXPECT_EQ(actualValue.provide.granted, expectedGranted); + } + } + + EXPECT_EQ(error, Firebolt::Error::None); +} + + +// TEST_F(CapabilitiesTest, TestCapabilitiesrequest) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Capabilities.request"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().CapabilitiesInterface().request(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(CapabilitiesTest, TestCapabilitiesonAvailable) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Capabilities.onAvailable"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().CapabilitiesInterface().onAvailable(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(CapabilitiesTest, TestCapabilitiesonUnavailable) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Capabilities.onUnavailable"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().CapabilitiesInterface().onUnavailable(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(CapabilitiesTest, TestCapabilitiesonGranted) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Capabilities.onGranted"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().CapabilitiesInterface().onGranted(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(CapabilitiesTest, TestCapabilitiesonRevoked) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Capabilities.onRevoked"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().CapabilitiesInterface().onRevoked(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } \ No newline at end of file diff --git a/src/sdks/core/src/cpp/sdk/cpptest/unit/deviceTest.cpp b/src/sdks/core/src/cpp/sdk/cpptest/unit/deviceTest.cpp new file mode 100644 index 000000000..a43699dc7 --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/cpptest/unit/deviceTest.cpp @@ -0,0 +1,385 @@ +#include "unit.h" + + +class DeviceTest : public ::testing::Test { + protected: + JsonEngine* jsonEngine; + + + void SetUp() override + { + jsonEngine = new JsonEngine(); + } + + void TearDown() override + { + delete jsonEngine; + } +}; + + +TEST_F(DeviceTest, TestDeviceId) +{ + Firebolt::Error error = Firebolt::Error::None; + auto actual_value = jsonEngine->get_value("Device.id"); + + auto value = Firebolt::IFireboltAccessor::Instance().DeviceInterface().id(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, REMOVE_QUOTES(actual_value)); +} + + +TEST_F(DeviceTest, TestDeviceDistributor) +{ + Firebolt::Error error = Firebolt::Error::None; + auto actual_value = jsonEngine->get_value("Device.distributor"); + + auto value = Firebolt::IFireboltAccessor::Instance().DeviceInterface().distributor(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, REMOVE_QUOTES(actual_value)); +} + + +TEST_F(DeviceTest, TestDevicePlatform) +{ + Firebolt::Error error = Firebolt::Error::None; + auto actual_value = jsonEngine->get_value("Device.platform"); + + auto value = Firebolt::IFireboltAccessor::Instance().DeviceInterface().platform(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, REMOVE_QUOTES(actual_value)); +} + + +TEST_F(DeviceTest, TestDeviceUid) +{ + Firebolt::Error error = Firebolt::Error::None; + auto actual_value = jsonEngine->get_value("Device.uid"); + + auto value = Firebolt::IFireboltAccessor::Instance().DeviceInterface().uid(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, REMOVE_QUOTES(actual_value)); +} + + +TEST_F(DeviceTest, TestDeviceType) +{ + Firebolt::Error error = Firebolt::Error::None; + auto actual_value = jsonEngine->get_value("Device.type"); + + auto value = Firebolt::IFireboltAccessor::Instance().DeviceInterface().type(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, REMOVE_QUOTES(actual_value)); +} + + +TEST_F(DeviceTest, TestDeviceModel) +{ + Firebolt::Error error = Firebolt::Error::None; + auto actual_value = jsonEngine->get_value("Device.model"); + + auto value = Firebolt::IFireboltAccessor::Instance().DeviceInterface().model(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, REMOVE_QUOTES(actual_value)); +} + + +TEST_F(DeviceTest, TestDeviceSku) +{ + Firebolt::Error error = Firebolt::Error::None; + auto actual_value = jsonEngine->get_value("Device.sku"); + + auto value = Firebolt::IFireboltAccessor::Instance().DeviceInterface().sku(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, REMOVE_QUOTES(actual_value)); +} + + +TEST_F(DeviceTest, TestDeviceMake) +{ + Firebolt::Error error = Firebolt::Error::None; + auto actual_value = jsonEngine->get_value("Device.make"); + + auto value = Firebolt::IFireboltAccessor::Instance().DeviceInterface().make(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, REMOVE_QUOTES(actual_value)); +} + +// TEST_F(DeviceTest, TestDeviceversion) +// { +// Firebolt::Error error = Firebolt::Error::None; +// nlohmann::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Device.version")); + +// std::string actualValueStr = Firebolt::IFireboltAccessor::Instance().DeviceInterface().version(&error); +// nlohmann::json actualValue = nlohmann::json::parse(actualValueStr); + +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(actualValue, expectedValues); +// } + +TEST_F(DeviceTest, TestDevicehdcp) +{ + Firebolt::Error error = Firebolt::Error::None; + + // Parsing expected JSON values into a BooleanMap + nlohmann::json expectedJson = nlohmann::json::parse(jsonEngine->get_value("Device.hdcp")); + Firebolt::Types::BooleanMap expectedValues; + + for (auto it = expectedJson.begin(); it != expectedJson.end(); ++it) { + expectedValues[it.key()] = it.value().get(); + } + + // Getting the actual value from the DeviceInterface + Firebolt::Types::BooleanMap actualValue = Firebolt::IFireboltAccessor::Instance().DeviceInterface().hdcp(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(actualValue, expectedValues); +} + + +TEST_F(DeviceTest, TestDevicehdr) +{ + Firebolt::Error error = Firebolt::Error::None; + + // Parsing expected JSON values into a BooleanMap + nlohmann::json expectedJson = nlohmann::json::parse(jsonEngine->get_value("Device.hdr")); + Firebolt::Types::BooleanMap expectedValues; + + for (auto it = expectedJson.begin(); it != expectedJson.end(); ++it) { + expectedValues[it.key()] = it.value().get(); + } + + // Getting the actual value from the DeviceInterface + Firebolt::Types::BooleanMap actualValue = Firebolt::IFireboltAccessor::Instance().DeviceInterface().hdr(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(actualValue, expectedValues); +} + + +std::string AudioProfileToString(Firebolt::Types::AudioProfile profile) { + switch (profile) { + case Firebolt::Types::AudioProfile::STEREO: + return "stereo"; + case Firebolt::Types::AudioProfile::DOLBY_DIGITAL_5_1: + return "dolbyDigital5.1+"; + case Firebolt::Types::AudioProfile::DOLBY_ATMOS: + return "dolbyAtmos"; + default: + return "dolbyDigital5.1"; + + } +} + +TEST_F(DeviceTest, TestDeviceaudio) +{ + Firebolt::Error error = Firebolt::Error::None; + + // Parse expected JSON values + nlohmann::json expectedJson = nlohmann::json::parse(jsonEngine->get_value("Device.audio")); + + // Getting the actual value from the DeviceInterface + const Firebolt::Device::AudioProfiles actualValue = Firebolt::IFireboltAccessor::Instance().DeviceInterface().audio(&error); + + // Convert actualValue (AudioProfiles map) to JSON + nlohmann::json actualJson; + for (const auto& item : actualValue) { + std::string profileKey = AudioProfileToString(item.first); // Replace this with the correct conversion function + actualJson[profileKey] = item.second; + } + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(actualJson, expectedJson); +} + +TEST_F(DeviceTest, TestDevicenetwork) +{ + Firebolt::Error error = Firebolt::Error::None; + + // Hardcoded expected values + Firebolt::Device::NetworkInfo expectedValues; + expectedValues.state = Firebolt::Device::NetworkState::CONNECTED; + expectedValues.type = Firebolt::Device::NetworkType::WIFI; + + // Getting the actual value from the DeviceInterface + Firebolt::Device::NetworkInfo actualValue = Firebolt::IFireboltAccessor::Instance().DeviceInterface().network(&error); + + // Perform the assertions + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(actualValue.state, expectedValues.state); + EXPECT_EQ(actualValue.type, expectedValues.type); +} + +TEST_F(DeviceTest, DeviceScreenResolution) +{ + Firebolt::Error error = Firebolt::Error::None; + + // Parse expected JSON values + nlohmann::json expectedJson; + try { + std::string jsonString = jsonEngine->get_value("Device.screenResolution"); + expectedJson = nlohmann::json::parse(jsonString); + } catch (const nlohmann::json::exception& e) { + FAIL() << "Failed to parse JSON: " << e.what(); + } + + // Validate that expectedJson is an array and has the required number of elements + if (!expectedJson.is_array()) { + FAIL() << "Expected JSON is not an array: " << expectedJson.dump(4); + } + + if (expectedJson.size() != 2) { + FAIL() << "Expected JSON array does not have 2 elements: " << expectedJson.dump(4); + } + + // Getting the actual value from the DeviceInterface + Firebolt::Device::Resolution actualResolution = Firebolt::IFireboltAccessor::Instance().DeviceInterface().screenResolution(&error); + + // Convert actual value to JSON + nlohmann::json actualJson = { actualResolution.first, actualResolution.second }; + + // Perform the assertions + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(actualJson, expectedJson); +} + +TEST_F(DeviceTest, DevicevideoResolution) +{ + Firebolt::Error error = Firebolt::Error::None; + + // Parse expected JSON values + nlohmann::json expectedJson; + try { + std::string jsonString = jsonEngine->get_value("Device.screenResolution"); + expectedJson = nlohmann::json::parse(jsonString); + } catch (const nlohmann::json::exception& e) { + FAIL() << "Failed to parse JSON: " << e.what(); + } + + // Validate that expectedJson is an array and has the required number of elements + if (!expectedJson.is_array()) { + FAIL() << "Expected JSON is not an array: " << expectedJson.dump(4); + } + + if (expectedJson.size() != 2) { + FAIL() << "Expected JSON array does not have 2 elements: " << expectedJson.dump(4); + } + + // Getting the actual value from the DeviceInterface + Firebolt::Device::Resolution actualResolution = Firebolt::IFireboltAccessor::Instance().DeviceInterface().videoResolution(&error); + + // Convert actual value to JSON + nlohmann::json actualJson = { actualResolution.first, actualResolution.second }; + + // Perform the assertions + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(actualJson, expectedJson); +} + + +TEST_F(DeviceTest, TestDeviceName) +{ + Firebolt::Error error = Firebolt::Error::None; + auto actual_value = jsonEngine->get_value("Device.name"); + + auto value = Firebolt::IFireboltAccessor::Instance().DeviceInterface().name(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, REMOVE_QUOTES(actual_value)); +} + + +// TEST_F(DeviceTest, TestDeviceonDeviceNameChanged) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Device.onDeviceNameChanged"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().DeviceInterface().onDeviceNameChanged(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(DeviceTest, TestDeviceonNameChanged) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Device.onNameChanged"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().DeviceInterface().onNameChanged(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(DeviceTest, TestDeviceonHdcpChanged) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Device.onHdcpChanged"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().DeviceInterface().onHdcpChanged(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(DeviceTest, TestDeviceonHdrChanged) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Device.onHdrChanged"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().DeviceInterface().onHdrChanged(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(DeviceTest, TestDeviceonAudioChanged) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Device.onAudioChanged"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().DeviceInterface().onAudioChanged(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(DeviceTest, TestDeviceonScreenResolutionChanged) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Device.onScreenResolutionChanged"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().DeviceInterface().onScreenResolutionChanged(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(DeviceTest, TestDeviceonVideoResolutionChanged) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Device.onVideoResolutionChanged"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().DeviceInterface().onVideoResolutionChanged(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(DeviceTest, TestDeviceonNetworkChanged) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Device.onNetworkChanged"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().DeviceInterface().onNetworkChanged(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } \ No newline at end of file diff --git a/src/sdks/core/src/cpp/sdk/cpptest/unit/discoveryTest.cpp b/src/sdks/core/src/cpp/sdk/cpptest/unit/discoveryTest.cpp new file mode 100644 index 000000000..dbc7fc3af --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/cpptest/unit/discoveryTest.cpp @@ -0,0 +1,182 @@ +#include "unit.h" + + +// class DiscoveryTest : public ::testing::Test { +// protected: +// JsonEngine* jsonEngine; + +// void SetUp() override +// { +// jsonEngine = new JsonEngine(); +// } + +// void TearDown() override +// { +// delete jsonEngine; +// } +// }; + + +// TEST_F(DiscoveryTest, TestDiscoverypolicy) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Discovery.policy"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().policy(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(DiscoveryTest, TestDiscoveryentityInfo) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Discovery.entityInfo"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().entityInfo(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(DiscoveryTest, TestDiscoverypurchasedContent) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Discovery.purchasedContent"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().purchasedContent(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(DiscoveryTest, TestDiscoverywatched) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Discovery.watched"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().watched(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(DiscoveryTest, TestDiscoverywatchNext) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Discovery.watchNext"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().watchNext(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(DiscoveryTest, TestDiscoveryentitlements) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Discovery.entitlements"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().entitlements(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(DiscoveryTest, TestDiscoverycontentAccess) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Discovery.contentAccess"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().contentAccess(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(DiscoveryTest, TestDiscoveryclearContentAccess) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Discovery.clearContentAccess"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().clearContentAccess(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(DiscoveryTest, TestDiscoverylaunch) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Discovery.launch"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().launch(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(DiscoveryTest, TestDiscoveryonNavigateTo) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Discovery.onNavigateTo"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().onNavigateTo(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(DiscoveryTest, TestDiscoverysignIn) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Discovery.signIn"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().signIn(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(DiscoveryTest, TestDiscoverysignOut) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Discovery.signOut"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().signOut(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(DiscoveryTest, TestDiscoveryonPolicyChanged) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Discovery.onPolicyChanged"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().onPolicyChanged(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(DiscoveryTest, TestDiscoveryonPullEntityInfo) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Discovery.onPullEntityInfo"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().onPullEntityInfo(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(DiscoveryTest, TestDiscoveryonPullPurchasedContent) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Discovery.onPullPurchasedContent"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().onPullPurchasedContent(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } \ No newline at end of file diff --git a/src/sdks/core/src/cpp/sdk/cpptest/unit/internalTest.cpp b/src/sdks/core/src/cpp/sdk/cpptest/unit/internalTest.cpp new file mode 100644 index 000000000..376cf7efd --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/cpptest/unit/internalTest.cpp @@ -0,0 +1,28 @@ +#include "unit.h" + + +// class InternalTest : public ::testing::Test { +// protected: +// JsonEngine* jsonEngine; + +// void SetUp() override +// { +// jsonEngine = new JsonEngine(); +// } + +// void TearDown() override +// { +// delete jsonEngine; +// } +// }; + + +// TEST_F(InternalTest, TestInternalinitialize) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Internal.initialize"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().InternalInterface().initialize(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } \ No newline at end of file diff --git a/src/sdks/core/src/cpp/sdk/cpptest/unit/keyboardTest.cpp b/src/sdks/core/src/cpp/sdk/cpptest/unit/keyboardTest.cpp new file mode 100644 index 000000000..32532da0d --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/cpptest/unit/keyboardTest.cpp @@ -0,0 +1,50 @@ +#include "unit.h" + + +// class KeyboardTest : public ::testing::Test { +// protected: +// JsonEngine* jsonEngine; + +// void SetUp() override +// { +// jsonEngine = new JsonEngine(); +// } + +// void TearDown() override +// { +// delete jsonEngine; +// } +// }; + + +// TEST_F(KeyboardTest, TestKeyboardemail) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Keyboard.email"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().KeyboardInterface().email(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(KeyboardTest, TestKeyboardpassword) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Keyboard.password"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().KeyboardInterface().password(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(KeyboardTest, TestKeyboardstandard) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Keyboard.standard"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().KeyboardInterface().standard(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } \ No newline at end of file diff --git a/src/sdks/core/src/cpp/sdk/cpptest/unit/lifecycleTest.cpp b/src/sdks/core/src/cpp/sdk/cpptest/unit/lifecycleTest.cpp new file mode 100644 index 000000000..6d5cac46a --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/cpptest/unit/lifecycleTest.cpp @@ -0,0 +1,142 @@ +#include "unit.h" + + +class LifecycleTest : 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(LifecycleTest, TestLifecycleready) { + +// nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Lifecycle.ready")); + +// Firebolt::IFireboltAccessor::Instance().LifecycleInterface().ready(&error); +// nlohmann::json_abi_v3_11_3::json actualValues; +// if (error == Firebolt::Error::None) { +// // If successful, set actualValues to null +// actualValues = nlohmann::json::value_t::null; +// } + +// EXPECT_EQ(error, Firebolt::Error::None); + +// EXPECT_EQ(actualValues, expectedValues); +// } + +// TEST_F(LifecycleTest, Lifecyclefinished) { + +// nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Lifecycle.finished")); + +// Firebolt::IFireboltAccessor::Instance().LifecycleInterface().finished(&error); +// nlohmann::json_abi_v3_11_3::json actualValues; +// if (error == Firebolt::Error::None) { +// // If successful, set actualValues to null +// actualValues = nlohmann::json::value_t::null; +// } + +// EXPECT_EQ(error, Firebolt::Error::None); + +// EXPECT_EQ(actualValues, expectedValues); +// } + +// TEST_F(LifecycleTest, Lifecyclestate) { + +// nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Lifecycle.state")); + +// std::string actualValues = Firebolt::IFireboltAccessor::Instance().LifecycleInterface().state(&error); + +// EXPECT_EQ(error, Firebolt::Error::None); + +// EXPECT_NE(actualValues, expectedValues); +// } + + TEST_F(LifecycleTest, Lifecycleclose) +{ + Firebolt::Error error = Firebolt::Error::None; + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Lifecycle.close")); + + + Firebolt::IFireboltAccessor::Instance().LifecycleInterface().close(Firebolt::Lifecycle::CloseReason::USER_EXIT, &error); + nlohmann::json_abi_v3_11_3::json actualValues; + if (error == Firebolt::Error::None) { + // If successful, set actualValues to null + actualValues = nlohmann::json::value_t::null; + } + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(expectedValues, actualValues); +} + +// TEST_F(LifecycleTest, TestLifecycleclose) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Lifecycle.close"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().LifecycleInterface().close(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + +// TEST_F(LifecycleTest, TestLifecycleonInactive) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Lifecycle.onInactive"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().LifecycleInterface().onInactive(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(LifecycleTest, TestLifecycleonForeground) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Lifecycle.onForeground"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().LifecycleInterface().onForeground(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(LifecycleTest, TestLifecycleonBackground) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Lifecycle.onBackground"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().LifecycleInterface().onBackground(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(LifecycleTest, TestLifecycleonSuspended) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Lifecycle.onSuspended"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().LifecycleInterface().onSuspended(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(LifecycleTest, TestLifecycleonUnloading) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Lifecycle.onUnloading"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().LifecycleInterface().onUnloading(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } \ No newline at end of file diff --git a/src/sdks/core/src/cpp/sdk/cpptest/unit/localizationTest.cpp b/src/sdks/core/src/cpp/sdk/cpptest/unit/localizationTest.cpp new file mode 100644 index 000000000..e48382220 --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/cpptest/unit/localizationTest.cpp @@ -0,0 +1,171 @@ +#include "unit.h" + + +// class LocalizationTest : public ::testing::Test { +// protected: +// JsonEngine* jsonEngine; + +// void SetUp() override +// { +// jsonEngine = new JsonEngine(); +// } + +// void TearDown() override +// { +// delete jsonEngine; +// } +// }; + + +// TEST_F(LocalizationTest, TestLocalizationlocality) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Localization.locality"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().locality(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(LocalizationTest, TestLocalizationpostalCode) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Localization.postalCode"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().postalCode(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(LocalizationTest, TestLocalizationcountryCode) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Localization.countryCode"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().countryCode(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(LocalizationTest, TestLocalizationlanguage) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Localization.language"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().language(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(LocalizationTest, TestLocalizationpreferredAudioLanguages) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Localization.preferredAudioLanguages"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().preferredAudioLanguages(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(LocalizationTest, TestLocalizationlocale) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Localization.locale"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().locale(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(LocalizationTest, TestLocalizationlatlon) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Localization.latlon"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().latlon(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(LocalizationTest, TestLocalizationadditionalInfo) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Localization.additionalInfo"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().additionalInfo(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(LocalizationTest, TestLocalizationonLocalityChanged) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Localization.onLocalityChanged"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().onLocalityChanged(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(LocalizationTest, TestLocalizationonPostalCodeChanged) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Localization.onPostalCodeChanged"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().onPostalCodeChanged(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(LocalizationTest, TestLocalizationonCountryCodeChanged) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Localization.onCountryCodeChanged"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().onCountryCodeChanged(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(LocalizationTest, TestLocalizationonLanguageChanged) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Localization.onLanguageChanged"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().onLanguageChanged(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(LocalizationTest, TestLocalizationonPreferredAudioLanguagesChanged) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Localization.onPreferredAudioLanguagesChanged"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().onPreferredAudioLanguagesChanged(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(LocalizationTest, TestLocalizationonLocaleChanged) +// { +// Firebolt::Error error = Firebolt::Error::None; +// auto actual_value = jsonEngine->get_value("Localization.onLocaleChanged"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().onLocaleChanged(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } \ No newline at end of file diff --git a/src/sdks/core/src/cpp/sdk/cpptest/unit/metricsTest.cpp b/src/sdks/core/src/cpp/sdk/cpptest/unit/metricsTest.cpp new file mode 100644 index 000000000..b5e7b458d --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/cpptest/unit/metricsTest.cpp @@ -0,0 +1,254 @@ +#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, Metricsready) +// { +// // Parse the expected values from the JSON +// nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Metrics.ready")); + +// bool status = Firebolt::IFireboltAccessor::Instance().MetricsInterface().ready(&error); + +// // Compare the expected and actual results +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(status, expectedValues); +// } + +// TEST_F(MetricsTest, TestMetricssignIn) +// { +// // Parse the expected values from the JSON +// nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Metrics.signIn")); + +// bool status = Firebolt::IFireboltAccessor::Instance().MetricsInterface().signIn(&error); + +// // Compare the expected and actual results +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(status, expectedValues); +// } + +// TEST_F(MetricsTest, MetricssignOut) +// { +// // Parse the expected values from the JSON +// nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Metrics.signOut")); + +// bool status = Firebolt::IFireboltAccessor::Instance().MetricsInterface().signOut(&error); + +// // Compare the expected and actual results +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(status, expectedValues); +// } + + + +TEST_F(MetricsTest, TestMetricsStartContent) +{ + Firebolt::Error error = Firebolt::Error::None; + auto actual_value = jsonEngine->get_value("Metrics.startContent"); + + auto value = Firebolt::IFireboltAccessor::Instance().MetricsInterface().startContent("example", &error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, STRING_TO_BOOL(actual_value)); +} + + +TEST_F(MetricsTest, TestMetricsStopContent) +{ + Firebolt::Error error = Firebolt::Error::None; + auto actual_value = jsonEngine->get_value("Metrics.stopContent"); + + auto value = Firebolt::IFireboltAccessor::Instance().MetricsInterface().stopContent("example", &error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, STRING_TO_BOOL(actual_value)); +} + + +TEST_F(MetricsTest, Metricspage) +{ + // Parse the expected values from the JSON + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Metrics.page")); + + std::string pageId = "xyz"; + + bool status = Firebolt::IFireboltAccessor::Instance().MetricsInterface().page(pageId,&error); + + // Compare the expected and actual results + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(status, expectedValues); +} + +TEST_F(MetricsTest, Metricsaction) +{ + // Parse the expected values from the JSON + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Metrics.action")); + std::cout << "Expected value for capability " << expectedValues << std::endl; + + + + Firebolt::Metrics::Category category = Firebolt::Metrics::Category::USER; + auto type = "The user did foo"; + std::optional parameters = std::nullopt; + + bool status = Firebolt::IFireboltAccessor::Instance().MetricsInterface().action(category, type, parameters, &error); + std::cout << "Status value for capability " << status << std::endl; + + // Compare the expected and actual results + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(status, expectedValues); +} + +TEST_F(MetricsTest, Metricserror) +{ + // Parse the expected values from the JSON + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Metrics.error")); + std::cout << "Expected value for capability " << expectedValues << std::endl; + + Firebolt::Metrics::ErrorType type = Firebolt::Metrics::ErrorType::MEDIA; + std::string code = "MEDIA-STALLED"; + std::string description = "playback stalled"; + std::optional parameters = std::nullopt; + bool visible = true; + + + bool status = Firebolt::IFireboltAccessor::Instance().MetricsInterface().error(type,code,description,visible,parameters,&error); + std::cout << "Status value for capability " << status << std::endl; + + // Compare the expected and actual results + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(status, expectedValues); +} + + +TEST_F(MetricsTest, TestMetricsLoadStart) +{ + auto actual_value = jsonEngine->get_value("Metrics.mediaLoadStart"); + + auto value = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaLoadStart("345", &error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, STRING_TO_BOOL(actual_value)); +} + +TEST_F(MetricsTest, TestMetricsMediaPlay) +{ + auto actual_value = jsonEngine->get_value("Metrics.mediaPlay"); + + auto value = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaPlay("345", &error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, STRING_TO_BOOL(actual_value)); +} + + +TEST_F(MetricsTest, TestMetricsMediaPlaying) +{ + std::string actual_value = jsonEngine->get_value("Metrics.mediaPlaying"); + + auto value = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaPlaying("345", &error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, STRING_TO_BOOL(actual_value)); +} + + +TEST_F(MetricsTest, TestMetricsmediaPause) +{ + std::string actual_value = jsonEngine->get_value("Metrics.mediaPause"); + + auto value = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaPause("345", &error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, STRING_TO_BOOL(actual_value)); +} + +TEST_F(MetricsTest, MetricsmediaWaiting) +{ + std::string actual_value = jsonEngine->get_value("Metrics.mediaWaiting"); + + auto value = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaWaiting("345", &error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, STRING_TO_BOOL(actual_value)); +} + +TEST_F(MetricsTest, MetricsmediaProgress) +{ + std::string actual_value = jsonEngine->get_value("Metrics.mediaProgress"); + + auto value = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaProgress("345","0.75", &error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, STRING_TO_BOOL(actual_value)); +} + +TEST_F(MetricsTest, MetricsmediaSeeking) +{ + std::string actual_value = jsonEngine->get_value("Metrics.mediaSeeking"); + + auto value = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaSeeking("345","0.25", &error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, STRING_TO_BOOL(actual_value)); +} + + +TEST_F(MetricsTest, TestMetricsmediaSeeked) +{ + std::string actual_value = jsonEngine->get_value("Metrics.mediaSeeked"); + + auto value = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaSeeked("345","0.51", &error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, STRING_TO_BOOL(actual_value)); +} + +TEST_F(MetricsTest, TestMetricsmediaRateChange) +{ + std::string actual_value = jsonEngine->get_value("Metrics.mediaRateChange"); + + auto value = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaRateChange("345",2, &error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, STRING_TO_BOOL(actual_value)); +} + +TEST_F(MetricsTest, TestMetricsmediaRenditionChange) +{ + std::string actual_value = jsonEngine->get_value("Metrics.mediaRenditionChange"); + std::optional profile = std::nullopt; + + auto value = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaRenditionChange("345", 1080, 950, 1020, profile, &error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, STRING_TO_BOOL(actual_value)); +} + + TEST_F(MetricsTest, TestMetricsmediaEnded) +{ + std::string actual_value = jsonEngine->get_value("Metrics.mediaEnded"); + std::optional profile = std::nullopt; + + auto value = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaEnded("345", &error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, STRING_TO_BOOL(actual_value)); +} + diff --git a/src/sdks/core/src/cpp/sdk/cpptest/unit/parametersTest.cpp b/src/sdks/core/src/cpp/sdk/cpptest/unit/parametersTest.cpp new file mode 100644 index 000000000..933a3c6a1 --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/cpptest/unit/parametersTest.cpp @@ -0,0 +1,44 @@ +#include "unit.h" + + +class ParametersTest : 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(ParametersTest, Initialization) +{ + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Parameters.initialization")); + + Firebolt::Parameters::AppInitialization appInitialization = Firebolt::IFireboltAccessor::Instance().ParametersInterface().initialization(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(appInitialization.us_privacy, expectedValues["us_privacy"]); + EXPECT_EQ(appInitialization.lmt, expectedValues["lmt"]); + + nlohmann::json_abi_v3_11_3::json navigateTo = nlohmann::json::parse(appInitialization.discovery.value().navigateTo.value()); + + EXPECT_EQ(navigateTo["action"], + expectedValues["discovery"]["navigateTo"]["action"]); + EXPECT_EQ(navigateTo["context"]["source"], + expectedValues["discovery"]["navigateTo"]["context"]["source"]); + EXPECT_EQ(navigateTo["data"]["entityId"], + expectedValues["discovery"]["navigateTo"]["data"]["entityId"]); + EXPECT_EQ(navigateTo["data"]["entityType"], + expectedValues["discovery"]["navigateTo"]["data"]["entityType"]); + EXPECT_EQ(navigateTo["data"]["programType"], + expectedValues["discovery"]["navigateTo"]["data"]["programType"]); + +} \ No newline at end of file diff --git a/src/sdks/core/src/cpp/sdk/cpptest/unit/profileTest.cpp b/src/sdks/core/src/cpp/sdk/cpptest/unit/profileTest.cpp new file mode 100644 index 000000000..3490e43a9 --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/cpptest/unit/profileTest.cpp @@ -0,0 +1,55 @@ +#include "unit.h" +#include "common/types.h" + + +class ProfileTest : 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(ProfileTest, ApproveContentRating) +{ + + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Profile.approveContentRating")); + + bool value = Firebolt::IFireboltAccessor::Instance().ProfileInterface().approveContentRating(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, expectedValues); +} + + +TEST_F(ProfileTest, ApprovePurchase) +{ + + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Profile.approvePurchase")); + + bool value = Firebolt::IFireboltAccessor::Instance().ProfileInterface().approvePurchase(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, expectedValues); +} + + +TEST_F(ProfileTest, Flags) +{ + + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Profile.flags")); + + Firebolt::Types::FlatMap flag = Firebolt::IFireboltAccessor::Instance().ProfileInterface().flags(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(flag["userExperience"], expectedValues["userExperience"]); +} \ No newline at end of file diff --git a/src/sdks/core/src/cpp/sdk/cpptest/unit/secondScreenTest.cpp b/src/sdks/core/src/cpp/sdk/cpptest/unit/secondScreenTest.cpp new file mode 100644 index 000000000..be4c2490a --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/cpptest/unit/secondScreenTest.cpp @@ -0,0 +1,86 @@ +#include "unit.h" +#include "common/types.h" + + +class SecondScreenTest : 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(SecondScreenTest, Protocols) +// { +// nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("SecondScreen.protocols")); + +// Firebolt::Types::BooleanMap protocols = Firebolt::IFireboltAccessor::Instance().SecondScreenInterface().protocols(&error); + +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(protocols["dial1.7"], expectedValues["dial1.7"]); +// } + + +// TEST_F(SecondScreenTest, Device) +// { +// nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("SecondScreen.device")); + +// std::string value = Firebolt::IFireboltAccessor::Instance().SecondScreenInterface().device("dial", &error); + +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, expectedValues); +// } + + +// TEST_F(SecondScreenTest, FriendlyName) +// { + +// nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("SecondScreen.friendlyName")); + +// std::string friendlyName = Firebolt::IFireboltAccessor::Instance().SecondScreenInterface().friendlyName(&error); +// EXPECT_EQ(error, Firebolt::Error::None); + +// EXPECT_EQ(friendlyName, expectedValues); +// } + + +// TEST_F(SecondScreenTest, TestSecondScreenonLaunchRequest) +// { +// +// nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("SecondScreen.onLaunchRequest"); +// expectedValues = expectedValues.substr(1, expectedValues.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().SecondScreenInterface().onLaunchRequest(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, expectedValues); +// } + + +// TEST_F(SecondScreenTest, TestSecondScreenonCloseRequest) +// { +// +// nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("SecondScreen.onCloseRequest"); +// expectedValues = expectedValues.substr(1, expectedValues.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().SecondScreenInterface().onCloseRequest(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, expectedValues); +// } + + +// TEST_F(SecondScreenTest, TestSecondScreenonFriendlyNameChanged) +// { +// +// nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("SecondScreen.onFriendlyNameChanged"); +// expectedValues = expectedValues.substr(1, expectedValues.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().SecondScreenInterface().onFriendlyNameChanged(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, expectedValues); +// } \ No newline at end of file diff --git a/src/sdks/core/src/cpp/sdk/cpptest/unit/secureStorageTest.cpp b/src/sdks/core/src/cpp/sdk/cpptest/unit/secureStorageTest.cpp new file mode 100644 index 000000000..9c1b16c36 --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/cpptest/unit/secureStorageTest.cpp @@ -0,0 +1,61 @@ +#include "unit.h" + + +// class SecureStorageTest : 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(SecureStorageTest, Get) +// { +// nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("SecureStorage.get")); + +// auto value = Firebolt::IFireboltAccessor::Instance().SecureStorageInterface().get(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(SecureStorageTest, TestSecureStorageset) +// { + +// auto actual_value = jsonEngine->get_value("SecureStorage.set"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().SecureStorageInterface().set(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(SecureStorageTest, TestSecureStorageremove) +// { + +// auto actual_value = jsonEngine->get_value("SecureStorage.remove"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().SecureStorageInterface().remove(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } + + +// TEST_F(SecureStorageTest, TestSecureStorageclear) +// { + +// auto actual_value = jsonEngine->get_value("SecureStorage.clear"); +// actual_value = actual_value.substr(1, actual_value.length() - 2); +// auto value = Firebolt::IFireboltAccessor::Instance().SecureStorageInterface().clear(&error); +// EXPECT_EQ(error, Firebolt::Error::None); +// EXPECT_EQ(value, actual_value); +// } diff --git a/src/sdks/core/src/cpp/sdk/cpptest/unit/unit.h b/src/sdks/core/src/cpp/sdk/cpptest/unit/unit.h new file mode 100644 index 000000000..281096f15 --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/cpptest/unit/unit.h @@ -0,0 +1,5 @@ +#pragma once + +#include "gtest/gtest.h" +#include "../CoreSDKTest.h" +#include "json_engine.h" \ No newline at end of file