mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-31 13:29:35 +08:00
change: update annotation
This commit is contained in:
@@ -18,6 +18,17 @@ import (
|
|||||||
"github.com/httprunner/httprunner/v4/hrp/pkg/gadb"
|
"github.com/httprunner/httprunner/v4/hrp/pkg/gadb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// See https://developer.android.com/reference/android/view/KeyEvent
|
||||||
|
const (
|
||||||
|
KEYCODE_BACK string = "4"
|
||||||
|
KEYCODE_CAMERA string = "27"
|
||||||
|
KEYCODE_ALT_LEFT string = "57"
|
||||||
|
KEYCODE_ALT_RIGHT string = "58"
|
||||||
|
KEYCODE_MENU string = "82"
|
||||||
|
KEYCODE_BREAK string = "121"
|
||||||
|
KEYCODE_ALL_APPS string = "284"
|
||||||
|
)
|
||||||
|
|
||||||
var errDriverNotImplemented = errors.New("driver method not implemented")
|
var errDriverNotImplemented = errors.New("driver method not implemented")
|
||||||
|
|
||||||
type uiaDriver struct {
|
type uiaDriver struct {
|
||||||
@@ -237,7 +248,7 @@ func (ud *uiaDriver) PressBack(options ...DataOption) (err error) {
|
|||||||
// register(postHandler, new PressBack("/wd/hub/session/:sessionId/back"))
|
// register(postHandler, new PressBack("/wd/hub/session/:sessionId/back"))
|
||||||
_, err = ud.httpPOST(nil, "/session", ud.sessionId, "back")
|
_, err = ud.httpPOST(nil, "/session", ud.sessionId, "back")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_, err = ud.adbDevice.RunShellCommand("input", "keyevent", "4")
|
_, err = ud.adbDevice.RunShellCommand("input", "keyevent", KEYCODE_BACK)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -260,7 +271,7 @@ func (ud *uiaDriver) StartCamera() (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
if _, err = ud.adbDevice.RunShellCommand("input", "keyevent", "27"); err != nil {
|
if _, err = ud.adbDevice.RunShellCommand("input", "keyevent", KEYCODE_CAMERA); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@@ -269,7 +280,7 @@ func (ud *uiaDriver) StartCamera() (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
if _, err = ud.adbDevice.RunShellCommand("input", "keyevent", "27"); err != nil {
|
if _, err = ud.adbDevice.RunShellCommand("input", "keyevent", KEYCODE_CAMERA); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -673,10 +673,10 @@ func (dExt *DriverExt) DoAction(action MobileAction) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (dExt *DriverExt) getAbsScope(x1, y1, x2, y2 float64) (int, int, int, int) {
|
func (dExt *DriverExt) getAbsScope(x1, y1, x2, y2 float64) (int, int, int, int) {
|
||||||
return int(x1 * float64(dExt.windowSize.Width)),
|
return int(x1 * float64(dExt.windowSize.Width) * dExt.scale),
|
||||||
int(y1 * float64(dExt.windowSize.Height)),
|
int(y1 * float64(dExt.windowSize.Height) * dExt.scale),
|
||||||
int(x2 * float64(dExt.windowSize.Width)),
|
int(x2 * float64(dExt.windowSize.Width) * dExt.scale),
|
||||||
int(y2 * float64(dExt.windowSize.Height))
|
int(y2 * float64(dExt.windowSize.Height) * dExt.scale)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dExt *DriverExt) DoValidation(check, assert, expected string, message ...string) bool {
|
func (dExt *DriverExt) DoValidation(check, assert, expected string, message ...string) bool {
|
||||||
|
|||||||
10
hrp/step.go
10
hrp/step.go
@@ -22,18 +22,18 @@ const (
|
|||||||
var (
|
var (
|
||||||
WithIdentifier = uixt.WithIdentifier
|
WithIdentifier = uixt.WithIdentifier
|
||||||
WithMaxRetryTimes = uixt.WithMaxRetryTimes
|
WithMaxRetryTimes = uixt.WithMaxRetryTimes
|
||||||
WithWaitTime = uixt.WithWaitTime
|
WithWaitTime = uixt.WithWaitTime // only applicable to SwipeToTap* action
|
||||||
WithIndex = uixt.WithIndex
|
WithIndex = uixt.WithIndex // index of the target element, should start from 1, only applicable to ocr actions
|
||||||
WithTimeout = uixt.WithTimeout
|
WithTimeout = uixt.WithTimeout
|
||||||
WithIgnoreNotFoundError = uixt.WithIgnoreNotFoundError
|
WithIgnoreNotFoundError = uixt.WithIgnoreNotFoundError
|
||||||
WithText = uixt.WithText
|
WithText = uixt.WithText
|
||||||
WithID = uixt.WithID
|
WithID = uixt.WithID
|
||||||
WithDescription = uixt.WithDescription
|
WithDescription = uixt.WithDescription
|
||||||
WithDuration = uixt.WithDuration
|
WithDuration = uixt.WithDuration // only applicable to ios swipe action
|
||||||
WIthSteps = uixt.WithSteps
|
WithSteps = uixt.WithSteps // only applicable to android swipe action
|
||||||
WithDirection = uixt.WithDirection
|
WithDirection = uixt.WithDirection
|
||||||
WithCustomDirection = uixt.WithCustomDirection
|
WithCustomDirection = uixt.WithCustomDirection
|
||||||
WithScope = uixt.WithScope
|
WithScope = uixt.WithScope // only applicable to ocr actions
|
||||||
WithOffset = uixt.WithOffset
|
WithOffset = uixt.WithOffset
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user