diff --git a/CHANGELOG.md b/CHANGELOG.md index 84bb67ad4..479e710c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [1.2.1-next.2](https://github.com/rdkcentral/firebolt-apis/compare/v1.2.1-next.1...v1.2.1-next.2) (2024-07-01) + + +### Bug Fixes + +* **core, manage:** update C++ tests to run simultaneously for core and manage SDKs ([ef7bc4c](https://github.com/rdkcentral/firebolt-apis/commit/ef7bc4ce117cbce799ddab8c9b44522730374514)) + ## [1.2.1-next.1](https://github.com/rdkcentral/firebolt-apis/compare/v1.2.0...v1.2.1-next.1) (2024-06-26) diff --git a/package-lock.json b/package-lock.json index c510e8d0b..41a261d7f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@firebolt-js/sdks", - "version": "1.2.1-next.1", + "version": "1.2.1-next.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@firebolt-js/sdks", - "version": "1.2.1-next.1", + "version": "1.2.1-next.2", "license": "Apache-2.0", "workspaces": [ "src/sdks/core", diff --git a/package.json b/package.json index 70fd7a0ea..3c8b0f036 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@firebolt-js/sdks", - "version": "1.2.1-next.1", + "version": "1.2.1-next.2", "description": "The Firebolt JS SDK", "type": "module", "bin": { diff --git a/src/sdks/core/package.json b/src/sdks/core/package.json index 75cebb255..b1d245e4f 100644 --- a/src/sdks/core/package.json +++ b/src/sdks/core/package.json @@ -1,6 +1,6 @@ { "name": "@firebolt-js/sdk", - "version": "1.2.1-next.1", + "version": "1.2.1-next.2", "description": "The Firebolt JS SDK", "main": "./dist/lib/firebolt.mjs", "types": "./dist/lib/firebolt.d.ts", diff --git a/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp b/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp index e82dc74a0..1b2fe4c9a 100644 --- a/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp +++ b/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp @@ -18,6 +18,8 @@ #include #include +#include +#include #include "CoreSDKTest.h" using namespace std; @@ -93,9 +95,11 @@ void CoreSDKTest::GetAccountId() if (error == Firebolt::Error::None) { cout << "Get Account Id = " << id.c_str() << endl; } else { - cout << "Get Account Id status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetAccountId failed. " + errorMessage); } } + void CoreSDKTest::GetAccountUid() { Firebolt::Error error = Firebolt::Error::None; @@ -103,7 +107,8 @@ void CoreSDKTest::GetAccountUid() if (error == Firebolt::Error::None) { cout << "Get Account Uid = " << uid.c_str() << endl; } else { - cout << "Get Account Uid status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetAccountUid failed. " + errorMessage); } } @@ -143,6 +148,7 @@ void PrintAdvertisingPolicy(const Firebolt::Advertising::AdPolicy& policy) cout << "\tlimitAdTracking : " << policy.limitAdTracking.value() << endl; } } + void CoreSDKTest::GetAdvertisingPolicy() { Firebolt::Error error = Firebolt::Error::None; @@ -151,14 +157,17 @@ void CoreSDKTest::GetAdvertisingPolicy() cout << "Get Advertising policy --> " << endl; PrintAdvertisingPolicy(policy); } else { - cout << "Get Advertising policy status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetAdvertisingPolicy failed. " + errorMessage); } } -void CoreSDKTest::OnPolicyChangedNotification::onPolicyChanged( const Firebolt::Advertising::AdPolicy& policy ) + +void CoreSDKTest::OnPolicyChangedNotification::onPolicyChanged(const Firebolt::Advertising::AdPolicy& policy) { cout << "New policy --> " << endl; PrintAdvertisingPolicy(policy); } + void CoreSDKTest::SubscribeAdvertisingPolicyChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -166,9 +175,11 @@ void CoreSDKTest::SubscribeAdvertisingPolicyChanged() if (error == Firebolt::Error::None) { cout << "Subscribe Advertising PolicyChange is success" << endl; } else { - cout << "Subscribe Advertising PolicyChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeAdvertisingPolicyChanged failed. " + errorMessage); } } + void CoreSDKTest::UnsubscribeAdvertisingPolicyChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -176,9 +187,11 @@ void CoreSDKTest::UnsubscribeAdvertisingPolicyChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe Advertising PolicyChange is success" << endl; } else { - cout << "Unsubscribe Advertising PolicyChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeAdvertisingPolicyChanged failed. " + errorMessage); } } + void CoreSDKTest::BuildAdvertisingConfiguration() { Firebolt::Error error = Firebolt::Error::None; @@ -191,9 +204,11 @@ void CoreSDKTest::BuildAdvertisingConfiguration() if (error == Firebolt::Error::None) { cout << "Build AdvertisingConfiguration is success, adFrameworkConfig : " << adFrameworkConfig << endl; } else { - cout << "Build AdvertisingConfiguration status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("BuildAdvertisingConfiguration failed. " + errorMessage); } } + void CoreSDKTest::GetAdvertisingDeviceAttributes() { Firebolt::Error error = Firebolt::Error::None; @@ -201,7 +216,8 @@ void CoreSDKTest::GetAdvertisingDeviceAttributes() if (error == Firebolt::Error::None) { cout << "Get Advertising DeviceAttributes is success, deviceAttributes : " << deviceAttributes << endl; } else { - cout << "Get Advertising DeviceAttributes status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetAdvertisingDeviceAttributes failed. " + errorMessage); } } @@ -213,11 +229,12 @@ void CoreSDKTest::GetDeviceName() if (error == Firebolt::Error::None) { cout << "Get Device Name = " << name.c_str() << endl; } else { - cout << "Get Device Name status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetDeviceName failed. " + errorMessage); } } -void CoreSDKTest::OnDeviceNameChangedNotification::onDeviceNameChanged( const std::string& name) +void CoreSDKTest::OnDeviceNameChangedNotification::onDeviceNameChanged(const std::string& name) { cout << "Name changed, new name --> " << name << endl; } @@ -229,7 +246,8 @@ void CoreSDKTest::SubscribeDeviceNameChanged() if (error == Firebolt::Error::None) { cout << "Subscribe Device NameChange is success" << endl; } else { - cout << "Subscribe Device NameChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeDeviceNameChanged failed. " + errorMessage); } } @@ -240,7 +258,8 @@ void CoreSDKTest::UnsubscribeDeviceNameChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe Device NameChange is success" << endl; } else { - cout << "Unsubscribe Device NameChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeDeviceNameChanged failed. " + errorMessage); } } @@ -252,7 +271,8 @@ void CoreSDKTest::GetDeviceModel() if (error == Firebolt::Error::None) { cout << "Get Device Model = " << model.c_str() << endl; } else { - cout << "Get Device Model status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetDeviceModel failed. " + errorMessage); } } @@ -264,17 +284,19 @@ void CoreSDKTest::GetDeviceSku() if (error == Firebolt::Error::None) { cout << "Get Device Sku = " << sku.c_str() << endl; } else { - cout << "Get Device Sku status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetDeviceSku failed. " + errorMessage); } } -void PrintDeviceAudioProfiles( const Firebolt::Device::AudioProfiles& audioProfiles ) +void PrintDeviceAudioProfiles(const Firebolt::Device::AudioProfiles& audioProfiles) { cout << "Get Device AudioProfiles :-> " << endl; for (auto& item : audioProfiles) { cout << "Profile: " << static_cast(item.first) << " status: " << item.second << endl; } } + void CoreSDKTest::GetDeviceAudio() { Firebolt::Error error = Firebolt::Error::None; @@ -282,14 +304,17 @@ void CoreSDKTest::GetDeviceAudio() if (error == Firebolt::Error::None) { PrintDeviceAudioProfiles(audioProfiles); } else { - cout << "Get Device AudioProfiles status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetDeviceAudio failed. " + errorMessage); } } -void CoreSDKTest::OnAudioChangedNotification::onAudioChanged( const Firebolt::Device::AudioProfiles& audioProfiles ) + +void CoreSDKTest::OnAudioChangedNotification::onAudioChanged(const Firebolt::Device::AudioProfiles& audioProfiles) { cout << "onAudioChanged event " << endl; PrintDeviceAudioProfiles(audioProfiles); } + void CoreSDKTest::SubscribeDeviceAudioChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -297,9 +322,11 @@ void CoreSDKTest::SubscribeDeviceAudioChanged() if (error == Firebolt::Error::None) { cout << "Subscribe Device Audio Change is success" << endl; } else { - cout << "Subscribe Device Audio Change status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeDeviceAudioChanged failed. " + errorMessage); } } + void CoreSDKTest::UnsubscribeDeviceAudioChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -307,15 +334,17 @@ void CoreSDKTest::UnsubscribeDeviceAudioChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe Device Audio Change is success" << endl; } else { - cout << "Unsubscribe Device Audio Change status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeDeviceAudioChanged failed. " + errorMessage); } } -void PrintDeviceScreenResolution( const Firebolt::Device::Resolution& resolution ) +void PrintDeviceScreenResolution(const Firebolt::Device::Resolution& resolution) { cout << "Get Device ScreenResolution :-> " << endl; cout << resolution.first << " X " << resolution.second << endl; } + void CoreSDKTest::GetDeviceScreenResolution() { Firebolt::Error error = Firebolt::Error::None; @@ -323,14 +352,17 @@ void CoreSDKTest::GetDeviceScreenResolution() if (error == Firebolt::Error::None) { PrintDeviceScreenResolution(resolution); } else { - cout << "Get Device ScreenResolution status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetDeviceScreenResolution failed. " + errorMessage); } } -void CoreSDKTest::OnScreenResolutionChangedNotification::onScreenResolutionChanged( const Firebolt::Device::Resolution& resolution ) + +void CoreSDKTest::OnScreenResolutionChangedNotification::onScreenResolutionChanged(const Firebolt::Device::Resolution& resolution) { cout << "onScreenResolutionChanged event " << endl; PrintDeviceScreenResolution(resolution); } + void CoreSDKTest::SubscribeDeviceScreenResolutionChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -338,9 +370,11 @@ void CoreSDKTest::SubscribeDeviceScreenResolutionChanged() if (error == Firebolt::Error::None) { cout << "Subscribe Device ScreenResolution Change is success" << endl; } else { - cout << "Subscribe Device ScreenResolution Change status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeDeviceScreenResolutionChanged failed. " + errorMessage); } } + void CoreSDKTest::UnsubscribeDeviceScreenResolutionChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -348,11 +382,12 @@ void CoreSDKTest::UnsubscribeDeviceScreenResolutionChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe Device ScreenResolution Change is success" << endl; } else { - cout << "Unsubscribe Device ScreenResolution Change status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeDeviceScreenResolutionChanged failed. " + errorMessage); } } -void PrintClosedCaptionsSettings( const Firebolt::Accessibility::ClosedCaptionsSettings& closedCaptionsSettings) +void PrintClosedCaptionsSettings(const Firebolt::Accessibility::ClosedCaptionsSettings& closedCaptionsSettings) { cout << "Get Accessibility ClosedCaptionsSettings :-> " << endl; cout << "ClosedCaptionsSettings::Enabled : " << closedCaptionsSettings.enabled << endl; @@ -400,6 +435,7 @@ void PrintClosedCaptionsSettings( const Firebolt::Accessibility::ClosedCaptionsS cout << endl; } } + void CoreSDKTest::GetAccessibilityClosedCaptionsSettings() { Firebolt::Error error = Firebolt::Error::None; @@ -407,14 +443,17 @@ void CoreSDKTest::GetAccessibilityClosedCaptionsSettings() if (error == Firebolt::Error::None) { PrintClosedCaptionsSettings(closedCaptionsSettings); } else { - cout << "Get Accessibility ClosedCaptionsSettings status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetAccessibilityClosedCaptionsSettings failed. " + errorMessage); } } -void CoreSDKTest::OnClosedCaptionsSettingsChangedNotification::onClosedCaptionsSettingsChanged( const Firebolt::Accessibility::ClosedCaptionsSettings& closedCaptionsSettings ) + +void CoreSDKTest::OnClosedCaptionsSettingsChangedNotification::onClosedCaptionsSettingsChanged(const Firebolt::Accessibility::ClosedCaptionsSettings& closedCaptionsSettings) { cout << "ClosedCaptionsSettingsChanged event " << endl; PrintClosedCaptionsSettings(closedCaptionsSettings); } + void CoreSDKTest::SubscribeAccessibilityClosedCaptionsSettingsChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -422,9 +461,11 @@ void CoreSDKTest::SubscribeAccessibilityClosedCaptionsSettingsChanged() if (error == Firebolt::Error::None) { cout << "Subscribe Accessibilty ClosedCaptionSettings Change is success" << endl; } else { - cout << "Subscribe Accessibilty ClosedCaptionSettings Change status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeAccessibilityClosedCaptionsSettingsChanged failed. " + errorMessage); } } + void CoreSDKTest::UnsubscribeAccessibilityClosedCaptionsSettingsChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -432,7 +473,8 @@ void CoreSDKTest::UnsubscribeAccessibilityClosedCaptionsSettingsChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe Accessibilty ClosedCaptionSettings Change is success" << endl; } else { - cout << "Unsubscribe Accessibilty ClosedCaptionSettings Change status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeAccessibilityClosedCaptionsSettingsChanged failed. " + errorMessage); } } @@ -447,9 +489,11 @@ void CoreSDKTest::GetLocalizationAdditionalInfo() cout << "key : " << element.first << ", value : " << element.second << endl; } } else { - cout << "Get Localization AdditionalInfo status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetLocalizationAdditionalInfo failed. " + errorMessage); } } + void CoreSDKTest::GetLocalizationLatlon() { Firebolt::Error error = Firebolt::Error::None; @@ -459,9 +503,11 @@ void CoreSDKTest::GetLocalizationLatlon() cout << "Get Localization LatLon pair value : " << endl; cout << "key : " << latlon.first << ", value : " << latlon.second << endl; } else { - cout << "Get Localization LatLon status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetLocalizationLatlon failed. " + errorMessage); } } + void CoreSDKTest::GetLocalizationPreferredAudioLanguages() { Firebolt::Error error = Firebolt::Error::None; @@ -470,19 +516,22 @@ void CoreSDKTest::GetLocalizationPreferredAudioLanguages() if (error == Firebolt::Error::None) { cout << "Get Localization PreferredAudioLanguages : " << endl; for (auto language: languages) { - cout << "----- > " < " << language << endl; } } else { - cout << "Get Localization PreferredAudioLanguages status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetLocalizationPreferredAudioLanguages failed. " + errorMessage); } } -void CoreSDKTest::OnPreferredAudioLanguagesChangedNotification::onPreferredAudioLanguagesChanged( const std::vector& languages) + +void CoreSDKTest::OnPreferredAudioLanguagesChangedNotification::onPreferredAudioLanguagesChanged(const std::vector& languages) { cout << "PreferredAudioLanguages Changed, new languages --> " << endl; for (auto language : languages) { cout << " -> " << language << endl; } } + void CoreSDKTest::SubscribeLocalizationPreferredAudioLanguagesChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -490,9 +539,11 @@ void CoreSDKTest::SubscribeLocalizationPreferredAudioLanguagesChanged() if (error == Firebolt::Error::None) { cout << "Subscribe Localization PreferredAudioLanguagesChange is success" << endl; } else { - cout << "Subscribe Localization PreferredAudioLanguagesChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeLocalizationPreferredAudioLanguagesChanged failed. " + errorMessage); } } + void CoreSDKTest::UnsubscribeLocalizationPreferredAudioLanguagesChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -500,7 +551,8 @@ void CoreSDKTest::UnsubscribeLocalizationPreferredAudioLanguagesChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe Localization PreferredAudioLanguagesChange is success" << endl; } else { - cout << "Unsubscribe Localization PreferredAudioLanguagesChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeLocalizationPreferredAudioLanguagesChanged failed. " + errorMessage); } } @@ -512,23 +564,28 @@ void CoreSDKTest::KeyboardStandardAsyncResponse::response(const std::string& res cout << "Keyboard standard response: " << response << endl; } } + void CoreSDKTest::InvokeKeyboardStandard() { Firebolt::Error error = Firebolt::Error::None; std::string message = "Enter the name you'd like to associate with this device"; Firebolt::IFireboltAccessor::Instance().KeyboardInterface().requestStandard(message, _keyboardStandardAsyncResponse, &error); if (error != Firebolt::Error::None) { - cout << "Error with keyboard standard request method invoke, error = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("InvokeKeyboardStandard failed. " + errorMessage); } } + void CoreSDKTest::AbortKeyboardStandard() { Firebolt::Error error = Firebolt::Error::None; Firebolt::IFireboltAccessor::Instance().KeyboardInterface().abortStandard(_keyboardStandardAsyncResponse, &error); if (error != Firebolt::Error::None) { - cout << "Error with keyboard standard abort method invoke, error = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("AbortKeyboardStandard failed. " + errorMessage); } } + void CoreSDKTest::KeyboardPasswordAsyncResponse::response(const std::string& response, Firebolt::Error* error) { if (error && (*error != Firebolt::Error::None)) { @@ -537,23 +594,28 @@ void CoreSDKTest::KeyboardPasswordAsyncResponse::response(const std::string& res cout << "Keyboard password response: " << response << endl; } } + void CoreSDKTest::InvokeKeyboardPassword() { Firebolt::Error error = Firebolt::Error::None; std::string message = "Enter the password to associate with this device"; Firebolt::IFireboltAccessor::Instance().KeyboardInterface().requestPassword(message, _keyboardPasswordAsyncResponse, &error); if (error != Firebolt::Error::None) { - cout << "Error with keyboard password request method invoke, error = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("InvokeKeyboardPassword failed. " + errorMessage); } } + void CoreSDKTest::AbortKeyboardPassword() { Firebolt::Error error = Firebolt::Error::None; Firebolt::IFireboltAccessor::Instance().KeyboardInterface().abortPassword(_keyboardPasswordAsyncResponse, &error); if (error != Firebolt::Error::None) { - cout << "Error with keyboard password abort method invoke, error = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("AbortKeyboardPassword failed. " + errorMessage); } } + void CoreSDKTest::KeyboardEmailAsyncResponse::response(const std::string& response, Firebolt::Error* error) { if (error && (*error != Firebolt::Error::None)) { @@ -562,6 +624,7 @@ void CoreSDKTest::KeyboardEmailAsyncResponse::response(const std::string& respon cout << "Keyboard email response: " << response << endl; } } + void CoreSDKTest::InvokeKeyboardEmail() { Firebolt::Error error = Firebolt::Error::None; @@ -569,15 +632,18 @@ void CoreSDKTest::InvokeKeyboardEmail() std::string message = "Enter your email to sign into this app/device"; Firebolt::IFireboltAccessor::Instance().KeyboardInterface().requestEmail(type, message, _keyboardEmailAsyncResponse, &error); if (error != Firebolt::Error::None) { - cout << "Error with keyboard email requeset method invoke, error = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("InvokeKeyboardEmail failed. " + errorMessage); } } + void CoreSDKTest::AbortKeyboardEmail() { Firebolt::Error error = Firebolt::Error::None; Firebolt::IFireboltAccessor::Instance().KeyboardInterface().abortEmail(_keyboardEmailAsyncResponse, &error); if (error != Firebolt::Error::None) { - cout << "Error with keyboard email abort method invoke, error = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("AbortKeyboardEmail failed. " + errorMessage); } } @@ -588,9 +654,11 @@ void CoreSDKTest::VerifyProfileApproveContentRating() if (error == Firebolt::Error::None) { cout << "Verify Profile ApproveContentRating is success value : " << allow << endl; } else { - cout << "Verify Profile ApproveContentRating status : " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("VerifyProfileApproveContentRating failed. " + errorMessage); } } + void CoreSDKTest::VerifyProfileApprovePurchase() { Firebolt::Error error = Firebolt::Error::None; @@ -598,36 +666,41 @@ void CoreSDKTest::VerifyProfileApprovePurchase() if (error == Firebolt::Error::None) { cout << "Verify Profile ApprovePurchase is success value : " << allow << endl; } else { - cout << "Verify Profile ApprovePurchase status : " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("VerifyProfileApprovePurchase failed. " + errorMessage); } } + void CoreSDKTest::GetProfileFlags() { - Firebolt::Error error = Firebolt::Error::None; - Firebolt::Types::FlatMap flatMap = Firebolt::IFireboltAccessor::Instance().ProfileInterface().flags(&error); - if (error == Firebolt::Error::None) { + Firebolt::Error error = Firebolt::Error::None; + Firebolt::Types::FlatMap flatMap = Firebolt::IFireboltAccessor::Instance().ProfileInterface().flags(&error); + if (error == Firebolt::Error::None) { cout << "Get Profile flags is success value : " << endl; for (const auto& item : flatMap) { - cout << "\t" << item.first << " : " << item.second << endl; + cout << "\t" << item.first << " : " << item.second << endl; } } else { - cout << "Get Profile flags status : " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetProfileFlags failed. " + errorMessage); } } void CoreSDKTest::LifecycleClose() { - Firebolt::Error error = Firebolt::Error::None; - cout << "Enter close reason remote button(0), user exit(1), done(2) or error(3)" << endl; - int32_t reason; - cin >> reason; - Firebolt::IFireboltAccessor::Instance().LifecycleInterface().close(static_cast(reason), &error); + Firebolt::Error error = Firebolt::Error::None; + cout << "Enter close reason remote button(0), user exit(1), done(2) or error(3)" << endl; + int32_t reason; + cin >> reason; + Firebolt::IFireboltAccessor::Instance().LifecycleInterface().close(static_cast(reason), &error); if (error == Firebolt::Error::None) { cout << "Lifecycle close is success" << endl; } else { - cout << "Lifecycle close status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("LifecycleClose failed. " + errorMessage); } } + EnumMap lifecycleStateMap = { { Firebolt::Lifecycle::LifecycleState::INITIALIZING, "initializing" }, { Firebolt::Lifecycle::LifecycleState::INACTIVE, "inactive" }, @@ -636,19 +709,22 @@ EnumMap lifecycleStateMap = { { Firebolt::Lifecycle::LifecycleState::UNLOADING, "unloading" }, { Firebolt::Lifecycle::LifecycleState::SUSPENDED, "suspended" } }; + EnumMap lifecycleEventSourceMap = { { Firebolt::Lifecycle::LifecycleEventSource::VOICE, "voice" }, { Firebolt::Lifecycle::LifecycleEventSource::REMOTE, "remote" } }; -void CoreSDKTest::OnBackgroundNotification::onBackground( const Firebolt::Lifecycle::LifecycleEvent& lifecycleEvent) + +void CoreSDKTest::OnBackgroundNotification::onBackground(const Firebolt::Lifecycle::LifecycleEvent& lifecycleEvent) { cout <<"onBackground event is triggered" << endl; cout <<"\tstate: " << ConvertFromEnum(lifecycleStateMap, lifecycleEvent.state) << endl; cout <<"\tprevious: " << ConvertFromEnum(lifecycleStateMap, lifecycleEvent.previous) << endl; if (lifecycleEvent.source.has_value()) { - cout <<"\tsource: " << ConvertFromEnum(lifecycleEventSourceMap, lifecycleEvent.source.value()) << endl; + cout <<"\tsource: " << ConvertFromEnum(lifecycleEventSourceMap, lifecycleEvent.source.value()) << endl; } } + void CoreSDKTest::SubscribeLifecycleBackgroundNotification() { Firebolt::Error error = Firebolt::Error::None; @@ -656,9 +732,11 @@ void CoreSDKTest::SubscribeLifecycleBackgroundNotification() if (error == Firebolt::Error::None) { cout << "Subscribe Lifecycle BackgroundNotification is success" << endl; } else { - cout << "Subscribe Lifecycle BackgroundNotification status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeLifecycleBackgroundNotification failed. " + errorMessage); } } + void CoreSDKTest::UnsubscribeLifecycleBackgroundNotification() { Firebolt::Error error = Firebolt::Error::None; @@ -666,18 +744,21 @@ void CoreSDKTest::UnsubscribeLifecycleBackgroundNotification() if (error == Firebolt::Error::None) { cout << "Unsubscribe Lifecycle BackgroundNotification is success" << endl; } else { - cout << "Unsubscribe Lifecycle BackgroundNotification status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeLifecycleBackgroundNotification failed. " + errorMessage); } } -void CoreSDKTest::OnForegroundNotification::onForeground( const Firebolt::Lifecycle::LifecycleEvent& lifecycleEvent) + +void CoreSDKTest::OnForegroundNotification::onForeground(const Firebolt::Lifecycle::LifecycleEvent& lifecycleEvent) { cout <<"onForeground event is triggered" << endl; cout <<"\tstate: " << ConvertFromEnum(lifecycleStateMap, lifecycleEvent.state) << endl; cout <<"\tprevious: " << ConvertFromEnum(lifecycleStateMap, lifecycleEvent.previous) << endl; if (lifecycleEvent.source.has_value()) { - cout <<"\tsource: " << ConvertFromEnum(lifecycleEventSourceMap, lifecycleEvent.source.value()) << endl; + cout <<"\tsource: " << ConvertFromEnum(lifecycleEventSourceMap, lifecycleEvent.source.value()) << endl; } } + void CoreSDKTest::SubscribeLifecycleForegroundNotification() { Firebolt::Error error = Firebolt::Error::None; @@ -685,9 +766,11 @@ void CoreSDKTest::SubscribeLifecycleForegroundNotification() if (error == Firebolt::Error::None) { cout << "Subscribe Lifecycle ForegroundNotification is success" << endl; } else { - cout << "Subscribe Lifecycle ForegroundNotification status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeLifecycleForegroundNotification failed. " + errorMessage); } } + void CoreSDKTest::UnsubscribeLifecycleForegroundNotification() { Firebolt::Error error = Firebolt::Error::None; @@ -695,7 +778,8 @@ void CoreSDKTest::UnsubscribeLifecycleForegroundNotification() if (error == Firebolt::Error::None) { cout << "Unsubscribe Lifecycle ForegroundNotification is success" << endl; } else { - cout << "Unsubscribe Lifecycle ForegroundNotification status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeLifecycleForegroundNotification failed. " + errorMessage); } } @@ -707,9 +791,11 @@ void CoreSDKTest::GetAuthenticationDevice() if (error == Firebolt::Error::None) { cout << "Get Authentication of Device = " << device.c_str() << endl; } else { - cout << "Get Authentication of Device status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetAuthenticationDevice failed. " + errorMessage); } } + void CoreSDKTest::GetAuthenticationSession() { Firebolt::Error error = Firebolt::Error::None; @@ -718,9 +804,11 @@ void CoreSDKTest::GetAuthenticationSession() if (error == Firebolt::Error::None) { cout << "Get Authentication of Session = " << session.c_str() << endl; } else { - cout << "Get Authentication of Session status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetAuthenticationSession failed. " + errorMessage); } } + void CoreSDKTest::GetAuthenticationRoot() { Firebolt::Error error = Firebolt::Error::None; @@ -729,9 +817,11 @@ void CoreSDKTest::GetAuthenticationRoot() if (error == Firebolt::Error::None) { cout << "Get Authentication of Root = " << root.c_str() << endl; } else { - cout << "Get Authentication of Root status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetAuthenticationRoot failed. " + errorMessage); } } + void CoreSDKTest::GetAuthenticationToken() { Firebolt::Error error = Firebolt::Error::None; @@ -750,14 +840,15 @@ void CoreSDKTest::GetAuthenticationToken() cout << "\ttype : " << token.type.value().c_str() << endl; } } else { - cout << "Get Authentication of Device status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetAuthenticationToken failed. " + errorMessage); } } EnumMap denyReasonMap = { { Firebolt::Capabilities::DenyReason::UNPERMITTED, "unpermitted" }, { Firebolt::Capabilities::DenyReason::UNSUPPORTED, "unsupported" }, - { Firebolt::Capabilities::DenyReason::DISABLED, "disbaled" }, + { Firebolt::Capabilities::DenyReason::DISABLED, "disabled" }, { Firebolt::Capabilities::DenyReason::UNAVAILABLE, "unavailable" }, { Firebolt::Capabilities::DenyReason::GRANT_DENIED, "grant_denied" }, { Firebolt::Capabilities::DenyReason::UNGRANTED, "ungranted" } @@ -797,10 +888,11 @@ static void PrintCapabilityInfo(const Firebolt::Capabilities::CapabilityInfo& in if (info.details.has_value()) { cout << "\tdetails: " << endl; for (auto item : info.details.value()) { - cout << "\t\t" << ConvertFromEnum(denyReasonMap, item) << endl; + cout << "\t\t" << ConvertFromEnum(denyReasonMap, item) << endl; } } } + void CoreSDKTest::GetCapabilitiesAvailable() { Firebolt::Error error = Firebolt::Error::None; @@ -809,9 +901,11 @@ void CoreSDKTest::GetCapabilitiesAvailable() if (error == Firebolt::Error::None) { cout << "Capabilities Available = " << (status ? "true" : "false") << endl; } else { - cout << "Capabilities Available status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetCapabilitiesAvailable failed. " + errorMessage); } } + void CoreSDKTest::SubscribeCapabilitiesAvailableChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -820,9 +914,11 @@ void CoreSDKTest::SubscribeCapabilitiesAvailableChanged() if (error == Firebolt::Error::None) { cout << "Subscribe Capabilities AvailableNotification is success" << endl; } else { - cout << "Subscribe Capabilities AvailableNotification status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeCapabilitiesAvailableChanged failed. " + errorMessage); } } + void CoreSDKTest::UnsubscribeCapabilitiesAvailableChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -830,15 +926,18 @@ void CoreSDKTest::UnsubscribeCapabilitiesAvailableChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe Capabilities AvailableNotification is success" << endl; } else { - cout << "Unsubscribe Capabilities AvailableNotification status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeCapabilitiesAvailableChanged failed. " + errorMessage); } } -void CoreSDKTest::OnAvailableNotification::onAvailable( const Firebolt::Capabilities::CapabilityInfo& info) + +void CoreSDKTest::OnAvailableNotification::onAvailable(const Firebolt::Capabilities::CapabilityInfo& info) { cout << "OnAvailableNotification is invoked " << endl; cout << "capabilityInfo: " << endl; PrintCapabilityInfo(info); } + void CoreSDKTest::GetCapabilitiesGranted() { Firebolt::Error error = Firebolt::Error::None; @@ -848,9 +947,11 @@ void CoreSDKTest::GetCapabilitiesGranted() if (error == Firebolt::Error::None) { cout << "Capabilities Granted = " << (status ? "true" : "false") << endl; } else { - cout << "Capabilities Granted status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetCapabilitiesGranted failed. " + errorMessage); } } + void CoreSDKTest::GetCapabilitiesPermitted() { Firebolt::Error error = Firebolt::Error::None; @@ -862,9 +963,11 @@ void CoreSDKTest::GetCapabilitiesPermitted() if (error == Firebolt::Error::None) { cout << "Capabilities Permitted = " << (status ? "true" : "false") << endl; } else { - cout << "Capabilities Permitted status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetCapabilitiesPermitted failed. " + errorMessage); } } + void CoreSDKTest::GetCapabilitiesSupported() { Firebolt::Error error = Firebolt::Error::None; @@ -873,9 +976,11 @@ void CoreSDKTest::GetCapabilitiesSupported() if (error == Firebolt::Error::None) { cout << "Capabilities Supported = " << (status ? "true" : "false") << endl; } else { - cout << "Capabilities Supported status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetCapabilitiesSupported failed. " + errorMessage); } } + void CoreSDKTest::GetCapabilitiesInfo() { Firebolt::Error error = Firebolt::Error::None; @@ -885,10 +990,11 @@ void CoreSDKTest::GetCapabilitiesInfo() cout << "Capabilities Info : " << endl; for (auto element : info) { PrintCapabilityInfo(element); - cout << endl; + cout << endl; } } else { - cout << "Capabilities Info status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetCapabilitiesInfo failed. " + errorMessage); } } @@ -901,9 +1007,11 @@ void CoreSDKTest::MetricsStartContent() if (error == Firebolt::Error::None) { cout << "Metrics Start Content = " << (status ? "true" : "false") << endl; } else { - cout << "Metrics Start Content status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("MetricsStartContent failed. " + errorMessage); } } + void CoreSDKTest::MetricsStopContent() { Firebolt::Error error = Firebolt::Error::None; @@ -913,7 +1021,8 @@ void CoreSDKTest::MetricsStopContent() if (error == Firebolt::Error::None) { cout << "Metrics Stop Content = " << (status ? "true" : "false") << endl; } else { - cout << "Metrics Stop Content status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("MetricsStopContent failed. " + errorMessage); } } @@ -926,9 +1035,11 @@ void CoreSDKTest::GetSecondScreenDevice() if (error == Firebolt::Error::None) { cout << "Get SecondScreen Device : " << deviceId.c_str() << endl; } else { - cout << "Get SecondScreen Device status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetSecondScreenDevice failed. " + errorMessage); } } + void CoreSDKTest::GetSecondScreenProtocols() { Firebolt::Error error = Firebolt::Error::None; @@ -939,9 +1050,11 @@ void CoreSDKTest::GetSecondScreenProtocols() cout << element.first << " : " << (element.second ? "true" : "false") << endl; } } else { - cout << "Get SecondScreen Protocols status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetSecondScreenProtocols failed. " + errorMessage); } } + void CoreSDKTest::GetSecondScreenFriendlyName() { Firebolt::Error error = Firebolt::Error::None; @@ -950,13 +1063,16 @@ void CoreSDKTest::GetSecondScreenFriendlyName() if (error == Firebolt::Error::None) { cout << "Get SecondScreen FriendlyName : " << friendlyName.c_str() << endl; } else { - cout << "Get SecondScreen FriendlyName status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetSecondScreenFriendlyName failed. " + errorMessage); } } -void CoreSDKTest::OnFriendlyNameChangedNotification::onFriendlyNameChanged( const std::string& friendlyName) + +void CoreSDKTest::OnFriendlyNameChangedNotification::onFriendlyNameChanged(const std::string& friendlyName) { cout << "OnFriendlyNameChangedNotification friendlyName : " << friendlyName.c_str() << endl; } + void CoreSDKTest::SubscribeSecondScreenFriendlyNameChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -964,9 +1080,11 @@ void CoreSDKTest::SubscribeSecondScreenFriendlyNameChanged() if (error == Firebolt::Error::None) { cout << "Subscribe SecondScreen FriendlyNameChangedNotification is success" << endl; } else { - cout << "Subscribe SecondScreen FriendlyNameChangedNotification status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeSecondScreenFriendlyNameChanged failed. " + errorMessage); } } + void CoreSDKTest::UnsubscribeSecondScreenFriendlyNameChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -974,13 +1092,15 @@ void CoreSDKTest::UnsubscribeSecondScreenFriendlyNameChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe SecondScreen FriendlyNameChangedNotification is success" << endl; } else { - cout << "Unsubscribe SecondScreen FriendlyNameChangedNotification status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeSecondScreenFriendlyNameChanged failed. " + errorMessage); } } EnumMap secondScreenEventTypeMap = { { Firebolt::SecondScreen::SecondScreenEventType::DIAL, "dial" } }; + void CoreSDKTest::ParametersInitialization() { Firebolt::Error error = Firebolt::Error::None; @@ -1001,17 +1121,18 @@ void CoreSDKTest::ParametersInitialization() if (appInitialization.secondScreen.has_value()) { if (appInitialization.secondScreen.value().launchRequest.has_value()) { Firebolt::SecondScreen::SecondScreenEvent event = appInitialization.secondScreen.value().launchRequest.value(); - cout <<"\tsecondScreen:launchRequest:type : " << ConvertFromEnum(secondScreenEventTypeMap, event.type) << endl; + cout << "\tsecondScreen:launchRequest:type : " << ConvertFromEnum(secondScreenEventTypeMap, event.type) << endl; if (event.version.has_value()) { - cout <<"\tsecondScreen:launchRequest:version : " << event.version.value().c_str() << endl; + cout << "\tsecondScreen:launchRequest:version : " << event.version.value().c_str() << endl; } if (event.data.has_value()) { - cout <<"\tsecondScreen:launchRequest:data : " << event.data.value().c_str() << endl; + cout << "\tsecondScreen:launchRequest:data : " << event.data.value().c_str() << endl; } } } } else { - cout << "Parameters Initialization status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("ParametersInitialization failed. " + errorMessage); } } @@ -1028,9 +1149,11 @@ void CoreSDKTest::DiscoverySignIn() if (error == Firebolt::Error::None) { cout << "Discovery SignIn is " << (status ? "true" : "false") << endl; } else { - cout << "Discovery SignIn status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoverySignIn failed. " + errorMessage); } } + void CoreSDKTest::DiscoverySignOut() { Firebolt::Error error = Firebolt::Error::None; @@ -1038,7 +1161,8 @@ void CoreSDKTest::DiscoverySignOut() if (error == Firebolt::Error::None) { cout << "Discovery SignOut is " << (status ? "true" : "false") << endl; } else { - cout << "Discovery SignOut status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoverySignOut failed. " + errorMessage); } } @@ -1046,7 +1170,7 @@ void CoreSDKTest::DiscoveryContentAccess() { Firebolt::Error error = Firebolt::Error::None; Firebolt::Discovery::ContentAccessIdentifiers contentAccessIdentifiers; - contentAccessIdentifiers.availabilities = std::make_optional>(); + contentAccessIdentifiers.availabilities = std::make_optional>(); Firebolt::Discovery::Availability availability; availability.type = Firebolt::Discovery::AvailabilityType::CHANNEL_LINEUP; availability.id = "partner.com/availability/123"; @@ -1064,9 +1188,11 @@ void CoreSDKTest::DiscoveryContentAccess() if (error == Firebolt::Error::None) { cout << "Discovery ContentAccess is success" << endl; } else { - cout << "Discovery ContentAccess status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoveryContentAccess failed. " + errorMessage); } } + void CoreSDKTest::DiscoveryClearContentAccess() { Firebolt::Error error = Firebolt::Error::None; @@ -1074,9 +1200,11 @@ void CoreSDKTest::DiscoveryClearContentAccess() if (error == Firebolt::Error::None) { cout << "Discovery ClearContentAccess is success" << endl; } else { - cout << "Discovery ClearContentAccess status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoveryClearContentAccess failed. " + errorMessage); } } + void CoreSDKTest::DiscoveryEntitlements() { Firebolt::Error error = Firebolt::Error::None; @@ -1090,9 +1218,11 @@ void CoreSDKTest::DiscoveryEntitlements() if (error == Firebolt::Error::None) { cout << "Discovery Entitlements is " << (status ? "true" : "false") << endl; } else { - cout << "Discovery Entitlements status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoveryEntitlements failed. " + errorMessage); } } + void CoreSDKTest::DiscoveryWatchNext() { Firebolt::Error error = Firebolt::Error::None; @@ -1107,18 +1237,20 @@ void CoreSDKTest::DiscoveryWatchNext() if (error == Firebolt::Error::None) { cout << "Discovery Watched Next is " << (status ? "true" : "false") << endl; } else { - cout << "Discovery Watched Next status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoveryWatchNext failed. " + errorMessage); } } + void CoreSDKTest::DiscoveryUserInterest() { Firebolt::Error error = Firebolt::Error::None; Firebolt::Discovery::InterestType type = Firebolt::Discovery::InterestType::INTEREST; Firebolt::Discovery::InterestReason reason = Firebolt::Discovery::InterestReason::PLAYLIST; - + // Set up the entity details Firebolt::Entity::EntityDetails entity; - + // Identifiers entity.identifiers = "{\"entityId\": \"123\"}"; @@ -1135,6 +1267,7 @@ void CoreSDKTest::DiscoveryUserInterest() cout << "Discovery User Interest status = " << static_cast(error) << endl; } } + void CoreSDKTest::DiscoveryPolicy() { Firebolt::Error error = Firebolt::Error::None; @@ -1145,9 +1278,11 @@ void CoreSDKTest::DiscoveryPolicy() cout << "\tshareWatchHistory: " << policy.shareWatchHistory << endl; cout << "\trememberWatchedPrograms: " << policy.rememberWatchedPrograms << endl; } else { - cout << "Discovery Policy status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoveryPolicy failed. " + errorMessage); } } + void CoreSDKTest::DiscoveryEntityInfo() { Firebolt::Error error = Firebolt::Error::None; @@ -1224,9 +1359,11 @@ void CoreSDKTest::DiscoveryEntityInfo() if (error == Firebolt::Error::None) { cout << "Discovery EntityInfo is " << (status ? "true" : "false") << endl; } else { - cout << "Discovery EntityInfo status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoveryEntityInfo failed. " + errorMessage); } } + void CoreSDKTest::DiscoveryPurchasedContent() { Firebolt::Error error = Firebolt::Error::None; @@ -1280,16 +1417,15 @@ void CoreSDKTest::DiscoveryPurchasedContent() if (error == Firebolt::Error::None) { cout << "Discovery PurchasedContent is " << (status ? "true" : "false") << endl; } else { - cout << "Discovery PurchasedContent status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoveryPurchasedContent failed. " + errorMessage); } } + void CoreSDKTest::DiscoveryLaunch() { Firebolt::Error error = Firebolt::Error::None; - cout << "Enter appId :"; - getchar(); - std::string appId; - getline(cin, appId); + std::string appId = "123"; { std::optional intent = std::make_optional(); intent.value().action = "tune"; @@ -1303,14 +1439,16 @@ void CoreSDKTest::DiscoveryLaunch() intent.value().context.source = "voice"; cout << "Calling Discovery Launch TuneIntent method " << endl; bool status = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().launch(appId, intent, &error); + if (error == Firebolt::Error::None) { cout << "Discovery Launch TuneIntent is " << (status ? "true" : "false") << endl; } else { - cout << "Discovery Launch TuneIntent status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoveryLaunch failed. " + errorMessage); } } - { + { std::optional intent = std::make_optional(); intent.value().action = "entity"; intent.value().context.source = "voice"; @@ -1321,7 +1459,8 @@ void CoreSDKTest::DiscoveryLaunch() if (error == Firebolt::Error::None) { cout << "Discovery Launch EntityIntent is " << (status ? "true" : "false") << endl; } else { - cout << "Discovery Launch EntityIntent status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoveryLaunch failed. " + errorMessage); } } @@ -1334,10 +1473,10 @@ void CoreSDKTest::DiscoveryLaunch() if (error == Firebolt::Error::None) { cout << "Discovery Launch HomeIntent is " << (status ? "true" : "false") << endl; } else { - cout << "Discovery Launch HomeIntent status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoveryLaunch failed. " + errorMessage); } } - cin.putback('\n'); } #ifdef POLYMORPHICS_REDUCER_METHODS void CoreSDKTest::DiscoveryWatched() @@ -1352,9 +1491,11 @@ void CoreSDKTest::DiscoveryWatched() if (error == Firebolt::Error::None) { cout << "Discovery Watched is " << (status ? "true" : "false") << endl; } else { - cout << "Discovery Watched status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoveryWatched failed. " + errorMessage); } } + void CoreSDKTest::DiscoveryWatchedReduced() { Firebolt::Error error = Firebolt::Error::None; @@ -1370,10 +1511,12 @@ void CoreSDKTest::DiscoveryWatchedReduced() if (error == Firebolt::Error::None) { cout << "Discovery Watched Reduced is " << (status ? "true" : "false") << endl; } else { - cout << "Discovery Watched Reduced status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DiscoveryWatchedReduced failed. " + errorMessage); } } #endif + void CoreSDKTest::SubscribeDiscoveryOnNavigateToLaunchNotification() { Firebolt::Error error = Firebolt::Error::None; @@ -1381,7 +1524,8 @@ void CoreSDKTest::SubscribeDiscoveryOnNavigateToLaunchNotification() if (error == Firebolt::Error::None) { cout << "Subscribe Discovery OnNavigateToLaunch HomeIntent is success" << endl; } else { - cout << "Subscribe Discovery OnNavigateToLaunch HomeIntent status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeDiscoveryOnNavigateToLaunchNotification failed. " + errorMessage); } error = Firebolt::Error::None; @@ -1389,7 +1533,8 @@ void CoreSDKTest::SubscribeDiscoveryOnNavigateToLaunchNotification() if (error == Firebolt::Error::None) { cout << "Subscribe Discovery OnNavigateToLaunch EntityIntent is success" << endl; } else { - cout << "Subscribe Discovery OnNavigateToLaunch EntityIntent status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeDiscoveryOnNavigateToLaunchNotification failed. " + errorMessage); } error = Firebolt::Error::None; @@ -1397,9 +1542,11 @@ void CoreSDKTest::SubscribeDiscoveryOnNavigateToLaunchNotification() if (error == Firebolt::Error::None) { cout << "Subscribe Discovery OnNavigateToLaunch TuneIntent is success" << endl; } else { - cout << "Subscribe Discovery OnNavigateToLaunch TuneIntent status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeDiscoveryOnNavigateToLaunchNotification failed. " + errorMessage); } } + void CoreSDKTest::UnsubscribeDiscoveryOnNavigateToLaunchNotification() { Firebolt::Error error = Firebolt::Error::None; @@ -1407,7 +1554,8 @@ void CoreSDKTest::UnsubscribeDiscoveryOnNavigateToLaunchNotification() if (error == Firebolt::Error::None) { cout << "Unsubscribe Discovery OnNavigateToLaunch HomeIntent is success" << endl; } else { - cout << "Unsubscribe Discovery OnNavigateToLaunch HomeIntent status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeDiscoveryOnNavigateToLaunchNotification failed. " + errorMessage); } error = Firebolt::Error::None; @@ -1415,7 +1563,8 @@ void CoreSDKTest::UnsubscribeDiscoveryOnNavigateToLaunchNotification() if (error == Firebolt::Error::None) { cout << "Unsubscribe Discovery OnNavigateToLaunch EntityIntent is success" << endl; } else { - cout << "Unsubscribe Discovery OnNavigateToLaunch EntityIntent status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeDiscoveryOnNavigateToLaunchNotification failed. " + errorMessage); } error = Firebolt::Error::None; @@ -1423,18 +1572,22 @@ void CoreSDKTest::UnsubscribeDiscoveryOnNavigateToLaunchNotification() if (error == Firebolt::Error::None) { cout << "Unsubscribe Discovery OnNavigateToLaunch TuneIntent is success" << endl; } else { - cout << "Unsubscribe Discovery OnNavigateToLaunch TuneIntent status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeDiscoveryOnNavigateToLaunchNotification failed. " + errorMessage); } } -void CoreSDKTest::OnNavigateToHomeIntentNotification::onNavigateTo( const Firebolt::Intents::HomeIntent& intent) + +void CoreSDKTest::OnNavigateToHomeIntentNotification::onNavigateTo(const Firebolt::Intents::HomeIntent& intent) { cout << "onNavigateTo for action : " << intent.action << endl; } -void CoreSDKTest::OnNavigateToEntityIntentNotification::onNavigateTo( const Firebolt::Intents::EntityIntent& intent) + +void CoreSDKTest::OnNavigateToEntityIntentNotification::onNavigateTo(const Firebolt::Intents::EntityIntent& intent) { cout << "onNavigateTo for action : " << intent.action << endl; } -void CoreSDKTest::OnNavigateToTuneIntentNotification::onNavigateTo( const Firebolt::Intents::TuneIntent& intent) + +void CoreSDKTest::OnNavigateToTuneIntentNotification::onNavigateTo(const Firebolt::Intents::TuneIntent& intent) { cout << "onNavigateTo for action : " << intent.action << endl; -} +} \ No newline at end of file diff --git a/src/sdks/core/src/cpp/sdk/cpptest/Main.cpp b/src/sdks/core/src/cpp/sdk/cpptest/Main.cpp index 7c4441792..ac6f6653f 100644 --- a/src/sdks/core/src/cpp/sdk/cpptest/Main.cpp +++ b/src/sdks/core/src/cpp/sdk/cpptest/Main.cpp @@ -1,659 +1,169 @@ #include +#include +#include +#include +#include #include "CoreSDKTest.h" -void ShowMenu() -{ - printf("Enter\n" - "\tI : Get Account Id\n" - "\tU : Get Account Uid\n" - "\tM : Get Device Model\n" - "\tS : Get Device Sku\n" - "\tA : Handle Advertising methods\n" - "\tN : Get/Subscribe/Unsubscribe Device Name\n" - "\tP : Get/Subscribe/Unsubscribe Device Audio Profiles\n" - "\tR : Get/Subscribe/Unsubscribe Device Screen Resolution\n" - "\tL : Handle Localization methods\n" - "\tC : Get/Subscribe/Unsubscribe Closed Caption Settings\n" - "\tK : Invoke keyboard methods email/password/standard\n" - "\tV : Handle Profile methods\n" - "\tT : Handle Authentication methods\n" - "\tB : Handle Capabilities Method\n" - "\tE : Handle Metrics methods\n" - "\tF : Handle Lifecycle methods\n" - "\tD : Handle SecondScreen methods\n" - "\tY : Handle Discovery methods\n" - "\tZ : Parameters Initialization\n" - "\tQ : Quit\n\n" - ); -} - -void ShowPropertyMenu(std::string& module, std::string& property) -{ - printf("%s:%s property options \n" - "\tG : Get value\n" - "\tR : Show subscribe/unscribe event menu\n" - "\tQ : Quit\n", module.c_str(), property.c_str()); -} - -void ShowProfileMenu() -{ - printf("Options: \n" - "\tC : Verify ApproveContentRating\n" - "\tP : Verify ApprovePurchase\n" - "\tF : Get Flags\n" - "\tQ : Quit\n"); -} - -void ShowLocalizationMenu() -{ - printf("Options: \n" - "\tA: Get additionalInfo\n" - "\tL: Get LatLon\n" - "\tP: Get/Subscribe/Unsubscribe Preferred AudioLanguages\n" - "\tQ : Quit\n"); -} - -void ShowAuthenticationMenu() -{ - printf("Options: \n" - "\t Invoke lifecyclesession management sequence from postman before invoking methods\n" - "\tD : Get Authentication Device\n" - "\tS : Get Authentication Session\n" - "\tR : Get Authentication Root\n" - "\tT : Get Authentication Token\n" - "\tQ : Quit\n"); -} - -void ShowCapabilitiesMenu() -{ - printf("Options: \n" - "\tA : Get Capabilities Available\n" - "\tG : Get Capabilities Granted\n" - "\tP : Get Capabilities Permitted\n" - "\tS : Get Capabilities Supported\n" - "\tI : Get Capabilities Info\n" - "\tQ : Quit\n"); -} - -void ShowAdvertisingMenu() -{ - printf("Options: \n" - "\tP : Get/Subscribe/Unsubscribe Advertising Policy\n" - "\tC : Build configuration object for Ad Framework initialization\n" - "\tD : Get the device advertising device attributes\n" - "\tQ : Quit\n"); -} - -void ShowLifecycleMenu() -{ - printf("Options: \n" - "\tC : Close lifecycle of the app\n" - "\tB : Subscribe/Unsubscribe Background notification\n" - "\tF : Subscribe/Unsubscribe Foreground notification\n" - "\tQ : Quit\n"); -} - -void ShowMetricsMenu() -{ - printf("Options: \n" - "\tS : Start Content\n" - "\tT : Stop Content\n" - "\tQ : Quit\n"); -} - -void ShowSecondScreenMenu() -{ - printf("Options: \n" - "\tD : Get Device Id\n" - "\tF : Get/Subscribe/Unsubscribe FriendlyName\n" - "\tP : Get Protocols\n" - "\tQ : Quit\n"); -} - -void ShowDiscoveryMenu() -{ - printf("Options: \n" - "\tS : SignIn\n" - "\tO : SignOut\n" - "\tA : ContentAccess\n" - "\tC : ClearContentAccess\n" - "\tE : Entitlements\n" - "\tI : EntityInfo\n" - "\tP : Policy\n" - "\tU : PurchasedContent\n" - "\tN : WatchNext\n" - "\tF : UserInterest\n" - "\tL : Launch\n" +using namespace std; + +const char* options = ":hu:"; + +void RunAllTests() { + bool allTestsPassed = true; + vector errorMessages; + + auto runTest = [&allTestsPassed, &errorMessages](auto testFunction, const string& testName) { + try { + testFunction(); + } catch (const exception& e) { + errorMessages.push_back("Test " + testName + " failed: " + e.what()); + allTestsPassed = false; + } + }; + + // Ensure the connection is ready before running tests + if (CoreSDKTest::WaitOnConnectionReady()) { + // Account ID + runTest(CoreSDKTest::GetAccountId, "GetAccountId"); + + // Account UID + runTest(CoreSDKTest::GetAccountUid, "GetAccountUid"); + + // Advertising methods + runTest(CoreSDKTest::BuildAdvertisingConfiguration, "BuildAdvertisingConfiguration"); + runTest(CoreSDKTest::GetAdvertisingDeviceAttributes, "GetAdvertisingDeviceAttributes"); + runTest(CoreSDKTest::SubscribeAdvertisingPolicyChanged, "SubscribeAdvertisingPolicyChanged"); + runTest(CoreSDKTest::UnsubscribeAdvertisingPolicyChanged, "UnsubscribeAdvertisingPolicyChanged"); + + // Device properties + runTest(CoreSDKTest::GetDeviceModel, "GetDeviceModel"); + runTest(CoreSDKTest::GetDeviceSku, "GetDeviceSku"); + runTest(CoreSDKTest::GetDeviceName, "GetDeviceName"); + runTest(CoreSDKTest::SubscribeDeviceNameChanged, "SubscribeDeviceNameChanged"); + runTest(CoreSDKTest::UnsubscribeDeviceNameChanged, "UnsubscribeDeviceNameChanged"); + runTest(CoreSDKTest::GetDeviceAudio, "GetDeviceAudio"); + runTest(CoreSDKTest::SubscribeDeviceAudioChanged, "SubscribeDeviceAudioChanged"); + runTest(CoreSDKTest::UnsubscribeDeviceAudioChanged, "UnsubscribeDeviceAudioChanged"); + runTest(CoreSDKTest::GetDeviceScreenResolution, "GetDeviceScreenResolution"); + runTest(CoreSDKTest::SubscribeDeviceScreenResolutionChanged, "SubscribeDeviceScreenResolutionChanged"); + runTest(CoreSDKTest::UnsubscribeDeviceScreenResolutionChanged, "UnsubscribeDeviceScreenResolutionChanged"); + + // Localization methods + runTest(CoreSDKTest::GetLocalizationAdditionalInfo, "GetLocalizationAdditionalInfo"); + runTest(CoreSDKTest::GetLocalizationLatlon, "GetLocalizationLatlon"); + runTest(CoreSDKTest::GetLocalizationPreferredAudioLanguages, "GetLocalizationPreferredAudioLanguages"); + runTest(CoreSDKTest::SubscribeLocalizationPreferredAudioLanguagesChanged, "SubscribeLocalizationPreferredAudioLanguagesChanged"); + runTest(CoreSDKTest::UnsubscribeLocalizationPreferredAudioLanguagesChanged, "UnsubscribeLocalizationPreferredAudioLanguagesChanged"); + + // Accessibility - Closed Captions Settings + runTest(CoreSDKTest::GetAccessibilityClosedCaptionsSettings, "GetAccessibilityClosedCaptionsSettings"); + runTest(CoreSDKTest::SubscribeAccessibilityClosedCaptionsSettingsChanged, "SubscribeAccessibilityClosedCaptionsSettingsChanged"); + runTest(CoreSDKTest::UnsubscribeAccessibilityClosedCaptionsSettingsChanged, "UnsubscribeAccessibilityClosedCaptionsSettingsChanged"); + + // Keyboard methods + // runTest(CoreSDKTest::InvokeKeyboardEmail, "InvokeKeyboardEmail"); + // runTest(CoreSDKTest::AbortKeyboardEmail, "AbortKeyboardEmail"); + // runTest(CoreSDKTest::InvokeKeyboardPassword, "InvokeKeyboardPassword"); + // runTest(CoreSDKTest::AbortKeyboardPassword, "AbortKeyboardPassword"); + // runTest(CoreSDKTest::InvokeKeyboardStandard, "InvokeKeyboardStandard"); + // runTest(CoreSDKTest::AbortKeyboardStandard, "AbortKeyboardStandard"); + + // Profile methods + runTest(CoreSDKTest::VerifyProfileApproveContentRating, "VerifyProfileApproveContentRating"); + runTest(CoreSDKTest::VerifyProfileApprovePurchase, "VerifyProfileApprovePurchase"); + runTest(CoreSDKTest::GetProfileFlags, "GetProfileFlags"); + + // Authentication methods + runTest(CoreSDKTest::GetAuthenticationDevice, "GetAuthenticationDevice"); + runTest(CoreSDKTest::GetAuthenticationSession, "GetAuthenticationSession"); + runTest(CoreSDKTest::GetAuthenticationRoot, "GetAuthenticationRoot"); + runTest(CoreSDKTest::GetAuthenticationToken, "GetAuthenticationToken"); + + // Capabilities methods + runTest(CoreSDKTest::GetCapabilitiesAvailable, "GetCapabilitiesAvailable"); + runTest(CoreSDKTest::GetCapabilitiesGranted, "GetCapabilitiesGranted"); + runTest(CoreSDKTest::GetCapabilitiesPermitted, "GetCapabilitiesPermitted"); + runTest(CoreSDKTest::GetCapabilitiesSupported, "GetCapabilitiesSupported"); + runTest(CoreSDKTest::GetCapabilitiesInfo, "GetCapabilitiesInfo"); + + // Lifecycle methods + // runTest(CoreSDKTest::LifecycleClose, "LifecycleClose"); + runTest(CoreSDKTest::SubscribeLifecycleBackgroundNotification, "SubscribeLifecycleBackgroundNotification"); + runTest(CoreSDKTest::UnsubscribeLifecycleBackgroundNotification, "UnsubscribeLifecycleBackgroundNotification"); + runTest(CoreSDKTest::SubscribeLifecycleForegroundNotification, "SubscribeLifecycleForegroundNotification"); + runTest(CoreSDKTest::UnsubscribeLifecycleForegroundNotification, "UnsubscribeLifecycleForegroundNotification"); + + // Metrics methods + runTest(CoreSDKTest::MetricsStartContent, "MetricsStartContent"); + runTest(CoreSDKTest::MetricsStopContent, "MetricsStopContent"); + + // SecondScreen methods + runTest(CoreSDKTest::GetSecondScreenDevice, "GetSecondScreenDevice"); + runTest(CoreSDKTest::GetSecondScreenFriendlyName, "GetSecondScreenFriendlyName"); + runTest(CoreSDKTest::SubscribeSecondScreenFriendlyNameChanged, "SubscribeSecondScreenFriendlyNameChanged"); + runTest(CoreSDKTest::UnsubscribeSecondScreenFriendlyNameChanged, "UnsubscribeSecondScreenFriendlyNameChanged"); + runTest(CoreSDKTest::GetSecondScreenProtocols, "GetSecondScreenProtocols"); + + // Discovery methods + runTest(CoreSDKTest::DiscoverySignIn, "DiscoverySignIn"); + runTest(CoreSDKTest::DiscoverySignOut, "DiscoverySignOut"); + runTest(CoreSDKTest::DiscoveryContentAccess, "DiscoveryContentAccess"); + runTest(CoreSDKTest::DiscoveryClearContentAccess, "DiscoveryClearContentAccess"); + runTest(CoreSDKTest::DiscoveryEntitlements, "DiscoveryEntitlements"); + runTest(CoreSDKTest::DiscoveryEntityInfo, "DiscoveryEntityInfo"); + runTest(CoreSDKTest::DiscoveryPolicy, "DiscoveryPolicy"); + runTest(CoreSDKTest::DiscoveryPurchasedContent, "DiscoveryPurchasedContent"); + runTest(CoreSDKTest::DiscoveryWatchNext, "DiscoveryWatchNext"); + runTest(CoreSDKTest::DiscoveryLaunch, "DiscoveryLaunch"); #ifdef POLYMORPHICS_REDUCER_METHODS - "\tW : Watched\n" - "\tR : WatchedReduced\n" + runTest(CoreSDKTest::DiscoveryWatched, "DiscoveryWatched"); + runTest(CoreSDKTest::DiscoveryWatchedReduced, "DiscoveryWatchedReduced"); #endif - "\tB : Subscribe/Unsubscribe DiscoveryOnNavigateToLaunch\n" - "\tQ : Quit\n"); -} - -void ShowKeyboardMenu() -{ - printf("Enter\n" - "\tE : Invoke Email method\n" - "\tA : Abort Email method\n" - "\tP : Invoke Password method\n" - "\tC : Abort Password method\n" - "\tS : Invoke Standard method\n" - "\tK : Abort Standard method\n" - "\tQ : Quit\n"); -} - -void ShowEventMenu() -{ - printf("Enter\n" - "\tS : Subscribe Event\n" - "\tU : Unsubscribe Event\n" - "\tQ : Quit\n"); -} - -#define VALUE(string) #string -#define TO_STRING(string) VALUE(string) - -#define HandleEventListener(Module, eventFuncName) \ -{ \ - int opt; \ - do { \ - getchar(); \ - ShowEventMenu(); \ - printf("Enter option : "); \ - opt = toupper(getchar()); \ - switch (opt) { \ - case 'S': { \ - CoreSDKTest::Subscribe##Module##eventFuncName(); \ - break; \ - } \ - case 'U': { \ - CoreSDKTest::Unsubscribe##Module##eventFuncName(); \ - break; \ - } \ - default: \ - break; \ - } \ - } while (opt != 'Q'); \ -} - - -#define HandleProperty(Module, Property) \ -{ \ - int opt; \ - do { \ - getchar(); \ - std::string module = TO_STRING(Module); \ - std::string property = TO_STRING(Property); \ - ShowPropertyMenu(module, property); \ - printf("Enter option : "); \ - opt = toupper(getchar()); \ - switch (opt) { \ - case 'G': { \ - CoreSDKTest::Get##Module##Property(); \ - break; \ - } \ - case 'R': { \ - HandleEventListener(Module, Property##Changed) \ - break; \ - } \ - default: \ - break; \ - } \ - } while (opt != 'Q'); \ -} - -void HandleAuthenticationMethod() -{ - int opt; - do { - getchar(); - ShowAuthenticationMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'D': { - CoreSDKTest::GetAuthenticationDevice(); - break; - } - case 'S': { - CoreSDKTest::GetAuthenticationSession(); - break; - } - case 'R': { - CoreSDKTest::GetAuthenticationRoot(); - break; - } - case 'T': { - CoreSDKTest::GetAuthenticationToken(); - break; - } - default: - break; - } - } while (opt != 'Q'); -} - -void HandleCapabilitiesMethod() -{ - int opt; - do { - getchar(); - ShowCapabilitiesMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'A': { - HandleProperty(Capabilities, Available) - break; - } - case 'G': { - CoreSDKTest::GetCapabilitiesGranted(); - break; - } - case 'P': { - CoreSDKTest::GetCapabilitiesPermitted(); - break; - } - case 'S': { - CoreSDKTest::GetCapabilitiesSupported(); - break; - } - case 'I': { - CoreSDKTest::GetCapabilitiesInfo(); - break; - } - default: - break; - } - } while (opt != 'Q'); -} - -void HandleProfileMethod() -{ - int opt; - do { - getchar(); - ShowProfileMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'C': { - CoreSDKTest::VerifyProfileApproveContentRating(); // Error while testing, need to cross check - break; - } - case 'P': { - CoreSDKTest::VerifyProfileApprovePurchase(); // Error while testing, need to cross check - break; - } - case 'F': { - CoreSDKTest::GetProfileFlags(); - break; - } - default: - break; - } - } while (opt != 'Q'); -} + runTest(CoreSDKTest::SubscribeDiscoveryOnNavigateToLaunchNotification, "SubscribeDiscoveryOnNavigateToLaunchNotification"); + runTest(CoreSDKTest::UnsubscribeDiscoveryOnNavigateToLaunchNotification, "UnsubscribeDiscoveryOnNavigateToLaunchNotification"); -void HandleLocalizationMethod() -{ - int opt; - do { - getchar(); - ShowLocalizationMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'A': { - CoreSDKTest::GetLocalizationAdditionalInfo(); - break; - } - case 'L': { - CoreSDKTest::GetLocalizationLatlon(); - break; - } - case 'P': { - HandleProperty(Localization, PreferredAudioLanguages) - break; - } - default: - break; - } - } while (opt != 'Q'); -} + // Parameters Initialization + runTest(CoreSDKTest::ParametersInitialization, "ParametersInitialization"); -void HandleAdvertisingMethod() -{ - int opt; - do { - getchar(); - ShowAdvertisingMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'P': { - HandleProperty(Advertising, Policy) - break; - } - case 'C': { - CoreSDKTest::BuildAdvertisingConfiguration(); // Error while testing need to check - break; - } - case 'D': { - CoreSDKTest::GetAdvertisingDeviceAttributes(); // Error while testing need to check - break; - } - default: - break; - } - } while (opt != 'Q'); -} - -void HandleLifecycleMethod() -{ - int opt; - do { - getchar(); - ShowLifecycleMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'C': { - CoreSDKTest::LifecycleClose(); - break; - } - case 'B': { - HandleEventListener(Lifecycle, BackgroundNotification) - break; - } - case 'F': { - HandleEventListener(Lifecycle, ForegroundNotification) - break; - } - default: - break; - } - } while (opt != 'Q'); -} - -void HandleMetricsMethod() -{ - int opt; - do { - getchar(); - ShowMetricsMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'S': { - CoreSDKTest::MetricsStartContent(); - break; - } - case 'T': { - CoreSDKTest::MetricsStopContent(); - break; - } - default: - break; - } - } while (opt != 'Q'); -} - -void HandleSecondScreenMethod() -{ - int opt; - do { - getchar(); - ShowSecondScreenMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'D': { - CoreSDKTest::GetSecondScreenDevice(); - break; - } - case 'F': { - HandleProperty(SecondScreen, FriendlyName) - break; - } - case 'P': { - CoreSDKTest::GetSecondScreenProtocols(); - break; - } - default: - break; - } - } while (opt != 'Q'); -} - -void HandleDiscoveryMethod() -{ - int opt; - do { - getchar(); - ShowDiscoveryMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'S': { - CoreSDKTest::DiscoverySignIn(); - break; - } - case 'O': { - CoreSDKTest::DiscoverySignOut(); - break; - } - case 'A': { - CoreSDKTest::DiscoveryContentAccess(); - break; - } - case 'C': { - CoreSDKTest::DiscoveryClearContentAccess(); - break; - } - case 'E': { - CoreSDKTest::DiscoveryEntitlements(); - break; - } - case 'I': { - CoreSDKTest::DiscoveryEntityInfo(); - break; - } - case 'P': { - CoreSDKTest::DiscoveryPolicy(); - break; - } - case 'U': { - CoreSDKTest::DiscoveryPurchasedContent(); - break; - } - case 'N': { - CoreSDKTest::DiscoveryWatchNext(); - break; - } - case 'F': { - CoreSDKTest::DiscoveryUserInterest(); - break; - } - case 'L': { - CoreSDKTest::DiscoveryLaunch(); - break; - } -#ifdef POLYMORPHICS_REDUCER_METHODS - case 'W': { - CoreSDKTest::DiscoveryWatched(); - break; - } - case 'R': { - CoreSDKTest::DiscoveryWatchedReduced(); - break; - } -#endif - case 'B': { - HandleEventListener(Discovery, OnNavigateToLaunchNotification) - } - default: - break; - } - } while (opt != 'Q'); -} - -void HandleKeyboardMethodsInvokation() -{ - int opt; - do { - getchar(); - ShowKeyboardMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'E': { - CoreSDKTest::InvokeKeyboardEmail(); - break; - } - case 'A': { - CoreSDKTest::AbortKeyboardEmail(); - break; - } - case 'P': { - CoreSDKTest::InvokeKeyboardPassword(); - break; - } - case 'C': { - CoreSDKTest::AbortKeyboardPassword(); - break; - } - case 'S': { - CoreSDKTest::InvokeKeyboardStandard(); - break; - } - case 'K': { - CoreSDKTest::AbortKeyboardStandard(); - break; - } - default: - break; + if (allTestsPassed) { + cout << "============================" << endl; + cout << "ALL CORE SDK TESTS SUCCEEDED!" << endl; + cout << "============================" << endl; + } else { + cout << "============================" << endl; + cout << "SOME TESTS FAILED:" << endl; + for (const auto& errorMessage : errorMessages) { + cout << errorMessage << endl; + } + cout << "============================" << endl; + exit(1); } - } while (opt != 'Q'); + } else { + cout << "Core Test not able to connect with server..." << endl; + exit(1); + } } -#define options ":hu:" -int main (int argc, char* argv[]) -{ +int main(int argc, char* argv[]) { int c; - std::string url = "ws://127.0.0.1:9998"; - while ((c = getopt (argc, argv, options)) != -1) { - switch (c) - { + string url = "ws://127.0.0.1:9998"; + while ((c = getopt(argc, argv, options)) != -1) { + switch (c) { case 'u': - url = optarg; - break; - + url = optarg; + break; case 'h': - printf("./TestFireboltManage -u ws://ip:port\n"); - exit(1); + printf("./TestFireboltManage -u ws://ip:port\n"); + exit(1); } } printf("Firebolt Core SDK Test\n"); CoreSDKTest::CreateFireboltInstance(url); - int option; - if (CoreSDKTest::WaitOnConnectionReady() == true) { - do { - ShowMenu(); - printf("Enter option : "); - option = toupper(getchar()); - switch (option) { - case 'I' : { - CoreSDKTest::GetAccountId(); // Error while running need to cross check - break; - } - case 'U' : { - CoreSDKTest::GetAccountUid(); // Error while running need to cross check - break; - } - case 'A' : { - HandleAdvertisingMethod(); - break; - } - case 'N': { - HandleProperty(Device, Name) - break; - } - case 'M': { - CoreSDKTest::GetDeviceModel(); - break; - } - case 'S': { - CoreSDKTest::GetDeviceSku(); - break; - } - case 'P': { - HandleProperty(Device, Audio) - break; - } - case 'R': { - HandleProperty(Device, ScreenResolution) - break; - } - case 'L': { - HandleLocalizationMethod(); - break; - } - case 'C': { - HandleProperty(Accessibility, ClosedCaptionsSettings) - break; - } - case 'K': { - HandleKeyboardMethodsInvokation(); - break; - } - case 'V': { - HandleProfileMethod(); - break; - } - case 'T': { - HandleAuthenticationMethod(); - break; - } - case 'B': { - HandleCapabilitiesMethod(); - break; - } - case 'F': { - HandleLifecycleMethod(); - break; - } - case 'E': { - HandleMetricsMethod(); - break; - } - case 'D': { - HandleSecondScreenMethod(); - break; - } - case 'Y': { - HandleDiscoveryMethod(); - break; - } - case 'Z': { - CoreSDKTest::ParametersInitialization(); - break; - } - default: - break; - } - getchar(); // Skip white space - } while (option != 'Q'); - - } else { - printf("Core Test not able to connect with server.... \n"); - } - + RunAllTests(); CoreSDKTest::DestroyFireboltInstance(); return 0; -} +} \ No newline at end of file diff --git a/src/sdks/discovery/package.json b/src/sdks/discovery/package.json index 23bc181f7..0e4ec34e9 100644 --- a/src/sdks/discovery/package.json +++ b/src/sdks/discovery/package.json @@ -1,6 +1,6 @@ { "name": "@firebolt-js/discovery-sdk", - "version": "1.2.1-next.1", + "version": "1.2.1-next.2", "description": "The Firebolt Discovery JS SDK", "main": "./dist/lib/firebolt-discovery.mjs", "types": "./dist/lib/firebolt-discovery.d.ts", diff --git a/src/sdks/manage/package.json b/src/sdks/manage/package.json index 46330e885..ef8c41e66 100644 --- a/src/sdks/manage/package.json +++ b/src/sdks/manage/package.json @@ -1,6 +1,6 @@ { "name": "@firebolt-js/manage-sdk", - "version": "1.2.1-next.1", + "version": "1.2.1-next.2", "description": "The Firebolt Manage JS SDK", "main": "./dist/lib/firebolt-manage.mjs", "types": "./dist/lib/firebolt-manage.d.ts", diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/Main.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/Main.cpp index 1a0b1df3b..c28aa7e0c 100644 --- a/src/sdks/manage/src/cpp/sdk/cpptest/Main.cpp +++ b/src/sdks/manage/src/cpp/sdk/cpptest/Main.cpp @@ -1,397 +1,145 @@ #include +#include +#include +#include +#include #include "ManageSDKTest.h" -void ShowMenu() -{ - printf("Options ---- >\n" - "\tA : Get/Set Advertising skipRestriction\n" - "\tT : Set Account Session\n" - "\tE : Get/Set/Subscribe/Unsubscribe AudioDescriptions Enabled\n" - "\tN : Get/Set/Subscribe/Unsubscribe Device Name\n" - "\tB : Get/Set/Subscribe/Unsubscribe ClosedCaption Background Opacity\n" - "\tF : Get/Set/Subscribe/Unsubscribe ClosedCaption Font Family\n" - "\tL : Get/Set/Subscribe/Unsubscribe Localization Preferred AudioLanguages\n" - "\tC : Get/Set/Subscribe/Unsubscribe Privacy Allow ACR Collection\n" - "\tS : Get Privacy Settings\n" - "\tI : Subscribe/Unsubscribe SignIn notification\n" - "\tO : Subscribe/Unsubscribe SignOut notification\n" - "\tR : Reset Advertising Identifier\n" - "\tK : Register for Keyboard Provider and check sequence\n" - "\tG : Register for Acknowledge Challenge Provider and check sequence\n" - "\tP : Register for Pin Challenge Provider and check sequence\n" - "\tD : Operate on Localization Additional Info\n" - "\tU : Grant/Deny/Clear permission on App\n" - "\tW : Scan Wifi on device\n" - "\tQ : Quit\n\n" - ); -} - -void ShowWifiOperationsMenu() -{ - printf("Options \n" - "\tS : Scan access points\n" - "\tC : Connect to selected access point \n" - "\tD : Disconnect from access point \n" - "\tQ : Quit\n"); -} - -void ShowUserGrantsMenu() -{ - printf("Invoke lifecyclesession management sequence from postman \n" - "Once the permission granted/denies/cleared, please use provider + api test to validate it \n" - "Here capabilty used for the testing is hardcoded as device:model\n" - "\tG : Get Permission\n" - "\tR : Grant Permission\n" - "\tD : Deny Permission\n" - "\tC : Clear Permission\n" - "\tQ : Quit\n"); -} - -void ShowAdditionalInfoMenu() -{ - printf("Options \n" - "\tG : Get Additional Info\n" - "\tA : Add Additional Info\n" - "\tR : Remove Additional Info\n" - "\tQ : Quit\n"); -} - -void ShowPropertyMenu(std::string& module, std::string& property) -{ - printf("%s:%s property options \n" - "\tG : Get value\n" - "\tS : Set value\n" - "\tQ : Quit\n", module.c_str(), property.c_str()); -} - -void ShowPropertyWithEventMenu(std::string& module, std::string& property) -{ - printf("%s:%s property options \n" - "\tG : Get value\n" - "\tS : Set value\n" - "\tR : Show subscribe/unscribe event menu\n" - "\tQ : Quit\n", module.c_str(), property.c_str()); -} +using namespace std; -void ShowProviderMenu(std::string& module) -{ - printf("Invoke lifecyclesession management from postman and api sequence from other entity for %s and press\n" - "\tR : To Send Response\n" - "\tE : To Send Error\n" - "\tQ : Quit\n", module.c_str()); -} +const char* options = ":hu:"; -void ShowEventMenu() -{ - printf("Options \n" - "\tS : Subscribe Event\n" - "\tU : Unsubscribe Event\n" - "\tQ : Quit\n"); -} +void RunAllTests() { + bool allTestsPassed = true; + vector errorMessages; -void HandleUserGrants() -{ - int opt; - do { - getchar(); - ShowUserGrantsMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'G': { - ManageSDKTest::GetUserGrantsPermission(); - break; - } - case 'R': { - ManageSDKTest::GrantUserGrantsPermission(); - break; - } - case 'D': { - ManageSDKTest::DenyUserGrantsPermission(); - break; - } - case 'C': { - ManageSDKTest::ClearUserGrantsPermission(); - break; - } - default: - break; - } - } while (opt != 'Q'); -} - -void HandleAdditionalInfo() -{ - int opt; - do { - getchar(); - ShowAdditionalInfoMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'G': { - ManageSDKTest::GetLocalizationAdditionalInfo(); - break; - } - case 'A': { - ManageSDKTest::AddLocalizationAdditionalInfo(); - break; - } - case 'R': { - ManageSDKTest::RemoveLocalizationAdditionalInfo(); - break; + auto runTest = [&allTestsPassed, &errorMessages](auto testFunction, const string& testName) { + try { + testFunction(); + } catch (const exception& e) { + errorMessages.push_back("Test " + testName + " failed: " + e.what()); + allTestsPassed = false; } - default: - break; + }; + + // Ensure the connection is ready before running tests + if (ManageSDKTest::WaitOnConnectionReady()) { + // Advertising methods + runTest(ManageSDKTest::GetAdvertisingSkipRestriction, "GetAdvertisingSkipRestriction"); + runTest(ManageSDKTest::SetAdvertisingSkipRestriction, "SetAdvertisingSkipRestriction"); + runTest(ManageSDKTest::ResetAdvertisingIdentifier, "ResetAdvertisingIdentifier"); + + // Account methods + runTest(ManageSDKTest::SetAccountSession, "SetAccountSession"); + + // AudioDescriptions methods + runTest(ManageSDKTest::GetAudioDescriptionsEnabled, "GetAudioDescriptionsEnabled"); + runTest(ManageSDKTest::SetAudioDescriptionsEnabled, "SetAudioDescriptionsEnabled"); + runTest(ManageSDKTest::SubscribeAudioDescriptionsEnabledChanged, "SubscribeAudioDescriptionsEnabledChanged"); + runTest(ManageSDKTest::UnsubscribeAudioDescriptionsEnabledChanged, "UnsubscribeAudioDescriptionsEnabledChanged"); + + // Device methods + runTest(ManageSDKTest::GetDeviceName, "GetDeviceName"); + runTest(ManageSDKTest::SetDeviceName, "SetDeviceName"); + runTest(ManageSDKTest::SubscribeDeviceNameChanged, "SubscribeDeviceNameChanged"); + runTest(ManageSDKTest::UnsubscribeDeviceNameChanged, "UnsubscribeDeviceNameChanged"); + + // ClosedCaptions methods + runTest(ManageSDKTest::GetClosedCaptionsBackgroundOpacity, "GetClosedCaptionsBackgroundOpacity"); + runTest(ManageSDKTest::SetClosedCaptionsBackgroundOpacity, "SetClosedCaptionsBackgroundOpacity"); + runTest(ManageSDKTest::SubscribeClosedCaptionsBackgroundOpacityChanged, "SubscribeClosedCaptionsBackgroundOpacityChanged"); + runTest(ManageSDKTest::UnsubscribeClosedCaptionsBackgroundOpacityChanged, "UnsubscribeClosedCaptionsBackgroundOpacityChanged"); + + runTest(ManageSDKTest::GetClosedCaptionsFontFamily, "GetClosedCaptionsFontFamily"); + runTest(ManageSDKTest::SetClosedCaptionsFontFamily, "SetClosedCaptionsFontFamily"); + runTest(ManageSDKTest::SubscribeClosedCaptionsFontFamilyChanged, "SubscribeClosedCaptionsFontFamilyChanged"); + runTest(ManageSDKTest::UnsubscribeClosedCaptionsFontFamilyChanged, "UnsubscribeClosedCaptionsFontFamilyChanged"); + + // Localization methods + runTest(ManageSDKTest::GetLocalizationPreferredAudioLanguages, "GetLocalizationPreferredAudioLanguages"); + runTest(ManageSDKTest::SetLocalizationPreferredAudioLanguages, "SetLocalizationPreferredAudioLanguages"); + runTest(ManageSDKTest::SubscribeLocalizationPreferredAudioLanguagesChanged, "SubscribeLocalizationPreferredAudioLanguagesChanged"); + runTest(ManageSDKTest::UnsubscribeLocalizationPreferredAudioLanguagesChanged, "UnsubscribeLocalizationPreferredAudioLanguagesChanged"); + + runTest(ManageSDKTest::GetLocalizationAdditionalInfo, "GetLocalizationAdditionalInfo"); + runTest(ManageSDKTest::AddLocalizationAdditionalInfo, "AddLocalizationAdditionalInfo"); + runTest(ManageSDKTest::RemoveLocalizationAdditionalInfo, "RemoveLocalizationAdditionalInfo"); + + // Privacy methods + runTest(ManageSDKTest::GetPrivacyAllowACRCollection, "GetPrivacyAllowACRCollection"); + runTest(ManageSDKTest::SetPrivacyAllowACRCollection, "SetPrivacyAllowACRCollection"); + runTest(ManageSDKTest::SubscribePrivacyAllowACRCollectionChanged, "SubscribePrivacyAllowACRCollectionChanged"); + runTest(ManageSDKTest::UnsubscribePrivacyAllowACRCollectionChanged, "UnsubscribePrivacyAllowACRCollectionChanged"); + + runTest(ManageSDKTest::GetPrivacySettings, "GetPrivacySettings"); + + // Discovery methods + runTest(ManageSDKTest::SubscribeDiscoverySignInNotification, "SubscribeDiscoverySignInNotification"); + runTest(ManageSDKTest::UnsubscribeDiscoverySignInNotification, "UnsubscribeDiscoverySignInNotification"); + runTest(ManageSDKTest::SubscribeDiscoverySignOutNotification, "SubscribeDiscoverySignOutNotification"); + runTest(ManageSDKTest::UnsubscribeDiscoverySignOutNotification, "UnsubscribeDiscoverySignOutNotification"); + + // UserGrants methods + runTest(ManageSDKTest::GetUserGrantsPermission, "GetUserGrantsPermission"); + runTest(ManageSDKTest::GrantUserGrantsPermission, "GrantUserGrantsPermission"); + runTest(ManageSDKTest::DenyUserGrantsPermission, "DenyUserGrantsPermission"); + runTest(ManageSDKTest::ClearUserGrantsPermission, "ClearUserGrantsPermission"); + + // Wifi methods + // runTest(ManageSDKTest::WifiScan, "WifiScan"); + // runTest(ManageSDKTest::WifiConnect, "WifiConnect"); + // runTest(ManageSDKTest::WifiDisconnect, "WifiDisconnect"); + + // Provider registration + runTest(ManageSDKTest::RegisterKeyboardProvider, "RegisterKeyboardProvider"); + runTest(ManageSDKTest::SendResponseMessageToKeyboardProvider, "SendResponseMessageToKeyboardProvider"); + runTest(ManageSDKTest::SendErrorMessageToKeyboardProvider, "SendErrorMessageToKeyboardProvider"); + + runTest(ManageSDKTest::RegisterAcknowledgeChallengeProvider, "RegisterAcknowledgeChallengeProvider"); + runTest(ManageSDKTest::SendResponseMessageToAcknowledgeChallengeProvider, "SendResponseMessageToAcknowledgeChallengeProvider"); + runTest(ManageSDKTest::SendErrorMessageToAcknowledgeChallengeProvider, "SendErrorMessageToAcknowledgeChallengeProvider"); + + runTest(ManageSDKTest::RegisterPinChallengeProvider, "RegisterPinChallengeProvider"); + runTest(ManageSDKTest::SendResponseMessageToPinChallengeProvider, "SendResponseMessageToPinChallengeProvider"); + runTest(ManageSDKTest::SendErrorMessageToPinChallengeProvider, "SendErrorMessageToPinChallengeProvider"); + + if (allTestsPassed) { + cout << "============================" << endl; + cout << "ALL MANAGE SDK TESTS SUCCEEDED!" << endl; + cout << "============================" << endl; + } else { + cout << "============================" << endl; + cout << "SOME TESTS FAILED:" << endl; + for (const auto& errorMessage : errorMessages) { + cout << errorMessage << endl; + } + cout << "============================" << endl; + exit(1); } - } while (opt != 'Q'); -} - -#define VALUE(string) #string -#define TO_STRING(string) VALUE(string) - -#define HandleEventListener(Module, eventFuncName) \ -{ \ - int opt; \ - do { \ - getchar(); \ - ShowEventMenu(); \ - printf("Enter option : "); \ - opt = toupper(getchar()); \ - switch (opt) { \ - case 'S': { \ - ManageSDKTest::Subscribe##Module##eventFuncName(); \ - break; \ - } \ - case 'U': { \ - ManageSDKTest::Unsubscribe##Module##eventFuncName(); \ - break; \ - } \ - default: \ - break; \ - } \ - } while (opt != 'Q'); \ -} - -#define HandleProperty(Module, Property) \ -{ \ - int opt; \ - do { \ - getchar(); \ - std::string module = TO_STRING(Module); \ - std::string property = TO_STRING(Property); \ - ShowPropertyMenu(module, property); \ - printf("Enter option : "); \ - opt = toupper(getchar()); \ - switch (opt) { \ - case 'G': { \ - ManageSDKTest::Get##Module##Property(); \ - break; \ - } \ - case 'S': { \ - ManageSDKTest::Set##Module##Property(); \ - break; \ - } \ - default: \ - break; \ - } \ - } while (opt != 'Q'); \ -} - - -#define HandlePropertyWithEvent(Module, Property) \ -{ \ - int opt; \ - do { \ - getchar(); \ - std::string module = TO_STRING(Module); \ - std::string property = TO_STRING(Property); \ - ShowPropertyWithEventMenu(module, property); \ - printf("Enter option : "); \ - opt = toupper(getchar()); \ - switch (opt) { \ - case 'G': { \ - ManageSDKTest::Get##Module##Property(); \ - break; \ - } \ - case 'S': { \ - ManageSDKTest::Set##Module##Property(); \ - break; \ - } \ - case 'R': { \ - HandleEventListener(Module, Property##Changed) \ - break; \ - } \ - default: \ - break; \ - } \ - } while (opt != 'Q'); \ -} - -#define HandleProviderSequence(Module) \ -{ \ - int opt; \ - do { \ - getchar(); \ - std::string module = TO_STRING(Module); \ - ShowProviderMenu(module); \ - printf("Enter option : "); \ - opt = toupper(getchar()); \ - switch (opt) { \ - case 'R': { \ - ManageSDKTest::SendResponseMessageTo##Module##Provider(); \ - break; \ - } \ - case 'E': { \ - ManageSDKTest::SendErrorMessageTo##Module##Provider(); \ - break; \ - } \ - default: \ - break; \ - } \ - } while (opt != 'Q'); \ -} - -void HandleWifiOperations() -{ - int opt; - do { - getchar(); - ShowWifiOperationsMenu(); - printf("Enter option : "); - opt = toupper(getchar()); - switch (opt) { - case 'S': { - ManageSDKTest::WifiScan(); - break; - } - case 'C': { - ManageSDKTest::WifiConnect(); - break; - } - case 'D': { - ManageSDKTest::WifiDisconnect(); // This method is not avaialble from ripple now - break; - } - default: - break; - } - } while (opt != 'Q'); + } else { + cout << "Manage Test not able to connect with server..." << endl; + exit(1); + } } -#define options ":hu:" -int main (int argc, char* argv[]) -{ +int main(int argc, char* argv[]) { int c; - std::string url = "ws://127.0.0.1:9998"; - while ((c = getopt (argc, argv, options)) != -1) { - switch (c) - { + string url = "ws://127.0.0.1:9998"; + while ((c = getopt(argc, argv, options)) != -1) { + switch (c) { case 'u': - url = optarg; - break; - + url = optarg; + break; case 'h': - printf("./TestFireboltManage -u ws://ip:port\n"); - exit(1); + printf("./TestFireboltManage -u ws://ip:port\n"); + exit(1); } } printf("Firebolt Manage SDK Test\n"); - ManageSDKTest::CreateFireboltInstance(url); - int option; - - if (ManageSDKTest::WaitOnConnectionReady() == true) { - do { - ShowMenu(); - printf("Enter option : "); - option = toupper(getchar()); - switch (option) { - case 'A': { - HandleProperty(Advertising, SkipRestriction) - break; - } - case 'T': { - ManageSDKTest::SetAccountSession(); - break; - } - case 'E': { - HandlePropertyWithEvent(AudioDescriptions, Enabled) - break; - } - case 'N': { - HandlePropertyWithEvent(Device, Name) - break; - } - case 'B': { - HandlePropertyWithEvent(ClosedCaptions, BackgroundOpacity) - break; - } - case 'F': { - HandlePropertyWithEvent(ClosedCaptions, FontFamily) - break; - } - case 'L': { - HandlePropertyWithEvent(Localization, PreferredAudioLanguages) - break; - } - case 'C': { - HandlePropertyWithEvent(Privacy, AllowACRCollection) - break; - } - case 'S': { - ManageSDKTest::GetPrivacySettings(); - break; - } - case 'I': { - HandleEventListener(Discovery, SignInNotification) - break; - } - case 'O': { - HandleEventListener(Discovery, SignOutNotification) - break; - } - case 'R': { - ManageSDKTest::ResetAdvertisingIdentifier(); - break; - } - case 'K': { - ManageSDKTest::RegisterKeyboardProvider(); - HandleProviderSequence(Keyboard) - break; - } - case 'G': { - ManageSDKTest::RegisterAcknowledgeChallengeProvider(); - HandleProviderSequence(AcknowledgeChallenge) - break; - } - case 'P': { - ManageSDKTest::RegisterPinChallengeProvider(); - HandleProviderSequence(PinChallenge) - break; - } - case 'D': { - HandleAdditionalInfo(); - break; - } - case 'U': { - HandleUserGrants(); - break; - } - case 'W': { - HandleWifiOperations(); - break; - } - default: - break; - } - getchar(); // Skip white space - } while (option != 'Q'); - - } else { - printf("Manage Test not able to connect with server.... \n"); - } + ManageSDKTest::CreateFireboltInstance(url); + RunAllTests(); ManageSDKTest::DestroyFireboltInstance(); return 0; diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.cpp index 47c128ab4..f8a388724 100644 --- a/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.cpp +++ b/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.cpp @@ -18,6 +18,7 @@ #include #include +#include #include "ManageSDKTest.h" using namespace std; @@ -105,6 +106,7 @@ EnumMap skipRestrictionMap = { { Firebolt::Advertising::SkipRestriction::ADS_UNWATCHED, "adsUnwatched" }, { Firebolt::Advertising::SkipRestriction::ADS_ALL, "adsAll" }, { Firebolt::Advertising::SkipRestriction::ALL, "all" }}; + void ManageSDKTest::GetAdvertisingSkipRestriction() { Firebolt::Error error = Firebolt::Error::None; @@ -112,9 +114,11 @@ void ManageSDKTest::GetAdvertisingSkipRestriction() if (error == Firebolt::Error::None) { cout << "Get Advertising SkipRestriction is success : " << ConvertFromEnum(skipRestrictionMap, skipRestriction) << endl; } else { - cout << "Get Advertising SkipRestriction status: " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetAdvertisingSkipRestriction failed. " + errorMessage); } } + void ManageSDKTest::SetAdvertisingSkipRestriction() { Firebolt::Error error = Firebolt::Error::None; @@ -122,17 +126,18 @@ void ManageSDKTest::SetAdvertisingSkipRestriction() for (auto skipRestriction : skipRestrictionMap) { cout << skipRestriction.second << endl; } - std::string skipRestriction; - cout << "Enter new skipRestriction : "; - cin >> skipRestriction; + + std::string skipRestriction = "none"; Firebolt::IFireboltAccessor::Instance().AdvertisingInterface().setSkipRestriction(ConvertToEnum(skipRestrictionMap, skipRestriction), &error); if (error == Firebolt::Error::None) { cout << "Set Advertising SkipRestriction is success " << endl; } else { - cout << "Set Advertising SkipRestriction status: " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SetAdvertisingSkipRestriction failed. " + errorMessage); } } + void ManageSDKTest::ResetAdvertisingIdentifier() { Firebolt::Error error = Firebolt::Error::None; @@ -140,7 +145,8 @@ void ManageSDKTest::ResetAdvertisingIdentifier() if (error == Firebolt::Error::None) { cout << "Set Advertising Reset Identifier is success " << endl; } else { - cout << "Set Advertising Reset Identifier status: " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("ResetAdvertisingIdentifier failed. " + errorMessage); } } @@ -153,7 +159,8 @@ void ManageSDKTest::SetAccountSession() if (error == Firebolt::Error::None) { cout << "Set Account Session is success" << endl; } else { - cout << "Set Account Session status : " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SetAccountSession failed. " + errorMessage); } } @@ -164,27 +171,29 @@ void ManageSDKTest::GetAudioDescriptionsEnabled() if (error == Firebolt::Error::None) { cout << "Get AudioDescriptions Enabled: " << (enabled ? "true" : "false") << endl; } else { - cout << "Get AudioDescriptions Enabled status: " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetAudioDescriptionsEnabled failed. " + errorMessage); } } + void ManageSDKTest::SetAudioDescriptionsEnabled() { Firebolt::Error error = Firebolt::Error::None; - std::string strEnabled; - cout << "Enter enabled or not (true/false): "; - cin >> strEnabled; - bool enabled = strEnabled == "true" ? true : false; + bool enabled = true; Firebolt::IFireboltAccessor::Instance().AudioDescriptionsInterface().setEnabled(enabled, &error); if (error == Firebolt::Error::None) { cout << "Set AudioDescriptions Enabled: " << endl; } else { - cout << "Set AudioDescriptions Enabled status: " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SetAudioDescriptionsEnabled failed. " + errorMessage); } } -void ManageSDKTest::OnAudioDescriptionsEnabledChangedNotification::onEnabledChanged( const bool enabled ) + +void ManageSDKTest::OnAudioDescriptionsEnabledChangedNotification::onEnabledChanged(const bool enabled) { cout << "AudioDescriptions Enabled changed, new value --> " << (enabled ? "true" : "false") << endl; } + void ManageSDKTest::SubscribeAudioDescriptionsEnabledChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -192,9 +201,11 @@ void ManageSDKTest::SubscribeAudioDescriptionsEnabledChanged() if (error == Firebolt::Error::None) { cout << "Subscribe AudioDescriptions EnabledChange is success" << endl; } else { - cout << "Subscribe AudioDescriptions EnabledChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeAudioDescriptionsEnabledChanged failed. " + errorMessage); } } + void ManageSDKTest::UnsubscribeAudioDescriptionsEnabledChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -202,7 +213,8 @@ void ManageSDKTest::UnsubscribeAudioDescriptionsEnabledChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe AudioDescriptions EnabledChange is success" << endl; } else { - cout << "Unsubscribe AudioDescriptions EnabledChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeAudioDescriptionsEnabledChanged failed. " + errorMessage); } } @@ -214,29 +226,30 @@ void ManageSDKTest::GetDeviceName() if (error == Firebolt::Error::None) { cout << "Get Device Name = " << name.c_str() << endl; } else { - cout << "Get Device Name status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetDeviceName failed. " + errorMessage); } } + void ManageSDKTest::SetDeviceName() { Firebolt::Error error = Firebolt::Error::None; - std::string name; - cout << "Enter new device name :"; - getchar(); - getline(cin, name); + std::string name = "Kitchen"; Firebolt::IFireboltAccessor::Instance().DeviceInterface().setName(name, &error); if (error == Firebolt::Error::None) { - cout << "Set Device Name is success" << endl; + cout << "Set Device Name to " << name << " is success" << endl; } else { - cout << "Set Device Name status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SetDeviceName failed. " + errorMessage); } - cin.putback('\n'); } -void ManageSDKTest::OnDeviceNameChangedNotification::onDeviceNameChanged( const std::string& name ) + +void ManageSDKTest::OnDeviceNameChangedNotification::onDeviceNameChanged(const std::string& name) { cout << "Name changed, new name --> " << name << endl; } + void ManageSDKTest::SubscribeDeviceNameChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -244,9 +257,11 @@ void ManageSDKTest::SubscribeDeviceNameChanged() if (error == Firebolt::Error::None) { cout << "Subscribe Device NameChange is success" << endl; } else { - cout << "Subscribe Device NameChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeDeviceNameChanged failed. " + errorMessage); } } + void ManageSDKTest::UnsubscribeDeviceNameChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -254,7 +269,8 @@ void ManageSDKTest::UnsubscribeDeviceNameChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe Device NameChange is success" << endl; } else { - cout << "Unsubscribe Device NameChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeDeviceNameChanged failed. " + errorMessage); } } @@ -266,28 +282,31 @@ void ManageSDKTest::GetClosedCaptionsBackgroundOpacity() if (error == Firebolt::Error::None) { cout << "Get ClosedCaption BackgroundOpacity = " << value << endl; } else { - cout << "Get ClosedCaption BackgroundOpacity status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetClosedCaptionsBackgroundOpacity failed. " + errorMessage); } } + void ManageSDKTest::SetClosedCaptionsBackgroundOpacity() { Firebolt::Error error = Firebolt::Error::None; - uint32_t bgOpacity; - cout << "Enter new background opacity: "; - scanf("%d", &bgOpacity); + uint32_t bgOpacity = 1; Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().setBackgroundOpacity(bgOpacity, &error); if (error == Firebolt::Error::None) { - cout << "Set ClosedCaption BackgroundOpacity is success" << endl; + cout << "Set ClosedCaption BackgroundOpacity to " << bgOpacity << " is success" << endl; } else { - cout << "Set ClosedCaption BackgroundOpacity status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SetClosedCaptionsBackgroundOpacity failed. " + errorMessage); } } -void ManageSDKTest::OnBackgroundOpacityChangedNotification::onBackgroundOpacityChanged( const float opacity ) + +void ManageSDKTest::OnBackgroundOpacityChangedNotification::onBackgroundOpacityChanged(const float opacity) { cout << "BackgroundOpacity changed, new value --> " << opacity << endl; } + void ManageSDKTest::SubscribeClosedCaptionsBackgroundOpacityChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -295,9 +314,11 @@ void ManageSDKTest::SubscribeClosedCaptionsBackgroundOpacityChanged() if (error == Firebolt::Error::None) { cout << "Subscribe ClosedCaptions BackgroundOpacityChange is success" << endl; } else { - cout << "Subscribe ClosedCaptions BackgroundOpacityChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeClosedCaptionsBackgroundOpacityChanged failed. " + errorMessage); } } + void ManageSDKTest::UnsubscribeClosedCaptionsBackgroundOpacityChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -305,7 +326,8 @@ void ManageSDKTest::UnsubscribeClosedCaptionsBackgroundOpacityChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe ClosedCaptions BackgroundOpacityChange is success" << endl; } else { - cout << "Unsubscribe ClosedCaptions BackgroundOpacityChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeClosedCaptionsBackgroundOpacityChanged failed. " + errorMessage); } } @@ -318,6 +340,7 @@ EnumMap fontFamilyMap = { { Firebolt::Accessibility::FontFamily::CURSIVE, "Cursive" }, { Firebolt::Accessibility::FontFamily::CASUAL, "Casual" } }; + void ManageSDKTest::GetClosedCaptionsFontFamily() { Firebolt::Error error = Firebolt::Error::None; @@ -326,31 +349,30 @@ void ManageSDKTest::GetClosedCaptionsFontFamily() if (error == Firebolt::Error::None) { cout << "Get ClosedCaption FontFamily value = " << ConvertFromEnum(fontFamilyMap, value) << endl; } else { - cout << "Get ClosedCaption FontFamily status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetClosedCaptionsFontFamily failed. " + errorMessage); } } + void ManageSDKTest::SetClosedCaptionsFontFamily() { Firebolt::Error error = Firebolt::Error::None; - std::string fontFamily; - cout << "Supported font family -> " << endl; - for (auto family : fontFamilyMap) { - cout << family.second << endl; - } - cout << "Enter new font family : "; - cin >> fontFamily; + Firebolt::Accessibility::FontFamily fontFamily = Firebolt::Accessibility::FontFamily::MONOSPACED_SERIF; - Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().setFontFamily(ConvertToEnum(fontFamilyMap, fontFamily), &error); + Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().setFontFamily(fontFamily, &error); if (error == Firebolt::Error::None) { - cout << "Set ClosedCaption FontFamily is success" << endl; + cout << "Set ClosedCaption FontFamily to MonospacedSerif is success" << endl; } else { - cout << "Set ClosedCaption FontFamily status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SetClosedCaptionsFontFamily failed. " + errorMessage); } } -void ManageSDKTest::OnFontFamilyChangedNotification::onFontFamilyChanged( const Firebolt::Accessibility::FontFamily& family ) + +void ManageSDKTest::OnFontFamilyChangedNotification::onFontFamilyChanged(const Firebolt::Accessibility::FontFamily& family) { cout << "FontFamily changed, new code --> " << ConvertFromEnum(fontFamilyMap, family) << endl; } + void ManageSDKTest::SubscribeClosedCaptionsFontFamilyChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -358,9 +380,11 @@ void ManageSDKTest::SubscribeClosedCaptionsFontFamilyChanged() if (error == Firebolt::Error::None) { cout << "Subscribe ClosedCaptions FontFamilyChange is success" << endl; } else { - cout << "Subscribe ClosedCaptions FontFamilyChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeClosedCaptionsFontFamilyChanged failed. " + errorMessage); } } + void ManageSDKTest::UnsubscribeClosedCaptionsFontFamilyChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -368,7 +392,8 @@ void ManageSDKTest::UnsubscribeClosedCaptionsFontFamilyChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe ClosedCaptions FontFamilyChange is success" << endl; } else { - cout << "Unsubscribe ClosedCaptions FontFamilyChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeClosedCaptionsFontFamilyChanged failed. " + errorMessage); } } @@ -380,49 +405,37 @@ void ManageSDKTest::GetLocalizationPreferredAudioLanguages() if (error == Firebolt::Error::None) { cout << "Get Localization PreferredAudioLanguages : " << endl; for (auto language: languages) { - cout << "----- > " < " << language << endl; } } else { - cout << "Get Localization PreferredAudioLanguages status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetLocalizationPreferredAudioLanguages failed. " + errorMessage); } } + void ManageSDKTest::SetLocalizationPreferredAudioLanguages() { Firebolt::Error error = Firebolt::Error::None; - const std::vector languages = { "ara", "jpn", "hin", "eng", "per", "dut" }; - cout << "Sample language code --> " << endl; - for (auto language : languages) { - cout << language << " "; - } - std::string language; - cout << " enter new audio language code to set : "; - getchar(); - getline(cin, language); + std::vector newLanguages = { "eng" }; - std::vector newLanguages; - string delimeter = " "; - char* token = strtok(const_cast(language.c_str()), delimeter.c_str()); - while (token != nullptr) - { - newLanguages.push_back(string(token)); - token = strtok(nullptr, delimeter.c_str()); - } Firebolt::IFireboltAccessor::Instance().LocalizationInterface().setPreferredAudioLanguages(newLanguages, &error); if (error == Firebolt::Error::None) { - cout << "Set Localization PreferredAudioLanguages is success" << endl; + cout << "Set Localization PreferredAudioLanguages to eng is success" << endl; } else { - cout << "Get Localization PreferredAudioLanguages status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SetLocalizationPreferredAudioLanguages failed. " + errorMessage); } - cin.putback('\n'); } -void ManageSDKTest::OnPreferredAudioLanguagesChangedNotification::onPreferredAudioLanguagesChanged( const std::vector& languages) + +void ManageSDKTest::OnPreferredAudioLanguagesChangedNotification::onPreferredAudioLanguagesChanged(const std::vector& languages) { cout << "PreferredAudioLanguages Changed, new languages --> " << endl; for (auto language : languages) { cout << " -> " << language << endl; } } + void ManageSDKTest::SubscribeLocalizationPreferredAudioLanguagesChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -430,9 +443,11 @@ void ManageSDKTest::SubscribeLocalizationPreferredAudioLanguagesChanged() if (error == Firebolt::Error::None) { cout << "Subscribe Localization PreferredAudioLanguagesChange is success" << endl; } else { - cout << "Subscribe Localization PreferredAudioLanguagesChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeLocalizationPreferredAudioLanguagesChanged failed. " + errorMessage); } } + void ManageSDKTest::UnsubscribeLocalizationPreferredAudioLanguagesChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -440,7 +455,8 @@ void ManageSDKTest::UnsubscribeLocalizationPreferredAudioLanguagesChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe Localization PreferredAudioLanguagesChange is success" << endl; } else { - cout << "Unsubscribe Localization PreferredAudioLanguagesChange status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeLocalizationPreferredAudioLanguagesChanged failed. " + errorMessage); } } @@ -452,28 +468,30 @@ void ManageSDKTest::GetPrivacyAllowACRCollection() if (error == Firebolt::Error::None) { cout << "Get Privacy AllowACRCollection : " << (allowACRCollection ? "true" : "false") << endl; } else { - cout << "Get Privacy AllowACRCollection status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetPrivacyAllowACRCollection failed. " + errorMessage); } } + void ManageSDKTest::SetPrivacyAllowACRCollection() { Firebolt::Error error = Firebolt::Error::None; - std::string strAllowACRCollection; - cout << "Enter new allowACRCollection (true/false): "; - cin >> strAllowACRCollection; - bool allowACRCollection = strAllowACRCollection == "true" ? true : false; - Firebolt::IFireboltAccessor::Instance().PrivacyInterface().setAllowACRCollection(allowACRCollection , &error); + bool allowACRCollection = false; + Firebolt::IFireboltAccessor::Instance().PrivacyInterface().setAllowACRCollection(allowACRCollection, &error); if (error == Firebolt::Error::None) { cout << "Set Privacy AllowACRCollection is success" << endl; } else { - cout << "Get Privacy AllowACRCollection status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SetPrivacyAllowACRCollection failed. " + errorMessage); } } -void ManageSDKTest::OnAllowACRCollectionChangedNotification::onAllowACRCollectionChanged( const bool allowACRCollection ) + +void ManageSDKTest::OnAllowACRCollectionChangedNotification::onAllowACRCollectionChanged(const bool allowACRCollection) { cout << "AllowACRCollection Changed, new value of allowACRCollection : " << (allowACRCollection ? "true" : "false") << endl; } + void ManageSDKTest::SubscribePrivacyAllowACRCollectionChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -481,9 +499,11 @@ void ManageSDKTest::SubscribePrivacyAllowACRCollectionChanged() if (error == Firebolt::Error::None) { cout << "Subscribe Privacy AllowACRCollectionChanged is success" << endl; } else { - cout << "Subscribe Privacy AllowACRCollectionChanged status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribePrivacyAllowACRCollectionChanged failed. " + errorMessage); } } + void ManageSDKTest::UnsubscribePrivacyAllowACRCollectionChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -491,9 +511,11 @@ void ManageSDKTest::UnsubscribePrivacyAllowACRCollectionChanged() if (error == Firebolt::Error::None) { cout << "Unsubscribe Privacy AllowACRCollectionChanged is success" << endl; } else { - cout << "Unsubscribe Privacy AllowACRCollectionChanged status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribePrivacyAllowACRCollectionChanged failed. " + errorMessage); } } + void ManageSDKTest::GetPrivacySettings() { Firebolt::Error error = Firebolt::Error::None; @@ -514,15 +536,16 @@ void ManageSDKTest::GetPrivacySettings() cout << "\tallowUnentitledResumePoints : " << privacySettings.allowUnentitledResumePoints << endl; cout << "\tallowWatchHistory : " << privacySettings.allowWatchHistory << endl; } else { - cout << "Get Privacy Settings status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetPrivacySettings failed. " + errorMessage); } - } -void ManageSDKTest::OnSignInNotification::onSignIn( const Firebolt::Discovery::Event& event ) +void ManageSDKTest::OnSignInNotification::onSignIn(const Firebolt::Discovery::Event& event) { cout << "Discovery SignIn Event for appId --> " << event.appId << endl; } + void ManageSDKTest::SubscribeDiscoverySignInNotification() { Firebolt::Error error = Firebolt::Error::None; @@ -530,9 +553,11 @@ void ManageSDKTest::SubscribeDiscoverySignInNotification() if (error == Firebolt::Error::None) { cout << "Subscribe Discovery SignIn Notification is success" << endl; } else { - cout << "Subscribe Discovery SignIn Notification status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeDiscoverySignInNotification failed. " + errorMessage); } } + void ManageSDKTest::UnsubscribeDiscoverySignInNotification() { Firebolt::Error error = Firebolt::Error::None; @@ -540,14 +565,16 @@ void ManageSDKTest::UnsubscribeDiscoverySignInNotification() if (error == Firebolt::Error::None) { cout << "Unsubscribe Discovery SignIn Notification is success" << endl; } else { - cout << "Unsubscribe Discovery SignIn Notification status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeDiscoverySignInNotification failed. " + errorMessage); } } -void ManageSDKTest::OnSignOutNotification::onSignOut( const Firebolt::Discovery::Event& event ) +void ManageSDKTest::OnSignOutNotification::onSignOut(const Firebolt::Discovery::Event& event) { cout << "Discovery SignOut Event for appId --> " << event.appId << endl; } + void ManageSDKTest::SubscribeDiscoverySignOutNotification() { Firebolt::Error error = Firebolt::Error::None; @@ -555,9 +582,11 @@ void ManageSDKTest::SubscribeDiscoverySignOutNotification() if (error == Firebolt::Error::None) { cout << "Subscribe Discovery SignOut Notification is success" << endl; } else { - cout << "Subscribe Discovery SignOut Notification status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("SubscribeDiscoverySignOutNotification failed. " + errorMessage); } } + void ManageSDKTest::UnsubscribeDiscoverySignOutNotification() { Firebolt::Error error = Firebolt::Error::None; @@ -565,7 +594,8 @@ void ManageSDKTest::UnsubscribeDiscoverySignOutNotification() if (error == Firebolt::Error::None) { cout << "Unsubscribe Discovery SignOut Notification is success" << endl; } else { - cout << "Unsubscribe Discovery SignOut Notification status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("UnsubscribeDiscoverySignOutNotification failed. " + errorMessage); } } @@ -575,6 +605,7 @@ ManageSDKTest::KeyboardProvider::KeyboardProvider() , _keyInput(false) { } + void ManageSDKTest::KeyboardProvider::SendMessage(bool response) { if (_keyInput) { @@ -605,35 +636,42 @@ void ManageSDKTest::KeyboardProvider::SendMessage(bool response) cout << " there is no active keyboard input session " << endl; } } + void ManageSDKTest::KeyboardProvider::standard(const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr session) { cout << "KeyboardProvider Standard is invoked" << endl; startKeyboardSession(parameters, std::move(session)); } + void ManageSDKTest::KeyboardProvider::password(const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr session) { cout << "KeyboardProvider Password is invoked" << endl; startKeyboardSession(parameters, std::move(session)); } + void ManageSDKTest::KeyboardProvider::email(const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr session) { cout << "KeyboardProvider Email is invoked" << endl; startKeyboardSession(parameters, std::move(session)); } -void ManageSDKTest::KeyboardProvider::startKeyboardSession( const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr session ) + +void ManageSDKTest::KeyboardProvider::startKeyboardSession(const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr session) { _session = std::move(session); _parameters = parameters; _keyInput = true; } + void ManageSDKTest::RegisterKeyboardProvider() { Firebolt::IFireboltAccessor::Instance().KeyboardInterface().provide(_keyboardProvider); } + void ManageSDKTest::SendResponseMessageToKeyboardProvider() { _keyboardProvider.SendMessage(true); } + void ManageSDKTest::SendErrorMessageToKeyboardProvider() { _keyboardProvider.SendMessage(false); @@ -645,6 +683,7 @@ ManageSDKTest::AcknowledgeChallengeProvider::AcknowledgeChallengeProvider() , _challengeInput(false) { } + void ManageSDKTest::AcknowledgeChallengeProvider::SendMessage(bool response) { if (_challengeInput) { @@ -674,25 +713,30 @@ void ManageSDKTest::AcknowledgeChallengeProvider::SendMessage(bool response) cout << " there is no active acknowledge challenge input session " << endl; } } + void ManageSDKTest::AcknowledgeChallengeProvider::challenge(const Firebolt::AcknowledgeChallenge::Challenge& parameters, std::unique_ptr session) { cout << "AcknowledgeChallengeProvider challenge is invoked" << endl; startAcknowledgeChallengeSession(parameters, std::move(session)); } -void ManageSDKTest::AcknowledgeChallengeProvider::startAcknowledgeChallengeSession( const Firebolt::AcknowledgeChallenge::Challenge& parameters, std::unique_ptr session ) + +void ManageSDKTest::AcknowledgeChallengeProvider::startAcknowledgeChallengeSession(const Firebolt::AcknowledgeChallenge::Challenge& parameters, std::unique_ptr session) { _session = std::move(session); _parameters = parameters; _challengeInput = true; } + void ManageSDKTest::RegisterAcknowledgeChallengeProvider() { Firebolt::IFireboltAccessor::Instance().AcknowledgeChallengeInterface().provide(_acknowledgeChallengeProvider); } + void ManageSDKTest::SendResponseMessageToAcknowledgeChallengeProvider() { _acknowledgeChallengeProvider.SendMessage(true); } + void ManageSDKTest::SendErrorMessageToAcknowledgeChallengeProvider() { _acknowledgeChallengeProvider.SendMessage(false); @@ -704,6 +748,7 @@ ManageSDKTest::PinChallengeProvider::PinChallengeProvider() , _challengeInput(false) { } + void ManageSDKTest::PinChallengeProvider::SendMessage(bool response) { if (_challengeInput) { @@ -738,25 +783,30 @@ void ManageSDKTest::PinChallengeProvider::SendMessage(bool response) cout << " there is no active pin challenge input session " << endl; } } + void ManageSDKTest::PinChallengeProvider::challenge(const Firebolt::PinChallenge::PinChallenge& parameters, std::unique_ptr session) { cout << "PinChallengeProvider challenge is invoked" << endl; startPinChallengeSession(parameters, std::move(session)); } -void ManageSDKTest::PinChallengeProvider::startPinChallengeSession( const Firebolt::PinChallenge::PinChallenge& parameters, std::unique_ptr session ) + +void ManageSDKTest::PinChallengeProvider::startPinChallengeSession(const Firebolt::PinChallenge::PinChallenge& parameters, std::unique_ptr session) { _session = std::move(session); _parameters = parameters; _challengeInput = true; } + void ManageSDKTest::RegisterPinChallengeProvider() { Firebolt::IFireboltAccessor::Instance().PinChallengeInterface().provide(_pinChallengeProvider); } + void ManageSDKTest::SendResponseMessageToPinChallengeProvider() { _pinChallengeProvider.SendMessage(true); } + void ManageSDKTest::SendErrorMessageToPinChallengeProvider() { _pinChallengeProvider.SendMessage(false); @@ -772,59 +822,49 @@ void ManageSDKTest::GetLocalizationAdditionalInfo() cout << " " << element.first << " : " << element.second << endl; } } else { - cout << "AdditionalInfo call status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetLocalizationAdditionalInfo failed. " + errorMessage); } } + void ManageSDKTest::AddLocalizationAdditionalInfo() { Firebolt::Error error = Firebolt::Error::None; - std::string key; - cout << "Enter new key :"; - getchar(); - getline(cin, key); - std::string value; - cout << "Enter new value :"; - getline(cin, value); + std::string key = "testKey"; + std::string value = "testValue"; Firebolt::IFireboltAccessor::Instance().LocalizationInterface().addAdditionalInfo(key, value, &error); if (error == Firebolt::Error::None) { cout << "Add AdditionalInfo is success" << endl; } else { - cout << "Add AdditionalInfo status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("AddLocalizationAdditionalInfo failed. " + errorMessage); } - - cin.putback('\n'); } + void ManageSDKTest::RemoveLocalizationAdditionalInfo() { Firebolt::Error error = Firebolt::Error::None; - std::string key; - cout << "Enter key to be removed :"; - getchar(); - getline(cin, key); + std::string key = "testKey"; Firebolt::IFireboltAccessor::Instance().LocalizationInterface().removeAdditionalInfo(key, &error); if (error == Firebolt::Error::None) { cout << "Remove AdditionalInfo is success" << endl; } else { - cout << "Remove AdditionalInfo status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("RemoveLocalizationAdditionalInfo failed. " + errorMessage); } - - cin.putback('\n'); } void ManageSDKTest::GetUserGrantsPermission() { Firebolt::Error error = Firebolt::Error::None; - cout << "Enter appId :"; - getchar(); - std::string appId; - getline(cin, appId); + std::string appId = "certApp"; std::vector grantInfo = Firebolt::IFireboltAccessor::Instance().UserGrantsInterface().app(appId, &error); if (error == Firebolt::Error::None) { cout << "Get UserGrants Permission is success" << endl; - if (grantInfo.size() > 0) { + if (grantInfo.size() > 0) { cout << "Grant Permission list : " << endl; for (auto info : grantInfo) { cout << "GrantState : " << static_cast(info.state) << endl; @@ -832,69 +872,59 @@ void ManageSDKTest::GetUserGrantsPermission() cout << "Role : " << static_cast(info.role) << endl; cout << "Lifespan : " << static_cast(info.lifespan) << endl; } - } + } } else { - cout << "Get UserGrants Permission status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GetUserGrantsPermission failed. " + errorMessage); } - - cin.putback('\n'); } + void ManageSDKTest::GrantUserGrantsPermission() { Firebolt::Error error = Firebolt::Error::None; Firebolt::UserGrants::GrantModificationOptions grantModificationOptions; - cout << "Enter appId :"; - getchar(); - std::string appId; - getline(cin, appId); + std::string appId = "certApp"; grantModificationOptions.appId = std::make_optional(appId); Firebolt::IFireboltAccessor::Instance().UserGrantsInterface().grant(Firebolt::Capabilities::Role::USE, "xrn:firebolt:capability:device:model", grantModificationOptions, &error); if (error == Firebolt::Error::None) { cout << "Grant UserGrants Permission is success" << endl; } else { - cout << "Grant UserGrants Permission status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("GrantUserGrantsPermission failed. " + errorMessage); } - - cin.putback('\n'); } + void ManageSDKTest::DenyUserGrantsPermission() { Firebolt::Error error = Firebolt::Error::None; Firebolt::UserGrants::GrantModificationOptions grantModificationOptions; - cout << "Enter appId :"; - getchar(); - std::string appId; - getline(cin, appId); + std::string appId = "certApp"; grantModificationOptions.appId = std::make_optional(appId); Firebolt::IFireboltAccessor::Instance().UserGrantsInterface().deny(Firebolt::Capabilities::Role::USE, "xrn:firebolt:capability:device:model", grantModificationOptions, &error); if (error == Firebolt::Error::None) { cout << "Deny UserGrants Permission is success" << endl; } else { - cout << "Deny UserGrants Permission status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("DenyUserGrantsPermission failed. " + errorMessage); } - - cin.putback('\n'); } + void ManageSDKTest::ClearUserGrantsPermission() { Firebolt::Error error = Firebolt::Error::None; Firebolt::UserGrants::GrantModificationOptions grantModificationOptions; - cout << "Enter appId :"; - getchar(); - std::string appId; - getline(cin, appId); + std::string appId = "certApp"; grantModificationOptions.appId = std::make_optional(appId); Firebolt::IFireboltAccessor::Instance().UserGrantsInterface().clear(Firebolt::Capabilities::Role::USE, "xrn:firebolt:capability:device:model", grantModificationOptions, &error); if (error == Firebolt::Error::None) { cout << "Clear UserGrants Permission is success" << endl; } else { - cout << "Clear UserGrants Permission status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("ClearUserGrantsPermission failed. " + errorMessage); } - - cin.putback('\n'); } void PrintAP(const Firebolt::Wifi::AccessPoint ap) @@ -912,6 +942,7 @@ void PrintAP(const Firebolt::Wifi::AccessPoint ap) cout << " Frequency : " << ap.frequency.value() << endl; } } + void PrintAPList(const Firebolt::Wifi::AccessPointList& apList) { if (apList.list.has_value()) { @@ -927,18 +958,21 @@ void PrintAPList(const Firebolt::Wifi::AccessPointList& apList) cout << "empty list " << endl; } } + void ManageSDKTest::WifiScan() { Firebolt::Error error = Firebolt::Error::None; - int32_t timeout = -1; + int32_t timeout = 1; _apList = Firebolt::IFireboltAccessor::Instance().WifiInterface().scan(timeout, &error); if (error == Firebolt::Error::None) { cout << "Wifi Scan is success, "; PrintAPList(_apList); } else { - cout << "Wifi Scan status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("WifiScan failed. " + errorMessage); } } + void ManageSDKTest::WifiConnect() { Firebolt::Error error = Firebolt::Error::None; @@ -961,12 +995,14 @@ void ManageSDKTest::WifiConnect() cout << "Wifi Connect is success, "; PrintAP(connectedAP); } else { - cout << "Wifi Connect status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("WifiConnect failed. " + errorMessage); } } else { cout << "Empty AP list, please initiate scan before trying connect " << endl; } } + void ManageSDKTest::WifiDisconnect() { Firebolt::Error error = Firebolt::Error::None; @@ -974,6 +1010,7 @@ void ManageSDKTest::WifiDisconnect() if (error == Firebolt::Error::None) { cout << "Wifi Disconnect is success, "; } else { - cout << "Wifi Disconnect status = " << static_cast(error) << endl; + std::string errorMessage = "Error: " + std::to_string(static_cast(error)); + throw std::runtime_error("WifiDisconnect failed. " + errorMessage); } }