Aurum: Improve performance of findElements command
[platform/core/uifw/aurum.git] / libaurum / src / UiObject.cc
index 042171a..3bbecc0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -92,7 +92,9 @@ std::vector<std::shared_ptr<UiObject>> UiObject::findObjects(
     const std::shared_ptr<UiSelector> selector) const
 {
     std::vector<std::shared_ptr<UiObject>> result{};
-    auto nodes = Comparer::findObjects(mDevice, selector, getAccessibleNode());
+
+    std::vector<std::shared_ptr<AccessibleNode>> nodes{};
+    Comparer::findObjects(nodes, mDevice, selector, getAccessibleNode());
     for ( auto& node : nodes) {
         if (!node) {
             LOGI("Skipped! (node == nullptr)");
@@ -144,8 +146,14 @@ std::shared_ptr<UiObject> UiObject::getChildAt(int index) const {
 
 std::vector<std::shared_ptr<UiObject>> UiObject::getChildren() const
 {
-    auto sel = Sel::depth(1);
-    return this->findObjects(sel);
+    std::vector<std::shared_ptr<UiObject>> ret{};
+
+    auto children = getAccessibleNode()->getChildren();
+    for (auto &child : children) {
+        ret.push_back(std::make_shared<UiObject>(mDevice, mSelector, child));
+    }
+
+    return ret;
 }
 
 std::shared_ptr<Node> UiObject::getDescendant()
@@ -174,7 +182,7 @@ std::string UiObject::getAutomationId() const
     return getAccessibleNode()->getAutomationId();
 }
 
-std::string UiObject::getElementType() const
+std::string UiObject::getType() const
 {
     return getAccessibleNode()->getType();
 }
@@ -194,11 +202,62 @@ std::string UiObject::getRole() const
     return getAccessibleNode()->getRole();
 }
 
+std::string UiObject::getXPath() const
+{
+    return getAccessibleNode()->getXPath();
+}
+
+const double UiObject::getMinValue() const
+{
+    return getAccessibleNode()->getMinValue();
+}
+
+const double UiObject::getMaxValue() const
+{
+    return getAccessibleNode()->getMaxValue();
+}
+
+const double UiObject::getValue() const
+{
+    return getAccessibleNode()->getValue();
+}
+
+const double UiObject::getIncrement() const
+{
+    return getAccessibleNode()->getIncrement();
+}
+
+const Rect<int> UiObject::getTextMinBoundingRect() const
+{
+    return getAccessibleNode()->getTextMinBoundingRect();
+}
+
+bool UiObject::setValue(double value)
+{
+    return getAccessibleNode()->setValue(value);
+}
+
 bool UiObject::setText(std::string text)
 {
     return getAccessibleNode()->setValue(text);
 }
 
+std::string UiObject::getOcrText() const
+{
+    return getAccessibleNode()->getOcrText();
+}
+
+std::string UiObject::getToolkitName() const
+{
+    getAccessibleNode()->updateToolkitName();
+    return getAccessibleNode()->getToolkitName();
+}
+
+void UiObject::setOcrText(std::string text)
+{
+    getAccessibleNode()->setOcrText(text);
+}
+
 bool UiObject::isCheckable() const
 {
     return getAccessibleNode()->isCheckable();
@@ -264,6 +323,11 @@ bool UiObject::isActive() const
     return getAccessibleNode()->isActive();
 }
 
+bool UiObject::isHighlightable() const
+{
+    return getAccessibleNode()->isHighlightable();
+}
+
 void UiObject::refresh() const
 {
     mNode->refresh();
@@ -304,6 +368,31 @@ void UiObject::updateExtents() const
     mNode->updateExtents();
 }
 
+void UiObject::updateXPath() const
+{
+    mNode->updateXPath();
+}
+
+void UiObject::updateValue() const
+{
+    mNode->updateValue();
+}
+
+void UiObject::updatePid() const
+{
+    mNode->updatePid();
+}
+
+void UiObject::updateToolkitName() const
+{
+    mNode->updateToolkitName();
+}
+
+void UiObject::updateTextMinBoundingRect() const
+{
+    mNode->updateTextMinBoundingRect();
+}
+
 bool UiObject::setFocus() const
 {
     return mNode->setFocus();