Aurum  0.1.1
 All Classes Functions Variables Pages
UiDevice.h
1 #ifndef UIDEVICE_H
2 #define UIDEVICE_H
3 #include "config.h"
4 
5 #include "UiObject.h"
6 #include "UiSelector.h"
7 
8 #include "IDevice.h"
9 #include "ISearchable.h"
10 
11 #include "AccessibleNode.h"
12 #include "Waiter.h"
13 
14 #include <functional>
15 #include <string>
20 enum class DeviceType {
21  DEFAULT,
22  NUM_DEVICETYPE,
23 };
28 class UiDevice : public IDevice, public ISearchable {
29 public:
34  bool click(const int x, const int y) override;
35 
40  bool click(const int x, const int y, const unsigned int intv) override;
41 
46  bool drag(const int sx, const int sy, const int ex, const int ey,
47  const int steps, const int durationMs) override;
48 
53  int touchDown(const int x, const int y) override;
54 
59  bool touchMove(const int x, const int y, const int seq) override;
60 
65  bool touchUp(const int x, const int y, const int seq) override;
66 
71  bool wheelUp(int amount, const int durationMs) override;
72 
77  bool wheelDown(int amount, const int durationMs) override;
78 
83  bool pressBack(KeyRequestType type) override;
84 
89  bool pressHome(KeyRequestType type) override;
90 
95  bool pressMenu(KeyRequestType type) override;
96 
101  bool pressVolUp(KeyRequestType type) override;
102 
107  bool pressVolDown(KeyRequestType type) override;
108 
113  bool pressPower(KeyRequestType type) override;
114 
119  bool pressKeyCode(std::string keycode, KeyRequestType type) override;
120 
125  bool takeScreenshot(std::string path, float scale, int quality) override;
126 
131  long long getSystemTime(TimeRequestType type) override;
132 
133 public:
134 
139  bool hasObject(const std::shared_ptr<UiSelector> selector) const override;
140 
145  std::unique_ptr<UiObject> findObject(
146  const std::shared_ptr<UiSelector> selector) const override;
147 
152  std::vector<std::unique_ptr<UiObject>> findObjects(
153  const std::shared_ptr<UiSelector> selector) const override;
154 
159  bool waitFor(
160  const std::function<bool(const ISearchable *)> condition) const;
161 
166  std::unique_ptr<UiObject> waitFor(
167  const std::function<std::unique_ptr<UiObject>(const ISearchable *)>
168  condition) const;
169 
170 public:
175  static UiDevice *getInstance(DeviceType type);
176 
177 private:
182  std::vector<std::unique_ptr<AccessibleNode>> getWindowRoot() const;
183 
188  bool waitForIdle() const;
189 private:
194  UiDevice();
195 
200  UiDevice(DeviceType type, IDevice *impl);
201 
206  virtual ~UiDevice();
207 
208 private:
212  DeviceType mType;
216  IDevice * mDeviceImpl;
220  const Waiter *mWaiter;
221 };
222 
223 #endif