aurum-service: Add textPartialMatch interface to search part of text in full text 31/268331/4
authorWoochanlee <wc0917.lee@samsung.com>
Mon, 20 Dec 2021 12:00:04 +0000 (21:00 +0900)
committerWoochanlee <wc0917.lee@samsung.com>
Tue, 28 Dec 2021 09:33:37 +0000 (18:33 +0900)
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
libaurum/inc/UiSelector.h
libaurum/src/PartialMatch.cc
libaurum/src/UiSelector.cc
org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc
protocol/aurum.proto

index fcc6aaf..e04bf33 100644 (file)
@@ -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.
index 302e6f7..f834b17 100644 (file)
@@ -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;
index 1e75b71..c1cd80a 100644 (file)
 
 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<UiSelector> selector,
                                  const std::shared_ptr<AccessibleNode> 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;
index 25af9e8..fe2ba4a 100644 (file)
 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;
index 34606f2..6783045 100644 (file)
@@ -45,24 +45,25 @@ std::vector<std::shared_ptr<UiSelector>> FindElementCommand::getSelectors(void)
 {
     auto sel = std::make_shared<UiSelector>();
 
-    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<std::shared_ptr<UiSelector>>{sel};
 }
index acb2c8c..bc0444f 100644 (file)
@@ -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;