airtest.core.android.touch_methods.base_touch module¶
-
class
BaseTouch
(adb, backend=False, size_info=None, input_event=None, *args, **kwargs)[源代码]¶ 基类:
object
A super class for Minitouch or Maxtouch
-
safe_send
(data)[源代码]¶ Send data to client
参数: data – data to send Raises: Exception
– when data cannot be sent返回: None
-
transform_xy
(x, y)[源代码]¶ Transform coordinates (x, y) according to the device display
参数: - x – coordinate x
- y – coordinate y
返回: transformed coordinates (x, y)
-
perform
(motion_events, interval=0.01)[源代码]¶ Perform a sequence of motion events including: UpEvent, DownEvent, MoveEvent, SleepEvent
参数: - motion_events – a list of MotionEvent instances
- interval – minimum interval between events
返回: None
-
touch
(tuple_xy, duration=0.01)[源代码]¶ Perform touch event
minitouch protocol example:
d 0 10 10 50 c <wait in your own code> u 0 c
参数: - tuple_xy – coordinates (x, y)
- duration – time interval for touch event, default is 0.01
返回: None
-
swipe_along
(coordinates_list, duration=0.8, steps=5)[源代码]¶ Perform swipe event across multiple points in sequence.
参数: - coordinates_list – list of coordinates: [(x1, y1), (x2, y2), (x3, y3)]
- duration – time interval for swipe duration, default is 0.8
- steps – size of swipe step, default is 5
返回: None
-
swipe
(tuple_from_xy, tuple_to_xy, duration=0.8, steps=5)[源代码]¶ Perform swipe event.
参数: - tuple_from_xy – start point
- tuple_to_xy – end point
- duration – time interval for swipe duration, default is 0.8
- steps – size of swipe step, default is 5
返回: None
-
two_finger_swipe
(tuple_from_xy, tuple_to_xy, duration=0.8, steps=5, offset=(0, 50))[源代码]¶ Perform two finger swipe action
minitouch protocol example:
d 0 0 0 50 d 1 1 0 50 c m 0 20 0 50 m 1 21 0 50 c m 0 40 0 50 m 1 41 0 50 c m 0 60 0 50 m 1 61 0 50 c m 0 80 0 50 m 1 81 0 50 c m 0 100 0 50 m 1 101 0 50 c u 0 u 1 c
参数: - tuple_from_xy – start point
- tuple_to_xy – end point
- duration – time interval for swipe duration, default is 0.8
- steps – size of swipe step, default is 5
- offset – coordinate offset of the second finger, default is (0, 50)
返回: None
-
pinch
(center=None, percent=0.5, duration=0.5, steps=5, in_or_out='in')[源代码]¶ Perform pinch action
minitouch protocol example:
d 0 0 100 50 d 1 100 0 50 c m 0 10 90 50 m 1 90 10 50 c m 0 20 80 50 m 1 80 20 50 c m 0 20 80 50 m 1 80 20 50 c m 0 30 70 50 m 1 70 30 50 c m 0 40 60 50 m 1 60 40 50 c m 0 50 50 50 m 1 50 50 50 c u 0 u 1 c
参数: - center – the center point of the pinch operation
- percent – pinch distance to half of screen, default is 0.5
- duration – time interval for swipe duration, default is 0.8
- steps – size of swipe step, default is 5
- in_or_out – pinch in or pinch out, default is ‘in’
返回: None
Raises: TypeError
– An error occurred when center is not a list/tuple or None
-
-
class
DownEvent
(coordinates, contact=0, pressure=50)[源代码]¶ 基类:
airtest.core.android.touch_methods.base_touch.MotionEvent
-
class
UpEvent
(contact=0)[源代码]¶ 基类:
airtest.core.android.touch_methods.base_touch.MotionEvent
-
class
MoveEvent
(coordinates, contact=0, pressure=50)[源代码]¶ 基类:
airtest.core.android.touch_methods.base_touch.MotionEvent
-
class
SleepEvent
(seconds)[源代码]¶ 基类:
airtest.core.android.touch_methods.base_touch.MotionEvent