fix: stop logcat only when enabled

This commit is contained in:
lilong.129
2023-02-13 23:34:09 +08:00
parent cdee2babd7
commit 4db263db15
4 changed files with 18 additions and 6 deletions

View File

@@ -138,6 +138,10 @@ func (dev *AndroidDevice) UUID() string {
return dev.SerialNumber
}
func (dev *AndroidDevice) LogEnabled() bool {
return dev.LogOn
}
func (dev *AndroidDevice) NewDriver(capabilities Capabilities) (driverExt *DriverExt, err error) {
var driver WebDriver
if dev.UIA2 {

View File

@@ -581,6 +581,7 @@ func NewData(data map[string]interface{}, options ...DataOption) map[string]inte
// current implemeted device: IOSDevice, AndroidDevice
type Device interface {
UUID() string // ios udid or android serial
LogEnabled() bool
NewDriver(capabilities Capabilities) (driverExt *DriverExt, err error)
StartPerf() error

View File

@@ -281,6 +281,10 @@ func (dev *IOSDevice) UUID() string {
return dev.UDID
}
func (dev *IOSDevice) LogEnabled() bool {
return dev.LogOn
}
func (dev *IOSDevice) NewDriver(capabilities Capabilities) (driverExt *DriverExt, err error) {
// init WDA driver
if capabilities == nil {

View File

@@ -625,13 +625,16 @@ func (r *SessionRunner) GetSummary() (*TestCaseSummary, error) {
for uuid, client := range r.caseRunner.hrpRunner.uiClients {
// add WDA/UIA logs to summary
log, err := client.Driver.StopCaptureLog()
if err != nil {
return caseSummary, err
}
logs := map[string]interface{}{
"uuid": uuid,
"content": log,
"uuid": uuid,
}
if client.Device.LogEnabled() {
log, err := client.Driver.StopCaptureLog()
if err != nil {
return caseSummary, err
}
logs["content"] = log
}
// stop performance monitor