From e6c2efeb0d3d7b685926a4ea6d4a3978399ad67d Mon Sep 17 00:00:00 2001 From: Woochanlee Date: Mon, 20 Dec 2021 21:00:04 +0900 Subject: [PATCH] aurum-service: Add textPartialMatch interface to search part of text in full text There was a constraint that the entire text must match. It is a function that improves usability through interface expansion. Change-Id: I8b4b996aa4d3a3badbe118c2fee44892a74a830a --- libaurum/inc/PartialMatch.h | 3 +- libaurum/inc/UiSelector.h | 13 ++++++++ libaurum/src/PartialMatch.cc | 23 ++++++++------ libaurum/src/UiSelector.cc | 24 +++++++++----- .../src/Commands/FindElementCommand.cc | 37 +++++++++++----------- protocol/aurum.proto | 6 +++- 6 files changed, 68 insertions(+), 38 deletions(-) diff --git a/libaurum/inc/PartialMatch.h b/libaurum/inc/PartialMatch.h index fcc6aaf..e04bf33 100644 --- a/libaurum/inc/PartialMatch.h +++ b/libaurum/inc/PartialMatch.h @@ -142,12 +142,13 @@ private: * * @param[in] textA string * @param[in] textB string + * @param[in] textPartialMatch bool * * @return ture if matched, else false * * @since_tizen 6.5 */ - static bool checkCriteria(const std::string textA, const std::string textB); + static bool checkCriteria(const std::string textA, const std::string textB, const bool textPartialMatch); /** * @brief Checks boolean value matched or not. diff --git a/libaurum/inc/UiSelector.h b/libaurum/inc/UiSelector.h index 302e6f7..f834b17 100644 --- a/libaurum/inc/UiSelector.h +++ b/libaurum/inc/UiSelector.h @@ -93,6 +93,17 @@ public: UiSelector *text(std::string text); /** + * @brief Sets the search criteria to match the object's text has given text. + * + * @param[in] text object text + * + * @return UiSelector class instance + * + * @since_tizen 6.5 + */ + UiSelector *textPartialMatch(std::string text); + + /** * @brief Sets the search criteria to match the object's package name. * * @param[in] text object package name @@ -343,6 +354,7 @@ public: std::string mPkg; std::string mType; std::string mStyle; + std::string mTextPartialMatch; bool mMatchId; bool mMatchAutomationId; @@ -351,6 +363,7 @@ public: bool mMatchPkg; bool mMatchType; bool mMatchStyle; + bool mMatchTextPartialMatch; bool mMatchChecked; bool mMatchCheckable; diff --git a/libaurum/src/PartialMatch.cc b/libaurum/src/PartialMatch.cc index 1e75b71..c1cd80a 100644 --- a/libaurum/src/PartialMatch.cc +++ b/libaurum/src/PartialMatch.cc @@ -24,10 +24,12 @@ using namespace Aurum; -bool PartialMatch::checkCriteria(const std::string textA, const std::string textB) +bool PartialMatch::checkCriteria(const std::string textA, const std::string textB, const bool textPartialMatch) { std::regex re(textA); - bool rst = !(!!std::regex_match(textB, re) == true); + bool rst; + if (textPartialMatch) rst = !(!!std::regex_search(textB, re) == true); + else rst = !(!!std::regex_match(textB, re) == true); return rst; } @@ -44,27 +46,28 @@ std::string PartialMatch::debugPrint() bool PartialMatch::checkCriteria(const std::shared_ptr selector, const std::shared_ptr node) { - if (selector->mMatchText) { + if (selector->mMatchText || selector->mMatchTextPartialMatch) { node->updateName(); - if (checkCriteria(selector->mText, node->getText())) return false; + if (selector->mMatchText && checkCriteria(selector->mText, node->getText(), 0)) return false; + if (selector->mMatchTextPartialMatch && checkCriteria(selector->mTextPartialMatch, node->getText(), 1)) return false; } if (selector->mMatchId) { node->updateUniqueId(); - if (checkCriteria(selector->mId, node->getId())) return false; + if (checkCriteria(selector->mId, node->getId(), 0)) return false; } if (selector->mMatchType || selector->mMatchAutomationId || selector->mMatchStyle) { node->updateAttributes(); - if (selector->mMatchAutomationId && checkCriteria(selector->mAutomationId, node->getAutomationId())) return false; - if (selector->mMatchType && checkCriteria(selector->mType, node->getType())) return false; - if (selector->mMatchStyle && checkCriteria(selector->mStyle, node->getStyle())) return false; + if (selector->mMatchAutomationId && checkCriteria(selector->mAutomationId, node->getAutomationId(), 0)) return false; + if (selector->mMatchType && checkCriteria(selector->mType, node->getType(), 0)) return false; + if (selector->mMatchStyle && checkCriteria(selector->mStyle, node->getStyle(), 0)) return false; } if (selector->mMatchPkg) { node->updateApplication(); - if (checkCriteria(selector->mPkg, node->getPkg())) return false; + if (checkCriteria(selector->mPkg, node->getPkg(), 0)) return false; } if (selector->mMatchRole) { node->updateRoleName(); - if (checkCriteria(selector->mRole, node->getRole())) return false; + if (checkCriteria(selector->mRole, node->getRole(), 0)) return false; } if (selector->mMatchChecked && checkCriteria(selector->mIschecked, node->isChecked())) return false; if (selector->mMatchCheckable && checkCriteria(selector->mIscheckable, node->isCheckable())) return false; diff --git a/libaurum/src/UiSelector.cc b/libaurum/src/UiSelector.cc index 25af9e8..fe2ba4a 100644 --- a/libaurum/src/UiSelector.cc +++ b/libaurum/src/UiSelector.cc @@ -22,14 +22,13 @@ using namespace Aurum; UiSelector::UiSelector() -: mId{}, mAutomationId{}, mRole{}, mText{}, mPkg{}, mType{}, mStyle{}, - mMatchId{}, mMatchAutomationId{}, mMatchRole{}, mMatchText{}, 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{}, mIsselectable{}, - mChild{}, mParent{} +: mId{}, mAutomationId{}, mRole{}, mText{}, mTextPartialMatch{}, mPkg{}, mType{}, mStyle{}, + mMatchId{}, mMatchAutomationId{}, mMatchRole{}, mMatchText{}, mMatchTextPartialMatch{}, 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{}, + mIsselectable{}, mChild{}, mParent{} { } @@ -41,6 +40,7 @@ std::string UiSelector::description() if(!this->mAutomationId.empty()) ss << "\"mAutomationId\":\"" << this->mAutomationId << "\", "; 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->mPkg.empty()) ss << "\"mPkg\":\"" << this->mPkg << "\", "; if(!this->mType.empty()) ss << "\"mType\":\"" << this->mType << "\", "; if(!this->mStyle.empty()) ss << "\"mStyle\":\"" << this->mStyle << "\", "; @@ -48,6 +48,7 @@ std::string UiSelector::description() 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->mMatchTextPartialMatch) ss << "\"mMatchTextPartialMatch\":\"" << ((this->mMatchTextPartialMatch)?"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" )<< "\", "; @@ -86,6 +87,13 @@ UiSelector *UiSelector::text(std::string text) return this; } +UiSelector *UiSelector::textPartialMatch(std::string text) +{ + this->mTextPartialMatch = text; + this->mMatchTextPartialMatch = true; + return this; +} + UiSelector *UiSelector::pkg(std::string text) { this->mPkg = text; diff --git a/org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc index 34606f2..6783045 100644 --- a/org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc +++ b/org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc @@ -45,24 +45,25 @@ std::vector> FindElementCommand::getSelectors(void) { auto sel = std::make_shared(); - if(mRequest->_elementid_case()) sel->id(mRequest->elementid()); - if(mRequest->_automationid_case()) sel->automationid(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()); - if(mRequest->_packagename_case()) sel->pkg(mRequest->packagename()); + if(mRequest->_elementid_case()) sel->id(mRequest->elementid()); + if(mRequest->_automationid_case()) sel->automationid(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()); + if(mRequest->_packagename_case()) sel->pkg(mRequest->packagename()); + if(mRequest->_textpartialmatch_case()) sel->textPartialMatch(mRequest->textpartialmatch()); return std::vector>{sel}; } diff --git a/protocol/aurum.proto b/protocol/aurum.proto index acb2c8c..bc0444f 100644 --- a/protocol/aurum.proto +++ b/protocol/aurum.proto @@ -167,7 +167,11 @@ message ReqFindElement { string packageName = 18; } - repeated ReqFindElement children = 19; + oneof _textpartialmatch { + string textPartialMatch = 19; + } + + repeated ReqFindElement children = 20; } message RspFindElement { RspStatus status = 1; -- 2.7.4