feat: add WithSwipeOffset to set offset for swipe start/end point

This commit is contained in:
lilong.129
2023-09-19 16:41:01 +08:00
parent f1fa87c912
commit 3bd10484e5
5 changed files with 72 additions and 8 deletions

View File

@@ -272,6 +272,15 @@ func (ad *adbDriver) Swipe(fromX, fromY, toX, toY int, options ...ActionOption)
}
func (ad *adbDriver) SwipeFloat(fromX, fromY, toX, toY float64, options ...ActionOption) error {
actionOptions := NewActionOptions(options...)
if len(actionOptions.Offset) == 4 {
fromX += float64(actionOptions.Offset[0])
fromY += float64(actionOptions.Offset[1])
toX += float64(actionOptions.Offset[2])
toY += float64(actionOptions.Offset[3])
}
// adb shell input swipe fromX fromY toX toY
_, err := ad.adbClient.RunShellCommand(
"input", "swipe",