Introduce new getMatchesInMatches API. 94/303694/5 accepted/tizen/unified/20240205.162750 accepted/tizen/unified/x/20240206.004203
authorHosang Kim <hosang12.kim@samsung.com>
Wed, 3 Jan 2024 10:47:30 +0000 (19:47 +0900)
committerHosang Kim <hosang12.kim@samsung.com>
Wed, 10 Jan 2024 07:14:28 +0000 (16:14 +0900)
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

libaurum/inc/Accessibility/AccessibleNode.h
libaurum/inc/Impl/Accessibility/AtspiAccessibleNode.h
libaurum/inc/Impl/Accessibility/AtspiWrapper.h
libaurum/inc/Impl/Accessibility/MockAccessibleNode.h
libaurum/inc/UiDevice.h
libaurum/inc/UiObject.h
libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc
libaurum/src/Impl/Accessibility/AtspiWrapper.cc
libaurum/src/Impl/Accessibility/MockAccessibleNode.cc
libaurum/src/UiDevice.cc
libaurum/src/UiObject.cc

index bcdc1fce00bcca4f089efc5f564bfe3ecb59715b..16f7c898bc84d6af19143ac965995212d21e1ac8 100644 (file)
@@ -137,6 +137,11 @@ public:
      */
     virtual std::vector<std::shared_ptr<AccessibleNode>> getMatches(const std::shared_ptr<UiSelector> selector, const bool ealryReturn) const = 0;
 
+    /**
+     * @copydoc UiObject::getMatchesInMatches()
+     */
+    virtual std::vector<std::shared_ptr<AccessibleNode>> getMatchesInMatches(const std::shared_ptr<UiSelector> firstSelector, const std::shared_ptr<UiSelector> secondSelector, const bool ealryReturn) const = 0;
+
     /**
      * @brief Called by @AccessibleWatcher::notifyAll.
      *        Changes Node property If it's @EventType, @ObjectEventType are matches.
index 29c0aeb93df9809a405a88ff3ab3676cb42d9db7..eb78152fd32f914719afde775a16edeedf223b80 100644 (file)
@@ -75,6 +75,11 @@ public:
      */
     std::vector<std::shared_ptr<AccessibleNode>> getMatches(const std::shared_ptr<UiSelector> selector, const bool ealryReturn) const override;
 
+    /**
+     * @copydoc UiObject::getMatchesInMatches()
+     */
+    std::vector<std::shared_ptr<AccessibleNode>> getMatchesInMatches(const std::shared_ptr<UiSelector> firstSelector, const std::shared_ptr<UiSelector> secondSelector, const bool ealryReturn) const override;
+
     /**
      * @copydoc AccessibleNode::isValid()
      */
index 63ac89d2b38456cc8f5dc8267852d7d8a74cedf4..e7901c4d43601926f1b225654f6b975f55c03dcb 100644 (file)
@@ -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);
 
index c2df6a7c31cb32aa1f8bbc6b18bfd6c270ed8593..4f2d02d58e38439434f165a8bb335f0454410142 100644 (file)
@@ -74,6 +74,11 @@ public:
      */
     std::vector<std::shared_ptr<AccessibleNode>> getMatches(const std::shared_ptr<UiSelector> selector, const bool ealryReturn) const override;
 
+    /**
+     * @copydoc UiObject::getMatchesInMatches()
+     */
+    std::vector<std::shared_ptr<AccessibleNode>> getMatchesInMatches(const std::shared_ptr<UiSelector> firstSelector, const std::shared_ptr<UiSelector> secondSelector, const bool ealryReturn) const override;
+
 public:
     /**
      * @brief TBD
index 7315f7b1db8fe4bf56a45b589d88986df604fb3a..75a9b4c7358059f96b388264bcf6bce7b495ad53 100644 (file)
@@ -327,6 +327,20 @@ public:
     std::vector<std::shared_ptr<UiObject>> getMatches(
         const std::shared_ptr<UiSelector> 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<std::shared_ptr<UiObject>> getMatchesInMatches(
+        const std::shared_ptr<UiSelector> firstSelector, const std::shared_ptr<UiSelector> secondSelector, const bool earlyReturn) const;
+
     /**
      * TODO
      */
