this patch refactors atspi related classes to mock atspi interface.
Change-Id: I2cfa273b29f4a8822ccb35364a9ce9977eeb9392
INVALID = 0X2000,
};
-class IAccessibleNode {
-public:
- virtual ~IAccessibleNode() = 0;
-
-
-};
-
/**
* @brief AccessibleNode Class
* @since_tizen 5.5
* @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
/**
* @brief TBD
*/
- std::string mRes;
+ std::string mId;
+
+ /**
+ * @brief TBD
+ */
+ std::string mAutomationId;
/**
* @brief TBD
* @brief TBD
*/
int mFeatureProperty;
-
};
\ No newline at end of file
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
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;
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
* @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
*/
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
*/
std::set<AtspiAccessible *> mWindowSet;
+ /**
+ * @brief TBD
+ */
std::map<AtspiAccessible *, AtspiAccessible *> mWindowAppMap;
};
\ No newline at end of file
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
#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
#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
* @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
#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:
*/
virtual std::shared_ptr<AccessibleApplication> getApplicationAt(int index) const override;
-
/**
* @brief TBD
* @since_tizen 5.5
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
#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
#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
*/
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
* @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:
#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
* @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
* @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
* @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
*/
UiSelector *hasChild(std::shared_ptr<UiSelector> child);
+ /**
+ * @brief TBD
+ * @since_tizen 5.5
+ */
+ UiSelector *fromParent(std::shared_ptr<UiSelector> parent);
+
public:
/**
* @brief TBD
* @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;
/**
* @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;
/**
* @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
}
AccessibleNode::AccessibleNode()
- : mText{""}, mPkg{""}, mRole{""}, mRes{""}, mType{""}, mStyle{""},
+ : mText{""}, mPkg{""}, mRole{""}, mId{""}, mType{""}, mStyle{""},
mBoundingBox{0,0,0,0}, mSupportingIfaces(0), mFeatureProperty(0)
{
}
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
const AccessibleWatcher *AccessibleWatcher::getInstance(AccessibleWatcher *watcherImpl)
{
- printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
static AccessibleWatcher *mInstance = nullptr;
if (watcherImpl) {
delete mInstance;
#endif
}
}
- printf("%s:%d / %s\n",__FILE__, __LINE__, __PRETTY_FUNCTION__);
return mInstance;
}
return mApp;
}
-std::shared_ptr<AccessibleNode> AccessibleWindow::getNode(void)
+std::shared_ptr<AccessibleNode> AccessibleWindow::getAccessibleNode(void)
{
return mNode;
}
\ No newline at end of file
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
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)
#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);
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);
}
std::vector<std::string> AtspiAccessibleNode::getActions() const
{
std::vector<std::string> result{};
- const char *name;
AtspiAction *action;
action = atspi_accessible_get_action_iface(mNode);
bool AtspiAccessibleNode::doAction(std::string actionName)
{
- const char *name;
AtspiAction *action;
action = atspi_accessible_get_action_iface(mNode);
case ATSPI_STATE_HAS_POPUP:
case ATSPI_STATE_READ_ONLY:
case ATSPI_STATE_LAST_DEFINED:
+ default:
break;
}
}
\ No newline at end of file
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;
}
LOG_F(INFO, "child:%p", acc);
});
LOG_F(INFO, "------------------------------");
-
}
void AtspiAccessibleWatcher::onWindowActivated(AtspiAccessible *node,
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
{
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
AtspiAccessibleWindow::AtspiAccessibleWindow(std::shared_ptr<AccessibleApplication> app, std::shared_ptr<AccessibleNode> node)
: AccessibleWindow(app, node)
{
-
}
AtspiAccessibleWindow::~AtspiAccessibleWindow()
{
-
}
\ No newline at end of file
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;
+}
+
#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;
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;
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);
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();
#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
#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
#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
#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)
{
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;
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;
}
#include <algorithm>
#include <iostream>
+#include <loguru.hpp>
UiDevice::UiDevice() : UiDevice(nullptr) {}
UiDevice::UiDevice(IDevice *impl)
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();
}
);
}
if (foundNode)
return std::make_shared<UiObject>(getInstance(), selector, foundNode);
}
+ LOG_F(INFO, "object not found");
return std::shared_ptr<UiObject>{nullptr};
}
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
#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{}
{
}
/*
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;
}
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
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);
}
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')
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);
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);