mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-07 16:40:50 +08:00
feat: add pre hook and post hook for DoubleTap action
This commit is contained in:
@@ -1 +1 @@
|
|||||||
v5.0.0-beta-2505092301
|
v5.0.0-beta-2505092306
|
||||||
|
|||||||
@@ -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 {
|
func (ad *ADBDriver) DoubleTap(x, y float64, opts ...option.ActionOption) error {
|
||||||
log.Info().Float64("x", x).Float64("y", y).Msg("ADBDriver.DoubleTap")
|
log.Info().Float64("x", x).Float64("y", y).Msg("ADBDriver.DoubleTap")
|
||||||
var err error
|
actionOptions := option.NewActionOptions(opts...)
|
||||||
x, y, err = handlerDoubleTap(ad, x, y, opts...)
|
x, y, err := preHandler_DoubleTap(ad, actionOptions, x, y)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer postHandler(ad, actionOptions)
|
||||||
|
|
||||||
// adb shell input tap x y
|
// adb shell input tap x y
|
||||||
xStr := fmt.Sprintf("%.1f", x)
|
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 {
|
func (ud *UIA2Driver) DoubleTap(x, y float64, opts ...option.ActionOption) error {
|
||||||
log.Info().Float64("x", x).Float64("y", y).Msg("UIA2Driver.DoubleTap")
|
log.Info().Float64("x", x).Float64("y", y).Msg("UIA2Driver.DoubleTap")
|
||||||
var err error
|
actionOptions := option.NewActionOptions(opts...)
|
||||||
x, y, err = handlerDoubleTap(ud, x, y, opts...)
|
x, y, err := preHandler_DoubleTap(ud, actionOptions, x, y)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer postHandler(ud, actionOptions)
|
||||||
|
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"actions": []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.
|
// DoubleTap Sends a double tap event at the coordinate.
|
||||||
func (wd *BrowserDriver) DoubleTap(x, y float64, options ...option.ActionOption) error {
|
func (wd *BrowserDriver) DoubleTap(x, y float64, options ...option.ActionOption) error {
|
||||||
var err error
|
actionOptions := option.NewActionOptions(options...)
|
||||||
x, y, err = handlerDoubleTap(wd, x, y, options...)
|
x, y, err := preHandler_DoubleTap(wd, actionOptions, x, y)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer postHandler(wd, actionOptions)
|
||||||
|
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"x": x,
|
"x": x,
|
||||||
"y": y,
|
"y": y,
|
||||||
|
|||||||
@@ -24,19 +24,22 @@ func preHandler_TapAbsXY(driver IDriver, options *option.ActionOptions, rawX, ra
|
|||||||
return x, y, nil
|
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) {
|
x, y float64, err error) {
|
||||||
|
|
||||||
|
if options.PreHook != nil {
|
||||||
|
options.PreHook()
|
||||||
|
}
|
||||||
|
|
||||||
x, y, err = convertToAbsolutePoint(driver, rawX, rawY)
|
x, y, err = convertToAbsolutePoint(driver, rawX, rawY)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, 0, err
|
return 0, 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
actionOptions := option.NewActionOptions(opts...)
|
x, y = options.ApplyTapOffset(x, y)
|
||||||
x, y = actionOptions.ApplyTapOffset(x, y)
|
|
||||||
|
|
||||||
// mark UI operation
|
// mark UI operation
|
||||||
if actionOptions.MarkOperationEnabled {
|
if options.MarkOperationEnabled {
|
||||||
if markErr := MarkUIOperation(driver, ACTION_DoubleTapXY, []float64{x, y}); markErr != nil {
|
if markErr := MarkUIOperation(driver, ACTION_DoubleTapXY, []float64{x, y}); markErr != nil {
|
||||||
log.Warn().Err(markErr).Msg("Failed to mark double tap operation")
|
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)
|
x = wd.toScale(x)
|
||||||
y = wd.toScale(y)
|
y = wd.toScale(y)
|
||||||
|
|
||||||
var err error
|
actionOptions := option.NewActionOptions(opts...)
|
||||||
x, y, err = handlerDoubleTap(wd, x, y, opts...)
|
x, y, err := preHandler_DoubleTap(wd, actionOptions, x, y)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer postHandler(wd, actionOptions)
|
||||||
|
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"x": x,
|
"x": x,
|
||||||
|
|||||||
Reference in New Issue
Block a user