index 6689962500edbb74bd2c9dccf08cefc6cf6aee9c..4b586023275aaef3b4f1d70b316f74af2d57ba8e 100644 (file)
@@ -152,6 +152,20 @@ public:
     std::vector<std::shared_ptr<UiObject>> getMatches(
         const std::shared_ptr<UiSelector> 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<std::shared_ptr<UiObject>> getMatchesInMatches(
+        const std::shared_ptr<UiSelector> firstSelector, const std::shared_ptr<UiSelector> secondSelector, const bool earlyReturn) const;
+
     /**
      * TODO
      */
index df3b06427252e2b30d1b613ba6be5a2b3ff439c7..5cc212aeda405072c0b2c6efce81b77aaab0a0a6 100644 (file)
@@ -725,3 +725,35 @@ std::vector<std::shared_ptr<AccessibleNode>> AtspiAccessibleNode::getMatches(con
 
     return ret;
 }
+
+std::vector<std::shared_ptr<AccessibleNode>> AtspiAccessibleNode::getMatchesInMatches(const std::shared_ptr<UiSelector> firstSelector, const std::shared_ptr<UiSelector> secondSelector, const bool ealryReturn) const
+{
+    std::vector<std::shared_ptr<AccessibleNode>> 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<AtspiAccessibleNode>(match));
+               }
+            }
+            g_array_free(matches, true);
+        }
+        g_object_unref(secondRule);
+        g_object_unref(firstRule);
+    }
+
+    return ret;
+}
index 10f98ff943265c11cf1755fbfd4f04676c4aefc0..33c183211dfeafb0ef7bbe25ddb5153c5d2b8a43 100644 (file)
@@ -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<std::recursive_mutex> 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<std::recursive_mutex> lock(mMutex);
index 8a51e90cb6624842a02d86a8fde584f115abb18b..ca6fc10f1f5a4638853efd11d2550129f5d66bee 100644 (file)
@@ -68,6 +68,14 @@ std::vector<std::shared_ptr<AccessibleNode>> MockAccessibleNode::getMatches(cons
     return ret;
 }
 
+std::vector<std::shared_ptr<AccessibleNode>> MockAccessibleNode::getMatchesInMatches(const std::shared_ptr<UiSelector> firstSelector, const std::shared_ptr<UiSelector> secondSelector, const bool ealryReturn) const
+{
+    std::vector<std::shared_ptr<AccessibleNode>> ret{};
+
+    return ret;
+}
+
+
 void* MockAccessibleNode::getRawHandler(void) const
 {
     printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
index 9bb7e42ea673385a2f84bc9dbf0a68e3716a2c05..2dacea623c23e24472a7d926757cc8c8c8958043 100644 (file)
@@ -128,6 +128,20 @@ std::vector<std::shared_ptr<UiObject>> UiDevice::getMatches(
     return ret;
 }
 
+std::vector<std::shared_ptr<UiObject>> UiDevice::getMatchesInMatches(
+    const std::shared_ptr<UiSelector> firstSelector, const std::shared_ptr<UiSelector> secondSelector, const bool earlyReturn) const
+{
+    std::vector<std::shared_ptr<UiObject>> 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<UiObject>(getInstance(), nullptr, node));
+    }
+    return ret;
+}
+
 bool UiDevice::waitFor(
     const std::function<bool(const ISearchable *)> condition) const
 {
index 82d956392a4408886ce5c3571ec0de0ced54a4d6..d8c3cfa587f7d60bf7914335466a885b28df8e91 100644 (file)
@@ -117,6 +117,18 @@ std::vector<std::shared_ptr<UiObject>> UiObject::getMatches(
     return result;
 }
 
+std::vector<std::shared_ptr<UiObject>> UiObject::getMatchesInMatches(
+    const std::shared_ptr<UiSelector> firstSelector, const std::shared_ptr<UiSelector> secondSelector, const bool earlyReturn) const
+{
+    std::vector<std::shared_ptr<UiObject>> result{};
+
+    auto nodes = getAccessibleNode()->getMatchesInMatches(firstSelector, secondSelector, earlyReturn);
+    for (auto &node : nodes) {
+        result.push_back(std::make_shared<UiObject>(mDevice, nullptr, std::move(node)));
+    }
+    return result;
+}
+
 bool UiObject::waitFor(
     const std::function<bool(const ISearchable *)> condition) const
 {