mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-05 12:37:09 +00:00
refactor(runner): delegate double-tap to driver, drop gesture timing
This commit is contained in:
1 parent
ffa84af591
commit
3eb08c10b4
1 file changed
+2
-20
@@ -21,11 +21,6 @@ import (
|
|||||||
"github.com/priyanshujain/sanderling/internal/verifier"
|
"github.com/priyanshujain/sanderling/internal/verifier"
|
||||||
)
|
)
|
||||||
|
|
||||||
// doubleTapGap is the inter-tap delay for ActionKindDoubleTap: short enough to
|
|
||||||
// land both events inside a sub-100 ms race window, long enough for adb
|
|
||||||
// `input tap` to serialize two MotionEvent streams.
|
|
||||||
const doubleTapGap = 50 * time.Millisecond
|
|
||||||
|
|
||||||
type Options struct {
|
type Options struct {
|
||||||
Duration time.Duration
|
Duration time.Duration
|
||||||
IdleTimeout time.Duration
|
IdleTimeout time.Duration
|
||||||
@@ -469,26 +464,13 @@ func applyAction(ctx context.Context, drv driver.DeviceDriver, action verifier.A
|
|||||||
return drv.Tap(ctx, x, y)
|
return drv.Tap(ctx, x, y)
|
||||||
case verifier.ActionKindDoubleTap:
|
case verifier.ActionKindDoubleTap:
|
||||||
x, y, ok := resolveCoordinates(action, tree)
|
x, y, ok := resolveCoordinates(action, tree)
|
||||||
tap := func() error {
|
|
||||||
if !ok {
|
if !ok {
|
||||||
if action.On == "" {
|
if action.On == "" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return drv.TapSelector(ctx, action.On)
|
return drv.DoubleTapSelector(ctx, action.On)
|
||||||
}
|
}
|
||||||
return drv.Tap(ctx, x, y)
|
return drv.DoubleTap(ctx, x, y)
|
||||||
}
|
|
||||||
if err := tap(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
timer := time.NewTimer(doubleTapGap)
|
|
||||||
defer timer.Stop()
|
|
||||||
select {
|
|
||||||
case <-ctx.Done():
|
|
||||||
return ctx.Err()
|
|
||||||
case <-timer.C:
|
|
||||||
}
|
|
||||||
return tap()
|
|
||||||
case verifier.ActionKindLongPress:
|
case verifier.ActionKindLongPress:
|
||||||
x, y, ok := resolveCoordinates(action, tree)
|
x, y, ok := resolveCoordinates(action, tree)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|||||||
Reference in new issue
Block a user