Skip to content

Commit

Permalink
chore: example about swipe ext
Browse files Browse the repository at this point in the history
  • Loading branch information
codematrixer committed Oct 9, 2024
1 parent cca6ac9 commit 9a4a820
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
50 changes: 49 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,55 @@ UI 控件树可视化工具,查看控件树层级,获取控件详情。

# API Documents

- [API Documents](#api-documents)
- [初始化Driver](#初始化driver)
- [App管理](#app管理)
- [安装App](#安装app)
- [卸载App](#卸载app)
- [启动App](#启动app)
- [停止App](#停止app)
- [清除App数据](#清除app数据)
- [获取App详情](#获取app详情)
- [设备操作](#设备操作)
- [获取设备信息](#获取设备信息)
- [获取设备分辨率](#获取设备分辨率)
- [获取设备旋转状态](#获取设备旋转状态)
- [设置设备旋转](#设置设备旋转)
- [Home](#home)
- [返回](#返回)
- [亮屏](#亮屏)
- [息屏](#息屏)
- [屏幕解锁](#屏幕解锁)
- [Key Events](#key-events)
- [执行hdc](#执行hdc)
- [打开URL (schema)](#打开url-schema)
- [文件操作](#文件操作)
- [屏幕截图](#屏幕截图)
- [屏幕录屏](#屏幕录屏)
- [Device Touch](#device-touch)
- [单击](#单击)
- [双击](#双击)
- [长按](#长按)
- [滑动](#滑动)
- [滑动 ext](#滑动-ext)
- [输入](#输入)
- [复杂手势](#复杂手势)
- [控件操作](#控件操作)
- [控件选择器](#控件选择器)
- [控件查找](#控件查找)
- [控件信息](#控件信息)
- [控件数量](#控件数量)
- [控件点击](#控件点击)
- [控件双击](#控件双击)
- [控件长按](#控件长按)
- [控件拖拽](#控件拖拽)
- [控件缩放](#控件缩放)
- [控件输入](#控件输入)
- [文本清除](#文本清除)
- [获取控件树](#获取控件树)
- [获取Toast](#获取toast)


## 初始化Driver
```python
from hmdriver2.driver import Driver
Expand Down Expand Up @@ -644,7 +693,6 @@ toast = d.toast_watcher.get_toast()
```



# 鸿蒙Uitest协议

See [DEVELOP.md](/docs/DEVELOP.md)
Expand Down
8 changes: 8 additions & 0 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@
d.long_click(500, 1000)
d.long_click(0.5, 0.4)
d.swipe(0.5, 0.8, 0.5, 0.4, speed=2000)

d.swipe_ext("up") # 向上滑动,"left", "right", "up", "down"
d.swipe_ext("right", scale=0.8) # 向右滑动,滑动距离为屏幕宽度的80%
d.swipe_ext("up", box=(0.2, 0.2, 0.8, 0.8)) # 在屏幕 (0.2, 0.2) -> (0.8, 0.8) 这个区域上滑

from hmdriver2.proto import SwipeDirection
d.swipe_ext(SwipeDirection.DOWN) # 向下滑动

d.input_text("adbcdfg")

# Device touch gersture
Expand Down
7 changes: 7 additions & 0 deletions hmdriver2/proto.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ class CommandResult:
exit_code: int


class SwipeDirection(str, Enum):
LEFT = "left"
RIGHT = "right"
UP = "up"
DOWN = "down"


class DisplayRotation(int, Enum):
ROTATION_0 = 0
ROTATION_90 = 1
Expand Down

0 comments on commit 9a4a820

Please sign in to comment.