Skip to content

Commit

Permalink
CPPSDK: standalone cpp test case added
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseenaSainul committed Oct 6, 2023
1 parent 774fb3a commit 862eff6
Show file tree
Hide file tree
Showing 14 changed files with 357 additions and 769 deletions.
291 changes: 37 additions & 254 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"devDependencies": {
"@commitlint/cli": "^17.0.3",
"@commitlint/config-conventional": "^17.0.3",
"@firebolt-js/openrpc": "2.1.0",
"@firebolt-js/openrpc": "file:../firebolt-openrpc",
"@firebolt-js/schemas": "1.0.0-next.0",
"@saithodev/semantic-release-backmerge": "^3.2.0",
"@semantic-release/changelog": "^6.0.1",
Expand Down
4 changes: 2 additions & 2 deletions src/openrpc/advertising.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
]
},
{
"name": "skipRestriction",
"name": "skipRestrictionAPI",
"summary": "Set the value for AdPolicy.skipRestriction",
"tags": [
{
Expand Down Expand Up @@ -325,4 +325,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

cmake_minimum_required(VERSION 3.3)

project(FireboltCoreSDKTests)
project(FireboltManageSDKTests)

if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${SYSROOT_PATH}/usr" CACHE INTERNAL "" FORCE)
Expand All @@ -42,11 +42,11 @@ find_package(${NAMESPACE}Core CONFIG REQUIRED)
find_package(Firebolt CONFIG REQUIRED)
find_package(${FIREBOLT_NAMESPACE}SDK CONFIG REQUIRED)

set(TESTAPP TestFireboltCore)
set(TESTAPP TestFireboltManage)

message("Setup ${TESTAPP}")

add_executable(${TESTAPP} main.c)
add_executable(${TESTAPP} ManageSDKTest.cpp Main.cpp)

target_link_libraries(${TESTAPP}
PRIVATE
Expand Down
88 changes: 88 additions & 0 deletions src/sdks/manage/src/cpp/sdk/cpptest/Main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@

#include "ManageSDKTest.h"

void ShowMenu()
{
printf("Enter\n"
"\tN : Get Device Name\n"
"\tS : Set Device Name\n"
"\tB : Get ClosedCaption Background Opacity\n"
"\tO : Set ClosedCaption Background Opacity\n"
"\tF : Get ClosedCaption Font Family\n"
"\tM : Set ClosedCaption Font Family\n"
"\tL : Get Localization Preferred AudioLanguages\n"
"\tP : Set Localization Preferred AudioLanguages\n"
"\tQ : Quit\n\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 Manage SDK Test\n");

ManageSDKTest::CreateFireboltInstance();
int option;

if (ManageSDKTest::WaitOnConnectionReady() == true) {
do {
ShowMenu();
printf("Enter option : ");
option = toupper(getchar());
switch (option) {
case 'N': {
ManageSDKTest::GetDeviceName();
break;
}
case 'S': {
ManageSDKTest::SetDeviceName();
break;
}
case 'B': {
ManageSDKTest::GetClosedCaptionBackgroundOpacity();
break;
}
case 'O': {
ManageSDKTest::SetClosedCaptionBackgroundOpacity();
break;
}
case 'F': {
ManageSDKTest::GetClosedCaptionFontFamily();
break;
}
case 'M': {
ManageSDKTest::SetClosedCaptionFontFamily();
break;
}
case 'L': {
ManageSDKTest::GetLocalizationPreferredAudioLanguages();
break;
}
case 'P': {
ManageSDKTest::SetLocalizationPreferredAudioLanguages();
break;
}

default:
break;
}
getchar(); // Skip white space
} while (option != 'Q');

} else {
printf("Manage Test not able to connect with server.... \n");
}

ManageSDKTest::DestroyFireboltInstance();

return 0;
}
171 changes: 171 additions & 0 deletions src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
/*
* 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 <unistd.h>
#include "firebolt.h"
#include "ManageSDKTest.h"

using namespace std;
bool ManageSDKTest::_connected;

void ManageSDKTest::ConnectionChanged(const bool connected, const Firebolt::Error error)
{
cout << "Change in connection: connected: " << connected << " error: " << static_cast<int>(error) << endl;
_connected = connected;
}

void ManageSDKTest::CreateFireboltInstance()
{
const std::string config = "{\
\"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 ManageSDKTest::DestroyFireboltInstance()
{
Firebolt::IFireboltAccessor::Instance().Disconnect();
Firebolt::IFireboltAccessor::Instance().Deinitialize();
Firebolt::IFireboltAccessor::Instance().Dispose();
}

bool ManageSDKTest::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 ManageSDKTest::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<int>(error) << endl;
}
}

void ManageSDKTest::SetDeviceName()
{
Firebolt::Error error = Firebolt::Error::None;
Firebolt::IFireboltAccessor::Instance().DeviceInterface().SetName("Hello", &error);

if (error == Firebolt::Error::None) {
cout << "Set DeviceName is success" << endl;
} else {
cout << "Set DeviceName status = " << static_cast<int>(error) << endl;
}
}

void ManageSDKTest::GetClosedCaptionBackgroundOpacity()
{
Firebolt::Error error = Firebolt::Error::None;
const float value = Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().BackgroundOpacity(&error);

if (error == Firebolt::Error::None) {
cout << "Get ClosedCaption BackgroundOpacity = " << value << endl;
} else {
cout << "Get ClosedCaption BackgroundOpacity status = " << static_cast<int>(error) << endl;
}
}

void ManageSDKTest::SetClosedCaptionBackgroundOpacity()
{
Firebolt::Error error = Firebolt::Error::None;
Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().SetBackgroundOpacity(2.0, &error);

if (error == Firebolt::Error::None) {
cout << "Set ClosedCaption BackgroundOpacity is success" << endl;
} else {
cout << "Set ClosedCaption BackgroundOpacity status = " << static_cast<int>(error) << endl;
}
}

void ManageSDKTest::GetClosedCaptionFontFamily()
{
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 = " << static_cast<int>(value) << endl;
} else {
cout << "Get ClosedCaption FontFamily status = " << static_cast<int>(error) << endl;
}
}

void ManageSDKTest::SetClosedCaptionFontFamily()
{
Firebolt::Error error = Firebolt::Error::None;
Firebolt::IFireboltAccessor::Instance().ClosedCaptionsInterface().SetFontFamily(Firebolt::Accessibility::FontFamily::PROPORTIONAL_SANSERIF, &error);

if (error == Firebolt::Error::None) {
cout << "Set ClosedCaption FontFamily is success" << endl;
} else {
cout << "Set ClosedCaption FontFamily status = " << static_cast<int>(error) << endl;
}
}

void ManageSDKTest::GetLocalizationPreferredAudioLanguages()
{
Firebolt::Error error = Firebolt::Error::None;
const std::vector<std::string> languages = Firebolt::IFireboltAccessor::Instance().LocalizationInterface().PreferredAudioLanguages(&error);

if (error == Firebolt::Error::None) {
cout << "Get Localization PreferredAudioLanguages : " << endl;
for (auto language: languages) {
cout << "----- > " <<language << endl;
}
} else {
cout << "Get Localization PreferredAudioLanguages status = " << static_cast<int>(error) << endl;
}
}

void ManageSDKTest::SetLocalizationPreferredAudioLanguages()
{
Firebolt::Error error = Firebolt::Error::None;
const std::vector<std::string> languages = { "ara", "jpn", "hin" };
Firebolt::IFireboltAccessor::Instance().LocalizationInterface().SetPreferredAudioLanguages(languages, &error);

if (error == Firebolt::Error::None) {
cout << "Set Localization PreferredAudioLanguages is success" << endl;
} else {
cout << "Get Localization PreferredAudioLanguages status = " << static_cast<int>(error) << endl;
}
}

47 changes: 47 additions & 0 deletions src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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 <iostream>
#include "error.h"

class ManageSDKTest {

public:
ManageSDKTest() = default;
virtual ~ManageSDKTest() = default;

static void CreateFireboltInstance();
static void DestroyFireboltInstance();
static void TestManageStaticSDK();
static void GetDeviceName();
static void SetDeviceName();
static void GetClosedCaptionBackgroundOpacity();
static void SetClosedCaptionBackgroundOpacity();
static void GetClosedCaptionFontFamily();
static void SetClosedCaptionFontFamily();
static void GetLocalizationPreferredAudioLanguages();
static void SetLocalizationPreferredAudioLanguages();
static bool WaitOnConnectionReady();

private:
static void ConnectionChanged(const bool, const Firebolt::Error);
static bool _connected;
};

File renamed without changes.
Loading

0 comments on commit 862eff6

Please sign in to comment.