Skip to content

Commit

Permalink
CPPSDK: Async test case updates (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseenaSainul authored Mar 20, 2024
1 parent 2d7034d commit e05d7dd
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 15 deletions.
75 changes: 60 additions & 15 deletions src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ CoreSDKTest::OnNavigateToHomeIntentNotification CoreSDKTest::_navigateToHomeInte
CoreSDKTest::OnNavigateToEntityIntentNotification CoreSDKTest::_navigateToEntityIntentNotification;
CoreSDKTest::OnNavigateToTuneIntentNotification CoreSDKTest::_navigateToTuneIntentNotification;

CoreSDKTest::KeyboardEmailAsyncResponse CoreSDKTest::_keyboardEmailAsyncResponse;
CoreSDKTest::KeyboardPasswordAsyncResponse CoreSDKTest::_keyboardPasswordAsyncResponse;
CoreSDKTest::KeyboardStandardAsyncResponse CoreSDKTest::_keyboardStandardAsyncResponse;

void CoreSDKTest::ConnectionChanged(const bool connected, const Firebolt::Error error)
{
cout << "Change in connection: connected: " << connected << " error: " << static_cast<int>(error) << endl;
Expand All @@ -46,7 +50,7 @@ void CoreSDKTest::ConnectionChanged(const bool connected, const Firebolt::Error
void CoreSDKTest::CreateFireboltInstance(const std::string& url)
{
const std::string config = "{\
\"waitTime\": 60000,\
\"waitTime\": 1000,\
\"logLevel\": \"Info\",\
\"workerPool\":{\
\"queueSize\": 8,\
Expand Down Expand Up @@ -500,39 +504,80 @@ void CoreSDKTest::UnsubscribeLocalizationPreferredAudioLanguagesChanged()
}
}

void CoreSDKTest::KeyboardStandardAsyncResponse::response(const std::string& response, Firebolt::Error* error)
{
if (error && (*error != Firebolt::Error::None)) {
cout << "Error with keyboard standard response, error = " << static_cast<int>(*error) << endl;
} else {
cout << "Keyboard standard response: " << response << endl;
}
}
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;
Firebolt::IFireboltAccessor::Instance().KeyboardInterface().requestStandard(message, _keyboardStandardAsyncResponse, &error);
if (error != Firebolt::Error::None) {
cout << "Error with keyboard standard request method invoke, error = " << static_cast<int>(error) << endl;
}
}
void CoreSDKTest::AbortKeyboardStandard()
{
Firebolt::Error error = Firebolt::Error::None;
Firebolt::IFireboltAccessor::Instance().KeyboardInterface().abortStandard(_keyboardStandardAsyncResponse, &error);
if (error != Firebolt::Error::None) {
cout << "Error with keyboard standard abort method invoke, error = " << static_cast<int>(error) << endl;
}
}
void CoreSDKTest::KeyboardPasswordAsyncResponse::response(const std::string& response, Firebolt::Error* error)
{
if (error && (*error != Firebolt::Error::None)) {
cout << "Error with keyboard password response, error = " << static_cast<int>(*error) << endl;
} else {
cout << "Error while invoking keyboard.standard method, error = " << static_cast<int>(error) << endl;
cout << "Keyboard password response: " << response << 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;
Firebolt::IFireboltAccessor::Instance().KeyboardInterface().requestPassword(message, _keyboardPasswordAsyncResponse, &error);
if (error != Firebolt::Error::None) {
cout << "Error with keyboard password request method invoke, error = " << static_cast<int>(error) << endl;
}
}
void CoreSDKTest::AbortKeyboardPassword()
{
Firebolt::Error error = Firebolt::Error::None;
Firebolt::IFireboltAccessor::Instance().KeyboardInterface().abortPassword(_keyboardPasswordAsyncResponse, &error);
if (error != Firebolt::Error::None) {
cout << "Error with keyboard password abort method invoke, error = " << static_cast<int>(error) << endl;
}
}
void CoreSDKTest::KeyboardEmailAsyncResponse::response(const std::string& response, Firebolt::Error* error)
{
if (error && (*error != Firebolt::Error::None)) {
cout << "Error with email password response, error = " << static_cast<int>(*error) << endl;
} else {
cout << "Error while invoking keyboard.password method, error = " << static_cast<int>(error) << endl;
cout << "Keyboard email response: " << response << 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;
Firebolt::IFireboltAccessor::Instance().KeyboardInterface().requestEmail(type, message, _keyboardEmailAsyncResponse, &error);
if (error != Firebolt::Error::None) {
cout << "Error with keyboard email requeset method invoke, error = " << static_cast<int>(error) << endl;
}
}
void CoreSDKTest::AbortKeyboardEmail()
{
Firebolt::Error error = Firebolt::Error::None;
Firebolt::IFireboltAccessor::Instance().KeyboardInterface().abortEmail(_keyboardEmailAsyncResponse, &error);
if (error != Firebolt::Error::None) {
cout << "Error with keyboard email abort method invoke, error = " << static_cast<int>(error) << endl;
}
}

Expand Down
15 changes: 15 additions & 0 deletions src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ class CoreSDKTest {
struct OnNavigateToTuneIntentNotification : public Firebolt::Discovery::IDiscovery::IOnNavigateToTuneIntentNotification {
void onNavigateTo( const Firebolt::Intents::TuneIntent& ) override;
};
struct KeyboardEmailAsyncResponse : public Firebolt::Keyboard::IKeyboardAsyncResponse {
void response(const std::string&, Firebolt::Error*) override;
};
struct KeyboardPasswordAsyncResponse : public Firebolt::Keyboard::IKeyboardAsyncResponse {
void response(const std::string&, Firebolt::Error*) override;
};
struct KeyboardStandardAsyncResponse : public Firebolt::Keyboard::IKeyboardAsyncResponse {
void response(const std::string&, Firebolt::Error*) override;
};

public:
CoreSDKTest() = default;
Expand Down Expand Up @@ -111,8 +120,11 @@ class CoreSDKTest {
static void GetAdvertisingDeviceAttributes();

static void InvokeKeyboardStandard();
static void AbortKeyboardStandard();
static void InvokeKeyboardPassword();
static void AbortKeyboardPassword();
static void InvokeKeyboardEmail();
static void AbortKeyboardEmail();

static void VerifyProfileApproveContentRating();
static void VerifyProfileApprovePurchase();
Expand Down Expand Up @@ -183,5 +195,8 @@ class CoreSDKTest {
static OnNavigateToHomeIntentNotification _navigateToHomeIntentNotification;
static OnNavigateToEntityIntentNotification _navigateToEntityIntentNotification;
static OnNavigateToTuneIntentNotification _navigateToTuneIntentNotification;
static KeyboardEmailAsyncResponse _keyboardEmailAsyncResponse;
static KeyboardPasswordAsyncResponse _keyboardPasswordAsyncResponse;
static KeyboardStandardAsyncResponse _keyboardStandardAsyncResponse;
};

15 changes: 15 additions & 0 deletions src/sdks/core/src/cpp/sdk/cpptest/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,11 @@ void ShowKeyboardMenu()
{
printf("Enter\n"
"\tE : Invoke Email method\n"
"\tA : Abort Email method\n"
"\tP : Invoke Password method\n"
"\tC : Abort Password method\n"
"\tS : Invoke Standard method\n"
"\tK : Abort Standard method\n"
"\tQ : Quit\n");
}

Expand Down Expand Up @@ -505,14 +508,26 @@ void HandleKeyboardMethodsInvokation()
CoreSDKTest::InvokeKeyboardEmail();
break;
}
case 'A': {
CoreSDKTest::AbortKeyboardEmail();
break;
}
case 'P': {
CoreSDKTest::InvokeKeyboardPassword();
break;
}
case 'C': {
CoreSDKTest::AbortKeyboardPassword();
break;
}
case 'S': {
CoreSDKTest::InvokeKeyboardStandard();
break;
}
case 'K': {
CoreSDKTest::AbortKeyboardStandard();
break;
}
default:
break;
}
Expand Down

0 comments on commit e05d7dd

Please sign in to comment.