refactor atspi related classes to mock atspi interface.
authorWonki Kim <wonki_.kim@samsung.com>
Mon, 7 Sep 2020 07:30:43 +0000 (16:30 +0900)
committerWonki Kim <wonki_.kim@samsung.com>
Fri, 11 Sep 2020 09:13:06 +0000 (18:13 +0900)
this patch refactors atspi related classes to mock atspi interface.

Change-Id: I2cfa273b29f4a8822ccb35364a9ce9977eeb9392

35 files changed:
libaurum/inc/Accessibility/AccessibleNode.h
libaurum/inc/Accessibility/AccessibleWindow.h
libaurum/inc/Comparer.h
libaurum/inc/Impl/Accessibility/AtspiAccessibleApplication.h
libaurum/inc/Impl/Accessibility/AtspiAccessibleNode.h
libaurum/inc/Impl/Accessibility/AtspiAccessibleWatcher.h
libaurum/inc/Impl/Accessibility/AtspiAccessibleWindow.h
libaurum/inc/Impl/Accessibility/MockAccessibleApplication.h
libaurum/inc/Impl/Accessibility/MockAccessibleNode.h
libaurum/inc/Impl/Accessibility/MockAccessibleWatcher.h
libaurum/inc/Impl/Accessibility/MockAccessibleWindow.h
libaurum/inc/Impl/MockDeviceImpl.h
libaurum/inc/Impl/TizenDeviceImpl.h
libaurum/inc/PartialMatch.h
libaurum/inc/UiObject.h
libaurum/inc/UiSelector.h
libaurum/src/Accessibility/AccessibleNode.cc
libaurum/src/Accessibility/AccessibleWatcher.cc
libaurum/src/Accessibility/AccessibleWindow.cc
libaurum/src/Comparer.cc
libaurum/src/Impl/Accessibility/AtspiAccessibleNode.cc
libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc
libaurum/src/Impl/Accessibility/AtspiAccessibleWindow.cc
libaurum/src/Impl/Accessibility/MockAccessibleApplication.cc
libaurum/src/Impl/Accessibility/MockAccessibleNode.cc
libaurum/src/Impl/Accessibility/MockAccessibleWatcher.cc
libaurum/src/Impl/Accessibility/MockAccessibleWindow.cc
libaurum/src/Impl/MockDeviceImpl.cc
libaurum/src/PartialMatch.cc
libaurum/src/UiDevice.cc
libaurum/src/UiObject.cc
libaurum/src/UiSelector.cc
org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc
protocol/examples/python/testInternal.py
tests/ua_test.cpp

index d85c2f2..4e56478 100644 (file)
@@ -55,13 +55,6 @@ enum class NodeFeatureProperties {
     INVALID         = 0X2000,
 };
 
-class IAccessibleNode {
-public:
-    virtual ~IAccessibleNode() = 0;
-
-    
-};
-
 /**
  * @brief AccessibleNode Class
  * @since_tizen 5.5
@@ -122,7 +115,13 @@ public:
      * @brief TBD
      * @since_tizen 5.5
      */
-    std::string getRes() const;
+    std::string getId() const;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
+    std::string getAutomationId() const;
 
     /**
      * @brief TBD
@@ -307,7 +306,12 @@ protected:
     /**
      * @brief TBD
      */
-    std::string mRes;
+    std::string mId;
+
+    /**
+     * @brief TBD
+     */
+    std::string mAutomationId;
 
     /**
      * @brief TBD
@@ -333,5 +337,4 @@ protected:
      * @brief TBD
      */
     int mFeatureProperty;
-
 };
\ No newline at end of file
index 44e87c6..9720557 100644 (file)
@@ -9,18 +9,57 @@ class AccessibleApplication;
 
 class AccessibleWindow {
 public:
+    /**
+     * @brief TBD
+     * @since_tizen 6.0
+     */
     AccessibleWindow(std::shared_ptr<AccessibleApplication> app, std::shared_ptr<AccessibleNode> node);
+
+    /**
+     * @brief TBD
+     * @since_tizen 6.0
+     */
     virtual ~AccessibleWindow();
 
 public:
+    /**
+     * @brief TBD
+     * @since_tizen 6.0
+     */
     std::string getTitle(void);
+
+    /**
+     * @brief TBD
+     * @since_tizen 6.0
+     */
     bool isShowing();
+
+    /**
+     * @brief TBD
+     * @since_tizen 6.0
+     */
     bool isActive();
 
+    /**
+     * @brief TBD
+     * @since_tizen 6.0
+     */
     std::shared_ptr<AccessibleApplication> getApplication(void);
-    std::shared_ptr<AccessibleNode> getNode(void);
+
+    /**
+     * @brief TBD
+     * @since_tizen 6.0
+     */
+    std::shared_ptr<AccessibleNode> getAccessibleNode(void);
 
 private:
-    std::shared_ptr<AccessibleNode> mNode;
+     /**
+     * @brief TBD
+     */
     std::shared_ptr<AccessibleApplication> mApp;
+
+    /**
+     * @brief TBD
+     */
+    std::shared_ptr<AccessibleNode> mNode;
 };
\ No newline at end of file
index 99b37ea..f6fc9dd 100644 (file)
@@ -65,16 +65,6 @@ private:
 private:
     /**
      * @brief TBD
-     * @since_tizen 5.5
-     */
-   /* std::unique_ptr<PartialMatch> accept(const AccessibleNode *node,
-                                         const std::shared_ptr<UiSelector> selector,
-                                         const int &index, const int &depth,
-                                         const int &relDepth);
-*/
-private:
-    /**
-     * @brief TBD
      */
     const std::shared_ptr<UiDevice> mDevice;
 
index 78208af..1ee5592 100644 (file)
@@ -6,12 +6,28 @@
 
 class AtspiAccessibleApplication : public AccessibleApplication, public std::enable_shared_from_this<AtspiAccessibleApplication> {
 public:
+    /**
+     * @brief TBD
+     * @since_tizen 6.0
+     */
     AtspiAccessibleApplication(std::shared_ptr<AccessibleNode> node);
+
+    /**
+     * @brief TBD
+     * @since_tizen 6.0
+     */
     virtual ~AtspiAccessibleApplication();
 
 public:
+    /**
+     * @brief TBD
+     * @since_tizen 6.0
+     */
     std::vector<std::shared_ptr<AccessibleWindow>> getWindows(void) override;
-    //std::vector<std::shared_ptr<AccessibleWindow>> getActiveWindows(void) override;
-    std::string getPackageName(void) override;
 
+    /**
+     * @brief TBD
+     * @since_tizen 6.0
+     */
+    std::string getPackageName(void) override;
 };
\ No newline at end of file
index 3121f8c..85fe9be 100644 (file)
@@ -85,11 +85,5 @@ private:
      * @brief TBD
      * @since_tizen 5.5
      */
-    //static std::map<AtspiAccessible *, AccessibleNode *> mNodeMap;
-
-    /**
-     * @brief TBD
-     * @since_tizen 5.5
-     */
     AtspiAccessible* mNode;
 };
\ No newline at end of file
index 93ded42..79bdc65 100644 (file)
@@ -98,19 +98,6 @@ public:
      */
     virtual std::vector<std::shared_ptr<AccessibleApplication>> getApplications(void) const override;
 
-    /**
-     * @brief TBD
-     * @since_tizen 5.5
-     */
-    //std::shared_ptr<AccessibleNode> getRootNode() const override;
-
-    /**
-     * @brief TBD
-     * @since_tizen 5.5
-     */
-    //std::vector<std::shared_ptr<AccessibleNode>> getTopNode() const override;
-
-
 public:
     /**
      * @brief TBD
@@ -212,6 +199,9 @@ private:
      */
     std::set<AtspiAccessible *>            mWindowSet;
 
+    /**
+     * @brief TBD
+     */
     std::map<AtspiAccessible *, AtspiAccessible *> mWindowAppMap;
 
 };
\ No newline at end of file
index 6883bf6..95631e7 100644 (file)
@@ -3,7 +3,16 @@
 
 class AtspiAccessibleWindow : public AccessibleWindow {
 public:
+    /**
+     * @brief TBD
+     * @since_tizen 6.0
+     */
     AtspiAccessibleWindow(std::shared_ptr<AccessibleApplication> app, std::shared_ptr<AccessibleNode> node);
+
+    /**
+     * @brief TBD
+     * @since_tizen 6.0
+     */
     ~AtspiAccessibleWindow();
 
 };
\ No newline at end of file
index dc4359e..76a3caa 100644 (file)
@@ -1,23 +1,65 @@
 #pragma once
 #include "AccessibleApplication.h"
