refactor: merge Tap and TapFloat

This commit is contained in:
lilong.129
2024-11-23 22:10:49 +08:00
parent 89a08f61ec
commit ad796590b5
10 changed files with 12 additions and 37 deletions

View File

@@ -1 +1 @@
v5.0.0+2411232207
v5.0.0+2411232210

View File

@@ -74,5 +74,5 @@ func TestDriverExtOCR(t *testing.T) {
checkErr(t, err)
t.Logf("point.X: %v, point.Y: %v", point.X, point.Y)
driverExt.Driver.TapFloat(point.X, point.Y-20)
driverExt.Driver.Tap(point.X, point.Y-20)
}

View File

@@ -315,11 +315,7 @@ func (ad *adbDriver) AppTerminate(packageName string) (successful bool, err erro
return true, nil
}
func (ad *adbDriver) Tap(x, y int, options ...ActionOption) error {
return ad.TapFloat(float64(x), float64(y), options...)
}
func (ad *adbDriver) TapFloat(x, y float64, options ...ActionOption) (err error) {
func (ad *adbDriver) Tap(x, y float64, options ...ActionOption) (err error) {
actionOptions := NewActionOptions(options...)
if len(actionOptions.Offset) == 2 {
@@ -663,7 +659,7 @@ func (ad *adbDriver) tapByTextUsingHierarchy(hierarchy *Hierarchy, text string,
}
for _, bound := range bounds {
width, height := bound.Center()
err := ad.TapFloat(width, height, options...)
err := ad.Tap(width, height, options...)
if err != nil {
return err
}

View File

@@ -225,7 +225,7 @@ func TestDriver_Tap(t *testing.T) {
}
//time.Sleep(time.Second)
//
//err = driverExt.Driver.TapFloat(60.5, 125.5, WithIdentifier("test"))
//err = driverExt.Driver.Tap(60.5, 125.5, WithIdentifier("test"))
//if err != nil {
// t.Fatal(err)
//}

View File

@@ -320,11 +320,7 @@ func (ud *uiaDriver) DoubleFloatTap(x, y float64) error {
return err
}
func (ud *uiaDriver) Tap(x, y int, options ...ActionOption) error {
return ud.TapFloat(float64(x), float64(y), options...)
}
func (ud *uiaDriver) TapFloat(x, y float64, options ...ActionOption) (err error) {
func (ud *uiaDriver) Tap(x, y float64, options ...ActionOption) (err error) {
// register(postHandler, new Tap("/wd/hub/session/:sessionId/appium/tap"))
actionOptions := NewActionOptions(options...)

View File

@@ -154,11 +154,7 @@ func (hd *hdcDriver) Orientation() (orientation Orientation, err error) {
return OrientationPortrait, nil
}
func (hd *hdcDriver) Tap(x, y int, options ...ActionOption) error {
return hd.TapFloat(float64(x), float64(y), options...)
}
func (hd *hdcDriver) TapFloat(x, y float64, options ...ActionOption) error {
func (hd *hdcDriver) Tap(x, y float64, options ...ActionOption) error {
actionOptions := NewActionOptions(options...)
if len(actionOptions.Offset) == 2 {

View File

@@ -577,8 +577,7 @@ type IWebDriver interface {
Orientation() (orientation Orientation, err error)
// Tap Sends a tap event at the coordinate.
Tap(x, y int, options ...ActionOption) error
TapFloat(x, y float64, options ...ActionOption) error
Tap(x, y float64, options ...ActionOption) error
// DoubleTap Sends a double tap event at the coordinate.
DoubleTap(x, y float64, options ...ActionOption) error

View File

@@ -495,11 +495,7 @@ func (wd *wdaDriver) AssertForegroundApp(bundleId string, viewControllerType ...
return nil
}
func (wd *wdaDriver) Tap(x, y int, options ...ActionOption) error {
return wd.TapFloat(float64(x), float64(y), options...)
}
func (wd *wdaDriver) TapFloat(x, y float64, options ...ActionOption) (err error) {
func (wd *wdaDriver) Tap(x, y float64, options ...ActionOption) (err error) {
// [[FBRoute POST:@"/wda/tap/:uuid"] respondWithTarget:self action:@selector(handleTap:)]
actionOptions := NewActionOptions(options...)
@@ -548,7 +544,7 @@ func (wd *wdaDriver) TouchAndHold(x, y float64, options ...ActionOption) (err er
if actionOptions.Duration == 0 {
options = append(options, WithDuration(1))
}
return wd.TapFloat(x, y, options...)
return wd.Tap(x, y, options...)
}
func (wd *wdaDriver) Drag(fromX, fromY, toX, toY float64, options ...ActionOption) (err error) {

View File

@@ -219,7 +219,7 @@ func (s *stubIOSDriver) Orientation() (orientation Orientation, err error) {
}
// Tap Sends a tap event at the coordinate.
func (s *stubIOSDriver) Tap(x, y int, options ...ActionOption) error {
func (s *stubIOSDriver) Tap(x, y float64, options ...ActionOption) error {
err := s.setUpWda()
if err != nil {
return err
@@ -227,14 +227,6 @@ func (s *stubIOSDriver) Tap(x, y int, options ...ActionOption) error {
return s.wdaDriver.Tap(x, y, options...)
}
func (s *stubIOSDriver) TapFloat(x, y float64, options ...ActionOption) error {
err := s.setUpWda()
if err != nil {
return err
}
return s.wdaDriver.TapFloat(x, y, options...)
}
// DoubleTap Sends a double tap event at the coordinate.
func (s *stubIOSDriver) DoubleTap(x, y float64, options ...ActionOption) error {
err := s.setUpWda()

View File

@@ -10,7 +10,7 @@ import (
func (dExt *DriverExt) TapAbsXY(x, y float64, options ...ActionOption) error {
// tap on absolute coordinate [x, y]
err := dExt.Driver.TapFloat(x, y, options...)
err := dExt.Driver.Tap(x, y, options...)
if err != nil {
return errors.Wrap(code.MobileUITapError, err.Error())
}