Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,652 changes: 1,996 additions & 1,656 deletions package-lock.json

Large diffs are not rendered by default.

337 changes: 324 additions & 13 deletions src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp

Large diffs are not rendered by default.

27 changes: 25 additions & 2 deletions src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#pragma once

#include <iostream>
#include <nlohmann/json.hpp>
#include "firebolt.h"

class CoreSDKTest {
Expand Down Expand Up @@ -178,14 +179,21 @@ class CoreSDKTest {
static void DiscoveryWatched();
static void DiscoveryWatchedReduced();
#endif
static void SubscribeDiscoveryOnNavigateToLaunchNotification();
static void UnsubscribeDiscoveryOnNavigateToLaunchNotification();
static void SubscribeDiscoveryOnNavigateToLaunchHomeIntentNotification();
static void SubscribeDiscoveryOnNavigateToLaunchEntityIntentNotification();
static void SubscribeDiscoveryOnNavigateToLaunchTuneIntentNotification();
static void UnsubscribeDiscoveryOnNavigateToLaunchHomeIntentNotification();
static void UnsubscribeDiscoveryOnNavigateToLaunchEntityIntentNotification();
static void UnsubscribeDiscoveryOnNavigateToLaunchTuneIntentNotification();
static void DiscoveryWatchNext();
static void DiscoveryUserInterest();

static void ParametersInitialization();

static bool WaitOnConnectionReady();

static void event_trigger(nlohmann::json event);
static void provider_trigger(nlohmann::json provider);

private:
static void ConnectionChanged(const bool, const Firebolt::Error);
Expand All @@ -206,4 +214,19 @@ class CoreSDKTest {
static KeyboardEmailAsyncResponse _keyboardEmailAsyncResponse;
static KeyboardPasswordAsyncResponse _keyboardPasswordAsyncResponse;
static KeyboardStandardAsyncResponse _keyboardStandardAsyncResponse;

public:
static const nlohmann::json adPolicy;
static const nlohmann::json deviceName;
static const nlohmann::json audioChanged;
static const nlohmann::json deviceScreenResolutionChanged;
static const nlohmann::json preferredAudioLanguagesChanged;
static const nlohmann::json closedCaptionsSettingsChanged;
static const nlohmann::json backgroundNotification;
static const nlohmann::json foregroundNotification;
static const nlohmann::json friendlyNameChanged;
static const nlohmann::json navigateTo;
static const nlohmann::json keyboardStandard;
static const nlohmann::json keyboardEmail;
static const nlohmann::json keyboardPassword;
};
268 changes: 257 additions & 11 deletions src/sdks/core/src/cpp/sdk/cpptest/Main.cpp

Large diffs are not rendered by default.

133 changes: 129 additions & 4 deletions src/sdks/discovery/src/cpp/sdk/cpptest/DiscoverySDKTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,98 @@
#include <unistd.h>
#include <cstring>
#include <string>
#include <cassert>
#include "DiscoverySDKTest.h"

using namespace std;
bool DiscoverySDKTest::_connected;
DiscoverySDKTest::OnUserInterestNotification DiscoverySDKTest::_userInterestNotification;

#ifdef GATEWAY_BIDIRECTIONAL

const nlohmann::json DiscoverySDKTest::userInterestEvent = {
{"method", "content.onUserInterest"},
{"payload", {
{"name", "interest"},
{"appId", "cool-app"},
{"type", "interest"},
{"reason", "playlist"},
{"entity", {
{"identifiers", {
{"entityId", "345"},
{"entityType", "program"},
{"programType", "movie"}
}},
{"info", {
{"title", "Cool Runnings"},
{"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."},
{"releaseDate", "1993-01-01T00:00:00.000Z"},
{"contentRatings", {
{
{"scheme", "US-Movie"},
{"rating", "PG"}
},
{
{"scheme", "CA-Movie"},
{"rating", "G"}
}
}}
}}
}}
}}
};


void DiscoverySDKTest::event_trigger(nlohmann::json event)
{
std::cout << "Event triggered: " << event["method"].dump() << std::endl;
std::string trigger_cmd = "curl --location --request POST http://localhost:3333/api/v1/bidirectionalEventPayload --header 'Content-Type: application/json' --data-raw '{ \"method\": " + event["method"].dump() + ", \"params\": " + event["payload"].dump() + "}'";
system(trigger_cmd.c_str());
std::cout << std::endl;
std::cout << "[ADITYA] trigger_cmd: " << trigger_cmd << std::endl;
}

void DiscoverySDKTest::provider_trigger(nlohmann::json provider)
{
std::cout << "Provider triggered: " << provider["method"].dump() << std::endl;
std::string trigger_cmd = "curl --location --request POST http://localhost:3333/api/v1/bidirectionalPayload --header 'Content-Type: application/json' --data-raw '{ \"method\": " + provider["method"].dump() + ", \"params\": " + provider["payload"].dump() + "}'";
system(trigger_cmd.c_str());
std::cout << std::endl;
}

std::string InterestTypeToString(Firebolt::Discovery::InterestType interestType) {
switch (interestType) {
case Firebolt::Discovery::InterestType::INTEREST:
return "interest";
case Firebolt::Discovery::InterestType::DISINTEREST:
return "disinterest";
default:
return "unknown";
}
}

std::string InterestReasonToString(Firebolt::Discovery::InterestReason interestReason) {
switch (interestReason) {
case Firebolt::Discovery::InterestReason::PLAYLIST:
return "playlist";
case Firebolt::Discovery::InterestReason::REACTION:
return "reaction";
case Firebolt::Discovery::InterestReason::RECORDING:
return "recording";
default:
return "unknown";
}
}


#endif

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

void DiscoverySDKTest::CreateFireboltInstance(const std::string& url)
Expand Down Expand Up @@ -67,6 +149,7 @@ bool DiscoverySDKTest::WaitOnConnectionReady()
usleep(sleepSlot);
waiting -= sleepSlot;
}
usleep(5000);
return _connected;
}

