aurum: fix return value for setValue API 30/269630/2
authorHosang Kim <hosang12.kim@samsung.com>
Wed, 19 Jan 2022 08:52:12 +0000 (17:52 +0900)
committerHosang Kim <hosang12.kim@samsung.com>
Mon, 24 Jan 2022 08:05:54 +0000 (17:05 +0900)
Sometimes we need to check whether it is successful or not.

Change-Id: Ie1fb3fd2fa6f6a6db51407af704a28a0c80791e7

libaurum/inc/Accessibility/AccessibleNode.h
libaurum/inc/Impl/Accessibility/AtspiAccessibleNode.h
libaurum/inc/Impl/Accessibility/MockAccessibleNode.h
libaurum/inc/UiObject.h
libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc
libaurum/src/Impl/Accessibility/MockAccessibleNode.cc
libaurum/src/UiObject.cc
org.tizen.aurum-bootstrap/src/Commands/SetValueCommand.cc

index ee0c07d421fb33b2369bd437f53afcbb5dc2e229..20373adf9579db354cd8ef5ad8194fbf09df6680 100644 (file)
@@ -354,10 +354,12 @@ public:
      * @brief Sets Node's value.
      *
      * @param[in] text string
+        *
+        * @return true if success, else false
      *
      * @since_tizen 6.5
      */
-    virtual void setValue(std::string text) = 0;
+    virtual bool setValue(std::string text) = 0;
 
     /**
      * @brief Check object valid or not.
index 42b7c3bf03663b11b12465214624e32e0a1b4e97..dfda9ff6367d08b7430deb7edafe533dba4f9f7e 100644 (file)
@@ -134,7 +134,7 @@ public:
     /**
      * @copydoc AccessibleNode::setValue()
      */
-    void setValue(std::string text) override;
+    bool setValue(std::string text) override;
 
 private:
     using AccessibleNode::setFeatureProperty;
index 2071c8108458cebc690519c54ce22370d0bd7baf..7286e0398018f48b981c8dbc606c660262a08186 100644 (file)
@@ -139,7 +139,7 @@ public:
      * @brief TBD
      * @since_tizen 6.5
      */
-    void setValue(std::string text) override;
+    bool setValue(std::string text) override;
 
 public:
     using AccessibleNode::setFeatureProperty;
index e9d81cef30796c1782ce22c08dfbf26be32c7bdc..14ab71740ee29346a3881406d99ee79c0011de62 100644 (file)
@@ -269,11 +269,11 @@ public:
      *
      * @param[in] text string
      *
-     * @return string
+     * @return true if success else false
      *
      * @since_tizen 6.5
      */
-    void setText(std::string text);
+    bool setText(std::string text);
 
     /**
      * @brief Gets object's geometry of the screen.
index 13d9373764a622f5078f8d7507c68496884937ee..32e5555fe55af06f9c293f9f292e3f88f50c32bc 100644 (file)
@@ -373,20 +373,23 @@ bool AtspiAccessibleNode::doAction(std::string actionName)
     return false;
 }
 
-void AtspiAccessibleNode::setValue(std::string text)
+bool AtspiAccessibleNode::setValue(std::string text)
 {
     if (!isValid()){
-        return;
+        return false;
     }
 
     AtspiEditableText *iface = AtspiWrapper::Atspi_accessible_get_editable_text(mNode);
     LOGI("set Value iface:%p obj:%p text:%s", iface, mNode, text.c_str() );
-    if (iface) {
-        int len = getText().length();
-        AtspiWrapper::Atspi_editable_text_delete_text(iface, 0, len, NULL);
-        AtspiWrapper::Atspi_editable_text_insert_text(iface, 0, text.c_str(), text.length(),
-                                        NULL);
-    }
+
+    if (!iface) return false;
+
+    refresh();
+    int len = getText().length();
+    AtspiWrapper::Atspi_editable_text_delete_text(iface, 0, len, NULL);
+    AtspiWrapper::Atspi_editable_text_insert_text(iface, 0, text.c_str(), text.length(),
+                                                  NULL);
+    return true;
 }
 
 void AtspiAccessibleNode::setFeatureProperty(AtspiStateType type)
index 5497dc214ea95f000eb1f7e789d2e217646990a1..2fcce9a1c1a522f3c186d3011d7ff36bd52b5f2b 100644 (file)
@@ -128,9 +128,10 @@ bool MockAccessibleNode::doAction(std::string action)
     return false;
 }
 
-void MockAccessibleNode::setValue(std::string text)
+bool MockAccessibleNode::setValue(std::string text)
 {
     mText = text;
+    return true;
 }
 
 void MockAccessibleNode::setFeatureProperty(int type)
@@ -201,4 +202,4 @@ void MockAccessibleNode::addAction(std::string action)
 void MockAccessibleNode::clearActions(void)
 {
     mActionSet.clear();
-}
\ No newline at end of file
+}
index 7d4ebccd2410cfdc3e1feb2209a1fa191ba966e6..f4bce91066f93c7cb57a77bd38f63e895e55878b 100644 (file)
@@ -194,9 +194,9 @@ std::string UiObject::getRole() const
     return getAccessibleNode()->getRole();
 }
 
-void UiObject::setText(std::string text)
+bool UiObject::setText(std::string text)
 {
-    getAccessibleNode()->setValue(text);
+    return getAccessibleNode()->setValue(text);
 }
 
 bool UiObject::isCheckable() const
index 1204ecaf08f59f77525d18a6959d9af2d4181150..ae0f0d75951c375e16e39965774376192770db92 100644 (file)
@@ -26,11 +26,16 @@ SetValueCommand::SetValueCommand(const ::aurum::ReqSetValue* request,
 
 ::grpc::Status SetValueCommand::execute()
 {
+    bool ret = false;
     LOGI("SetValue --------------- ");
     LOGI("text:%s", mRequest->stringvalue().c_str());
 
     ObjectMapper *mObjMap = ObjectMapper::getInstance();
     std::shared_ptr<UiObject> obj = mObjMap->getElement(mRequest->elementid());
-    if (obj) obj->setText(const_cast<std::string&>(mRequest->stringvalue()));
+    if (obj) ret = obj->setText(const_cast<std::string&>(mRequest->stringvalue()));
+
+    if (ret) mResponse->set_status(::aurum::RspStatus::OK);
+    else mResponse->set_status(::aurum::RspStatus::ERROR);
+
     return grpc::Status::OK;
 }