From 0063c21251d7cb31bf248450339e5c60ac2f72e0 Mon Sep 17 00:00:00 2001 From: Woochanlee Date: Wed, 3 Mar 2021 14:49:50 +0900 Subject: [PATCH 01/16] Add Aurum.h to manage headers. Change-Id: Ib8e7fed4ddd8e9aed4836c1fc7c0ac611bfb6021 --- libaurum/inc/Aurum.h | 17 +++++++++++++++++ libaurum/meson.build | 1 + 2 files changed, 18 insertions(+) create mode 100644 libaurum/inc/Aurum.h diff --git a/libaurum/inc/Aurum.h b/libaurum/inc/Aurum.h new file mode 100644 index 0000000..801d2dd --- /dev/null +++ b/libaurum/inc/Aurum.h @@ -0,0 +1,17 @@ +#include "UiDevice.h" +#include "UiObject.h" +#include "UiSelector.h" +#include "Sel.h" +#include "Until.h" +#include "Waiter.h" +#include "ISearchable.h" +#include "IDevice.h" +#include "AccessibleNode.h" +#include "AccessibleUtils.h" +#include "AccessibleWatcher.h" +#include "AccessibleApplication.h" +#include "AccessibleWindow.h" +#include "IEventConsumer.h" +#include "IEventSource.h" +#include "Point2D.h" +#include "Rect.h" diff --git a/libaurum/meson.build b/libaurum/meson.build index 9171b21..83417cb 100644 --- a/libaurum/meson.build +++ b/libaurum/meson.build @@ -18,6 +18,7 @@ libaurum_install_inc = [ './inc/Accessibility/IEventSource.h', './inc/Misc/Point2D.h', './inc/Misc/Rect.h', + './inc/Aurum.h', ] libaurum_inc = [ -- 2.7.4 From fe0b083aa53b17dca4d2286fc0bb2e2511e536d7 Mon Sep 17 00:00:00 2001 From: Hosang Kim Date: Tue, 23 Mar 2021 14:28:35 +0900 Subject: [PATCH 02/16] libaurum: enable early return. Change-Id: I660e0aab32ad7865db08605efdd6f3d4736da6a1 --- libaurum/src/Comparer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libaurum/src/Comparer.cc b/libaurum/src/Comparer.cc index b68869b..3372093 100644 --- a/libaurum/src/Comparer.cc +++ b/libaurum/src/Comparer.cc @@ -25,7 +25,7 @@ std::vector> Comparer::findObjects(const std::sh const std::shared_ptr selector, const std::shared_ptr root, bool earlyReturn) { - Comparer comparer(device, selector, false); + Comparer comparer(device, selector, earlyReturn); LOG_SCOPE_F(INFO, "findObjects selector(%s) from (type:%s style:%s, role:%s, text:%d) earlyReturn:%d", selector->description().c_str(), root->getType().c_str(), root->getStyle().c_str(), root->getRole().c_str(), root->getText().c_str(), earlyReturn); -- 2.7.4 From 7e5433ece3bd19cdee9e7fb0ab0aa72850c03475 Mon Sep 17 00:00:00 2001 From: Hosang Kim Date: Wed, 24 Mar 2021 15:58:11 +0900 Subject: [PATCH 03/16] libaurum: find type of attributes with "t" NUI/dali use keyword "t" instead of "type" Change-Id: I51986e6aadc9e98d2df48397ea9402a1ce42f3b9 --- libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc b/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc index 82b1e61..f506502 100644 --- a/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc +++ b/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc @@ -180,6 +180,7 @@ void AtspiAccessibleNode::refresh() GHashTable *attributes = AtspiWrapper::Atspi_accessible_get_attributes(mNode, NULL); if (attributes) { char *t = (char*)g_hash_table_lookup(attributes, "type"); + if (!t) t = (char*)g_hash_table_lookup(attributes, "t"); char *s = (char*)g_hash_table_lookup(attributes, "style"); char *a = (char*)g_hash_table_lookup(attributes, "automationId"); -- 2.7.4 From 7c053c2623cd957ad476eadae26ad0c924aea811 Mon Sep 17 00:00:00 2001 From: Hosang Kim Date: Fri, 9 Apr 2021 16:29:50 +0900 Subject: [PATCH 04/16] libaurum: apply pkg name for accesible node Change-Id: Iba4cbbaa72b3d03b81ff6a964d2d617e3b69c1e6 --- libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc b/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc index f506502..2cf3fe1 100644 --- a/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc +++ b/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc @@ -173,9 +173,20 @@ void AtspiAccessibleNode::refresh() #endif gchar *name = AtspiWrapper::Atspi_accessible_get_name(mNode, NULL); - mText = name; - mPkg = name; - g_free(name); + if (name) { + mText = name; + g_free(name); + } + + AtspiAccessible *app = AtspiWrapper::Atspi_accessible_get_application(mNode, NULL); + if (app) { + gchar *pkg = AtspiWrapper::Atspi_accessible_get_name(app, NULL); + if (pkg) { + mPkg = pkg; + g_free(pkg); + } + g_object_unref(app); + } GHashTable *attributes = AtspiWrapper::Atspi_accessible_get_attributes(mNode, NULL); if (attributes) { -- 2.7.4 From 8a8a0c4120ac4aa9ca1bfa9c5b32f93c35b24594 Mon Sep 17 00:00:00 2001 From: Hosang Kim Date: Fri, 9 Apr 2021 17:11:25 +0900 Subject: [PATCH 05/16] libaurum: disable stderr log Change-Id: Ib333d125a7d867456fa244f76ee1daa6f26d297f --- libaurum/src/Impl/TizenDeviceImpl.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libaurum/src/Impl/TizenDeviceImpl.cc b/libaurum/src/Impl/TizenDeviceImpl.cc index d496e4e..91c5f81 100644 --- a/libaurum/src/Impl/TizenDeviceImpl.cc +++ b/libaurum/src/Impl/TizenDeviceImpl.cc @@ -17,6 +17,9 @@ TizenDeviceImpl::TizenDeviceImpl() : mFakeTouchHandle{0}, mFakeKeyboardHandle{0}, mFakeWheelHandle{0}, tStart{}, isTimerStarted{false}, mTouchSeq{} { + loguru::add_file("/tmp/aurum.log", loguru::Append, loguru::Verbosity_MAX); + loguru::g_stderr_verbosity = loguru::Verbosity_ERROR; + LOG_SCOPE_F(INFO, "device implementation init"); ecore_main_loop_thread_safe_call_sync([](void *data)->void*{ TizenDeviceImpl *obj = static_cast(data); -- 2.7.4 From 373712d219167dad48d10c76e4cd3fc98c36fc63 Mon Sep 17 00:00:00 2001 From: Hosang Kim Date: Mon, 12 Apr 2021 19:45:34 +0900 Subject: [PATCH 06/16] libaurum: add synchronize API Add two api for synchronize, waitForEvents, sendKeyAndWaitForEvents. sample: mDevice->sendKeyAndWaitForEvents("Left", A11yEvent::EVENT_STATE_CHANGED_FOCUSED, 5000) mDevice->waitForEvents(A11yEvent::EVENT_WINDOW_DEACTIVATE, 5000) Change-Id: If3886af4b2331f5e50f35e1dfcd27780c9618b93 --- libaurum/inc/A11yEvent.h | 49 ++++++++++ libaurum/inc/Accessibility/AccessibleWatcher.h | 10 +- .../Impl/Accessibility/AtspiAccessibleWatcher.h | 39 +++++++- .../inc/Impl/Accessibility/MockAccessibleWatcher.h | 8 +- libaurum/inc/Runnable/Runnable.h | 9 ++ libaurum/inc/Runnable/Runnables.h | 3 + libaurum/inc/Runnable/SendKeyRunnable.h | 14 +++ libaurum/inc/UiDevice.h | 22 ++++- libaurum/inc/bitmask.h | 72 ++++++++++++++ libaurum/meson.build | 4 + libaurum/src/A11yEvent.cc | 65 +++++++++++++ .../src/Impl/Accessibility/AtspiAccessibleNode.cc | 2 +- .../Impl/Accessibility/AtspiAccessibleWatcher.cc | 107 ++++++++++++++++++--- .../Impl/Accessibility/MockAccessibleWatcher.cc | 7 +- libaurum/src/Runnable/SendKeyRunnable.cc | 18 ++++ libaurum/src/Runnable/meson.build | 3 + libaurum/src/UiDevice.cc | 21 ++++ libaurum/src/meson.build | 4 +- 18 files changed, 432 insertions(+), 25 deletions(-) create mode 100644 libaurum/inc/A11yEvent.h create mode 100644 libaurum/inc/Runnable/Runnable.h create mode 100644 libaurum/inc/Runnable/Runnables.h create mode 100644 libaurum/inc/Runnable/SendKeyRunnable.h create mode 100644 libaurum/inc/bitmask.h create mode 100644 libaurum/src/A11yEvent.cc create mode 100644 libaurum/src/Runnable/SendKeyRunnable.cc create mode 100644 libaurum/src/Runnable/meson.build diff --git a/libaurum/inc/A11yEvent.h b/libaurum/inc/A11yEvent.h new file mode 100644 index 0000000..43da498 --- /dev/null +++ b/libaurum/inc/A11yEvent.h @@ -0,0 +1,49 @@ +#pragma once +#include "bitmask.h" + +#include + +enum class A11yEvent { + EVENT_NONE = 0x00000, + EVENT_WINDOW_CREATE = 0x00001, + EVENT_WINDOW_CLOSE = 0x00002, + EVENT_WINDOW_MINIMIZE = 0x00004, + EVENT_WINDOW_MAXIMIZE = 0x00008, + EVENT_WINDOW_RESTORE = 0x00010, + EVENT_WINDOW_ACTIVATE = 0x00020, + EVENT_WINDOW_DEACTIVATE = 0x00040, + EVENT_WINDOW_RAISE = 0x00080, + EVENT_WINDOW_LOWER = 0x00100, + EVENT_WINDOW_MOVE = 0x00200, + EVENT_WINDOW_RESIZE = 0x00400, + + EVENT_TEXT_CHANGED_INSERT = 0x00800, + EVENT_TEXT_CHANGED_DELETE = 0x01000, + + EVENT_STATE_CHANGED_VISIBLE = 0x02000, + EVENT_STATE_CHANGED_FOCUSED = 0x04000, + EVENT_STATE_CHANGED_CHECKED = 0x08000, + EVENT_STATE_CHANGED_PRESSED = 0x10000, + EVENT_STATE_CHANGED_SELECTED = 0x20000, +}; + +enableEnumClassBitfield(A11yEvent); + +class A11yEventInfo { +public: + A11yEventInfo(); + A11yEventInfo(A11yEvent event, std::string name = "", std::string pkg = ""); + A11yEventInfo(std::string event, std::string name = "", std::string pkg = ""); + ~A11yEventInfo(); +public: + A11yEvent getEvent(); + A11yEvent getEvent(std::string event); + std::string getName(); + std::string getPkg(); + +protected: + const A11yEvent mEvent; + const std::string mName; + const std::string mPkg; +}; + diff --git a/libaurum/inc/Accessibility/AccessibleWatcher.h b/libaurum/inc/Accessibility/AccessibleWatcher.h index d767742..e695057 100644 --- a/libaurum/inc/Accessibility/AccessibleWatcher.h +++ b/libaurum/inc/Accessibility/AccessibleWatcher.h @@ -6,6 +6,8 @@ #include "AccessibleNode.h" #include "AccessibleUtils.h" #include "IEventSource.h" +#include "Runnable.h" +#include "A11yEvent.h" #include #include @@ -57,6 +59,12 @@ public: */ virtual std::vector> getApplications(void) const = 0; + /**s + * @brief TBD + * @since_tizen 6.5 + */ + virtual bool executeAndWaitForEvents(const Runnable *cmd, const A11yEvent type, const int timeout) = 0; + public: /** * @brief TBD @@ -92,4 +100,4 @@ private: * @brief TBD */ std::mutex mLock; -}; \ No newline at end of file +}; diff --git a/libaurum/inc/Impl/Accessibility/AtspiAccessibleWatcher.h b/libaurum/inc/Impl/Accessibility/AtspiAccessibleWatcher.h index 3eb3566..3d8294f 100644 --- a/libaurum/inc/Impl/Accessibility/AtspiAccessibleWatcher.h +++ b/libaurum/inc/Impl/Accessibility/AtspiAccessibleWatcher.h @@ -97,6 +97,12 @@ public: */ virtual std::vector> getApplications(void) const override; + /** + * @brief TBD + * @since_tizen 6.5 + */ + virtual bool executeAndWaitForEvents(const Runnable *cmd, const A11yEvent type, const int timeout) override; + public: /** * @brief TBD @@ -140,6 +146,11 @@ public: */ void onObjectDefunct(AtspiAccessible* node) override; + /** + * @brief TBD + * @since_tizen 6.5 + */ + static void onEventListener(AtspiEvent *event, void *user_data); private: /** * @brief TBD @@ -167,12 +178,25 @@ private: void print_debug(); -private: + /** + * @brief TBD + * @since_tizen 6.5 + */ + void addEventListener(AtspiEventListener *listener, A11yEvent type); + + /** + * @brief TBD + * @since_tizen 6.5 + */ + void removeEventListener(AtspiEventListener *listener, A11yEvent type); + +public: /** * @brief TBD */ - static AtspiEventListener * listener; + static guint timeoutId; +private: /** * @brief TBD */ @@ -198,4 +222,13 @@ private: */ std::map mWindowAppMap; -}; \ No newline at end of file + /** + * @brief TBD + */ + static GThread * mEventThread; + + /** + * @brief TBD + */ + static std::vector> mEventQueue; +}; diff --git a/libaurum/inc/Impl/Accessibility/MockAccessibleWatcher.h b/libaurum/inc/Impl/Accessibility/MockAccessibleWatcher.h index 5262cf2..c183248 100644 --- a/libaurum/inc/Impl/Accessibility/MockAccessibleWatcher.h +++ b/libaurum/inc/Impl/Accessibility/MockAccessibleWatcher.h @@ -42,6 +42,12 @@ public: */ virtual std::vector> getApplications(void) const override; + /** + * @brief TBD + * @since_tizen 6.5 + */ + virtual bool executeAndWaitForEvents(const Runnable *cmd, const A11yEvent type, const int timeout) override; + public: /** * @brief TBD @@ -60,4 +66,4 @@ private: * @brief TBD */ std::vector> mApplicationList; -}; \ No newline at end of file +}; diff --git a/libaurum/inc/Runnable/Runnable.h b/libaurum/inc/Runnable/Runnable.h new file mode 100644 index 0000000..354c90f --- /dev/null +++ b/libaurum/inc/Runnable/Runnable.h @@ -0,0 +1,9 @@ +#pragma once + +class Runnable +{ +public: + virtual ~Runnable() { } + virtual void run() const = 0; +}; + diff --git a/libaurum/inc/Runnable/Runnables.h b/libaurum/inc/Runnable/Runnables.h new file mode 100644 index 0000000..1428466 --- /dev/null +++ b/libaurum/inc/Runnable/Runnables.h @@ -0,0 +1,3 @@ +#pragma once + +#include "SendKeyRunnable.h" diff --git a/libaurum/inc/Runnable/SendKeyRunnable.h b/libaurum/inc/Runnable/SendKeyRunnable.h new file mode 100644 index 0000000..57cf886 --- /dev/null +++ b/libaurum/inc/Runnable/SendKeyRunnable.h @@ -0,0 +1,14 @@ +#pragma once + +#include + +#include "Runnable.h" + +class SendKeyRunnable : public Runnable { +protected: + std::string mKeycode; + +public: + SendKeyRunnable(std::string keycode); + void run() const override; +}; diff --git a/libaurum/inc/UiDevice.h b/libaurum/inc/UiDevice.h index ce9fd1f..504ceff 100644 --- a/libaurum/inc/UiDevice.h +++ b/libaurum/inc/UiDevice.h @@ -10,6 +10,9 @@ #include "AccessibleNode.h" #include "Waiter.h" +#include "Runnable.h" +#include "A11yEvent.h" + #include #include @@ -158,6 +161,23 @@ public: std::shared_ptr waitFor( const std::function(const ISearchable *)> condition) const; + + /** + * @brief TBD + * @since_tizen 6.5 + */ + bool waitForEvents( + const A11yEvent type, const int timeout) const; + + /** + * @brief TBD + * @since_tizen 6.5 + */ + bool sendKeyAndWaitForEvents( + const std::string keycode, const A11yEvent type, const int timeout) const; +private: + bool executeAndWaitForEvents( + const Runnable *cmd, const A11yEvent type, const int timeout) const; public: /** * @brief TBD @@ -206,4 +226,4 @@ private: * @brief TBD */ const Waiter *mWaiter; -}; \ No newline at end of file +}; diff --git a/libaurum/inc/bitmask.h b/libaurum/inc/bitmask.h new file mode 100644 index 0000000..0dda2f6 --- /dev/null +++ b/libaurum/inc/bitmask.h @@ -0,0 +1,72 @@ +#pragma once +#include + +template +struct enable_bitmask_operators{ + static const bool enable=false; +}; + +#define enableEnumClassBitfield(E) template<> \ + struct enable_bitmask_operators{ \ + static const bool enable=true; \ + } + +template +typename std::enable_if_t::enable,E> +operator|(E lhs,E rhs){ + typedef typename std::underlying_type_t underlying; + return static_cast( + static_cast(lhs) | static_cast(rhs)); +} + +template +typename std::enable_if_t::enable,E> +operator&(E lhs,E rhs){ + typedef typename std::underlying_type_t underlying; + return static_cast( + static_cast(lhs) & static_cast(rhs)); +} + +template +typename std::enable_if_t::enable,E> +operator^(E lhs,E rhs){ + typedef typename std::underlying_type_t underlying; + return static_cast( + static_cast(lhs) ^ static_cast(rhs)); +} + +template +typename std::enable_if_t::enable,E> +operator~(E lhs){ + typedef typename std::underlying_type_t underlying; + return static_cast( + ~static_cast(lhs)); +} + +template +typename std::enable_if_t::enable,E&> +operator|=(E& lhs,E rhs){ + typedef typename std::underlying_type_t underlying; + lhs=static_cast( + static_cast(lhs) | static_cast(rhs)); + return lhs; +} + +template +typename std::enable_if_t::enable,E&> +operator&=(E& lhs,E rhs){ + typedef typename std::underlying_type_t underlying; + lhs=static_cast( + static_cast(lhs) & static_cast(rhs)); + return lhs; +} + +template +typename std::enable_if_t::enable,E&> +operator^=(E& lhs,E rhs){ + typedef typename std::underlying_type_t underlying; + lhs=static_cast( + static_cast(lhs) ^ static_cast(rhs)); + return lhs; +} + diff --git a/libaurum/meson.build b/libaurum/meson.build index 83417cb..85afdb3 100644 --- a/libaurum/meson.build +++ b/libaurum/meson.build @@ -9,6 +9,8 @@ libaurum_install_inc = [ './inc/Waiter.h', './inc/ISearchable.h', './inc/IDevice.h', + './inc/A11yEvent.h', + './inc/bitmask.h', './inc/Accessibility/AccessibleNode.h', './inc/Accessibility/AccessibleUtils.h', './inc/Accessibility/AccessibleWatcher.h', @@ -16,6 +18,7 @@ libaurum_install_inc = [ './inc/Accessibility/AccessibleWindow.h', './inc/Accessibility/IEventConsumer.h', './inc/Accessibility/IEventSource.h', + './inc/Runnable/Runnable.h', './inc/Misc/Point2D.h', './inc/Misc/Rect.h', './inc/Aurum.h', @@ -27,6 +30,7 @@ libaurum_inc = [ include_directories('./inc/Impl'), include_directories('./inc/Impl/Accessibility'), include_directories('./inc/Misc'), + include_directories('./inc/Runnable/'), root_inc, loguru_inc, ] diff --git a/libaurum/src/A11yEvent.cc b/libaurum/src/A11yEvent.cc new file mode 100644 index 0000000..325d6fb --- /dev/null +++ b/libaurum/src/A11yEvent.cc @@ -0,0 +1,65 @@ +#include "A11yEvent.h" + +#include + +A11yEventInfo::A11yEventInfo() : A11yEventInfo(A11yEvent::EVENT_NONE, nullptr, nullptr) {} + +A11yEventInfo::~A11yEventInfo() {} + +A11yEventInfo::A11yEventInfo(A11yEvent event, std::string name, std::string pkg) + : mEvent(event), + mName(name), + mPkg(pkg) +{ +} + +A11yEventInfo::A11yEventInfo(std::string event, std::string name, std::string pkg) + : mEvent(getEvent(event)), + mName(name), + mPkg(pkg) +{ +} + + +static std::unordered_map const table = { {"window:create", A11yEvent::EVENT_WINDOW_CREATE}, + {"window:close", A11yEvent::EVENT_WINDOW_CLOSE}, + {"window:minimize", A11yEvent::EVENT_WINDOW_MINIMIZE}, + {"window:maxmize", A11yEvent::EVENT_WINDOW_MAXIMIZE}, + {"window:restore", A11yEvent::EVENT_WINDOW_RESTORE}, + {"window:activate", A11yEvent::EVENT_WINDOW_ACTIVATE}, + {"window:deactivate", A11yEvent::EVENT_WINDOW_DEACTIVATE}, + {"window:raise", A11yEvent::EVENT_WINDOW_RAISE}, + {"window:lower", A11yEvent::EVENT_WINDOW_LOWER}, + {"window:resize", A11yEvent::EVENT_WINDOW_RESIZE}, + {"window:move", A11yEvent::EVENT_WINDOW_MOVE}, + {"object:text-changed:insert", A11yEvent::EVENT_TEXT_CHANGED_INSERT}, + {"object:text-changed:delete", A11yEvent::EVENT_TEXT_CHANGED_DELETE}, + {"object:state-changed:VISIBLE", A11yEvent::EVENT_STATE_CHANGED_VISIBLE}, + {"object:state-changed:focused", A11yEvent::EVENT_STATE_CHANGED_FOCUSED}, + {"object:state-changed:checked", A11yEvent::EVENT_STATE_CHANGED_CHECKED}, + {"object:state-changed:pressed", A11yEvent::EVENT_STATE_CHANGED_PRESSED}, + {"object:state-changed:selected", A11yEvent::EVENT_STATE_CHANGED_SELECTED} }; + +A11yEvent A11yEventInfo::getEvent() +{ + return mEvent; +} + +A11yEvent A11yEventInfo::getEvent(std::string event) +{ + auto it = table.find(event); + if (it != table.end()) { + return it->second; + } + return A11yEvent::EVENT_NONE; +} + +std::string A11yEventInfo::getName() +{ + return mName; +} + +std::string A11yEventInfo::getPkg() +{ + return mPkg; +} diff --git a/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc b/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc index 2cf3fe1..1b2c4db 100644 --- a/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc +++ b/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc @@ -398,4 +398,4 @@ void AtspiAccessibleNode::setFeatureProperty(AtspiStateType type) default: break; } -} \ No newline at end of file +} diff --git a/libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc b/libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc index 59dfe94..0925ef6 100644 --- a/libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc +++ b/libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc @@ -5,10 +5,14 @@ #include "AtspiAccessibleNode.h" #include "AtspiWrapper.h" #include +#include +#include +#include #include -AtspiEventListener *AtspiAccessibleWatcher::listener = nullptr; +std::vector> AtspiAccessibleWatcher::mEventQueue; +GThread *AtspiAccessibleWatcher::mEventThread = nullptr; static bool iShowingNode(AtspiAccessible *node) { @@ -40,7 +44,6 @@ findActiveNode(AtspiAccessible *node, int depth, std::vector ret{}; if (iShowingNode(node)) { - g_object_ref(node); char *name = AtspiWrapper::Atspi_accessible_get_name(node, NULL); if (name) { LOG_SCOPE_F(INFO, "%s", name); @@ -67,6 +70,27 @@ findActiveNode(AtspiAccessible *node, int depth, return ret; } +static gpointer _event_thread_loop (gpointer data) +{ + LOG_F(INFO, "event thread start"); + AtspiEventListener * listener = + atspi_event_listener_new(AtspiAccessibleWatcher::onAtspiEvents, NULL, NULL); + + atspi_event_listener_register(listener, "window:", NULL); + atspi_event_listener_register(listener, "object:state-changed:focused", NULL); + atspi_event_listener_register(listener, "object:text-changed:insert", NULL); + + atspi_event_main(); +end: + LOG_F(INFO, "event thread end"); + atspi_event_listener_deregister(listener, "object:state-changed:focused", NULL); + atspi_event_listener_deregister(listener, "object:text-changed:insert", NULL); + atspi_event_listener_deregister(listener, "window:", NULL); + + g_object_unref(listener); + + return NULL; +} AtspiAccessibleWatcher::AtspiAccessibleWatcher() : mDbusProxy{nullptr} { @@ -75,11 +99,7 @@ AtspiAccessibleWatcher::AtspiAccessibleWatcher() atspi_set_main_context (g_main_context_default ()); atspi_init(); - listener = - atspi_event_listener_new(AtspiAccessibleWatcher::onAtspiEvents, this, NULL); - - atspi_event_listener_register(listener, "window:", NULL); - atspi_event_listener_register(listener, "object:", NULL); + mEventThread = g_thread_new("AtspiEventThread", _event_thread_loop, nullptr); mDbusProxy = g_dbus_proxy_new_for_bus_sync( G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, @@ -93,7 +113,6 @@ AtspiAccessibleWatcher::AtspiAccessibleWatcher() g_variant_new("(ssv)", "org.a11y.Status", "IsEnabled", enabled_variant), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); - g_variant_unref(enabled_variant); g_variant_unref(result); } @@ -108,23 +127,38 @@ AtspiAccessibleWatcher::~AtspiAccessibleWatcher() g_variant_new("(ssv)", "org.a11y.Status", "IsEnabled", enabled_variant), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); - atspi_event_listener_deregister(listener, "window:", NULL); - atspi_event_listener_deregister(listener, "object:", NULL); - - g_object_unref(listener); g_object_unref(mDbusProxy); - g_variant_unref(enabled_variant); g_variant_unref(result); atspi_event_quit(); + g_thread_join(mEventThread); atspi_exit(); } - void AtspiAccessibleWatcher::onAtspiEvents(AtspiEvent *event, void *user_data) { AtspiWrapper::lock(); - char *name = NULL, *pname = NULL; + if (!event->source) + { + AtspiWrapper::unlock(); + return; + } + char *name = NULL, *pkg = NULL; + name = AtspiWrapper::Atspi_accessible_get_name(event->source, NULL); + + AtspiAccessible *app = AtspiWrapper::Atspi_accessible_get_application(event->source, NULL); + if (app) + { + pkg = AtspiWrapper::Atspi_accessible_get_name(app, NULL); + g_object_unref(app); + } + else + pkg = strdup(""); + + mEventQueue.push_back(std::make_shared(std::string(event->type), std::string(name), std::string(pkg))); + if (name) free(name); + if (pkg) free(pkg); +/* char *name = NULL, *pname = NULL; AtspiAccessibleWatcher *instance = (AtspiAccessibleWatcher *)user_data; if (!event->source) @@ -159,7 +193,7 @@ void AtspiAccessibleWatcher::onAtspiEvents(AtspiEvent *event, void *user_data) static_cast(event->source)); } if (name) free(name); - if (pname) free(pname); + if (pname) free(pname);*/ AtspiWrapper::unlock(); } @@ -268,6 +302,47 @@ std::vector> AtspiAccessibleWatcher::getA return ret; } +#define COMPARE(A, B) \ + (B != A11yEvent::EVENT_NONE) && ((A & B) == B) + +bool AtspiAccessibleWatcher::executeAndWaitForEvents(const Runnable *cmd, const A11yEvent type, const int timeout) +{ + AtspiWrapper::lock(); + mEventQueue.clear(); + AtspiWrapper::unlock(); + if (cmd) + cmd->run(); + + std::chrono::system_clock::time_point start = + std::chrono::system_clock::now(); + while (true) + { + std::vector> localEvents; + AtspiWrapper::lock(); + localEvents.assign(mEventQueue.begin(), mEventQueue.end()); + mEventQueue.clear(); + AtspiWrapper::unlock(); + + if (!localEvents.empty()) + { + for (const auto &event : localEvents) { + if (COMPARE(type, event->getEvent())) + { + LOG_F(INFO, "type %d == %d name %s pkg %s",static_cast(type), static_cast(event->getEvent()), event->getName().c_str(), event->getPkg().c_str()); + return true; + } + } + } + if ((std::chrono::system_clock::now() - start) > + std::chrono::milliseconds{timeout}) + break; + std::this_thread::sleep_for( + std::chrono::milliseconds{100}); + } + + return false; +} + bool AtspiAccessibleWatcher::removeFromActivatedList(AtspiAccessible *node) { LOG_SCOPE_F(INFO,"remove from activelist node %p", node); diff --git a/libaurum/src/Impl/Accessibility/MockAccessibleWatcher.cc b/libaurum/src/Impl/Accessibility/MockAccessibleWatcher.cc index 68f7f54..379a25b 100644 --- a/libaurum/src/Impl/Accessibility/MockAccessibleWatcher.cc +++ b/libaurum/src/Impl/Accessibility/MockAccessibleWatcher.cc @@ -37,4 +37,9 @@ std::shared_ptr MockAccessibleWatcher::addApplication std::shared_ptr app = std::make_shared(appNode); this->addApplication(app); return app; -} \ No newline at end of file +} + +bool MockAccessibleWatcher::executeAndWaitForEvents(const Runnable *cmd, const A11yEvent type, const int timeout) +{ + return true; +} diff --git a/libaurum/src/Runnable/SendKeyRunnable.cc b/libaurum/src/Runnable/SendKeyRunnable.cc new file mode 100644 index 0000000..88e1fef --- /dev/null +++ b/libaurum/src/Runnable/SendKeyRunnable.cc @@ -0,0 +1,18 @@ +#include "SendKeyRunnable.h" + +#include +#include + +SendKeyRunnable::SendKeyRunnable(std::string keycode) + : mKeycode{keycode} +{ +} + +void SendKeyRunnable::run() const +{ + LOG_F(INFO, "sendKey %s",mKeycode.c_str()); + std::shared_ptr mDevice = UiDevice::getInstance(); + mDevice->pressKeyCode(mKeycode.c_str(), KeyRequestType::PRESS); + mDevice->pressKeyCode(mKeycode.c_str(), KeyRequestType::RELEASE); +} + diff --git a/libaurum/src/Runnable/meson.build b/libaurum/src/Runnable/meson.build new file mode 100644 index 0000000..f92c75d --- /dev/null +++ b/libaurum/src/Runnable/meson.build @@ -0,0 +1,3 @@ +libaurum_src += [ + files('SendKeyRunnable.cc') +] diff --git a/libaurum/src/UiDevice.cc b/libaurum/src/UiDevice.cc index 6b6a788..b9b5ab4 100644 --- a/libaurum/src/UiDevice.cc +++ b/libaurum/src/UiDevice.cc @@ -7,6 +7,8 @@ #endif #include "MockDeviceImpl.h" +#include "Runnables.h" + #include #include #include @@ -121,6 +123,25 @@ bool UiDevice::waitForIdle() const return true; } +bool UiDevice::waitForEvents( + const A11yEvent type, const int timeout) const +{ + return executeAndWaitForEvents(NULL, type, timeout); +} + +bool UiDevice::executeAndWaitForEvents( + const Runnable *cmd, const A11yEvent type, const int timeout) const +{ + return AccessibleWatcher::getInstance()->executeAndWaitForEvents(cmd, type, timeout); +} + +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); +} + bool UiDevice::click(const int x, const int y) { bool result = mDeviceImpl->click(x, y); diff --git a/libaurum/src/meson.build b/libaurum/src/meson.build index be6ee85..0a651e5 100644 --- a/libaurum/src/meson.build +++ b/libaurum/src/meson.build @@ -8,7 +8,9 @@ libaurum_src += [ files('Until.cc'), files('Waiter.cc'), files('PartialMatch.cc'), + files('A11yEvent.cc'), ] subdir('Accessibility') -subdir('Impl') \ No newline at end of file +subdir('Impl') +subdir('Runnable') -- 2.7.4 From 55f14bc44de1d252ecce54cabe8fb10c26ca3f58 Mon Sep 17 00:00:00 2001 From: Hosang Kim Date: Tue, 18 May 2021 13:11:06 +0900 Subject: [PATCH 07/16] bootstrap: add package infomation to result of findelement Change-Id: I7689152cf2328b5331dd523c015a9c30943036db --- org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc index 9056538..fb9bd1d 100644 --- a/org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc +++ b/org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc @@ -72,9 +72,10 @@ std::vector> FindElementCommand::getSelectors(void) obj->getAutomationId().c_str(), key.c_str()); ::aurum::Element* elm = mResponse->add_elements(); elm->set_elementid(key); + elm->set_package(obj->getApplicationPackage()); } mResponse->set_status(::aurum::RspStatus::OK); } return grpc::Status::OK; -} \ No newline at end of file +} -- 2.7.4 From f4e91cfc749921415b71a3e01880f4b94b66e5e6 Mon Sep 17 00:00:00 2001 From: Woochanlee Date: Tue, 25 May 2021 12:21:02 +0900 Subject: [PATCH 08/16] libaurum: Fix build warning in Until.cc shared ptr can't cast to void * (%p) Change-Id: Ia5b614fa29e6ae34000db9ca37b755dc440a9981 --- libaurum/src/Until.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libaurum/src/Until.cc b/libaurum/src/Until.cc index dea7f6d..c243fca 100644 --- a/libaurum/src/Until.cc +++ b/libaurum/src/Until.cc @@ -7,7 +7,7 @@ std::function Until::hasObject( const std::shared_ptr selector) { return [=](const ISearchable *searchable) -> bool { - LOG_SCOPE_F(INFO, "Until::hasObject sel:%p, search:%p", selector, searchable); + LOG_SCOPE_F(INFO, "Until::hasObject search:%p", searchable); std::shared_ptr obj = searchable->findObject(selector); return obj.get() != nullptr; }; @@ -17,7 +17,7 @@ std::function(const ISearchable *)> Until::findObject( const std::shared_ptr selector) { return [=](const ISearchable *searchable) -> std::shared_ptr { - LOG_SCOPE_F(INFO, "Until::findObject sel:%p, search:%p", selector, searchable); + LOG_SCOPE_F(INFO, "Until::findObject search:%p", searchable); std::shared_ptr obj = searchable->findObject(selector); return obj; }; @@ -29,4 +29,4 @@ std::function Until::checkable(const bool isCheckable) LOG_SCOPE_F(INFO, "Until::checkable checkable:%d for obj %p", isCheckable, object); return object->isClickable() == isCheckable; }; -} \ No newline at end of file +} -- 2.7.4 From fe03c47b8953190ca4569bf1b8462dd9a094d68b Mon Sep 17 00:00:00 2001 From: Woochanlee Date: Tue, 25 May 2021 11:28:47 +0900 Subject: [PATCH 09/16] libaurum: Fix build warning in Comparer.cc fix argument type mismatch. Change-Id: I15918811ef1d987618e9de2fae78d11f11ce58c5 --- libaurum/src/Comparer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libaurum/src/Comparer.cc b/libaurum/src/Comparer.cc index 3372093..b54298f 100644 --- a/libaurum/src/Comparer.cc +++ b/libaurum/src/Comparer.cc @@ -27,7 +27,7 @@ std::vector> Comparer::findObjects(const std::sh { Comparer comparer(device, selector, earlyReturn); - LOG_SCOPE_F(INFO, "findObjects selector(%s) from (type:%s style:%s, role:%s, text:%d) earlyReturn:%d", selector->description().c_str(), root->getType().c_str(), root->getStyle().c_str(), root->getRole().c_str(), root->getText().c_str(), earlyReturn); + LOG_SCOPE_F(INFO, "findObjects selector(%s) from (type:%s style:%s, role:%s, text:%s) earlyReturn:%d", selector->description().c_str(), root->getType().c_str(), root->getStyle().c_str(), root->getRole().c_str(), root->getText().c_str(), earlyReturn); if (selector->mParent) { auto ret = Comparer::findObjects(device, selector->mParent, root); -- 2.7.4 From 55f89ba04eea0b49a80e5a65d229676ec0f56123 Mon Sep 17 00:00:00 2001 From: Woochanlee Date: Tue, 25 May 2021 11:11:20 +0900 Subject: [PATCH 10/16] libaurum: Fix build warning in Waiter.cc fix argument type dismatch build warning. Change-Id: I6ddddc6509578f4286ef38c6989179409665456b --- libaurum/src/Waiter.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libaurum/src/Waiter.cc b/libaurum/src/Waiter.cc index dcbc048..bdee46a 100644 --- a/libaurum/src/Waiter.cc +++ b/libaurum/src/Waiter.cc @@ -32,7 +32,7 @@ template bool Waiter::waitFor( template R Waiter::waitFor(const std::function condition) const { - LOG_SCOPE_F(INFO, "Waiter::waitFor %p", condition); + LOG_SCOPE_F(INFO, "Waiter::waitFor ISearchable"); // startTime = currentTime(); std::chrono::system_clock::time_point start = std::chrono::system_clock::now(); @@ -51,7 +51,7 @@ R Waiter::waitFor(const std::function condition) const template R Waiter::waitFor(const std::function condition) const { - LOG_SCOPE_F(INFO, "Waiter::waitFor %p", condition); + LOG_SCOPE_F(INFO, "Waiter::waitFor UiObject"); if (mUiObject) { std::chrono::system_clock::time_point start = std::chrono::system_clock::now(); @@ -67,4 +67,4 @@ R Waiter::waitFor(const std::function condition) const return result; } return R(); -} \ No newline at end of file +} -- 2.7.4 From 28dbc9c5fe227c791212150ff13207401fbeeb3d Mon Sep 17 00:00:00 2001 From: Woochanlee Date: Tue, 25 May 2021 10:56:25 +0900 Subject: [PATCH 11/16] libloguru: Fix coverity(uninit_use_in_call) Change-Id: Ib5a5658e4c16256dff7b986251503788c8cfe2a9 CID:1227411 --- libloguru/src/loguru.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libloguru/src/loguru.cpp b/libloguru/src/loguru.cpp index 06ae87c..0042789 100644 --- a/libloguru/src/loguru.cpp +++ b/libloguru/src/loguru.cpp @@ -1053,7 +1053,7 @@ namespace loguru std::string stacktrace_as_stdstring(int skip) { // From https://gist.github.com/fmela/591333 - void* callstack[128]; + void* callstack[128] = {0}; const auto max_frames = sizeof(callstack) / sizeof(callstack[0]); int num_frames = backtrace(callstack, max_frames); char** symbols = backtrace_symbols(callstack, num_frames); @@ -1792,4 +1792,4 @@ namespace loguru #endif // _WIN32 -#endif // LOGURU_IMPLEMENTATION \ No newline at end of file +#endif // LOGURU_IMPLEMENTATION -- 2.7.4 From 4838ea00530db489b7142a41af75aa2401d046c2 Mon Sep 17 00:00:00 2001 From: Woochanlee Date: Tue, 25 May 2021 10:31:39 +0900 Subject: [PATCH 12/16] libaurum: unref GVariant to avoid leak. It deleted by 373712d219167dad48d10c76e4cd3fc98c36fc63 Change-Id: I406e62fb0e939ecd6daf9b5df6d65c88b51918a9 --- libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc b/libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc index 0925ef6..bb3b5e2 100644 --- a/libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc +++ b/libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc @@ -113,6 +113,7 @@ AtspiAccessibleWatcher::AtspiAccessibleWatcher() g_variant_new("(ssv)", "org.a11y.Status", "IsEnabled", enabled_variant), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); + g_variant_unref(enabled_variant); g_variant_unref(result); } @@ -128,6 +129,7 @@ AtspiAccessibleWatcher::~AtspiAccessibleWatcher() G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); g_object_unref(mDbusProxy); + g_variant_unref(enabled_variant); g_variant_unref(result); atspi_event_quit(); -- 2.7.4 From 14c2e4b4d2fc047058061565bbc7189f150583a1 Mon Sep 17 00:00:00 2001 From: Woochanlee Date: Tue, 25 May 2021 10:43:44 +0900 Subject: [PATCH 13/16] libaurum: Fix resource leak. GError need to free when it done. Change-Id: I324f44c51eaf1909f8e655736c8517731d8d73f5 --- libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc b/libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc index bb3b5e2..07f611e 100644 --- a/libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc +++ b/libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc @@ -115,6 +115,7 @@ AtspiAccessibleWatcher::AtspiAccessibleWatcher() g_variant_unref(enabled_variant); g_variant_unref(result); + g_error_free(error); } AtspiAccessibleWatcher::~AtspiAccessibleWatcher() @@ -131,6 +132,7 @@ AtspiAccessibleWatcher::~AtspiAccessibleWatcher() g_object_unref(mDbusProxy); g_variant_unref(enabled_variant); g_variant_unref(result); + g_error_free(error); atspi_event_quit(); g_thread_join(mEventThread); -- 2.7.4 From 36d2dc6618f97a4db816061ff9ff665064e4c6f4 Mon Sep 17 00:00:00 2001 From: Hosang Kim Date: Tue, 25 May 2021 14:43:59 +0900 Subject: [PATCH 14/16] libaurum: fix build warning in DeviceImpl.cc Change-Id: I198973bd6d82c3b1646549449fa13f3aa1fb7275 --- libaurum/src/Impl/MockDeviceImpl.cc | 7 +++---- libaurum/src/Impl/TizenDeviceImpl.cc | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/libaurum/src/Impl/MockDeviceImpl.cc b/libaurum/src/Impl/MockDeviceImpl.cc index 743e3b7..486c32e 100644 --- a/libaurum/src/Impl/MockDeviceImpl.cc +++ b/libaurum/src/Impl/MockDeviceImpl.cc @@ -43,9 +43,8 @@ bool MockDeviceImpl::click(const int x, const int y, const unsigned int intv) bool MockDeviceImpl::drag(const int sx, const int sy, const int ex, const int ey, const int steps, const int durationMs) { - int i, j; - int _durationUs, _steps, _stepUs; - int dur; + unsigned int _stepUs; + int _durationUs, _steps; int consumptionUs; if (steps <= 0) _steps = 1; @@ -231,4 +230,4 @@ long long MockDeviceImpl::timeStamp(void) clock_gettime(CLOCK_MONOTONIC, &t); long long rtn = (t.tv_sec + t.tv_nsec/1000000000.0) * 1000000; return rtn; -} \ No newline at end of file +} diff --git a/libaurum/src/Impl/TizenDeviceImpl.cc b/libaurum/src/Impl/TizenDeviceImpl.cc index 91c5f81..14f684b 100644 --- a/libaurum/src/Impl/TizenDeviceImpl.cc +++ b/libaurum/src/Impl/TizenDeviceImpl.cc @@ -171,9 +171,8 @@ int TizenDeviceImpl::stopTimer(void) bool TizenDeviceImpl::drag(const int sx, const int sy, const int ex, const int ey, const int steps, const int durationMs) { - int i, j; - int _durationUs, _steps, _stepUs; - int dur; + unsigned int _stepUs; + int _durationUs, _steps; int consumptionUs; if (steps <= 0) _steps = 1; @@ -362,7 +361,7 @@ long long TizenDeviceImpl::getSystemTime(TimeRequestType type) int TizenDeviceImpl::grabTouchSeqNumber() { - for (int i = 0 ; i < MAX_FINGER_NUMBER; i++) { + for (unsigned int i = 0 ; i < MAX_FINGER_NUMBER; i++) { if (mTouchSeq.count(i) == 0) { mTouchSeq.insert(i); return i; -- 2.7.4 From a229716443cb9ce59a7ddee6598928bd5d6eaebd Mon Sep 17 00:00:00 2001 From: Hosang Kim Date: Tue, 25 May 2021 18:56:03 +0900 Subject: [PATCH 15/16] libaurum: fix build warning in AtspiAccessibleWatcher Change-Id: Ibe12ecfbb187cd0ce77f1afa643f1c5019635aaa --- libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc b/libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc index 07f611e..23b15b4 100644 --- a/libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc +++ b/libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc @@ -81,7 +81,7 @@ static gpointer _event_thread_loop (gpointer data) atspi_event_listener_register(listener, "object:text-changed:insert", NULL); atspi_event_main(); -end: + LOG_F(INFO, "event thread end"); atspi_event_listener_deregister(listener, "object:state-changed:focused", NULL); atspi_event_listener_deregister(listener, "object:text-changed:insert", NULL); @@ -241,7 +241,7 @@ void AtspiAccessibleWatcher::onWindowCreated(AtspiAccessible *node) void AtspiAccessibleWatcher::onWindowDestroyed(AtspiAccessible *node) { - LOG_SCOPE_F(INFO, "onWindowDestroyed obj:%p vis:%d", node); + LOG_SCOPE_F(INFO, "onWindowDestroyed obj:%p", node); notifyAll((int)EventType::Window, (int)WindowEventType::WindowDestroyed, node); } -- 2.7.4 From 308d8a980e91cc2cb4924eb73cf6bd691749c3c0 Mon Sep 17 00:00:00 2001 From: Woochanlee Date: Fri, 28 May 2021 17:55:19 +0900 Subject: [PATCH 16/16] bootstrap: Delete Sync Command It do nothing. Change-Id: I0a17b090566172c6b7dc474ae3ca2271f97afa3d --- org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h | 5 +---- org.tizen.aurum-bootstrap/inc/Commands/Command.h | 2 +- org.tizen.aurum-bootstrap/inc/Commands/Commands.h | 2 -- org.tizen.aurum-bootstrap/inc/Commands/SyncCommand.h | 18 ------------------ org.tizen.aurum-bootstrap/meson.build | 1 - org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc | 7 ------- org.tizen.aurum-bootstrap/src/Commands/SyncCommand.cc | 19 ------------------- protocol/aurum.proto | 3 +-- protocol/examples/node/client.js | 2 -- protocol/examples/python/legacySamples/sample01.py | 4 ---- protocol/examples/python/legacySamples/sample02.py | 5 ----- protocol/examples/python/legacySamples/sample03.py | 5 ----- protocol/examples/python/legacySamples/sample04.py | 6 ------ 13 files changed, 3 insertions(+), 76 deletions(-) delete mode 100644 org.tizen.aurum-bootstrap/inc/Commands/SyncCommand.h delete mode 100644 org.tizen.aurum-bootstrap/src/Commands/SyncCommand.cc diff --git a/org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h b/org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h index b4550b9..9c0d637 100644 --- a/org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h +++ b/org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h @@ -13,9 +13,6 @@ protected: ::grpc::Status execute(Command *cmd); public: - ::grpc::Status sync(::grpc::ServerContext * context, - const ::aurum::ReqEmpty *request, - ::aurum::RspEmpty * response) override; ::grpc::Status killServer(::grpc::ServerContext * context, const ::aurum::ReqEmpty *request, ::aurum::RspEmpty * response) override; @@ -92,4 +89,4 @@ public: ::grpc::Status dumpObjectTree(::grpc::ServerContext *context, const ::aurum::ReqDumpObjectTree *request, ::aurum::RspDumpObjectTree * response) override; -}; \ No newline at end of file +}; diff --git a/org.tizen.aurum-bootstrap/inc/Commands/Command.h b/org.tizen.aurum-bootstrap/inc/Commands/Command.h index 85607df..544c6fc 100644 --- a/org.tizen.aurum-bootstrap/inc/Commands/Command.h +++ b/org.tizen.aurum-bootstrap/inc/Commands/Command.h @@ -13,4 +13,4 @@ public: virtual ::grpc::Status execute() = 0; virtual ::grpc::Status executePost(); virtual ::grpc::Status executePre(); -}; \ No newline at end of file +}; diff --git a/org.tizen.aurum-bootstrap/inc/Commands/Commands.h b/org.tizen.aurum-bootstrap/inc/Commands/Commands.h index 30dc22e..20a0dd8 100644 --- a/org.tizen.aurum-bootstrap/inc/Commands/Commands.h +++ b/org.tizen.aurum-bootstrap/inc/Commands/Commands.h @@ -1,8 +1,6 @@ #pragma once #include "Commands/KillServerCommand.h" -#include "Commands/SyncCommand.h" - #include "Commands/FindElementCommand.h" #include "Commands/GetAttributeCommand.h" diff --git a/org.tizen.aurum-bootstrap/inc/Commands/SyncCommand.h b/org.tizen.aurum-bootstrap/inc/Commands/SyncCommand.h deleted file mode 100644 index 6c52304..0000000 --- a/org.tizen.aurum-bootstrap/inc/Commands/SyncCommand.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#include -#include -#include "Commands/Command.h" -#include "ObjectMapper.h" -#include -#include "config.h" - -class SyncCommand : public Command { -private: - const ::aurum::ReqEmpty* mRequest; - ::aurum::RspEmpty* mResponse; - -public: - SyncCommand(const ::aurum::ReqEmpty* request, ::aurum::RspEmpty* response); - ::grpc::Status execute() override; -}; \ No newline at end of file diff --git a/org.tizen.aurum-bootstrap/meson.build b/org.tizen.aurum-bootstrap/meson.build index 14e8f31..eb6cfd0 100644 --- a/org.tizen.aurum-bootstrap/meson.build +++ b/org.tizen.aurum-bootstrap/meson.build @@ -33,7 +33,6 @@ bootstrap_svr_src += [ files('src/Commands/TouchDownCommand.cc'), files('src/Commands/TouchMoveCommand.cc'), files('src/Commands/TouchUpCommand.cc'), - files('src/Commands/SyncCommand.cc'), files('src/Commands/KillServerCommand.cc'), files('src/Commands/TakeScreenshotCommand.cc'), files('src/Commands/Command.cc'), diff --git a/org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc b/org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc index b5f7a44..8cf4527 100644 --- a/org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc +++ b/org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc @@ -26,13 +26,6 @@ aurumServiceImpl::aurumServiceImpl() } aurumServiceImpl::~aurumServiceImpl() {} -::grpc::Status aurumServiceImpl::aurumServiceImpl::sync( - ::grpc::ServerContext* context, const ::aurum::ReqEmpty* request, - ::aurum::RspEmpty* response) -{ - std::unique_ptr cmd = std::make_unique(request, response); - return execute(cmd.get()); -} ::grpc::Status aurumServiceImpl::aurumServiceImpl::killServer( ::grpc::ServerContext* context, const ::aurum::ReqEmpty* request, ::aurum::RspEmpty* response) diff --git a/org.tizen.aurum-bootstrap/src/Commands/SyncCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/SyncCommand.cc deleted file mode 100644 index 70c4de6..0000000 --- a/org.tizen.aurum-bootstrap/src/Commands/SyncCommand.cc +++ /dev/null @@ -1,19 +0,0 @@ -#include "SyncCommand.h" -#include - -#include "UiDevice.h" - -SyncCommand::SyncCommand(const ::aurum::ReqEmpty *request, - ::aurum::RspEmpty * response) - : mRequest{request}, mResponse{response} -{ -} - -::grpc::Status SyncCommand::execute() -{ - std::shared_ptr obj = UiDevice::getInstance(); - long long timeMs = obj->getSystemTime(TimeRequestType::WALLCLOCK); - LOG_SCOPE_F(INFO, "Sync Command @ %f", timeMs/1000.0); - // do post-command - return grpc::Status::OK; -} \ No newline at end of file diff --git a/protocol/aurum.proto b/protocol/aurum.proto index 00efec3..a93de34 100644 --- a/protocol/aurum.proto +++ b/protocol/aurum.proto @@ -6,7 +6,6 @@ package aurum; * Here is a page with some descriptions about protocol explained */ service Bootstrap { - rpc sync(ReqEmpty) returns (RspEmpty) {} rpc killServer(ReqEmpty) returns (RspEmpty) {} rpc findElement(ReqFindElement) returns (RspFindElement) {} rpc getValue(ReqGetValue) returns (RspGetValue) {} @@ -406,4 +405,4 @@ message ReqDumpObjectTree { message RspDumpObjectTree { RspStatus status = 1; repeated Element roots = 2; -} \ No newline at end of file +} diff --git a/protocol/examples/node/client.js b/protocol/examples/node/client.js index b368488..64f1007 100644 --- a/protocol/examples/node/client.js +++ b/protocol/examples/node/client.js @@ -10,8 +10,6 @@ function main() { var request = new messages.ReqFindElement(); - client.sync(new messages.ReqEmpty(), function(err, res){console.log(res)}); - request.setStrategy(proto.aurum.ReqFindElement.RequestType.TEXT); request.setTextfield("DONE"); diff --git a/protocol/examples/python/legacySamples/sample01.py b/protocol/examples/python/legacySamples/sample01.py index a143c15..28eddc4 100644 --- a/protocol/examples/python/legacySamples/sample01.py +++ b/protocol/examples/python/legacySamples/sample01.py @@ -94,10 +94,6 @@ def touchup(stub, xx, yy): rsp = stub.touchUp(aurum_pb2.ReqTouchUp(coordination=aurum_pb2.Point(x=xx,y=yy))) print(rsp) -def sync(stub): - rsp = stub.sync(aurum_pb2.ReqEmpty()) - print(rsp) - def run(): with grpc.insecure_channel('127.0.0.1:50051') as channel: stub = aurum_pb2_grpc.BootstrapStub(channel) diff --git a/protocol/examples/python/legacySamples/sample02.py b/protocol/examples/python/legacySamples/sample02.py index 5c7d849..13d2b4e 100644 --- a/protocol/examples/python/legacySamples/sample02.py +++ b/protocol/examples/python/legacySamples/sample02.py @@ -39,11 +39,6 @@ def touchup(stub, xx, yy): rsp = stub.touchUp(aurum_pb2.ReqTouchUp(coordination=aurum_pb2.Point(x=xx,y=yy))) print(rsp) -def sync(stub): - rsp = stub.sync(aurum_pb2.ReqEmpty()) - print(rsp) - - def new_memo(stub): touchdown(stub, 630,1140) time.sleep(0.1) diff --git a/protocol/examples/python/legacySamples/sample03.py b/protocol/examples/python/legacySamples/sample03.py index 65e4420..eaf9a3a 100644 --- a/protocol/examples/python/legacySamples/sample03.py +++ b/protocol/examples/python/legacySamples/sample03.py @@ -39,11 +39,6 @@ def touchup(stub, xx, yy): rsp = stub.touchUp(aurum_pb2.ReqTouchUp(coordination=aurum_pb2.Point(x=xx,y=yy))) print(rsp) -def sync(stub): - rsp = stub.sync(aurum_pb2.ReqEmpty()) - print(rsp) - - def new_memo(stub): touchdown(stub, 630,1140) time.sleep(0.1) diff --git a/protocol/examples/python/legacySamples/sample04.py b/protocol/examples/python/legacySamples/sample04.py index 12074e8..d504fdd 100644 --- a/protocol/examples/python/legacySamples/sample04.py +++ b/protocol/examples/python/legacySamples/sample04.py @@ -39,11 +39,6 @@ def touchup(stub, xx, yy): rsp = stub.touchUp(aurum_pb2.ReqTouchUp(coordination=aurum_pb2.Point(x=xx,y=yy))) print(rsp) -def sync(stub): - rsp = stub.sync(aurum_pb2.ReqEmpty()) - print(rsp) - - def new_memo(stub): touchdown(stub, 630,1140) time.sleep(0.1) @@ -112,7 +107,6 @@ def clear_text(stub, el): def run(): with grpc.insecure_channel('127.0.0.1:50051') as channel: stub = aurum_pb2_grpc.BootstrapStub(channel) -#sync(stub) foundId = findElementByText(stub, 'Title') print(foundId) -- 2.7.4