Skip to content

Commit

Permalink
Manage Test update based on provider integration
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseenaSainul committed Nov 23, 2023
1 parent 732bcb2 commit 83a48cf
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 4 deletions.
11 changes: 10 additions & 1 deletion src/sdks/manage/src/cpp/sdk/cpptest/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

void ShowMenu()
{
printf("Enter\n"
printf("Options ---- >\n"
"\tN : Get Device Name\n"
"\tS : Set Device Name\n"
"\tC : Subscribe/Unsubscribe for Device Name Change\n"
Expand All @@ -19,6 +19,8 @@ void ShowMenu()
#ifdef RPC_ONLY
"\tP : Subscribe/Unsubscribe for PinChallenge RequestChallenge\n"
#endif
"\tD : Register for Keyboard Provider\n"
"\tE : Send Keyboard Result to Provider\n"
"\tQ : Quit\n\n"
);
}
Expand Down Expand Up @@ -131,6 +133,13 @@ int main (int argc, char* argv[])
break;
}
#endif
case 'D': {
ManageSDKTest::RegisterKeyboardProvider();
break;
}
case 'E': {
ManageSDKTest::SendMessageToKeyboardProvider();
}
default:
break;
}
Expand Down
70 changes: 68 additions & 2 deletions src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ ManageSDKTest::OnPreferredAudioLanguagesChangedNotification ManageSDKTest::_pref
#ifdef RPC_ONLY
ManageSDKTest::OnRequestChallengeNotification ManageSDKTest::_requestChallengeNotification;
#endif
ManageSDKTest::KeyboardProvider ManageSDKTest::_keyboardProvider;

void ManageSDKTest::ConnectionChanged(const bool connected, const Firebolt::Error error)
{
Expand Down Expand Up @@ -99,7 +100,7 @@ void ManageSDKTest::SetDeviceName()
}
}

void ManageSDKTest::OnDeviceNameChangedNotification::onDeviceNameChanged( const std::string& name )
void ManageSDKTest::OnDeviceNameChangedNotification::onDeviceNameChanged( const std::string& name)
{
cout << "Name changed, new name --> " << name << endl;
}
Expand Down Expand Up @@ -270,7 +271,7 @@ void ManageSDKTest::SetLocalizationPreferredAudioLanguages()
}
}

void ManageSDKTest::OnPreferredAudioLanguagesChangedNotification::onPreferredAudioLanguagesChanged( const std::vector<std::string>& languages )
void ManageSDKTest::OnPreferredAudioLanguagesChangedNotification::onPreferredAudioLanguagesChanged( const std::vector<std::string>& languages)
{
cout << "PreferredAudioLanguages Changed, new languages --> " << endl;
for (auto language : languages) {
Expand Down Expand Up @@ -342,3 +343,68 @@ void ManageSDKTest::UnsubscribePinChallengeRequestChallenge()
}
}
#endif

ManageSDKTest::KeyboardProvider::KeyboardProvider()
: _session(nullptr)
, _parameters()
, _keyInput(false)
{
}

void ManageSDKTest::KeyboardProvider::keyboardLoop()
{
if (_keyInput) {
cout << " Invoking _session.get()->focus " << endl;
_session.get()->focus();
string key;
cout << _parameters.message << " : ";
getchar();
getline(cin, key);
cout<< " key --> " << key;
cin.putback('\n');
Firebolt::Keyboard::KeyboardResult keyboardResult;
keyboardResult.text = key;
keyboardResult.canceled = false;
cout << " Invoking _session.get()->result " << endl;
cout << " keyboardResult.text " << keyboardResult.text << endl;
_session.get()->result(keyboardResult);
_keyInput = false;
} else {
cout << " there is no active keyboard input session " << endl;
}
}

void ManageSDKTest::KeyboardProvider::standard(const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr<Firebolt::Keyboard::IKeyboardSession> session)
{
cout << "KeyboardProvider Standard is invoked" << endl;
startKeyboardSession(parameters, std::move(session));
}

void ManageSDKTest::KeyboardProvider::password(const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr<Firebolt::Keyboard::IKeyboardSession> session)
{
cout << "KeyboardProvider Password is invoked" << endl;
startKeyboardSession(parameters, std::move(session));
}

void ManageSDKTest::KeyboardProvider::email(const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr<Firebolt::Keyboard::IKeyboardSession> session)
{
cout << "KeyboardProvider Email is invoked" << endl;
startKeyboardSession(parameters, std::move(session));
}

void ManageSDKTest::KeyboardProvider::startKeyboardSession( const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr<Firebolt::Keyboard::IKeyboardSession> session )
{
_session = std::move(session);
_parameters = parameters;
_keyInput = true;
}

void ManageSDKTest::RegisterKeyboardProvider()
{
Firebolt::IFireboltAccessor::Instance().KeyboardInterface().provide(_keyboardProvider);
}

void ManageSDKTest::SendMessageToKeyboardProvider()
{
_keyboardProvider.keyboardLoop();
}
22 changes: 21 additions & 1 deletion src/sdks/manage/src/cpp/sdk/cpptest/ManageSDKTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,28 @@ class ManageSDKTest {
};

#ifdef RPC_ONLY
struct OnRequestChallengeNotification : public Firebolt::PinChallenge::IPinChallenge::IOnRequestChallengeNotification {
class OnRequestChallengeNotification : public Firebolt::PinChallenge::IPinChallenge::IOnRequestChallengeNotification {
public:
void onRequestChallenge( const Firebolt::PinChallenge::PinChallengeProviderRequest& ) override;
};
#endif
class KeyboardProvider : public Firebolt::Keyboard::IKeyboardProvider {
public:
KeyboardProvider();
~KeyboardProvider() override = default;
void standard( const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr<Firebolt::Keyboard::IKeyboardSession> session ) override;
void password( const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr<Firebolt::Keyboard::IKeyboardSession> session ) override;
void email( const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr<Firebolt::Keyboard::IKeyboardSession> session ) override;
void keyboardLoop();

private:
void startKeyboardSession(const Firebolt::Keyboard::KeyboardParameters& parameters, std::unique_ptr<Firebolt::Keyboard::IKeyboardSession> session);

private:
std::unique_ptr<Firebolt::Keyboard::IKeyboardSession> _session;
Firebolt::Keyboard::KeyboardParameters _parameters;
bool _keyInput;
};
public:
ManageSDKTest() = default;
virtual ~ManageSDKTest() = default;
Expand Down Expand Up @@ -74,6 +91,8 @@ class ManageSDKTest {
static void SubscribePinChallengeRequestChallenge();
static void UnsubscribePinChallengeRequestChallenge();
#endif
static void RegisterKeyboardProvider();
static void SendMessageToKeyboardProvider();
static bool WaitOnConnectionReady();

private:
Expand All @@ -86,5 +105,6 @@ class ManageSDKTest {
#ifdef RPC_ONLY
static OnRequestChallengeNotification _requestChallengeNotification;
#endif
static KeyboardProvider _keyboardProvider;
};

0 comments on commit 83a48cf

Please sign in to comment.