From: Hosang Kim Date: Wed, 3 Jan 2024 10:47:30 +0000 (+0900) Subject: Introduce new getMatchesInMatches API. X-Git-Tag: accepted/tizen/unified/20240205.162750^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F94%2F303694%2F5;p=platform%2Fcore%2Fuifw%2Faurum.git Introduce new getMatchesInMatches API. The getMatchesInMatches API gets the object that satisfied with both condition in the object tree. It runs quickly because the search happens in the app. Change-Id: I377fd73360014d4c99d43d388257d27dc1247c87 --- diff --git a/libaurum/inc/Accessibility/AccessibleNode.h b/libaurum/inc/Accessibility/AccessibleNode.h index bcdc1fc..16f7c89 100644 --- a/libaurum/inc/Accessibility/AccessibleNode.h +++ b/libaurum/inc/Accessibility/AccessibleNode.h @@ -138,6 +138,11 @@ public: virtual std::vector> getMatches(const std::shared_ptr selector, const bool ealryReturn) const = 0; /** + * @copydoc UiObject::getMatchesInMatches() + */ + virtual std::vector> getMatchesInMatches(const std::shared_ptr firstSelector, const std::shared_ptr secondSelector, const bool ealryReturn) const = 0; + + /** * @brief Called by @AccessibleWatcher::notifyAll. * Changes Node property If it's @EventType, @ObjectEventType are matches. * diff --git a/libaurum/inc/Impl/Accessibility/AtspiAccessibleNode.h b/libaurum/inc/Impl/Accessibility/AtspiAccessibleNode.h index 29c0aeb..eb78152 100644 --- a/libaurum/inc/Impl/Accessibility/AtspiAccessibleNode.h +++ b/libaurum/inc/Impl/Accessibility/AtspiAccessibleNode.h @@ -76,6 +76,11 @@ public: std::vector> getMatches(const std::shared_ptr selector, const bool ealryReturn) const override; /** + * @copydoc UiObject::getMatchesInMatches() + */ + std::vector> getMatchesInMatches(const std::shared_ptr firstSelector, const std::shared_ptr secondSelector, const bool ealryReturn) const override; + + /** * @copydoc AccessibleNode::isValid() */ bool isValid() const override; diff --git a/libaurum/inc/Impl/Accessibility/AtspiWrapper.h b/libaurum/inc/Impl/Accessibility/AtspiWrapper.h index 63ac89d..e7901c4 100644 --- a/libaurum/inc/Impl/Accessibility/AtspiWrapper.h +++ b/libaurum/inc/Impl/Accessibility/AtspiWrapper.h @@ -73,6 +73,7 @@ public: static void Atspi_accessible_set_listen_post_render(AtspiAccessible *obj, gboolean enabled, GError **error); static AtspiCollection *Atspi_accessible_get_collection_iface(AtspiAccessible *node); static GArray *Atspi_collection_get_matches(AtspiCollection *obj, AtspiMatchRule *rule, AtspiCollectionSortOrder sortby, gint count, gboolean traverse, GError **error); + static GArray *Atspi_collection_get_matches_in_matches(AtspiCollection *obj, AtspiMatchRule *first_rule, AtspiMatchRule *second_rule, AtspiCollectionSortOrder sortby, gint first_count, gint second_count, gboolean traverse, GError **error); static AtspiAccessibleNodeInfo *Atspi_accessible_get_node_info(AtspiAccessible *obj, GError **error); static void Atspi_accessible_free_node_info(AtspiAccessibleNodeInfo *node_info); diff --git a/libaurum/inc/Impl/Accessibility/MockAccessibleNode.h b/libaurum/inc/Impl/Accessibility/MockAccessibleNode.h index c2df6a7..4f2d02d 100644 --- a/libaurum/inc/Impl/Accessibility/MockAccessibleNode.h +++ b/libaurum/inc/Impl/Accessibility/MockAccessibleNode.h @@ -74,6 +74,11 @@ public: */ std::vector> getMatches(const std::shared_ptr selector, const bool ealryReturn) const override; + /** + * @copydoc UiObject::getMatchesInMatches() + */ + std::vector> getMatchesInMatches(const std::shared_ptr firstSelector, const std::shared_ptr secondSelector, const bool ealryReturn) const override; + public: /** * @brief TBD diff --git a/libaurum/inc/UiDevice.h b/libaurum/inc/UiDevice.h index 7315f7b..75a9b4c 100644 --- a/libaurum/inc/UiDevice.h +++ b/libaurum/inc/UiDevice.h @@ -328,6 +328,20 @@ public: const std::shared_ptr selector, const bool earlyReturn) const; /** + * @brief Get the object that satisfied with both condition in the object tree. + * + * @param[in] firstSelector @UiSelector + * @param[in] secondSelector @UiSelector + * @param[in] earlyReturn boolean + * + * @return the list of found UiObject pointer vector + * + * @since_tizen 8.0 + */ + std::vector> getMatchesInMatches( + const std::shared_ptr firstSelector, const std::shared_ptr secondSelector, const bool earlyReturn) const; + + /** * TODO */ bool waitFor( diff --git a/libaurum/inc/UiObject.h b/libaurum/inc/UiObject.h index 6689962..4b58602 100644 --- a/libaurum/inc/UiObject.h +++ b/libaurum/inc/UiObject.h @@ -153,6 +153,20 @@ public: const std::shared_ptr selector, const bool earlyReturn) const; /** + * @brief Get the object that satisfied with both condition in the object tree. + * + * @param[in] firstSelector @UiSelector + * @param[in] secondSelector @UiSelector + * @param[in] earlyReturn boolean + * + * @return the list of found UiObject pointer vector + * + * @since_tizen 8.0 + */ + std::vector> getMatchesInMatches( + const std::shared_ptr firstSelector, const std::shared_ptr secondSelector, const bool earlyReturn) const; + + /** * TODO */ bool waitFor( diff --git a/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc b/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc index df3b064..5cc212a 100644 --- a/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc +++ b/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc @@ -725,3 +725,35 @@ std::vector> AtspiAccessibleNode::getMatches(con return ret; } + +std::vector> AtspiAccessibleNode::getMatchesInMatches(const std::shared_ptr firstSelector, const std::shared_ptr secondSelector, const bool ealryReturn) const +{ + std::vector> ret{}; + + AtspiCollection *collection = AtspiWrapper::Atspi_accessible_get_collection_iface(mNode); + if (collection) { + AtspiMatchRule *firstRule = AtspiMatchRuleConvertor(firstSelector); + if (!firstRule) return ret; + + AtspiMatchRule *secondRule = AtspiMatchRuleConvertor(secondSelector); + if (!secondRule) return ret; + + int count = ealryReturn ? 1 : 0; + GArray *matches = AtspiWrapper::Atspi_collection_get_matches_in_matches(collection, firstRule, secondRule, ATSPI_Collection_SORT_ORDER_CANONICAL, 0, count, false, NULL); + if (matches) { + ret.reserve(matches->len); + AtspiAccessible *match = nullptr; + for (unsigned int i = 0; i < matches->len; i++) { + match = g_array_index(matches, AtspiAccessible *, i); + if (match) { + ret.push_back(std::make_shared(match)); + } + } + g_array_free(matches, true); + } + g_object_unref(secondRule); + g_object_unref(firstRule); + } + + return ret; +} diff --git a/libaurum/src/Impl/Accessibility/AtspiWrapper.cc b/libaurum/src/Impl/Accessibility/AtspiWrapper.cc index 10f98ff..33c1832 100644 --- a/libaurum/src/Impl/Accessibility/AtspiWrapper.cc +++ b/libaurum/src/Impl/Accessibility/AtspiWrapper.cc @@ -249,6 +249,12 @@ GArray *AtspiWrapper::Atspi_collection_get_matches(AtspiCollection *obj, AtspiMa return atspi_collection_get_matches(obj, rule, sortby, count, traverse, error); } +GArray *AtspiWrapper::Atspi_collection_get_matches_in_matches(AtspiCollection *obj, AtspiMatchRule *first_rule, AtspiMatchRule *second_rule, AtspiCollectionSortOrder sortby, gint first_count, gint second_count, gboolean traverse, GError **error) +{ + std::unique_lock lock(mMutex); + return atspi_collection_get_matches_in_matches(obj, first_rule, second_rule, sortby, first_count, second_count, traverse, error); +} + AtspiAccessibleNodeInfo *AtspiWrapper::Atspi_accessible_get_node_info(AtspiAccessible *obj, GError **error) { std::unique_lock lock(mMutex); diff --git a/libaurum/src/Impl/Accessibility/MockAccessibleNode.cc b/libaurum/src/Impl/Accessibility/MockAccessibleNode.cc index 8a51e90..ca6fc10 100644 --- a/libaurum/src/Impl/Accessibility/MockAccessibleNode.cc +++ b/libaurum/src/Impl/Accessibility/MockAccessibleNode.cc @@ -68,6 +68,14 @@ std::vector> MockAccessibleNode::getMatches(cons return ret; } +std::vector> MockAccessibleNode::getMatchesInMatches(const std::shared_ptr firstSelector, const std::shared_ptr secondSelector, const bool ealryReturn) const +{ + std::vector> ret{}; + + return ret; +} + + void* MockAccessibleNode::getRawHandler(void) const { printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__); diff --git a/libaurum/src/UiDevice.cc b/libaurum/src/UiDevice.cc index 9bb7e42..2dacea6 100644 --- a/libaurum/src/UiDevice.cc +++ b/libaurum/src/UiDevice.cc @@ -128,6 +128,20 @@ std::vector> UiDevice::getMatches( return ret; } +std::vector> UiDevice::getMatchesInMatches( + const std::shared_ptr firstSelector, const std::shared_ptr secondSelector, const bool earlyReturn) const +{ + std::vector> ret{}; + + auto rootNodes = getWindowRoot(); + for (const auto &window : rootNodes) { + auto nodes = window->getMatchesInMatches(firstSelector, secondSelector, earlyReturn); + for (auto &node : nodes) + ret.push_back(std::make_shared(getInstance(), nullptr, node)); + } + return ret; +} + bool UiDevice::waitFor( const std::function condition) const { diff --git a/libaurum/src/UiObject.cc b/libaurum/src/UiObject.cc index 82d9563..d8c3cfa 100644 --- a/libaurum/src/UiObject.cc +++ b/libaurum/src/UiObject.cc @@ -117,6 +117,18 @@ std::vector> UiObject::getMatches( return result; } +std::vector> UiObject::getMatchesInMatches( + const std::shared_ptr firstSelector, const std::shared_ptr secondSelector, const bool earlyReturn) const +{ + std::vector> result{}; + + auto nodes = getAccessibleNode()->getMatchesInMatches(firstSelector, secondSelector, earlyReturn); + for (auto &node : nodes) { + result.push_back(std::make_shared(mDevice, nullptr, std::move(node))); + } + return result; +} + bool UiObject::waitFor( const std::function condition) const {