libaurum: Introduce new value commands 24/275224/4
authorHosang Kim <hosang12.kim@samsung.com>
Wed, 18 May 2022 11:51:57 +0000 (20:51 +0900)
committerwoochan lee <wc0917.lee@samsung.com>
Wed, 22 Jun 2022 11:11:34 +0000 (11:11 +0000)
-get minimum value
-get maximum value
-get current value
-get minimum increment
-set current value

Change-Id: I82fd2b4b9066cdaa7645ee3418db39876aaf5a75

16 files changed:
libaurum/inc/Accessibility/AccessibleNode.h
libaurum/inc/Impl/Accessibility/AtspiAccessibleNode.h
libaurum/inc/Impl/Accessibility/AtspiWrapper.h
libaurum/inc/Impl/Accessibility/MockAccessibleNode.h
libaurum/inc/UiObject.h
libaurum/src/Accessibility/AccessibleNode.cc
libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc
libaurum/src/Impl/Accessibility/AtspiWrapper.cc
libaurum/src/Impl/Accessibility/MockAccessibleNode.cc
libaurum/src/UiObject.cc
org.tizen.aurum-bootstrap/src/Commands/DumpObjectTreeCommand.cc
org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc
org.tizen.aurum-bootstrap/src/Commands/FindElementsCommand.cc
org.tizen.aurum-bootstrap/src/Commands/GetValueCommand.cc
org.tizen.aurum-bootstrap/src/Commands/SetValueCommand.cc
protocol/aurum.proto

index 2077d23..9a44612 100644 (file)
@@ -183,6 +183,7 @@ public:
      * @copydoc UiObject::getStyle()
      */
     std::string getStyle() const;
+
     /**
      * @copydoc UiObject::getXPath()
      */
@@ -199,6 +200,30 @@ public:
     Rect<int> getWindowBoundingBox() const;
 
     /**
+     * @copydoc UiObject::getMinValue()
+     *
+     */
+    double getMinValue() const;
+
+    /**
+     * @copydoc UiObject::getMaxValue()
+     *
+     */
+    double getMaxValue() const;
+
+    /**
+     * @copydoc UiObject::getValue()
+     *
+     */
+    double getValue() const;
+
+    /**
+     * @copydoc UiObject::getIncrement()
+     *
+     */
+    double getIncrement() const;
+
+    /**
      * @copydoc UiObject::isCheckable()
      */
     bool isCheckable() const;
@@ -333,6 +358,11 @@ public:
     virtual void updateXPath() = 0;
 
     /**
+     * @copydoc UiObject::updateValue()
+     */
+    virtual void updateValue() = 0;
+
+    /**
      * @copydoc UiObject::setFocus()
      */
     virtual bool setFocus() = 0;
@@ -376,6 +406,17 @@ public:
     virtual bool setValue(std::string text) = 0;
 
     /**
+     * @brief Sets Node's value.
+     *
+     * @param[in] value double
+     *
+     * @return true if success, else false
+     *
+     * @since_tizen 7.0
+     */
+    virtual bool setValue(double value) = 0;
+
+    /**
      * @brief Check object valid or not.
      *
      * @return true if valid, else false
@@ -437,6 +478,10 @@ protected:
     Rect<int> mWindowBoundingBox;
     int mSupportingIfaces;
     int mFeatureProperty;
+    double mMinValue;
+    double mMaxValue;
+    double mValue;
+    double mIncrement;
 
 private:
     bool mValid;
index dd187f9..2724c93 100644 (file)
@@ -122,6 +122,11 @@ public:
     void updateXPath() override;
 
     /**
+     * @copydoc UiObject::updateValue()
+     */
+    void updateValue() override;
+
+    /**
      * @copydoc UiObject::setFocus()
      */
     bool setFocus() override;
@@ -146,6 +151,11 @@ public:
      */
     bool setValue(std::string text) override;
 
+    /**
+     * @copydoc AccessibleNode::setValue()
+     */
+    bool setValue(double value) override;
+
 private:
     using AccessibleNode::setFeatureProperty;
 
index e9bcb8e..89a6dae 100644 (file)
@@ -60,6 +60,12 @@ public:
     static void Atspi_accessible_clear_cache (AtspiAccessible *node);
     static gboolean Atspi_component_grab_focus(AtspiComponent *obj, GError **error);
     static void Atspi_accessible_set_cache_mask(AtspiAccessible *node, AtspiCache mask);