+#include "MockAccessibleWindow.h"
+#include "MockAccessibleNode.h"
 
 #include <memory>
 
 class MockAccessibleApplication : public AccessibleApplication, public std::enable_shared_from_this<MockAccessibleApplication> {
 public:
+    /**
+     * @brief TBD
+     * @since tizen_6.0
+     */
     MockAccessibleApplication(std::shared_ptr<AccessibleNode> node);
+
+    /**
+     * @brief TBD
+     * @since tizen_6.0
+     */
+    MockAccessibleApplication(std::shared_ptr<AccessibleNode> parent, std::string text,std::string pkg,std::string role, std::string res,std::string type,std::string style,Rect<int> boundingBox,int supportingIfaces,int featureProperty);
+
+    /**
+     * @brief TBD
+     * @since tizen_6.0
+     */
     virtual ~MockAccessibleApplication();
 
 public:
+    /**
+     * @brief TBD
+     * @since tizen_6.0
+     */
     std::vector<std::shared_ptr<AccessibleWindow>> getWindows(void) override;
-    //std::vector<std::shared_ptr<AccessibleWindow>> getActiveWindows(void) override;
+
+    /**
+     * @brief TBD
+     * @since tizen_6.0
+     */
     std::string getPackageName(void) override;
 
 public:
+    /**
+     * @brief TBD
+     * @since tizen_6.0
+     */
     void addWindow(std::shared_ptr<AccessibleWindow> window);
+
+    /**
+     * @brief TBD
+     * @since tizen_6.0
+     */
+    std::shared_ptr<MockAccessibleWindow> addWindow(std::string title, std::string widget, Rect<int> geometry, int properties);
+
+    /**
+     * @brief TBD
+     * @since tizen_6.0
+     */
     void clearWindows(void);
 
 private:
+    /**
+     * @brief TBD
+     */
     std::vector<std::shared_ptr<AccessibleWindow>> mWindowList;
-
 };
\ No newline at end of file
index 98bbb44..80e8ad3 100644 (file)
@@ -1,15 +1,16 @@
 #pragma once
 #include "AccessibleNode.h"
 
+#include <mutex>
 #include <set>
 
-class MockAccessibleNode : public AccessibleNode {
+class MockAccessibleNode : public AccessibleNode, public std::enable_shared_from_this<MockAccessibleNode> {
 public:
     /**
      * @brief TBD
      * @since_tizen 5.5
      */
-    MockAccessibleNode(std::shared_ptr<AccessibleNode> parent, std::string text,std::string pkg,std::string role, std::string res,std::string type,std::string style,Rect<int> boundingBox,int supportingIfaces,int featureProperty);
+    MockAccessibleNode(std::shared_ptr<MockAccessibleNode> parent, std::string text,std::string pkg,std::string role, std::string id, std::string type,std::string style, std::string automationId, Rect<int> boundingBox,int supportingIfaces,int featureProperty);
 
     /**
      * @brief TBD
@@ -87,17 +88,55 @@ public:
      * @since_tizen 5.5
      */
     void addChild(std::shared_ptr<AccessibleNode> child);
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
+    std::shared_ptr<MockAccessibleNode> addChild(std::string text, std::string pkg, std::string role, std::string res, std::string type, std::string style,std::string automationId,  Rect<int> geometry, int ifaces, int properties);
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     void clearChildren(void);
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     void addAction(std::string action);
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     void clearActions(void);
-    void setProperties(std::string text,std::string pkg, std::string role, std::string res, std::string type, std::string style, Rect<int> boundingBox, int supportingIfaces, int featureProperty);
 
-private:
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
+    void setProperties(std::string text,std::string pkg, std::string role, std::string res, std::string type, std::string style,std::string automationId,  Rect<int> boundingBox, int supportingIfaces, int featureProperty);
 
+private:
+    /**
+     * @brief TBD
+     */
     std::shared_ptr<AccessibleNode> mParentNode;
-    std::vector<std::shared_ptr<AccessibleNode>> mChildrenList;
-    std::set<std::string> mActionSet;
 
-};
+    /**
+     * @brief TBD
+     */
+    std::vector<std::shared_ptr<AccessibleNode>> mChildrenList;
 
+    /**
+     * @brief TBD
+     */
+    std::set<std::string> mActionSet;
 
+    /**
+     * @brief TBD
+     */
+    std::mutex                            mLock;
+};
\ No newline at end of file
index e3476d2..2d523d3 100644 (file)
@@ -2,18 +2,25 @@
 #include "AccessibleNode.h"
 #include "AccessibleWatcher.h"
 
+#include "MockAccessibleApplication.h"
+
 #include <mutex>
 #include <shared_mutex>
 #include <memory>
-#include <list>
 #include <vector>
-#include <set>
-#include <map>
-
 
 class MockAccessibleWatcher : public AccessibleWatcher {
 public:
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     MockAccessibleWatcher();
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     virtual ~MockAccessibleWatcher();
 
 public:
@@ -29,7 +36,6 @@ public:
      */
     virtual std::shared_ptr<AccessibleApplication> getApplicationAt(int index) const override;
 
-
     /**
      * @brief TBD
      * @since_tizen 5.5
@@ -37,14 +43,26 @@ public:
     virtual std::vector<std::shared_ptr<AccessibleApplication>> getApplications(void) const override;
 
 public:
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     void addApplication(std::shared_ptr<AccessibleApplication> application);
 
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
+    std::shared_ptr<MockAccessibleApplication> addApplication(std::string pkgName, Rect<int> geometry, int ifaces, int properties);
+
 private:
+    /**
+     * @brief TBD
+     */
     std::vector<std::shared_ptr<AccessibleApplication>> mApplicationList;
 
     /**
      * @brief TBD
      */
     std::mutex                            mLock;
-
 };
\ No newline at end of file
index e7ec0b5..a0264e9 100644 (file)
@@ -1,8 +1,33 @@
 #pragma once
 #include "AccessibleWindow.h"
+#include "MockAccessibleNode.h"
+
+class MockAccessibleApplication;
 
 class MockAccessibleWindow : public AccessibleWindow {
 public:
-    MockAccessibleWindow(std::shared_ptr<AccessibleApplication> app, std::shared_ptr<AccessibleNode> node);
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
+    MockAccessibleWindow(std::shared_ptr<MockAccessibleApplication> app, std::shared_ptr<MockAccessibleNode> node);
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     ~MockAccessibleWindow();
+
+public:
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
+    std::shared_ptr<MockAccessibleNode> addNode(std::string text, std::string pkg, std::string role, std::string res, std::string type, std::string style, std::string automationId, Rect<int> geometry, int ifaces, int properties);
+
+private:
+    /**
+     * @brief TBD
+     */
+    std::shared_ptr<MockAccessibleNode> mMockNode;
 };
\ No newline at end of file
index dd35e6f..43ad464 100644 (file)
 #include "IDevice.h"
 
 #include <set>
+#include <list>
+#include <tuple>
+#include <vector>
+#include <map>
 
+enum class MockKeyType {
+    BACK,
+    HOME,
+    MENU,
+    VOLUP,
+    VOLDOWN,
+    POWER,
+    KEY
+};
+
+struct TouchData { int x; int y; long long stamp1; long long stamp2;};
 class MockDeviceImpl : public IDevice {
 public:
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     MockDeviceImpl();
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     ~MockDeviceImpl();
 
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool click(const int x, const int y) override;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool click(const int x, const int y, const unsigned int intv) override;
 
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool drag(const int sx, const int sy, const int ex, const int ey,
               const int steps, const int durationMs) override;
 
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     int touchDown(const int x, const int y) override;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool touchMove(const int x, const int y, const int seq) override;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool touchUp(const int x, const int y, const int seq) override;
 
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool wheelUp(int amount, const int durationMs) override;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool wheelDown(int amount, const int durationMs) override;
 
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool pressBack(KeyRequestType type) override;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool pressHome(KeyRequestType type) override;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool pressMenu(KeyRequestType type) override;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool pressVolUp(KeyRequestType type) override;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool pressVolDown(KeyRequestType type) override;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool pressPower(KeyRequestType type) override;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool pressKeyCode(std::string keycode, KeyRequestType type) override;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool takeScreenshot(std::string path, float scale, int quality) override;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     long long getSystemTime(TimeRequestType type) override;
 
 protected:
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool strokeKeyCode(std::string keycode, unsigned int intv);
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool pressKeyCode(std::string keycode);
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool releaseKeyCode(std::string keycode);
 
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     int grabTouchSeqNumber();
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool releaseTouchSeqNumber(int seq);
 
 private:
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     void startTimer(void);
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     int stopTimer(void);
 
-private:
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
+    long long timeStamp(void);
+
+public:
+    /**
+     * @brief TBD
+     */
     static const unsigned int INTV_CLICK = 5;
+
+    /**
+     * @brief TBD
+     */
     static const unsigned int INTV_SHORTSTROKE = 100;
+
+    /**
+     * @brief TBD
+     */
     static const unsigned int INTV_LONGSTROKE = 2000;
 
+    /**
+     * @brief TBD
+     */
     static const unsigned int INTV_MINIMUM_DRAG_MS = 25;
+
+    /**
+     * @brief TBD
+     */
     static const unsigned int INTV_MINIMUM_USLEEP = 1000;
+
+    /**
+     * @brief TBD
+     */
     static const unsigned int MINIMUM_DURATION_DRAG = 100;
+
+    /**
+     * @brief TBD
+     */
     static const unsigned int MSEC_PER_SEC = 1000;
+
+    /**
+     * @brief TBD
+     */
     static const unsigned int MAX_FINGER_NUMBER = 2;
 
+    /**
+     * @brief TBD
+     */
     struct timespec tStart;
+
+    /**
+     * @brief TBD
+     */
     bool isTimerStarted;
 
+    /**
+     * @brief TBD
+     */
     std::set<int> mTouchSeq;
+
+public:
+    /**
+     * @brief TBD
+     */
+    std::map<int, TouchData> mTouchRelease;
+
+    /**
+     * @brief TBD
+     */
+    std::map<int, TouchData> mTouchDown;
+
+    /**
+     * @brief TBD
+     */
+    std::vector<std::tuple<MockKeyType, KeyRequestType, std::string>> mKeyDevice;
+
+    /**
+     * @brief TBD
+     */
+    int mWheelDevice;
 };
