Skip to content

Commit 91faf10

Browse files
committed
feat: Add device touch gesture
1 parent dfcd2fb commit 91faf10

13 files changed

+544
-102
lines changed

README.md

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,35 @@ d.long_click(0.5, 0.4)
7171
d.swipe(0.5, 0.8, 0.5, 0.4, speed=2000)
7272
d.input_text(0.5, 0.5, "adbcdfg")
7373

74+
75+
# Device touch gersture
76+
d.gesture.start(630, 984, interval=.5).move(0.2, 0.4).pause(interval=1).move(0.5, 0.6).action()
77+
d.gesture.start(0.77, 0.49).action() # click
78+
79+
7480
# App Element
75-
d(text="showToast").info
81+
d(id="swiper").exists()
82+
d(type="Button", text="tab_recrod").exists()
83+
d(text="tab_recrod", isAfter=True).exists()
84+
d(text="tab_recrod").click_if_exists()
85+
d(type="Button", index=3).click()
86+
d(text="tab_recrod").double_click()
87+
d(text="tab_recrod").long_click()
88+
89+
component: ComponentData = d(type="ListItem", index=1).find_component()
90+
d(type="ListItem").drag_to(component)
91+
92+
d(text="tab_recrod").input_text("abc")
93+
d(text="tab_recrod").clear_text()
94+
d(text="tab_recrod").pinch_in()
95+
d(text="tab_recrod").pinch_out()
96+
97+
d(text="tab_recrod").info
7698
# {
7799
# "id": "",
78100
# "key": "",
79101
# "type": "Button",
80-
# "text": "showToast",
102+
# "text": "tab_recrod",
81103
# "description": "",
82104
# "isSelected": False,
83105
# "isChecked": False,
@@ -99,29 +121,14 @@ d(text="showToast").info
99121
# }
100122
# }
101123

102-
d(id="swiper").exists()
103-
d(type="Button", text="tab_recrod").exists()
104-
d(text="tab_recrod", isAfter=True).exists()
105-
d(text="tab_recrod").click_if_exists()
106-
d(type="Button", index=3).click()
107-
d(text="tab_recrod").double_click()
108-
d(text="tab_recrod").long_click()
109-
110-
component: ComponentData = d(type="ListItem", index=1).find_component()
111-
d(type="ListItem").drag_to(component)
112-
113-
d(text="tab_recrod").input_text("abc")
114-
d(text="tab_recrod").clear_text()
115-
d(text="tab_recrod").pinch_in()
116-
d(text="tab_recrod").pinch_out()
117124

118125
# Dump hierarchy
119126
d.dump_hierarchy()
120127

121128
# Toast Watcher
122129
d.toast_watcher.start()
123130
d(type="Button", text="tab_recrod").click() # 触发toast的操作
124-
toast = d.toast_watcher.get()
131+
toast = d.toast_watcher.get_toast()
125132

126133
```
127134

agent.so

146 KB
Binary file not shown.

docs/DEVELOP.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,46 @@
189189
{"result":{"bundleName":"com.samples.test.uitest","text":"testMessage","type":"Toast"}}
190190
```
191191

192+
### PointerMatrix.create
193+
**send**
194+
```
195+
{"module":"com.ohos.devicetest.hypiumApiHelper","method":"callHypiumApi","params":{"api":"PointerMatrix.create","this":null,"args":[1,104],"message_type":"hypium"},"request_id":"20240906204116056319"}
196+
```
197+
**recv**
198+
```
199+
{"result":"PointerMatrix#0"}
200+
```
201+
202+
### PointerMatrix.setPoint
203+
**send**
204+
```
205+
{"module":"com.ohos.devicetest.hypiumApiHelper","method":"callHypiumApi","params":{"api":"PointerMatrix.setPoint","this":"PointerMatrix#0","args":[0,0,{"x":65536630,"y":984}],"message_type":"hypium"},"request_id":"20240906204116061416"}
206+
207+
{"module":"com.ohos.devicetest.hypiumApiHelper","method":"callHypiumApi","params":{"api":"PointerMatrix.setPoint","this":"PointerMatrix#0","args":[0,1,{"x":3277430,"y":984}],"message_type":"hypium"},"request_id":"20240906204116069343"}
208+
209+
{"module":"com.ohos.devicetest.hypiumApiHelper","method":"callHypiumApi","params":{"api":"PointerMatrix.setPoint","this":"PointerMatrix#0","args":[0,2,{"x":3277393,"y":994}],"message_type":"hypium"},"request_id":"20240906204116072723"}
210+
211+
...
212+
213+
{"module":"com.ohos.devicetest.hypiumApiHelper","method":"callHypiumApi","params":{"api":"PointerMatrix.setPoint","this":"PointerMatrix#0","args":[0,102,{"x":2622070,"y":1632}],"message_type":"hypium"},"request_id":"20240906204116359992"}
214+
215+
{"module":"com.ohos.devicetest.hypiumApiHelper","method":"callHypiumApi","params":{"api":"PointerMatrix.setPoint","this":"PointerMatrix#0","args":[0,103,{"x":633,"y":1632}],"message_type":"hypium"},"request_id":"20240906204116363228"}
216+
```
217+
**recv**
218+
```
219+
{"result":null}
220+
```
221+
222+
### injectMultiPointerAction
223+
**send**
224+
```
225+
{"module":"com.ohos.devicetest.hypiumApiHelper","method":"callHypiumApi","params":{"api":"Driver.injectMultiPointerAction","this":"Driver#0","args":["PointerMatrix#0",2000],"message_type":"hypium"},"request_id":"20240906204116366578"}
226+
```
227+
**recv**
228+
```
229+
{"result":true}
230+
```
231+
192232

193233
## Component
194234
### Component.getId

0 commit comments

Comments
 (0)