From 304ca58f9d4eb7bb6473fa36325fce9ce709c76a Mon Sep 17 00:00:00 2001 From: Hosang Kim Date: Fri, 29 Nov 2024 13:44:10 +0900 Subject: [PATCH] aurum: add image source information Change-Id: I92c9ec52a12a1a31dd55e6b810f58f1d0db76ae0 --- libaurum/inc/Accessibility/AccessibleNode.h | 6 ++++++ libaurum/inc/UiObject.h | 9 +++++++++ libaurum/inc/UiSelector.h | 13 +++++++++++++ libaurum/src/Accessibility/AccessibleNode.cc | 8 +++++++- libaurum/src/AurumXML.cc | 1 + .../src/Impl/Accessibility/AtspiAccessibleNode.cc | 4 ++++ libaurum/src/PartialMatch.cc | 3 ++- libaurum/src/UiObject.cc | 5 +++++ libaurum/src/UiSelector.cc | 13 +++++++++++-- .../src/Commands/DumpObjectTreeCommand.cc | 1 + .../src/Commands/FindElementCommand.cc | 2 ++ .../src/Commands/FindElementsCommand.cc | 3 ++- .../src/Commands/FirstCommand.cc | 1 + .../src/Commands/LastCommand.cc | 1 + .../src/Commands/NextCommand.cc | 1 + .../src/Commands/PrevCommand.cc | 1 + protocol/aurum.proto | 9 +++++++++ 17 files changed, 76 insertions(+), 5 deletions(-) diff --git a/libaurum/inc/Accessibility/AccessibleNode.h b/libaurum/inc/Accessibility/AccessibleNode.h index c9524f9..6874b09 100644 --- a/libaurum/inc/Accessibility/AccessibleNode.h +++ b/libaurum/inc/Accessibility/AccessibleNode.h @@ -351,6 +351,11 @@ public: */ std::string getDescription() const; + /** + * @copydoc UiObject::getImgSrc() + */ + std::string getImgSrc() const; + /** * @copydoc UiObject::isCheckable() */ @@ -621,6 +626,7 @@ protected: std::string mToolkitName; std::string mInterface; std::string mDescription; + std::string mImgSrc; Rect mScreenBoundingBox; Rect mWindowBoundingBox; Rect mTextMinBoundingRect; diff --git a/libaurum/inc/UiObject.h b/libaurum/inc/UiObject.h index 7968155..0d9ea68 100644 --- a/libaurum/inc/UiObject.h +++ b/libaurum/inc/UiObject.h @@ -490,6 +490,15 @@ public: */ std::string getDescription() const; + /** + * @brief Gets object's image source. + * + * @return string + * + * @since_tizen 10.0 + */ + std::string getImgSrc() const; + /** * @brief Gets object's checkable property. * diff --git a/libaurum/inc/UiSelector.h b/libaurum/inc/UiSelector.h index 24519dc..93d0ce9 100644 --- a/libaurum/inc/UiSelector.h +++ b/libaurum/inc/UiSelector.h @@ -404,6 +404,17 @@ public: */ UiSelector *description(std::string description); + /** + * @brief Sets the search criteria to match the object's image source. + * + * @param[in] imgSrc object image source + * + * @return UiSelector class instance + * + * @since_tizen 10.0 + */ + UiSelector *imgSrc(std::string imgSrc); + public: std::string mId; std::string mAutomationId; @@ -416,6 +427,7 @@ public: std::string mXPath; std::string mOcrText; std::string mDescription; + std::string mImgSrc; bool mMatchId; bool mMatchAutomationId; @@ -429,6 +441,7 @@ public: bool mMatchOcrText; bool mMatchGeometry; bool mMatchDescription; + bool mMatchImgSrc; bool mMatchChecked; bool mMatchCheckable; diff --git a/libaurum/src/Accessibility/AccessibleNode.cc b/libaurum/src/Accessibility/AccessibleNode.cc index d84643e..b373c27 100644 --- a/libaurum/src/Accessibility/AccessibleNode.cc +++ b/libaurum/src/Accessibility/AccessibleNode.cc @@ -56,7 +56,7 @@ AccessibleNode::~AccessibleNode() } AccessibleNode::AccessibleNode() -: mText{""}, mOcrText{""}, mPkg{""}, mRole{""}, mId{""}, mAutomationId{""}, mType{""}, mStyle{""}, mXPath{""}, mToolkitName{""}, mInterface{""}, mDescription{""}, +: mText{""}, mOcrText{""}, mPkg{""}, mRole{""}, mId{""}, mAutomationId{""}, mType{""}, mStyle{""}, mXPath{""}, mToolkitName{""}, mInterface{""}, mDescription{""}, mImgSrc{""}, mScreenBoundingBox{0,0,0,0}, mWindowBoundingBox{0,0,0,0}, mTextMinBoundingRect{0,0,0,0}, mSupportingIfaces(0), mFeatureProperty(0), mPid(0), mWindowAngle(0), mTargetAngle(0), mMinValue{0.0}, mMaxValue{0.0}, mValue{0.0}, mIncrement{0.0}, mValid{true}, mLock{} { } @@ -74,6 +74,7 @@ std::string AccessibleNode::description() { ss << "\"mPkg\":\"" << this->mPkg << "\", "; ss << "\"mType\":\"" << this->mType << "\", "; ss << "\"mStyle\":\"" << this->mStyle << "\", "; + ss << "\"mImgSrc\":\"" << this->mImgSrc << "\", "; ss << "}"; return ss.str(); @@ -239,6 +240,11 @@ std::string AccessibleNode::getDescription() const return mDescription; } +std::string AccessibleNode::getImgSrc() const +{ + return mImgSrc; +} + bool AccessibleNode::isCheckable() const { return hasFeatureProperty(NodeFeatureProperties::CHECKABLE); diff --git a/libaurum/src/AurumXML.cc b/libaurum/src/AurumXML.cc index 25f267d..7cb8ff4 100644 --- a/libaurum/src/AurumXML.cc +++ b/libaurum/src/AurumXML.cc @@ -64,6 +64,7 @@ void AurumXML::traverse(xml_node& element, const std::shared_ptr element.append_attribute("name") = node->getText().c_str(); element.append_attribute("id") = node->getId().c_str(); element.append_attribute("automationid") = node->getAutomationId().c_str(); + element.append_attribute("imgSrc") = node->getImgSrc().c_str(); mXNodeMap[node->getId()] = node; diff --git a/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc b/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc index b82f0a6..ceea20c 100644 --- a/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc +++ b/libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc @@ -202,6 +202,7 @@ void AtspiAccessibleNode::updateAttributes() if (!t) t = (char*)g_hash_table_lookup(attributes, "class"); char *s = (char*)g_hash_table_lookup(attributes, "style"); char *a = (char*)g_hash_table_lookup(attributes, "automationId"); + char *i = (char*)g_hash_table_lookup(attributes, "imgSrc"); if (t) mType = std::string(t); else { @@ -210,6 +211,7 @@ void AtspiAccessibleNode::updateAttributes() } if (s) mStyle = std::string(s); if (a) mAutomationId = std::string(a); + if (i) mImgSrc = std::string(i); g_hash_table_unref(attributes); } @@ -370,11 +372,13 @@ void AtspiAccessibleNode::refresh(bool updateAll) if (!t) t = (char *)g_hash_table_lookup(attributes, "class"); char *s = (char *)g_hash_table_lookup(attributes, "style"); char *a = (char *)g_hash_table_lookup(attributes, "automationId"); + char *i = (char*)g_hash_table_lookup(attributes, "imgSrc"); if (t) mType = std::string(t); else mType = mRole; if (s) mStyle = std::string(s); if (a) mAutomationId = std::string(a); + if (i) mImgSrc = std::string(i); } } if (ni->states) { diff --git a/libaurum/src/PartialMatch.cc b/libaurum/src/PartialMatch.cc index defed5a..a18b3cd 100644 --- a/libaurum/src/PartialMatch.cc +++ b/libaurum/src/PartialMatch.cc @@ -74,11 +74,12 @@ bool PartialMatch::checkCriteria(const std::shared_ptr selector, node->updateUniqueId(); if (checkCriteria(selector->mId, node->getId(), 0)) return false; } - if (selector->mMatchType || selector->mMatchAutomationId || selector->mMatchStyle) { + if (selector->mMatchType || selector->mMatchAutomationId || selector->mMatchStyle || selector->mMatchImgSrc) { node->updateAttributes(); 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->mMatchImgSrc && checkCriteria(selector->mImgSrc, node->getImgSrc(), 0)) return false; } if (selector->mMatchPkg) { node->updateApplication(); diff --git a/libaurum/src/UiObject.cc b/libaurum/src/UiObject.cc index b15f2d9..75c1bbf 100644 --- a/libaurum/src/UiObject.cc +++ b/libaurum/src/UiObject.cc @@ -266,6 +266,11 @@ std::string UiObject::getDescription() const return mNode->getDescription(); } +std::string UiObject::getImgSrc() const +{ + return mNode->getImgSrc(); +} + bool UiObject::setValue(double value) { return mNode->setValue(value); diff --git a/libaurum/src/UiSelector.cc b/libaurum/src/UiSelector.cc index 15e708f..423e07c 100644 --- a/libaurum/src/UiSelector.cc +++ b/libaurum/src/UiSelector.cc @@ -22,9 +22,9 @@ using namespace Aurum; UiSelector::UiSelector() -: mId{}, mAutomationId{}, mRole{}, mText{}, mPkg{}, mType{}, mStyle{}, mTextPartialMatch{}, mXPath{}, mOcrText{}, mDescription{}, +: mId{}, mAutomationId{}, mRole{}, mText{}, mPkg{}, mType{}, mStyle{}, mTextPartialMatch{}, mXPath{}, mOcrText{}, mDescription{}, mImgSrc{}, mMatchId{}, mMatchAutomationId{}, mMatchRole{}, mMatchText{}, mMatchPkg{}, mMatchType{}, mMatchStyle{}, - mMatchTextPartialMatch{}, mMatchXPath{}, mMatchOcrText{}, mMatchGeometry{}, mMatchDescription{}, mMatchChecked{}, mMatchCheckable{}, mMatchClickable{}, mMatchEnabled{}, + mMatchTextPartialMatch{}, mMatchXPath{}, mMatchOcrText{}, mMatchGeometry{}, mMatchDescription{}, mMatchImgSrc{}, mMatchChecked{}, mMatchCheckable{}, mMatchClickable{}, mMatchEnabled{}, mMatchFocused{}, mMatchFocusable{}, mMatchScrollable{}, mMatchSelected{}, mMatchShowing{}, mMatchActive{}, mMatchVisible{}, mMatchSelectable{}, mMatchHighlightable{}, mMinDepth{}, mMaxDepth{}, mIschecked{}, mIscheckable{}, mIsclickable{}, mIsenabled{}, mIsfocused{}, mIsfocusable{}, mIsscrollable{}, mIsselected{}, mIsshowing{}, mIsactive{}, mIsvisible{}, @@ -47,6 +47,7 @@ std::string UiSelector::description() if(!this->mPkg.empty()) ss << "\"mPkg\":\"" << this->mPkg << "\", "; if(!this->mType.empty()) ss << "\"mType\":\"" << this->mType << "\", "; if(!this->mStyle.empty()) ss << "\"mStyle\":\"" << this->mStyle << "\", "; + if(!this->mImgSrc.empty()) ss << "\"mImgSrc\":\"" << this->mImgSrc << "\", "; if(this->mMatchGeometry) ss << "\"mGeometry\":\"" << this->mGeometry.mTopLeft.x << "//" << this->mGeometry.mTopLeft.y << "//" << this->mGeometry.width() << "//" << this->mGeometry.height() << "\", "; if(this->mMatchId) ss << "\"mMatchId\":\"" << ((this->mMatchId)?"true":"false") << "\", "; if(this->mMatchAutomationId) ss << "\"mMatchAutomationId\":\"" << ((this->mMatchAutomationId)?"true":"false") << "\", "; @@ -60,6 +61,7 @@ std::string UiSelector::description() if(this->mMatchStyle) ss << "\"mMatchStyle\":\"" << ((this->mMatchStyle)?"true":"false" )<< "\", "; if(this->mMatchGeometry) ss << "\"mMatchGeometry\":\"" << ((this->mMatchGeometry)?"true":"false" )<< "\", "; if(this->mMatchDescription) ss << "\"mMatchDescription\":\"" << ((this->mMatchDescription)?"true":"false") << "\", "; + if(this->mMatchImgSrc) ss << "\"mMatchImgSrc\":\"" << ((this->mMatchImgSrc)?"true":"false") << "\", "; if(this->mMinDepth) ss << "\"mMinDepth\":\"" << this->mMinDepth << "\", "; if(this->mMaxDepth) ss << "\"mMaxDepth\":\"" << this->mMaxDepth << "\", "; if(this->mMatchChecked) ss << "\"mMatchChecked\":\"" << ((this->mMatchChecked)?"true":"false") << "\", "; @@ -302,3 +304,10 @@ UiSelector *UiSelector::description(std::string description) this->mMatchDescription = true; return this; } + +UiSelector *UiSelector::imgSrc(std::string imgSrc) +{ + this->mImgSrc = imgSrc; + this->mMatchImgSrc = true; + return this; +} diff --git a/org.tizen.aurum-bootstrap/src/Commands/DumpObjectTreeCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/DumpObjectTreeCommand.cc index 7021eca..eb39d54 100644 --- a/org.tizen.aurum-bootstrap/src/Commands/DumpObjectTreeCommand.cc +++ b/org.tizen.aurum-bootstrap/src/Commands/DumpObjectTreeCommand.cc @@ -88,6 +88,7 @@ void DumpObjectTreeCommand::traverse(::aurum::Element *root, std::shared_ptrset_interface(obj->getInterface()); root->set_description(obj->getDescription()); + root->set_imgsrc(obj->getImgSrc()); for( auto && childNode : node->mChildren) { ::aurum::Element *child = root->add_child(); diff --git a/org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc index e9b27f2..12e202f 100644 --- a/org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc +++ b/org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc @@ -73,6 +73,7 @@ std::shared_ptr FindElementCommand::getSelector(void) if(mRequest->reqIsselectable_case()) sel->isSelectable(mRequest->isselectable()); if(mRequest->reqIshighlightable_case()) sel->isHighlightable(mRequest->ishighlightable()); if(mRequest->reqDescription_case()) sel->description(mRequest->description()); + if(mRequest->reqImgSrc_case()) sel->imgSrc(mRequest->imgsrc()); return sel; } @@ -150,6 +151,7 @@ std::shared_ptr FindElementCommand::getSelector(void) elm->set_interface(obj->getInterface()); elm->set_description(obj->getDescription()); + elm->set_imgsrc(obj->getImgSrc()); mResponse->set_status(::aurum::RspStatus::OK); } else { diff --git a/org.tizen.aurum-bootstrap/src/Commands/FindElementsCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/FindElementsCommand.cc index ce95b5e..8a5d68f 100644 --- a/org.tizen.aurum-bootstrap/src/Commands/FindElementsCommand.cc +++ b/org.tizen.aurum-bootstrap/src/Commands/FindElementsCommand.cc @@ -73,7 +73,7 @@ std::vector> FindElementsCommand::getSelectors(void) if(mRequest->reqIsselectable_case()) sel->isSelectable(mRequest->isselectable()); if(mRequest->reqIshighlightable_case()) sel->isHighlightable(mRequest->ishighlightable()); if(mRequest->reqDescription_case()) sel->description(mRequest->description()); - + if(mRequest->reqImgSrc_case()) sel->imgSrc(mRequest->imgsrc()); return std::vector>{sel}; } @@ -158,6 +158,7 @@ std::vector> FindElementsCommand::getSelectors(void) elm->set_interface(obj->getInterface()); elm->set_description(obj->getDescription()); + elm->set_imgsrc(obj->getImgSrc()); } mResponse->set_status(::aurum::RspStatus::OK); } else { diff --git a/org.tizen.aurum-bootstrap/src/Commands/FirstCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/FirstCommand.cc index 43e21fb..a7c5f4a 100644 --- a/org.tizen.aurum-bootstrap/src/Commands/FirstCommand.cc +++ b/org.tizen.aurum-bootstrap/src/Commands/FirstCommand.cc @@ -98,6 +98,7 @@ FirstCommand::FirstCommand(const ::aurum::ReqFirst *request, elm->set_interface(obj->getInterface()); elm->set_description(obj->getDescription()); + elm->set_imgsrc(obj->getImgSrc()); mResponse->set_status(::aurum::RspStatus::OK); } else { diff --git a/org.tizen.aurum-bootstrap/src/Commands/LastCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/LastCommand.cc index ada839a..85b7de6 100644 --- a/org.tizen.aurum-bootstrap/src/Commands/LastCommand.cc +++ b/org.tizen.aurum-bootstrap/src/Commands/LastCommand.cc @@ -98,6 +98,7 @@ LastCommand::LastCommand(const ::aurum::ReqLast *request, elm->set_interface(obj->getInterface()); elm->set_description(obj->getDescription()); + elm->set_imgsrc(obj->getImgSrc()); mResponse->set_status(::aurum::RspStatus::OK); } else { diff --git a/org.tizen.aurum-bootstrap/src/Commands/NextCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/NextCommand.cc index 038acd5..08b0fc6 100644 --- a/org.tizen.aurum-bootstrap/src/Commands/NextCommand.cc +++ b/org.tizen.aurum-bootstrap/src/Commands/NextCommand.cc @@ -98,6 +98,7 @@ NextCommand::NextCommand(const ::aurum::ReqNext *request, elm->set_interface(obj->getInterface()); elm->set_description(obj->getDescription()); + elm->set_imgsrc(obj->getImgSrc()); mResponse->set_status(::aurum::RspStatus::OK); } else { diff --git a/org.tizen.aurum-bootstrap/src/Commands/PrevCommand.cc b/org.tizen.aurum-bootstrap/src/Commands/PrevCommand.cc index 3447b2c..54475df 100644 --- a/org.tizen.aurum-bootstrap/src/Commands/PrevCommand.cc +++ b/org.tizen.aurum-bootstrap/src/Commands/PrevCommand.cc @@ -98,6 +98,7 @@ PrevCommand::PrevCommand(const ::aurum::ReqPrev *request, elm->set_interface(obj->getInterface()); elm->set_description(obj->getDescription()); + elm->set_imgsrc(obj->getImgSrc()); mResponse->set_status(::aurum::RspStatus::OK); } else { diff --git a/protocol/aurum.proto b/protocol/aurum.proto index 1ecdafa..1492f09 100644 --- a/protocol/aurum.proto +++ b/protocol/aurum.proto @@ -108,6 +108,7 @@ message Element { string interface = 33; string description = 34; + string imgSrc = 35; } message Point { @@ -233,6 +234,10 @@ message ReqFindElement { string description = 26; } + oneof reqImgSrc { + string imgSrc = 28; + } + repeated ReqFindElement children = 27; } @@ -345,6 +350,10 @@ message ReqFindElements { string description = 26; } + oneof reqImgSrc { + string imgSrc = 28; + } + repeated ReqFindElements children = 27; } -- 2.34.1