\ No newline at end of file
index 6e4dca4..cf5b5cb 100644 (file)
  */
 class TizenDeviceImpl : public IDevice {
 public:
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     TizenDeviceImpl();
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     ~TizenDeviceImpl();
 
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool click(const int x, const int y) override;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool click(const int x, const int y, const unsigned int intv) override;
 
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool drag(const int sx, const int sy, const int ex, const int ey,
               const int steps, const int durationMs) override;
 
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     int touchDown(const int x, const int y) override;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool touchMove(const int x, const int y, const int seq) override;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool touchUp(const int x, const int y, const int seq) override;
 
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool wheelUp(int amount, const int durationMs) override;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool wheelDown(int amount, const int durationMs) override;
 
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool pressBack(KeyRequestType type) override;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool pressHome(KeyRequestType type) override;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool pressMenu(KeyRequestType type) override;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool pressVolUp(KeyRequestType type) override;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool pressVolDown(KeyRequestType type) override;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool pressPower(KeyRequestType type) override;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool pressKeyCode(std::string keycode, KeyRequestType type) override;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool takeScreenshot(std::string path, float scale, int quality) override;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     long long getSystemTime(TimeRequestType type) override;
 
 protected:
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool strokeKeyCode(std::string keycode, unsigned int intv);
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool pressKeyCode(std::string keycode);
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool releaseKeyCode(std::string keycode);
 
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     int grabTouchSeqNumber();
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     bool releaseTouchSeqNumber(int seq);
 
 private:
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     void startTimer(void);
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     int stopTimer(void);
 
 private:
+    /**
+     * @brief TBD
+     */
     efl_util_inputgen_h mFakeTouchHandle;
+
+    /**
+     * @brief TBD
+     */
     efl_util_inputgen_h mFakeKeyboardHandle;
+
+    /**
+     * @brief TBD
+     */
     efl_util_inputgen_h mFakeWheelHandle;
+
+    /**
+     * @brief TBD
+     */
     static const unsigned int INTV_CLICK = 5;
+
+    /**
+     * @brief TBD
+     */
     static const unsigned int INTV_SHORTSTROKE = 100;
+
+    /**
+     * @brief TBD
+     */
     static const unsigned int INTV_LONGSTROKE = 2000;
 
+    /**
+     * @brief TBD
+     */
     static const unsigned int INTV_MINIMUM_DRAG_MS = 25;
+
+    /**
+     * @brief TBD
+     */
     static const unsigned int INTV_MINIMUM_USLEEP = 1000;
+
+    /**
+     * @brief TBD
+     */
     static const unsigned int MINIMUM_DURATION_DRAG = 100;
+
+    /**
+     * @brief TBD
+     */
     static const unsigned int MSEC_PER_SEC = 1000;
+
+    /**
+     * @brief TBD
+     */
     static const unsigned int MAX_FINGER_NUMBER = 2;
 
+    /**
+     * @brief TBD
+     */
     struct timespec tStart;
+
+    /**
+     * @brief TBD
+     */
     bool isTimerStarted;
 
+    /**
+     * @brief TBD
+     */
     std::set<int> mTouchSeq;
 };
\ No newline at end of file
index a4085c8..7248d58 100644 (file)
@@ -78,6 +78,12 @@ private:
      * @brief TBD
      * @since_tizen 5.5
      */
+    static bool checkCriteria(const std::string *textA, const std::string textB, const bool *match);
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     static bool checkCriteria(const bool *boolA, const bool boolB);
 
 private:
index 538810e..6b9e0d0 100644 (file)
 #include <vector>
 
 class UiDevice;
+
+class Node : public std::enable_shared_from_this<Node> {
+public:
+    Node(std::shared_ptr<UiObject> node, std::vector<std::shared_ptr<Node>> children)
+    :mNode{node}, mChildren{children}{}
+
+    std::shared_ptr<UiObject> mNode;
+    std::vector<std::shared_ptr<Node>> mChildren;
+};
+
 /**
  * @brief UiObject class
  * @since_tizen 5.5
  */
-class UiObject : public ISearchable {
+class UiObject : public ISearchable , public std::enable_shared_from_this<UiObject> {
 public:
     /**
      * @brief TBD
@@ -119,13 +129,25 @@ public:
      * @brief TBD
      * @since_tizen 5.5
      */
+    std::shared_ptr<Node> getDescendant();
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     std::string getApplicationPackage() const;
 
     /**
      * @brief TBD
      * @since_tizen 5.5
      */
-    std::string getResourceName() const;
+    std::string getId() const;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
+    std::string getAutomationId() const;
 
     /**
      * @brief TBD
index c65caf0..489aeb6 100644 (file)
@@ -29,31 +29,43 @@ public:
      * @brief TBD
      * @since_tizen 5.5
      */
-    UiSelector *id(std::string text);
+    UiSelector *id(std::string text, bool match = true);
 
     /**
      * @brief TBD
      * @since_tizen 5.5
      */
-    UiSelector *text(std::string text);
+    UiSelector *automationid(std::string text, bool match = true);
 
     /**
      * @brief TBD
      * @since_tizen 5.5
      */
-    UiSelector *pkg(std::string text);
+    UiSelector *text(std::string text, bool match = true);
 
     /**
      * @brief TBD
      * @since_tizen 5.5
      */
-    UiSelector *type(std::string text);
+    UiSelector *pkg(std::string text, bool match = true);
 
     /**
      * @brief TBD
      * @since_tizen 5.5
      */
-    UiSelector *style(std::string text);
+    UiSelector *role(std::string text, bool match = true);
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
+    UiSelector *type(std::string text, bool match = true);
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
+    UiSelector *style(std::string text, bool match = true);
 
     /**
      * @brief TBD
@@ -143,13 +155,13 @@ public:
      * @brief TBD
      * @since_tizen 5.5
      */
-    UiSelector *res(std::string text);
+    UiSelector *isVisible(bool cond);
 
     /**
      * @brief TBD
      * @since_tizen 5.5
      */
-    UiSelector *desc(std::string text);
+    UiSelector *isSelectable(bool cond);
 
     /**
      * @brief TBD
@@ -157,6 +169,12 @@ public:
      */
     UiSelector *hasChild(std::shared_ptr<UiSelector> child);
 
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
+    UiSelector *fromParent(std::shared_ptr<UiSelector> parent);
+
 public:
     /**
      * @brief TBD
@@ -168,6 +186,18 @@ public:
      * @brief TBD
      * @since_tizen 5.5
      */
+    std::unique_ptr<std::string> mAutomationId;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
+    std::unique_ptr<std::string> mRole;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     std::unique_ptr<std::string> mText;
 
     /**
@@ -192,6 +222,48 @@ public:
      * @brief TBD
      * @since_tizen 5.5
      */
+    std::unique_ptr<bool> mMatchId;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
+    std::unique_ptr<bool> mMatchAutomationId;
+
+        /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
+    std::unique_ptr<bool> mMatchRole;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
+    std::unique_ptr<bool> mMatchText;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
+    std::unique_ptr<bool> mMatchPkg;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
+    std::unique_ptr<bool> mMatchType;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
+    std::unique_ptr<bool> mMatchStyle;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
     std::unique_ptr<int> mMinDepth;
 
     /**
@@ -264,11 +336,23 @@ public:
      * @brief TBD
      * @since_tizen 5.5
      */
-    std::unique_ptr<std::string> mRes;
+    std::unique_ptr<bool> mIsvisible;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
+    std::unique_ptr<bool> mIsselectable;
 
     /**
      * @brief TBD
      * @since_tizen 5.5
      */
     std::vector<std::shared_ptr<UiSelector>> mChild;
+
+    /**
+     * @brief TBD
+     * @since_tizen 5.5
+     */
+    std::shared_ptr<UiSelector> mParent;
 };
\ No newline at end of file
index 14de23f..0679aa3 100644 (file)
@@ -12,7 +12,7 @@ AccessibleNode::~AccessibleNode()
 }
 
 AccessibleNode::AccessibleNode()
