bootstrap: rework ClearCommand accepted/tizen/unified/20200409.083718 submit/tizen/20200405.220557 submit/tizen/20200406.235844 submit/tizen/20200407.212858 submit/tizen/20200408.212617
authorWonki Kim <wonki_.kim@samsung.com>
Thu, 26 Mar 2020 09:58:27 +0000 (18:58 +0900)
committerJongmin Lee <jm105.lee@samsung.com>
Fri, 3 Apr 2020 00:33:21 +0000 (09:33 +0900)
Change-Id: Id515e6b377e0fe1c52d5f3af0d9027b3acf9011b

bootstrap/server/inc/Commands/ClearCommand.h
bootstrap/server/src/Commands/ClearCommand.cc
bootstrap/server/src/Commands/SetValueCommand.cc
libaurum/inc/AccessibleNode.h
libaurum/inc/UiObject.h
libaurum/src/AccessibleNode.cc
libaurum/src/UiObject.cc

index 7883290..0197559 100644 (file)
@@ -15,8 +15,10 @@ private:
 
 public:
     ClearCommand(const ::aurum::ReqClear* request, ::aurum::RspClear* response);
-    ;
     ::grpc::Status execute() override;
+
+protected:
+    bool hasHintText(UiObject *obj);
 };
 
 #endif
\ No newline at end of file
index 60683ae..5c24358 100644 (file)
@@ -1,7 +1,6 @@
 #include "ClearCommand.h"
 #include <UiObject.h>
 #include <loguru.hpp>
-
 #include <string>
 
 ClearCommand::ClearCommand(const ::aurum::ReqClear* request,
@@ -10,6 +9,20 @@ ClearCommand::ClearCommand(const ::aurum::ReqClear* request,
 {
 }
 
+bool ClearCommand::hasHintText(UiObject *obj)
+{
+    if (!obj) return false;
+
+    auto old_text = obj->getText();
+    obj->setText("");
+    if (!old_text.compare(obj->getText())) {
+        return true;
+    } else {
+        obj->setText(old_text);
+        return false;
+    }
+}
+
 ::grpc::Status ClearCommand::execute()
 {
     LOG_SCOPE_F(INFO, "Clear --------------- ");
@@ -17,9 +30,18 @@ ClearCommand::ClearCommand(const ::aurum::ReqClear* request,
     UiObject*     obj = mObjMap->getElement(mRequest->elementid());
 
     if (obj) {
-        std::string empty{};
-        obj->setText(empty);
-        mResponse->set_status(::aurum::RspStatus::OK);
+        obj->setText("");
+        obj->refresh();
+        auto text = obj->getText();
+        if (text.length() != 0) {
+            if (hasHintText(obj)) {
+                mResponse->set_status(::aurum::RspStatus::OK);
+            } else {
+                mResponse->set_status(::aurum::RspStatus::ERROR);
+            }
+        } else {
+            mResponse->set_status(::aurum::RspStatus::OK);
+        }
     }
 
     return grpc::Status::OK;
index 1aa59de..9f574ee 100644 (file)
@@ -9,10 +9,9 @@ SetValueCommand::SetValueCommand(const ::aurum::ReqSetValue* request,
 
 ::grpc::Status SetValueCommand::execute()
 {
-    LOG_SCOPE_F(INFO, "SetValue --------------- ");
+    LOG_SCOPE_F(INFO, "SetValue (text:%s) --------------- ", mRequest->stringvalue().c_str());
     ObjectMapper* mObjMap = ObjectMapper::getInstance();
     UiObject*     obj = mObjMap->getElement(mRequest->elementid());
     if (obj) obj->setText(const_cast<std::string&>(mRequest->stringvalue()));
-    LOG_F(INFO, "%p %s", obj, mRequest->stringvalue().c_str());
     return grpc::Status::OK;
 }
\ No newline at end of file
index a842881..a2eed5f 100644 (file)
@@ -133,7 +133,7 @@ public:
     void print(int, int) const;
     void refresh() const;
 
-    void setValue(std::string &text) const;
+    void setValue(std::string text) const;
 
 private:
     bool isSupporting(AccessibleNodeInterface thisIface) const;
index 4b1b0f7..7fe6d89 100644 (file)
@@ -48,7 +48,7 @@ public:
     std::string getResourceName() const;
 
     std::string getText() const;
-    void        setText(std::string &text);
+    void        setText(std::string text);
 
     const Rect<int> getBoundingBox() const;
 
index 0f75a2b..f275538 100644 (file)
@@ -377,10 +377,13 @@ AtspiAccessible *AccessibleNode::getAccessible() const
     return mNode.get();
 }
 
-void AccessibleNode::setValue(std::string &text) const
+void AccessibleNode::setValue(std::string text) const
 {
     AtspiEditableText *iface = atspi_accessible_get_editable_text(mNode.get());
+    LOG_F(INFO,"set Value iface:%p obj:%p text:%s", iface, mNode.get(), text.c_str() );
     if (iface) {
+        int len = getText().length();
+        atspi_editable_text_delete_text(iface, 0, len, NULL);
         atspi_editable_text_insert_text(iface, 0, text.c_str(), text.length(),
                                         NULL);
     }
index f185dc0..184beaf 100644 (file)
@@ -138,7 +138,7 @@ std::string UiObject::getText() const
     return getAccessibleNode()->getText();
 }
 
-void UiObject::setText(std::string &text)
+void UiObject::setText(std::string text)
 {
     getAccessibleNode()->setValue(text);
 }