From fbdef2e581a9b24d6753d8fc97c4129a93fe62a6 Mon Sep 17 00:00:00 2001 From: Hosang Kim Date: Fri, 1 Apr 2022 17:22:03 +0900 Subject: [PATCH] aurum: add XPath interface to search object in object tree Change-Id: I92e6fd2d0e62ff65634e5e81ee7ae57557017d68 --- libaurum/inc/UiSelector.h | 13 +++++++++++++ libaurum/src/UiSelector.cc | 13 +++++++++++-- .../src/Commands/FindElementCommand.cc | 2 ++ protocol/aurum.proto | 6 +++++- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/libaurum/inc/UiSelector.h b/libaurum/inc/UiSelector.h index f834b17..c8f510d 100644 --- a/libaurum/inc/UiSelector.h +++ b/libaurum/inc/UiSelector.h @@ -346,6 +346,17 @@ public: */ UiSelector *fromParent(std::shared_ptr parent); + /** + * @brief Sets the search criteria to match the object's XPath. + * + * @param[in] xpath object XPath + * + * @return UiSelector class instance + * + * @since_tizen 7.0 + */ + UiSelector *xpath(std::string xpath); + public: std::string mId; std::string mAutomationId; @@ -355,6 +366,7 @@ public: std::string mType; std::string mStyle; std::string mTextPartialMatch; + std::string mXPath; bool mMatchId; bool mMatchAutomationId; @@ -364,6 +376,7 @@ public: bool mMatchType; bool mMatchStyle; bool mMatchTextPartialMatch; + bool mMatchXPath; bool mMatchChecked; bool mMatchCheckable; diff --git a/libaurum/src/UiSelector.cc b/libaurum/src/UiSelector.cc index fe2ba4a..f97aea3 100644 --- a/libaurum/src/UiSelector.cc +++ b/libaurum/src/UiSelector.cc @@ -23,8 +23,8 @@ using namespace Aurum; UiSelector::UiSelector() : mId{}, mAutomationId{}, mRole{}, mText{}, mTextPartialMatch{}, mPkg{}, mType{}, mStyle{}, - mMatchId{}, mMatchAutomationId{}, mMatchRole{}, mMatchText{}, mMatchTextPartialMatch{}, mMatchPkg{}, mMatchType{}, - mMatchStyle{}, mMatchChecked{}, mMatchCheckable{}, mMatchClickable{}, mMatchEnabled{}, mMatchFocused{}, + mMatchId{}, mMatchAutomationId{}, mMatchRole{}, mMatchText{}, mMatchTextPartialMatch{}, mMatchXPath{}, mMatchPkg{}, + mMatchType{}, mMatchStyle{}, mMatchChecked{}, mMatchCheckable{}, mMatchClickable{}, mMatchEnabled{}, mMatchFocused{}, mMatchFocusable{}, mMatchScrollable{}, mMatchSelected{}, mMatchShowing{}, mMatchActive{}, mMatchVisible{}, mMatchSelectable{}, mMinDepth{}, mMaxDepth{}, mIschecked{}, mIscheckable{}, mIsclickable{}, mIsenabled{}, mIsfocused{}, mIsfocusable{}, mIsscrollable{}, mIsselected{}, mIsshowing{}, mIsactive{}, mIsvisible{}, @@ -41,6 +41,7 @@ std::string UiSelector::description() if(!this->mRole.empty()) ss << "\"mRole\":\"" << this->mRole << "\", "; if(!this->mText.empty()) ss << "\"mText\":\"" << this->mText << "\", "; if(!this->mTextPartialMatch.empty()) ss << "\"mTextPartialMatch\":\"" << this->mTextPartialMatch << "\", "; + if(!this->mXPath.empty()) ss << "\"mXPath\":\"" << this->mXPath << "\", "; if(!this->mPkg.empty()) ss << "\"mPkg\":\"" << this->mPkg << "\", "; if(!this->mType.empty()) ss << "\"mType\":\"" << this->mType << "\", "; if(!this->mStyle.empty()) ss << "\"mStyle\":\"" << this->mStyle << "\", "; @@ -49,6 +50,7 @@ std::string UiSelector::description() if(this->mMatchRole) ss << "\"mMatchRole\":\"" << ((this->mMatchRole)?"true":"false") << "\", "; if(this->mMatchText) ss << "\"mMatchText\":\"" << ((this->mMatchText)?"true":"false") << "\", "; if(this->mMatchTextPartialMatch) ss << "\"mMatchTextPartialMatch\":\"" << ((this->mMatchTextPartialMatch)?"true":"false") << "\", "; + if(this->mMatchXPath) ss << "\"mMatchXPath\":\"" << ((this->mMatchXPath)?"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" )<< "\", "; @@ -115,6 +117,13 @@ UiSelector *UiSelector::automationid(std::string text) return this; } +UiSelector *UiSelector::xpath(std::string xpath) +{ + this->mXPath = xpath; + this->mMatchXPath = true; + return this; +} + UiSelector *UiSelector::role(std::string text) { this->mRole = text; diff --git a/org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc index 1ad25dc..5e25ece 100644 --- a/org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc +++ b/org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc @@ -64,6 +64,7 @@ std::vector> FindElementCommand::getSelectors(void) if(mRequest->_maxdepth_case()) sel->maxDepth(mRequest->maxdepth()); if(mRequest->_packagename_case()) sel->pkg(mRequest->packagename()); if(mRequest->_textpartialmatch_case()) sel->textPartialMatch(mRequest->textpartialmatch()); + if(mRequest->_xpath_case()) sel->xpath(mRequest->xpath()); return std::vector>{sel}; } @@ -112,6 +113,7 @@ std::vector> FindElementCommand::getSelectors(void) elm->set_widget_style(obj->getElementStyle()); elm->set_text(obj->getText()); + elm->set_xpath(obj->getXPath()); elm->set_automationid(obj->getAutomationId()); elm->set_package(obj->getApplicationPackage()); elm->set_role(obj->getRole()); diff --git a/protocol/aurum.proto b/protocol/aurum.proto index a6edb59..bca9eb4 100644 --- a/protocol/aurum.proto +++ b/protocol/aurum.proto @@ -174,7 +174,11 @@ message ReqFindElement { string textPartialMatch = 19; } - repeated ReqFindElement children = 20; + oneof _xpath { + string xpath = 20; + } + + repeated ReqFindElement children = 21; } message RspFindElement { RspStatus status = 1; -- 2.7.4