--- /dev/null
+#pragma once
+
+
+typedef enum _KeyRequestType {
+ STROKE,
+ LONG_STROKE,
+ PRESS,
+ RELEASE,
+} KeyRequestType;
+
+typedef enum _TimeRequestType {
+ WALLCLOCK,
+ MONOTONIC,
+} TimeRequestType;
+
+/**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+int aurum_uidevice_click(const int x, const int y);
+
+/**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+int aurum_uidevice_interval_click(const int x, const int y, const unsigned int intv);
+
+/**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+int aurum_uidevice_drag(const int sx, const int sy, const int ex, const int ey,
+ const int steps, const int durationMs);
+
+/**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+int aurum_uidevice_touchDown(const int x, const int y);
+
+/**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+int aurum_uidevice_touchMove(const int x, const int y, const int seq);
+
+/**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+int aurum_uidevice_touchUp(const int x, const int y, const int seq);
+
+/**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+int aurum_uidevice_wheelUp(int amount, const int durationMs);
+
+/**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+int aurum_uidevice_wheelDown(int amount, const int durationMs);
+
+/**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+int aurum_uidevice_pressBack(KeyRequestType type);
+
+/**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+int aurum_uidevice_pressHome(KeyRequestType type);
+
+/**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+int aurum_uidevice_pressMenu(KeyRequestType type);
+
+/**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+int aurum_uidevice_pressVolUp(KeyRequestType type);
+
+/**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+int aurum_uidevice_pressVolDown(KeyRequestType type);
+
+/**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+int aurum_uidevice_pressPower(KeyRequestType type);
+
+/**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+int aurum_uidevice_pressKeyCode(char* keycode, KeyRequestType type);
+
+/**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+int aurum_uidevice_takeScreenshot(char* path, float scale, int quality);
+
+/**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+long long aurum_uidevice_getSystemTime(TimeRequestType type);
+
+/**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+int aurum_uidevice_hasObject(const std::shared_ptr<UiSelector> selector);
+
+/**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+std::shared_ptr<UiObject> aurum_uidevice_findObject(
+ const std::shared_ptr<UiSelector> selector) const;
+
+/**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+std::vector<std::shared_ptr<UiObject>> aurum_uidevice_findObjects(
+ const std::shared_ptr<UiSelector> selector) const;
+
+/**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+/*
+bool aurum_uidevice_waitFor(
+ const std::function<bool(const ISearchable *)> condition) const;
+*/
+/**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+std::shared_ptr<UiObject> aurum_uidevice_waitFor(
+ const std::function<std::shared_ptr<UiObject>(const ISearchable *)>
+ condition) const;
+/**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+std::shared_ptr<UiDevice> aurum_uidevice_getInstance(IDevice *deviceImpl = nullptr);
+
+/**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+std::vector<std::shared_ptr<AccessibleNode>> aurum_uidevice_getWindowRoot() const;
--- /dev/null
+#include "capi_uidevice.h"
\ No newline at end of file
*/
virtual ~AccessibleNode();
+ /**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+ std::string description();
+
public:
/**
* @brief TBD
* @brief TBD
* @since_tizen 5.5
*/
- void debugPrint();
+ std::string debugPrint();
public:
static std::shared_ptr<PartialMatch> accept(const std::shared_ptr<AccessibleNode> node,
* @since_tizen 5.5
*/
UiSelector();
+
/**
* @brief TBD
* @since_tizen 5.5
// UiSelector(const UiSelector &src);
// UiSelector &operator= (const UiSelector& src);
+ /**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+ std::string description();
+
public:
/**
* @brief TBD
return !(child->isActive() && child->isShowing()); // && child->isShowing() && child->isVisible());
}), children.end());
- LOG_SCOPE_F(INFO, "getActiveWindows app(%s) for %p, size:%d", getPackageName().c_str(), getAccessibleNode()->getRawHandler(), children.size());
-
return children;
}
\ No newline at end of file
#include <loguru.hpp>
#include "config.h"
+#include <sstream>
AccessibleNode::~AccessibleNode()
}
AccessibleNode::AccessibleNode()
- : mText{""}, mPkg{""}, mRole{""}, mId{""}, mType{""}, mStyle{""},
+ : mText{""}, mPkg{""}, mRole{""}, mId{""}, mAutomationId{""}, mType{""}, mStyle{""},
mBoundingBox{0,0,0,0}, mSupportingIfaces(0), mFeatureProperty(0)
{
}
+std::string AccessibleNode::description() {
+ std::stringstream ss{};
+ ss << "{";
+ ss << "\"mId\":\"" << this->mId << "\", ";
+ ss << "\"mAutomationId\":\"" << this->mAutomationId << "\", ";
+ ss << "\"mRole\":\"" << this->mRole << "\", ";
+ ss << "\"mText\":\"" << this->mText << "\", ";
+ ss << "\"mPkg\":\"" << this->mPkg << "\", ";
+ ss << "\"mType\":\"" << this->mType << "\", ";
+ ss << "\"mStyle\":\"" << this->mStyle << "\", ";
+ /*
+ if(this->mMatchId) ss << "\"mMatchId\":\"" << ((*this->mMatchId)?"true":"false") << "\", ";
+ if(this->mMatchAutomationId) ss << "\"mMatchAutomationId\":\"" << ((*this->mMatchAutomationId)?"true":"false") << "\", ";
+ if(this->mMatchRole) ss << "\"mMatchRole\":\"" << ((*this->mMatchRole)?"true":"false") << "\", ";
+ if(this->mMatchText) ss << "\"mMatchText\":\"" << ((*this->mMatchText)?"true":"false") << "\", ";
+ if(this->mMatchPkg) ss << "\"mMatchPkg\":\"" << ((*this->mMatchPkg)?"true":"false") << "\", ";
+ if(this->mMatchType) ss << "\"mMatchType\":\"" << ((*this->mMatchType)?"true":"false") << "\", ";
+ if(this->mMatchStyle) ss << "\"mMatchStyle\":\"" << ((*this->mMatchStyle)?"true":"false" )<< "\", ";
+ if(this->mMinDepth) ss << "\"mMinDepth\":\"" << *this->mMinDepth << "\", ";
+ if(this->mMaxDepth) ss << "\"mMaxDepth\":\"" << *this->mMaxDepth << "\", ";
+ if(this->mIschecked) ss << "\"mIschecked\":\"" << ((*this->mIschecked)?"true":"false") << "\", ";
+ if(this->mIscheckable) ss << "\"mIscheckable\":\"" << ((*this->mIscheckable)?"true":"false") << "\", ";
+ if(this->mIsclickable) ss << "\"mIsclickable\":\"" << ((*this->mIsclickable)?"true":"false") << "\", ";
+ if(this->mIsenabled) ss << "\"mIsenabled\":\"" << ((*this->mIsenabled)?"true":"false") << "\", ";
+ if(this->mIsfocused) ss << "\"mIsfocused\":\"" << ((*this->mIsfocused)?"true":"false") << "\", ";
+ if(this->mIsfocusable) ss << "\"mIsfocusable\":\"" << ((*this->mIsfocusable)?"true":"false") << "\", ";
+ if(this->mIsscrollable) ss << "\"mIsscrollable\":\"" << ((*this->mIsscrollable)?"true":"false") << "\", ";
+ if(this->mIsselected) ss << "\"mIsselected\":\"" << ((*this->mIsselected)?"true":"false") << "\", ";
+ if(this->mIsshowing) ss << "\"mIsshowing\":\"" << ((*this->mIsshowing)?"true":"false") << "\", ";
+ if(this->mIsactive) ss << "\"mIsactive\":\"" << ((*this->mIsactive)?"true":"false") << "\", ";
+ if(this->mIsvisible) ss << "\"mIsvisible\":\"" << ((*this->mIsvisible)?"true":"false") << "\", ";
+ if(this->mIsselectable) ss << "\"mIsselectable\":\"" << ((*this->mIsselectable)?"true":"false") << "\", ";
+ if(this->mParent) {
+ ss << "\"mParent\":" << this->mParent->description();
+ }
+ ss << "\"mChild\":[";
+ for ( auto child = mChild.begin(); child != mChild.end(); child++) {
+ ss << (*child)->description();
+ if (child+1 != mChild.end()) ss << ", " ;
+ }
+ ss << "]";
+ */
+ ss << "}";
+ return ss.str();
+}
+
void AccessibleNode::print(int depth, int maxDepth)
{
if (maxDepth <= 0 || depth > maxDepth) return;
void AccessibleNode::print(int d)
{
this->refresh();
- LOG_F(INFO, "%s - %p(%s) / pkg:%s, text:%s",
- std::string(d, ' ').c_str(), getRawHandler(), getText().c_str(),
- getPkg().c_str(), getText().c_str());
+ LOG_F(INFO, "%s%s",std::string(d, ' ').c_str(), description().c_str());
}
bool AccessibleNode::isSupporting(AccessibleNodeInterface thisIface) const
const std::shared_ptr<UiSelector> selector,
const std::shared_ptr<AccessibleNode> root)
{
- std::vector<std::shared_ptr<AccessibleNode>> ret = findObjects(device, selector, root);
+ std::vector<std::shared_ptr<AccessibleNode>> ret = findObjects(device, selector, root, true);
if (ret.size() > 0)
return std::move(ret[0]);
else
std::vector<std::shared_ptr<AccessibleNode>> Comparer::findObjects(const std::shared_ptr<UiDevice> device,
const std::shared_ptr<UiSelector> selector,
const std::shared_ptr<AccessibleNode> root, bool earlyReturn)
- const std::shared_ptr<AccessibleNode> root)
{
Comparer comparer(device, selector, false);
+ 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);
+
if (selector->mParent) {
auto ret = Comparer::findObjects(device, selector->mParent, root);
std::vector<std::shared_ptr<AccessibleNode>> merged{};
{
std::list<std::shared_ptr<PartialMatch>> partialList{};
std::vector<std::shared_ptr<AccessibleNode>> ret = findObjects(root, 0, 0, partialList);
+ LOG_F(INFO, "%d object(s) found", ret.size());
return ret;
}
std::list<std::shared_ptr<PartialMatch>> &partialMatches)
{
std::vector<std::shared_ptr<AccessibleNode>> ret;
- root->refresh();
- LOG_SCOPE_F(INFO, "findObjects %s, %s, %s / i:%d d:%d / p.matches:%d", root->getText().c_str(), root->getType().c_str(), root->getStyle().c_str(), index, depth, partialMatches.size());
+ //LOG_SCOPE_F(INFO, "findObjects idx:%d, depth:%d, partialMatches.size:%d", index, depth, partialMatches.size());
+ root->refresh();
for (auto &match : partialMatches)
match->update(root, index, depth, partialMatches);
if (!ret.empty() && mEarlyReturn) return ret;
}
} else {
- LOG_F(INFO, "no need to search children(maxDepth limit overflow, %d < %d < %d)", mSelector->mMinDepth?*(mSelector->mMinDepth):-1, depth, mSelector->mMaxDepth?*(mSelector->mMaxDepth):9999999);
+ LOG_F(INFO, "Abort searching! No need to search children(maxDepth limit overflow, %d < %d < %d)", mSelector->mMinDepth?*(mSelector->mMinDepth):-1, depth, mSelector->mMaxDepth?*(mSelector->mMaxDepth):9999999);
}
if (currentMatch && currentMatch->finalizeMatch()){
- LOG_F(INFO, "child 3 %p(raw:%p)", root.get(), root->getRawHandler());
+ LOG_F(INFO, "Found matched = %s with criteria %s", root->description().c_str(), currentMatch->debugPrint().c_str());
ret.push_back(root);
}
#include <iostream>
#include <set>
#include <regex>
+#include <sstream>
#include <loguru.hpp>
+
bool PartialMatch::checkCriteria(const std::string *textA, const std::string textB, const bool *match)
{
if (!textA || !match) return false;
return *boolA != boolB;
}
-void PartialMatch::debugPrint()
+std::string PartialMatch::debugPrint()
{
- if (mSelector->mPkg)
- LOG_F(INFO, "selector->pkg :%s", mSelector->mPkg->c_str());
- if (mSelector->mId)
- LOG_F(INFO, "selector->id :%s", mSelector->mId->c_str());
- if (mSelector->mText)
- LOG_F(INFO, "selector->text :%s", mSelector->mText->c_str());
- if (mSelector->mType)
- LOG_F(INFO, "selector->type :%s", mSelector->mType->c_str());
- if (mSelector->mStyle)
- LOG_F(INFO, "selector->style :%s", mSelector->mStyle->c_str());
+ return mSelector->description();
}
bool PartialMatch::checkCriteria(const std::shared_ptr<UiSelector> selector,
int index, int absoluteDepth,
int relativeDepth)
{
- LOG_SCOPE_F(INFO, "accept checking i:%d a:%d r:%d / %d < %d < %d", index, absoluteDepth, relativeDepth, selector->mMinDepth?*(selector->mMinDepth):-1, relativeDepth, selector->mMaxDepth?*(selector->mMaxDepth):9999999);
+ //LOG_SCOPE_F(INFO, "PartialMatch::accept idx:%d abs:%d rel:%d / %d < %d < %d", index, absoluteDepth, relativeDepth, selector->mMinDepth?*(selector->mMinDepth):-1, relativeDepth, selector->mMaxDepth?*(selector->mMaxDepth):9999999);
PartialMatch *match = nullptr;
if ((selector->mMinDepth && (relativeDepth < *(selector->mMinDepth))) ||
(selector->mMaxDepth && (relativeDepth > *(selector->mMaxDepth)))) {
- LOG_F(INFO, "depth limit overflow %d < %d < %d", selector->mMinDepth?*(selector->mMinDepth):-1, relativeDepth, selector->mMaxDepth?*(selector->mMaxDepth):9999999);
return std::shared_ptr<PartialMatch>(nullptr);
}
-
- if (PartialMatch::checkCriteria(selector, node)) {
- LOG_F(INFO, "New Match found %p %d", selector, absoluteDepth);
+ if (PartialMatch::checkCriteria(selector, node))
match = new PartialMatch(selector, absoluteDepth);
- }
-
return std::shared_ptr<PartialMatch>(match);
}
if (foundNode)
return std::make_shared<UiObject>(getInstance(), selector, foundNode);
}
- LOG_F(INFO, "object not found");
return std::shared_ptr<UiObject>{nullptr};
}
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());
for ( auto& node : nodes) {
if (!node) {
- LOG_F(INFO, "skipped(node == nullptr)");
+ LOG_F(INFO, "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));
+ auto sel = Sel::depth(1);
+ return this->findObjects(sel);
}
std::shared_ptr<Node> UiObject::getDescendant()
void UiObject::click() const
{
- LOG_SCOPE_F(INFO, "click on obj %p", this);
mNode->refresh();
const Rect<int> rect = mNode->getBoundingBox();
const Point2D<int> midPoint = rect.midPoint();
void UiObject::longClick(const unsigned int intv) const
{
- LOG_SCOPE_F(INFO, "click on obj %p", this);
mNode->refresh();
const Rect<int> rect = mNode->getBoundingBox();
const Point2D<int> midPoint = rect.midPoint();
#include "UiSelector.h"
#include <string>
-
-
-
+#include <sstream>
UiSelector::UiSelector()
: mId{}, mAutomationId{}, mRole{}, mText{}, mPkg{}, mType{}, mStyle{},
mChild{}, mParent{}
{
}
+
+std::string UiSelector::description()
+{
+ std::stringstream ss{};
+ ss << "{";
+ if(this->mId) ss << "\"mId\":\"" << *this->mId << "\", ";
+ if(this->mAutomationId) ss << "\"mAutomationId\":\"" << *this->mAutomationId << "\", ";
+ if(this->mRole) ss << "\"mRole\":\"" << *this->mRole << "\", ";
+ if(this->mText) ss << "\"mText\":\"" << *this->mText << "\", ";
+ if(this->mPkg) ss << "\"mPkg\":\"" << *this->mPkg << "\", ";
+ if(this->mType) ss << "\"mType\":\"" << *this->mType << "\", ";
+ if(this->mStyle) ss << "\"mStyle\":\"" << *this->mStyle << "\", ";
+ if(this->mMatchId) ss << "\"mMatchId\":\"" << ((*this->mMatchId)?"true":"false") << "\", ";
+ if(this->mMatchAutomationId) ss << "\"mMatchAutomationId\":\"" << ((*this->mMatchAutomationId)?"true":"false") << "\", ";
+ if(this->mMatchRole) ss << "\"mMatchRole\":\"" << ((*this->mMatchRole)?"true":"false") << "\", ";
+ if(this->mMatchText) ss << "\"mMatchText\":\"" << ((*this->mMatchText)?"true":"false") << "\", ";
+ if(this->mMatchPkg) ss << "\"mMatchPkg\":\"" << ((*this->mMatchPkg)?"true":"false") << "\", ";
+ if(this->mMatchType) ss << "\"mMatchType\":\"" << ((*this->mMatchType)?"true":"false") << "\", ";
+ if(this->mMatchStyle) ss << "\"mMatchStyle\":\"" << ((*this->mMatchStyle)?"true":"false" )<< "\", ";
+ if(this->mMinDepth) ss << "\"mMinDepth\":\"" << *this->mMinDepth << "\", ";
+ if(this->mMaxDepth) ss << "\"mMaxDepth\":\"" << *this->mMaxDepth << "\", ";
+ if(this->mIschecked) ss << "\"mIschecked\":\"" << ((*this->mIschecked)?"true":"false") << "\", ";
+ if(this->mIscheckable) ss << "\"mIscheckable\":\"" << ((*this->mIscheckable)?"true":"false") << "\", ";
+ if(this->mIsclickable) ss << "\"mIsclickable\":\"" << ((*this->mIsclickable)?"true":"false") << "\", ";
+ if(this->mIsenabled) ss << "\"mIsenabled\":\"" << ((*this->mIsenabled)?"true":"false") << "\", ";
+ if(this->mIsfocused) ss << "\"mIsfocused\":\"" << ((*this->mIsfocused)?"true":"false") << "\", ";
+ if(this->mIsfocusable) ss << "\"mIsfocusable\":\"" << ((*this->mIsfocusable)?"true":"false") << "\", ";
+ if(this->mIsscrollable) ss << "\"mIsscrollable\":\"" << ((*this->mIsscrollable)?"true":"false") << "\", ";
+ if(this->mIsselected) ss << "\"mIsselected\":\"" << ((*this->mIsselected)?"true":"false") << "\", ";
+ if(this->mIsshowing) ss << "\"mIsshowing\":\"" << ((*this->mIsshowing)?"true":"false") << "\", ";
+ if(this->mIsactive) ss << "\"mIsactive\":\"" << ((*this->mIsactive)?"true":"false") << "\", ";
+ if(this->mIsvisible) ss << "\"mIsvisible\":\"" << ((*this->mIsvisible)?"true":"false") << "\", ";
+ if(this->mIsselectable) ss << "\"mIsselectable\":\"" << ((*this->mIsselectable)?"true":"false") << "\", ";
+ if(this->mParent) {
+ ss << "\"mParent\":" << this->mParent->description();
+ }
+ ss << "\"mChild\":[";
+ for ( auto child = mChild.begin(); child != mChild.end(); child++) {
+ ss << (*child)->description();
+ if (child+1 != mChild.end()) ss << ", " ;
+ }
+ ss << "]";
+
+ ss << "}";
+ return ss.str();
+}
+
/*
UiSelector::UiSelector(const UiSelector &src)
{
const std::shared_ptr<UiSelector> selector)
{
return [=](const ISearchable *searchable) -> bool {
- LOG_SCOPE_F(INFO, "sel:%p, search:%p", selector, searchable);
+ LOG_SCOPE_F(INFO, "Until::hasObject sel:%p, search:%p", selector, searchable);
std::shared_ptr<UiObject> obj = searchable->findObject(selector);
return obj.get() != nullptr;
};
const std::shared_ptr<UiSelector> selector)
{
return [=](const ISearchable *searchable) -> std::shared_ptr<UiObject> {
- LOG_SCOPE_F(INFO, "sel:%p, search:%p", selector, searchable);
+ LOG_SCOPE_F(INFO, "Until::findObject sel:%p, search:%p", selector, searchable);
std::shared_ptr<UiObject> obj = searchable->findObject(selector);
return obj;
};
std::function<bool(const UiObject *)> Until::checkable(const bool isCheckable)
{
return [=](const UiObject *object) -> bool {
- LOG_SCOPE_F(INFO, "waitfor ischeckable %d for obj %p", isCheckable,
- object);
+ LOG_SCOPE_F(INFO, "Until::checkable checkable:%d for obj %p", isCheckable, object);
return object->isClickable() == isCheckable;
};
}
\ No newline at end of file
template <typename R>
R Waiter::waitFor(const std::function<R(const ISearchable *)> condition) const
{
+ LOG_SCOPE_F(INFO, "Waiter::waitFor %p", condition);
// startTime = currentTime();
std::chrono::system_clock::time_point start =
std::chrono::system_clock::now();
template <typename R>
R Waiter::waitFor(const std::function<R(const UiObject *)> condition) const
{
- LOG_F(INFO, "1");
+ LOG_SCOPE_F(INFO, "Waiter::waitFor %p", condition);
if (mUiObject) {
- LOG_F(INFO, "2");
std::chrono::system_clock::time_point start =
std::chrono::system_clock::now();
R result = condition(mUiObject);
- LOG_F(INFO, "3 : %d", result);
while (!result) {
if ((std::chrono::system_clock::now() - start) >
std::chrono::milliseconds{WAIT_TIMEOUT_MS})
std::this_thread::sleep_for(
std::chrono::milliseconds{WAIT_INTERVAL_MS});
result = condition(mUiObject);
- LOG_F(INFO, "4 : %d", result);
}
return result;
}