Skip to content

Commit

Permalink
feat: Add device touch gesture
Browse files Browse the repository at this point in the history
  • Loading branch information
codematrixer committed Sep 9, 2024
1 parent dfcd2fb commit 91faf10
Show file tree
Hide file tree
Showing 13 changed files with 544 additions and 102 deletions.
43 changes: 25 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,35 @@ d.long_click(0.5, 0.4)
d.swipe(0.5, 0.8, 0.5, 0.4, speed=2000)
d.input_text(0.5, 0.5, "adbcdfg")


# Device touch gersture
d.gesture.start(630, 984, interval=.5).move(0.2, 0.4).pause(interval=1).move(0.5, 0.6).action()
d.gesture.start(0.77, 0.49).action() # click


# App Element
d(text="showToast").info
d(id="swiper").exists()
d(type="Button", text="tab_recrod").exists()
d(text="tab_recrod", isAfter=True).exists()
d(text="tab_recrod").click_if_exists()
d(type="Button", index=3).click()
d(text="tab_recrod").double_click()
d(text="tab_recrod").long_click()

component: ComponentData = d(type="ListItem", index=1).find_component()
d(type="ListItem").drag_to(component)

d(text="tab_recrod").input_text("abc")
d(text="tab_recrod").clear_text()
d(text="tab_recrod").pinch_in()
d(text="tab_recrod").pinch_out()

d(text="tab_recrod").info
# {
# "id": "",
# "key": "",
# "type": "Button",
# "text": "showToast",
# "text": "tab_recrod",
# "description": "",
# "isSelected": False,
# "isChecked": False,
Expand All @@ -99,29 +121,14 @@ d(text="showToast").info
# }
# }

d(id="swiper").exists()
d(type="Button", text="tab_recrod").exists()
d(text="tab_recrod", isAfter=True).exists()
d(text="tab_recrod").click_if_exists()
d(type="Button", index=3).click()
d(text="tab_recrod").double_click()
d(text="tab_recrod").long_click()

component: ComponentData = d(type="ListItem", index=1).find_component()
d(type="ListItem").drag_to(component)

d(text="tab_recrod").input_text("abc")
d(text="tab_recrod").clear_text()
d(text="tab_recrod").pinch_in()
d(text="tab_recrod").pinch_out()

# Dump hierarchy
d.dump_hierarchy()

# Toast Watcher
d.toast_watcher.start()
d(type="Button", text="tab_recrod").click() # 触发toast的操作
toast = d.toast_watcher.get()
toast = d.toast_watcher.get_toast()

```

Expand Down
Binary file added agent.so
Binary file not shown.
40 changes: 40 additions & 0 deletions docs/DEVELOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,46 @@
{"result":{"bundleName":"com.samples.test.uitest","text":"testMessage","type":"Toast"}}
```

### PointerMatrix.create
**send**
```
{"module":"com.ohos.devicetest.hypiumApiHelper","method":"callHypiumApi","params":{"api":"PointerMatrix.create","this":null,"args":[1,104],"message_type":"hypium"},"request_id":"20240906204116056319"}
```
**recv**
```
{"result":"PointerMatrix#0"}
```

### PointerMatrix.setPoint
**send**
```
{"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"}
{"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"}
{"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"}
...
{"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"}
{"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"}
```
**recv**
```
{"result":null}
```

### injectMultiPointerAction
**send**
```
{"module":"com.ohos.devicetest.hypiumApiHelper","method":"callHypiumApi","params":{"api":"Driver.injectMultiPointerAction","this":"Driver#0","args":["PointerMatrix#0",2000],"message_type":"hypium"},"request_id":"20240906204116366578"}
```
**recv**
```
{"result":true}
```


## Component
### Component.getId
Expand Down
Loading

0 comments on commit 91faf10

Please sign in to comment.