+    static AtspiValue *Atspi_accessible_get_value(AtspiAccessible *node);
+    static gdouble Atspi_value_get_minimum_value(AtspiValue *iface, GError **error);
+    static gdouble Atspi_value_get_current_value(AtspiValue *iface, GError **error);
+    static gdouble Atspi_value_get_maximum_value(AtspiValue *iface, GError **error);
+    static gboolean Atspi_value_set_current_value(AtspiValue *iface, gdouble value, GError **error);
+    static gdouble Atspi_value_get_minimum_increment(AtspiValue *iface, GError **error);
 
 private:
     static std::recursive_mutex mMutex;
index 1a2852f..be6ce32 100644 (file)
@@ -116,6 +116,7 @@ public:
      * @since_tizen 6.5
      */
     void updateExtents() override;
+
     /**
      * @brief TBD
      * @since_tizen 6.5
@@ -126,6 +127,12 @@ public:
      * @brief TBD
      * @since_tizen 7.0
      */
+    void updateValue() override;
+
+    /**
+     * @brief TBD
+     * @since_tizen 7.0
+     */
     bool setFocus() override;
 
        /**
@@ -152,6 +159,12 @@ public:
      */
     bool setValue(std::string text) override;
 
+    /**
+     * @brief TBD
+     * @since_tizen 7.0
+     */
+    bool setValue(double value) override;
+
 public:
     using AccessibleNode::setFeatureProperty;
     /**
index 4065bda..98c3a6c 100644 (file)
@@ -303,6 +303,53 @@ public:
     const Rect<int> getWindowBoundingBox() const;
 
     /**
+     * @brief Gets object's minimum value.
+     *
+     * @return double
+     *
+     * @since_tizen 7.0
+     */
+    const double getMinValue() const;
+
+    /**
+     * @brief Gets object's maximum value.
+     *
+     * @return double
+     *
+     * @since_tizen 7.0
+     */
+    const double getMaxValue() const;
+
+    /**
+     * @brief Gets object's current value.
+     *
+     * @return double
+     *
+     * @since_tizen 7.0
+     */
+    const double getValue() const;
+
+    /**
+     * @brief Gets object's current increment.
+     *
+     * @return double
+     *
+     * @since_tizen 7.0
+     */
+    const double getIncrement() const;
+
+    /**
+     * @brief Sets object's value.
+     *
+     * @param[in] double value
+     *
+     * @return true if success else false
+     *
+     * @since_tizen 7.0
+     */
+    bool setValue(double value);
+
+    /**
      * @brief Gets object's checkable property.
      *
      * @return true if checkable else false
@@ -497,6 +544,13 @@ public:
     void updateXPath() const;
 
     /**
+     * @brief Updates object's value information from atspi server.
+     *
+     * @since_tizen 7.0
+     */
+    void updateValue() const;
+
+    /**
      * @brief Sets focus to object.
      *
      * @since_tizen 7.0
index 60f6baa..4fc7fcf 100644 (file)
@@ -31,8 +31,8 @@ AccessibleNode::~AccessibleNode()
 }
 
 AccessibleNode::AccessibleNode()
-: mText{""}, mPkg{""}, mRole{""}, mId{""}, mType{""}, mStyle{""},
-  mScreenBoundingBox{0,0,0,0}, mWindowBoundingBox{0,0,0,0}, mSupportingIfaces(0), mFeatureProperty(0), mValid{true}, mLock{}
+: mText{""}, mPkg{""}, mRole{""}, mId{""}, mAutomationId{""}, mType{""}, mStyle{""}, mXPath{""},
+  mScreenBoundingBox{0,0,0,0}, mWindowBoundingBox{0,0,0,0}, mSupportingIfaces(0), mFeatureProperty(0), mMinValue{0.0}, mMaxValue{0.0}, mValue{0.0}, mIncrement{0.0}, mValid{true}, mLock{}
 {
 }
 
@@ -229,3 +229,23 @@ bool AccessibleNode::isActive() const
 {
     return hasFeatureProperty(NodeFeatureProperties::ACTIVE);
 }
+
+double AccessibleNode::getMinValue() const
+{
+    return mMinValue;
+}
+
+double AccessibleNode::getMaxValue() const
+{
+    return mMaxValue;
+}
+
+double AccessibleNode::getValue() const
+{
+    return mValue;
+}
+
+double AccessibleNode::getIncrement() const
+{
+    return mIncrement;
+}
\ No newline at end of file
index 3cb67ea..d0b88d1 100644 (file)
@@ -240,6 +240,20 @@ void AtspiAccessibleNode::updateXPath()
     mXPath = XMLDoc->getXPath(mId);
 }
 
+void AtspiAccessibleNode::updateValue()
+{
+    AtspiWrapper::Atspi_accessible_clear_cache(mNode);
+
+    AtspiValue *value = AtspiWrapper::Atspi_accessible_get_value(mNode);
+    if (value) {
+        mMinValue= AtspiWrapper::Atspi_value_get_minimum_value(value, NULL);
+        mMaxValue= AtspiWrapper::Atspi_value_get_maximum_value(value, NULL);
+        mValue= AtspiWrapper::Atspi_value_get_current_value(value, NULL);
+        mIncrement= AtspiWrapper::Atspi_value_get_minimum_increment(value, NULL);
+        g_object_unref(value);
+    }
+}
+
 bool AtspiAccessibleNode::setFocus()
 {
     AtspiComponent *component = AtspiWrapper::Atspi_accessible_get_component_iface(mNode);
@@ -337,9 +351,19 @@ void AtspiAccessibleNode::refresh(bool updateAll)
                 g_free(windowExtent);
             }
             g_object_unref(component);
+        }
 
-            if (updateAll) updateXPath();
+        AtspiValue *value = AtspiWrapper::Atspi_accessible_get_value(mNode);
+        if (value) {
+            mMinValue= AtspiWrapper::Atspi_value_get_minimum_value(value, NULL);
+            mMaxValue= AtspiWrapper::Atspi_value_get_maximum_value(value, NULL);
+            mValue= AtspiWrapper::Atspi_value_get_current_value(value, NULL);
+            mIncrement= AtspiWrapper::Atspi_value_get_minimum_increment(value, NULL);
+            g_object_unref(value);
         }
+
+        if (updateAll) updateXPath();
+
     } else {
         setFeatureProperty(ATSPI_STATE_INVALID);
     }
@@ -413,7 +437,7 @@ bool AtspiAccessibleNode::setValue(std::string text)
 
     if (!iface) return false;
 
-    refresh();
+    updateName();
     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(),
@@ -423,6 +447,24 @@ bool AtspiAccessibleNode::setValue(std::string text)
     return true;
 }
 
+bool AtspiAccessibleNode::setValue(double value)
+{
+    if (!isValid()){
+        return false;
+    }
+
+    AtspiValue *iface = AtspiWrapper::Atspi_accessible_get_value(mNode);
+    LOGI("set Value iface:%p obj:%p value:%lf",iface, mNode, value);
+
+    if (!iface) return false;
+
+    updateValue();
+    AtspiWrapper::Atspi_value_set_current_value(iface, value, NULL);
+    g_object_unref(iface);
+
+    return true;
+}
+
 void AtspiAccessibleNode::setFeatureProperty(AtspiStateType type)
 {
     switch(type) {
index 8a81984..34d459f 100644 (file)
@@ -170,3 +170,39 @@ void AtspiWrapper::Atspi_accessible_set_cache_mask(AtspiAccessible *node, AtspiC
     std::unique_lock<std::recursive_mutex> lock(mMutex);
     return atspi_accessible_set_cache_mask (node, mask);
 }
+
+AtspiValue *AtspiWrapper::Atspi_accessible_get_value(AtspiAccessible *node)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_accessible_get_value_iface(node);
+}
+
+gdouble AtspiWrapper::Atspi_value_get_minimum_value(AtspiValue *iface, GError **error)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_value_get_minimum_value(iface, error);
+}
+
+gdouble AtspiWrapper::Atspi_value_get_current_value(AtspiValue *iface, GError **error)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_value_get_current_value(iface, error);
+}
+
+gdouble AtspiWrapper::Atspi_value_get_maximum_value(AtspiValue *iface, GError **error)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_value_get_maximum_value(iface, error);
+}
+
+gboolean AtspiWrapper::Atspi_value_set_current_value(AtspiValue *iface, gdouble value, GError **error)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_value_set_current_value(iface, value, error);
+}
+
+gdouble AtspiWrapper::Atspi_value_get_minimum_increment(AtspiValue *iface, GError **error)
+{
+    std::unique_lock<std::recursive_mutex> lock(mMutex);
+    return atspi_value_get_minimum_increment(iface, error);
+}
\ No newline at end of file
index cd78ffa..51ba193 100644 (file)
@@ -113,6 +113,10 @@ void MockAccessibleNode::updateXPath()
 {
 }
 
+void MockAccessibleNode::updateValue()
+{
+}
+
 bool MockAccessibleNode::setFocus()
 {
     return false;
@@ -143,6 +147,11 @@ bool MockAccessibleNode::setValue(std::string text)
     return true;
 }
 
+bool MockAccessibleNode::setValue(double value)
+{
+    return true;
+}
+
 void MockAccessibleNode::setFeatureProperty(int type)
 {
     switch(type) {
index ccf60ef..706d28f 100644 (file)
@@ -199,6 +199,31 @@ std::string UiObject::getXPath() const
     return getAccessibleNode()->getXPath();
 }
 
+const double UiObject::getMinValue() const
+{
+    return getAccessibleNode()->getMinValue();
+}
+
+const double UiObject::getMaxValue() const
+{
+    return getAccessibleNode()->getMaxValue();
+}
+
+const double UiObject::getValue() const
+{
+    return getAccessibleNode()->getValue();
+}
+
+const double UiObject::getIncrement() const
+{
+    return getAccessibleNode()->getIncrement();
+}
+
+bool UiObject::setValue(double value)
+{
+    return getAccessibleNode()->setValue(value);
+}
+
 bool UiObject::setText(std::string text)
 {
     return getAccessibleNode()->setValue(text);
@@ -314,6 +339,11 @@ void UiObject::updateXPath() const
     mNode->updateXPath();
 }
 
+void UiObject::updateValue() const
+{
+    mNode->updateValue();
+}
+
 bool UiObject::setFocus() const
 {
     return mNode->setFocus();
index 48e8dee..dfcda80 100644 (file)
@@ -77,6 +77,11 @@ void DumpObjectTreeCommand::traverse(::aurum::Element *root, std::shared_ptr<Nod
     root->set_isvisible(obj->isVisible());
     root->set_isselectable(obj->isSelectable());
 
+    root->set_minvalue(obj->getMinValue());
+    root->set_maxvalue(obj->getMaxValue());
+    root->set_value(obj->getValue());
+    root->set_increment(obj->getIncrement());
+
     for( auto && childNode : node->mChildren) {
         ::aurum::Element *child = root->add_child();
         traverse(child, childNode, depth+1);
index cdcdff2..929119d 100644 (file)
@@ -125,6 +125,11 @@ std::shared_ptr<UiSelector> FindElementCommand::getSelector(void)
         elm->set_isvisible(obj->isVisible());
         elm->set_isselectable(obj->isSelectable());
 
+        elm->set_minvalue(obj->getMinValue());
+        elm->set_maxvalue(obj->getMaxValue());
+        elm->set_value(obj->getValue());
+        elm->set_increment(obj->getIncrement());
+
         mResponse->set_status(::aurum::RspStatus::OK);
     } else {
         mResponse->set_status(::aurum::RspStatus::ERROR);
index 74e281b..2efc5c7 100644 (file)
@@ -130,6 +130,11 @@ std::vector<std::shared_ptr<UiSelector>> FindElementsCommand::getSelectors(void)
             elm->set_isactive(obj->isActive());
             elm->set_isvisible(obj->isVisible());
             elm->set_isselectable(obj->isSelectable());
+
+            elm->set_minvalue(obj->getMinValue());
+            elm->set_maxvalue(obj->getMaxValue());
+            elm->set_value(obj->getValue());
+            elm->set_increment(obj->getIncrement());
         }
         mResponse->set_status(::aurum::RspStatus::OK);
     } else {
index 0b4f257..e5eaaba 100644 (file)
@@ -20,7 +20,7 @@
 #include "UiObject.h"
 
 GetValueCommand::GetValueCommand(const ::aurum::ReqGetValue *request,
-                                 ::aurum::RspGetValue *response)
+                                 ::aurum::RspGetValue       *response)
     : mRequest{request}, mResponse{response}
 {
 }
@@ -28,14 +28,41 @@ GetValueCommand::GetValueCommand(const ::aurum::ReqGetValue *request,
 ::grpc::Status GetValueCommand::execute()
 {
     LOGI("GetValue --------------- ");
-    ObjectMapper *mObjMap = ObjectMapper::getInstance();
-    std::shared_ptr<UiObject> obj = mObjMap->getElement(mRequest->elementid());
+    ::aurum::ParamType param_type = mRequest->type();
+    if (param_type == ::aurum::STRING) {
+        ObjectMapper             *mObjMap = ObjectMapper::getInstance();
+        std::shared_ptr<UiObject> obj =
+            mObjMap->getElement(mRequest->elementid());
 
-    if (obj) {
-        obj->updateName();
-        std::string text = obj->getText();
-        mResponse->set_stringvalue(text.c_str());
-        mResponse->set_status(::aurum::RspStatus::OK);
+        if (obj) {
+            obj->updateName();
+            std::string text = obj->getText();
+            mResponse->set_type(::aurum::STRING);
+            mResponse->set_stringvalue(text.c_str());
+            mResponse->set_status(::aurum::RspStatus::OK);
+        } else {
+            mResponse->set_status(::aurum::RspStatus::ERROR);
+        }
+    } else if (param_type == ::aurum::INT) {
+        LOGI("Integer is not supported.");
+        mResponse->set_status(::aurum::RspStatus::ERROR);
+    } else if (param_type == ::aurum::DOUBLE) {
+        ObjectMapper             *mObjMap = ObjectMapper::getInstance();
+        std::shared_ptr<UiObject> obj =
+            mObjMap->getElement(mRequest->elementid());
+
+        if (obj) {
+            obj->updateValue();
+            double value = obj->getValue();
+            mResponse->set_type(::aurum::DOUBLE);
+            mResponse->set_doublevalue(value);
+            mResponse->set_status(::aurum::RspStatus::OK);
+        } else {
+            mResponse->set_status(::aurum::RspStatus::ERROR);
+        }
+    } else if (param_type == ::aurum::BOOL) {
+        LOGI("Boolean is not supported.");
+        mResponse->set_status(::aurum::RspStatus::ERROR);
     }
 
     return grpc::Status::OK;
index ae0f0d7..6f7f1ee 100644 (file)
@@ -28,14 +28,33 @@ SetValueCommand::SetValueCommand(const ::aurum::ReqSetValue* request,
 {
     bool ret = false;
     LOGI("SetValue --------------- ");
-    LOGI("text:%s", mRequest->stringvalue().c_str());
+    ::aurum::ParamType param_type = mRequest->type();
+    if (param_type == ::aurum::STRING) {
+        LOGI("text:%s", mRequest->stringvalue().c_str());
 
-    ObjectMapper *mObjMap = ObjectMapper::getInstance();
-    std::shared_ptr<UiObject> obj = mObjMap->getElement(mRequest->elementid());
-    if (obj) ret = obj->setText(const_cast<std::string&>(mRequest->stringvalue()));
+        ObjectMapper*             mObjMap = ObjectMapper::getInstance();
+        std::shared_ptr<UiObject> obj =
+            mObjMap->getElement(mRequest->elementid());
+        if (obj)
+            ret =
+                obj->setText(const_cast<std::string&>(mRequest->stringvalue()));
+    } else if (param_type == ::aurum::INT) {
+        LOGI("Integer is not supported.");
+    } else if (param_type == ::aurum::DOUBLE) {
+        LOGI("value:%lf", mRequest->doublevalue());
+        ObjectMapper*             mObjMap = ObjectMapper::getInstance();
+        std::shared_ptr<UiObject> obj =
+            mObjMap->getElement(mRequest->elementid());
+        if (obj) ret = obj->setValue(mRequest->doublevalue());
 
-    if (ret) mResponse->set_status(::aurum::RspStatus::OK);
-    else mResponse->set_status(::aurum::RspStatus::ERROR);
+    } else if (param_type == ::aurum::BOOL) {
+        LOGI("Boolean is not supported.");
+    }
+
+    if (ret)
+        mResponse->set_status(::aurum::RspStatus::OK);
+    else
+        mResponse->set_status(::aurum::RspStatus::ERROR);
 
     return grpc::Status::OK;
 }
index a9ef0f9..6b7d454 100644 (file)
@@ -78,6 +78,11 @@ message Element {
    bool isActive = 21;
    bool isVisible = 22;
    bool isSelectable = 23;
+
+   double minValue = 24;
+   double maxValue = 25;
+   double value = 26;
+   double increment = 27;
 }
 
 message Point {
@@ -279,6 +284,7 @@ message RspFindElements {
 
 message ReqGetValue {
    string elementId = 1;
+   ParamType type  = 2;
    // TODO : text, widgetstyle, widgettype, automationid
 }
 message RspGetValue {