-    : mText{""}, mPkg{""}, mRole{""}, mRes{""}, mType{""}, mStyle{""},
+    : mText{""}, mPkg{""}, mRole{""}, mId{""}, mType{""}, mStyle{""},
       mBoundingBox{0,0,0,0}, mSupportingIfaces(0), mFeatureProperty(0)
 {
 }
@@ -65,9 +65,14 @@ std::string AccessibleNode::getPkg() const
     return mPkg;
 }
 
-std::string AccessibleNode::getRes() const
+std::string AccessibleNode::getId() const
 {
-    return mRes;
+    return mId;
+}
+
+std::string AccessibleNode::getAutomationId() const
+{
+    return mAutomationId;
 }
 
 std::string AccessibleNode::getRole() const
index a689671..647d7e4 100644 (file)
@@ -36,7 +36,6 @@ void AccessibleWatcher::printDbgInformation() const
 
 const AccessibleWatcher *AccessibleWatcher::getInstance(AccessibleWatcher *watcherImpl)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
     static AccessibleWatcher *mInstance = nullptr;
     if (watcherImpl) {
         delete mInstance;
@@ -52,7 +51,6 @@ const AccessibleWatcher *AccessibleWatcher::getInstance(AccessibleWatcher *watch
 #endif
         }
     }
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
     return mInstance;
 }
 
index 8de9d5a..437f141 100644 (file)
@@ -30,7 +30,7 @@ std::shared_ptr<AccessibleApplication> AccessibleWindow::getApplication(void)
     return mApp;
 }
 
-std::shared_ptr<AccessibleNode> AccessibleWindow::getNode(void)
+std::shared_ptr<AccessibleNode> AccessibleWindow::getAccessibleNode(void)
 {
     return mNode;
 }
\ No newline at end of file
index ccf6138..f8abbd9 100644 (file)
@@ -14,8 +14,7 @@ std::shared_ptr<AccessibleNode> Comparer::findObject(const std::shared_ptr<UiDev
                                      const std::shared_ptr<UiSelector> selector,
                                      const std::shared_ptr<AccessibleNode> root)
 {
-    Comparer                      comparer(device, selector, true);
-    std::vector<std::shared_ptr<AccessibleNode>> ret = comparer.findObjects(root);
+    std::vector<std::shared_ptr<AccessibleNode>> ret = findObjects(device, selector, root);
     if (ret.size() > 0)
         return std::move(ret[0]);
     else
@@ -26,9 +25,20 @@ std::vector<std::shared_ptr<AccessibleNode>> Comparer::findObjects(const std::sh
                                                     const std::shared_ptr<UiSelector> selector,
                                                     const std::shared_ptr<AccessibleNode> root)
 {
-    Comparer                      comparer(device, selector, false);
-    std::vector<std::shared_ptr<AccessibleNode>> ret = comparer.findObjects(root);
-    return ret;
+    Comparer comparer(device, selector, false);
+
+    if (selector->mParent) {
+        auto ret = Comparer::findObjects(device, selector->mParent, root);
+        std::vector<std::shared_ptr<AccessibleNode>> merged{};
+
+        for (const auto &node : ret) {
+            auto tmp = comparer.findObjects(node);
+            std::move(std::begin(tmp), std::end(tmp), std::back_inserter(merged));
+        }
+        return merged;
+    }
+
+    return comparer.findObjects(root);
 }
 
 std::vector<std::shared_ptr<AccessibleNode>> Comparer::findObjects(const std::shared_ptr<AccessibleNode> root)
index a497533..00e530a 100644 (file)
@@ -117,11 +117,11 @@ void AtspiAccessibleNode::refresh()
 #ifdef TIZEN
     gchar *uID = atspi_accessible_get_unique_id(mNode, NULL);
     if (uID) {
-        mRes = uID;
+        mId = uID;
         g_free(uID);
     }
 #else
-    mRes = std::string{"N/A"};
+    mId = std::string{"N/A"};
 #endif
 
     gchar *name = atspi_accessible_get_name(mNode, NULL);
@@ -132,21 +132,23 @@ void AtspiAccessibleNode::refresh()
     GHashTable *attributes = atspi_accessible_get_attributes(mNode, NULL);
     char *t = (char*)g_hash_table_lookup(attributes, "type");
     char *s = (char*)g_hash_table_lookup(attributes, "style");
+    char *a = (char*)g_hash_table_lookup(attributes, "automationId");
 
     if (t) mType =  std::string(t);
     if (s) mStyle = std::string(s);
+    if (a) mAutomationId = std::string(a);
 
     free(t);
     free(s);
+    free(a);
 
     g_hash_table_unref(attributes);
 
     AtspiStateSet *st = atspi_accessible_get_state_set(mNode);
     GArray *states = atspi_state_set_get_states(st);
 
-    char *state_name = NULL;
     AtspiStateType stat;
-    for (int i = 0; states && (i < states->len); ++i) {
+    for (unsigned int i = 0; states && (i < states->len); ++i) {
         stat = g_array_index(states, AtspiStateType, i);
         setFeatureProperty(stat);
     }
@@ -171,7 +173,6 @@ void AtspiAccessibleNode::refresh()
 std::vector<std::string> AtspiAccessibleNode::getActions() const
 {
     std::vector<std::string> result{};
-    const char *name;
     AtspiAction *action;
 
     action = atspi_accessible_get_action_iface(mNode);
@@ -192,7 +193,6 @@ std::vector<std::string> AtspiAccessibleNode::getActions() const
 
 bool AtspiAccessibleNode::doAction(std::string actionName)
 {
-    const char *name;
     AtspiAction *action;
 
     action = atspi_accessible_get_action_iface(mNode);
@@ -305,6 +305,7 @@ void AtspiAccessibleNode::setFeatureProperty(AtspiStateType type)
         case ATSPI_STATE_HAS_POPUP:
         case ATSPI_STATE_READ_ONLY:
         case ATSPI_STATE_LAST_DEFINED:
+        default:
         break;
     }
 }
\ No newline at end of file
index f82ae7a..5205072 100644 (file)
@@ -18,17 +18,16 @@ static bool iShowingNode(AtspiAccessible *node)
 
     LOG_SCOPE_F(INFO, "isShowing %s", name);
     auto stateSet = atspi_accessible_get_state_set(node);
-    auto states = atspi_state_set_get_states(stateSet);
 
     if (atspi_state_set_contains(stateSet, ATSPI_STATE_ACTIVE)
         && atspi_state_set_contains(stateSet, ATSPI_STATE_SHOWING)) {
         LOG_F(INFO, "active and showing %p %s", node, name);
         free(name);
-        // TODO : free states and stateSet
+        g_object_unref(stateSet);
         return true;
     }
     free(name);
-    // TODO : free states and stateSet
+    g_object_unref(stateSet);
     return false;
 }
 
@@ -191,7 +190,6 @@ void AtspiAccessibleWatcher::print_debug()
         LOG_F(INFO, "child:%p", acc);
     });
     LOG_F(INFO, "------------------------------");
-
 }
 
 void AtspiAccessibleWatcher::onWindowActivated(AtspiAccessible *node,
@@ -275,6 +273,60 @@ std::vector<std::shared_ptr<AccessibleApplication>> AtspiAccessibleWatcher::getA
     return ret;
 }
 
