Skip to content

Commit

Permalink
CPPSDK: Core & Manage test updates with more test: inprogress
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseenaSainul committed Dec 4, 2023
1 parent 6e00ace commit 72e453c
Show file tree
Hide file tree
Showing 6 changed files with 752 additions and 143 deletions.
169 changes: 152 additions & 17 deletions src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

using namespace std;
bool CoreSDKTest::_connected;
CoreSDKTest::OnPolicyChangedNotification CoreSDKTest::_policyChangedNotification;
CoreSDKTest::OnDeviceNameChangedNotification CoreSDKTest::_deviceNameChangedNotification;
CoreSDKTest::OnAudioChangedNotification CoreSDKTest::_audioChangedNotification;
CoreSDKTest::OnScreenResolutionChangedNotification CoreSDKTest::_screenResolutionChangedNotification;
Expand Down Expand Up @@ -72,6 +73,124 @@ bool CoreSDKTest::WaitOnConnectionReady()
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<int>(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<int>(error) << endl;
}
}

template<typename T>
using EnumMap = std::unordered_map<T, string>;
template <typename T>
inline const string& ConvertFromEnum(EnumMap<T> enumMap, T type)
{
return enumMap[type];
}
template <typename T>
inline const T ConvertToEnum(EnumMap<T> enumMap, const string& str)
{
T value;
for (auto element: enumMap) {
if (element.second == str) {
value = element.first;
break;
}
}
return value;
}

EnumMap<Firebolt::Advertising::SkipRestriction> 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<Firebolt::Advertising::SkipRestriction>(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<int>(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<int>(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<int>(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<int>(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<int>(error) << endl;
}
}

void CoreSDKTest::GetDeviceName()
{
Firebolt::Error error = Firebolt::Error::None;
Expand Down Expand Up @@ -142,7 +261,6 @@ void PrintDeviceAudioProfiles( const Firebolt::Device::AudioProfiles& audioProfi
cout << "Profile: " << static_cast<int>(item.first) << " status: " << item.second << endl;
}
}

void CoreSDKTest::GetDeviceAudio()
{
Firebolt::Error error = Firebolt::Error::None;
Expand All @@ -153,13 +271,11 @@ void CoreSDKTest::GetDeviceAudio()
cout << "Get Device AudioProfiles status = " << static_cast<int>(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;
Expand All @@ -170,7 +286,6 @@ void CoreSDKTest::SubscribeDeviceAudioChanged()
cout << "Subscribe Device Audio Change status = " << static_cast<int>(error) << endl;
}
}

void CoreSDKTest::UnsubscribeDeviceAudioChanged()
{
Firebolt::Error error = Firebolt::Error::None;
Expand All @@ -187,7 +302,6 @@ 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;
Expand All @@ -198,13 +312,11 @@ void CoreSDKTest::GetDeviceScreenResolution()
cout << "Get Device ScreenResolution status = " << static_cast<int>(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;
Expand All @@ -215,7 +327,6 @@ void CoreSDKTest::SubscribeDeviceScreenResolutionChanged()
cout << "Subscribe Device ScreenResolution Change status = " << static_cast<int>(error) << endl;
}
}

void CoreSDKTest::UnsubscribeDeviceScreenResolutionChanged()
{
Firebolt::Error error = Firebolt::Error::None;
Expand Down Expand Up @@ -274,7 +385,6 @@ void PrintClosedCaptionsSettings( const Firebolt::Accessibility::ClosedCaptionsS
}
cout << endl;
}

void CoreSDKTest::GetAccessibilityClosedCaptionsSettings()
{
Firebolt::Error error = Firebolt::Error::None;
Expand All @@ -285,13 +395,11 @@ void CoreSDKTest::GetAccessibilityClosedCaptionsSettings()
cout << "Get Accessibility ClosedCaptionsSettings status = " << static_cast<int>(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;
Expand All @@ -302,7 +410,6 @@ void CoreSDKTest::SubscribeAccessibilityClosedCaptionsSettingsChanged()
cout << "Subscribe Accessibilty ClosedCaptionSettings Change status = " << static_cast<int>(error) << endl;
}
}

void CoreSDKTest::UnsubscribeAccessibilityClosedCaptionsSettingsChanged()
{
Firebolt::Error error = Firebolt::Error::None;
Expand All @@ -328,15 +435,13 @@ void CoreSDKTest::GetLocalizationPreferredAudioLanguages()
cout << "Get Localization PreferredAudioLanguages status = " << static_cast<int>(error) << endl;
}
}

void CoreSDKTest::OnPreferredAudioLanguagesChangedNotification::onPreferredAudioLanguagesChanged( const std::vector<std::string>& languages)
{
cout << "PreferredAudioLanguages Changed, new languages --> " << endl;
for (auto language : languages) {
cout << " -> " << language << endl;
}
}

void CoreSDKTest::SubscribeLocalizationPreferredAudioLanguagesChanged()
{
Firebolt::Error error = Firebolt::Error::None;
Expand All @@ -347,7 +452,6 @@ void CoreSDKTest::SubscribeLocalizationPreferredAudioLanguagesChanged()
cout << "Subscribe Localization PreferredAudioLanguagesChange status = " << static_cast<int>(error) << endl;
}
}

void CoreSDKTest::UnsubscribeLocalizationPreferredAudioLanguagesChanged()
{
Firebolt::Error error = Firebolt::Error::None;
Expand All @@ -370,7 +474,6 @@ void CoreSDKTest::InvokeKeyboardStandard()
cout << "Error while invoking keyboard.standard method, error = " << static_cast<int>(error) << endl;
}
}

void CoreSDKTest::InvokeKeyboardPassword()
{
Firebolt::Error error = Firebolt::Error::None;
Expand All @@ -383,7 +486,6 @@ void CoreSDKTest::InvokeKeyboardPassword()
}

}

void CoreSDKTest::InvokeKeyboardEmail()
{
Firebolt::Error error = Firebolt::Error::None;
Expand All @@ -397,3 +499,36 @@ void CoreSDKTest::InvokeKeyboardEmail()
}
}

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<int>(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<int>(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<int>(error) << endl;
}
}
16 changes: 15 additions & 1 deletion src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
#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;
Expand Down Expand Up @@ -50,6 +53,8 @@ class CoreSDKTest {
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();
Expand All @@ -68,14 +73,23 @@ class CoreSDKTest {
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 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;
Expand Down
Loading

0 comments on commit 72e453c

Please sign in to comment.