mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
fix: failed to open camera on android
This commit is contained in:
@@ -238,10 +238,37 @@ func (ud *uiaDriver) PressBack() (err error) {
|
||||
}
|
||||
|
||||
func (ud *uiaDriver) StartCamera() (err error) {
|
||||
if _, err = ud.adbDevice.RunShellCommand("am", "start", "-a", "android.media.action.VIDEO_CAPTURE"); err != nil {
|
||||
if _, err = ud.adbDevice.RunShellCommand("rm", "-r", "/sdcard/DCIM/Camera"); err != nil {
|
||||
return err
|
||||
}
|
||||
return
|
||||
time.Sleep(5 * time.Second)
|
||||
var version string
|
||||
if version, err = ud.adbDevice.RunShellCommand("getprop", "ro.build.version.release"); err != nil {
|
||||
return err
|
||||
}
|
||||
if version == "11" || version == "12" {
|
||||
if _, err = ud.adbDevice.RunShellCommand("am", "start", "-a", "android.media.action.STILL_IMAGE_CAMERA"); err != nil {
|
||||
return err
|
||||
}
|
||||
time.Sleep(5 * time.Second)
|
||||
if _, err = ud.adbDevice.RunShellCommand("input", "swipe", "750", "1000", "250", "1000"); err != nil {
|
||||
return err
|
||||
}
|
||||
time.Sleep(5 * time.Second)
|
||||
if _, err = ud.adbDevice.RunShellCommand("input", "keyevent", "27"); err != nil {
|
||||
return err
|
||||
}
|
||||
return
|
||||
} else {
|
||||
if _, err = ud.adbDevice.RunShellCommand("am", "start", "-a", "android.media.action.VIDEO_CAPTURE"); err != nil {
|
||||
return err
|
||||
}
|
||||
time.Sleep(5 * time.Second)
|
||||
if _, err = ud.adbDevice.RunShellCommand("input", "keyevent", "27"); err != nil {
|
||||
return err
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (ud *uiaDriver) StopCamera() (err error) {
|
||||
@@ -266,24 +293,6 @@ func (ud *uiaDriver) StopCamera() (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (ud *uiaDriver) StartRecording() (err error) {
|
||||
var res string
|
||||
if res, err = ud.adbDevice.RunShellCommand("input", "keyevent", "27"); err != nil {
|
||||
return err
|
||||
}
|
||||
log.Info().Str("shell", res)
|
||||
return
|
||||
}
|
||||
|
||||
func (ud *uiaDriver) StopRecording() (err error) {
|
||||
var res string
|
||||
if res, err = ud.adbDevice.RunShellCommand("input", "keyevent", "27"); err != nil {
|
||||
return err
|
||||
}
|
||||
log.Info().Str("shell", res)
|
||||
return
|
||||
}
|
||||
|
||||
func (ud *uiaDriver) ActiveAppInfo() (info AppInfo, err error) {
|
||||
// TODO
|
||||
return info, errDriverNotImplemented
|
||||
|
||||
@@ -500,10 +500,6 @@ func (dExt *DriverExt) DoAction(action MobileAction) error {
|
||||
return dExt.Driver.StartCamera()
|
||||
case CtlStopCamera:
|
||||
return dExt.Driver.StopCamera()
|
||||
case RecordStart:
|
||||
return dExt.Driver.StartRecording()
|
||||
case RecordStop:
|
||||
return dExt.Driver.StopRecording()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -885,9 +885,6 @@ type WebDriver interface {
|
||||
// StopCamera Stops the camera for recording
|
||||
StopCamera() error
|
||||
|
||||
StartRecording() error
|
||||
StopRecording() error
|
||||
|
||||
// Tap Sends a tap event at the coordinate.
|
||||
Tap(x, y int, options ...DataOption) error
|
||||
TapFloat(x, y float64, options ...DataOption) error
|
||||
|
||||
@@ -579,16 +579,6 @@ func (wd *wdaDriver) StopCamera() (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (wd *wdaDriver) StartRecording() (err error) {
|
||||
// TODO
|
||||
return errDriverNotImplemented
|
||||
}
|
||||
|
||||
func (wd *wdaDriver) StopRecording() (err error) {
|
||||
// TODO
|
||||
return errDriverNotImplemented
|
||||
}
|
||||
|
||||
func (wd *wdaDriver) ExpectNotification(notifyName string, notifyType NotificationType, second ...int) (err error) {
|
||||
// [[FBRoute POST:@"/wda/expectNotification"] respondWithTarget:self action:@selector(handleExpectNotification:)]
|
||||
if len(second) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user