Skip to content

Commit

Permalink
Core test update to add more test case to link with provider sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseenaSainul committed Nov 29, 2023
1 parent a4b1b53 commit c0253b3
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 17 deletions.
69 changes: 65 additions & 4 deletions src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,16 @@ void CoreSDKTest::ConnectionChanged(const bool connected, const Firebolt::Error
_connected = connected;
}

void CoreSDKTest::CreateFireboltInstance()
void CoreSDKTest::CreateFireboltInstance(const std::string& url)
{
const std::string config = "{\
\"waitTime\": 1000,\
\"waitTime\": 60000,\
\"logLevel\": \"Info\",\
\"workerPool\":{\
\"queueSize\": 8,\
\"threadCount\": 3\
},\
\"wsUrl\": \"ws://127.0.0.1:9998\"\
}";
\"wsUrl\": " + url + "}";

_connected = false;
Firebolt::IFireboltAccessor::Instance().Initialize(config);
Expand Down Expand Up @@ -112,6 +111,30 @@ void CoreSDKTest::UnsubscribeDeviceNameChanged()
}
}

void CoreSDKTest::GetDeviceModel()
{
Firebolt::Error error = Firebolt::Error::None;
const std::string model = Firebolt::IFireboltAccessor::Instance().DeviceInterface().model(&error);

if (error == Firebolt::Error::None) {
cout << "Get Device Model = " << model.c_str() << endl;
} else {
cout << "Get Device Model status = " << static_cast<int>(error) << endl;
}
}

void CoreSDKTest::GetDeviceSKU()
{
Firebolt::Error error = Firebolt::Error::None;
const std::string sku = Firebolt::IFireboltAccessor::Instance().DeviceInterface().sku(&error);

if (error == Firebolt::Error::None) {
cout << "Get Device Sku = " << sku.c_str() << endl;
} else {
cout << "Get Device Sku status = " << static_cast<int>(error) << endl;
}
}

void PrintDeviceAudioProfiles( const Firebolt::Device::AudioProfiles& audioProfiles )
{
cout << "Get Device AudioProfiles :-> " << endl;
Expand Down Expand Up @@ -336,3 +359,41 @@ void CoreSDKTest::UnsubscribeLocalizationPreferredAudioLanguagesChanged()
}
}

void CoreSDKTest::InvokeKeyboardStandard()
{
Firebolt::Error error = Firebolt::Error::None;
std::string message = "Enter the name you'd like to associate with this device";
string response = Firebolt::IFireboltAccessor::Instance().KeyboardInterface().standard(message, &error);
if (error == Firebolt::Error::None) {
cout << "Keyboard standard response: " << response << endl;
} else {
cout << "Error while invoking keyboard.standard method, error = " << static_cast<int>(error) << endl;
}
}

void CoreSDKTest::InvokeKeyboardPassword()
{
Firebolt::Error error = Firebolt::Error::None;
std::string message = "Enter the password to associate with this device";
string response = Firebolt::IFireboltAccessor::Instance().KeyboardInterface().password(message, &error);
if (error == Firebolt::Error::None) {
cout << "Keyboard password response: " << response << endl;
} else {
cout << "Error while invoking keyboard.password method, error = " << static_cast<int>(error) << endl;
}

}

void CoreSDKTest::InvokeKeyboardEmail()
{
Firebolt::Error error = Firebolt::Error::None;
Firebolt::Keyboard::EmailUsage type = Firebolt::Keyboard::EmailUsage::SIGN_IN;
std::string message = "Enter your email to sign into this app/device";
string response = Firebolt::IFireboltAccessor::Instance().KeyboardInterface().email(type, message, &error);
if (error == Firebolt::Error::None) {
cout << "Keyboard email response: " << response << endl;
} else {
cout << "Error while invoking keyboard.email method, error = " << static_cast<int>(error) << endl;
}
}

