refactor: handlerDoubleTap

This commit is contained in:
lilong.129
2025-05-06 00:52:47 +08:00
parent 48e3d9002e
commit 71dac459e6
7 changed files with 48 additions and 30 deletions

View File

@@ -594,6 +594,9 @@ func (wd *WDADriver) TapAbsXY(x, y float64, opts ...option.ActionOption) error {
log.Info().Float64("x", x).Float64("y", y).Msg("WDADriver.TapAbsXY")
// [[FBRoute POST:@"/wda/tap/:uuid"] respondWithTarget:self action:@selector(handleTap:)]
x = wd.toScale(x)
y = wd.toScale(y)
var err error
x, y, _, err = handlerTapAbsXY(wd, x, y, opts...)
if err != nil {
@@ -601,8 +604,8 @@ func (wd *WDADriver) TapAbsXY(x, y float64, opts ...option.ActionOption) error {
}
data := map[string]interface{}{
"x": wd.toScale(x),
"y": wd.toScale(y),
"x": x,
"y": y,
}
option.MergeOptions(data, opts...)
@@ -614,16 +617,16 @@ func (wd *WDADriver) TapAbsXY(x, y float64, opts ...option.ActionOption) error {
func (wd *WDADriver) DoubleTap(x, y float64, opts ...option.ActionOption) error {
log.Info().Float64("x", x).Float64("y", y).Msg("WDADriver.DoubleTap")
// [[FBRoute POST:@"/wda/doubleTap"] respondWithTarget:self action:@selector(handleDoubleTapCoordinate:)]
x = wd.toScale(x)
y = wd.toScale(y)
var err error
x, y, err = convertToAbsolutePoint(wd, x, y)
x, y, err = handlerDoubleTap(wd, x, y, opts...)
if err != nil {
return err
}
actionOptions := option.NewActionOptions(opts...)
x, y = actionOptions.ApplyTapOffset(x, y)
x = wd.toScale(x)
y = wd.toScale(y)
data := map[string]interface{}{
"x": x,
"y": y,
@@ -648,23 +651,16 @@ func (wd *WDADriver) Drag(fromX, fromY, toX, toY float64, opts ...option.ActionO
log.Info().Float64("fromX", fromX).Float64("fromY", fromY).
Float64("toX", toX).Float64("toY", toY).Msg("WDADriver.Drag")
// [[FBRoute POST:@"/wda/dragfromtoforduration"] respondWithTarget:self action:@selector(handleDragCoordinate:)]
var err error
fromX, fromY, toX, toY, err = convertToAbsoluteCoordinates(wd, fromX, fromY, toX, toY)
if err != nil {
return err
}
fromX = wd.toScale(fromX)
fromY = wd.toScale(fromY)
toX = wd.toScale(toX)
toY = wd.toScale(toY)
actionOptions := option.NewActionOptions(opts...)
fromX, fromY, toX, toY = actionOptions.ApplySwipeOffset(fromX, fromY, toX, toY)
// mark UI operation
if actionOptions.MarkOperationEnabled {
if markErr := MarkUIOperation(wd, ACTION_Drag, []float64{fromX, fromY, toX, toY}); markErr != nil {
log.Warn().Err(markErr).Msg("Failed to mark drag operation")
}
var err error
fromX, fromY, toX, toY, err = handlerDrag(wd, fromX, fromY, toX, toY, opts...)
if err != nil {
return err
}
data := map[string]interface{}{