airtest.core.android.touch_methods.base_touch module

retry_when_connection_error(func)[源代码]
class BaseTouch(adb, backend=False, size_info=None, input_event=None, *args, **kwargs)[源代码]

基类:object

A super class for Minitouch or Maxtouch

install_and_setup()[源代码]

Install and setup airtest touch

返回:

None

uninstall()[源代码]

Uninstall airtest touch

返回:

None

install()[源代码]

Install airtest touch

返回:

None

setup_server()[源代码]

Setip touch server and adb forward

返回:

server process

safe_send(data)[源代码]

Send data to client

参数:

data – data to send

抛出:

Exception – when data cannot be sent

返回:

None

setup_client_backend()[源代码]

Setup backend client thread as daemon

返回:

None

setup_client()[源代码]

Setup client

返回:

None

teardown()[源代码]

Stop the server and client

返回:

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

抛出:

TypeError – An error occurred when center is not a list/tuple or None

operate(args)[源代码]

Perform down, up and move actions

参数:

args

action arguments, dictionary containing type and x, y coordinates, e.g.:

{
"type" : "down",
"x" : 10,
"y" : 10
}

抛出:

RuntimeError – is invalid arguments are provided

返回:

None

class MotionEvent[源代码]

基类:object

Motion Event to be performed by Minitouch/Maxtouch

getcmd(transform=None)[源代码]
class DownEvent(coordinates, contact=0, pressure=50)[源代码]

基类:MotionEvent

getcmd(transform=None)[源代码]
class UpEvent(contact=0)[源代码]

基类:MotionEvent

getcmd(transform=None)[源代码]
class MoveEvent(coordinates, contact=0, pressure=50)[源代码]

基类:MotionEvent

getcmd(transform=None)[源代码]
class SleepEvent(seconds)[源代码]

基类:MotionEvent

getcmd(transform=None)[源代码]