mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-02 14:29:44 +08:00
feat: add pre hook and post hook for DoubleTap action
This commit is contained in:
@@ -326,11 +326,12 @@ func (ad *ADBDriver) TapAbsXY(x, y float64, opts ...option.ActionOption) error {
|
||||
|
||||
func (ad *ADBDriver) DoubleTap(x, y float64, opts ...option.ActionOption) error {
|
||||
log.Info().Float64("x", x).Float64("y", y).Msg("ADBDriver.DoubleTap")
|
||||
var err error
|
||||
x, y, err = handlerDoubleTap(ad, x, y, opts...)
|
||||
actionOptions := option.NewActionOptions(opts...)
|
||||
x, y, err := preHandler_DoubleTap(ad, actionOptions, x, y)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer postHandler(ad, actionOptions)
|
||||
|
||||
// adb shell input tap x y
|
||||
xStr := fmt.Sprintf("%.1f", x)
|
||||
|
||||
@@ -257,11 +257,12 @@ func (ud *UIA2Driver) Orientation() (orientation types.Orientation, err error) {
|
||||
|
||||
func (ud *UIA2Driver) DoubleTap(x, y float64, opts ...option.ActionOption) error {
|
||||
log.Info().Float64("x", x).Float64("y", y).Msg("UIA2Driver.DoubleTap")
|
||||
var err error
|
||||
x, y, err = handlerDoubleTap(ud, x, y, opts...)
|
||||
actionOptions := option.NewActionOptions(opts...)
|
||||
x, y, err := preHandler_DoubleTap(ud, actionOptions, x, y)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer postHandler(ud, actionOptions)
|
||||
|
||||
data := map[string]interface{}{
|
||||
"actions": []interface{}{
|
||||
|
||||
@@ -535,11 +535,13 @@ func (wd *BrowserDriver) TapFloat(x, y float64, opts ...option.ActionOption) err
|
||||
|
||||
// DoubleTap Sends a double tap event at the coordinate.
|
||||
func (wd *BrowserDriver) DoubleTap(x, y float64, options ...option.ActionOption) error {
|
||||
var err error
|
||||
x, y, err = handlerDoubleTap(wd, x, y, options...)
|
||||
actionOptions := option.NewActionOptions(options...)
|
||||
x, y, err := preHandler_DoubleTap(wd, actionOptions, x, y)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer postHandler(wd, actionOptions)
|
||||
|
||||
data := map[string]interface{}{
|
||||
"x": x,
|
||||
"y": y,
|
||||
|
||||
@@ -24,19 +24,22 @@ func preHandler_TapAbsXY(driver IDriver, options *option.ActionOptions, rawX, ra
|
||||
return x, y, nil
|
||||
}
|
||||
|
||||
func handlerDoubleTap(driver IDriver, rawX, rawY float64, opts ...option.ActionOption) (
|
||||
func preHandler_DoubleTap(driver IDriver, options *option.ActionOptions, rawX, rawY float64) (
|
||||
x, y float64, err error) {
|
||||
|
||||
if options.PreHook != nil {
|
||||
options.PreHook()
|
||||
}
|
||||
|
||||
x, y, err = convertToAbsolutePoint(driver, rawX, rawY)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
actionOptions := option.NewActionOptions(opts...)
|
||||
x, y = actionOptions.ApplyTapOffset(x, y)
|
||||
x, y = options.ApplyTapOffset(x, y)
|
||||
|
||||
// mark UI operation
|
||||
if actionOptions.MarkOperationEnabled {
|
||||
if options.MarkOperationEnabled {
|
||||
if markErr := MarkUIOperation(driver, ACTION_DoubleTapXY, []float64{x, y}); markErr != nil {
|
||||
log.Warn().Err(markErr).Msg("Failed to mark double tap operation")
|
||||
}
|
||||
|
||||
@@ -622,11 +622,12 @@ func (wd *WDADriver) DoubleTap(x, y float64, opts ...option.ActionOption) error
|
||||
x = wd.toScale(x)
|
||||
y = wd.toScale(y)
|
||||
|
||||
var err error
|
||||
x, y, err = handlerDoubleTap(wd, x, y, opts...)
|
||||
actionOptions := option.NewActionOptions(opts...)
|
||||
x, y, err := preHandler_DoubleTap(wd, actionOptions, x, y)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer postHandler(wd, actionOptions)
|
||||
|
||||
data := map[string]interface{}{
|
||||
"x": x,
|
||||
|
||||
Reference in New Issue
Block a user