Skip to content

Commit

Permalink
chore: split different level API
Browse files Browse the repository at this point in the history
  • Loading branch information
williamfzc committed Jun 15, 2019
1 parent 855a840 commit 875d72e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
8 changes: 8 additions & 0 deletions fitch/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ def tap_point(self, target_point: typing.Sequence, duration: int = None):

self.player.tap(target_point, duration=duration)

def tap_and_drag(self,
point1: (list, tuple),
point2: (list, tuple),
duration: int = None,
part: int = None):
self.player.long_tap(point1, no_up=True)
self.player.swipe(point1, point2, duration, part, no_down=True)


@contextlib.contextmanager
def safe_device(device_id: str) -> FDevice:
Expand Down
11 changes: 1 addition & 10 deletions fitch/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@


class ActionPlayer(object):
""" base, low level API here """
def __init__(self, device_id: str):
self.device_id = device_id
self.mnt = MNTDevice(device_id)
Expand Down Expand Up @@ -73,16 +74,6 @@ def slow_swipe(self,
point2: (list, tuple)):
self.swipe(point1, point2, duration=1, part=50)

# --- high level API below ---
def tap_and_drag(self,
point1: (list, tuple),
point2: (list, tuple),
duration: int = None,
part: int = None):

self.long_tap(point1, no_up=True)
self.swipe(point1, point2, duration, part, no_down=True)


if __name__ == '__main__':
ap = ActionPlayer('4df189487c7b6fef')
Expand Down

0 comments on commit 875d72e

Please sign in to comment.