mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-02 22:39:42 +08:00
fix: tap/swipe points with random offset
This commit is contained in:
@@ -225,9 +225,11 @@ func (ad *adbDriver) TapFloat(x, y float64, options ...ActionOption) (err error)
|
||||
actionOptions := NewActionOptions(options...)
|
||||
|
||||
if len(actionOptions.Offset) == 2 {
|
||||
x += float64(actionOptions.Offset[0] + actionOptions.getRandomOffset())
|
||||
y += float64(actionOptions.Offset[1] + actionOptions.getRandomOffset())
|
||||
x += float64(actionOptions.Offset[0])
|
||||
y += float64(actionOptions.Offset[1])
|
||||
}
|
||||
x += actionOptions.getRandomOffset()
|
||||
y += actionOptions.getRandomOffset()
|
||||
|
||||
// adb shell input tap x y
|
||||
xStr := fmt.Sprintf("%.1f", x)
|
||||
@@ -275,11 +277,15 @@ func (ad *adbDriver) SwipeFloat(fromX, fromY, toX, toY float64, options ...Actio
|
||||
actionOptions := NewActionOptions(options...)
|
||||
|
||||
if len(actionOptions.Offset) == 4 {
|
||||
fromX += float64(actionOptions.Offset[0] + actionOptions.getRandomOffset())
|
||||
fromY += float64(actionOptions.Offset[1] + actionOptions.getRandomOffset())
|
||||
toX += float64(actionOptions.Offset[2] + actionOptions.getRandomOffset())
|
||||
toY += float64(actionOptions.Offset[3] + actionOptions.getRandomOffset())
|
||||
fromX += float64(actionOptions.Offset[0])
|
||||
fromY += float64(actionOptions.Offset[1])
|
||||
toX += float64(actionOptions.Offset[2])
|
||||
toY += float64(actionOptions.Offset[3])
|
||||
}
|
||||
fromX += actionOptions.getRandomOffset()
|
||||
fromY += actionOptions.getRandomOffset()
|
||||
toX += actionOptions.getRandomOffset()
|
||||
toY += actionOptions.getRandomOffset()
|
||||
|
||||
// adb shell input swipe fromX fromY toX toY
|
||||
_, err := ad.adbClient.RunShellCommand(
|
||||
|
||||
Reference in New Issue
Block a user