bool isSelectable() const;
bool isSelected() const;
bool isVisible() const;
+ bool isShowing() const;
+ bool isActive() const;
public:
void print(int) const;
void update(const AccessibleNode *node, int index, int depth,
std::list<std::shared_ptr<PartialMatch>> &partialMatches);
bool finalizeMatch();
+ void debugPrint();
public:
static std::shared_ptr<PartialMatch> accept(const AccessibleNode *node,
const std::shared_ptr<UiSelector> selector,
int index, int absoluteDepth,
int relativeDepth);
-
private:
static bool checkCriteria(const std::shared_ptr<UiSelector> selector,
const AccessibleNode *node);
+
+ static bool checkCriteria(const std::string *textA, const std::string textB);
+ static bool checkCriteria(const bool *boolA, const bool boolB);
};
#endif
\ No newline at end of file
class Sel {
public:
- static std::shared_ptr<UiSelector> text(const std::string &text);
- static std::shared_ptr<UiSelector> type(const std::string &text);
- static std::shared_ptr<UiSelector> depth(const int &depth);
+ static std::shared_ptr<UiSelector> text(std::string text);
+ static std::shared_ptr<UiSelector> type(std::string text);
+ static std::shared_ptr<UiSelector> style(std::string text);
+ static std::shared_ptr<UiSelector> depth(int depth);
};
#endif
\ No newline at end of file
// UiObject(const UiObject &src); // copy constroctur
UiObject(UiObject &&src); // move constructor
+ UiObject();
virtual ~UiObject();
+ std::shared_ptr<UiSelector> getSelector();
+
bool hasObject(const std::shared_ptr<UiSelector> selector) const override;
std::unique_ptr<UiObject> findObject(
const std::shared_ptr<UiSelector> selector) const override;
bool isSelectable() const;
bool isSelected() const;
bool isVisible() const;
+ bool isShowing() const;
+ bool isActive() const;
void click() const;
void longClick(const unsigned int intv = LOGNCLICK_INTERVAL) const;
void refresh() const;
private:
- UiObject();
const AccessibleNode *getAccessibleNode() const;
static const unsigned int LOGNCLICK_INTERVAL = 50;
// UiSelector &operator= (const UiSelector& src);
public:
- UiSelector *text(const std::string &text);
- UiSelector *pkg(const std::string &text);
- UiSelector *res(const std::string &text);
- UiSelector *desc(const std::string &text);
- UiSelector *type(const std::string &text);
+ UiSelector *id(std::string text);
+ UiSelector *text(std::string text);
+ UiSelector *pkg(std::string text);
+
+ UiSelector *type(std::string text);
+ UiSelector *style(std::string text);
UiSelector *depth(int depth);
+ UiSelector *depth(int minDepth, int maxDepth);
+ UiSelector *minDepth(int depth);
+ UiSelector *maxDepth(int depth);
+
+ UiSelector *isChecked(bool cond);
+ UiSelector *isCheckable(bool cond);
+ UiSelector *isClickable(bool cond);
+ UiSelector *isEnabled(bool cond);
+ UiSelector *isFocused(bool cond);
+ UiSelector *isFocusable(bool cond);
+ UiSelector *isScrollable(bool cond);
+ UiSelector *isSelected(bool cond);
+ UiSelector *isShowing(bool cond);
+ UiSelector *isActive(bool cond);
+
+ UiSelector *res(std::string text);
+ UiSelector *desc(std::string text);
UiSelector *hasChild(std::shared_ptr<UiSelector> child);
public:
- std::string mText;
- std::string mPkg;
- std::string mRes;
- std::string mDesc;
- std::string mType;
- int mDepth;
+ std::unique_ptr<std::string> mId;
+ std::unique_ptr<std::string> mText;
+ std::unique_ptr<std::string> mPkg;
+
+ std::unique_ptr<std::string> mType;
+ std::unique_ptr<std::string> mStyle;
+
+ std::unique_ptr<int> mMinDepth;
+ std::unique_ptr<int> mMaxDepth;
+
+ std::unique_ptr<bool> mIschecked;
+ std::unique_ptr<bool> mIscheckable;
+ std::unique_ptr<bool> mIsclickable;
+ std::unique_ptr<bool> mIsenabled;
+ std::unique_ptr<bool> mIsfocused;
+ std::unique_ptr<bool> mIsfocusable;
+ std::unique_ptr<bool> mIsscrollable;
+ std::unique_ptr<bool> mIsselected;
+ std::unique_ptr<bool> mIsshowing;
+ std::unique_ptr<bool> mIsactive;
+
+ std::unique_ptr<std::string> mRes;
+ std::unique_ptr<std::string> mDesc;
std::vector<std::shared_ptr<UiSelector>> mChild;
};
mRes = "Not_Supported";
#endif
-
GHashTable *attributes = atspi_accessible_get_attributes(mNode.get(), NULL);
char *t = (char*)g_hash_table_lookup(attributes, "type");
char *s = (char*)g_hash_table_lookup(attributes, "style");
{
return mRes;
}
+
std::string AccessibleNode::getType() const
{
return mType;
}
+
+std::string AccessibleNode::getStyle() const
+{
+ return mStyle;
+}
+
Rect<int> AccessibleNode::getBoundingBox() const
{
AtspiComponent *component = atspi_accessible_get_component_iface(mNode.get());
return hasFeatureProperty(NodeFeatureProperties::VISIBLE);
}
+bool AccessibleNode::isShowing() const
+{
+ return hasFeatureProperty(NodeFeatureProperties::SHOWING);
+}
+
+bool AccessibleNode::isActive() const
+{
+ return hasFeatureProperty(NodeFeatureProperties::ACTIVE);
+}
+
AtspiAccessible *AccessibleNode::getAccessible() const
{
return mNode.get();
#include "loguru.hpp"
+bool PartialMatch::checkCriteria(const std::string *textA, const std::string textB)
+{
+ if (!textA) return false;
+ return textA->compare(textB);
+}
+
+bool PartialMatch::checkCriteria(const bool *boolA, const bool boolB)
+{
+ if (!boolA) return false;
+ return *boolA != boolB;
+}
+
+void PartialMatch::debugPrint()
+{
+ if (mSelector->mPkg)
+ LOG_F(INFO, "selector->pkg :%s", mSelector->mPkg->c_str());
+ if (mSelector->mRes)
+ LOG_F(INFO, "selector->pkg :%s", mSelector->mRes->c_str());
+ if (mSelector->mText)
+ LOG_F(INFO, "selector->pkg :%s", mSelector->mText->c_str());
+ if (mSelector->mDesc)
+ LOG_F(INFO, "selector->pkg :%s", mSelector->mDesc->c_str());
+ if (mSelector->mType)
+ LOG_F(INFO, "selector->pkg :%s", mSelector->mType->c_str());
+ if (mSelector->mStyle)
+ LOG_F(INFO, "selector->pkg :%s", mSelector->mStyle->c_str());
+}
+
bool PartialMatch::checkCriteria(const std::shared_ptr<UiSelector> selector,
const AccessibleNode *node)
{
- if (selector->mPkg.length() > 0 && selector->mPkg.compare(node->getPkg()))
- return false;
- if (selector->mRes.length() > 0 && selector->mRes.compare(node->getRes()))
- return false;
- if (selector->mText.length() > 0 && selector->mText.compare(node->getText()))
- return false;
- if (selector->mDesc.length() > 0 && selector->mDesc.compare(node->getDesc()))
- return false;
- if (selector->mType.length() > 0 && selector->mType.compare(node->getType()))
- return false;
-
- LOG_F(INFO, "node mPkg :%s, selector->desc :%s | %ld", node->getPkg().c_str(),
- selector->mPkg.c_str(), selector->mPkg.length());
- LOG_F(INFO, "node mRes :%s, selector->desc :%s | %ld", node->getRes().c_str(),
- selector->mRes.c_str(), selector->mRes.length());
- LOG_F(INFO, "node mText :%s, selector->desc :%s | %ld", node->getText().c_str(),
- selector->mText.c_str(), selector->mText.length());
- LOG_F(INFO, "node mDesc :%s, selector->desc :%s | %ld", node->getDesc().c_str(),
- selector->mDesc.c_str(), selector->mDesc.length());
- LOG_F(INFO, "node mType :%s, selector->type :%s | %ld", node->getType().c_str(),
- selector->mType.c_str(), selector->mType.length());
+ if(checkCriteria(selector->mPkg.get(), node->getPkg())) return false;
+ if(checkCriteria(selector->mRes.get(), node->getRes())) return false;
+ if(checkCriteria(selector->mText.get(), node->getText())) return false;
+ if(checkCriteria(selector->mDesc.get(), node->getDesc())) return false;
+ if(checkCriteria(selector->mType.get(), node->getType())) return false;
+ if(checkCriteria(selector->mStyle.get(), node->getStyle())) return false;
+ if(checkCriteria(selector->mStyle.get(), node->getStyle())) return false;
+
+ if(checkCriteria(selector->mIschecked.get(), node->isChecked())) return false;
+ if(checkCriteria(selector->mIscheckable.get(), node->isCheckable())) return false;
+ if(checkCriteria(selector->mIsclickable.get(), node->isClickable())) return false;
+ if(checkCriteria(selector->mIsenabled.get(), node->isEnabled())) return false;
+ if(checkCriteria(selector->mIsfocused.get(), node->isFocused())) return false;
+ if(checkCriteria(selector->mIsfocusable.get(), node->isFocusable())) return false;
+ if(checkCriteria(selector->mIsscrollable.get(), node->isScrollable())) return false;
+ if(checkCriteria(selector->mIsselected.get(), node->isSelected())) return false;
+ if(checkCriteria(selector->mIsshowing.get(), node->isShowing())) return false;
+ if(checkCriteria(selector->mIsactive.get(), node->isActive())) return false;
return true;
}
#include "Sel.h"
#include <utility>
-std::shared_ptr<UiSelector> Sel::text(const std::string &text)
+std::shared_ptr<UiSelector> Sel::text(std::string text)
{
std::shared_ptr<UiSelector> sel = std::make_shared<UiSelector>();
sel->text(text);
return sel;
}
-std::shared_ptr<UiSelector> Sel::type(const std::string &text)
+std::shared_ptr<UiSelector> Sel::type(std::string text)
{
std::shared_ptr<UiSelector> sel = std::make_shared<UiSelector>();
sel->type(text);
return sel;
}
-std::shared_ptr<UiSelector> Sel::depth(const int &depth)
+std::shared_ptr<UiSelector> Sel::style(std::string text)
+{
+ std::shared_ptr<UiSelector> sel = std::make_shared<UiSelector>();
+ sel->style(text);
+ return sel;
+}
+
+std::shared_ptr<UiSelector> Sel::depth(int depth)
{
std::shared_ptr<UiSelector> sel = std::make_shared<UiSelector>();
sel->depth(depth);
src.mWaiter = nullptr;
}
+std::shared_ptr<UiSelector> UiObject::getSelector()
+{
+ return this->mSelector;
+}
+
bool UiObject::hasObject(const std::shared_ptr<UiSelector> selector) const
{
std::unique_ptr<AccessibleNode> node =
return getAccessibleNode()->isVisible();
}
+bool UiObject::isShowing() const
+{
+ return getAccessibleNode()->isShowing();
+}
+
+bool UiObject::isActive() const
+{
+ return getAccessibleNode()->isActive();
+}
+
void UiObject::refresh() const
{
mNode->refresh();
#include <string>
UiSelector::UiSelector()
- : mText{""}, mPkg{""}, mRes{""}, mDesc{""}, mType{""}, mDepth{-1}, mChild{}
+ : mChild{}
{
}
/*
return *this;
}
*/
+UiSelector *UiSelector::id(std::string text)
+{
+ this->mId = std::make_unique<std::string>(text);
+ return this;
+}
+
+UiSelector *UiSelector::desc(std::string text)
+{
+ this->mDesc = std::make_unique<std::string>(text);
+ return this;
+}
-UiSelector *UiSelector::desc(const std::string &text)
+UiSelector *UiSelector::text(std::string text)
{
- this->mDesc = text;
+ this->mText = std::make_unique<std::string>(text);
return this;
}
-UiSelector *UiSelector::text(const std::string &text)
+UiSelector *UiSelector::pkg(std::string text)
{
- this->mText = text;
+ this->mPkg = std::make_unique<std::string>(text);
return this;
}
-UiSelector *UiSelector::pkg(const std::string &text)
+UiSelector *UiSelector::res(std::string text)
{
- this->mPkg = text;
+ this->mRes = std::make_unique<std::string>(text);
return this;
}
-UiSelector *UiSelector::res(const std::string &text)
+UiSelector *UiSelector::type(std::string text)
{
- this->mRes = text;
+ this->mType = std::make_unique<std::string>(text);
return this;
}
-UiSelector *UiSelector::type(const std::string &text)
+UiSelector *UiSelector::style(std::string text)
{
- this->mType = text;
+ this->mStyle = std::make_unique<std::string>(text);
return this;
}
UiSelector *UiSelector::depth(int depth)
{
- this->mDepth = depth;
+ this->mMinDepth = std::make_unique<int>(depth);
+ this->mMaxDepth = std::make_unique<int>(depth);
+ return this;
+}
+
+UiSelector *UiSelector::depth(int minDepth, int maxDepth)
+{
+ this->mMinDepth = std::make_unique<int>(minDepth);
+ this->mMaxDepth = std::make_unique<int>(maxDepth);
+ return this;
+}
+
+UiSelector *UiSelector::minDepth(int depth)
+{
+ this->mMinDepth = std::make_unique<int>(depth);
+ return this;
+}
+
+UiSelector *UiSelector::maxDepth(int depth)
+{
+ this->mMaxDepth = std::make_unique<int>(depth);
+ return this;
+}
+
+UiSelector *UiSelector::isChecked(bool cond)
+{
+ this->mIschecked = std::make_unique<bool>(cond);
+ return this;
+}
+
+UiSelector *UiSelector::isCheckable(bool cond)
+{
+ this->mIscheckable = std::make_unique<bool>(cond);
+ return this;
+}
+
+UiSelector *UiSelector::isClickable(bool cond)
+{
+ this->mIsclickable = std::make_unique<bool>(cond);
+ return this;
+}
+
+UiSelector *UiSelector::isEnabled(bool cond)
+{
+ this->mIsenabled = std::make_unique<bool>(cond);
+ return this;
+}
+
+UiSelector *UiSelector::isFocused(bool cond)
+{
+ this->mIsfocused = std::make_unique<bool>(cond);
+ return this;
+}
+
+UiSelector *UiSelector::isFocusable(bool cond)
+{
+ this->mIsfocusable = std::make_unique<bool>(cond);
+ return this;
+}
+
+UiSelector *UiSelector::isScrollable(bool cond)
+{
+ this->mIsscrollable = std::make_unique<bool>(cond);
+ return this;
+}
+
+UiSelector *UiSelector::isSelected(bool cond)
+{
+ this->mIsselected = std::make_unique<bool>(cond);
+ return this;
+}
+
+UiSelector *UiSelector::isShowing(bool cond)
+{
+ this->mIsshowing = std::make_unique<bool>(cond);
+ return this;
+}
+
+UiSelector *UiSelector::isActive(bool cond)
+{
+ this->mIsactive = std::make_unique<bool>(cond);
return this;
}
::grpc::Status execute() override;
};
+class GetShowingAttributeCommand : public GetAttributeCommand {
+ using GetAttributeCommand::GetAttributeCommand;
+public:
+ ::grpc::Status execute() override;
+};
+
+class GetActiveAttributeCommand : public GetAttributeCommand {
+ using GetAttributeCommand::GetAttributeCommand;
+public:
+ ::grpc::Status execute() override;
+};
#endif
\ No newline at end of file
ISearchable* FindElementCommand::getSearchableTop(void)
{
ISearchable* searchableObj = nullptr;
- bool fromObject = mRequest->elementid().empty() == false;
- if (fromObject) searchableObj = mObjMap->getElement(mRequest->elementid());
+ if (mRequest->_automationid_case() != 0)
+ searchableObj = mObjMap->getElement(mRequest->elementid());
if (!searchableObj) searchableObj = UiDevice::getInstance(DeviceType::DEFAULT);
return searchableObj;
std::vector<std::shared_ptr<UiSelector>> FindElementCommand::getSelectors(void)
{
- std::vector<std::shared_ptr<UiSelector>> ret = {};
- ret.push_back(Sel::text(mRequest->textfield()));
- return ret;
+ auto sel = std::make_shared<UiSelector>();
+
+ if(mRequest->_automationid_case()) sel->id(mRequest->automationid());
+ if(mRequest->_textfield_case()) sel->text(mRequest->textfield());
+ if(mRequest->_widgettype_case()) sel->type(mRequest->widgettype());
+ if(mRequest->_widgetstyle_case()) sel->style(mRequest->widgetstyle());
+ if(mRequest->_ischecked_case()) sel->isChecked(mRequest->ischecked());
+ if(mRequest->_ischeckable_case()) sel->isCheckable(mRequest->ischeckable());
+ if(mRequest->_isclickable_case()) sel->isClickable(mRequest->isclickable());
+ if(mRequest->_isenabled_case()) sel->isEnabled(mRequest->isenabled());
+ if(mRequest->_isfocused_case()) sel->isFocused(mRequest->isfocused());
+ if(mRequest->_isfocusable_case()) sel->isFocusable(mRequest->isfocusable());
+ if(mRequest->_isscrollable_case()) sel->isScrollable(mRequest->isscrollable());
+ if(mRequest->_isselected_case()) sel->isSelected(mRequest->isselected());
+ if(mRequest->_isshowing_case()) sel->isShowing(mRequest->isshowing());
+ if(mRequest->_isactive_case()) sel->isActive(mRequest->isactive());
+ if(mRequest->_mindepth_case()) sel->minDepth(mRequest->mindepth());
+ if(mRequest->_maxdepth_case()) sel->maxDepth(mRequest->maxdepth());
+
+ return std::vector<std::shared_ptr<UiSelector>>{sel};
}
::grpc::Status FindElementCommand::execute()
return std::make_unique<GetSelectedAttributeCommand>(request, response);
else if (type == ::aurum::ReqGetAttribute_RequestType::ReqGetAttribute_RequestType_SELECTABLE)
return std::make_unique<GetSelectableAttributeCommand>(request, response);
+ else if (type == ::aurum::ReqGetAttribute_RequestType::ReqGetAttribute_RequestType_SHOWING)
+ return std::make_unique<GetShowingAttributeCommand>(request, response);
+ else if (type == ::aurum::ReqGetAttribute_RequestType::ReqGetAttribute_RequestType_ACTIVE)
+ return std::make_unique<GetActiveAttributeCommand>(request, response);
else
return std::make_unique<GetAttributeCommand>(request, response);
}
mResponse->set_status(aurum::RspStatus::OK);
return grpc::Status::OK;
}
+
+
+::grpc::Status GetShowingAttributeCommand::execute()
+{
+ UiObject* obj = mObjMap->getElement(mRequest->elementid());
+ if (!obj) {
+ mResponse->set_boolvalue(false);
+ mResponse->set_status(aurum::RspStatus::ERROR);
+ return grpc::Status::OK;
+ }
+ mResponse->set_boolvalue(obj->isShowing());
+ mResponse->set_status(aurum::RspStatus::OK);
+ return grpc::Status::OK;
+}
+
+
+
+::grpc::Status GetActiveAttributeCommand::execute()
+{
+ UiObject* obj = mObjMap->getElement(mRequest->elementid());
+ if (!obj) {
+ mResponse->set_boolvalue(false);
+ mResponse->set_status(aurum::RspStatus::ERROR);
+ return grpc::Status::OK;
+ }
+ mResponse->set_boolvalue(obj->isActive());
+ mResponse->set_status(aurum::RspStatus::OK);
+ return grpc::Status::OK;
+}
// ------------------------------------ //
message ReqFindElement {
- enum RequestType {
- AUTOMATIONID = 0;
- TEXT = 1;
- TYPE = 2;
- STYLE = 3;
+ oneof _elementid {
+ string elementId = 1;
}
- string elementId = 1;
- RequestType strategy = 2;
- oneof params {
- string automationId = 3;
- string textField = 4;
- string widgetType = 5;
- string widgetStyle = 6;
+
+ oneof _automationid {
+ string automationId = 2;
+ }
+
+ oneof _textfield {
+ string textField = 3;
+ }
+
+ oneof _widgettype {
+ string widgetType = 4;
+ }
+
+ oneof _widgetstyle {
+ string widgetStyle = 5;
+ }
+
+ oneof _ischecked {
+ bool isChecked = 6;
+ }
+
+ oneof _ischeckable {
+ bool isCheckable= 7;
+ }
+
+ oneof _isclickable {
+ bool isClickable = 8;
+ }
+
+ oneof _isenabled {
+ bool isEnabled = 9;
+ }
+
+ oneof _isfocused {
+ bool isFocused = 10;
+ }
+
+ oneof _isfocusable {
+ bool isFocusable = 11;
+ }
+
+ oneof _isscrollable {
+ bool isScrollable = 12;
+ }
+
+ oneof _isselected {
+ bool isSelected = 13;
}
+
+ oneof _isshowing {
+ bool isShowing = 14;
+ }
+
+ oneof _isactive {
+ bool isActive = 15;
+ }
+ oneof _mindepth {
+ int32 minDepth = 16;
+ }
+
+ oneof _maxdepth {
+ int32 maxDepth = 17;
+ }
+
+ repeated ReqFindElement children = 18;
}
message RspFindElement {
RspStatus status = 1;
message ReqGetValue {
string elementId = 1;
+ // TODO : text, widgetstyle, widgettype, automationid
}
message RspGetValue {
RspStatus status = 1;
CHECKED = 7;
SELECTED = 8;
SELECTABLE = 9;
+ SHOWING = 10;
+ ACTIVE = 11;
}
string elementId = 1;
RequestType attribute = 2;