Expand All @@ -90,9 +173,51 @@ inline const T ConvertToEnum(EnumMap<T> enumMap, const string& str)
return value;
}

void DiscoverySDKTest::OnUserInterestNotification::onUserInterest( const Firebolt::Content::InterestEvent& interest)
std::string ContentRatingSchemeToString(Firebolt::Entertainment::ContentRatingScheme scheme)
{
switch (scheme)
{
case Firebolt::Entertainment::ContentRatingScheme::CA_MOVIE:
return "CA-Movie";
case Firebolt::Entertainment::ContentRatingScheme::CA_TV:
return "CA-TV";
case Firebolt::Entertainment::ContentRatingScheme::CA_MOVIE_FR:
return "CA-Movie_Fr";
case Firebolt::Entertainment::ContentRatingScheme::CA_TV_FR:
return "CA-TV_Fr";
case Firebolt::Entertainment::ContentRatingScheme::US_MOVIE:
return "US-Movie";
case Firebolt::Entertainment::ContentRatingScheme::US_TV:
return "US-TV";
default:
return "UNKNOWN";
}
}

void DiscoverySDKTest::OnUserInterestNotification::onUserInterest(const Firebolt::Content::InterestEvent &interest)
{
cout << "User Interest changed notification" << endl;
cout << "onUserInterest() notification \n";

#ifdef GATEWAY_BIDIRECTIONAL
assert(interest.appId == userInterestEvent["payload"]["appId"]);
assert(InterestTypeToString(interest.type) == userInterestEvent["payload"]["type"]);
assert(InterestReasonToString(interest.reason) == userInterestEvent["payload"]["reason"]);
assert(interest.entity.info->title.value() == userInterestEvent["payload"]["entity"]["info"]["title"]);
assert(interest.entity.info->synopsis.value() == userInterestEvent["payload"]["entity"]["info"]["synopsis"]);
assert(interest.entity.info->releaseDate.value() == userInterestEvent["payload"]["entity"]["info"]["releaseDate"]);
size_t i = 0;
for (const auto &rating : interest.entity.info->contentRatings.value())
{
assert(ContentRatingSchemeToString(rating.scheme) == userInterestEvent["payload"]["entity"]["info"]["contentRatings"][i]["scheme"]);
i++;
}
size_t j = 0;
for (const auto &ratings : interest.entity.info->contentRatings.value())
{
assert(ratings.rating == userInterestEvent["payload"]["entity"]["info"]["contentRatings"][j]["rating"]);
j++;
}
#endif
}

void DiscoverySDKTest::SubscribeUserInterest()
Expand Down
11 changes: 11 additions & 0 deletions src/sdks/discovery/src/cpp/sdk/cpptest/DiscoverySDKTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#pragma once

#include <iostream>
#include <nlohmann/json.hpp>
#include "firebolt.h"

