diff --git a/package-lock.json b/package-lock.json index ee2a731a0..55f6248eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "devDependencies": { "@commitlint/cli": "^17.0.3", "@commitlint/config-conventional": "^17.0.3", - "@firebolt-js/openrpc": "2.0.4", + "@firebolt-js/openrpc": "2.1.0-next.1", "@firebolt-js/schemas": "1.0.0-next.0", "@semantic-release/changelog": "^6.0.1", "@semantic-release/git": "^10.0.1", @@ -1045,9 +1045,9 @@ "link": true }, "node_modules/@firebolt-js/openrpc": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@firebolt-js/openrpc/-/openrpc-2.0.4.tgz", - "integrity": "sha512-jMdLillhMZA1hXol4KGb68XMT44TnbDoiJZLvcVOqT6eH/SgpPb5NSDFsGTu9awGy+eYZh/eIdWg+prwUvmoVQ==", + "version": "2.1.0-next.1", + "resolved": "https://registry.npmjs.org/@firebolt-js/openrpc/-/openrpc-2.1.0-next.1.tgz", + "integrity": "sha512-nO9ria6cXFs8eOzLlW/xupZCwqcVDfgi2SL1eIlh002+/xPkBDPzE79zOZ9DoIbDi30L6TrAyGSWNSQoma/Igw==", "dev": true, "dependencies": { "ajv": "^8.3.0", @@ -12753,7 +12753,7 @@ }, "src/sdks/core": { "name": "@firebolt-js/sdk", - "version": "0.16.0", + "version": "0.17.0-next.1", "license": "Apache-2.0", "devDependencies": { "jest": "^28.1.0", @@ -12763,7 +12763,7 @@ }, "src/sdks/manage": { "name": "@firebolt-js/manage-sdk", - "version": "0.16.0", + "version": "0.17.0-next.1", "license": "Apache-2.0", "devDependencies": { "jest": "^28.1.0", diff --git a/package.json b/package.json index 22c6bd7c1..db0f6b101 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "devDependencies": { "@commitlint/cli": "^17.0.3", "@commitlint/config-conventional": "^17.0.3", - "@firebolt-js/openrpc": "2.0.4", + "@firebolt-js/openrpc": "2.1.0-next.1", "@firebolt-js/schemas": "1.0.0-next.0", "@semantic-release/changelog": "^6.0.1", "@semantic-release/git": "^10.0.1", diff --git a/src/openrpc/capabilities.json b/src/openrpc/capabilities.json index 892f0e493..e2b35f8af 100644 --- a/src/openrpc/capabilities.json +++ b/src/openrpc/capabilities.json @@ -563,7 +563,7 @@ } ], "result": { - "name": "Default Result", + "name": "request", "summary": "Returns an array of CapabilityInfo objects for the passed in capabilities.", "schema": { "type": "array", @@ -907,4 +907,4 @@ } } } -} \ 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/ctest/CMakeLists.txt new file mode 100644 index 000000000..c87f15662 --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/ctest/CMakeLists.txt @@ -0,0 +1,70 @@ +# 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 + +cmake_minimum_required(VERSION 3.3) + +project(FireboltCoreSDKTests) + +if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${SYSROOT_PATH}/usr" CACHE INTERNAL "" FORCE) + set(CMAKE_PREFIX_PATH ${SYSROOT_PATH}/usr/lib/cmake CACHE INTERNAL "" FORCE) +endif() + +list(APPEND CMAKE_MODULE_PATH + "${SYSROOT_PATH}/usr/lib/cmake" + "${SYSROOT_PATH}/tools/cmake") +message("FIREBOLT_PATH inside cmake " ${FIREBOLT_PATH}) +if (FIREBOLT_PATH) + set(CMAKE_FIREBOLT_PATH + "${FIREBOLT_PATH}/usr/lib/cmake/Firebolt" + "${FIREBOLT_PATH}/usr/lib/cmake/FireboltSDK") + list(APPEND CMAKE_PREFIX_PATH ${CMAKE_FIREBOLT_PATH}) + list(APPEND CMAKE_MODULE_PATH ${CMAKE_FIREBOLT_PATH}) +else () + set(FIREBOLT_PATH "${SYSROOT_PATH}" CACHE INTERNAL "" FORCE) +endif () + +find_package(WPEFramework CONFIG REQUIRED) +find_package(${NAMESPACE}Core CONFIG REQUIRED) +find_package(Firebolt CONFIG REQUIRED) +find_package(${FIREBOLT_NAMESPACE}SDK CONFIG REQUIRED) + +set(TESTAPP TestFireboltCore) + +message("Setup ${TESTAPP}") + +add_executable(${TESTAPP} main.c) + +target_link_libraries(${TESTAPP} + PRIVATE + ${NAMESPACE}Core::${NAMESPACE}Core + ${FIREBOLT_NAMESPACE}SDK::${FIREBOLT_NAMESPACE}SDK +) + +target_include_directories(${TESTAPP} + PRIVATE + $ + $ + $ +) + +add_custom_command( + TARGET ${TESTAPP} + POST_BUILD + COMMENT "=================== Installing TestApp ======================" + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/${FIREBOLT_NAMESPACE}/usr/bin + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${TESTAPP} ${CMAKE_BINARY_DIR}/${FIREBOLT_NAMESPACE}/usr/bin +) diff --git a/src/sdks/core/src/cpp/sdk/ctest/build.sh b/src/sdks/core/src/cpp/sdk/ctest/build.sh new file mode 100755 index 000000000..4db39cbe8 --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/ctest/build.sh @@ -0,0 +1,40 @@ +#!/bin/bash +usage() +{ + echo "options:" + echo " -t test path" + echo " -s sysroot path" + echo " -f firebolt path" + echo " -c clear build" + echo " -h : help" + echo + echo "usage: " + echo " ./build.sh -t testpath -c -f fireboltpath -s sysrootpath" +} + +TestPath="." +FireboltPath=${FIREBOLT_PATH} +SysrootPath=${SYSROOT_PATH} +ClearBuild="N" +while getopts t:s:f:ch flag +do + case "${flag}" in + t) TestPath="${OPTARG}";; + s) SysrootPath="${OPTARG}";; + f) FireboltPath="${OPTARG}";; + c) ClearBuild="Y";; + h) usage && exit 1;; + esac +done + +if [ "${ClearBuild}" == "Y" ]; +then + rm -rf ${TestPath}/build +fi + +echo "TestPath" +echo "${TestPath}" +echo "FireboltPath" +echo ${FireboltPath} +cmake -B${TestPath}/build -S${TestPath} -DSYSROOT_PATH=${SysrootPath} -DFIREBOLT_PATH=${FireboltPath} +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 new file mode 100644 index 000000000..6e6dbf020 --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/ctest/main.c @@ -0,0 +1,470 @@ +#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 new file mode 100644 index 000000000..9242ea10e --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/test/CMakeLists.txt @@ -0,0 +1,85 @@ +# 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 + +cmake_minimum_required(VERSION 3.3) + +project(FireboltCoreSDKTests) +project_version(1.0.0) + +set(TESTLIB ${PROJECT_NAME}) + +message("Setup ${TESTLIB} v${PROJECT_VERSION}") + +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) + +target_link_libraries(${TESTLIB} + PRIVATE + ${FIREBOLT_NAMESPACE}SDK::${FIREBOLT_NAMESPACE}SDK + ${NAMESPACE}Core::${NAMESPACE}Core +) + +target_include_directories(${TESTLIB} + PRIVATE + $ + $ + $ + $ +) + +set_target_properties(${TESTLIB} PROPERTIES + CXX_STANDARD 11 + CXX_STANDARD_REQUIRED YES + LINK_WHAT_YOU_USE TRUE + FRAMEWORK FALSE +) + +set(TESTAPP FireboltCoreSDKTestApp) + +message("Setup ${TESTAPP} v${PROJECT_VERSION}") + +add_executable(${TESTAPP} Main.c) + +target_link_libraries(${TESTAPP} + PRIVATE + ${TESTLIB} +) + +target_include_directories(${TESTAPP} + PRIVATE + $ + $ + $ +) + +install( + TARGETS ${TESTLIB} EXPORT ${TESTLIB}Targets + ARCHIVE DESTINATION lib COMPONENT libs # static lib + LIBRARY DESTINATION lib COMPONENT libs # shared lib +) + +InstallCMakeConfig(TARGETS ${TESTLIB}) + +add_custom_command( + TARGET ${TESTAPP} + POST_BUILD + COMMENT "=================== Installing TestApp ======================" + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/${FIREBOLT_NAMESPACE}/usr/bin + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${TESTAPP} ${CMAKE_BINARY_DIR}/${FIREBOLT_NAMESPACE}/usr/bin +) diff --git a/src/sdks/core/src/cpp/sdk/test/CoreSDKCTests.h b/src/sdks/core/src/cpp/sdk/test/CoreSDKCTests.h new file mode 100644 index 000000000..a6592156c --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/test/CoreSDKCTests.h @@ -0,0 +1,35 @@ +/* + * 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 + */ + +#ifndef CORESDK_C_TESTS_H +#define CORESDK_C_TESTS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int32_t test_firebolt_core_main(); +int32_t test_properties_get_policy(); + +#ifdef __cplusplus +} +#endif + +#endif //CORESDK_C_TESTS_H diff --git a/src/sdks/core/src/cpp/sdk/test/CoreSDKTestGeneratedCode.c b/src/sdks/core/src/cpp/sdk/test/CoreSDKTestGeneratedCode.c new file mode 100644 index 000000000..cbb0fa76c --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/test/CoreSDKTestGeneratedCode.c @@ -0,0 +1,330 @@ +/* + * 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.h b/src/sdks/core/src/cpp/sdk/test/CoreSDKTestGeneratedCode.h new file mode 100644 index 000000000..4b9d12441 --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/test/CoreSDKTestGeneratedCode.h @@ -0,0 +1,42 @@ +/* + * 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 + */ + +#ifndef CORESDK_TEST_GENERATED_CODE_H +#define CORESDK_TEST_GENERATED_CODE_H + + +#ifdef __cplusplus +extern "C" { +#endif + +//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(); + +#ifdef __cplusplus +} +#endif + +#endif // CORESDK_TEST_GENERATED_CODE_H diff --git a/src/sdks/core/src/cpp/sdk/test/CoreSDKTests.cpp b/src/sdks/core/src/cpp/sdk/test/CoreSDKTests.cpp new file mode 100644 index 000000000..cfcca0686 --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/test/CoreSDKTests.cpp @@ -0,0 +1,86 @@ +/* + * 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/CoreSDKTests.h b/src/sdks/core/src/cpp/sdk/test/CoreSDKTests.h new file mode 100644 index 000000000..480129e6d --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/test/CoreSDKTests.h @@ -0,0 +1,62 @@ +/* + * 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 + +namespace FireboltSDK { + class Policy : public WPEFramework::Core::JSON::Container { + public: + Policy(const Policy& copy) = delete; + Policy() + : WPEFramework::Core::JSON::Container() + , EnableRecommendations(false) + , ShareWatchHistory(false) + , RememberWatchedPrograms(false) + { + Add(_T("enableRecommendations"), &EnableRecommendations); + Add(_T("shareWatchHistory"), &ShareWatchHistory); + Add(_T("rememberWatchedPrograms"), &RememberWatchedPrograms); + } + Policy& operator=(const Policy& RHS) + { + EnableRecommendations = RHS.EnableRecommendations; + ShareWatchHistory = RHS.ShareWatchHistory; + RememberWatchedPrograms = RHS.RememberWatchedPrograms; + + return (*this); + } + + ~Policy() override = default; + + public: + WPEFramework::Core::JSON::Boolean EnableRecommendations; + WPEFramework::Core::JSON::Boolean ShareWatchHistory; + WPEFramework::Core::JSON::Boolean RememberWatchedPrograms; + }; + + class CoreTests : public Tests { + + public: + CoreTests(); + ~CoreTests() override = default; + + static int32_t GetDiscoveryPolicy(); + }; +} diff --git a/src/sdks/core/src/cpp/sdk/test/Main.c b/src/sdks/core/src/cpp/sdk/test/Main.c new file mode 100644 index 000000000..2490dbb95 --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/test/Main.c @@ -0,0 +1,57 @@ +/* + * 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/Module.cpp b/src/sdks/core/src/cpp/sdk/test/Module.cpp new file mode 100644 index 000000000..d63badc4b --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/test/Module.cpp @@ -0,0 +1,21 @@ +/* + * 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" + +MODULE_NAME_DECLARATION(BUILD_REFERENCE) diff --git a/src/sdks/core/src/cpp/sdk/test/Module.h b/src/sdks/core/src/cpp/sdk/test/Module.h new file mode 100644 index 000000000..c32a6dcd0 --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/test/Module.h @@ -0,0 +1,28 @@ +/* + * 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 + +#ifndef MODULE_NAME +#define MODULE_NAME OpenRPCCoreTestApp +#endif + +#include + +#undef EXTERNAL +#define EXTERNAL