feat: support pre hook and post hook for actions

This commit is contained in:
lilong.129
2025-05-09 23:01:27 +08:00
parent 433b1cd48d
commit 3715cbb432
10 changed files with 89 additions and 20 deletions

View File

@@ -8,6 +8,7 @@ import (
"testing"
"time"
"github.com/rs/zerolog/log"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -133,6 +134,33 @@ func TestDriver_ADB_TapXY(t *testing.T) {
assert.Nil(t, err)
}
func TestDriver_ADB_TapXY_WithHook(t *testing.T) {
driver := setupADBDriverExt(t)
x, y := 0.4, 0.5
err := driver.TapXY(x, y,
option.WithHooks(
func() {
log.Info().Msg("pre hook")
x += 1
},
func() {
log.Info().Msg("post hook")
},
),
)
assert.Nil(t, err)
err = driver.TapXY(0.4, 0.5,
option.WithPreHook(func() {
log.Info().Msg("pre hook")
}),
option.WithPostHook(func() {
log.Info().Msg("post hook")
}),
)
assert.Nil(t, err)
}
func TestDriver_ADB_TapAbsXY(t *testing.T) {
driver := setupADBDriverExt(t)
err := driver.TapAbsXY(100, 300)