feat: add FoundAction to SwipeUntil

This commit is contained in:
debugtalk
2022-08-31 20:36:34 +08:00
parent 6d418ff795
commit 9b547524d2
2 changed files with 21 additions and 16 deletions
+10 -8
View File
@@ -37,6 +37,10 @@ func TestSwipeUntil(t *testing.T) {
x, y, width, height, err = d.FindTextByOCR("抖音")
return err
}
foundAppAction := func(d *DriverExt) error {
// click app, launch douyin
return d.TapFloat(x+width*0.5, y+height*0.5-20)
}
driverExt.Homescreen()
@@ -46,22 +50,20 @@ func TestSwipeUntil(t *testing.T) {
}
// swipe until app found
err = driverExt.SwipeUntil("left", findApp, 10)
err = driverExt.SwipeUntil("left", findApp, foundAppAction, 10)
checkErr(t, err)
// click app, launch douyin
driverExt.TapFloat(x+width*0.5, y+height*0.5-20)
findLive := func(d *DriverExt) error {
var err error
x, y, width, height, err = d.FindTextByOCR("点击进入直播间")
return err
}
foundLiveAction := func(d *DriverExt) error {
// enter live room
return d.TapFloat(x+width*0.5, y+height*0.5)
}
// swipe until live room found
err = driverExt.SwipeUntil("up", findLive, 20)
err = driverExt.SwipeUntil("up", findLive, foundLiveAction, 20)
checkErr(t, err)
// enter live room
driverExt.TapFloat(x+width*0.5, y+height*0.5)
}