airtest.core.android.touch_methods.base_touch module¶
-
class
BaseTouch
(adb, backend=False, size_info=None, input_event=None, *args, **kwargs)[source]¶ Bases:
object
A super class for Minitouch or Maxtouch
-
safe_send
(data)[source]¶ Send data to client
Parameters: data – data to send Raises: Exception
– when data cannot be sentReturns: None
-
transform_xy
(x, y)[source]¶ Transform coordinates (x, y) according to the device display
Parameters: - x – coordinate x
- y – coordinate y
Returns: transformed coordinates (x, y)
-
perform
(motion_events, interval=0.01)[source]¶ Perform a sequence of motion events including: UpEvent, DownEvent, MoveEvent, SleepEvent
Parameters: - motion_events – a list of MotionEvent instances
- interval – minimum interval between events
Returns: None
-
touch
(tuple_xy, duration=0.01)[source]¶ Perform touch event
minitouch protocol example:
d 0 10 10 50 c <wait in your own code> u 0 c
Parameters: - tuple_xy – coordinates (x, y)
- duration – time interval for touch event, default is 0.01
Returns: None
-
swipe_along
(coordinates_list, duration=0.8, steps=5)[source]¶ Perform swipe event across multiple points in sequence.
Parameters: - 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
Returns: None
-
swipe
(tuple_from_xy, tuple_to_xy, duration=0.8, steps=5)[source]¶ Perform swipe event.
Parameters: - 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
Returns: None
-
two_finger_swipe
(tuple_from_xy, tuple_to_xy, duration=0.8, steps=5, offset=(0, 50))[source]¶ 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
Parameters: - 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)
Returns: None
-
pinch
(center=None, percent=0.5, duration=0.5, steps=5, in_or_out='in')[source]¶ 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
Parameters: - 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’
Returns: None
Raises: TypeError
– An error occurred when center is not a list/tuple or None
-
-
class
DownEvent
(coordinates, contact=0, pressure=50)[source]¶ Bases:
airtest.core.android.touch_methods.base_touch.MotionEvent
-
class
UpEvent
(contact=0)[source]¶ Bases:
airtest.core.android.touch_methods.base_touch.MotionEvent
-
class
MoveEvent
(coordinates, contact=0, pressure=50)[source]¶ Bases:
airtest.core.android.touch_methods.base_touch.MotionEvent
-
class
SleepEvent
(seconds)[source]¶ Bases:
airtest.core.android.touch_methods.base_touch.MotionEvent