mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-26 10:01:28 +08:00
Merge branch 'feat/caoshuai.1900/doubleTap' into 'master'
feat: android double tap See merge request iesqa/httprunner!48
This commit is contained in:
@@ -295,8 +295,21 @@ func (ad *adbDriver) DoubleTap(x, y int) error {
|
||||
}
|
||||
|
||||
func (ad *adbDriver) DoubleTapFloat(x, y float64) (err error) {
|
||||
err = errDriverNotImplemented
|
||||
return
|
||||
// adb shell input tap x y
|
||||
xStr := fmt.Sprintf("%.1f", x)
|
||||
yStr := fmt.Sprintf("%.1f", y)
|
||||
_, err = ad.adbClient.RunShellCommand(
|
||||
"input", "tap", xStr, yStr)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("tap <%s, %s> failed", xStr, yStr))
|
||||
}
|
||||
time.Sleep(time.Duration(100) * time.Millisecond)
|
||||
_, err = ad.adbClient.RunShellCommand(
|
||||
"input", "tap", xStr, yStr)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("tap <%s, %s> failed", xStr, yStr))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ad *adbDriver) TouchAndHold(x, y int, second ...float64) (err error) {
|
||||
|
||||
@@ -195,10 +195,6 @@ func (dev *AndroidDevice) Init() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dev *AndroidDevice) System() string {
|
||||
return "android"
|
||||
}
|
||||
|
||||
func (dev *AndroidDevice) UUID() string {
|
||||
return dev.SerialNumber
|
||||
}
|
||||
|
||||
@@ -286,6 +286,32 @@ func (ud *uiaDriver) Orientation() (orientation Orientation, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (ud *uiaDriver) DoubleTap(x, y int) error {
|
||||
return ud.DoubleFloatTap(float64(x), float64(y))
|
||||
}
|
||||
|
||||
func (ud *uiaDriver) DoubleFloatTap(x, y float64) error {
|
||||
data := map[string]interface{}{
|
||||
"actions": []interface{}{
|
||||
map[string]interface{}{
|
||||
"type": "pointer",
|
||||
"parameters": map[string]string{"pointerType": "touch"},
|
||||
"id": "touch",
|
||||
"actions": []interface{}{
|
||||
map[string]interface{}{"type": "pointerMove", "duration": 0, "x": x, "y": y, "origin": "viewport"},
|
||||
map[string]interface{}{"type": "pointerDown", "duration": 0, "button": 0},
|
||||
map[string]interface{}{"type": "pointerUp", "duration": 0, "button": 0},
|
||||
map[string]interface{}{"type": "pointerDown", "duration": 0, "button": 0},
|
||||
map[string]interface{}{"type": "pointerUp", "duration": 0, "button": 0},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
_, err := ud.httpPOST(data, "/session", ud.sessionId, "actions/tap")
|
||||
return err
|
||||
}
|
||||
|
||||
func (ud *uiaDriver) Tap(x, y int, options ...ActionOption) error {
|
||||
return ud.TapFloat(float64(x), float64(y), options...)
|
||||
}
|
||||
|
||||
@@ -457,9 +457,10 @@ func (vc *VideoCrawler) getCurrentVideo() (video *Video, err error) {
|
||||
}
|
||||
|
||||
func (vc *VideoCrawler) getLivePreviewProb() float64 {
|
||||
if vc.driverExt.Device.System() == "ios" {
|
||||
if _, ok := vc.driverExt.Device.(*IOSDevice); ok {
|
||||
return 0.5326
|
||||
} else if vc.driverExt.Device.System() == "android" {
|
||||
}
|
||||
if _, ok := vc.driverExt.Device.(*AndroidDevice); ok {
|
||||
return 0.3414
|
||||
}
|
||||
return -1
|
||||
|
||||
Reference in New Issue
Block a user