+bool AtspiAccessibleWatcher::removeFromActivatedList(AtspiAccessible *node)
+{
+    LOG_SCOPE_F(INFO,"remove from activelist node %p", node);
+    mActivatedWindowList.remove_if([&](auto &n) { return n == node; });
+
+    AtspiAccessible *app = atspi_accessible_get_application(node, NULL);
+    LOG_F(INFO, "node:%p, app:%p", node, app);
+    if (app) {
+        mActivatedApplicationList.remove_if([&](auto &n) { return n == app; });
+        g_object_unref(app);
+    }
+    return true;
+}
+
+bool AtspiAccessibleWatcher::addToActivatedList(AtspiAccessible *node)
+{
+    LOG_SCOPE_F(INFO,"add to activelist node %p", node);
+    mActivatedWindowList.remove_if([&](auto &n) { return n == node; });
+    mActivatedWindowList.push_front(node);
+
+    auto iter = mWindowSet.find(node);
+    if ( iter == mWindowSet.end()) mWindowSet.insert(node);
+
+    AtspiAccessible *app = atspi_accessible_get_application(node, NULL);
+    LOG_F(INFO, "node:%p, app:%p", node, app);
+    if (app) {
+        mActivatedApplicationList.remove_if([&](auto &n) { if(n == app) { g_object_unref(app); return true;} else return false; });
+        mActivatedApplicationList.push_front(app);
+    }
+
+    return true;
+}
+
+bool AtspiAccessibleWatcher::removeFromWindowSet(AtspiAccessible *node)
+{
+    removeFromActivatedList(node);
+    auto iter = mWindowSet.find(node);
+    if ( iter != mWindowSet.end()){
+        mWindowSet.erase(node);
+        return true;
+    }
+    return false;
+}
+
+bool AtspiAccessibleWatcher::addToWindowSet(AtspiAccessible *node)
+{
+    auto iter = mWindowSet.find(node);
+    if ( iter == mWindowSet.end()){
+        mWindowSet.insert(node);
+        return true;
+    }
+    return false;
+}
+
 /*
 std::shared_ptr<AccessibleNode> AtspiAccessibleWatcher::getRootNode() const
 {
@@ -349,58 +401,4 @@ void AtspiAccessibleWatcher::clearWindowList()
 
     mWindowSet.clear();
 }
-*/
-
-bool AtspiAccessibleWatcher::removeFromActivatedList(AtspiAccessible *node)
-{
-    LOG_SCOPE_F(INFO,"remove from activelist node %p", node);
-    mActivatedWindowList.remove_if([&](auto &n) { return n == node; });
-
-    AtspiAccessible *app = atspi_accessible_get_application(node, NULL);
-    LOG_F(INFO, "node:%p, app:%p", node, app);
-    if (app) {
-        mActivatedApplicationList.remove_if([&](auto &n) { return n == app; });
-        g_object_unref(app);
-    }
-    return true;
-}
-
-bool AtspiAccessibleWatcher::addToActivatedList(AtspiAccessible *node)
-{
-    LOG_SCOPE_F(INFO,"add to activelist node %p", node);
-    mActivatedWindowList.remove_if([&](auto &n) { return n == node; });
-    mActivatedWindowList.push_front(node);
-
-    auto iter = mWindowSet.find(node);
-    if ( iter == mWindowSet.end()) mWindowSet.insert(node);
-
-    AtspiAccessible *app = atspi_accessible_get_application(node, NULL);
-    LOG_F(INFO, "node:%p, app:%p", node, app);
-    if (app) {
-        mActivatedApplicationList.remove_if([&](auto &n) { if(n == app) { g_object_unref(app); return true;} else return false; });
-        mActivatedApplicationList.push_front(app);
-    }
-
-    return true;
-}
-
-bool AtspiAccessibleWatcher::removeFromWindowSet(AtspiAccessible *node)
-{
-    removeFromActivatedList(node);
-    auto iter = mWindowSet.find(node);
-    if ( iter != mWindowSet.end()){
-        mWindowSet.erase(node);
-        return true;
-    }
-    return false;
-}
-
-bool AtspiAccessibleWatcher::addToWindowSet(AtspiAccessible *node)
-{
-    auto iter = mWindowSet.find(node);
-    if ( iter == mWindowSet.end()){
-        mWindowSet.insert(node);
-        return true;
-    }
-    return false;
-}
\ No newline at end of file
+*/
\ No newline at end of file
index d563df8..26ed203 100644 (file)
@@ -4,10 +4,8 @@
 AtspiAccessibleWindow::AtspiAccessibleWindow(std::shared_ptr<AccessibleApplication> app, std::shared_ptr<AccessibleNode> node)
 : AccessibleWindow(app, node)
 {
-
 }
 
 AtspiAccessibleWindow::~AtspiAccessibleWindow()
 {
-
 }
\ No newline at end of file
index a4326dc..e4f0f34 100644 (file)
@@ -9,57 +9,36 @@
 MockAccessibleApplication::MockAccessibleApplication(std::shared_ptr<AccessibleNode> node)
 : AccessibleApplication(node), mWindowList{}
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
 }
 
 MockAccessibleApplication::~MockAccessibleApplication()
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
 }
 
 std::vector<std::shared_ptr<AccessibleWindow>> MockAccessibleApplication::getWindows(void)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
     return mWindowList;
 }
-/*
-std::vector<std::shared_ptr<AccessibleWindow>> MockAccessibleApplication::getActiveWindows(void)
-{
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
-
-    std::vector<std::shared_ptr<AccessibleWindow>> ret{};
-
-    auto children = getWindows();
-
-    children.erase(std::remove_if(children.begin(), children.end(), [](auto child){
-                        return !(child->isActive()); // && child->isShowing() && child->isVisible());
-                    }), children.end());
-
-    LOG_SCOPE_F(INFO, "getActiveWindows app(%s) for %p, size:%d", getPackageName().c_str(), getAccessibleNode()->getRawHandler(), children.size());
-
-    // std::transform(children.begin(), children.end(), std::back_inserter(ret),
-    //     [&](std::shared_ptr<AccessibleNode> child) {
-    //         return std::make_shared<MockAccessibleWindow>(this->shared_from_this(), child);
-    //     }
-    // );
 
-    return ret;
-}
-*/
 std::string MockAccessibleApplication::getPackageName(void)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
     return "This.Is.Mock.Application";
 }
 
 void MockAccessibleApplication::addWindow(std::shared_ptr<AccessibleWindow> window)
 {
     mWindowList.push_back(window);
-    // auto node = getAccessibleNode();
-    // auto node2 = dynamic_cast<std::shared_ptr<MockAccessibleNode>>(node);
-    // node2->addChild(window->getNode());
 }
 void MockAccessibleApplication::clearWindows(void)
 {
     mWindowList.clear();
-}
\ No newline at end of file
+}
+
+std::shared_ptr<MockAccessibleWindow> MockAccessibleApplication::addWindow(std::string title, std::string widget, Rect<int> geometry, int properties)
+{
+    auto node = std::make_shared<MockAccessibleNode>(nullptr, title, title, "window", "res",widget,"style", "", geometry, 0, properties);
+    auto win = std::make_shared<MockAccessibleWindow>(shared_from_this(), node);
+    this->addWindow(win);
+    return win;
+}
+
index 0ce2788..4bf3980 100644 (file)
@@ -1,54 +1,49 @@
 #include "MockAccessibleNode.h"
 
 #include <algorithm>
+#include <iostream>
 
-MockAccessibleNode::MockAccessibleNode(std::shared_ptr<AccessibleNode> parent, std::string text, std::string pkg, std::string role, std::string res, std::string type, std::string style, Rect<int> boundingBox, int supportingIfaces,int featureProperty)
-: mParentNode(parent), mChildrenList{}, mActionSet{}
+MockAccessibleNode::MockAccessibleNode(std::shared_ptr<MockAccessibleNode> parent, std::string text, std::string pkg, std::string role, std::string res, std::string type, std::string style,std::string automationId,  Rect<int> boundingBox, int supportingIfaces,int featureProperty)
+: mParentNode(parent), mChildrenList{}, mActionSet{}, mLock{}
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
-    setProperties(text,pkg,role,res,type,style,boundingBox, supportingIfaces, featureProperty);
+    setProperties(text,pkg,role,res,type,style,automationId, boundingBox, supportingIfaces, featureProperty);
 }
 
 MockAccessibleNode::~MockAccessibleNode()
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
 }
 
 int MockAccessibleNode::getChildCount() const
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
     return mChildrenList.size();
 }
 
 std::shared_ptr<AccessibleNode> MockAccessibleNode::getChildAt(int index) const
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
     return mChildrenList.at(index);
 }
 std::vector<std::shared_ptr<AccessibleNode>> MockAccessibleNode::getChildren() const
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
     return mChildrenList;
 }
 
 std::shared_ptr<AccessibleNode> MockAccessibleNode::getParent() const
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
     return mParentNode;
 }
 
 void* MockAccessibleNode::getRawHandler(void) const
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
     return (void*)0;
 }
 
