mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 11:29:48 +08:00
fix: update interface of recording adb logs
This commit is contained in:
@@ -68,7 +68,10 @@ func InitUIAClient(device *AndroidDevice) (*DriverExt, error) {
|
||||
}
|
||||
|
||||
if device.LogOn {
|
||||
err = driverExt.StartLogRecording("hrp_adb_log")
|
||||
err = driverExt.Driver.StartCaptureLog("hrp_adb_log")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return driverExt, err
|
||||
|
||||
@@ -947,11 +947,18 @@ func (ud *uiaDriver) Wait(condition Condition) error {
|
||||
}
|
||||
|
||||
func (ud *uiaDriver) StartCaptureLog(identifier ...string) (err error) {
|
||||
// TODO
|
||||
log.Info().Msg("start adb log recording")
|
||||
err = ud.logcat.CatchLogcat()
|
||||
return
|
||||
}
|
||||
|
||||
func (ud *uiaDriver) StopCaptureLog() (result interface{}, err error) {
|
||||
// TODO
|
||||
return
|
||||
log.Info().Msg("stop adb log recording")
|
||||
err = ud.logcat.Stop()
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("failed to get adb log recording")
|
||||
return "", err
|
||||
}
|
||||
content := ud.logcat.logBuffer.String()
|
||||
return ConvertPoints(content), nil
|
||||
}
|
||||
|
||||
@@ -301,45 +301,6 @@ func (dExt *DriverExt) IsImageExist(text string) bool {
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func (dExt *DriverExt) StartLogRecording(identifier string) error {
|
||||
if _, ok := dExt.Driver.(*wdaDriver); ok {
|
||||
log.Info().Msg("start WDA log recording")
|
||||
data := map[string]interface{}{"action": "start", "type": 2, "identifier": identifier}
|
||||
_, err := dExt.triggerWDALog(data)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to start WDA log recording")
|
||||
}
|
||||
} else {
|
||||
log.Info().Msg("start adb log recording")
|
||||
err := dExt.Driver.(*uiaDriver).logcat.CatchLogcat()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to start adb log recording")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dExt *DriverExt) GetLogs() (interface{}, error) {
|
||||
if _, ok := dExt.Driver.(*wdaDriver); ok {
|
||||
log.Info().Msg("stop WDA log recording")
|
||||
data := map[string]interface{}{"action": "stop"}
|
||||
reply, err := dExt.triggerWDALog(data)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "failed to get WDA logs")
|
||||
}
|
||||
return reply.Value, nil
|
||||
} else {
|
||||
log.Info().Msg("stop adb log recording")
|
||||
err := dExt.Driver.(*uiaDriver).logcat.Stop()
|
||||
if err != nil {
|
||||
println("failed to get adb log recording")
|
||||
//return "", errors.Wrap(err, "failed to get adb log recording")
|
||||
}
|
||||
content := dExt.Driver.(*uiaDriver).logcat.logBuffer.String()
|
||||
return ConvertPoints(content), err
|
||||
}
|
||||
}
|
||||
|
||||
var errActionNotImplemented = errors.New("UI action not implemented")
|
||||
|
||||
func (dExt *DriverExt) DoAction(action MobileAction) error {
|
||||
|
||||
Reference in New Issue
Block a user