From c0253b374a5066d4a67501f28ff874a863b7ac3a Mon Sep 17 00:00:00 2001 From: HaseenaSainul Date: Wed, 29 Nov 2023 10:09:32 -0500 Subject: [PATCH] Core test update to add more test case to link with provider sequence --- .../core/src/cpp/sdk/cpptest/CoreSDKTest.cpp | 69 +++++++++++++++- .../core/src/cpp/sdk/cpptest/CoreSDKTest.h | 7 +- src/sdks/core/src/cpp/sdk/cpptest/Main.cpp | 82 ++++++++++++++++--- 3 files changed, 141 insertions(+), 17 deletions(-) diff --git a/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp b/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp index b0b9834a1..d6eeca4cc 100644 --- a/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp +++ b/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp @@ -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); @@ -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(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(error) << endl; + } +} + void PrintDeviceAudioProfiles( const Firebolt::Device::AudioProfiles& audioProfiles ) { cout << "Get Device AudioProfiles :-> " << endl; @@ -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(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(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(error) << endl; + } +} + diff --git a/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h b/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h index 93f3f207a..61ff8eb36 100644 --- a/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h +++ b/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h @@ -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(); @@ -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: diff --git a/src/sdks/core/src/cpp/sdk/cpptest/Main.cpp b/src/sdks/core/src/cpp/sdk/cpptest/Main.cpp index a76ace55e..a21407d97 100644 --- a/src/sdks/core/src/cpp/sdk/cpptest/Main.cpp +++ b/src/sdks/core/src/cpp/sdk/cpptest/Main.cpp @@ -1,4 +1,4 @@ - +#include #include "CoreSDKTest.h" void ShowMenu() @@ -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" @@ -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; \ @@ -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 { @@ -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; }