-void MockAccessibleNode::setProperties(std::string text,std::string pkg,std::string role,std::string res,std::string type,std::string style,Rect<int> boundingBox,int supportingIfaces,int featureProperty)
+void MockAccessibleNode::setProperties(std::string text,std::string pkg,std::string role,std::string id,std::string type,std::string style,std::string automationId, Rect<int> boundingBox,int supportingIfaces,int featureProperty)
 {
     mText = text;
     mPkg = pkg;
     mRole = role;
-    mRes = res;
+    mId = id;
+    mAutomationId = automationId;
     mType = type;
     mStyle = style;
     mBoundingBox = boundingBox;
@@ -58,12 +53,10 @@ void MockAccessibleNode::setProperties(std::string text,std::string pkg,std::str
 
 void MockAccessibleNode::refresh()
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
 }
 
 std::vector<std::string> MockAccessibleNode::getActions() const
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
     std::vector<std::string> ret{};
     std::transform(mActionSet.begin(), mActionSet.end(), std::back_inserter(ret), [](auto action){
         return action;
@@ -73,20 +66,17 @@ std::vector<std::string> MockAccessibleNode::getActions() const
 
 bool MockAccessibleNode::doAction(std::string action)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
     if (mActionSet.find(action) != mActionSet.end()) return true;
     return false;
 }
 
 void MockAccessibleNode::setValue(std::string text)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
     mText = text;
 }
 
 void MockAccessibleNode::setFeatureProperty(int type)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
     switch(type) {
         case 1:
             setFeatureProperty(NodeFeatureProperties::CHECKED, true);
@@ -133,6 +123,15 @@ void MockAccessibleNode::addChild(std::shared_ptr<AccessibleNode> child)
     mChildrenList.push_back(child);
 }
 
+std::shared_ptr<MockAccessibleNode> MockAccessibleNode::addChild(std::string text, std::string pkg, std::string role, std::string res, std::string type, std::string style, std::string automationId, Rect<int> geometry, int ifaces, int properties)
+{
+    std::unique_lock<std::mutex> lock(mLock);
+
+    auto node = std::make_shared<MockAccessibleNode>(shared_from_this(), text, pkg, role, res, type, style, automationId, geometry, ifaces, properties);
+    this->addChild(node);
+    return node;
+}
+
 void MockAccessibleNode::clearChildren(void)
 {
     mChildrenList.clear();
index 6c4b9e0..68f7f54 100644 (file)
@@ -1,68 +1,40 @@
 #include "MockAccessibleWatcher.h"
 #include "MockAccessibleWindow.h"
+#include "MockAccessibleApplication.h"
 #include "MockAccessibleNode.h"
 
-#include <stdio.h>
-
 MockAccessibleWatcher::MockAccessibleWatcher()
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
-
-    /*
-        Root
-            Application
-                Window
-                    Node
-                        Node
-                            Node
-                            Node
-                            Node
-                            Node
-                        Node
-                            Node
-                            Node
-                        Node
-                    Node
-                    Node
-                Window
-                    Node
-                        Node
-            Application
-                Window
-            Application
-                Window
-            Application
-                Window
-            Application
-                Window
-    */
 }
 
 MockAccessibleWatcher::~MockAccessibleWatcher()
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
 }
 
 int MockAccessibleWatcher::getApplicationCount(void) const
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
-    return -1;
+    return mApplicationList.size();
 }
 
 std::shared_ptr<AccessibleApplication> MockAccessibleWatcher::getApplicationAt(int index) const
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
     return mApplicationList.at(index);
 }
 
 std::vector<std::shared_ptr<AccessibleApplication>> MockAccessibleWatcher::getApplications(void) const
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
     return mApplicationList;
 }
 
 void MockAccessibleWatcher::addApplication(std::shared_ptr<AccessibleApplication> application)
 {
     mApplicationList.push_back(application);
-    
+}
+
+std::shared_ptr<MockAccessibleApplication> MockAccessibleWatcher::addApplication(std::string pkgName, Rect<int> geometry, int ifaces, int properties)
+{
+    std::shared_ptr<MockAccessibleNode> appNode = std::make_shared<MockAccessibleNode>(nullptr, pkgName, pkgName, "application", "", "Elm_Win", "default", "", geometry, ifaces, properties);
+    std::shared_ptr<MockAccessibleApplication> app = std::make_shared<MockAccessibleApplication>(appNode);
+    this->addApplication(app);
+    return app;
 }
\ No newline at end of file
index 23ea498..73ed9c2 100644 (file)
@@ -1,12 +1,19 @@
 #include "MockAccessibleWindow.h"
+#include "MockAccessibleApplication.h"
+#include "MockAccessibleNode.h"
 
-MockAccessibleWindow::MockAccessibleWindow(std::shared_ptr<AccessibleApplication> app, std::shared_ptr<AccessibleNode> node)
-: AccessibleWindow(app, node)
+MockAccessibleWindow::MockAccessibleWindow(std::shared_ptr<MockAccessibleApplication> app, std::shared_ptr<MockAccessibleNode> node)
+: AccessibleWindow(app, node), mMockNode{node}
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
 }
 
 MockAccessibleWindow::~MockAccessibleWindow()
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
+}
+
+std::shared_ptr<MockAccessibleNode> MockAccessibleWindow::addNode(std::string text, std::string pkg, std::string role, std::string res, std::string type, std::string style, std::string automationId, Rect<int> geometry, int ifaces, int properties)
+{
+    auto node = std::make_shared<MockAccessibleNode>(mMockNode, text, pkg, role, res, type, style, automationId, geometry, ifaces, properties);
+    mMockNode->addChild(node);
+    return node;
 }
\ No newline at end of file
index 3fdf45b..743e3b7 100644 (file)
@@ -2,6 +2,7 @@
 #include <loguru.hpp>
 
 #include <functional>
+#include <algorithm>
 #include <tuple>
 #include <iostream>
 #include <memory>
 #include <time.h>
 
 #include <stdio.h>
+#include <unistd.h>
+
+#include <chrono>
+#include <thread>
 
 MockDeviceImpl::MockDeviceImpl()
-:tStart{}, isTimerStarted{false}, mTouchSeq{}
+:tStart{}, isTimerStarted{false}, mTouchRelease{}, mTouchDown{}, mKeyDevice{}, mWheelDevice{0}
 {
-    printf("mockdevice ctor\n");printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
+    mTouchRelease.emplace(1, TouchData{0,0,0,0});
+    mTouchRelease.emplace(2, TouchData{0,0,0,0});
 }
 
 MockDeviceImpl::~MockDeviceImpl()
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
 }
 
 bool MockDeviceImpl::click(const int x, const int y)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
-    return false;
+    return click(x, y, INTV_CLICK);
 }
 
 bool MockDeviceImpl::click(const int x, const int y, const unsigned int intv)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
-    return false;
+    int seq = touchDown(x, y);
+    if (seq < 0) return false;
+    std::this_thread::sleep_for(std::chrono::milliseconds{intv});
+    return touchUp(x, y, seq);
 }
 
 bool MockDeviceImpl::drag(const int sx, const int sy, const int ex, const int ey,
             const int steps, const int durationMs)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
-    return false;
+    int i, j;
+    int _durationUs, _steps, _stepUs;
+    int dur;
+    int consumptionUs;
+
+    if (steps <= 0) _steps = 1;
+    else _steps = steps;
+
+    if (durationMs < MINIMUM_DURATION_DRAG) _durationUs = INTV_MINIMUM_DRAG_MS * MSEC_PER_SEC;
+    else _durationUs = durationMs * MSEC_PER_SEC;
+
+    _stepUs = _durationUs / (_steps +1);
+
+    if (_stepUs < (INTV_MINIMUM_DRAG_MS * MSEC_PER_SEC)) {
+        _steps = (int)(_durationUs / (INTV_MINIMUM_DRAG_MS * MSEC_PER_SEC)) - 1;
+        _stepUs  = (INTV_MINIMUM_DRAG_MS * MSEC_PER_SEC);
+    }
+    startTimer();
+    int seq = touchDown(sx, sy);
+    if (seq < 0) return false;
+    consumptionUs = stopTimer();
+
+    for ( int s = 1; s <= _steps + 1; s++) {
+        usleep((_stepUs - consumptionUs)>INTV_MINIMUM_USLEEP?(_stepUs - consumptionUs):INTV_MINIMUM_USLEEP);
+        startTimer();
+        touchMove(sx + (ex - sx) * s / (steps + 1), sy + (ey - sy) * s / (steps + 1), seq);
+        consumptionUs = stopTimer();
+    }
+    usleep((_stepUs - consumptionUs)>INTV_MINIMUM_USLEEP?(_stepUs - consumptionUs):INTV_MINIMUM_USLEEP);
+    touchMove(ex, ey, seq);
+    touchUp(ex, ey, seq);
+
+    return true;
 }
 
 int MockDeviceImpl::touchDown(const int x, const int y)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
-    return -1;
+    if (mTouchRelease.size() <= 0) return -1;
+    int seq = mTouchRelease.begin()->first;
+    mTouchDown[seq] = TouchData{x, y, timeStamp(), -1};
+    mTouchRelease.erase(seq);
+    return seq;
 }
 
 bool MockDeviceImpl::touchMove(const int x, const int y, const int seq)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
-    return false;
+    if (mTouchDown.count(seq) <= 0) return false;
+    mTouchDown[seq] = TouchData{x, y, mTouchDown[seq].stamp1, timeStamp()};
+    return true;
 }
 
 bool MockDeviceImpl::touchUp(const int x, const int y, const int seq)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
-    return false;
-
+    if (mTouchDown.count(seq) <= 0) return false;
+    mTouchRelease[seq] = TouchData{x, y, mTouchDown[seq].stamp1, timeStamp()};
+    mTouchDown.erase(seq);
+    return true;
 }
 
 bool MockDeviceImpl::wheelUp(int amount, const int durationMs)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
-    return false;
+    for (int i = 0; i < amount; i++){
+        mWheelDevice++;
+        usleep(durationMs*MSEC_PER_SEC/amount);
+    }
 
+    return true;
 }
 
 bool MockDeviceImpl::wheelDown(int amount, const int durationMs)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
-    return false;
+    for (int i = 0; i < amount; i++){
+        mWheelDevice--;
+        usleep(durationMs*MSEC_PER_SEC/(double)amount);
+    }
+
+    return true;
 
 }
 
 bool MockDeviceImpl::pressBack(KeyRequestType type)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
