-#include "UiObject.h"
-#include "Comparer.h"
-#include "Sel.h"
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "Aurum.h"
#include <iostream>
#include <utility>
-#include <loguru.hpp>
-
#include <chrono>
#include <thread>
+
+using namespace Aurum;
+
UiObject::UiObject() : UiObject(nullptr, nullptr, nullptr) {}
UiObject::~UiObject()
const AccessibleNode *node)
: mDevice(device),
mSelector(selector),
- mNode(std::shared_ptr<AccessibleNode>(const_cast<AccessibleNode*>(node))),
+ mNode(std::shared_ptr<AccessibleNode>(const_cast<AccessibleNode *>(node))),
mWaiter(new Waiter{this, this})
{
}
{
}
-// UiObject::UiObject(const UiObject &src)
-// : mDevice(src.mDevice),
-// mSelector(src.mSelector),
-// mNode(src.mNode),
-// mWaiter{src.mWaiter},
-// mNode_src(std::move(src.mNode_src))
-
-// {
-// }
-
UiObject::UiObject(UiObject &&src)
: mDevice(src.mDevice),
mSelector(std::move(src.mSelector)),
std::vector<std::shared_ptr<UiObject>> UiObject::findObjects(
const std::shared_ptr<UiSelector> selector) const
{
- LOG_SCOPE_F(INFO, "findObjects");
std::vector<std::shared_ptr<UiObject>> result{};
- auto nodes = Comparer::findObjects(mDevice, selector, getAccessibleNode());
- LOG_SCOPE_F(INFO, "size : %d", nodes.size());
+
+ std::vector<std::shared_ptr<AccessibleNode>> nodes{};
+ Comparer::findObjects(nodes, mDevice, selector, getAccessibleNode());
for ( auto& node : nodes) {
if (!node) {
- LOG_F(INFO, "skipped(node == nullptr)");
+ LOGI("Skipped! (node == nullptr)");
continue;
}
result.push_back(std::make_shared<UiObject>(mDevice, selector, std::move(node)));
std::vector<std::shared_ptr<UiObject>> UiObject::getChildren() const
{
- return this->findObjects(Sel::depth(1));
+ 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()
return getAccessibleNode()->getAutomationId();
}
-std::string UiObject::getElementType() const
+std::string UiObject::getType() const
{
return getAccessibleNode()->getType();
}
return getAccessibleNode()->getRole();
}
-void UiObject::setText(std::string text)
+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
{
- getAccessibleNode()->setValue(text);
+ 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()->isActive();
}
+bool UiObject::isHighlightable() const
+{
+ return getAccessibleNode()->isHighlightable();
+}
+
void UiObject::refresh() const
{
mNode->refresh();
}
-const Rect<int> UiObject::getBoundingBox() const
+void UiObject::updateRoleName() const
{
- mNode->refresh();
- return mNode->getBoundingBox();
+ mNode->updateRoleName();
+}
+
+void UiObject::updateUniqueId() const
+{
+ mNode->updateUniqueId();
+}
+
+void UiObject::updateName() const
+{
+ mNode->updateName();
+}
+
+void UiObject::updateApplication() const
+{
+ mNode->updateApplication();
+}
+
+void UiObject::updateAttributes() const
+{
+ mNode->updateAttributes();
+}
+
+void UiObject::updateStates() const
+{
+ mNode->updateStates();
+}
+
+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();
+}
+
+bool UiObject::isValid() const
+{
+ return mNode->isValid();
+}
+
+const Rect<int> UiObject::getScreenBoundingBox() const
+{
+ return mNode->getScreenBoundingBox();
+}
+
+const Rect<int> UiObject::getWindowBoundingBox() const
+{
+ return mNode->getWindowBoundingBox();
}
void UiObject::click() const
{
- LOG_SCOPE_F(INFO, "click on obj %p", this);
- mNode->refresh();
- const Rect<int> rect = mNode->getBoundingBox();
+ mNode->updateExtents();
+ const Rect<int> rect = mNode->getScreenBoundingBox();
const Point2D<int> midPoint = rect.midPoint();
mDevice->click(midPoint.x, midPoint.y);
}
-void UiObject::longClick(const unsigned int intv) const
+void UiObject::longClick(const unsigned int durationMs) const
{
- LOG_SCOPE_F(INFO, "click on obj %p", this);
- mNode->refresh();
- const Rect<int> rect = mNode->getBoundingBox();
+ mNode->updateExtents();
+ const Rect<int> rect = mNode->getScreenBoundingBox();
const Point2D<int> midPoint = rect.midPoint();
- mDevice->click(midPoint.x, midPoint.y, intv);
+ mDevice->click(midPoint.x, midPoint.y, durationMs);
}
bool UiObject::DoAtspiActivate() const
if (mNode == nullptr) throw;
// TODO : wait for animation and refresh current node
// mDevice->waitForIdle();
- mNode->refresh();
return mNode;
}