class DiscoverySDKTest {
Expand All @@ -41,9 +42,19 @@ class DiscoverySDKTest {

static bool WaitOnConnectionReady();

#ifdef GATEWAY_BIDIRECTIONAL
static void event_trigger(nlohmann::json event);
static void provider_trigger(nlohmann::json provider);
#endif

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

#ifdef GATEWAY_BIDIRECTIONAL
public:
static const nlohmann::json userInterestEvent;
#endif

};
4 changes: 4 additions & 0 deletions src/sdks/discovery/src/cpp/sdk/cpptest/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <string>
#include <iostream>
#include <stdexcept>
#include <unistd.h>
#include "DiscoverySDKTest.h"

using namespace std;
Expand All @@ -42,8 +43,11 @@ void RunAllTests() {

// Ensure the connection is ready before running tests
if (DiscoverySDKTest::WaitOnConnectionReady()) {

sleep(2);

runTest(DiscoverySDKTest::SubscribeUserInterest, "SubscribeUserInterest");
DiscoverySDKTest::event_trigger(DiscoverySDKTest::userInterestEvent);
runTest(DiscoverySDKTest::UnsubscribeUserInterest, "UnsubscribeUserInterest");
runTest(DiscoverySDKTest::RequestUserInterest, "RequestUserInterest");

Expand Down
38 changes: 26 additions & 12 deletions src/sdks/manage/src/cpp/sdk/cpptest/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <string>
#include <iostream>
#include <stdexcept>
#include <unistd.h>
#include "ManageSDKTest.h"

using namespace std;
Expand Down Expand Up @@ -54,29 +55,34 @@ void RunAllTests() {
runTest(ManageSDKTest::GetAudioDescriptionsEnabled, "GetAudioDescriptionsEnabled");
runTest(ManageSDKTest::SetAudioDescriptionsEnabled, "SetAudioDescriptionsEnabled");
runTest(ManageSDKTest::SubscribeAudioDescriptionsEnabledChanged, "SubscribeAudioDescriptionsEnabledChanged");
ManageSDKTest::event_trigger(ManageSDKTest::audioDescriptionsEnabledChanged);
runTest(ManageSDKTest::UnsubscribeAudioDescriptionsEnabledChanged, "UnsubscribeAudioDescriptionsEnabledChanged");

// Device methods
runTest(ManageSDKTest::GetDeviceName, "GetDeviceName");
runTest(ManageSDKTest::SetDeviceName, "SetDeviceName");
runTest(ManageSDKTest::SubscribeDeviceNameChanged, "SubscribeDeviceNameChanged");
ManageSDKTest::event_trigger(ManageSDKTest::deviceNameChanged);
runTest(ManageSDKTest::UnsubscribeDeviceNameChanged, "UnsubscribeDeviceNameChanged");

// ClosedCaptions methods
runTest(ManageSDKTest::GetClosedCaptionsBackgroundOpacity, "GetClosedCaptionsBackgroundOpacity");
runTest(ManageSDKTest::SetClosedCaptionsBackgroundOpacity, "SetClosedCaptionsBackgroundOpacity");
runTest(ManageSDKTest::SubscribeClosedCaptionsBackgroundOpacityChanged, "SubscribeClosedCaptionsBackgroundOpacityChanged");
ManageSDKTest::event_trigger(ManageSDKTest::backgroundOpacityChanged);
runTest(ManageSDKTest::UnsubscribeClosedCaptionsBackgroundOpacityChanged, "UnsubscribeClosedCaptionsBackgroundOpacityChanged");

runTest(ManageSDKTest::GetClosedCaptionsFontFamily, "GetClosedCaptionsFontFamily");
runTest(ManageSDKTest::SetClosedCaptionsFontFamily, "SetClosedCaptionsFontFamily");
runTest(ManageSDKTest::SubscribeClosedCaptionsFontFamilyChanged, "SubscribeClosedCaptionsFontFamilyChanged");
ManageSDKTest::event_trigger(ManageSDKTest::fontFamilyChanged);
runTest(ManageSDKTest::UnsubscribeClosedCaptionsFontFamilyChanged, "UnsubscribeClosedCaptionsFontFamilyChanged");

// Localization methods
runTest(ManageSDKTest::GetLocalizationPreferredAudioLanguages, "GetLocalizationPreferredAudioLanguages");
runTest(ManageSDKTest::SetLocalizationPreferredAudioLanguages, "SetLocalizationPreferredAudioLanguages");
runTest(ManageSDKTest::SubscribeLocalizationPreferredAudioLanguagesChanged, "SubscribeLocalizationPreferredAudioLanguagesChanged");
ManageSDKTest::event_trigger(ManageSDKTest::preferredAudioLanguagesChanged);
runTest(ManageSDKTest::UnsubscribeLocalizationPreferredAudioLanguagesChanged, "UnsubscribeLocalizationPreferredAudioLanguagesChanged");

runTest(ManageSDKTest::GetLocalizationAdditionalInfo, "GetLocalizationAdditionalInfo");
Expand All @@ -87,14 +93,17 @@ void RunAllTests() {
runTest(ManageSDKTest::GetPrivacyAllowACRCollection, "GetPrivacyAllowACRCollection");
runTest(ManageSDKTest::SetPrivacyAllowACRCollection, "SetPrivacyAllowACRCollection");
runTest(ManageSDKTest::SubscribePrivacyAllowACRCollectionChanged, "SubscribePrivacyAllowACRCollectionChanged");
ManageSDKTest::event_trigger(ManageSDKTest::allowACRCollectionChanged);
runTest(ManageSDKTest::UnsubscribePrivacyAllowACRCollectionChanged, "UnsubscribePrivacyAllowACRCollectionChanged");

runTest(ManageSDKTest::GetPrivacySettings, "GetPrivacySettings");

// Discovery methods
runTest(ManageSDKTest::SubscribeDiscoverySignInNotification, "SubscribeDiscoverySignInNotification");
ManageSDKTest::event_trigger(ManageSDKTest::signInEvent);
runTest(ManageSDKTest::UnsubscribeDiscoverySignInNotification, "UnsubscribeDiscoverySignInNotification");
runTest(ManageSDKTest::SubscribeDiscoverySignOutNotification, "SubscribeDiscoverySignOutNotification");
ManageSDKTest::event_trigger(ManageSDKTest::signOutEvent);
runTest(ManageSDKTest::UnsubscribeDiscoverySignOutNotification, "UnsubscribeDiscoverySignOutNotification");

// UserGrants methods
Expand All @@ -103,25 +112,30 @@ void RunAllTests() {
runTest(ManageSDKTest::DenyUserGrantsPermission, "DenyUserGrantsPermission");
runTest(ManageSDKTest::ClearUserGrantsPermission, "ClearUserGrantsPermission");

// Wifi methods
// runTest(ManageSDKTest::WifiScan, "WifiScan");
// runTest(ManageSDKTest::WifiConnect, "WifiConnect");
// runTest(ManageSDKTest::WifiDisconnect, "WifiDisconnect");

// Provider registration
runTest(ManageSDKTest::RegisterKeyboardProvider, "RegisterKeyboardProvider");
ManageSDKTest::provider_trigger(ManageSDKTest::requestStandard);
runTest(ManageSDKTest::SendResponseMessageToKeyboardProvider, "SendResponseMessageToKeyboardProvider");

runTest(ManageSDKTest::RegisterKeyboardProvider, "RegisterKeyboardProvider");
ManageSDKTest::provider_trigger(ManageSDKTest::requestEmail);
runTest(ManageSDKTest::SendResponseMessageToKeyboardProvider, "SendResponseMessageToKeyboardProvider");
runTest(ManageSDKTest::SendErrorMessageToKeyboardProvider, "SendErrorMessageToKeyboardProvider");

runTest(ManageSDKTest::RegisterAcknowledgeChallengeProvider, "RegisterAcknowledgeChallengeProvider");
runTest(ManageSDKTest::SendResponseMessageToAcknowledgeChallengeProvider, "SendResponseMessageToAcknowledgeChallengeProvider");
runTest(ManageSDKTest::SendErrorMessageToAcknowledgeChallengeProvider, "SendErrorMessageToAcknowledgeChallengeProvider");
runTest(ManageSDKTest::RegisterKeyboardProvider, "RegisterKeyboardProvider");
ManageSDKTest::provider_trigger(ManageSDKTest::requestPassword);
runTest(ManageSDKTest::SendResponseMessageToKeyboardProvider, "SendResponseMessageToKeyboardProvider");

// runTest(ManageSDKTest::RegisterAcknowledgeChallengeProvider, "RegisterAcknowledgeChallengeProvider");
// ManageSDKTest::provider_trigger(ManageSDKTest::ackRequestChallenge);
// runTest(ManageSDKTest::SendResponseMessageToAcknowledgeChallengeProvider, "SendResponseMessageToAcknowledgeChallengeProvider");

// runTest(ManageSDKTest::RegisterPinChallengeProvider, "RegisterPinChallengeProvider");
// ManageSDKTest::provider_trigger(ManageSDKTest::pinRequestChallenge);
// runTest(ManageSDKTest::SendResponseMessageToPinChallengeProvider, "SendResponseMessageToPinChallengeProvider");

runTest(ManageSDKTest::RegisterPinChallengeProvider, "RegisterPinChallengeProvider");
runTest(ManageSDKTest::SendResponseMessageToPinChallengeProvider, "SendResponseMessageToPinChallengeProvider");
runTest(ManageSDKTest::SendErrorMessageToPinChallengeProvider, "SendErrorMessageToPinChallengeProvider");

runTest(ManageSDKTest::GlobalSubscribeHdmiAutoLowLatencyModeCapableChanged, "GlobalSubscribeHdmiAutoLowLatencyModeCapableChanged");
ManageSDKTest::event_trigger(ManageSDKTest::autoLowLatencyModeCapableChanged);
runTest(ManageSDKTest::GlobalUnsubscribeHdmiAutoLowLatencyModeCapableChanged, "GlobalUnsubscribeHdmiAutoLowLatencyModeCapableChanged");

runTest(ManageSDKTest::GetAutoLowLatencyModeCapable, "GetAutoLowLatencyModeCapable");
Expand Down
Loading