-    return false;
+    mKeyDevice.push_back(std::tuple<MockKeyType, KeyRequestType, std::string>(MockKeyType::BACK, type, ""));
+    return true;
 
 }
 
 bool MockDeviceImpl::pressHome(KeyRequestType type)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
-    return false;
+    mKeyDevice.push_back(std::tuple<MockKeyType, KeyRequestType, std::string>(MockKeyType::HOME, type, ""));
+    return true;
 
 }
 
 bool MockDeviceImpl::pressMenu(KeyRequestType type)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
-    return false;
-
+    mKeyDevice.push_back(std::tuple<MockKeyType, KeyRequestType, std::string>(MockKeyType::MENU, type, ""));
+    return true;
 }
 
 bool MockDeviceImpl::pressVolUp(KeyRequestType type)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
-    return false;
-
+    mKeyDevice.push_back(std::tuple<MockKeyType, KeyRequestType, std::string>(MockKeyType::VOLUP, type, ""));
+    return true;
 }
 
 bool MockDeviceImpl::pressVolDown(KeyRequestType type)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
-    return false;
-
+    mKeyDevice.push_back(std::tuple<MockKeyType, KeyRequestType, std::string>(MockKeyType::VOLDOWN, type, ""));
+    return true;
 }
 
 bool MockDeviceImpl::pressPower(KeyRequestType type)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
-    return false;
-
+    mKeyDevice.push_back(std::tuple<MockKeyType, KeyRequestType, std::string>(MockKeyType::POWER, type, ""));
+    return true;
 }
 
 bool MockDeviceImpl::pressKeyCode(std::string keycode, KeyRequestType type)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
-    return false;
-
+    mKeyDevice.push_back(std::tuple<MockKeyType, KeyRequestType, std::string>(MockKeyType::KEY, type, keycode));
+    return true;
 }
 
 bool MockDeviceImpl::takeScreenshot(std::string path, float scale, int quality)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
-    return false;
-
+    return true;
 }
 
 long long MockDeviceImpl::getSystemTime(TimeRequestType type)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
-    return -1;
+    struct timespec t;
+
+    if (type == TimeRequestType::MONOTONIC) {
+        clock_gettime(CLOCK_MONOTONIC, &t);
+    } else if (type == TimeRequestType::WALLCLOCK) {
+        clock_gettime(CLOCK_REALTIME, &t);
+    }
+
+    return (long long)t.tv_sec * 1000L + (long long)(t.tv_nsec / 1000000);
 }
 
 bool MockDeviceImpl::strokeKeyCode(std::string keycode, unsigned int intv)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
     return false;
-
 }
 
 bool MockDeviceImpl::pressKeyCode(std::string keycode)
 {
-
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
     return false;
-
 }
 
 bool MockDeviceImpl::releaseKeyCode(std::string keycode)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
     return false;
-
 }
 
 int MockDeviceImpl::grabTouchSeqNumber()
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
     return 0;
 }
 
 bool MockDeviceImpl::releaseTouchSeqNumber(int seq)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
     return false;
-
 }
 
 void MockDeviceImpl::startTimer(void)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
+    isTimerStarted = true;
+    clock_gettime(CLOCK_MONOTONIC, &tStart);
 }
 
 int MockDeviceImpl::stopTimer(void)
 {
-    printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
-    return 0;
+    struct timespec tEnd;
+    if (!isTimerStarted) return 0;
+    isTimerStarted = false;
+    clock_gettime(CLOCK_MONOTONIC, &tEnd);
+    return ((tEnd.tv_sec + tEnd.tv_nsec/1000000000.0) - (tStart.tv_sec + tStart.tv_nsec/1000000000.0)) * 1000000;
+}
+
+long long MockDeviceImpl::timeStamp(void)
+{
+    struct timespec t;
+    clock_gettime(CLOCK_MONOTONIC, &t);
+    long long rtn = (t.tv_sec + t.tv_nsec/1000000000.0) * 1000000;
+    return rtn;
 }
\ No newline at end of file
index 5edc6f2..942bc62 100644 (file)
@@ -6,11 +6,20 @@
 
 #include <loguru.hpp>
 
-bool PartialMatch::checkCriteria(const std::string *textA, const std::string textB)
+bool PartialMatch::checkCriteria(const std::string *textA, const std::string textB, const bool *match)
 {
-    if (!textA) return false;
+    if (!textA || !match) return false;
     std::regex re(*textA);
-    return !std::regex_match(textB, re);
+    bool rst = !(!!std::regex_match(textB, re) == (*match));
+
+    LOG_F(INFO, "WKWK# %d %s %s=> %d\n", *match, textA->c_str(), textB.c_str(), rst);
+    return rst;
+}
+
+bool PartialMatch::checkCriteria(const std::string *textA, const std::string textB)
+{
+    bool match = true;
+    return checkCriteria(textA, textB, &match);
 }
 
 bool PartialMatch::checkCriteria(const bool *boolA, const bool boolB)
@@ -23,26 +32,26 @@ void PartialMatch::debugPrint()
 {
     if (mSelector->mPkg)
         LOG_F(INFO, "selector->pkg :%s", mSelector->mPkg->c_str());
-    if (mSelector->mRes)
-        LOG_F(INFO, "selector->pkg :%s", mSelector->mRes->c_str());
+    if (mSelector->mId)
+        LOG_F(INFO, "selector->id :%s", mSelector->mId->c_str());
     if (mSelector->mText)
-        LOG_F(INFO, "selector->pkg :%s", mSelector->mText->c_str());
+        LOG_F(INFO, "selector->text :%s", mSelector->mText->c_str());
     if (mSelector->mType)
-        LOG_F(INFO, "selector->pkg :%s", mSelector->mType->c_str());
+        LOG_F(INFO, "selector->type :%s", mSelector->mType->c_str());
     if (mSelector->mStyle)
-        LOG_F(INFO, "selector->pkg :%s", mSelector->mStyle->c_str());
+        LOG_F(INFO, "selector->style :%s", mSelector->mStyle->c_str());
 }
 
 bool PartialMatch::checkCriteria(const std::shared_ptr<UiSelector> selector,
                                  const std::shared_ptr<AccessibleNode> node)
 {
-    if(checkCriteria(selector->mPkg.get(), node->getPkg())) return false;
-    if(checkCriteria(selector->mRes.get(), node->getRes())) return false;
-    if(checkCriteria(selector->mText.get(), node->getText())) return false;
-    if(checkCriteria(selector->mType.get(), node->getType())) return false;
-    if(checkCriteria(selector->mStyle.get(), node->getStyle())) return false;
-    if(checkCriteria(selector->mStyle.get(), node->getStyle())) return false;
-
+    if(checkCriteria(selector->mText.get(), node->getText(), selector->mMatchText.get())) return false;
+    if(checkCriteria(selector->mId.get(), node->getId(), selector->mMatchId.get())) return false;
+    if(checkCriteria(selector->mAutomationId.get(), node->getAutomationId(), selector->mMatchAutomationId.get())) return false;
+    if(checkCriteria(selector->mType.get(), node->getType(), selector->mMatchType.get())) return false;
+    if(checkCriteria(selector->mStyle.get(), node->getStyle(), selector->mMatchStyle.get())) return false;
+    if(checkCriteria(selector->mPkg.get(), node->getPkg(), selector->mMatchPkg.get())) return false;
+    if(checkCriteria(selector->mRole.get(), node->getRole(), selector->mMatchRole.get())) return false;
     if(checkCriteria(selector->mIschecked.get(), node->isChecked())) return false;
     if(checkCriteria(selector->mIscheckable.get(), node->isCheckable())) return false;
     if(checkCriteria(selector->mIsclickable.get(), node->isClickable())) return false;
@@ -53,6 +62,8 @@ bool PartialMatch::checkCriteria(const std::shared_ptr<UiSelector> selector,
     if(checkCriteria(selector->mIsselected.get(), node->isSelected())) return false;
     if(checkCriteria(selector->mIsshowing.get(), node->isShowing())) return false;
     if(checkCriteria(selector->mIsactive.get(), node->isActive())) return false;
+    if(checkCriteria(selector->mIsvisible.get(), node->isVisible())) return false;
+    if(checkCriteria(selector->mIsselectable.get(), node->isSelectable())) return false;
 
     return true;
 }
index f694f28..05d8f04 100644 (file)
@@ -15,6 +15,7 @@
 #include <algorithm>
 #include <iostream>
 
+#include <loguru.hpp>
 UiDevice::UiDevice() : UiDevice(nullptr) {}
 
 UiDevice::UiDevice(IDevice *impl)
@@ -57,7 +58,7 @@ std::vector<std::shared_ptr<AccessibleNode>> UiDevice::getWindowRoot() const
         auto activeWindows = app->getActiveWindows();
         std::transform(activeWindows.begin(), activeWindows.end(), std::back_inserter(ret),
             [&](std::shared_ptr<AccessibleWindow> window){
-                return window->getNode();
+                return window->getAccessibleNode();
             }
         );
     }
