Skip to content

Commit

Permalink
fix swipe, close #842
Browse files Browse the repository at this point in the history
  • Loading branch information
codeskyblue committed May 14, 2024
1 parent 0a66b07 commit bcc1675
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions uiautomator2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,17 @@ def swipe(self, fx, fy, tx, ty, duration: Optional[float] = None, steps: Optiona
Links:
https://developer.android.com/reference/android/support/test/uiautomator/UiDevice.html#swipe%28int,%20int,%20int,%20int,%20int%29
"""
if duration is not None and steps is not None:
warnings.warn("duration and steps can not be set at the same time, use steps")
duration = None
if duration:
steps = int(duration * 200)
if not steps:
steps = SCROLL_STEPS
logger.debug("swipe from (%s, %s) to (%s, %s), steps: %d", fx, fy, tx, ty, steps)
rel2abs = self.pos_rel2abs
fx, fy = rel2abs(fx, fy)
tx, ty = rel2abs(tx, ty)
if not duration:
steps = SCROLL_STEPS
if not steps:
steps = int(duration * 200)
steps = max(2, steps) # step=1 has no swipe effect
with self._operation_delay("swipe"):
return self.jsonrpc.swipe(fx, fy, tx, ty, steps)
Expand Down
2 changes: 1 addition & 1 deletion uiautomator2/assets/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

set -e

APK_VERSION="2.3.9"
APK_VERSION="2.3.10"
# AGENT_VERSION="0.10.1"

cd "$(dirname $0)"
Expand Down

0 comments on commit bcc1675

Please sign in to comment.