7 changes: 6 additions & 1 deletion src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ class CoreSDKTest {
CoreSDKTest() = default;
virtual ~CoreSDKTest() = default;

static void CreateFireboltInstance();
static void CreateFireboltInstance(const std::string& url);
static void DestroyFireboltInstance();
static void TestCoreStaticSDK();
static void GetDeviceName();
static void SubscribeDeviceNameChanged();
static void UnsubscribeDeviceNameChanged();
static void GetDeviceModel();
static void GetDeviceSKU();
static void GetDeviceAudio();
static void SubscribeDeviceAudioChanged();
static void UnsubscribeDeviceAudioChanged();
Expand All @@ -66,6 +68,9 @@ class CoreSDKTest {
static void GetAccessibilityClosedCaptionsSettings();
static void SubscribeAccessibilityClosedCaptionsSettingsChanged();
static void UnsubscribeAccessibilityClosedCaptionsSettingsChanged();
static void InvokeKeyboardStandard();
static void InvokeKeyboardPassword();
static void InvokeKeyboardEmail();
static bool WaitOnConnectionReady();

private:
Expand Down
82 changes: 70 additions & 12 deletions src/sdks/core/src/cpp/sdk/cpptest/Main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

#include <getopt.h>
#include "CoreSDKTest.h"

void ShowMenu()
Expand All @@ -14,10 +14,22 @@ void ShowMenu()
"\tP : Subscribe/Unsubscribe for Localization Preferred AudioLanguages Change\n"
"\tC : Get Closed Caption Settings\n"
"\tB : Subscribe/Unsubscribe for Closed Caption Settings\n"
"\tK : Invoke keyboard methods email/password/standard\n"
"\tM : Get Device Model\n"
"\tE : Get Device sku\n"
"\tQ : Quit\n\n"
);
}

void ShowKeyboardMenu()
{
printf("Enter\n"
"\tE: Invoke Email method\n"
"\tP: Invoke Password method\n"
"\tS: Invoke Standard method\n"
"\tQ : Quit\n");
}

void ShowEventMenu()
{
printf("Enter\n"
Expand All @@ -26,6 +38,33 @@ void ShowEventMenu()
"\tQ : Quit\n");
}

void HandleKeyboardMethodsInvokation()
{
int opt;
do {
getchar();
ShowKeyboardMenu();
printf("Enter option : ");
opt = toupper(getchar());
switch (opt) {
case 'E': {
CoreSDKTest::InvokeKeyboardEmail();
break;
}
case 'P': {
CoreSDKTest::InvokeKeyboardPassword();
break;
}
case 'S': {
CoreSDKTest::InvokeKeyboardStandard();
break;
}
default:
break;
}
} while (opt != 'Q');
}

#define HandleEventListener(Module, eventFuncName) \
{ \
int opt; \
Expand All @@ -49,21 +88,27 @@ void ShowEventMenu()
} while (opt != 'Q'); \
}

#define options ":hu:"
int main (int argc, char* argv[])
{
char* config = "{\
\"waitTime\": 1000,\
\"logLevel\": \"Info\",\
\"workerPool\":{\
\"queueSize\": 8,\
\"threadCount\": 3\
},\
\"wsUrl\": \"ws://127.0.0.1:9998\"\
}";
int c;
std::string url = "ws://127.0.0.1:9998";
while ((c = getopt (argc, argv, options)) != -1) {
switch (c)
{
case 'u':
url = optarg;
break;

case 'h':
printf("./TestFireboltManage -u ws://ip:port\n");
exit(1);
}
}

printf("Firebolt Core SDK Test\n");
CoreSDKTest::CreateFireboltInstance();

CoreSDKTest::CreateFireboltInstance(url);
int option;
if (CoreSDKTest::WaitOnConnectionReady() == true) {
do {
Expand Down Expand Up @@ -111,6 +156,19 @@ int main (int argc, char* argv[])
HandleEventListener(Accessibility, ClosedCaptionsSettingsChanged)
break;
}
case 'K': {
HandleKeyboardMethodsInvokation();
break;
}
case 'M': {
CoreSDKTest::GetDeviceModel();
break;
}
case 'E': {
CoreSDKTest::GetDeviceSKU();
break;
}

default:
break;
}
Expand Down

0 comments on commit c0253b3

Please sign in to comment.