@@ -85,6 +86,7 @@ std::shared_ptr<UiObject> UiDevice::findObject(const std::shared_ptr<UiSelector>
         if (foundNode)
             return std::make_shared<UiObject>(getInstance(), selector, foundNode);
     }
+    LOG_F(INFO, "object not found");
     return std::shared_ptr<UiObject>{nullptr};
 }
 
index 6b5b987..4b52680 100644 (file)
@@ -135,14 +135,30 @@ std::vector<std::shared_ptr<UiObject>> UiObject::getChildren() const
     return this->findObjects(Sel::depth(1));
 }
 
+std::shared_ptr<Node> UiObject::getDescendant()
+{
+    std::vector<std::shared_ptr<Node>> nodeChildren{};
+
+    auto children = getChildren();
+    for (auto &&child : children) {
+        nodeChildren.push_back(child->getDescendant());
+    }
+    return std::make_shared<Node>(shared_from_this(), nodeChildren);
+}
+
 std::string UiObject::getApplicationPackage() const
 {
     return getAccessibleNode()->getPkg();
 }
 
-std::string UiObject::getResourceName() const
+std::string UiObject::getId() const
+{
+    return getAccessibleNode()->getId();
+}
+
+std::string UiObject::getAutomationId() const
 {
-    return getAccessibleNode()->getRes();
+    return getAccessibleNode()->getAutomationId();
 }
 
 std::string UiObject::getElementType() const
index 886c729..663c24d 100644 (file)
@@ -1,8 +1,16 @@
 #include "UiSelector.h"
 #include <string>
 
+
+
+
 UiSelector::UiSelector()
-    : mChild{}
+: mId{}, mAutomationId{}, mRole{}, mText{}, mPkg{}, mType{}, mStyle{},
+  mMatchId{}, mMatchAutomationId{}, mMatchRole{}, mMatchText{}, mMatchPkg{}, mMatchType{}, mMatchStyle{},
+  mMinDepth{}, mMaxDepth{}, mIschecked{}, mIscheckable{}, mIsclickable{},
+  mIsenabled{}, mIsfocused{}, mIsfocusable{}, mIsscrollable{}, mIsselected{},
+  mIsshowing{}, mIsactive{}, mIsvisible{}, mIsselectable{},
+  mChild{}, mParent{}
 {
 }
 /*
@@ -18,39 +26,53 @@ UiSelector& UiSelector::operator= (const UiSelector& src)
     return *this;
 }
 */
-UiSelector *UiSelector::id(std::string text)
+
+UiSelector *UiSelector::text(std::string text, bool match)
 {
-    this->mId = std::make_unique<std::string>(text);
+    this->mText = std::make_unique<std::string>(text);
+    this->mMatchText = std::make_unique<bool>(match);
     return this;
 }
 
-UiSelector *UiSelector::text(std::string text)
+UiSelector *UiSelector::pkg(std::string text, bool match)
 {
-    this->mText = std::make_unique<std::string>(text);
+    this->mPkg = std::make_unique<std::string>(text);
+    this->mMatchPkg = std::make_unique<bool>(match);
     return this;
 }
 
-UiSelector *UiSelector::pkg(std::string text)
+UiSelector *UiSelector::id(std::string text, bool match)
 {
-    this->mPkg = std::make_unique<std::string>(text);
+    this->mId = std::make_unique<std::string>(text);
+    this->mMatchId = std::make_unique<bool>(match);
     return this;
 }
 
-UiSelector *UiSelector::res(std::string text)
+UiSelector *UiSelector::automationid(std::string text, bool match)
 {
-    this->mRes = std::make_unique<std::string>(text);
+    this->mAutomationId = std::make_unique<std::string>(text);
+    this->mMatchAutomationId = std::make_unique<bool>(match);
     return this;
 }
 
-UiSelector *UiSelector::type(std::string text)
+UiSelector *UiSelector::role(std::string text, bool match)
+{
+    this->mRole = std::make_unique<std::string>(text);
+    this->mMatchRole = std::make_unique<bool>(match);
+    return this;
+}
+
+UiSelector *UiSelector::type(std::string text, bool match)
 {
     this->mType = std::make_unique<std::string>(text);
+    this->mMatchType = std::make_unique<bool>(match);
     return this;
 }
 
-UiSelector *UiSelector::style(std::string text)
+UiSelector *UiSelector::style(std::string text, bool match)
 {
     this->mStyle = std::make_unique<std::string>(text);
+    this->mMatchStyle = std::make_unique<bool>(match);
     return this;
 }
 
@@ -140,8 +162,26 @@ UiSelector *UiSelector::isActive(bool cond)
     return this;
 }
 
+UiSelector *UiSelector::isVisible(bool cond)
+{
+    this->mIsvisible = std::make_unique<bool>(cond);
+    return this;
+}
+
+UiSelector *UiSelector::isSelectable(bool cond)
+{
+    this->mIsselectable = std::make_unique<bool>(cond);
+    return this;
+}
+
 UiSelector *UiSelector::hasChild(std::shared_ptr<UiSelector> child)
 {
     mChild.push_back(child);
     return this;
 }
+
+UiSelector *UiSelector::fromParent(std::shared_ptr<UiSelector> parent)
+{
+    mParent = parent;
+    return this;
+}
\ No newline at end of file
index c7935e8..9056538 100644 (file)
@@ -69,7 +69,7 @@ std::vector<std::shared_ptr<UiSelector>> FindElementCommand::getSelectors(void)
             UiObject*   obj = found.get();
             std::string key = mObjMap->addElement(std::move(found));
             LOG_F(INFO, "found object : %s key:%s",
-                  obj->getResourceName().c_str(), key.c_str());
+                  obj->getAutomationId().c_str(), key.c_str());
             ::aurum::Element* elm = mResponse->add_elements();
             elm->set_elementid(key);
         }
index 3ad24c3..4d5548e 100644 (file)
@@ -26,7 +26,7 @@ global img
 
 def traverse(node, canvas, depth):
     print('traverse', depth)
-    print('size:',node.geometry)
+    print('size:',node.geometry, node)
 
     #//canvas.pack()
     rect = canvas.create_rectangle(node.geometry.x, node.geometry.y, node.geometry.x+node.geometry.width, node.geometry.y+node.geometry.height,  outline='red')
index ad422cf..7209d1b 100644 (file)
@@ -73,13 +73,13 @@ TEST_F(UaTest, FindElement)
     MockAccessibleWatcher *mockWatcher = dynamic_cast<MockAccessibleWatcher*>(const_cast<AccessibleWatcher*>(watcher));
     ASSERT_NE(mockWatcher, nullptr);
 
-    std::shared_ptr<MockAccessibleNode> appNode = std::make_shared<MockAccessibleNode>(nullptr, "text", "pkg", "application", "res","type","style", Rect<int>{0,0,100,200}, 0, 0);
+    std::shared_ptr<MockAccessibleNode> appNode = std::make_shared<MockAccessibleNode>(nullptr, "text", "pkg", "application", "res","type","style", "id1", Rect<int>{0,0,100,200}, 0, 0);
     ASSERT_NE(appNode, nullptr);
     std::shared_ptr<MockAccessibleApplication> app = std::make_shared<MockAccessibleApplication>(appNode);
     ASSERT_NE(app, nullptr);
     mockWatcher->addApplication(app);
 
-    std::shared_ptr<MockAccessibleNode> winNode = std::make_shared<MockAccessibleNode>(nullptr, "text", "pkg", "window", "res","type","style", Rect<int>{0,0,100,200}, 0, 0);
+    std::shared_ptr<MockAccessibleNode> winNode = std::make_shared<MockAccessibleNode>(nullptr, "text", "pkg", "window", "res","type","style", "id1",Rect<int>{0,0,100,200}, 0, 0);
     ASSERT_NE(winNode, nullptr);
 
     std::shared_ptr<MockAccessibleWindow> win = std::make_shared<MockAccessibleWindow>(app, winNode);
@@ -90,11 +90,11 @@ TEST_F(UaTest, FindElement)
     winNode->setFeatureProperty(10);
     app->addWindow(win);
 
-    std::shared_ptr<MockAccessibleNode> node = std::make_shared<MockAccessibleNode>(nullptr, "test", "pkg", "TeSt1234!@#$", "res","type","style", Rect<int>{0,0,100,200}, 0, 0);
+    std::shared_ptr<MockAccessibleNode> node = std::make_shared<MockAccessibleNode>(nullptr, "test", "pkg", "TeSt1234!@#$", "res","type","style", "id1",Rect<int>{0,0,100,200}, 0, 0);
     ASSERT_NE(node, nullptr);
     winNode->addChild(node);
 
-    node = std::make_shared<MockAccessibleNode>(nullptr, "test", "pkg", "TeSt1234!@#$", "res","type","style", Rect<int>{0,0,100,200}, 0, 0);
+    node = std::make_shared<MockAccessibleNode>(nullptr, "test", "pkg", "TeSt1234!@#$", "res","type","style", "id1",Rect<int>{0,0,100,200}, 0, 0);
     ASSERT_NE(node, nullptr);
     winNode->addChild(node);