From f6000e209c93213f70cad98d52cf388a79195919 Mon Sep 17 00:00:00 2001 From: Chihun Jeong Date: Wed, 5 Oct 2022 15:14:10 +0900 Subject: [PATCH] libaurum: add packageName to actionAndWaitEvent command Change-Id: I7d8e4699093ce98592fe6eab90e75a205a9c04d9 (cherry picked from commit 5e550cb6d03b0a0e98e3bbe18921a8e897710e2c) --- libaurum/inc/Accessibility/AccessibleWatcher.h | 2 +- libaurum/inc/Impl/Accessibility/AtspiAccessibleWatcher.h | 2 +- libaurum/inc/Impl/Accessibility/MockAccessibleWatcher.h | 2 +- libaurum/inc/UiDevice.h | 3 ++- libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc | 6 +++--- libaurum/src/Impl/Accessibility/MockAccessibleWatcher.cc | 2 +- libaurum/src/UiDevice.cc | 8 ++++---- .../src/Commands/ActionAndWaitEventCommand.cc | 2 +- org.tizen.aurum-bootstrap/src/Commands/LaunchAppCommand.cc | 2 +- protocol/aurum.proto | 1 + 10 files changed, 16 insertions(+), 14 deletions(-) diff --git a/libaurum/inc/Accessibility/AccessibleWatcher.h b/libaurum/inc/Accessibility/AccessibleWatcher.h index 227b0de..5f2c300 100644 --- a/libaurum/inc/Accessibility/AccessibleWatcher.h +++ b/libaurum/inc/Accessibility/AccessibleWatcher.h @@ -108,7 +108,7 @@ public: * * @since_tizen 6.5 */ - virtual bool executeAndWaitForEvents(const Runnable *cmd, const A11yEvent type, const int timeout) = 0; + virtual bool executeAndWaitForEvents(const Runnable *cmd, const A11yEvent type, const int timeout, const std::string packageName) = 0; /** * @brief Gets active application map. diff --git a/libaurum/inc/Impl/Accessibility/AtspiAccessibleWatcher.h b/libaurum/inc/Impl/Accessibility/AtspiAccessibleWatcher.h index e63bf03..9285e6a 100644 --- a/libaurum/inc/Impl/Accessibility/AtspiAccessibleWatcher.h +++ b/libaurum/inc/Impl/Accessibility/AtspiAccessibleWatcher.h @@ -105,7 +105,7 @@ public: /** * @copydoc @AccessibleWatcher::executeAndWaitForEvents() */ - virtual bool executeAndWaitForEvents(const Runnable *cmd, const A11yEvent type, const int timeout) override; + virtual bool executeAndWaitForEvents(const Runnable *cmd, const A11yEvent type, const int timeout, const std::string packageName) override; /** * @copydoc @AccessibleWatcher::getActiveAppMap() diff --git a/libaurum/inc/Impl/Accessibility/MockAccessibleWatcher.h b/libaurum/inc/Impl/Accessibility/MockAccessibleWatcher.h index bf480cb..0139365 100644 --- a/libaurum/inc/Impl/Accessibility/MockAccessibleWatcher.h +++ b/libaurum/inc/Impl/Accessibility/MockAccessibleWatcher.h @@ -71,7 +71,7 @@ public: * @brief TBD * @since_tizen 6.5 */ - virtual bool executeAndWaitForEvents(const Runnable *cmd, const A11yEvent type, const int timeout) override; + virtual bool executeAndWaitForEvents(const Runnable *cmd, const A11yEvent type, const int timeout, const std::string packageName) override; std::map> getActiveAppMap(void); diff --git a/libaurum/inc/UiDevice.h b/libaurum/inc/UiDevice.h index 7e89949..fa4a22a 100644 --- a/libaurum/inc/UiDevice.h +++ b/libaurum/inc/UiDevice.h @@ -364,13 +364,14 @@ public: * @param[in] cmd @Runnable * @param[in] type one of @A11yEvent * @param[in] timeout time(millisecond) to wait event occur + * @param[in] packageName package name that event occurs * * @return true if event happened in time, otherwise false * * @since_tizen 6.5 */ bool executeAndWaitForEvents( - const Runnable *cmd, const A11yEvent type, const int timeout) const; + const Runnable *cmd, const A11yEvent type, const int timeout, const std::string packageName) const; public: /** * @brief Gets UiDevice instance. diff --git a/libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc b/libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc index 8e91895..f3d7d8e 100644 --- a/libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc +++ b/libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc @@ -306,7 +306,7 @@ std::vector> AtspiAccessibleWatcher::getA return ret; } -bool AtspiAccessibleWatcher::executeAndWaitForEvents(const Runnable *cmd, const A11yEvent type, const int timeout) +bool AtspiAccessibleWatcher::executeAndWaitForEvents(const Runnable *cmd, const A11yEvent type, const int timeout, const std::string packageName) { mMutex.lock(); mEventQueue.clear(); @@ -327,9 +327,9 @@ bool AtspiAccessibleWatcher::executeAndWaitForEvents(const Runnable *cmd, const if (!localEvents.empty()) { for (const auto &event : localEvents) { - if (COMPARE(type, event->getEvent())) + if (COMPARE(type, event->getEvent()) && (packageName.empty() || packageName == event->getPkg())) { - LOGI("type %d == %d name %s pkg %s",static_cast(type), static_cast(event->getEvent()), event->getName().c_str(), event->getPkg().c_str()); + LOGI("type %d == %d name %s pkg %s",static_cast(type), static_cast(event->getEvent()), event->getName().c_str(), event->getPkg().c_str()); return true; } } diff --git a/libaurum/src/Impl/Accessibility/MockAccessibleWatcher.cc b/libaurum/src/Impl/Accessibility/MockAccessibleWatcher.cc index 2a218d1..4377d88 100644 --- a/libaurum/src/Impl/Accessibility/MockAccessibleWatcher.cc +++ b/libaurum/src/Impl/Accessibility/MockAccessibleWatcher.cc @@ -68,7 +68,7 @@ std::shared_ptr MockAccessibleWatcher::addApplication return app; } -bool MockAccessibleWatcher::executeAndWaitForEvents(const Runnable *cmd, const A11yEvent type, const int timeout) +bool MockAccessibleWatcher::executeAndWaitForEvents(const Runnable *cmd, const A11yEvent type, const int timeout, const std::string packageName) { return true; } diff --git a/libaurum/src/UiDevice.cc b/libaurum/src/UiDevice.cc index 198dcd8..eccd630 100644 --- a/libaurum/src/UiDevice.cc +++ b/libaurum/src/UiDevice.cc @@ -301,20 +301,20 @@ bool UiDevice::waitForIdle() const bool UiDevice::waitForEvents( const A11yEvent type, const int timeout) const { - return executeAndWaitForEvents(NULL, type, timeout); + return executeAndWaitForEvents(NULL, type, timeout, std::string()); } bool UiDevice::executeAndWaitForEvents( - const Runnable *cmd, const A11yEvent type, const int timeout) const + const Runnable *cmd, const A11yEvent type, const int timeout, const std::string packageName) const { - return AccessibleWatcher::getInstance()->executeAndWaitForEvents(cmd, type, timeout); + return AccessibleWatcher::getInstance()->executeAndWaitForEvents(cmd, type, timeout, packageName); } bool UiDevice::sendKeyAndWaitForEvents( const std::string keycode, const A11yEvent type, const int timeout) const { std::unique_ptr cmd = std::make_unique(keycode); - return executeAndWaitForEvents(cmd.get(), type, timeout); + return executeAndWaitForEvents(cmd.get(), type, timeout, std::string()); } bool UiDevice::click(const int x, const int y) diff --git a/org.tizen.aurum-bootstrap/src/Commands/ActionAndWaitEventCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/ActionAndWaitEventCommand.cc index 76d5e4b..4449c2f 100644 --- a/org.tizen.aurum-bootstrap/src/Commands/ActionAndWaitEventCommand.cc +++ b/org.tizen.aurum-bootstrap/src/Commands/ActionAndWaitEventCommand.cc @@ -44,7 +44,7 @@ A11yEvent convertEventType(const ::aurum::ReqActionAndWaitEvent_EventType type) std::unique_ptr cmd = std::make_unique( mRequest->type(), mRequest->elementid(), mRequest->xf86keycode()); std::shared_ptr obj = UiDevice::getInstance(); - bool ret = obj->executeAndWaitForEvents(cmd.get(), convertEventType(mRequest->eventtype()), mRequest->timeoutms()); + bool ret = obj->executeAndWaitForEvents(cmd.get(), convertEventType(mRequest->eventtype()), mRequest->timeoutms(), mRequest->packagename()); if (ret) mResponse->set_status(::aurum::RspStatus::OK); else mResponse->set_status(::aurum::RspStatus::ERROR); diff --git a/org.tizen.aurum-bootstrap/src/Commands/LaunchAppCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/LaunchAppCommand.cc index 8f85d5b..401ac0a 100644 --- a/org.tizen.aurum-bootstrap/src/Commands/LaunchAppCommand.cc +++ b/org.tizen.aurum-bootstrap/src/Commands/LaunchAppCommand.cc @@ -35,7 +35,7 @@ LaunchAppCommand::LaunchAppCommand(const ::aurum::ReqLaunchApp *request, LOGI("LaunchApp --------------- "); std::unique_ptr cmd = std::make_unique(mRequest->packagename(), mRequest->data()); std::shared_ptr obj = UiDevice::getInstance(); - obj->executeAndWaitForEvents(cmd.get(), A11yEvent::EVENT_WINDOW_ACTIVATE, WAIT_APP_LAUNCH); + obj->executeAndWaitForEvents(cmd.get(), A11yEvent::EVENT_WINDOW_ACTIVATE, WAIT_APP_LAUNCH, mRequest->packagename()); return grpc::Status::OK; } \ No newline at end of file diff --git a/protocol/aurum.proto b/protocol/aurum.proto index 2240ae5..73ed266 100644 --- a/protocol/aurum.proto +++ b/protocol/aurum.proto @@ -572,6 +572,7 @@ message ReqActionAndWaitEvent { } EventType eventType = 4; int32 timeoutMs = 5; + string packageName = 6; } message RspActionAndWaitEvent { -- 2.7.4