change: update annotation

This commit is contained in:
xucong.053
2022-11-10 13:14:12 +08:00
parent 85ff696f47
commit 5e00895f76
3 changed files with 23 additions and 12 deletions

View File

@@ -18,6 +18,17 @@ import (
"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")
type uiaDriver struct {
@@ -237,7 +248,7 @@ func (ud *uiaDriver) PressBack(options ...DataOption) (err error) {
// register(postHandler, new PressBack("/wd/hub/session/:sessionId/back"))
_, err = ud.httpPOST(nil, "/session", ud.sessionId, "back")
if err != nil {
_, err = ud.adbDevice.RunShellCommand("input", "keyevent", "4")
_, err = ud.adbDevice.RunShellCommand("input", "keyevent", KEYCODE_BACK)
}
return
}
@@ -260,7 +271,7 @@ func (ud *uiaDriver) StartCamera() (err error) {
return err
}
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
@@ -269,7 +280,7 @@ func (ud *uiaDriver) StartCamera() (err error) {
return err
}
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

View File

@@ -673,10 +673,10 @@ func (dExt *DriverExt) DoAction(action MobileAction) error {
}
func (dExt *DriverExt) getAbsScope(x1, y1, x2, y2 float64) (int, int, int, int) {
return int(x1 * float64(dExt.windowSize.Width)),
int(y1 * float64(dExt.windowSize.Height)),
int(x2 * float64(dExt.windowSize.Width)),
int(y2 * float64(dExt.windowSize.Height))
return int(x1 * float64(dExt.windowSize.Width) * dExt.scale),
int(y1 * float64(dExt.windowSize.Height) * dExt.scale),
int(x2 * float64(dExt.windowSize.Width) * dExt.scale),
int(y2 * float64(dExt.windowSize.Height) * dExt.scale)
}
func (dExt *DriverExt) DoValidation(check, assert, expected string, message ...string) bool {

View File

@@ -22,18 +22,18 @@ const (
var (
WithIdentifier = uixt.WithIdentifier
WithMaxRetryTimes = uixt.WithMaxRetryTimes
WithWaitTime = uixt.WithWaitTime
WithIndex = uixt.WithIndex
WithWaitTime = uixt.WithWaitTime // only applicable to SwipeToTap* action
WithIndex = uixt.WithIndex // index of the target element, should start from 1, only applicable to ocr actions
WithTimeout = uixt.WithTimeout
WithIgnoreNotFoundError = uixt.WithIgnoreNotFoundError
WithText = uixt.WithText
WithID = uixt.WithID
WithDescription = uixt.WithDescription
WithDuration = uixt.WithDuration
WIthSteps = uixt.WithSteps
WithDuration = uixt.WithDuration // only applicable to ios swipe action
WithSteps = uixt.WithSteps // only applicable to android swipe action
WithDirection = uixt.WithDirection
WithCustomDirection = uixt.WithCustomDirection
WithScope = uixt.WithScope
WithScope = uixt.WithScope // only applicable to ocr actions
WithOffset = uixt.WithOffset
)