-
Notifications
You must be signed in to change notification settings - Fork 26
Feat: Native SDK unit tests part 1 #325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AdityaKasar
wants to merge
11
commits into
next
Choose a base branch
from
feature/core-sdk-unit-test
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
622d05a
test(core): Unit test setup
AdityaKasar 1a139ca
test(core): Accessibility module unit tests
AdityaKasar 415ff9b
test(core): Account module unit tests
AdityaKasar 2b448ef
test(core): Advertising module unit tests
AdityaKasar a4e6e04
test(core): Authentication module unit tests
AdityaKasar 0bb732c
test(core): Capabilities module unit tests
AdityaKasar 1cec81d
test(core): Device module unit tests
AdityaKasar 87b4622
test(core): Lifecycle module unit tests
AdityaKasar 9d8e743
test(core): Metrics module unit tests
AdityaKasar 9fb9be6
test(core): Parameters module unit tests
AdityaKasar 24e2020
test(core): Profile module unit tests
AdityaKasar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #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(); | ||
| } |
178 changes: 178 additions & 0 deletions
178
src/sdks/core/src/cpp/sdk/cpptest/unit/accessibilityTest.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,178 @@ | ||
| #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 closedCaptions = Firebolt::IFireboltAccessor::Instance().AccessibilityInterface().closedCaptions(&error); | ||
|
|
||
| EXPECT_EQ(error, Firebolt::Error::None) << "Failed to retrieve closedCaptions from Accessibility.closedCaptions() method"; | ||
| EXPECT_EQ(closedCaptions.enabled, expectedValues["enabled"]); | ||
|
|
||
| EXPECT_EQ(closedCaptions.styles.backgroundColor.value(), expectedValues["styles"]["backgroundColor"]); | ||
| EXPECT_EQ(closedCaptions.styles.backgroundOpacity.value(), expectedValues["styles"]["backgroundOpacity"]); | ||
| EXPECT_EQ(closedCaptions.styles.fontColor.value(), expectedValues["styles"]["fontColor"]); | ||
|
|
||
| if (closedCaptions.styles.fontEdge.has_value()) | ||
| EXPECT_EQ(fontEdgeToString(closedCaptions.styles.fontEdge.value()), expectedValues["styles"]["fontEdge"]); | ||
|
|
||
| EXPECT_EQ(closedCaptions.styles.fontEdgeColor.value(), expectedValues["styles"]["fontEdgeColor"]); | ||
|
|
||
| if (closedCaptions.styles.fontFamily.has_value()) | ||
| EXPECT_EQ(fontFamilyToString(closedCaptions.styles.fontFamily.value()), expectedValues["styles"]["fontFamily"]); | ||
|
|
||
| EXPECT_EQ(closedCaptions.styles.fontOpacity.value(), expectedValues["styles"]["fontOpacity"]); | ||
| EXPECT_EQ(closedCaptions.styles.fontSize.value(), expectedValues["styles"]["fontSize"]); | ||
| EXPECT_EQ(closedCaptions.styles.textAlign.value(), expectedValues["styles"]["textAlign"]); | ||
| EXPECT_EQ(closedCaptions.styles.textAlignVertical.value(), expectedValues["styles"]["textAlignVertical"]); | ||
| EXPECT_EQ(closedCaptions.styles.windowColor.value(), expectedValues["styles"]["windowColor"]); | ||
| EXPECT_EQ(closedCaptions.styles.windowOpacity.value(), expectedValues["styles"]["windowOpacity"]); | ||
|
|
||
| EXPECT_EQ(closedCaptions.preferredLanguages.value()[0], expectedValues["preferredLanguages"][0]); | ||
| EXPECT_EQ(closedCaptions.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) << "Failed to retrieve closedCaptionSettings from Accessibility.closedCaptionSettings() method"; | ||
| 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 voiceGuidance = Firebolt::IFireboltAccessor::Instance().AccessibilityInterface().voiceGuidance(&error); | ||
|
|
||
| EXPECT_EQ(error, Firebolt::Error::None) << "Failed to retrieve voiceGuidance from Accessibility.voiceGuidance() method"; | ||
|
|
||
| EXPECT_EQ(voiceGuidance.enabled, expectedValues["enabled"]); | ||
| EXPECT_EQ(voiceGuidance.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) << "Failed to retrieve voiceGuidanceSettings from Accessibility.voiceGuidanceSettings() method"; | ||
|
|
||
| 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) << "Failed to retrieve audioDescriptionSettings from Accessibility.audioDescriptionSettings() method"; | ||
|
|
||
| EXPECT_EQ(audioDescriptionSettings.enabled, expectedValues["enabled"]); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #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 account_id = Firebolt::IFireboltAccessor::Instance().AccountInterface().id(&error); | ||
|
|
||
| EXPECT_EQ(error, Firebolt::Error::None) << "Failed to retrieve account_id from Account.id() method"; | ||
| EXPECT_EQ(account_id, expectedValues); | ||
| } | ||
|
|
||
| TEST_F(AccountTest, Uid) | ||
| { | ||
| nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Account.uid")); | ||
|
|
||
| std::string account_uid = Firebolt::IFireboltAccessor::Instance().AccountInterface().uid(&error); | ||
|
|
||
| EXPECT_EQ(error, Firebolt::Error::None) << "Failed to retrieve account_uid from Account.uid() method"; | ||
| EXPECT_EQ(account_uid, expectedValues); | ||
| } |
102 changes: 102 additions & 0 deletions
102
src/sdks/core/src/cpp/sdk/cpptest/unit/advertisingTest.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| #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) << "Failed to retrieve adFrameworkConfig from Advertising.config() method"; | ||
| 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) << "Failed to retrieve adPolicy from Advertising.policy() method"; | ||
|
|
||
| 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<Firebolt::Advertising::AdvertisingIdOptions> options = std::nullopt; // Assuming options are not provided | ||
|
|
||
| Firebolt::Advertising::AdvertisingId actualValues = Firebolt::IFireboltAccessor::Instance().AdvertisingInterface().advertisingId(options, &error); | ||
|
|
||
| EXPECT_EQ(error, Firebolt::Error::None) << "Failed to retrieve AdvertisingId from Advertising.advertisingId() method"; | ||
|
|
||
| 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) << "Failed to retrieve deviceAttributes from Advertising.deviceAttributes() method"; | ||
| EXPECT_EQ(deviceAttributes, expectedValues); | ||
| } | ||
|
|
||
| TEST_F(AdvertisingTest, AppBundleId) | ||
| { | ||
| auto actual_value = jsonEngine->get_value("Advertising.appBundleId"); | ||
|
|
||
| auto appBundleId = Firebolt::IFireboltAccessor::Instance().AdvertisingInterface().appBundleId(&error); | ||
|
|
||
| EXPECT_EQ(error, Firebolt::Error::None) << "Failed to retrieve appBundleId from Advertising.appBundleId() method"; | ||
| EXPECT_EQ(appBundleId, REMOVE_QUOTES(actual_value)); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.