From f2be8d1b2719df8c02eb6d869b3072654aef35c6 Mon Sep 17 00:00:00 2001 From: chenxin Date: Fri, 22 Jul 2022 19:55:33 +0800 Subject: [PATCH] add positon return --- poco/utils/airtest/input.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/poco/utils/airtest/input.py b/poco/utils/airtest/input.py index 34119167..98ee4aa2 100644 --- a/poco/utils/airtest/input.py +++ b/poco/utils/airtest/input.py @@ -78,7 +78,9 @@ def getTouchDownDuration(self): def click(self, x, y): pos = self.get_target_pos(x, y) - touch(pos, duration=self.default_touch_down_duration) + ret = touch(pos, duration=self.default_touch_down_duration) + resolution = current_device().get_current_resolution() + return ret[0] / resolution[0], ret[1] / resolution[1] # convert position to normalized coordinate def swipe(self, x1, y1, x2, y2, duration=2.0): if duration <= 0: @@ -86,13 +88,18 @@ def swipe(self, x1, y1, x2, y2, duration=2.0): direction = x2 - x1, y2 - y1 pos = self.get_target_pos(x1, y1) steps = int(duration * 40) + 1 - swipe(pos, vector=direction, duration=duration, steps=steps) + ret = swipe(pos, vector=direction, duration=duration, steps=steps) + resolution = current_device().get_current_resolution() + return (ret[0][0] / resolution[0], ret[0][1] / resolution[1]),\ + (ret[1][0] / resolution[0], ret[1][1] / resolution[1]) def longClick(self, x, y, duration=2.0): if duration <= 0: raise ValueError("Operation duration cannot be less equal 0. Please provide a positive number.") pos = self.get_target_pos(x, y) - touch(pos, duration=duration) + ret = touch(pos, duration=duration) + resolution = current_device().get_current_resolution() + return ret[0] / resolution[0], ret[1] / resolution[1] def applyMotionEvents(self, events): if device_platform() != 'Android':