mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-07 23:41:22 +08:00
refactor: merge Swipe and SwipeFloat
This commit is contained in:
@@ -1 +1 @@
|
|||||||
v5.0.0+2411232206
|
v5.0.0+2411232207
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ func dragHandler(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
err := dExt.Driver.SwipeFloat(
|
err := dExt.Driver.Swipe(
|
||||||
dragReq.FromX, dragReq.FromY, dragReq.ToX, dragReq.ToY,
|
dragReq.FromX, dragReq.FromY, dragReq.ToX, dragReq.ToY,
|
||||||
actionOptions...)
|
actionOptions...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -418,11 +418,7 @@ func (ad *adbDriver) Drag(fromX, fromY, toX, toY float64, options ...ActionOptio
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ad *adbDriver) Swipe(fromX, fromY, toX, toY int, options ...ActionOption) error {
|
func (ad *adbDriver) Swipe(fromX, fromY, toX, toY float64, options ...ActionOption) error {
|
||||||
return ad.SwipeFloat(float64(fromX), float64(fromY), float64(toX), float64(toY), options...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ad *adbDriver) SwipeFloat(fromX, fromY, toX, toY float64, options ...ActionOption) error {
|
|
||||||
actionOptions := NewActionOptions(options...)
|
actionOptions := NewActionOptions(options...)
|
||||||
|
|
||||||
if len(actionOptions.Offset) == 4 {
|
if len(actionOptions.Offset) == 4 {
|
||||||
|
|||||||
@@ -417,11 +417,7 @@ func (ud *uiaDriver) Drag(fromX, fromY, toX, toY float64, options ...ActionOptio
|
|||||||
// per step. So for a 100 steps, the swipe will take about 1/2 second to complete.
|
// per step. So for a 100 steps, the swipe will take about 1/2 second to complete.
|
||||||
//
|
//
|
||||||
// `steps` is the number of move steps sent to the system
|
// `steps` is the number of move steps sent to the system
|
||||||
func (ud *uiaDriver) Swipe(fromX, fromY, toX, toY int, options ...ActionOption) error {
|
func (ud *uiaDriver) Swipe(fromX, fromY, toX, toY float64, options ...ActionOption) error {
|
||||||
return ud.SwipeFloat(float64(fromX), float64(fromY), float64(toX), float64(toY), options...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ud *uiaDriver) SwipeFloat(fromX, fromY, toX, toY float64, options ...ActionOption) error {
|
|
||||||
// register(postHandler, new Swipe("/wd/hub/session/:sessionId/touch/perform"))
|
// register(postHandler, new Swipe("/wd/hub/session/:sessionId/touch/perform"))
|
||||||
actionOptions := NewActionOptions(options...)
|
actionOptions := NewActionOptions(options...)
|
||||||
if len(actionOptions.Offset) == 4 {
|
if len(actionOptions.Offset) == 4 {
|
||||||
|
|||||||
@@ -188,11 +188,7 @@ func (hd *hdcDriver) Drag(fromX, fromY, toX, toY float64, options ...ActionOptio
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Swipe works like Drag, but `pressForDuration` value is 0
|
// Swipe works like Drag, but `pressForDuration` value is 0
|
||||||
func (hd *hdcDriver) Swipe(fromX, fromY, toX, toY int, options ...ActionOption) error {
|
func (hd *hdcDriver) Swipe(fromX, fromY, toX, toY float64, options ...ActionOption) error {
|
||||||
return hd.SwipeFloat(float64(fromX), float64(fromY), float64(toX), float64(toY), options...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (hd *hdcDriver) SwipeFloat(fromX, fromY, toX, toY float64, options ...ActionOption) error {
|
|
||||||
actionOptions := NewActionOptions(options...)
|
actionOptions := NewActionOptions(options...)
|
||||||
if len(actionOptions.Offset) == 4 {
|
if len(actionOptions.Offset) == 4 {
|
||||||
fromX += float64(actionOptions.Offset[0])
|
fromX += float64(actionOptions.Offset[0])
|
||||||
|
|||||||
@@ -592,8 +592,7 @@ type IWebDriver interface {
|
|||||||
Drag(fromX, fromY, toX, toY float64, options ...ActionOption) error
|
Drag(fromX, fromY, toX, toY float64, options ...ActionOption) error
|
||||||
|
|
||||||
// Swipe works like Drag, but `pressForDuration` value is 0
|
// Swipe works like Drag, but `pressForDuration` value is 0
|
||||||
Swipe(fromX, fromY, toX, toY int, options ...ActionOption) error
|
Swipe(fromX, fromY, toX, toY float64, options ...ActionOption) error
|
||||||
SwipeFloat(fromX, fromY, toX, toY float64, options ...ActionOption) error
|
|
||||||
|
|
||||||
// SetPasteboard Sets data to the general pasteboard
|
// SetPasteboard Sets data to the general pasteboard
|
||||||
SetPasteboard(contentType PasteboardType, content string) error
|
SetPasteboard(contentType PasteboardType, content string) error
|
||||||
|
|||||||
@@ -818,7 +818,9 @@ func (dev *IOSDevice) NewStubDriver() (driver IWebDriver, err error) {
|
|||||||
fmt.Sprintf("forward tcp port failed: %v", err))
|
fmt.Sprintf("forward tcp port failed: %v", err))
|
||||||
}
|
}
|
||||||
host := "localhost"
|
host := "localhost"
|
||||||
stubDriver, err := newStubIOSDriver(fmt.Sprintf("http://%s:%d", host, localStubPort), fmt.Sprintf("http://%s:%d", host, localServerPort), dev)
|
stubDriver, err := newStubIOSDriver(
|
||||||
|
fmt.Sprintf("http://%s:%d", host, localStubPort),
|
||||||
|
fmt.Sprintf("http://%s:%d", host, localServerPort), dev)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -588,11 +588,7 @@ func (wd *wdaDriver) Drag(fromX, fromY, toX, toY float64, options ...ActionOptio
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wd *wdaDriver) Swipe(fromX, fromY, toX, toY int, options ...ActionOption) error {
|
func (wd *wdaDriver) Swipe(fromX, fromY, toX, toY float64, options ...ActionOption) error {
|
||||||
return wd.SwipeFloat(float64(fromX), float64(fromY), float64(toX), float64(toY), options...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (wd *wdaDriver) SwipeFloat(fromX, fromY, toX, toY float64, options ...ActionOption) error {
|
|
||||||
return wd.Drag(fromX, fromY, toX, toY, options...)
|
return wd.Drag(fromX, fromY, toX, toY, options...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -265,23 +265,6 @@ func (s *stubIOSDriver) Drag(fromX, fromY, toX, toY float64, options ...ActionOp
|
|||||||
return s.wdaDriver.Drag(fromX, fromY, toX, toY, options...)
|
return s.wdaDriver.Drag(fromX, fromY, toX, toY, options...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Swipe works like Drag, but `pressForDuration` value is 0
|
|
||||||
func (s *stubIOSDriver) Swipe(fromX, fromY, toX, toY int, options ...ActionOption) error {
|
|
||||||
err := s.setUpWda()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return s.wdaDriver.Swipe(fromX, fromY, toX, toY, options...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *stubIOSDriver) SwipeFloat(fromX, fromY, toX, toY float64, options ...ActionOption) error {
|
|
||||||
err := s.setUpWda()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return s.wdaDriver.SwipeFloat(fromX, fromY, toX, toY, options...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetPasteboard Sets data to the general pasteboard
|
// SetPasteboard Sets data to the general pasteboard
|
||||||
func (s *stubIOSDriver) SetPasteboard(contentType PasteboardType, content string) error {
|
func (s *stubIOSDriver) SetPasteboard(contentType PasteboardType, content string) error {
|
||||||
err := s.setUpWda()
|
err := s.setUpWda()
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func (dExt *DriverExt) SwipeRelative(fromX, fromY, toX, toY float64, options ...
|
|||||||
fromY = float64(height) * fromY
|
fromY = float64(height) * fromY
|
||||||
toX = float64(width) * toX
|
toX = float64(width) * toX
|
||||||
toY = float64(height) * toY
|
toY = float64(height) * toY
|
||||||
err = dExt.Driver.SwipeFloat(fromX, fromY, toX, toY, options...)
|
err = dExt.Driver.Swipe(fromX, fromY, toX, toY, options...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(code.MobileUISwipeError, err.Error())
|
return errors.Wrap(code.MobileUISwipeError, err.Error())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user