Skip to content

Commit 9a4a820

Browse files
committed
chore: example about swipe ext
1 parent cca6ac9 commit 9a4a820

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

README.md

+49-1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,55 @@ UI 控件树可视化工具,查看控件树层级,获取控件详情。
102102

103103
# API Documents
104104

105+
- [API Documents](#api-documents)
106+
- [初始化Driver](#初始化driver)
107+
- [App管理](#app管理)
108+
- [安装App](#安装app)
109+
- [卸载App](#卸载app)
110+
- [启动App](#启动app)
111+
- [停止App](#停止app)
112+
- [清除App数据](#清除app数据)
113+
- [获取App详情](#获取app详情)
114+
- [设备操作](#设备操作)
115+
- [获取设备信息](#获取设备信息)
116+
- [获取设备分辨率](#获取设备分辨率)
117+
- [获取设备旋转状态](#获取设备旋转状态)
118+
- [设置设备旋转](#设置设备旋转)
119+
- [Home](#home)
120+
- [返回](#返回)
121+
- [亮屏](#亮屏)
122+
- [息屏](#息屏)
123+
- [屏幕解锁](#屏幕解锁)
124+
- [Key Events](#key-events)
125+
- [执行hdc](#执行hdc)
126+
- [打开URL (schema)](#打开url-schema)
127+
- [文件操作](#文件操作)
128+
- [屏幕截图](#屏幕截图)
129+
- [屏幕录屏](#屏幕录屏)
130+
- [Device Touch](#device-touch)
131+
- [单击](#单击)
132+
- [双击](#双击)
133+
- [长按](#长按)
134+
- [滑动](#滑动)
135+
- [滑动 ext](#滑动-ext)
136+
- [输入](#输入)
137+
- [复杂手势](#复杂手势)
138+
- [控件操作](#控件操作)
139+
- [控件选择器](#控件选择器)
140+
- [控件查找](#控件查找)
141+
- [控件信息](#控件信息)
142+
- [控件数量](#控件数量)
143+
- [控件点击](#控件点击)
144+
- [控件双击](#控件双击)
145+
- [控件长按](#控件长按)
146+
- [控件拖拽](#控件拖拽)
147+
- [控件缩放](#控件缩放)
148+
- [控件输入](#控件输入)
149+
- [文本清除](#文本清除)
150+
- [获取控件树](#获取控件树)
151+
- [获取Toast](#获取toast)
152+
153+
105154
## 初始化Driver
106155
```python
107156
from hmdriver2.driver import Driver
@@ -644,7 +693,6 @@ toast = d.toast_watcher.get_toast()
644693
```
645694

646695

647-
648696
# 鸿蒙Uitest协议
649697

650698
See [DEVELOP.md](/docs/DEVELOP.md)

example.py

+8
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@
5353
d.long_click(500, 1000)
5454
d.long_click(0.5, 0.4)
5555
d.swipe(0.5, 0.8, 0.5, 0.4, speed=2000)
56+
57+
d.swipe_ext("up") # 向上滑动,"left", "right", "up", "down"
58+
d.swipe_ext("right", scale=0.8) # 向右滑动,滑动距离为屏幕宽度的80%
59+
d.swipe_ext("up", box=(0.2, 0.2, 0.8, 0.8)) # 在屏幕 (0.2, 0.2) -> (0.8, 0.8) 这个区域上滑
60+
61+
from hmdriver2.proto import SwipeDirection
62+
d.swipe_ext(SwipeDirection.DOWN) # 向下滑动
63+
5664
d.input_text("adbcdfg")
5765

5866
# Device touch gersture

hmdriver2/proto.py

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ class CommandResult:
1313
exit_code: int
1414

1515

16+
class SwipeDirection(str, Enum):
17+
LEFT = "left"
18+
RIGHT = "right"
19+
UP = "up"
20+
DOWN = "down"
21+
22+
1623
class DisplayRotation(int, Enum):
1724
ROTATION_0 = 0
1825
ROTATION_90 = 1

0 commit comments

Comments
 (0)