diff --git a/src/sdks/core/package.json b/src/sdks/core/package.json index b5c39baab..12fcca321 100644 --- a/src/sdks/core/package.json +++ b/src/sdks/core/package.json @@ -12,6 +12,7 @@ "validate": "npx firebolt-openrpc validate --input ./dist/firebolt-core-open-rpc.json", "sdk": "npx firebolt-openrpc sdk --input ./dist/firebolt-core-open-rpc.json --template ./src/js --output ./build/javascript/src --static-module Platform", "native": "npx firebolt-openrpc sdk --input ./dist/firebolt-core-open-rpc.json --template ./src/cpp --output ./build/c/src --static-module Platform --language ../../../node_modules/@firebolt-js/openrpc/languages/c", + "cpp": "npx firebolt-openrpc sdk --input ./dist/firebolt-core-open-rpc.json --template ./src/cpp --output ./build/cpp/src --static-module Platform --language ../../../node_modules/@firebolt-js/openrpc/languages/cpp", "compile": "cd ../../.. && npm run compile", "slice": "npx firebolt-openrpc slice -i ../../../dist/firebolt-open-rpc.json --sdk ./sdk.config.json -o ./dist/firebolt-core-open-rpc.json", "docs": "npx firebolt-openrpc docs --input ./dist/firebolt-core-open-rpc.json --output build/docs/markdown --as-path", @@ -48,4 +49,4 @@ "sdk" ], "license": "Apache-2.0" -} \ No newline at end of file +} diff --git a/src/sdks/core/src/cpp/sdk/ctest/CMakeLists.txt b/src/sdks/core/src/cpp/sdk/cpptest/CMakeLists.txt similarity index 89% rename from src/sdks/core/src/cpp/sdk/ctest/CMakeLists.txt rename to src/sdks/core/src/cpp/sdk/cpptest/CMakeLists.txt index c87f15662..c542cf6cc 100644 --- a/src/sdks/core/src/cpp/sdk/ctest/CMakeLists.txt +++ b/src/sdks/core/src/cpp/sdk/cpptest/CMakeLists.txt @@ -46,7 +46,7 @@ set(TESTAPP TestFireboltCore) message("Setup ${TESTAPP}") -add_executable(${TESTAPP} main.c) +add_executable(${TESTAPP} CoreSDKTest.cpp Main.cpp) target_link_libraries(${TESTAPP} PRIVATE @@ -61,6 +61,17 @@ target_include_directories(${TESTAPP} $ ) +if (POLYMORPHICS_REDUCER_METHODS) + target_compile_definitions(${TESTAPP} + PUBLIC + POLYMORPHICS_REDUCER_METHODS=1) +endif() + +set_target_properties(${TESTAPP} PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED YES +) + add_custom_command( TARGET ${TESTAPP} POST_BUILD diff --git a/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp b/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp new file mode 100644 index 000000000..327dcb413 --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp @@ -0,0 +1,1369 @@ +/* + * Copyright 2023 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include "CoreSDKTest.h" + +using namespace std; +bool CoreSDKTest::_connected; +CoreSDKTest::OnPolicyChangedNotification CoreSDKTest::_policyChangedNotification; +CoreSDKTest::OnDeviceNameChangedNotification CoreSDKTest::_deviceNameChangedNotification; +CoreSDKTest::OnAudioChangedNotification CoreSDKTest::_audioChangedNotification; +CoreSDKTest::OnScreenResolutionChangedNotification CoreSDKTest::_screenResolutionChangedNotification; +CoreSDKTest::OnClosedCaptionsSettingsChangedNotification CoreSDKTest::_closedCaptionsSettingsChangedNotification; +CoreSDKTest::OnPreferredAudioLanguagesChangedNotification CoreSDKTest::_preferredAudioLanguagesChangedNotification; +CoreSDKTest::OnBackgroundNotification CoreSDKTest::_backgroundNotification; +CoreSDKTest::OnForegroundNotification CoreSDKTest::_foregroundNotification; +CoreSDKTest::OnFriendlyNameChangedNotification CoreSDKTest::_friendlyNameChangedNotification; +CoreSDKTest::OnAvailableNotification CoreSDKTest::_availableNotification; + +CoreSDKTest::OnNavigateToHomeIntentNotification CoreSDKTest::_navigateToHomeIntentNotification; +CoreSDKTest::OnNavigateToEntityIntentNotification CoreSDKTest::_navigateToEntityIntentNotification; +CoreSDKTest::OnNavigateToTuneIntentNotification CoreSDKTest::_navigateToTuneIntentNotification; + +void CoreSDKTest::ConnectionChanged(const bool connected, const Firebolt::Error error) +{ + cout << "Change in connection: connected: " << connected << " error: " << static_cast(error) << endl; + _connected = connected; +} + +void CoreSDKTest::CreateFireboltInstance(const std::string& url) +{ + const std::string config = "{\ + \"waitTime\": 60000,\ + \"logLevel\": \"Info\",\ + \"workerPool\":{\ + \"queueSize\": 8,\ + \"threadCount\": 3\ + },\ + \"wsUrl\": " + url + "}"; + + _connected = false; + Firebolt::IFireboltAccessor::Instance().Initialize(config); + Firebolt::IFireboltAccessor::Instance().Connect(ConnectionChanged); +} + +void CoreSDKTest::DestroyFireboltInstance() +{ + Firebolt::IFireboltAccessor::Instance().Disconnect(); + Firebolt::IFireboltAccessor::Instance().Deinitialize(); + Firebolt::IFireboltAccessor::Instance().Dispose(); +} + +bool CoreSDKTest::WaitOnConnectionReady() +{ + uint32_t waiting = 10000; + static constexpr uint32_t SLEEPSLOT_TIME = 100; + + // Right, a wait till connection is closed is requested.. + while ((waiting > 0) && (_connected == false)) { + + uint32_t sleepSlot = (waiting > SLEEPSLOT_TIME ? SLEEPSLOT_TIME : waiting); + // Right, lets sleep in slices of 100 ms + usleep(sleepSlot); + waiting -= sleepSlot; + } + return _connected; +} + +void CoreSDKTest::GetAccountId() +{ + Firebolt::Error error = Firebolt::Error::None; + const std::string id = Firebolt::IFireboltAccessor::Instance().AccountInterface().id(&error); + if (error == Firebolt::Error::None) { + cout << "Get Account Id = " << id.c_str() << endl; + } else { + cout << "Get Account Id status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::GetAccountUid() +{ + Firebolt::Error error = Firebolt::Error::None; + const std::string uid = Firebolt::IFireboltAccessor::Instance().AccountInterface().uid(&error); + if (error == Firebolt::Error::None) { + cout << "Get Account Uid = " << uid.c_str() << endl; + } else { + cout << "Get Account Uid status = " << static_cast(error) << endl; + } +} + +template +using EnumMap = std::unordered_map; +template +inline const string& ConvertFromEnum(EnumMap enumMap, T type) +{ + return enumMap[type]; +} +template +inline const T ConvertToEnum(EnumMap enumMap, const string& str) +{ + T value; + for (auto element: enumMap) { + if (element.second == str) { + value = element.first; + break; + } + } + return value; +} + +EnumMap skipRestrictionMap = { + { Firebolt::Advertising::SkipRestriction::NONE, "none" }, + { Firebolt::Advertising::SkipRestriction::ADS_UNWATCHED, "adsUnwatched" }, + { Firebolt::Advertising::SkipRestriction::ADS_ALL, "adsAll" }, + { Firebolt::Advertising::SkipRestriction::ALL, "all" } +}; + +void PrintAdvertisingPolicy(const Firebolt::Advertising::AdPolicy& policy) +{ + if (policy.skipRestriction.has_value()) { + cout << "\tskipRestriction : " << ConvertFromEnum(skipRestrictionMap, policy.skipRestriction.value()) << endl; + } + if (policy.limitAdTracking.has_value()) { + cout << "\tlimitAdTracking : " << policy.limitAdTracking.value() << endl; + } +} +void CoreSDKTest::GetAdvertisingPolicy() +{ + Firebolt::Error error = Firebolt::Error::None; + const Firebolt::Advertising::AdPolicy policy = Firebolt::IFireboltAccessor::Instance().AdvertisingInterface().policy(&error); + if (error == Firebolt::Error::None) { + cout << "Get Advertising policy --> " << endl; + PrintAdvertisingPolicy(policy); + } else { + cout << "Get Advertising policy status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::OnPolicyChangedNotification::onPolicyChanged( const Firebolt::Advertising::AdPolicy& policy ) +{ + cout << "New policy --> " << endl; + PrintAdvertisingPolicy(policy); +} +void CoreSDKTest::SubscribeAdvertisingPolicyChanged() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().AdvertisingInterface().subscribe(_policyChangedNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Subscribe Advertising PolicyChange is success" << endl; + } else { + cout << "Subscribe Advertising PolicyChange status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::UnsubscribeAdvertisingPolicyChanged() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().AdvertisingInterface().unsubscribe(_policyChangedNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Unsubscribe Advertising PolicyChange is success" << endl; + } else { + cout << "Unsubscribe Advertising PolicyChange status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::BuildAdvertisingConfiguration() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::Advertising::AdConfigurationOptions options; + options.coppa = true; + options.environment = Firebolt::Advertising::AdConfigurationOptionsEnvironment::TEST; + options.authenticationEntity = "MVPD"; + + Firebolt::Advertising::AdFrameworkConfig adFrameworkConfig = Firebolt::IFireboltAccessor::Instance().AdvertisingInterface().config(options, &error); + if (error == Firebolt::Error::None) { + cout << "Build AdvertisingConfiguration is success, adFrameworkConfig : " << adFrameworkConfig << endl; + } else { + cout << "Build AdvertisingConfiguration status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::GetAdvertisingDeviceAttributes() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::Advertising::DeviceAttributes deviceAttributes = Firebolt::IFireboltAccessor::Instance().AdvertisingInterface().deviceAttributes(&error); + if (error == Firebolt::Error::None) { + cout << "Get Advertising DeviceAttributes is success, deviceAttributes : " << deviceAttributes << endl; + } else { + cout << "Get Advertising DeviceAttributes status = " << static_cast(error) << endl; + } +} + +void CoreSDKTest::GetDeviceName() +{ + Firebolt::Error error = Firebolt::Error::None; + const std::string name = Firebolt::IFireboltAccessor::Instance().DeviceInterface().name(&error); + + if (error == Firebolt::Error::None) { + cout << "Get Device Name = " << name.c_str() << endl; + } else { + cout << "Get Device Name status = " << static_cast(error) << endl; + } +} + +void CoreSDKTest::OnDeviceNameChangedNotification::onDeviceNameChanged( const std::string& name) +{ + cout << "Name changed, new name --> " << name << endl; +} + +void CoreSDKTest::SubscribeDeviceNameChanged() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().DeviceInterface().subscribe(_deviceNameChangedNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Subscribe Device NameChange is success" << endl; + } else { + cout << "Subscribe Device NameChange status = " << static_cast(error) << endl; + } +} + +void CoreSDKTest::UnsubscribeDeviceNameChanged() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().DeviceInterface().unsubscribe(_deviceNameChangedNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Unsubscribe Device NameChange is success" << endl; + } else { + cout << "Unsubscribe Device NameChange status = " << static_cast(error) << endl; + } +} + +void CoreSDKTest::GetDeviceModel() +{ + Firebolt::Error error = Firebolt::Error::None; + const std::string model = Firebolt::IFireboltAccessor::Instance().DeviceInterface().model(&error); + + if (error == Firebolt::Error::None) { + cout << "Get Device Model = " << model.c_str() << endl; + } else { + cout << "Get Device Model status = " << static_cast(error) << endl; + } +} + +void CoreSDKTest::GetDeviceSku() +{ + Firebolt::Error error = Firebolt::Error::None; + const std::string sku = Firebolt::IFireboltAccessor::Instance().DeviceInterface().sku(&error); + + if (error == Firebolt::Error::None) { + cout << "Get Device Sku = " << sku.c_str() << endl; + } else { + cout << "Get Device Sku status = " << static_cast(error) << endl; + } +} + +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; + const Firebolt::Device::AudioProfiles audioProfiles = Firebolt::IFireboltAccessor::Instance().DeviceInterface().audio(&error); + if (error == Firebolt::Error::None) { + PrintDeviceAudioProfiles(audioProfiles); + } else { + cout << "Get Device AudioProfiles status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::OnAudioChangedNotification::onAudioChanged( const Firebolt::Device::AudioProfiles& audioProfiles ) +{ + cout << "onAudioChanged event " << endl; + PrintDeviceAudioProfiles(audioProfiles); +} +void CoreSDKTest::SubscribeDeviceAudioChanged() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().DeviceInterface().subscribe(_audioChangedNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Subscribe Device Audio Change is success" << endl; + } else { + cout << "Subscribe Device Audio Change status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::UnsubscribeDeviceAudioChanged() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().DeviceInterface().unsubscribe(_audioChangedNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Unsubscribe Device Audio Change is success" << endl; + } else { + cout << "Unsubscribe Device Audio Change status = " << static_cast(error) << endl; + } +} + +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; + const Firebolt::Device::Resolution resolution = Firebolt::IFireboltAccessor::Instance().DeviceInterface().screenResolution(&error); + if (error == Firebolt::Error::None) { + PrintDeviceScreenResolution(resolution); + } else { + cout << "Get Device ScreenResolution status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::OnScreenResolutionChangedNotification::onScreenResolutionChanged( const Firebolt::Device::Resolution& resolution ) +{ + cout << "onScreenResolutionChanged event " << endl; + PrintDeviceScreenResolution(resolution); +} +void CoreSDKTest::SubscribeDeviceScreenResolutionChanged() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().DeviceInterface().subscribe(_screenResolutionChangedNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Subscribe Device ScreenResolution Change is success" << endl; + } else { + cout << "Subscribe Device ScreenResolution Change status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::UnsubscribeDeviceScreenResolutionChanged() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().DeviceInterface().unsubscribe(_screenResolutionChangedNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Unsubscribe Device ScreenResolution Change is success" << endl; + } else { + cout << "Unsubscribe Device ScreenResolution Change status = " << static_cast(error) << endl; + } +} + +void PrintClosedCaptionsSettings( const Firebolt::Accessibility::ClosedCaptionsSettings& closedCaptionsSettings) +{ + cout << "Get Accessibility ClosedCaptionsSettings :-> " << endl; + cout << "ClosedCaptionsSettings::Enabled : " << closedCaptionsSettings.enabled << endl; + if (closedCaptionsSettings.styles.fontFamily.has_value()) { + cout << "ClosedCaptionsSettings::Styles::FontFamily : " << static_cast(closedCaptionsSettings.styles.fontFamily.value()) << endl; + } + if (closedCaptionsSettings.styles.fontSize.has_value()) { + cout << "ClosedCaptionsSettings::Styles::FontSize : " << setprecision(3) << closedCaptionsSettings.styles.fontSize.value() << endl; + } + if (closedCaptionsSettings.styles.fontColor.has_value()) { + cout << "ClosedCaptionsSettings::Styles::FontColor : " << closedCaptionsSettings.styles.fontColor.value() << endl; + } + if (closedCaptionsSettings.styles.fontEdge.has_value()) { + cout << "ClosedCaptionsSettings::Styles::FontEdge : " << static_cast(closedCaptionsSettings.styles.fontEdge.value()) << endl; + } + if (closedCaptionsSettings.styles.fontEdgeColor.has_value()) { + cout << "ClosedCaptionsSettings::Styles::FontEdgeColor : " << closedCaptionsSettings.styles.fontEdgeColor.value() << endl; + } + if (closedCaptionsSettings.styles.fontOpacity.has_value()) { + cout << "ClosedCaptionsSettings::Styles::FontOpacity : " << closedCaptionsSettings.styles.fontOpacity.value() << endl; + } + if (closedCaptionsSettings.styles.backgroundColor.has_value()) { + cout << "ClosedCaptionsSettings::Styles::BackgroundColor : " << closedCaptionsSettings.styles.backgroundColor.value() << endl; + } + if (closedCaptionsSettings.styles.backgroundOpacity.has_value()) { + cout << "ClosedCaptionsSettings::Styles::BackgroundOpacity : " << closedCaptionsSettings.styles.backgroundOpacity.value() << endl; + } + if (closedCaptionsSettings.styles.textAlign.has_value()) { + cout << "ClosedCaptionsSettings::Styles::TextAlign : " << closedCaptionsSettings.styles.textAlign.value() << endl; + } + if (closedCaptionsSettings.styles.textAlignVertical.has_value()) { + cout << "ClosedCaptionsSettings::Styles::TextAlignVertical : " << closedCaptionsSettings.styles.textAlignVertical.value() << endl; + } + if (closedCaptionsSettings.styles.windowColor.has_value()) { + cout << "ClosedCaptionsSettings::Styles::WindowColor : " << closedCaptionsSettings.styles.windowColor.value() << endl; + } + if (closedCaptionsSettings.styles.windowOpacity.has_value()) { + cout << "ClosedCaptionsSettings::Styles::WindowOpacity : " << closedCaptionsSettings.styles.windowOpacity.value() << endl; + } + cout << "ClosedCaptionsSettings::PreferredLanguages :"; + + for (auto index: closedCaptionsSettings.preferredLanguages.value()) { + cout << " " << index; + } + cout << endl; +} +void CoreSDKTest::GetAccessibilityClosedCaptionsSettings() +{ + Firebolt::Error error = Firebolt::Error::None; + const Firebolt::Accessibility::ClosedCaptionsSettings closedCaptionsSettings = Firebolt::IFireboltAccessor::Instance().AccessibilityInterface().closedCaptionsSettings(&error); + if (error == Firebolt::Error::None) { + PrintClosedCaptionsSettings(closedCaptionsSettings); + } else { + cout << "Get Accessibility ClosedCaptionsSettings status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::OnClosedCaptionsSettingsChangedNotification::onClosedCaptionsSettingsChanged( const Firebolt::Accessibility::ClosedCaptionsSettings& closedCaptionsSettings ) +{ + cout << "ClosedCaptionsSettingsChanged event " << endl; + PrintClosedCaptionsSettings(closedCaptionsSettings); +} +void CoreSDKTest::SubscribeAccessibilityClosedCaptionsSettingsChanged() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().AccessibilityInterface().subscribe(_closedCaptionsSettingsChangedNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Subscribe Accessibilty ClosedCaptionSettings Change is success" << endl; + } else { + cout << "Subscribe Accessibilty ClosedCaptionSettings Change status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::UnsubscribeAccessibilityClosedCaptionsSettingsChanged() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().AccessibilityInterface().unsubscribe(_closedCaptionsSettingsChangedNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Unsubscribe Accessibilty ClosedCaptionSettings Change is success" << endl; + } else { + cout << "Unsubscribe Accessibilty ClosedCaptionSettings Change status = " << static_cast(error) << endl; + } +} + +void CoreSDKTest::GetLocalizationAdditionalInfo() +{ + Firebolt::Error error = Firebolt::Error::None; + const Firebolt::Localization::Info info = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().additionalInfo(&error); + + if (error == Firebolt::Error::None) { + cout << "Get Localization AdditionalInfo : " << endl; + for (auto element: info) { + cout << "key : " << element.first << ", value : " << element.second << endl; + } + } else { + cout << "Get Localization AdditionalInfo status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::GetLocalizationLatlon() +{ + Firebolt::Error error = Firebolt::Error::None; + const Firebolt::Localization::LatLon latlon = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().latlon(&error); + + if (error == Firebolt::Error::None) { + 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; + } +} +void CoreSDKTest::GetLocalizationPreferredAudioLanguages() +{ + Firebolt::Error error = Firebolt::Error::None; + const std::vector languages = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().preferredAudioLanguages(&error); + + if (error == Firebolt::Error::None) { + cout << "Get Localization PreferredAudioLanguages : " << endl; + for (auto language: languages) { + cout << "----- > " < " << endl; + for (auto language : languages) { + cout << " -> " << language << endl; + } +} +void CoreSDKTest::SubscribeLocalizationPreferredAudioLanguagesChanged() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().LocalizationInterface().subscribe(_preferredAudioLanguagesChangedNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Subscribe Localization PreferredAudioLanguagesChange is success" << endl; + } else { + cout << "Subscribe Localization PreferredAudioLanguagesChange status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::UnsubscribeLocalizationPreferredAudioLanguagesChanged() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().LocalizationInterface().unsubscribe(_preferredAudioLanguagesChangedNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Unsubscribe Localization PreferredAudioLanguagesChange is success" << endl; + } else { + cout << "Unsubscribe Localization PreferredAudioLanguagesChange status = " << static_cast(error) << endl; + } +} + +void CoreSDKTest::InvokeKeyboardStandard() +{ + Firebolt::Error error = Firebolt::Error::None; + std::string message = "Enter the name you'd like to associate with this device"; + string response = Firebolt::IFireboltAccessor::Instance().KeyboardInterface().standard(message, &error); + if (error == Firebolt::Error::None) { + cout << "Keyboard standard response: " << response << endl; + } else { + cout << "Error while invoking keyboard.standard method, error = " << static_cast(error) << endl; + } +} +void CoreSDKTest::InvokeKeyboardPassword() +{ + Firebolt::Error error = Firebolt::Error::None; + std::string message = "Enter the password to associate with this device"; + string response = Firebolt::IFireboltAccessor::Instance().KeyboardInterface().password(message, &error); + if (error == Firebolt::Error::None) { + cout << "Keyboard password response: " << response << endl; + } else { + cout << "Error while invoking keyboard.password method, error = " << static_cast(error) << endl; + } + +} +void CoreSDKTest::InvokeKeyboardEmail() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::Keyboard::EmailUsage type = Firebolt::Keyboard::EmailUsage::SIGN_IN; + std::string message = "Enter your email to sign into this app/device"; + string response = Firebolt::IFireboltAccessor::Instance().KeyboardInterface().email(type, message, &error); + if (error == Firebolt::Error::None) { + cout << "Keyboard email response: " << response << endl; + } else { + cout << "Error while invoking keyboard.email method, error = " << static_cast(error) << endl; + } +} + +void CoreSDKTest::VerifyProfileApproveContentRating() +{ + Firebolt::Error error = Firebolt::Error::None; + bool allow = Firebolt::IFireboltAccessor::Instance().ProfileInterface().approveContentRating(&error); + if (error == Firebolt::Error::None) { + cout << "Verify Profile ApproveContentRating is success value : " << allow << endl; + } else { + cout << "Verify Profile ApproveContentRating status : " << static_cast(error) << endl; + } +} +void CoreSDKTest::VerifyProfileApprovePurchase() +{ + Firebolt::Error error = Firebolt::Error::None; + bool allow = Firebolt::IFireboltAccessor::Instance().ProfileInterface().approvePurchase(&error); + if (error == Firebolt::Error::None) { + cout << "Verify Profile ApprovePurchase is success value : " << allow << endl; + } else { + cout << "Verify Profile ApprovePurchase status : " << static_cast(error) << endl; + } +} +void CoreSDKTest::GetProfileFlags() +{ + 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; + } + } else { + cout << "Get Profile flags status : " << static_cast(error) << endl; + } +} + +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); + if (error == Firebolt::Error::None) { + cout << "Lifecycle close is success" << endl; + } else { + cout << "Lifecycle close status = " << static_cast(error) << endl; + } +} +EnumMap lifecycleStateMap = { + { Firebolt::Lifecycle::LifecycleState::INITIALIZING, "initializing" }, + { Firebolt::Lifecycle::LifecycleState::INACTIVE, "inactive" }, + { Firebolt::Lifecycle::LifecycleState::FOREGROUND, "foreground" }, + { Firebolt::Lifecycle::LifecycleState::BACKGROUND, "background" }, + { 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) +{ + 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; + } +} +void CoreSDKTest::SubscribeLifecycleBackgroundNotification() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().LifecycleInterface().subscribe(_backgroundNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Subscribe Lifecycle BackgroundNotification is success" << endl; + } else { + cout << "Subscribe Lifecycle BackgroundNotification status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::UnsubscribeLifecycleBackgroundNotification() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().LifecycleInterface().unsubscribe(_backgroundNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Unsubscribe Lifecycle BackgroundNotification is success" << endl; + } else { + cout << "Unsubscribe Lifecycle BackgroundNotification status = " << static_cast(error) << endl; + } +} +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; + } +} +void CoreSDKTest::SubscribeLifecycleForegroundNotification() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().LifecycleInterface().subscribe(_foregroundNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Subscribe Lifecycle ForegroundNotification is success" << endl; + } else { + cout << "Subscribe Lifecycle ForegroundNotification status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::UnsubscribeLifecycleForegroundNotification() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().LifecycleInterface().unsubscribe(_foregroundNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Unsubscribe Lifecycle ForegroundNotification is success" << endl; + } else { + cout << "Unsubscribe Lifecycle ForegroundNotification status = " << static_cast(error) << endl; + } +} + +void CoreSDKTest::GetAuthenticationDevice() +{ + Firebolt::Error error = Firebolt::Error::None; + const std::string device = Firebolt::IFireboltAccessor::Instance().AuthenticationInterface().device(&error); + + 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; + } +} +void CoreSDKTest::GetAuthenticationSession() +{ + Firebolt::Error error = Firebolt::Error::None; + const std::string session = Firebolt::IFireboltAccessor::Instance().AuthenticationInterface().device(&error); + + 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; + } +} +void CoreSDKTest::GetAuthenticationRoot() +{ + Firebolt::Error error = Firebolt::Error::None; + const std::string root = Firebolt::IFireboltAccessor::Instance().AuthenticationInterface().device(&error); + + 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; + } +} +void CoreSDKTest::GetAuthenticationToken() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::Authentication::TokenType type = Firebolt::Authentication::TokenType::DEVICE; + std::optional options; + + const Firebolt::Authentication::Token token = Firebolt::IFireboltAccessor::Instance().AuthenticationInterface().token(type, options, &error); + + if (error == Firebolt::Error::None) { + cout << "Get Authentication of token : " << endl; + cout << "\tvalue: " << token.value.c_str() << endl; + if (token.expires.has_value()) { + cout << "\texpires : " << token.expires.value().c_str() << endl; + } + if (token.type.has_value()) { + cout << "\ttype : " << token.type.value().c_str() << endl; + } + } else { + cout << "Get Authentication of Device status = " << static_cast(error) << endl; + } +} + +EnumMap denyReasonMap = { + { Firebolt::Capabilities::DenyReason::UNPERMITTED, "unpermitted" }, + { Firebolt::Capabilities::DenyReason::UNSUPPORTED, "unsupported" }, + { Firebolt::Capabilities::DenyReason::DISABLED, "disbaled" }, + { Firebolt::Capabilities::DenyReason::UNAVAILABLE, "unavailable" }, + { Firebolt::Capabilities::DenyReason::GRANT_DENIED, "grant_denied" }, + { Firebolt::Capabilities::DenyReason::UNGRANTED, "ungranted" } +}; + +static void PrintCapabilityInfo(const Firebolt::Capabilities::CapabilityInfo& info) +{ + if (info.capability.has_value()) { + cout << "\tcapability : " << info.capability.value() << endl; + } + cout << "\tsupported : " << (info.supported ? "true" : "false") << endl; + cout << "\tavailable : " << (info.available ? "true" : "false") << endl; + if (info.use.permitted.has_value() || info.use.granted.has_value()) { + if (info.use.permitted.has_value()) { + cout << "\tuse.permitted : " << (info.use.permitted.value() ? "true" : "false") << endl; + } + if (info.use.granted.has_value()) { + cout << "\tuse.granted : " << (info.use.granted.value() ? "true" : "false") << endl; + } + } + if (info.manage.permitted.has_value() || info.manage.granted.has_value()) { + if (info.manage.permitted.has_value()) { + cout << "\tmanage.permitted : " << (info.manage.permitted.value() ? "true" : "false") << endl; + } + if (info.manage.granted.has_value()) { + cout << "\tmanage.granted : " << (info.manage.granted.value() ? "true" : "false") << endl; + } + } + if (info.provide.permitted.has_value() || info.provide.granted.has_value()) { + if (info.provide.permitted.has_value()) { + cout << "\tprovide.permitted : " << (info.provide.permitted.value() ? "true" : "false") << endl; + } + if (info.provide.granted.has_value()) { + cout << "\tprovide.granted : " << (info.provide.granted.value() ? "true" : "false") << endl; + } + } + if (info.details.has_value()) { + cout << "\tdetails: " << endl; + for (auto item : info.details.value()) { + cout << "\t\t" << ConvertFromEnum(denyReasonMap, item) << endl; + } + } +} +void CoreSDKTest::GetCapabilitiesAvailable() +{ + Firebolt::Error error = Firebolt::Error::None; + std::string capability = "xrn:firebolt:capability:token:device"; + bool status = Firebolt::IFireboltAccessor::Instance().CapabilitiesInterface().available(capability, &error); + if (error == Firebolt::Error::None) { + cout << "Capabilities Available = " << (status ? "true" : "false") << endl; + } else { + cout << "Capabilities Available status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::SubscribeCapabilitiesAvailableChanged() +{ + Firebolt::Error error = Firebolt::Error::None; + std::string capability = "xrn:firebolt:capability:usergrant:pinchallenge"; + Firebolt::IFireboltAccessor::Instance().CapabilitiesInterface().subscribe(capability, _availableNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Subscribe Capabilities AvailableNotification is success" << endl; + } else { + cout << "Subscribe Capabilities AvailableNotification status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::UnsubscribeCapabilitiesAvailableChanged() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().CapabilitiesInterface().unsubscribe(_availableNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Unsubscribe Capabilities AvailableNotification is success" << endl; + } else { + cout << "Unsubscribe Capabilities AvailableNotification status = " << static_cast(error) << endl; + } +} +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; + std::string capability = "xrn:firebolt:capability:localization:postal-code"; + std::optional options; + bool status = Firebolt::IFireboltAccessor::Instance().CapabilitiesInterface().granted(capability, options, &error); + if (error == Firebolt::Error::None) { + cout << "Capabilities Granted = " << (status ? "true" : "false") << endl; + } else { + cout << "Capabilities Granted status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::GetCapabilitiesPermitted() +{ + Firebolt::Error error = Firebolt::Error::None; + std::string capability = "xrn:firebolt:capability:input:keyboard"; + std::optional options = std::make_optional(); + options.value().role = std::make_optional(); + options.value().role.value() = Firebolt::Capabilities::Role::MANAGE; + bool status = Firebolt::IFireboltAccessor::Instance().CapabilitiesInterface().permitted(capability, options, &error); + if (error == Firebolt::Error::None) { + cout << "Capabilities Permitted = " << (status ? "true" : "false") << endl; + } else { + cout << "Capabilities Permitted status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::GetCapabilitiesSupported() +{ + Firebolt::Error error = Firebolt::Error::None; + std::string capability = "xrn:firebolt:capability:wifi:scan"; + bool status = Firebolt::IFireboltAccessor::Instance().CapabilitiesInterface().supported(capability, &error); + if (error == Firebolt::Error::None) { + cout << "Capabilities Supported = " << (status ? "true" : "false") << endl; + } else { + cout << "Capabilities Supported status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::GetCapabilitiesInfo() +{ + Firebolt::Error error = Firebolt::Error::None; + std::vector capabilities = { "xrn:firebolt:capability:device:model", "xrn:firebolt:capability:input:keyboard", "xrn:firebolt:capability:protocol:bluetoothle", "xrn:firebolt:capability:token:device", "xrn:firebolt:capability:token:platform", "xrn:firebolt:capability:protocol:moca", "xrn:firebolt:capability:wifi:scan", "xrn:firebolt:capability:localization:postal-code", "xrn:firebolt:capability:localization:locality"}; + std::vector info = Firebolt::IFireboltAccessor::Instance().CapabilitiesInterface().info(capabilities, &error); + if (error == Firebolt::Error::None) { + cout << "Capabilities Info : " << endl; + for (auto element : info) { + PrintCapabilityInfo(element); + cout << endl; + } + } else { + cout << "Capabilities Info status = " << static_cast(error) << endl; + } +} + +void CoreSDKTest::MetricsStartContent() +{ + Firebolt::Error error = Firebolt::Error::None; + std::optional entityId; + bool status = Firebolt::IFireboltAccessor::Instance().MetricsInterface().startContent(entityId, &error); + + if (error == Firebolt::Error::None) { + cout << "Metrics Start Content = " << (status ? "true" : "false") << endl; + } else { + cout << "Metrics Start Content status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::MetricsStopContent() +{ + Firebolt::Error error = Firebolt::Error::None; + std::optional entityId; + bool status = Firebolt::IFireboltAccessor::Instance().MetricsInterface().stopContent(entityId, &error); + + if (error == Firebolt::Error::None) { + cout << "Metrics Stop Content = " << (status ? "true" : "false") << endl; + } else { + cout << "Metrics Stop Content status = " << static_cast(error) << endl; + } +} + +void CoreSDKTest::GetSecondScreenDevice() +{ + Firebolt::Error error = Firebolt::Error::None; + std::optional type; + std::string deviceId = Firebolt::IFireboltAccessor::Instance().SecondScreenInterface().device(type, &error); + + if (error == Firebolt::Error::None) { + cout << "Get SecondScreen Device : " << deviceId.c_str() << endl; + } else { + cout << "Get SecondScreen Device status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::GetSecondScreenProtocols() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::Types::BooleanMap map = Firebolt::IFireboltAccessor::Instance().SecondScreenInterface().protocols(&error); + if (error == Firebolt::Error::None) { + cout << "Get SecondScreen Protocols : " << endl; + for (auto element : map) { + cout << element.first << " : " << (element.second ? "true" : "false") << endl; + } + } else { + cout << "Get SecondScreen Protocols status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::GetSecondScreenFriendlyName() +{ + Firebolt::Error error = Firebolt::Error::None; + std::string friendlyName = Firebolt::IFireboltAccessor::Instance().SecondScreenInterface().friendlyName(&error); + + if (error == Firebolt::Error::None) { + cout << "Get SecondScreen FriendlyName : " << friendlyName.c_str() << endl; + } else { + cout << "Get SecondScreen FriendlyName status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::OnFriendlyNameChangedNotification::onFriendlyNameChanged( const std::string& friendlyName) +{ + cout << "OnFriendlyNameChangedNotification friendlyName : " << friendlyName.c_str() << endl; +} +void CoreSDKTest::SubscribeSecondScreenFriendlyNameChanged() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().SecondScreenInterface().subscribe(_friendlyNameChangedNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Subscribe SecondScreen FriendlyNameChangedNotification is success" << endl; + } else { + cout << "Subscribe SecondScreen FriendlyNameChangedNotification status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::UnsubscribeSecondScreenFriendlyNameChanged() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().SecondScreenInterface().unsubscribe(_friendlyNameChangedNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Unsubscribe SecondScreen FriendlyNameChangedNotification is success" << endl; + } else { + cout << "Unsubscribe SecondScreen FriendlyNameChangedNotification status = " << static_cast(error) << endl; + } +} + +EnumMap secondScreenEventTypeMap = { + { Firebolt::SecondScreen::SecondScreenEventType::DIAL, "dial" } +}; +void CoreSDKTest::ParametersInitialization() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::Parameters::AppInitialization appInitialization = Firebolt::IFireboltAccessor::Instance().ParametersInterface().initialization(&error); + if (error == Firebolt::Error::None) { + cout << "Parameters Initialization is success" << endl; + if (appInitialization.us_privacy.has_value()) { + cout << "\tus_privacy : " << appInitialization.us_privacy.value().c_str() << endl; + } + if (appInitialization.lmt.has_value()) { + cout << "\tlmt : " << appInitialization.lmt.value() << endl; + } + if (appInitialization.discovery.has_value()) { + if (appInitialization.discovery.value().navigateTo.has_value()) { + cout << "\tdiscovery:navigateTo : " << appInitialization.discovery.value().navigateTo.value().c_str() << endl; + } + } + 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; + if (event.version.has_value()) { + 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; + } + } + } + } else { + cout << "Parameters Initialization status = " << static_cast(error) << endl; + } +} + +void CoreSDKTest::DiscoverySignIn() +{ + Firebolt::Error error = Firebolt::Error::None; + std::optional> entitlements = std::make_optional>(); + Firebolt::Entertainment::Entitlement entitlement; + entitlement.startTime = "2025-01-01T00:00:00.000Z"; + entitlement.endTime = "2025-01-01T00:00:00.000Z"; + entitlements.value().push_back(entitlement); + + bool status = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().signIn(entitlements, &error); + if (error == Firebolt::Error::None) { + cout << "Discovery SignIn is " << (status ? "true" : "false") << endl; + } else { + cout << "Discovery SignIn status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::DiscoverySignOut() +{ + Firebolt::Error error = Firebolt::Error::None; + bool status = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().signOut(&error); + if (error == Firebolt::Error::None) { + cout << "Discovery SignOut is " << (status ? "true" : "false") << endl; + } else { + cout << "Discovery SignOut status = " << static_cast(error) << endl; + } +} + +void CoreSDKTest::DiscoveryContentAccess() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::Discovery::ContentAccessIdentifiers contentAccessIdentifiers; + contentAccessIdentifiers.availabilities = std::make_optional>(); + Firebolt::Discovery::Availability availability; + availability.type = Firebolt::Discovery::AvailabilityType::CHANNEL_LINEUP; + availability.id = "partner.com/availability/123"; + availability.startTime = "2021-04-23T18:25:43.511Z"; + availability.endTime = "2021-04-23T18:25:43.511Z"; + contentAccessIdentifiers.availabilities.value().push_back(availability); + + contentAccessIdentifiers.entitlements = std::make_optional>(); + Firebolt::Entertainment::Entitlement entitlement; + entitlement.startTime = "2025-01-01T00:00:00.000Z"; + entitlement.endTime = "2025-01-01T00:00:00.000Z"; + contentAccessIdentifiers.entitlements.value().push_back(entitlement); + + Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().contentAccess(contentAccessIdentifiers, &error); + if (error == Firebolt::Error::None) { + cout << "Discovery ContentAccess is success" << endl; + } else { + cout << "Discovery ContentAccess status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::DiscoveryClearContentAccess() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().clearContentAccess(&error); + if (error == Firebolt::Error::None) { + cout << "Discovery ClearContentAccess is success" << endl; + } else { + cout << "Discovery ClearContentAccess status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::DiscoveryEntitlements() +{ + Firebolt::Error error = Firebolt::Error::None; + std::vector entitlements; + Firebolt::Entertainment::Entitlement entitlement; + entitlement.startTime = "2025-01-01T00:00:00.000Z"; + entitlement.endTime = "2025-01-01T00:00:00.000Z"; + entitlements.push_back(entitlement); + + bool status = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().entitlements(entitlements, &error); + if (error == Firebolt::Error::None) { + cout << "Discovery Entitlements is " << (status ? "true" : "false") << endl; + } else { + cout << "Discovery Entitlements status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::DiscoveryWatchNext() +{ + Firebolt::Error error = Firebolt::Error::None; + std::string title = "A Cool Show"; + Firebolt::Entertainment::ContentIdentifiers identifiers; + identifiers.entityId = "partner.com/entity/123"; + std::optional expires = "2021-04-23T18:25:43.511Z"; + std::optional images = std::make_optional(); + images = "{\"3x4\": {\"en-US\": \"https://i.ytimg.com/vi/4r7wHMg5Yjg/maxresdefault.jpg\", \"es\": \"https://i.ytimg.com/vi/4r7wHMg5Yjg/maxresdefault.jpg\"}, \"16x9\": {\"en\": \"https://i.ytimg.com/vi/4r7wHMg5Yjg/maxresdefault.jpg\"}}"; + + bool status = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().watchNext(title, identifiers, expires, images, &error); + if (error == Firebolt::Error::None) { + cout << "Discovery Watched Next is " << (status ? "true" : "false") << endl; + } else { + cout << "Discovery Watched Next status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::DiscoveryPolicy() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::Discovery::DiscoveryPolicy policy = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().policy(&error); + if (error == Firebolt::Error::None) { + cout << "Discovery Policy is " << endl; + cout << "\tenableRecommendations: " << policy.enableRecommendations << endl; + cout << "\tshareWatchHistory: " << policy.shareWatchHistory << endl; + cout << "\trememberWatchedPrograms: " << policy.rememberWatchedPrograms << endl; + } else { + cout << "Discovery Policy status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::DiscoveryEntityInfo() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::Discovery::EntityInfoResult result; + result.expires = "2025-01-01T00:00:00.000Z"; + { + result.entity.identifiers.entityId = "345"; + result.entity.title = "Cool Running"; + result.entity.entityType = "program"; + result.entity.programType = Firebolt::Entertainment::ProgramType::MOVIE; + result.entity.synopsis = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pulvinar sapien et ligula ullamcorper malesuada proin libero nunc."; + result.entity.releaseDate = "1993-01-01T00:00:00.000Z"; + result.entity.contentRatings = std::make_optional>(); + { + Firebolt::Entertainment::ContentRating contentRating; + contentRating.scheme = Firebolt::Entertainment::ContentRatingScheme::US_MOVIE; + contentRating.rating = "PG"; + result.entity.contentRatings.value().push_back(contentRating); + } + { + Firebolt::Entertainment::ContentRating contentRating; + contentRating.scheme = Firebolt::Entertainment::ContentRatingScheme::CA_MOVIE; + contentRating.rating = "G"; + result.entity.contentRatings.value().push_back(contentRating); + } + + Firebolt::Entertainment::WayToWatch wayToWatch; + result.entity.waysToWatch = std::make_optional>(); + wayToWatch.identifiers.assetId = "123"; + wayToWatch.expires = "2025-01-01T00:00:00.000Z"; + wayToWatch.entitled = true; + wayToWatch.entitledExpires = "2025-01-01T00:00:00.000Z"; + wayToWatch.offeringType = Firebolt::Entertainment::OfferingType::BUY; + wayToWatch.price = 2.99; + wayToWatch.videoQuality = std::make_optional>(); + wayToWatch.videoQuality.value().push_back(Firebolt::Entertainment::WayToWatchVideoQuality::UHD); + wayToWatch.audioProfile.push_back(Firebolt::Types::AudioProfile::DOLBY_ATMOS); + wayToWatch.audioLanguages = std::make_optional>(); + wayToWatch.audioLanguages.value().push_back("en"); + wayToWatch.closedCaptions = std::make_optional>(); + wayToWatch.closedCaptions.value().push_back("en"); + wayToWatch.subtitles = std::make_optional>(); + wayToWatch.subtitles.value().push_back("es"); + wayToWatch.audioDescriptions = std::make_optional>(); + wayToWatch.audioDescriptions.value().push_back("en"); + result.entity.waysToWatch.value().push_back(wayToWatch); + } + { + result.related = std::make_optional>(); + Firebolt::Entertainment::EntityInfo entityInfo; + entityInfo.identifiers.entityId = "345"; + entityInfo.title = "Cool Runnings Trailer"; + entityInfo.entityType = "program"; + entityInfo.programType = Firebolt::Entertainment::ProgramType::PREVIEW; + entityInfo.releaseDate = "1993-01-01T00:00:00.000Z"; + entityInfo.waysToWatch = std::make_optional>(); + Firebolt::Entertainment::WayToWatch wayToWatch; + wayToWatch.identifiers.assetId = "123111"; + wayToWatch.identifiers.entityId = "345"; + wayToWatch.expires = "2026-01-01T00:00:00.000Z"; + wayToWatch.entitled = true; + wayToWatch.videoQuality = std::make_optional>(); + wayToWatch.videoQuality.value().push_back(Firebolt::Entertainment::WayToWatchVideoQuality::HD); + wayToWatch.audioProfile.push_back(Firebolt::Types::AudioProfile::DOLBY_ATMOS); + wayToWatch.audioLanguages = std::make_optional>(); + wayToWatch.audioLanguages.value().push_back("en"); + wayToWatch.closedCaptions = std::make_optional>(); + wayToWatch.closedCaptions.value().push_back("en"); + entityInfo.waysToWatch.value().push_back(wayToWatch); + result.related.value().push_back(entityInfo); + } + + bool status = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().entityInfo(result, &error); + if (error == Firebolt::Error::None) { + cout << "Discovery EntityInfo is " << (status ? "true" : "false") << endl; + } else { + cout << "Discovery EntityInfo status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::DiscoveryPurchasedContent() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::Discovery::PurchasedContentResult result; + result.expires = "2025-01-01T00:00:00.000Z"; + result.totalCount = 10; + Firebolt::Entertainment::EntityInfo entityInfo; + entityInfo.identifiers.entityId = "345"; + entityInfo.title = "Cool Runnings"; + entityInfo.entityType = "program"; + entityInfo.programType = Firebolt::Entertainment::ProgramType::MOVIE; + entityInfo.synopsis = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pulvinar sapien et ligula ullamcorper malesuada proin libero nunc."; + entityInfo.releaseDate = "1993-01-01T00:00:00.000Z"; + entityInfo.contentRatings = std::make_optional>(); + { + Firebolt::Entertainment::ContentRating contentRating; + contentRating.scheme = Firebolt::Entertainment::ContentRatingScheme::US_MOVIE; + contentRating.rating = "PG"; + entityInfo.contentRatings.value().push_back(contentRating); + } + { + Firebolt::Entertainment::ContentRating contentRating; + contentRating.scheme = Firebolt::Entertainment::ContentRatingScheme::CA_TV; + contentRating.rating = "TV-PG"; + entityInfo.contentRatings.value().push_back(contentRating); + } + + Firebolt::Entertainment::WayToWatch wayToWatch; + entityInfo.waysToWatch = std::make_optional>(); + wayToWatch.identifiers.assetId = "123"; + wayToWatch.expires = "2025-01-01T00:00:00.000Z"; + wayToWatch.entitled = true; + wayToWatch.entitledExpires = "2025-01-01T00:00:00.000Z"; + wayToWatch.offeringType = Firebolt::Entertainment::OfferingType::BUY; + wayToWatch.price = 2.99; + wayToWatch.videoQuality = std::make_optional>(); + wayToWatch.videoQuality.value().push_back(Firebolt::Entertainment::WayToWatchVideoQuality::UHD); + wayToWatch.audioProfile.push_back(Firebolt::Types::AudioProfile::DOLBY_ATMOS); + wayToWatch.audioLanguages = std::make_optional>(); + wayToWatch.audioLanguages.value().push_back("en"); + wayToWatch.closedCaptions = std::make_optional>(); + wayToWatch.closedCaptions.value().push_back("en"); + wayToWatch.subtitles = std::make_optional>(); + wayToWatch.subtitles.value().push_back("es"); + wayToWatch.audioDescriptions = std::make_optional>(); + wayToWatch.audioDescriptions.value().push_back("en"); + entityInfo.waysToWatch.value().push_back(wayToWatch); + result.entries.push_back(entityInfo); + + bool status = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().purchasedContent(result, &error); + if (error == Firebolt::Error::None) { + cout << "Discovery PurchasedContent is " << (status ? "true" : "false") << endl; + } else { + cout << "Discovery PurchasedContent status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::DiscoveryLaunch() +{ + Firebolt::Error error = Firebolt::Error::None; + cout << "Enter appId :"; + getchar(); + std::string appId; + getline(cin, appId); + { + std::optional intent = std::make_optional(); + intent.value().action = "tune"; + intent.value().data.entity.entityType = "channel"; + intent.value().data.entity.channelType = Firebolt::Intents::ChannelEntityChannelType::STREAMING; + intent.value().data.entity.entityId = "an-ott-channel"; + std::string entityId; + std::optional appContentData; + intent.value().data.options = std::make_optional(); + intent.value().data.options.value().restartCurrentProgram = true; + intent.value().context.source = Firebolt::Intents::IntentContextSource::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::optional intent = std::make_optional(); + intent.value().action = "entity"; + intent.value().context.source = Firebolt::Intents::IntentContextSource::VOICE; + intent.value().data = "{\"entityId\":\"example-movie-id\",\"entityType\":\"program\",\"programType\":\"movie\"}"; + intent.value().context.source = Firebolt::Intents::IntentContextSource::VOICE; + cout << "Calling Discovery Launch EntityIntent method " << endl; + bool status = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().launch(appId, intent, &error); + 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::optional intent = std::make_optional(); + intent.value().action = "home"; + intent.value().context.source = Firebolt::Intents::IntentContextSource::VOICE; + cout << "Calling Discovery Launch HomeIntent method " << endl; + bool status = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().launch(appId, intent, &error); + if (error == Firebolt::Error::None) { + cout << "Discovery Launch HomeIntent is " << (status ? "true" : "false") << endl; + } else { + cout << "Discovery Launch HomeIntent status = " << static_cast(error) << endl; + } + } + cin.putback('\n'); +} +#ifdef POLYMORPHICS_REDUCER_METHODS +void CoreSDKTest::DiscoveryWatched() +{ + Firebolt::Error error = Firebolt::Error::None; + std::string entityId = "partner.com/entity/123"; + std::optional progress = 0.95; + std::optional completed = true; + std::optional watchedOn = "2021-04-23T18:25:43.511Z"; + + bool status = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().watched(entityId, progress, completed, watchedOn, &error); + if (error == Firebolt::Error::None) { + cout << "Discovery Watched is " << (status ? "true" : "false") << endl; + } else { + cout << "Discovery Watched status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::DiscoveryWatchedReduced() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::Discovery::WatchedInfo watchedInfo; + watchedInfo.entityId = "partner.com/entity/123"; + watchedInfo.progress = 0.95; + watchedInfo.completed = true; + watchedInfo.watchedOn = "2021-04-23T18:25:43.511Z"; + std::vector watchedInfoList; + watchedInfoList.push_back(watchedInfo); + + bool status = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().watched(watchedInfoList, &error); + if (error == Firebolt::Error::None) { + cout << "Discovery Watched Reduced is " << (status ? "true" : "false") << endl; + } else { + cout << "Discovery Watched Reduced status = " << static_cast(error) << endl; + } +} +#endif +void CoreSDKTest::SubscribeDiscoveryOnNavigateToLaunchNotification() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().subscribe(_navigateToHomeIntentNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Subscribe Discovery OnNavigateToLaunch HomeIntent is success" << endl; + } else { + cout << "Subscribe Discovery OnNavigateToLaunch HomeIntent status = " << static_cast(error) << endl; + } + + error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().subscribe(_navigateToEntityIntentNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Subscribe Discovery OnNavigateToLaunch EntityIntent is success" << endl; + } else { + cout << "Subscribe Discovery OnNavigateToLaunch EntityIntent status = " << static_cast(error) << endl; + } + + error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().subscribe(_navigateToTuneIntentNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Subscribe Discovery OnNavigateToLaunch TuneIntent is success" << endl; + } else { + cout << "Subscribe Discovery OnNavigateToLaunch TuneIntent status = " << static_cast(error) << endl; + } +} +void CoreSDKTest::UnsubscribeDiscoveryOnNavigateToLaunchNotification() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().unsubscribe(_navigateToHomeIntentNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Unsubscribe Discovery OnNavigateToLaunch HomeIntent is success" << endl; + } else { + cout << "Unsubscribe Discovery OnNavigateToLaunch HomeIntent status = " << static_cast(error) << endl; + } + + error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().unsubscribe(_navigateToEntityIntentNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Unsubscribe Discovery OnNavigateToLaunch EntityIntent is success" << endl; + } else { + cout << "Unsubscribe Discovery OnNavigateToLaunch EntityIntent status = " << static_cast(error) << endl; + } + + error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().unsubscribe(_navigateToTuneIntentNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Unsubscribe Discovery OnNavigateToLaunch TuneIntent is success" << endl; + } else { + cout << "Unsubscribe Discovery OnNavigateToLaunch TuneIntent status = " << static_cast(error) << endl; + } +} +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) +{ + cout << "onNavigateTo for action : " << intent.action << endl; +} +void CoreSDKTest::OnNavigateToTuneIntentNotification::onNavigateTo( const Firebolt::Intents::TuneIntent& intent) +{ + cout << "onNavigateTo for action : " << intent.action << endl; +} diff --git a/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h b/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h new file mode 100644 index 000000000..7cb29a930 --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h @@ -0,0 +1,187 @@ +/* + * Copyright 2023 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include +#include "firebolt.h" + +class CoreSDKTest { + class OnPolicyChangedNotification : public Firebolt::Advertising::IAdvertising::IOnPolicyChangedNotification { + public: + void onPolicyChanged( const Firebolt::Advertising::AdPolicy& ) override; + }; + class OnDeviceNameChangedNotification : public Firebolt::Device::IDevice::IOnDeviceNameChangedNotification { + public: + void onDeviceNameChanged( const std::string& ) override; + }; + class OnAudioChangedNotification : public Firebolt::Device::IDevice::IOnAudioChangedNotification { + public: + void onAudioChanged( const Firebolt::Device::AudioProfiles& ) override; + }; + class OnScreenResolutionChangedNotification : public Firebolt::Device::IDevice::IOnScreenResolutionChangedNotification { + public: + void onScreenResolutionChanged( const Firebolt::Device::Resolution& ) override; + }; + class OnPreferredAudioLanguagesChangedNotification : public Firebolt::Localization::ILocalization::IOnPreferredAudioLanguagesChangedNotification { + public: + void onPreferredAudioLanguagesChanged( const std::vector& ) override; + }; + struct OnClosedCaptionsSettingsChangedNotification : public Firebolt::Accessibility::IAccessibility::IOnClosedCaptionsSettingsChangedNotification { + void onClosedCaptionsSettingsChanged( const Firebolt::Accessibility::ClosedCaptionsSettings& ) override; + }; + + struct OnBackgroundNotification : public Firebolt::Lifecycle::ILifecycle::IOnBackgroundNotification { + void onBackground( const Firebolt::Lifecycle::LifecycleEvent& ) override; + }; + struct OnForegroundNotification : public Firebolt::Lifecycle::ILifecycle::IOnForegroundNotification { + void onForeground( const Firebolt::Lifecycle::LifecycleEvent& ) override; + }; + + struct OnFriendlyNameChangedNotification : public Firebolt::SecondScreen::ISecondScreen::IOnFriendlyNameChangedNotification { + void onFriendlyNameChanged( const std::string& ) override; + }; + + struct OnAvailableNotification : public Firebolt::Capabilities::ICapabilities::IOnAvailableNotification { + void onAvailable( const Firebolt::Capabilities::CapabilityInfo& ) override; + }; + + struct OnNavigateToHomeIntentNotification : public Firebolt::Discovery::IDiscovery::IOnNavigateToHomeIntentNotification { + void onNavigateTo( const Firebolt::Intents::HomeIntent& ) override; + }; + struct OnNavigateToEntityIntentNotification : public Firebolt::Discovery::IDiscovery::IOnNavigateToEntityIntentNotification { + void onNavigateTo( const Firebolt::Intents::EntityIntent& ) override; + }; + struct OnNavigateToTuneIntentNotification : public Firebolt::Discovery::IDiscovery::IOnNavigateToTuneIntentNotification { + void onNavigateTo( const Firebolt::Intents::TuneIntent& ) override; + }; + +public: + CoreSDKTest() = default; + virtual ~CoreSDKTest() = default; + + static void CreateFireboltInstance(const std::string& url); + static void DestroyFireboltInstance(); + static void TestCoreStaticSDK(); + + static void GetAccountId(); + static void GetAccountUid(); + + static void GetDeviceName(); + static void SubscribeDeviceNameChanged(); + static void UnsubscribeDeviceNameChanged(); + static void GetDeviceModel(); + static void GetDeviceSku(); + static void GetDeviceAudio(); + static void SubscribeDeviceAudioChanged(); + static void UnsubscribeDeviceAudioChanged(); + static void GetDeviceScreenResolution(); + static void SubscribeDeviceScreenResolutionChanged(); + static void UnsubscribeDeviceScreenResolutionChanged(); + + static void GetLocalizationAdditionalInfo(); + static void GetLocalizationLatlon(); + static void GetLocalizationPreferredAudioLanguages(); + static void SubscribeLocalizationPreferredAudioLanguagesChanged(); + static void UnsubscribeLocalizationPreferredAudioLanguagesChanged(); + + static void GetAccessibilityClosedCaptionsSettings(); + static void SubscribeAccessibilityClosedCaptionsSettingsChanged(); + static void UnsubscribeAccessibilityClosedCaptionsSettingsChanged(); + + static void GetAdvertisingPolicy(); + static void SubscribeAdvertisingPolicyChanged(); + static void UnsubscribeAdvertisingPolicyChanged(); + static void BuildAdvertisingConfiguration(); + static void GetAdvertisingDeviceAttributes(); + + static void InvokeKeyboardStandard(); + static void InvokeKeyboardPassword(); + static void InvokeKeyboardEmail(); + + static void VerifyProfileApproveContentRating(); + static void VerifyProfileApprovePurchase(); + static void GetProfileFlags(); + + static void LifecycleClose(); + static void SubscribeLifecycleBackgroundNotification(); + static void UnsubscribeLifecycleBackgroundNotification(); + static void SubscribeLifecycleForegroundNotification(); + static void UnsubscribeLifecycleForegroundNotification(); + + static void GetAuthenticationDevice(); + static void GetAuthenticationSession(); + static void GetAuthenticationToken(); + static void GetAuthenticationRoot(); + + static void GetCapabilitiesSupported(); + static void GetCapabilitiesAvailable(); + static void GetCapabilitiesGranted(); + static void GetCapabilitiesPermitted(); + static void GetCapabilitiesInfo(); + static void SubscribeCapabilitiesAvailableChanged(); + static void UnsubscribeCapabilitiesAvailableChanged(); + + static void MetricsStartContent(); + static void MetricsStopContent(); + + static void GetSecondScreenDevice(); + static void GetSecondScreenProtocols(); + static void GetSecondScreenFriendlyName(); + static void SubscribeSecondScreenFriendlyNameChanged(); + static void UnsubscribeSecondScreenFriendlyNameChanged(); + + static void DiscoverySignIn(); + static void DiscoverySignOut(); + static void DiscoveryContentAccess(); + static void DiscoveryClearContentAccess(); + static void DiscoveryEntitlements(); + static void DiscoveryEntityInfo(); + static void DiscoveryPolicy(); + static void DiscoveryPurchasedContent(); + static void DiscoveryLaunch(); +#ifdef POLYMORPHICS_REDUCER_METHODS + static void DiscoveryWatched(); + static void DiscoveryWatchedReduced(); +#endif + static void SubscribeDiscoveryOnNavigateToLaunchNotification(); + static void UnsubscribeDiscoveryOnNavigateToLaunchNotification(); + static void DiscoveryWatchNext(); + + static void ParametersInitialization(); + + static bool WaitOnConnectionReady(); + +private: + static void ConnectionChanged(const bool, const Firebolt::Error); + static bool _connected; + static OnPolicyChangedNotification _policyChangedNotification; + static OnDeviceNameChangedNotification _deviceNameChangedNotification; + static OnAudioChangedNotification _audioChangedNotification; + static OnScreenResolutionChangedNotification _screenResolutionChangedNotification; + static OnPreferredAudioLanguagesChangedNotification _preferredAudioLanguagesChangedNotification; + static OnClosedCaptionsSettingsChangedNotification _closedCaptionsSettingsChangedNotification; + static OnBackgroundNotification _backgroundNotification; + static OnForegroundNotification _foregroundNotification; + static OnFriendlyNameChangedNotification _friendlyNameChangedNotification; + static OnAvailableNotification _availableNotification; + static OnNavigateToHomeIntentNotification _navigateToHomeIntentNotification; + static OnNavigateToEntityIntentNotification _navigateToEntityIntentNotification; + static OnNavigateToTuneIntentNotification _navigateToTuneIntentNotification; +}; + diff --git a/src/sdks/core/src/cpp/sdk/cpptest/Main.cpp b/src/sdks/core/src/cpp/sdk/cpptest/Main.cpp new file mode 100644 index 000000000..dcd9c7ee7 --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/cpptest/Main.cpp @@ -0,0 +1,639 @@ +#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" + "\tL : Launch\n" +#ifdef POLYMORPHICS_REDUCER_METHODS + "\tW : Watched\n" + "\tR : WatchedReduced\n" +#endif + "\tB : Subscribe/Unsubscribe DiscoveryOnNavigateToLaunch\n" + "\tQ : Quit\n"); +} + +void ShowKeyboardMenu() +{ + printf("Enter\n" + "\tE : Invoke Email method\n" + "\tP : Invoke Password method\n" + "\tS : Invoke 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'); +} + +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'); +} + +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 '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 'P': { + CoreSDKTest::InvokeKeyboardPassword(); + break; + } + case 'S': { + CoreSDKTest::InvokeKeyboardStandard(); + break; + } + default: + break; + } + } while (opt != 'Q'); +} + +#define options ":hu:" +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) + { + case 'u': + url = optarg; + break; + + case 'h': + 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"); + } + + CoreSDKTest::DestroyFireboltInstance(); + + return 0; +} diff --git a/src/sdks/core/src/cpp/sdk/ctest/build.sh b/src/sdks/core/src/cpp/sdk/cpptest/build.sh similarity index 94% rename from src/sdks/core/src/cpp/sdk/ctest/build.sh rename to src/sdks/core/src/cpp/sdk/cpptest/build.sh index 4db39cbe8..b404a78f3 100755 --- a/src/sdks/core/src/cpp/sdk/ctest/build.sh +++ b/src/sdks/core/src/cpp/sdk/cpptest/build.sh @@ -37,4 +37,5 @@ echo "${TestPath}" echo "FireboltPath" echo ${FireboltPath} cmake -B${TestPath}/build -S${TestPath} -DSYSROOT_PATH=${SysrootPath} -DFIREBOLT_PATH=${FireboltPath} +# -DPOLYMORPHICS_METHODS=ON // Enable this to test cmake --build ${TestPath}/build diff --git a/src/sdks/core/src/cpp/sdk/ctest/main.c b/src/sdks/core/src/cpp/sdk/ctest/main.c deleted file mode 100644 index 6e6dbf020..000000000 --- a/src/sdks/core/src/cpp/sdk/ctest/main.c +++ /dev/null @@ -1,470 +0,0 @@ -#include -#include -#include - -#include "firebolt.h" -#include "accessibility.h" -#include "account.h" -#include "advertising.h" -#include "device.h" -#include "discovery.h" -#include "common/entertainment.h" - -void ShowMenu() -{ - printf("Enter\n" - "\tI : Get Device ID\n" - "\tC : Get Closed Caption Settings\n" - "\tG : Get Voice Guidance Settings\n" - "\tP : Get Advertising Policy\n" - "\tU : Get Account UID\n" - "\tE : Push EntityInfo\n" - "\tN : Register/Unregister for Device Name change\n" - "\tR : Register/Unregister for Screen Resolution change\n" - "\tA : Register/Unregister for Accessibilty Voice Guidance change\n" - "\tH : Register/Unregister for OnNavigateTo:HomeIntent\n" - "\tS : Register/Unregister for OnNavigateTo:SearchIntent\n" - "\tQ : Quit\n\n" - ); -} - -void ShowEventMenu() -{ - printf("Enter\n" - "\tR: Register Event\n" - "\tU: Unregister Event\n" - "\tQ : Quit\n"); -} - -#define HandleEventListener(Module, eventFuncName, Callback, eventTestStr, eventName) \ -{ \ - int opt; \ - do { \ - getchar(); \ - ShowEventMenu(); \ - printf("Enter option : "); \ - opt = toupper(getchar()); \ - switch (opt) { \ - case 'R': { \ - int32_t result = Module##_Register_On##eventFuncName((const void*)Callback, eventTestStr); \ - if (result != FireboltSDKErrorNone) { \ - printf("Register event %s is failed, status = %d \n", eventName, result); \ - } else { \ - printf("Event %s is registered successfully\n", eventName); \ - } \ - break; \ - } \ - case 'U': { \ - int32_t result = Module##_Unregister_On##eventFuncName((const void*)Callback); \ - if (result != FireboltSDKErrorNone) { \ - printf("Unregister event %s is failed, status = %d \n", eventName, result); \ - } else { \ - printf("Event %s is unregistered successfully\n", eventName); \ - } \ - break; \ - } \ - default: \ - break; \ - } \ - } while (opt != 'Q'); \ -} - -const char* get_skiprestriction_enum_string(Advertising_SkipRestriction skipRestriction) -{ - char* strSkipRestriction; - switch(skipRestriction) { - case ADVERTISING_SKIPRESTRICTION_NONE: - strSkipRestriction = "None"; - break; - case ADVERTISING_SKIPRESTRICTION_ADS_UNWATCHED: - strSkipRestriction = "AdsUnwatched"; - break; - case ADVERTISING_SKIPRESTRICTION_ADS_ALL: - strSkipRestriction = "AdsAll"; - break; - case ADVERTISING_SKIPRESTRICTION_ALL: - strSkipRestriction = "All"; - break; - default: - strSkipRestriction = "None"; - break; - } - return strSkipRestriction; -} - -static const char deviceNameTestStr[] = "DeviceNameTestStr"; -static void NotifyDeviceNameChange(const void* userData, Firebolt_String_t handle) -{ - if (handle) { - printf("Got new device.name :%s\n", Firebolt_String(handle)); - Firebolt_String_Release(handle); - } else { - printf("device.name event handle is not valid\n"); - } -} - -static const char deviceScreenResolutionTestStr[] = "deviceScreenResolutionTestStr"; -static void NotifyDeviceScreenResolutionChange(const void* userData, Device_ResolutionArray_t handle) -{ - if (Device_ResolutionArray_IsValid(handle) == true) { - uint32_t size = Device_ResolutionArray_Size(handle); - printf("Device ScreenResolutions changed for %d numbers\n", size); - for (uint32_t i = 0; i < size; ++i) { - printf("New reslution[%d] = %d\n", i, Device_ResolutionArray_Get(handle, i)); - } - Device_ResolutionArray_Release(handle); - } else { - printf("device.screenresolution event handle is not valid\n"); - } -} - -static const char accessibilityVoiceGuidanceTestStr[] = "AccessibilityVoiceGuidanceTestStr"; -static void NotifyAccessibilityVoiceGuidanceChange(const void* userData, Accessibility_VoiceGuidanceSettings_t handle) -{ - if (Accessibility_VoiceGuidanceSettings_IsValid(handle) == true) { - bool enabled = Accessibility_VoiceGuidanceSettings_Get_Enabled(handle); - uint32_t speed = Accessibility_VoiceGuidanceSettings_Get_Speed(handle); - printf("VoiceGuidanceSettings: Enabled : %d, Speed : %d\n", enabled, speed); - Accessibility_VoiceGuidanceSettings_Release(handle); - } else { - printf("accessibility.voiceguidance event handle is not valid\n"); - } -} - -static const char discoveryHomeIntentTestStr[] = "DiscoveryHomeIntentTestStr"; -static void NotifyOnNavigateToHomeIntent(const void* userData, Intents_HomeIntent_t handle) -{ - if (Intents_HomeIntent_IsValid(handle) == true) { - char* action = Intents_HomeIntent_Get_Action(handle); - printf("NavigateToHomeIntent: Action: %s\n", action); - Intents_HomeIntent_Release(handle); - } else { - printf("discovery.onNavigateToChanged HomeIntent event handle is not valid\n"); - } -} - -static const char discoverySearchIntentTestStr[] = "DiscoverySearchIntentTestStr"; -static void NotifyOnNavigateToSearchIntent(const void* userData, Intents_SearchIntent_t handle) -{ - if (Intents_SearchIntent_IsValid(handle) == true) { - char* action = Intents_SearchIntent_Get_Action(handle); - printf("NavigateToSearchIntent: Action: %s\n", action); - Intents_SearchIntent_Release(handle); - } else { - printf("discovery.onNavigateTo LauncIntent event handle is not valid\n"); - } -} - -int main (int argc, char* argv[]) -{ - char* config = "{\ - \"waitTime\": 1000,\ - \"logLevel\": \"Info\",\ - \"workerPool\":{\ - \"queueSize\": 8,\ - \"threadCount\": 3\ - },\ - \"wsUrl\": \"ws://127.0.0.1:9998\"\ -}"; - - printf("Firebolt Core SDK Test\n"); - - //Intitialize the SDK - FireboltSDK_Initialize(config); - int option; - - do { - ShowMenu(); - printf("Enter option : "); - option = toupper(getchar()); - switch (option) { - case 'I': { - //Lets get the Device ID - Firebolt_String_t handle; - int32_t result = Device_GetId(&handle); - if (result == FireboltSDKErrorNone) { - printf("Device: Id:%s\n\n", Firebolt_String(handle)); - Firebolt_String_Release(handle); - handle = NULL; - } else { - printf("Failed to get Device ID\n\n"); - } - break; - } - case 'C': { - Accessibility_ClosedCaptionsSettings_t handle; - int32_t result = Accessibility_GetClosedCaptionsSettings(&handle); - - if (result == FireboltSDKErrorNone) { - if (Accessibility_ClosedCaptionsSettings_IsValid(handle) == true) { - printf("ClosedCaption Settings ------------------\n"); - Accessibility_ClosedCaptionsStyles_t styleHandle = Accessibility_ClosedCaptionsSettings_Get_Styles(handle); - if (Accessibility_ClosedCaptionsStyles_IsValid(styleHandle)) { - printf("ClosedCaptionStyles:\n"); - char* fontFamily = Accessibility_ClosedCaptionsStyles_Get_FontFamily(styleHandle); - printf("\tFontFamily : %s\n", fontFamily); - uint32_t fontSize = Accessibility_ClosedCaptionsStyles_Get_FontSize(styleHandle); - printf("\tFontSize : %d\n", fontSize); - char* fontColor = Accessibility_ClosedCaptionsStyles_Get_FontColor(styleHandle); - printf("\tFontColor : %s\n", fontColor); - char* fontEdge = Accessibility_ClosedCaptionsStyles_Get_FontEdge(styleHandle); - printf("\tFontEdge : %s\n", fontEdge); - char* fontEdgeColor = Accessibility_ClosedCaptionsStyles_Get_FontEdgeColor(styleHandle); - printf("\tFontEdgeColor : %s\n", fontEdgeColor); - uint32_t fontOpacity = Accessibility_ClosedCaptionsStyles_Get_FontOpacity(styleHandle); - printf("\tFontOpacity : %d\n", fontOpacity); - char* bgColor = Accessibility_ClosedCaptionsStyles_Get_BackgroundColor(styleHandle); - printf("\tBackgroundColor : %s\n", bgColor); - uint32_t bgOpacity = Accessibility_ClosedCaptionsStyles_Get_BackgroundOpacity(styleHandle); - printf("\tBackgroundOpacity : %d\n", bgOpacity); - char* txAlign = Accessibility_ClosedCaptionsStyles_Get_TextAlign(styleHandle); - printf("\tTextAlign : %s\n", txAlign); - char* txAlignVertical = Accessibility_ClosedCaptionsStyles_Get_TextAlignVertical(styleHandle); - printf("\tTextAlignVertical : %s\n", txAlignVertical); - Accessibility_ClosedCaptionsStyles_Release(styleHandle); - } - bool enabled = Accessibility_ClosedCaptionsSettings_Get_Enabled(handle); - printf("Enabled: %d\n\n", enabled); - Accessibility_ClosedCaptionsSettings_Release(handle); - } else { - printf("Invalid ClosedCaptionsSettings_t\n\n"); - } - } else { - printf("Failed to get Closed Caption Settings\n\n"); - } - break; - } - case 'G': { - Accessibility_VoiceGuidanceSettings_t handle; - int32_t result = Accessibility_GetVoiceGuidanceSettings(&handle); - - if (result == FireboltSDKErrorNone) { - if (Accessibility_VoiceGuidanceSettings_IsValid(handle) == true) { - bool enabled = Accessibility_VoiceGuidanceSettings_Get_Enabled(handle); - uint32_t speed = Accessibility_VoiceGuidanceSettings_Get_Speed(handle); - printf("VoiceGuidanceSettings: Enabled : %d, Speed : %d\n", enabled, speed); - Accessibility_VoiceGuidanceSettings_Release(handle); - } else { - printf("Invalid VoiceGuidanceSettings_t\n\n"); - } - } else { - printf("Failed to get Voice Guidance Settings\n\n"); - } - break; - } - case 'P': { - Advertising_AdPolicy_t handle; - int32_t result = Advertising_GetPolicy(&handle); - if (result == FireboltSDKErrorNone) { - if (Advertising_AdPolicy_IsValid(handle) == true) { - printf("AdPolicy: "); - Advertising_SkipRestriction skipRestriction = Advertising_AdPolicy_Get_SkipRestriction(handle); - printf("SkipRestriction = %s ", get_skiprestriction_enum_string(skipRestriction)); - bool limitAdTracking = Advertising_AdPolicy_Get_LimitAdTracking(handle); - printf("LimitAdTracking = %s \n", limitAdTracking? "true" : "false"); - Advertising_AdPolicy_Release(handle); - } else { - printf("Invalid Advertising_AdPolicy_t\n\n"); - } - } else { - printf("Failed to get Advertising Policy\n\n"); - } - break; - } - case 'U': { - Firebolt_String_t handle; - int32_t result = Account_GetUid(&handle); - if (result == FireboltSDKErrorNone) { - printf("Account: Uid:%s\n\n", Firebolt_String(handle)); - Firebolt_String_Release(handle); - handle = NULL; - } else { - printf("Failed to get Advertising Policy\n\n"); - } - break; - } - case 'E': { - { - Discovery_EntityInfoResult_t entityInfoResult = Discovery_EntityInfoResult_Acquire(); - Entertainment_EntityInfo_t entityInfo = Entertainment_EntityInfo_Acquire(); - - //Populate the ContentIdentifiers Object - Entertainment_ContentIdentifiers_t ci = Entertainment_ContentIdentifiers_Acquire(); - Entertainment_ContentIdentifiers_Set_AssetId(ci, "12345678"); - Entertainment_ContentIdentifiers_Set_EntityId(ci, "ABCDEFGH"); - Entertainment_ContentIdentifiers_Set_SeasonId(ci, "1"); - Entertainment_ContentIdentifiers_Set_SeriesId(ci, "9ER34FR"); - Entertainment_ContentIdentifiers_Set_AppContentData(ci, "Sample App Content Data"); - - //Populate EntityInfo Object - //Set the ContentIdentifiers Object to EntityInfo Object - Entertainment_EntityInfo_Set_Identifiers(entityInfo, ci); - Entertainment_ContentIdentifiers_Release(ci); - Entertainment_EntityInfo_Set_Title(entityInfo, "Game Of Thrones"); - Entertainment_EntityInfo_Set_EntityType(entityInfo, "program"); - Entertainment_EntityInfo_Set_ProgramType(entityInfo, ENTERTAINMENT_PROGRAMTYPE_SEASON); - Entertainment_EntityInfo_Set_Synopsis(entityInfo, "The imaginary continent of Westeros was once inhabited by a magical people, the Children of the Forest. For centuries, other people came across the Narrow Sea from the eastern continent of Essos: up North, the First Men; in the Center, the Andals; down South, the Dornish."); - Entertainment_EntityInfo_Set_SeasonNumber(entityInfo, 1); - Entertainment_EntityInfo_Set_EpisodeNumber(entityInfo, 1); - Entertainment_EntityInfo_Set_ReleaseDate(entityInfo, "2012-04-23T18:25:43.511Z"); - - { - Entertainment_ContentRatingArray_t crArray = Entertainment_ContentRatingArray_Acquire(); - { - //Populate the ContentRatings Handle for US TV scheme - Entertainment_ContentRating_t cr = Entertainment_ContentRating_Acquire(); - Entertainment_ContentRating_Set_Scheme(cr, ENTERTAINMENT_CONTENTRATING_SCHEME_US_TV); - Entertainment_ContentRating_Set_Rating(cr, "TVMA"); - Entertainment_ContentRating_AdvisoriesArray_t crAdvisories = Entertainment_ContentRating_AdvisoriesArray_Acquire(); - Entertainment_ContentRating_AdvisoriesArray_Add(crAdvisories, "V"); - Entertainment_ContentRating_AdvisoriesArray_Add(crAdvisories, "S"); - Entertainment_ContentRating_AdvisoriesArray_Add(crAdvisories, "L"); - Entertainment_ContentRating_Set_Advisories(cr, crAdvisories); - Entertainment_ContentRating_AdvisoriesArray_Release(crAdvisories); - Entertainment_ContentRatingArray_Add(crArray, cr); - } - { - //Populate the ContentRatings Handle for US TV scheme - Entertainment_ContentRating_t cr = Entertainment_ContentRating_Acquire(); - Entertainment_ContentRating_Set_Scheme(cr, ENTERTAINMENT_CONTENTRATING_SCHEME_CA_TV); - Entertainment_ContentRating_Set_Rating(cr, "18+"); - Entertainment_ContentRating_AdvisoriesArray_t crAdvisories = Entertainment_ContentRating_AdvisoriesArray_Acquire(); - Entertainment_ContentRating_AdvisoriesArray_Add(crAdvisories, "18+"); - Entertainment_ContentRating_Set_Advisories(cr, crAdvisories); - Entertainment_ContentRating_AdvisoriesArray_Release(crAdvisories); - Entertainment_ContentRatingArray_Add(crArray, cr); - } - Entertainment_EntityInfo_Set_ContentRatings(entityInfo, crArray); - Entertainment_ContentRatingArray_Release(crArray); - } - - //Populate WayToWatch Array in EntityInfo - { - //Populate the WayToWatch Object - Entertainment_WayToWatch_t w2w = Entertainment_WayToWatch_Acquire(); - { - //Add the ContentIdentifiers Object in WayToWatch - Entertainment_ContentIdentifiers_t ciI = Entertainment_ContentIdentifiers_Acquire(); - Entertainment_ContentIdentifiers_Set_AssetId(ciI, "12345678"); - Entertainment_ContentIdentifiers_Set_EntityId(ciI, "ABCDEFGH"); - Entertainment_ContentIdentifiers_Set_SeasonId(ciI, "1"); - Entertainment_ContentIdentifiers_Set_SeriesId(ciI, "9ER34FR"); - Entertainment_ContentIdentifiers_Set_AppContentData(ciI, "Sample App Content Data"); - Entertainment_WayToWatch_Set_Identifiers(w2w, ciI); - Entertainment_ContentIdentifiers_Release(ciI); - } - Entertainment_WayToWatch_Set_Expires(w2w, "2014-04-23T18:25:43.511Z"); - Entertainment_WayToWatch_Set_Entitled(w2w, true); - Entertainment_WayToWatch_Set_EntitledExpires(w2w, "2014-04-23T18:25:43.511Z"); - Entertainment_WayToWatch_Set_OfferingType(w2w, ENTERTAINMENT_OFFERINGTYPE_FREE); - Entertainment_WayToWatch_Set_HasAds(w2w, true); - - //Populate VideoQuality Array - Entertainment_WayToWatch_VideoQualityArray_t vqArray = - Entertainment_WayToWatch_VideoQualityArray_Acquire(); - Entertainment_WayToWatch_VideoQualityArray_Add( - vqArray, ENTERTAINMENT_WAYTOWATCH_VIDEOQUALITY_HD); - Entertainment_WayToWatch_VideoQualityArray_Add( - vqArray, ENTERTAINMENT_WAYTOWATCH_VIDEOQUALITY_UHD); - Entertainment_WayToWatch_Set_VideoQuality(w2w, vqArray); - Entertainment_WayToWatch_VideoQualityArray_Release(vqArray); - - //Populate AudioProfile Array - Entertainment_AudioProfileArray_t apArray = - Entertainment_AudioProfileArray_Acquire(); - Entertainment_AudioProfileArray_Add( - apArray, TYPES_AUDIOPROFILE_STEREO); - Entertainment_AudioProfileArray_Add( - apArray, TYPES_AUDIOPROFILE_DOLBY_DIGITAL_5_1); - Entertainment_AudioProfileArray_Add( - apArray, TYPES_AUDIOPROFILE_DOLBY_DIGITAL_5_1_PLUS); - Entertainment_WayToWatch_Set_AudioProfile(w2w, apArray); - Entertainment_AudioProfileArray_Release(apArray); - - //Populate AudioLanguages Array - Entertainment_WayToWatch_AudioLanguagesArray_t alArray = - Entertainment_WayToWatch_AudioLanguagesArray_Acquire(); - Entertainment_WayToWatch_AudioLanguagesArray_Add(alArray, "en"); - Entertainment_WayToWatch_AudioLanguagesArray_Add(alArray, "fr"); - Entertainment_WayToWatch_Set_AudioLanguages(w2w, alArray); - Entertainment_WayToWatch_AudioLanguagesArray_Release(alArray); - - //Populate ClosedCaptions Array - Entertainment_WayToWatch_ClosedCaptionsArray_t ccArray = - Entertainment_WayToWatch_ClosedCaptionsArray_Acquire(); - Entertainment_WayToWatch_ClosedCaptionsArray_Add(ccArray, "en"); - Entertainment_WayToWatch_ClosedCaptionsArray_Add(ccArray, "fr"); - Entertainment_WayToWatch_Set_ClosedCaptions(w2w, ccArray); - Entertainment_WayToWatch_ClosedCaptionsArray_Release(ccArray); - - //Populate Subtitles Array - Entertainment_WayToWatch_SubtitlesArray_t sbArray = - Entertainment_WayToWatch_SubtitlesArray_Acquire(); - Entertainment_WayToWatch_SubtitlesArray_Add(sbArray, "en"); - Entertainment_WayToWatch_SubtitlesArray_Add(sbArray, "fr"); - Entertainment_WayToWatch_Set_Subtitles(w2w, sbArray); - Entertainment_WayToWatch_SubtitlesArray_Release(sbArray); - - //Populate AudioDescriptions Array - Entertainment_WayToWatch_AudioDescriptionsArray_t adArray = - Entertainment_WayToWatch_AudioDescriptionsArray_Acquire(); - Entertainment_WayToWatch_AudioDescriptionsArray_Add(adArray, "en"); - Entertainment_WayToWatch_Set_AudioDescriptions(w2w, adArray); - Entertainment_WayToWatch_AudioDescriptionsArray_Release(adArray); - - //Populate WayToWatch Array - Entertainment_WayToWatchArray_t w2wArray = - Entertainment_WayToWatchArray_Acquire(); - Entertainment_WayToWatchArray_Add(w2wArray, w2w); - Entertainment_EntityInfo_Set_WaysToWatch(entityInfo, w2wArray); - Entertainment_WayToWatchArray_Release(w2wArray); - Entertainment_WayToWatch_Release(w2w); - } - - //Populate EntityInfoResult Object - Discovery_EntityInfoResult_Set_Expires(entityInfoResult, "2012-06-23T18:25:43.511Z"); - Discovery_EntityInfoResult_Set_Entity(entityInfoResult, entityInfo); - Entertainment_EntityInfo_Release(entityInfo); - - //All Set, Call the Push - int32_t result = Discovery_PushEntityInfo(entityInfoResult); - if (result == FireboltSDKErrorNone) { - printf("\nSuccessfully Pushed entityInfo\n"); - - } else { - printf("\nFailed to Push entityInfo\n"); - } - Discovery_EntityInfoResult_Release(entityInfoResult); - break; - } - } - case 'R': { - HandleEventListener(Device, ScreenResolutionChanged, (const void*)NotifyDeviceScreenResolutionChange, deviceScreenResolutionTestStr, "device.screenresolution") - break; - } - case 'N': { - HandleEventListener(Device, NameChanged, (const void*)NotifyDeviceNameChange, deviceNameTestStr, "device.name") - break; - } - case 'A': { - HandleEventListener(Accessibility, VoiceGuidanceSettingsChanged, (const void*)NotifyAccessibilityVoiceGuidanceChange, accessibilityVoiceGuidanceTestStr, "accessibility.voiceguidance") - break; - } - case 'H': { - HandleEventListener(Discovery, NavigateToHomeIntent, (const void*)NotifyOnNavigateToHomeIntent, discoveryHomeIntentTestStr, "discovery.onNavigateTo") - break; - } - case 'S': { - HandleEventListener(Discovery, NavigateToSearchIntent, (const void*)NotifyOnNavigateToSearchIntent, discoverySearchIntentTestStr, "discovery.onNavigateTo") - break; - } - default: - break; - } - getchar(); // Skip white space - } while (option != 'Q'); - - FireboltSDK_Deinitialize(); - - return 0; -} diff --git a/src/sdks/core/src/cpp/sdk/test/CMakeLists.txt b/src/sdks/core/src/cpp/sdk/test/CMakeLists.txt index 9242ea10e..b196ac143 100644 --- a/src/sdks/core/src/cpp/sdk/test/CMakeLists.txt +++ b/src/sdks/core/src/cpp/sdk/test/CMakeLists.txt @@ -27,7 +27,9 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) find_package(${NAMESPACE}Core CONFIG REQUIRED) file(GLOB CPP_SOURCES *.cpp) -add_library(${TESTLIB} STATIC ${CPP_SOURCES} CoreSDKTestGeneratedCode.c) +list(REMOVE_ITEM CPP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Main.cpp) +message("After CPP_SOURCES " ${CPP_SOURCES}) +add_library(${TESTLIB} STATIC ${CPP_SOURCES}) target_link_libraries(${TESTLIB} PRIVATE @@ -44,7 +46,7 @@ target_include_directories(${TESTLIB} ) set_target_properties(${TESTLIB} PROPERTIES - CXX_STANDARD 11 + CXX_STANDARD 17 CXX_STANDARD_REQUIRED YES LINK_WHAT_YOU_USE TRUE FRAMEWORK FALSE @@ -54,7 +56,7 @@ set(TESTAPP FireboltCoreSDKTestApp) message("Setup ${TESTAPP} v${PROJECT_VERSION}") -add_executable(${TESTAPP} Main.c) +add_executable(${TESTAPP} Main.cpp) target_link_libraries(${TESTAPP} PRIVATE diff --git a/src/sdks/core/src/cpp/sdk/test/CoreSDKTestGeneratedCode.c b/src/sdks/core/src/cpp/sdk/test/CoreSDKTestGeneratedCode.c deleted file mode 100644 index cbb0fa76c..000000000 --- a/src/sdks/core/src/cpp/sdk/test/CoreSDKTestGeneratedCode.c +++ /dev/null @@ -1,330 +0,0 @@ -/* - * Copyright 2023 Comcast Cable Communications Management, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include - -#include "CoreSDKCTests.h" -#include "CoreSDKTestGeneratedCode.h" - -#include "accessibility.h" -#include "advertising.h" -#include "common/types.h" -#include "device.h" -#include "lifecycle.h" - -#ifdef __cplusplus -extern "C" { -#endif - -int32_t test_generated_properties_get_device_id() -{ - Firebolt_String_t handle; - int32_t result = Device_GetId(&handle); - - if (result == FireboltSDKErrorNone) { - printf("\nDevice: Id:%s\n", Firebolt_String(handle)); - Firebolt_String_Release(handle); - } - - EXPECT_EQ(result, FireboltSDKErrorNone); - return result; -} -#if 0 -int32_t test_generated_properties_get_device_version() -{ - Device_Versions_t handle; - int32_t result = Device_GetVersion(&handle); - - if (result == FireboltSDKErrorNone) { - if (Device_Versions_IsValid(handle)) { - Types_SemanticVersion_t sdkHandle = Device_Versions_Get_Sdk(handle); - if (Types_SemanticVersion_IsValid(sdkHandle)) { - uint32_t major = Types_SemanticVersion_Get_Major(sdkHandle); - uint32_t minor = Types_SemanticVersion_Get_Minor(sdkHandle); - uint32_t patch = Types_SemanticVersion_Get_Patch(sdkHandle); - char* readable = Types_SemanticVersion_Get_Readable(sdkHandle); - printf("\nDevice:SDK Version major:%d minor:%d patch:%d readable:%s\n", - major, minor, patch, readable); - Types_SemanticVersion_Release(sdkHandle); - result = FireboltSDKErrorNone; - } - Types_SemanticVersion_t osHandle = Device_Versions_Get_Os(handle); - if (Types_SemanticVersion_IsValid(osHandle)) { - uint32_t major = Types_SemanticVersion_Get_Major(osHandle); - uint32_t minor = Types_SemanticVersion_Get_Minor(osHandle); - uint32_t patch = Types_SemanticVersion_Get_Patch(osHandle); - const char* readable = Types_SemanticVersion_Get_Readable(osHandle); - printf("\nDevice:OS Version major:%d minor:%d patch:%d readable:%s\n", - major, minor, patch, readable); - Types_SemanticVersion_Release(osHandle); - result = FireboltSDKErrorNone; - } - Device_Versions_Release(handle); - } else { - result = FireboltSDKErrorUnavailable; - } - } - - EXPECT_EQ(result, FireboltSDKErrorNone); - return result; -} -#endif -int32_t test_generated_properties_get_accessibility_closedcaption() -{ - Accessibility_ClosedCaptionsSettings_t handle; - int32_t result = Accessibility_GetClosedCaptionsSettings(&handle); - - if (result == FireboltSDKErrorNone) { - if (Accessibility_ClosedCaptionsSettings_IsValid(handle) == true) { - printf("ClosedCaption Settings ------------------\n"); - Accessibility_ClosedCaptionsStyles_t styleHandle = Accessibility_ClosedCaptionsSettings_Get_Styles(handle); - if (Accessibility_ClosedCaptionsStyles_IsValid(styleHandle)) { - printf("ClosedCaptionStyles:\n"); - char* fontFamily = Accessibility_ClosedCaptionsStyles_Get_FontFamily(styleHandle); - printf("\tFontFamily : %s\n", fontFamily); - uint32_t fontSize = Accessibility_ClosedCaptionsStyles_Get_FontSize(styleHandle); - printf("\tFontSize : %d\n", fontSize); - char* fontColor = Accessibility_ClosedCaptionsStyles_Get_FontColor(styleHandle); - printf("\tFontColor : %s\n", fontColor); - char* fontEdge = Accessibility_ClosedCaptionsStyles_Get_FontEdge(styleHandle); - printf("\tFontEdge : %s\n", fontEdge); - char* fontEdgeColor = Accessibility_ClosedCaptionsStyles_Get_FontEdgeColor(styleHandle); - printf("\tFontEdgeColor : %s\n", fontEdgeColor); - uint32_t fontOpacity = Accessibility_ClosedCaptionsStyles_Get_FontOpacity(styleHandle); - printf("\tFontOpacity : %d\n", fontOpacity); - char* bgColor = Accessibility_ClosedCaptionsStyles_Get_BackgroundColor(styleHandle); - printf("\tBackgroundColor : %s\n", bgColor); - uint32_t bgOpacity = Accessibility_ClosedCaptionsStyles_Get_BackgroundOpacity(styleHandle); - printf("\tBackgroundOpacity : %d\n", bgOpacity); - char* txAlign = Accessibility_ClosedCaptionsStyles_Get_TextAlign(styleHandle); - printf("\tTextAlign : %s\n", txAlign); - char* txAlignVertical = Accessibility_ClosedCaptionsStyles_Get_TextAlignVertical(styleHandle); - printf("\tTextAlignVertical : %s\n", txAlignVertical); - Accessibility_ClosedCaptionsStyles_Release(styleHandle); - } - bool enabled = Accessibility_ClosedCaptionsSettings_Get_Enabled(handle); - printf("Enabled: %d\n", enabled); - Accessibility_ClosedCaptionsSettings_Release(handle); - } else { - result = FireboltSDKErrorUnavailable; - } - } - - EXPECT_EQ(result, FireboltSDKErrorNone); - return result; -} -int32_t test_generated_properties_get_accessibility_voiceguidancesettings() -{ - Accessibility_VoiceGuidanceSettings_t handle; - int32_t result = Accessibility_GetVoiceGuidanceSettings(&handle); - - if (result == FireboltSDKErrorNone) { - if (Accessibility_VoiceGuidanceSettings_IsValid(handle) == true) { - bool enabled = Accessibility_VoiceGuidanceSettings_Get_Enabled(handle); - uint32_t speed = Accessibility_VoiceGuidanceSettings_Get_Speed(handle); - printf("VoiceGuidanceSettings: Enabled : %d, Speed : %d\n", enabled, speed); - Accessibility_VoiceGuidanceSettings_Release(handle); - } else { - result = FireboltSDKErrorUnavailable; - } - } - EXPECT_EQ(result, FireboltSDKErrorNone); - return result; -} -const char* get_skiprestriction_enum_string(Advertising_SkipRestriction skipRestriction) -{ - const char* strSkipRestriction; - switch(skipRestriction) { - case ADVERTISING_SKIPRESTRICTION_NONE: - strSkipRestriction = "None"; - break; - case ADVERTISING_SKIPRESTRICTION_ADS_UNWATCHED: - strSkipRestriction = "AdsUnwatched"; - break; - case ADVERTISING_SKIPRESTRICTION_ADS_ALL: - strSkipRestriction = "AdsAll"; - break; - case ADVERTISING_SKIPRESTRICTION_ALL: - strSkipRestriction = "All"; - break; - default: - strSkipRestriction = "None"; - break; - } - return strSkipRestriction; -} - -int32_t test_generated_properties_get_advertising_policy() -{ - Advertising_AdPolicy_t handle; - int32_t result = Advertising_GetPolicy(&handle); - if (result == FireboltSDKErrorNone) { - if (Advertising_AdPolicy_IsValid(handle) == true) { - printf("AdPolicy: "); - Advertising_SkipRestriction skipRestriction = Advertising_AdPolicy_Get_SkipRestriction(handle); - printf("SkipRestriction = %s ", get_skiprestriction_enum_string(skipRestriction)); - bool limitAdTracking = Advertising_AdPolicy_Get_LimitAdTracking(handle); - printf("LimitAdTracking = %s \n", limitAdTracking? "true" : "false"); - Advertising_AdPolicy_Release(handle); - } else { - result = FireboltSDKErrorUnavailable; - } - } - EXPECT_EQ(result, FireboltSDKErrorNone); - return result; -} - -#include -#include -pthread_cond_t cond = PTHREAD_COND_INITIALIZER; -pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; - -static const char deviceNameTestStr[] = "DeviceNameTestStr"; -static void NotifyDeviceNameChange(const void* userData, Firebolt_String_t handle) -{ - EXPECT_NE(handle, NULL); - if (handle) { - printf("\nGot new device.name :%s\n", Firebolt_String(handle)); - Firebolt_String_Release(handle); - } - EXPECT_EQ(strncmp((const char*)userData, deviceNameTestStr, strlen(deviceNameTestStr)), 0); - pthread_cond_signal(&cond); -} -int32_t test_generated_event_device_name() -{ - int32_t result = Device_Register_OnNameChanged((const void*)&NotifyDeviceNameChange, deviceNameTestStr); - EXPECT_EQ(result, FireboltSDKErrorNone); - if (result != FireboltSDKErrorNone) { - printf("Set event device.name status = %d \n", result); - } else { - printf("Set event device.name registered successfully\n"); - - pthread_mutex_lock(&lock); - printf("Waiting for device.name event\n"); - pthread_cond_wait(&cond, &lock); - pthread_mutex_unlock(&lock); - } - - result = Device_Unregister_OnNameChanged((const void*)NotifyDeviceNameChange); - EXPECT_EQ(result, FireboltSDKErrorNone); - return result; -} - -int32_t test_generated_event_device_name_with_register_same_callback() -{ - int32_t result = Device_Register_OnNameChanged((const void*)NotifyDeviceNameChange, deviceNameTestStr); - EXPECT_EQ(result, FireboltSDKErrorNone); - if (result != FireboltSDKErrorNone) { - printf("Set event device.name status = %d \n", result); - } else { - printf("Set event device.name registered successfully\n"); - result = Device_Register_OnNameChanged((const void*)NotifyDeviceNameChange, deviceNameTestStr); - EXPECT_EQ(result, FireboltSDKErrorInUse); - if (result == FireboltSDKErrorInUse) { - printf("%s Yes this device.name event is already registered with same callback\n", __func__); - } - } - - result = Device_Unregister_OnNameChanged((const void*)NotifyDeviceNameChange); - EXPECT_EQ(result, FireboltSDKErrorNone); - return result; -} -static const char deviceScreenResolutionTestStr[] = "deviceScreenResolutionTestStr"; -static void NotifyDeviceScreenResolutionChange(const void* userData, Device_ResolutionArray_t handle) -{ - EXPECT_EQ(Device_ResolutionArray_IsValid(handle), true); - if (Device_ResolutionArray_IsValid(handle) == true) { - uint32_t size = Device_ResolutionArray_Size(handle); - printf("Device ScreenResolutions changed for %d numbers\n", size); - for (uint32_t i = 0; i < size; ++i) { - printf("New reslution[%d] = %d\n", i, Device_ResolutionArray_Get(handle, i)); - } - Device_ResolutionArray_Release(handle); - } - EXPECT_EQ(strncmp((const char*)userData, deviceScreenResolutionTestStr, strlen(deviceScreenResolutionTestStr)), 0); - pthread_cond_signal(&cond); -} -int32_t test_generated_event_device_screenresolution() -{ - int32_t result = Device_Register_OnScreenResolutionChanged((const void*)NotifyDeviceScreenResolutionChange, deviceScreenResolutionTestStr); - EXPECT_EQ(result, FireboltSDKErrorNone); - if (result != FireboltSDKErrorNone) { - printf("Set event device.screenresolution status = %d \n", result); - } else { - printf("Set event device.screenresolution registered successfully\n"); - - pthread_mutex_lock(&lock); - printf("Waiting for device.screenresolution event\n"); - pthread_cond_wait(&cond, &lock); - pthread_mutex_unlock(&lock); - } - - result = Device_Unregister_OnScreenResolutionChanged((const void*)NotifyDeviceScreenResolutionChange); - EXPECT_EQ(result, FireboltSDKErrorNone); - return result; -} - -static const char accessibilityVoiceGuidanceTestStr[] = "AccessibilityVoiceGuidanceTestStr"; -static void NotifyAccessibilityVoiceGuidanceChange(const void* userData, Accessibility_VoiceGuidanceSettings_t handle) -{ - EXPECT_EQ(Accessibility_VoiceGuidanceSettings_IsValid(handle), true); - if (Accessibility_VoiceGuidanceSettings_IsValid(handle) == true) { - bool enabled = Accessibility_VoiceGuidanceSettings_Get_Enabled(handle); - uint32_t speed = Accessibility_VoiceGuidanceSettings_Get_Speed(handle); - printf("VoiceGuidanceSettings: Enabled : %d, Speed : %d\n", enabled, speed); - Accessibility_VoiceGuidanceSettings_Release(handle); - } - EXPECT_EQ(strncmp((const char*)userData, accessibilityVoiceGuidanceTestStr, strlen(accessibilityVoiceGuidanceTestStr)), 0); - pthread_cond_signal(&cond); -} -int32_t test_generated_event_accessibility_voice_guidance_settings() -{ - int32_t result = Accessibility_Register_OnVoiceGuidanceSettingsChanged((const void*)NotifyAccessibilityVoiceGuidanceChange, accessibilityVoiceGuidanceTestStr); - EXPECT_EQ(result, FireboltSDKErrorNone); - if (result != FireboltSDKErrorNone) { - printf("Set event device.name status = %d \n", result); - } else { - printf("Set event accessibility.voiceguidance registered successfully\n"); - - pthread_mutex_lock(&lock); - printf("Waiting for accessibility.voiceguidance event\n"); - pthread_cond_wait(&cond, &lock); - pthread_mutex_unlock(&lock); - } - - result = Accessibility_Unregister_OnVoiceGuidanceSettingsChanged((const void*)NotifyAccessibilityVoiceGuidanceChange); - EXPECT_EQ(result, FireboltSDKErrorNone); - return result; -} -#if 0 -int32_t test_generated_calls_metrics_lifecycle_ready() -{ - int32_t result = Lifecycle_Ready(); - if (result != FireboltSDKErrorNone) { - printf("Lifecycle.ready call status = %d \n", result); - } else { - printf("Lifecycle.ready is called successfully\n"); - } - // Just add sleep() to keep the test process in active for a while, since the test process should be in-active to invoke worker pool dispatcher (for calls-metrics mehods). This sleep is not required for actual apps case. - sleep(1); - return result; -} -#endif -#ifdef __cplusplus -} -#endif diff --git a/src/sdks/core/src/cpp/sdk/test/CoreSDKTestGeneratedCode.cpp b/src/sdks/core/src/cpp/sdk/test/CoreSDKTestGeneratedCode.cpp new file mode 100644 index 000000000..3265daf68 --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/test/CoreSDKTestGeneratedCode.cpp @@ -0,0 +1,91 @@ +/* + * Copyright 2023 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +#include "Module.h" +#include "firebolt.h" +#include "CoreSDKTestStaticCode.h" +#include "CoreSDKTestGeneratedCode.h" + +using namespace std; +bool CoreSDKTestGeneratedCode::_connected; + +void CoreSDKTestGeneratedCode::ConnectionChanged(const bool connected, const Firebolt::Error error) +{ + cout << "Change in connection: connected: " << connected << " error: " << static_cast(error) << endl; + _connected = connected; +} + +void CoreSDKTestGeneratedCode::CreateFireboltInstance() +{ + const std::string config = _T("{\ + \"waitTime\": 1000,\ + \"logLevel\": \"Info\",\ + \"workerPool\":{\ + \"queueSize\": 8,\ + \"threadCount\": 3\ + },\ + \"wsUrl\": \"ws://127.0.0.1:9998\"\ + }"); + + _connected = false; + Firebolt::IFireboltAccessor::Instance().Initialize(config); + Firebolt::IFireboltAccessor::Instance().Connect(ConnectionChanged); +} + +void CoreSDKTestGeneratedCode::DestroyFireboltInstance() +{ + Firebolt::IFireboltAccessor::Instance().Disconnect(); + Firebolt::IFireboltAccessor::Instance().Deinitialize(); + Firebolt::IFireboltAccessor::Instance().Dispose(); +} + +bool CoreSDKTestGeneratedCode::WaitOnConnectionReady() +{ + uint32_t waiting = 10000; + static constexpr uint32_t SLEEPSLOT_TIME = 100; + + // Right, a wait till connection is closed is requested.. + while ((waiting > 0) && (_connected == false)) { + + uint32_t sleepSlot = (waiting > SLEEPSLOT_TIME ? SLEEPSLOT_TIME : waiting); + // Right, lets sleep in slices of 100 ms + SleepMs(sleepSlot); + waiting -= sleepSlot; + } + return _connected; +} + +void CoreSDKTestGeneratedCode::TestCoreStaticSDK() +{ + FireboltSDK::Tests::Main(); +} + +void CoreSDKTestGeneratedCode::GetDeviceName() +{ + Firebolt::Error error = Firebolt::Error::None; + const std::string name = Firebolt::IFireboltAccessor::Instance().DeviceInterface().Name(&error); + + if (error == Firebolt::Error::None) { + cout << "Get DeviceName = " << name.c_str() << endl; + } else { + cout << "Get DeviceName status = " << static_cast(error) << endl; + } +} + diff --git a/src/sdks/core/src/cpp/sdk/test/CoreSDKTestGeneratedCode.h b/src/sdks/core/src/cpp/sdk/test/CoreSDKTestGeneratedCode.h index 4b9d12441..cfa3c86ae 100644 --- a/src/sdks/core/src/cpp/sdk/test/CoreSDKTestGeneratedCode.h +++ b/src/sdks/core/src/cpp/sdk/test/CoreSDKTestGeneratedCode.h @@ -16,27 +16,24 @@ * SPDX-License-Identifier: Apache-2.0 */ -#ifndef CORESDK_TEST_GENERATED_CODE_H -#define CORESDK_TEST_GENERATED_CODE_H +#pragma once +#include "error.h" -#ifdef __cplusplus -extern "C" { -#endif +class CoreSDKTestGeneratedCode { -//int32_t test_generated_properties_get_device_version(); -int32_t test_generated_properties_get_device_id(); -int32_t test_generated_properties_get_accessibility_closedcaption(); -int32_t test_generated_properties_get_accessibility_voiceguidancesettings(); -int32_t test_generated_properties_get_advertising_policy(); -int32_t test_generated_event_device_name(); -int32_t test_generated_event_device_name_with_register_same_callback(); -int32_t test_generated_event_device_screenresolution(); -int32_t test_generated_event_accessibility_voice_guidance_settings(); -//int32_t test_generated_calls_metrics_lifecycle_ready(); +public: + CoreSDKTestGeneratedCode() = default; + virtual ~CoreSDKTestGeneratedCode() = default; -#ifdef __cplusplus -} -#endif + static void CreateFireboltInstance(); + static void DestroyFireboltInstance(); + static void TestCoreStaticSDK(); + static void GetDeviceName(); + static bool WaitOnConnectionReady(); + +private: + static void ConnectionChanged(const bool, const Firebolt::Error); + static bool _connected; +}; -#endif // CORESDK_TEST_GENERATED_CODE_H diff --git a/src/sdks/core/src/cpp/sdk/test/CoreSDKTestStaticCode.cpp b/src/sdks/core/src/cpp/sdk/test/CoreSDKTestStaticCode.cpp new file mode 100644 index 000000000..8ac533e31 --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/test/CoreSDKTestStaticCode.cpp @@ -0,0 +1,46 @@ +/* + * Copyright 2023 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "Module.h" +#include "CoreSDKTestStaticCode.h" + +namespace FireboltSDK { + CoreTestStaticCode::CoreTestStaticCode() + : Tests() + { + _functionMap.emplace(std::piecewise_construct, std::forward_as_tuple("Get Country Code"), + std::forward_as_tuple(&GetCountryCode)); + } + + /* static */ Firebolt::Error CoreTestStaticCode::GetCountryCode() + { + const string method = _T("localization.countryCode"); + WPEFramework::Core::ProxyType response; + Firebolt::Error status = FireboltSDK::Properties::Get(method, response); + + EXPECT_EQ(status, Firebolt::Error::None); + if (status == Firebolt::Error::None) { + FIREBOLT_LOG_INFO(Logger::Category::Core, Logger::Module(), "CountryCode : %s", response->Value().c_str()); + } else { + FIREBOLT_LOG_ERROR(Logger::Category::Core, Logger::Module(), "Get %s status = %d\n", method.c_str(), status); + } + + return status; + } +} + diff --git a/src/sdks/core/src/cpp/sdk/test/CoreSDKTests.h b/src/sdks/core/src/cpp/sdk/test/CoreSDKTestStaticCode.h similarity index 91% rename from src/sdks/core/src/cpp/sdk/test/CoreSDKTests.h rename to src/sdks/core/src/cpp/sdk/test/CoreSDKTestStaticCode.h index 480129e6d..8966112f9 100644 --- a/src/sdks/core/src/cpp/sdk/test/CoreSDKTests.h +++ b/src/sdks/core/src/cpp/sdk/test/CoreSDKTestStaticCode.h @@ -17,7 +17,6 @@ */ #pragma once - #include namespace FireboltSDK { @@ -51,12 +50,12 @@ namespace FireboltSDK { WPEFramework::Core::JSON::Boolean RememberWatchedPrograms; }; - class CoreTests : public Tests { + class CoreTestStaticCode : public Tests { public: - CoreTests(); - ~CoreTests() override = default; + CoreTestStaticCode(); + ~CoreTestStaticCode() override = default; - static int32_t GetDiscoveryPolicy(); + static Firebolt::Error GetCountryCode(); }; } diff --git a/src/sdks/core/src/cpp/sdk/test/CoreSDKTests.cpp b/src/sdks/core/src/cpp/sdk/test/CoreSDKTests.cpp deleted file mode 100644 index cfcca0686..000000000 --- a/src/sdks/core/src/cpp/sdk/test/CoreSDKTests.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2023 Comcast Cable Communications Management, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "Module.h" -#include "CoreSDKTests.h" - -namespace FireboltSDK { - CoreTests::CoreTests() - : Tests() - { - _functionMap.emplace(std::piecewise_construct, std::forward_as_tuple("Get Discovery Policy"), - std::forward_as_tuple(&GetDiscoveryPolicy)); - } - - /* static */ int32_t CoreTests::GetDiscoveryPolicy() - { - const string method = _T("discovery.policy"); - WPEFramework::Core::ProxyType response; - int32_t status = FireboltSDK::Properties::Get(method, response); - - EXPECT_EQ(status, FireboltSDKErrorNone); - if (status == FireboltSDKErrorNone) { - FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::Core, Logger::Module(), - "EnableRecommendations : %d", response->EnableRecommendations.Value()); - FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::Core, Logger::Module(), - "ShareWatchHistory : %d", response->ShareWatchHistory.Value()); - FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::Core, Logger::Module(), - "RememberWatchedPrograms : %d", response->RememberWatchedPrograms.Value()); - } else { - FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::Core, Logger::Module(), - "Get %s status = %d", method.c_str(), status); - } - - return status; - } -} - -#ifdef __cplusplus -extern "C" { -#endif - -int32_t test_firebolt_core_main() -{ - return FireboltSDK::Tests::Main(); -} - -int32_t test_properties_get_policy() -{ - const string method = _T("discovery.policy"); - WPEFramework::Core::ProxyType response; - int32_t status = FireboltSDK::Properties::Get(method, response); - - EXPECT_EQ(status, FireboltSDKErrorNone); - if (status == FireboltSDKErrorNone) { - FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::Core, "ctest", - "EnableRecommendations : %d", response->EnableRecommendations.Value()); - FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::Core, "ctest", - "ShareWatchHistory : %d", response->ShareWatchHistory.Value()); - FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::Core, "ctest", - "RememberWatchedPrograms : %d", response->RememberWatchedPrograms.Value()); - } else { - FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::Core, "ctest", - "Get %s status = %d", method.c_str(), status); - } - - return status; -} - -#ifdef __cplusplus -} -#endif diff --git a/src/sdks/core/src/cpp/sdk/test/Main.c b/src/sdks/core/src/cpp/sdk/test/Main.c deleted file mode 100644 index 2490dbb95..000000000 --- a/src/sdks/core/src/cpp/sdk/test/Main.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2023 Comcast Cable Communications Management, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include "CoreSDKCTests.h" -#include "CoreSDKTestGeneratedCode.h" - -int __cnt = 0; -int __pass = 0; - -int TotalTests = 0; -int TotalTestsPassed = 0; - -int main() -{ - test_firebolt_create_instance(); - test_firebolt_core_main(); - - // Calling C function sequences - printf("%s:%s:%d Calling C function tests\n", __FILE__, __func__, __LINE__); - EXECUTE("test_properties_get_device_id", test_properties_get_device_id); - EXECUTE("test_properties_get_policy", test_properties_get_policy); - EXECUTE("test_properties_set", test_properties_set); - EXECUTE("test_eventregister_by_providing_callback", test_eventregister_by_providing_callback); - EXECUTE("test_eventregister", test_eventregister); - EXECUTE("test_string_set_get_value", test_string_set_get_value); - EXECUTE("test_generated_properties_get_device_id", test_generated_properties_get_device_id); - //EXECUTE("test_generated_properties_get_device_version", test_generated_properties_get_device_version); - EXECUTE("test_generated_properties_get_accessibility_closedcaption", test_generated_properties_get_accessibility_closedcaption); - EXECUTE("test_generated_properties_get_accessibility_voiceguidancesettings", test_generated_properties_get_accessibility_voiceguidancesettings); - EXECUTE("test_generated_properties_get_advertising_policy", test_generated_properties_get_advertising_policy); - EXECUTE("test_generated_event_device_name", test_generated_event_device_name); - EXECUTE("test_generated_event_device_name_with_register_same_callback", test_generated_event_device_name_with_register_same_callback); - EXECUTE("test_generated_event_device_screenresolution", test_generated_event_device_screenresolution); - EXECUTE("test_generated_event_accessibility_voice_guidance_settings", test_generated_event_accessibility_voice_guidance_settings); - //EXECUTE("test_generated_calls_metrics_lifecycle_ready", test_generated_calls_metrics_lifecycle_ready); - - test_firebolt_dispose_instance(); - - printf("TOTAL: %i tests; %i PASSED, %i FAILED\n", TotalTests, TotalTestsPassed, (TotalTests - TotalTestsPassed)); -} - diff --git a/src/sdks/core/src/cpp/sdk/test/CoreSDKCTests.h b/src/sdks/core/src/cpp/sdk/test/Main.cpp similarity index 57% rename from src/sdks/core/src/cpp/sdk/test/CoreSDKCTests.h rename to src/sdks/core/src/cpp/sdk/test/Main.cpp index a6592156c..bd4329d42 100644 --- a/src/sdks/core/src/cpp/sdk/test/CoreSDKCTests.h +++ b/src/sdks/core/src/cpp/sdk/test/Main.cpp @@ -16,20 +16,23 @@ * SPDX-License-Identifier: Apache-2.0 */ -#ifndef CORESDK_C_TESTS_H -#define CORESDK_C_TESTS_H +#include +#include "CoreSDKTestGeneratedCode.h" -#include +int __cnt = 0; +int __pass = 0; -#ifdef __cplusplus -extern "C" { -#endif +int TotalTests = 0; +int TotalTestsPassed = 0; -int32_t test_firebolt_core_main(); -int32_t test_properties_get_policy(); +int main() +{ + CoreSDKTestGeneratedCode::CreateFireboltInstance(); -#ifdef __cplusplus + if (CoreSDKTestGeneratedCode::WaitOnConnectionReady() == true) { + CoreSDKTestGeneratedCode::GetDeviceName(); + } + CoreSDKTestGeneratedCode::DestroyFireboltInstance(); + printf("TOTAL: %i tests; %i PASSED, %i FAILED\n", TotalTests, TotalTestsPassed, (TotalTests - TotalTestsPassed)); } -#endif -#endif //CORESDK_C_TESTS_H diff --git a/src/sdks/core/src/cpp/templates/Metrics/src/module_impl.cpp b/src/sdks/core/src/cpp/templates/Metrics/src/module_impl.cpp new file mode 100644 index 000000000..03a3764ff --- /dev/null +++ b/src/sdks/core/src/cpp/templates/Metrics/src/module_impl.cpp @@ -0,0 +1,98 @@ +/* + * Copyright 2023 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "${info.title.lowercase}_impl.h" + +${if.implementations} +namespace Firebolt { +namespace ${info.Title} { +${if.providers} +/* ${PROVIDERS} */${end.if.providers} + void ${info.Title}Impl::signIn() + { + Firebolt::Error status = Firebolt::Error::NotConnected; + FireboltSDK::Transport* transport = FireboltSDK::Accessor::Instance().GetTransport(); + if (transport != nullptr) { + + JsonObject jsonParameters; + + WPEFramework::Core::JSON::Boolean jsonResult; + status = transport->Invoke("${info.title.lowercase}.signIn", jsonParameters, jsonResult); + if (status == Firebolt::Error::None) { + FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "${info.Title.signIn is successfully invoked, status : %s", (jsonResult.Value() ? "true" : "false")); + } + + } else { + FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Error in getting Transport err = %d", status); + } + } + + void ${info.Title}Impl::signOut() + { + Firebolt::Error status = Firebolt::Error::NotConnected; + FireboltSDK::Transport* transport = FireboltSDK::Accessor::Instance().GetTransport(); + if (transport != nullptr) { + + JsonObject jsonParameters; + + WPEFramework::Core::JSON::Boolean jsonResult; + status = transport->Invoke("${info.title.lowercase}.signOut", jsonParameters, jsonResult); + if (status == Firebolt::Error::None) { + FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "${info.Title}.signOut is successfully invoked, status : %s", (jsonResult.Value() ? "true" : "false")); + } + + } else { + FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Error in getting Transport err = %d", status); + } + } + + void ${info.Title}Impl::ready() + { + Firebolt::Error status = Firebolt::Error::NotConnected; + FireboltSDK::Transport* transport = FireboltSDK::Accessor::Instance().GetTransport(); + if (transport != nullptr) { + + JsonObject jsonParameters; + + WPEFramework::Core::JSON::Boolean jsonResult; + status = transport->Invoke("${info.title.lowercase}.ready", jsonParameters, jsonResult); + if (status == Firebolt::Error::None) { + FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "${info.Title}.ready is successfully invoked, status : %s", (jsonResult.Value() ? "true" : "false")); + } + + } else { + FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Error in getting Transport err = %d", status); + } + } + + // Methods + /* ${METHODS} */ + + // Events + /* ${EVENTS} */ + +}//namespace ${info.Title} +}${end.if.implementations} +${if.enums} + +namespace WPEFramework { + + +/* ${ENUMS} */ + +}${end.if.enums} diff --git a/src/sdks/core/src/cpp/templates/Metrics/src/module_impl.h b/src/sdks/core/src/cpp/templates/Metrics/src/module_impl.h new file mode 100644 index 000000000..d64b59695 --- /dev/null +++ b/src/sdks/core/src/cpp/templates/Metrics/src/module_impl.h @@ -0,0 +1,52 @@ +/* + * Copyright 2023 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "FireboltSDK.h" +#include "IModule.h" +/* ${IMPORTS} */ +#include "${info.title.lowercase}.h" + +${if.implementations} +namespace Firebolt { +namespace ${info.Title} { +${if.enums} + +/* ${ENUMS:json-types} */${end.if.enums} +${if.types} + // Types +/* ${TYPES:json-types} */${end.if.types} + ${if.methods}class ${info.Title}Impl : public I${info.Title}, public IModule { + + public: + ${info.Title}Impl() = default; + ${info.Title}Impl(const ${info.Title}Impl&) = delete; + ${info.Title}Impl& operator=(const ${info.Title}Impl&) = delete; + + ~${info.Title}Impl() override = default; + + static void signIn(); + static void signOut(); + static void ready(); + // Methods & Events + /* ${METHODS:declarations-override} */ + };${end.if.methods} + +}//namespace ${info.Title} +}${end.if.implementations} diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/Main.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/Main.cpp index df37559ae..1a0b1df3b 100644 --- a/src/sdks/manage/src/cpp/sdk/cpptest/Main.cpp +++ b/src/sdks/manage/src/cpp/sdk/cpptest/Main.cpp @@ -1,36 +1,155 @@ - +#include #include "ManageSDKTest.h" void ShowMenu() { - printf("Enter\n" - "\tN : Get Device Name\n" - "\tS : Set Device Name\n" - "\tC : Subscribe/Unsubscribe for Device Name Change\n" - "\tB : Get ClosedCaption Background Opacity\n" - "\tO : Set ClosedCaption Background Opacity\n" - "\tY : Subscribe/Unsubscribe for ClosedCaption Background Opacity Change\n" - "\tF : Get ClosedCaption Font Family\n" - "\tM : Set ClosedCaption Font Family\n" - "\tI : Subscribe/Unsubscribe for ClosedCaption Font Family Change\n" - "\tL : Get Localization Preferred AudioLanguages\n" - "\tA : Set Localization Preferred AudioLanguages\n" - "\tR : Subscribe/Unsubscribe for Localization Preferred AudioLanguages Change\n" -#ifdef RPC_ONLY - "\tP : Subscribe/Unsubscribe for PinChallenge RequestChallenge\n" -#endif + 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()); +} + +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()); +} + void ShowEventMenu() { - printf("Enter\n" - "\tS: Subscribe Event\n" - "\tU: Unsubscribe Event\n" + printf("Options \n" + "\tS : Subscribe Event\n" + "\tU : Unsubscribe Event\n" "\tQ : Quit\n"); } +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; + } + default: + break; + } + } while (opt != 'Q'); +} + +#define VALUE(string) #string +#define TO_STRING(string) VALUE(string) + #define HandleEventListener(Module, eventFuncName) \ { \ int opt; \ @@ -54,21 +173,132 @@ void ShowEventMenu() } 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'); +} + +#define options ":hu:" int main (int argc, char* argv[]) { - char* config = "{\ - \"waitTime\": 1000,\ - \"logLevel\": \"Info\",\ - \"workerPool\":{\ - \"queueSize\": 8,\ - \"threadCount\": 3\ - },\ - \"wsUrl\": \"ws://127.0.0.1:9998\"\ -}"; + int c; + std::string url = "ws://127.0.0.1:9998"; + while ((c = getopt (argc, argv, options)) != -1) { + switch (c) + { + case 'u': + url = optarg; + break; + + case 'h': + printf("./TestFireboltManage -u ws://ip:port\n"); + exit(1); + } + } printf("Firebolt Manage SDK Test\n"); - - ManageSDKTest::CreateFireboltInstance(); + ManageSDKTest::CreateFireboltInstance(url); int option; if (ManageSDKTest::WaitOnConnectionReady() == true) { @@ -77,60 +307,81 @@ int main (int argc, char* argv[]) printf("Enter option : "); option = toupper(getchar()); switch (option) { - case 'N': { - ManageSDKTest::GetDeviceName(); + case 'A': { + HandleProperty(Advertising, SkipRestriction) break; } - case 'S': { - ManageSDKTest::SetDeviceName(); + case 'T': { + ManageSDKTest::SetAccountSession(); break; } - case 'C': { - HandleEventListener(Device, NameChanged) + case 'E': { + HandlePropertyWithEvent(AudioDescriptions, Enabled) + break; + } + case 'N': { + HandlePropertyWithEvent(Device, Name) break; } case 'B': { - ManageSDKTest::GetClosedCaptionBackgroundOpacity(); + HandlePropertyWithEvent(ClosedCaptions, BackgroundOpacity) break; } - case 'O': { - ManageSDKTest::SetClosedCaptionBackgroundOpacity(); + case 'F': { + HandlePropertyWithEvent(ClosedCaptions, FontFamily) break; } - case 'Y': { - HandleEventListener(ClosedCaptions, BackgroundOpacityChanged) + case 'L': { + HandlePropertyWithEvent(Localization, PreferredAudioLanguages) break; } - case 'F': { - ManageSDKTest::GetClosedCaptionFontFamily(); + case 'C': { + HandlePropertyWithEvent(Privacy, AllowACRCollection) break; } - case 'M': { - ManageSDKTest::SetClosedCaptionFontFamily(); + case 'S': { + ManageSDKTest::GetPrivacySettings(); break; } case 'I': { - HandleEventListener(ClosedCaptions, FontFamilyChanged) + HandleEventListener(Discovery, SignInNotification) break; } - case 'L': { - ManageSDKTest::GetLocalizationPreferredAudioLanguages(); + case 'O': { + HandleEventListener(Discovery, SignOutNotification) break; } - case 'A': { - ManageSDKTest::SetLocalizationPreferredAudioLanguages(); + case 'R': { + ManageSDKTest::ResetAdvertisingIdentifier(); break; } - case 'R': { - HandleEventListener(Localization, PreferredAudioLanguagesChanged) + case 'K': { + ManageSDKTest::RegisterKeyboardProvider(); + HandleProviderSequence(Keyboard) + break; + } + case 'G': { + ManageSDKTest::RegisterAcknowledgeChallengeProvider(); + HandleProviderSequence(AcknowledgeChallenge) break; } -#ifdef RPC_ONLY case 'P': { - HandleEventListener(PinChallenge, RequestChallenge) + ManageSDKTest::RegisterPinChallengeProvider(); + HandleProviderSequence(PinChallenge) + break; + } + case 'D': { + HandleAdditionalInfo(); + break; + } + case 'U': { + HandleUserGrants(); + break; + } + case 'W': { + HandleWifiOperations(); break; } -#endif default: break; } diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.cpp b/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.cpp index f5d498518..37197ef87 100644 --- a/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.cpp +++ b/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.cpp @@ -17,17 +17,23 @@ */ #include +#include #include "ManageSDKTest.h" using namespace std; bool ManageSDKTest::_connected; +ManageSDKTest::OnAudioDescriptionsEnabledChangedNotification ManageSDKTest::_audioDescriptionEnabledChangedNotification; ManageSDKTest::OnDeviceNameChangedNotification ManageSDKTest::_deviceNameChangedNotification; ManageSDKTest::OnFontFamilyChangedNotification ManageSDKTest::_fontFamilyChangedNotification; ManageSDKTest::OnBackgroundOpacityChangedNotification ManageSDKTest::_backgroundOpacityChangedNotification; ManageSDKTest::OnPreferredAudioLanguagesChangedNotification ManageSDKTest::_preferredAudioLanguagesChangedNotification; -#ifdef RPC_ONLY -ManageSDKTest::OnRequestChallengeNotification ManageSDKTest::_requestChallengeNotification; -#endif +ManageSDKTest::OnAllowACRCollectionChangedNotification ManageSDKTest::_allowACRCollectionChangedNotification; +ManageSDKTest::OnSignInNotification ManageSDKTest::_signInNotification; +ManageSDKTest::OnSignOutNotification ManageSDKTest::_signOutNotification; +ManageSDKTest::KeyboardProvider ManageSDKTest::_keyboardProvider; +ManageSDKTest::AcknowledgeChallengeProvider ManageSDKTest::_acknowledgeChallengeProvider; +ManageSDKTest::PinChallengeProvider ManageSDKTest::_pinChallengeProvider; +Firebolt::Wifi::AccessPointList ManageSDKTest::_apList; void ManageSDKTest::ConnectionChanged(const bool connected, const Firebolt::Error error) { @@ -35,17 +41,16 @@ void ManageSDKTest::ConnectionChanged(const bool connected, const Firebolt::Erro _connected = connected; } -void ManageSDKTest::CreateFireboltInstance() +void ManageSDKTest::CreateFireboltInstance(const std::string& url) { const std::string config = "{\ - \"waitTime\": 1000,\ + \"waitTime\": 100000,\ \"logLevel\": \"Info\",\ \"workerPool\":{\ \"queueSize\": 8,\ \"threadCount\": 3\ },\ - \"wsUrl\": \"ws://127.0.0.1:9998\"\ - }"; + \"wsUrl\": " + url + "}"; _connected = false; Firebolt::IFireboltAccessor::Instance().Initialize(config); @@ -75,6 +80,132 @@ bool ManageSDKTest::WaitOnConnectionReady() return _connected; } +template +using EnumMap = std::unordered_map; +template +inline const string& ConvertFromEnum(EnumMap enumMap, T type) +{ + return enumMap[type]; +} +template +inline const T ConvertToEnum(EnumMap enumMap, const string& str) +{ + T value; + for (auto element: enumMap) { + if (element.second == str) { + value = element.first; + break; + } + } + return value; +} + +EnumMap skipRestrictionMap = { + { Firebolt::Advertising::SkipRestriction::NONE, "none" }, + { 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; + Firebolt::Advertising::SkipRestriction skipRestriction = Firebolt::IFireboltAccessor::Instance().AdvertisingInterface().skipRestriction(&error); + 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; + } +} +void ManageSDKTest::SetAdvertisingSkipRestriction() +{ + Firebolt::Error error = Firebolt::Error::None; + cout << "Support SkipRestriction -> " << endl; + for (auto skipRestriction : skipRestrictionMap) { + cout << skipRestriction.second << endl; + } + std::string skipRestriction; + cout << "Enter new skipRestriction : "; + cin >> skipRestriction; + + 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; + } +} +void ManageSDKTest::ResetAdvertisingIdentifier() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().AdvertisingInterface().resetIdentifier(&error); + if (error == Firebolt::Error::None) { + cout << "Set Advertising Reset Identifier is success " << endl; + } else { + cout << "Set Advertising Reset Identifier status: " << static_cast(error) << endl; + } +} + +void ManageSDKTest::SetAccountSession() +{ + Firebolt::Error error = Firebolt::Error::None; + std::optional token = "Test"; + std::optional expiresIn = 60; + Firebolt::IFireboltAccessor::Instance().AccountInterface().session(token, expiresIn, &error); + if (error == Firebolt::Error::None) { + cout << "Set Account Session is success" << endl; + } else { + cout << "Set Account Session status : " << static_cast(error) << endl; + } +} + +void ManageSDKTest::GetAudioDescriptionsEnabled() +{ + Firebolt::Error error = Firebolt::Error::None; + bool enabled = Firebolt::IFireboltAccessor::Instance().AudioDescriptionsInterface().enabled(&error); + if (error == Firebolt::Error::None) { + cout << "Get AudioDescriptions Enabled: " << (enabled ? "true" : "false") << endl; + } else { + cout << "Get AudioDescriptions Enabled status: " << static_cast(error) << endl; + } +} +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; + 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; + } +} +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; + Firebolt::IFireboltAccessor::Instance().AudioDescriptionsInterface().subscribe(_audioDescriptionEnabledChangedNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Subscribe AudioDescriptions EnabledChange is success" << endl; + } else { + cout << "Subscribe AudioDescriptions EnabledChange status = " << static_cast(error) << endl; + } +} +void ManageSDKTest::UnsubscribeAudioDescriptionsEnabledChanged() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().AudioDescriptionsInterface().unsubscribe(_audioDescriptionEnabledChangedNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Unsubscribe AudioDescriptions EnabledChange is success" << endl; + } else { + cout << "Unsubscribe AudioDescriptions EnabledChange status = " << static_cast(error) << endl; + } +} + void ManageSDKTest::GetDeviceName() { Firebolt::Error error = Firebolt::Error::None; @@ -86,24 +217,26 @@ void ManageSDKTest::GetDeviceName() cout << "Get Device Name status = " << static_cast(error) << endl; } } - void ManageSDKTest::SetDeviceName() { Firebolt::Error error = Firebolt::Error::None; - Firebolt::IFireboltAccessor::Instance().DeviceInterface().setName("Hello", &error); + std::string name; + cout << "Enter new device name :"; + getchar(); + getline(cin, name); + Firebolt::IFireboltAccessor::Instance().DeviceInterface().setName(name, &error); if (error == Firebolt::Error::None) { cout << "Set Device Name is success" << endl; } else { cout << "Set Device Name status = " << static_cast(error) << endl; } + cin.putback('\n'); } - void ManageSDKTest::OnDeviceNameChangedNotification::onDeviceNameChanged( const std::string& name ) { cout << "Name changed, new name --> " << name << endl; } - void ManageSDKTest::SubscribeDeviceNameChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -114,7 +247,6 @@ void ManageSDKTest::SubscribeDeviceNameChanged() cout << "Subscribe Device NameChange status = " << static_cast(error) << endl; } } - void ManageSDKTest::UnsubscribeDeviceNameChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -126,7 +258,7 @@ void ManageSDKTest::UnsubscribeDeviceNameChanged() } } -void ManageSDKTest::GetClosedCaptionBackgroundOpacity() +void ManageSDKTest::GetClosedCaptionsBackgroundOpacity() { Firebolt::Error error = Firebolt::Error::None; const float value = Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().backgroundOpacity(&error); @@ -137,11 +269,14 @@ void ManageSDKTest::GetClosedCaptionBackgroundOpacity() cout << "Get ClosedCaption BackgroundOpacity status = " << static_cast(error) << endl; } } - -void ManageSDKTest::SetClosedCaptionBackgroundOpacity() +void ManageSDKTest::SetClosedCaptionsBackgroundOpacity() { Firebolt::Error error = Firebolt::Error::None; - Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().setBackgroundOpacity(2.0, &error); + uint32_t bgOpacity; + cout << "Enter new background opacity: "; + scanf("%d", &bgOpacity); + + Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().setBackgroundOpacity(bgOpacity, &error); if (error == Firebolt::Error::None) { cout << "Set ClosedCaption BackgroundOpacity is success" << endl; @@ -149,12 +284,10 @@ void ManageSDKTest::SetClosedCaptionBackgroundOpacity() cout << "Set ClosedCaption BackgroundOpacity status = " << static_cast(error) << endl; } } - void ManageSDKTest::OnBackgroundOpacityChangedNotification::onBackgroundOpacityChanged( const float opacity ) { cout << "BackgroundOpacity changed, new value --> " << opacity << endl; } - void ManageSDKTest::SubscribeClosedCaptionsBackgroundOpacityChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -165,7 +298,6 @@ void ManageSDKTest::SubscribeClosedCaptionsBackgroundOpacityChanged() cout << "Subscribe ClosedCaptions BackgroundOpacityChange status = " << static_cast(error) << endl; } } - void ManageSDKTest::UnsubscribeClosedCaptionsBackgroundOpacityChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -177,49 +309,48 @@ void ManageSDKTest::UnsubscribeClosedCaptionsBackgroundOpacityChanged() } } -using FontFamilyMap = std::unordered_map; -FontFamilyMap fontFamilyMap = { +EnumMap fontFamilyMap = { { Firebolt::Accessibility::FontFamily::MONOSPACED_SERIF, "MonospacedSerif" }, { Firebolt::Accessibility::FontFamily::PROPORTIONAL_SERIF, "ProportionalSerif" }, { Firebolt::Accessibility::FontFamily::MONOSPACED_SANSERIF, "MonospacedSanserif" }, { Firebolt::Accessibility::FontFamily::PROPORTIONAL_SANSERIF, "ProportionalSanserif" }, { Firebolt::Accessibility::FontFamily::SMALLCAPS, "SmallCaps" }, { Firebolt::Accessibility::FontFamily::CURSIVE, "Cursive" }, - { Firebolt::Accessibility::FontFamily::CASUAL, "Casual" }}; -inline const string& ConvertToFontFamilyStr(Firebolt::Accessibility::FontFamily family) -{ - return fontFamilyMap[family]; -} - -void ManageSDKTest::GetClosedCaptionFontFamily() + { Firebolt::Accessibility::FontFamily::CASUAL, "Casual" } +}; +void ManageSDKTest::GetClosedCaptionsFontFamily() { Firebolt::Error error = Firebolt::Error::None; const Firebolt::Accessibility::FontFamily value = Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().fontFamily(&error); if (error == Firebolt::Error::None) { - cout << "Get ClosedCaption FontFamily value = " << ConvertToFontFamilyStr(value) << endl; + cout << "Get ClosedCaption FontFamily value = " << ConvertFromEnum(fontFamilyMap, value) << endl; } else { cout << "Get ClosedCaption FontFamily status = " << static_cast(error) << endl; } } - -void ManageSDKTest::SetClosedCaptionFontFamily() +void ManageSDKTest::SetClosedCaptionsFontFamily() { Firebolt::Error error = Firebolt::Error::None; - Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().setFontFamily(Firebolt::Accessibility::FontFamily::PROPORTIONAL_SANSERIF, &error); + std::string fontFamily; + cout << "Supported font family -> " << endl; + for (auto family : fontFamilyMap) { + cout << family.second << endl; + } + cout << "Enter new font family : "; + cin >> fontFamily; + Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().setFontFamily(ConvertToEnum(fontFamilyMap, fontFamily), &error); if (error == Firebolt::Error::None) { cout << "Set ClosedCaption FontFamily is success" << endl; } else { cout << "Set ClosedCaption FontFamily status = " << static_cast(error) << endl; } } - void ManageSDKTest::OnFontFamilyChangedNotification::onFontFamilyChanged( const Firebolt::Accessibility::FontFamily& family ) { - cout << "FontFamily changed, new code --> " << ConvertToFontFamilyStr(family) << endl; + cout << "FontFamily changed, new code --> " << ConvertFromEnum(fontFamilyMap, family) << endl; } - void ManageSDKTest::SubscribeClosedCaptionsFontFamilyChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -230,7 +361,6 @@ void ManageSDKTest::SubscribeClosedCaptionsFontFamilyChanged() cout << "Subscribe ClosedCaptions FontFamilyChange status = " << static_cast(error) << endl; } } - void ManageSDKTest::UnsubscribeClosedCaptionsFontFamilyChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -256,28 +386,43 @@ void ManageSDKTest::GetLocalizationPreferredAudioLanguages() cout << "Get Localization PreferredAudioLanguages status = " << static_cast(error) << endl; } } - void ManageSDKTest::SetLocalizationPreferredAudioLanguages() { Firebolt::Error error = Firebolt::Error::None; - const std::vector languages = { "ara", "jpn", "hin" }; - Firebolt::IFireboltAccessor::Instance().LocalizationInterface().setPreferredAudioLanguages(languages, &error); + 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; + 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; } else { cout << "Get Localization PreferredAudioLanguages status = " << static_cast(error) << endl; } + 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; @@ -288,7 +433,6 @@ void ManageSDKTest::SubscribeLocalizationPreferredAudioLanguagesChanged() cout << "Subscribe Localization PreferredAudioLanguagesChange status = " << static_cast(error) << endl; } } - void ManageSDKTest::UnsubscribeLocalizationPreferredAudioLanguagesChanged() { Firebolt::Error error = Firebolt::Error::None; @@ -300,45 +444,536 @@ void ManageSDKTest::UnsubscribeLocalizationPreferredAudioLanguagesChanged() } } -#ifdef RPC_ONLY -using PinSpaceMap = std::unordered_map; -PinSpaceMap pinSpaceMap = { - { Firebolt::PinChallenge::PinChallengePinSpace::PURCHASE, "Purchase" }, - { Firebolt::PinChallenge::PinChallengePinSpace::CONTENT, "Content" }}; -inline const string& ConvertToPinSpaceStr(Firebolt::PinChallenge::PinChallengePinSpace pinSpace) +void ManageSDKTest::GetPrivacyAllowACRCollection() { - return pinSpaceMap[pinSpace]; + Firebolt::Error error = Firebolt::Error::None; + bool allowACRCollection = Firebolt::IFireboltAccessor::Instance().PrivacyInterface().allowACRCollection(&error); + + if (error == Firebolt::Error::None) { + cout << "Get Privacy AllowACRCollection : " << (allowACRCollection ? "true" : "false") << endl; + } else { + cout << "Get Privacy AllowACRCollection status = " << static_cast(error) << endl; + } } +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); -void ManageSDKTest::OnRequestChallengeNotification::onRequestChallenge( const Firebolt::PinChallenge::PinChallengeProviderRequest& pinChallenge ) + if (error == Firebolt::Error::None) { + cout << "Set Privacy AllowACRCollection is success" << endl; + } else { + cout << "Get Privacy AllowACRCollection status = " << static_cast(error) << endl; + } +} +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; + Firebolt::IFireboltAccessor::Instance().PrivacyInterface().subscribe(_allowACRCollectionChangedNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Subscribe Privacy AllowACRCollectionChanged is success" << endl; + } else { + cout << "Subscribe Privacy AllowACRCollectionChanged status = " << static_cast(error) << endl; + } +} +void ManageSDKTest::UnsubscribePrivacyAllowACRCollectionChanged() { - cout << "RequestChallenge, new challenge --> " << endl; - cout << "CorrelationId : " << pinChallenge.correlationId << endl; - cout << "PinChallenge.ChallengeRequestor.Id : " << pinChallenge.parameters.requestor.id << endl; - cout << "PinChallenge.ChallengeRequestor.Name : " << pinChallenge.parameters.requestor.name << endl; - cout << "PinChallenge.PinChallengePinSpace : " << ConvertToPinSpaceStr(pinChallenge.parameters.pinSpace) << endl; - cout << "PinChallenge.Capability : " << *(pinChallenge.parameters.capability) << endl; + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().PrivacyInterface().unsubscribe(_allowACRCollectionChangedNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Unsubscribe Privacy AllowACRCollectionChanged is success" << endl; + } else { + cout << "Unsubscribe Privacy AllowACRCollectionChanged status = " << static_cast(error) << endl; + } } +void ManageSDKTest::GetPrivacySettings() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::Privacy::PrivacySettings privacySettings = Firebolt::IFireboltAccessor::Instance().PrivacyInterface().settings(&error); -void ManageSDKTest::SubscribePinChallengeRequestChallenge() + if (error == Firebolt::Error::None) { + cout << "Get Privacy Settings -> " << endl; + cout << "\tallowACRCollection : " << privacySettings.allowACRCollection << endl; + cout << "\tallowResumePoints : " << privacySettings.allowResumePoints << endl; + cout << "\tallowAppContentAdTargeting : " << privacySettings.allowAppContentAdTargeting << endl; + cout << "\tallowCameraAnalytics : " << privacySettings.allowCameraAnalytics << endl; + cout << "\tallowPersonalization : " << privacySettings.allowPersonalization << endl; + cout << "\tallowPrimaryBrowseAdTargeting : " << privacySettings.allowPrimaryBrowseAdTargeting << endl; + cout << "\tallowPrimaryContentAdTargeting : " << privacySettings.allowPrimaryContentAdTargeting << endl; + cout << "\tallowProductAnalytics : " << privacySettings.allowProductAnalytics << endl; + cout << "\tallowRemoteDiagnostics : " << privacySettings.allowRemoteDiagnostics << endl; + cout << "\tallowUnentitledPersonalization : " << privacySettings.allowUnentitledPersonalization << endl; + cout << "\tallowUnentitledResumePoints : " << privacySettings.allowUnentitledResumePoints << endl; + cout << "\tallowWatchHistory : " << privacySettings.allowWatchHistory << endl; + } else { + cout << "Get Privacy Settings status = " << static_cast(error) << endl; + } + +} + +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; + Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().subscribe(_signInNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Subscribe Discovery SignIn Notification is success" << endl; + } else { + cout << "Subscribe Discovery SignIn Notification status = " << static_cast(error) << endl; + } +} +void ManageSDKTest::UnsubscribeDiscoverySignInNotification() { Firebolt::Error error = Firebolt::Error::None; - Firebolt::IFireboltAccessor::Instance().PinChallengeInterface().subscribe(_requestChallengeNotification, &error); + Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().unsubscribe(_signInNotification, &error); if (error == Firebolt::Error::None) { - cout << "Subscribe PinChallenge RequestChallenge is success" << endl; + cout << "Unsubscribe Discovery SignIn Notification is success" << endl; } else { - cout << "Subscribe PinChallenge RequestChallenge status = " << static_cast(error) << endl; + cout << "Unsubscribe Discovery SignIn Notification status = " << static_cast(error) << endl; } } -void ManageSDKTest::UnsubscribePinChallengeRequestChallenge() +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; + Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().subscribe(_signOutNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Subscribe Discovery SignOut Notification is success" << endl; + } else { + cout << "Subscribe Discovery SignOut Notification status = " << static_cast(error) << endl; + } +} +void ManageSDKTest::UnsubscribeDiscoverySignOutNotification() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().unsubscribe(_signOutNotification, &error); + if (error == Firebolt::Error::None) { + cout << "Unsubscribe Discovery SignOut Notification is success" << endl; + } else { + cout << "Unsubscribe Discovery SignOut Notification status = " << static_cast(error) << endl; + } +} + +ManageSDKTest::KeyboardProvider::KeyboardProvider() + : _session(nullptr) + , _parameters() + , _keyInput(false) +{ +} +void ManageSDKTest::KeyboardProvider::SendMessage(bool response) +{ + if (_keyInput) { + cout << " Invoking _session->focus " << endl; + _session->focus(); + getchar(); + + string key; + cout << _parameters.message << " : "; + getline(cin, key); + if (response) { + Firebolt::Keyboard::KeyboardResult keyboardResult; + keyboardResult.text = key; + keyboardResult.canceled = false; + cout << " Invoking _session->result " << endl; + _session->result(keyboardResult); + } else { + Firebolt::Keyboard::KeyboardError keyboardError; + keyboardError.code = 123; + keyboardError.message = key; + keyboardError.data = "nothing to send"; + cout << " Invoking _session->error " << endl; + _session->error(keyboardError); + } + _keyInput = false; + cin.putback('\n'); + } else { + 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 ) +{ + _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); +} + +ManageSDKTest::AcknowledgeChallengeProvider::AcknowledgeChallengeProvider() + : _session(nullptr) + , _parameters() + , _challengeInput(false) +{ +} +void ManageSDKTest::AcknowledgeChallengeProvider::SendMessage(bool response) +{ + if (_challengeInput) { + cout << " Invoking _session->focus " << endl; + _session->focus(); + cout << " capability : " << _parameters.capability << endl; + cout << " id : " << _parameters.requestor.id << endl; + cout << " name : " << _parameters.requestor.name << endl; + if (response) { + Firebolt::AcknowledgeChallenge::GrantResult challengeResult; + challengeResult.granted = true; + cout << " Invoking _session->result " << endl; + _session->result(challengeResult); + } else { + string key; + getline(cin, key); + + Firebolt::AcknowledgeChallenge::AcknowledgeChallengeError challengeError; + challengeError.code = 234; + challengeError.message = key; + cout << " Invoking _session->error " << endl; + _session->error(challengeError); + cin.putback('\n'); + } + _challengeInput = false; + } else { + 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 ) +{ + _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); +} + +ManageSDKTest::PinChallengeProvider::PinChallengeProvider() + : _session(nullptr) + , _parameters() + , _challengeInput(false) +{ +} +void ManageSDKTest::PinChallengeProvider::SendMessage(bool response) +{ + if (_challengeInput) { + cout << " Invoking _session->focus " << endl; + _session->focus(); + cout << " pinSpace : " << static_cast(_parameters.pinSpace) << endl; + if (_parameters.capability.has_value()) { + cout << " capability : " << _parameters.capability.value() << endl; + } + cout << " id : " << _parameters.requestor.id << endl; + cout << " name : " << _parameters.requestor.name << endl; + + if (response) { + Firebolt::PinChallenge::PinChallengeResult challengeResult; + challengeResult.granted = true; + challengeResult.reason = Firebolt::PinChallenge::ResultReason::CORRECT_PIN; + cout << " Invoking _session->result " << endl; + _session->result(challengeResult); + } else { + string key; + getline(cin, key); + + Firebolt::PinChallenge::PinChallengeError challengeError; + challengeError.code = 234; + challengeError.message = key; + cout << " Invoking _session->error " << endl; + _session->error(challengeError); + cin.putback('\n'); + } + _challengeInput = false; + } else { + 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 ) +{ + _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); +} + +void ManageSDKTest::GetLocalizationAdditionalInfo() +{ + Firebolt::Error error = Firebolt::Error::None; + Firebolt::Localization::Info info = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().additionalInfo(&error); + if (error == Firebolt::Error::None) { + cout << "AdditionalInfo is success, Info : " << endl; + for (auto element : info) { + cout << " " << element.first << " : " << element.second << endl; + } + } else { + cout << "AdditionalInfo call status = " << static_cast(error) << endl; + } +} +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); + + 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; + } + + 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); + + 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; + } + + cin.putback('\n'); +} + +void ManageSDKTest::GetUserGrantsPermission() +{ + Firebolt::Error error = Firebolt::Error::None; + cout << "Enter appId :"; + getchar(); + std::string appId; + getline(cin, appId); + + 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) { + cout << "Grant Permission list : " << endl; + for (auto info : grantInfo) { + cout << "GrantState : " << static_cast(info.state) << endl; + cout << "Capability : " << info.capability << endl; + cout << "Role : " << static_cast(info.role) << endl; + cout << "Lifespan : " << static_cast(info.lifespan) << endl; + } + } + } else { + cout << "Get UserGrants Permission status = " << static_cast(error) << endl; + } + + 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); + 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; + } + + 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); + 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; + } + + 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); + 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; + } + + cin.putback('\n'); +} + +void PrintAP(const Firebolt::Wifi::AccessPoint ap) +{ + if (ap.ssid.has_value()) { + cout << " SSID : " << ap.ssid.value() << endl; + } + if (ap.securityMode.has_value()) { + cout << " SecurityMode : " << static_cast(ap.securityMode.value()) << endl; + } + if (ap.signalStrength.has_value()) { + cout << " SignalStrength : " << ap.signalStrength.value() << endl; + } + if (ap.frequency.has_value()) { + cout << " Frequency : " << ap.frequency.value() << endl; + } +} +void PrintAPList(const Firebolt::Wifi::AccessPointList& apList) +{ + if (apList.list.has_value()) { + cout<< "list ---->" << endl; + uint32_t index = 0; + for (const auto ap : apList.list.value()) { + cout << index << ". " << endl; + PrintAP(ap); + cout << endl; + index++; + } + } else { + cout << "empty list " << endl; + } +} +void ManageSDKTest::WifiScan() +{ + Firebolt::Error error = Firebolt::Error::None; + 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; + } +} +void ManageSDKTest::WifiConnect() +{ + Firebolt::Error error = Firebolt::Error::None; + if (_apList.list.has_value()) { + cout << "Scanned access pointlist : " << endl; + PrintAPList(_apList); + cout << "Select access point from the list: enter index : "; + int32_t index; + cin >> index; + Firebolt::Wifi::AccessPoint ap = _apList.list.value()[index]; + std::string passphrase; + cout << "Enter passphrase to connect "; + cin >> passphrase; + + string ssid = ap.ssid.has_value() ? ap.ssid.value() : ""; + printf("%s:%s:%d _apList.list.value()[index] = %s\n", __FILE__, __func__, __LINE__, ssid.c_str()); + Firebolt::Wifi::WifiSecurityMode securityMode = ap.securityMode.has_value() ? ap.securityMode.value() : Firebolt::Wifi::WifiSecurityMode::NONE; + Firebolt::Wifi::AccessPoint connectedAP = Firebolt::IFireboltAccessor::Instance().WifiInterface().connect(ssid, passphrase, securityMode , &error); + if (error == Firebolt::Error::None) { + cout << "Wifi Connect is success, "; + PrintAP(connectedAP); + } else { + cout << "Wifi Connect status = " << static_cast(error) << endl; + } + } else { + cout << "Empty AP list, please initiate scan before trying connect " << endl; + } +} +void ManageSDKTest::WifiDisconnect() { Firebolt::Error error = Firebolt::Error::None; - Firebolt::IFireboltAccessor::Instance().PinChallengeInterface().unsubscribe(_requestChallengeNotification, &error); + Firebolt::IFireboltAccessor::Instance().WifiInterface().disconnect(&error); if (error == Firebolt::Error::None) { - cout << "Unsubscribe PinChallenge RequestChallenge is success" << endl; + cout << "Wifi Disconnect is success, "; } else { - cout << "Unsubscribe PinChallenge RequestChallenge status = " << static_cast(error) << endl; + cout << "Wifi Disconnect status = " << static_cast(error) << endl; } } -#endif diff --git a/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.h b/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.h index 894aa3324..2f8be7145 100644 --- a/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.h +++ b/src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.h @@ -22,6 +22,10 @@ #include "firebolt.h" class ManageSDKTest { + class OnAudioDescriptionsEnabledChangedNotification : public Firebolt::AudioDescriptions::IAudioDescriptions::IOnEnabledChangedNotification { + public: + void onEnabledChanged( const bool ) override; + }; class OnDeviceNameChangedNotification : public Firebolt::Device::IDevice::IOnDeviceNameChangedNotification { public: @@ -41,50 +45,161 @@ class ManageSDKTest { void onPreferredAudioLanguagesChanged( const std::vector& ) override; }; -#ifdef RPC_ONLY - struct OnRequestChallengeNotification : public Firebolt::PinChallenge::IPinChallenge::IOnRequestChallengeNotification { + class OnAllowACRCollectionChangedNotification : public Firebolt::Privacy::IPrivacy::IOnAllowACRCollectionChangedNotification { + public: + void onAllowACRCollectionChanged( const bool ) override; + }; + + class OnSignInNotification : public Firebolt::Discovery::IDiscovery::IOnSignInNotification { + public: + void onSignIn( const Firebolt::Discovery::Event& ) override; + }; + + class OnSignOutNotification : public Firebolt::Discovery::IDiscovery::IOnSignOutNotification { + public: + void onSignOut( const Firebolt::Discovery::Event& ) override; + }; + + class KeyboardProvider : public Firebolt::Keyboard::IKeyboardProvider { + public: + KeyboardProvider(); + ~KeyboardProvider() override = default; + void standard( const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr session ) override; + void password( const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr session ) override; + void email( const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr session ) override; + void SendMessage(bool response); + + private: + void startKeyboardSession(const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr session); + + private: + std::unique_ptr _session; + Firebolt::Keyboard::KeyboardParameters _parameters; + bool _keyInput; + }; + class AcknowledgeChallengeProvider : public Firebolt::AcknowledgeChallenge::IAcknowledgeChallengeProvider { public: - void onRequestChallenge( const Firebolt::PinChallenge::PinChallengeProviderRequest& ) override; + AcknowledgeChallengeProvider(); + ~AcknowledgeChallengeProvider() override = default; + void challenge( const Firebolt::AcknowledgeChallenge::Challenge& parameters, std::unique_ptr session ) override; + void SendMessage(bool response); + + private: + void startAcknowledgeChallengeSession(const Firebolt::AcknowledgeChallenge::Challenge& parameters, std::unique_ptr session); + + private: + std::unique_ptr _session; + Firebolt::AcknowledgeChallenge::Challenge _parameters; + bool _challengeInput; }; -#endif + class PinChallengeProvider : public Firebolt::PinChallenge::IPinChallengeProvider { + public: + PinChallengeProvider(); + ~PinChallengeProvider() override = default; + void challenge( const Firebolt::PinChallenge::PinChallenge& parameters, std::unique_ptr session ) override; + void SendMessage(bool response); + + private: + void startPinChallengeSession(const Firebolt::PinChallenge::PinChallenge& parameters, std::unique_ptr session); + + private: + std::unique_ptr _session; + Firebolt::PinChallenge::PinChallenge _parameters; + bool _challengeInput; + }; + public: ManageSDKTest() = default; virtual ~ManageSDKTest() = default; - static void CreateFireboltInstance(); + static void CreateFireboltInstance(const std::string& url); static void DestroyFireboltInstance(); static void TestManageStaticSDK(); + + static void GetAdvertisingSkipRestriction(); + static void SetAdvertisingSkipRestriction(); + static void ResetAdvertisingIdentifier(); + + static void SetAccountSession(); + + static void GetAudioDescriptionsEnabled(); + static void SetAudioDescriptionsEnabled(); + static void SubscribeAudioDescriptionsEnabledChanged(); + static void UnsubscribeAudioDescriptionsEnabledChanged(); + static void GetDeviceName(); static void SetDeviceName(); static void SubscribeDeviceNameChanged(); static void UnsubscribeDeviceNameChanged(); - static void GetClosedCaptionBackgroundOpacity(); - static void SetClosedCaptionBackgroundOpacity(); + + static void GetClosedCaptionsBackgroundOpacity(); + static void SetClosedCaptionsBackgroundOpacity(); static void SubscribeClosedCaptionsBackgroundOpacityChanged(); static void UnsubscribeClosedCaptionsBackgroundOpacityChanged(); - static void GetClosedCaptionFontFamily(); - static void SetClosedCaptionFontFamily(); + + static void GetClosedCaptionsFontFamily(); + static void SetClosedCaptionsFontFamily(); static void SubscribeClosedCaptionsFontFamilyChanged(); static void UnsubscribeClosedCaptionsFontFamilyChanged(); + static void GetLocalizationPreferredAudioLanguages(); static void SetLocalizationPreferredAudioLanguages(); static void SubscribeLocalizationPreferredAudioLanguagesChanged(); static void UnsubscribeLocalizationPreferredAudioLanguagesChanged(); -#ifdef RPC_ONLY - static void SubscribePinChallengeRequestChallenge(); - static void UnsubscribePinChallengeRequestChallenge(); -#endif + + static void GetPrivacyAllowACRCollection(); + static void SetPrivacyAllowACRCollection(); + static void SubscribePrivacyAllowACRCollectionChanged(); + static void UnsubscribePrivacyAllowACRCollectionChanged(); + static void GetPrivacySettings(); + + static void SubscribeDiscoverySignInNotification(); + static void UnsubscribeDiscoverySignInNotification(); + static void SubscribeDiscoverySignOutNotification(); + static void UnsubscribeDiscoverySignOutNotification(); + + static void RegisterKeyboardProvider(); + static void SendResponseMessageToKeyboardProvider(); + static void SendErrorMessageToKeyboardProvider(); + + static void RegisterAcknowledgeChallengeProvider(); + static void SendResponseMessageToAcknowledgeChallengeProvider(); + static void SendErrorMessageToAcknowledgeChallengeProvider(); + + static void RegisterPinChallengeProvider(); + static void SendResponseMessageToPinChallengeProvider(); + static void SendErrorMessageToPinChallengeProvider(); + + static void GetLocalizationAdditionalInfo(); + static void AddLocalizationAdditionalInfo(); + static void RemoveLocalizationAdditionalInfo(); + + static void GetUserGrantsPermission(); + static void GrantUserGrantsPermission(); + static void DenyUserGrantsPermission(); + static void ClearUserGrantsPermission(); + + static void WifiScan(); + static void WifiConnect(); + static void WifiDisconnect(); + static bool WaitOnConnectionReady(); private: static void ConnectionChanged(const bool, const Firebolt::Error); static bool _connected; + static OnAudioDescriptionsEnabledChangedNotification _audioDescriptionEnabledChangedNotification; static OnDeviceNameChangedNotification _deviceNameChangedNotification; static OnFontFamilyChangedNotification _fontFamilyChangedNotification; static OnBackgroundOpacityChangedNotification _backgroundOpacityChangedNotification; static OnPreferredAudioLanguagesChangedNotification _preferredAudioLanguagesChangedNotification; -#ifdef RPC_ONLY - static OnRequestChallengeNotification _requestChallengeNotification; -#endif + static OnAllowACRCollectionChangedNotification _allowACRCollectionChangedNotification; + static KeyboardProvider _keyboardProvider; + static AcknowledgeChallengeProvider _acknowledgeChallengeProvider; + static PinChallengeProvider _pinChallengeProvider; + static OnSignInNotification _signInNotification; + static OnSignOutNotification _signOutNotification; + + static Firebolt::Wifi::AccessPointList _apList; };