mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-06 15:01:22 +08:00
fix ADBDriver
This commit is contained in:
@@ -1 +1 @@
|
|||||||
v5.0.0+2502102128
|
v5.0.0+2502102158
|
||||||
|
|||||||
@@ -31,15 +31,15 @@ import (
|
|||||||
func NewADBDriver(device *AndroidDevice) (*ADBDriver, error) {
|
func NewADBDriver(device *AndroidDevice) (*ADBDriver, error) {
|
||||||
log.Info().Interface("device", device).Msg("init android adb driver")
|
log.Info().Interface("device", device).Msg("init android adb driver")
|
||||||
driver := &ADBDriver{
|
driver := &ADBDriver{
|
||||||
AndroidDevice: device,
|
Device: device,
|
||||||
Session: &Session{},
|
Session: &Session{},
|
||||||
}
|
}
|
||||||
driver.InitSession(nil)
|
driver.InitSession(nil)
|
||||||
return driver, nil
|
return driver, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type ADBDriver struct {
|
type ADBDriver struct {
|
||||||
*AndroidDevice
|
Device *AndroidDevice
|
||||||
Session *Session
|
Session *Session
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ func (ad *ADBDriver) Status() (deviceStatus types.DeviceStatus, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ad *ADBDriver) GetDevice() IDevice {
|
func (ad *ADBDriver) GetDevice() IDevice {
|
||||||
return ad.AndroidDevice
|
return ad.Device
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ad *ADBDriver) DeviceInfo() (deviceInfo types.DeviceInfo, err error) {
|
func (ad *ADBDriver) DeviceInfo() (deviceInfo types.DeviceInfo, err error) {
|
||||||
@@ -768,7 +768,7 @@ func (ad *ADBDriver) IsHealthy() (healthy bool, err error) {
|
|||||||
func (ad *ADBDriver) StartCaptureLog(identifier ...string) (err error) {
|
func (ad *ADBDriver) StartCaptureLog(identifier ...string) (err error) {
|
||||||
log.Info().Msg("start adb log recording")
|
log.Info().Msg("start adb log recording")
|
||||||
// start logcat
|
// start logcat
|
||||||
err = ad.Logcat.CatchLogcat("iesqaMonitor:V")
|
err = ad.Device.Logcat.CatchLogcat("iesqaMonitor:V")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = errors.Wrap(code.DeviceCaptureLogError,
|
err = errors.Wrap(code.DeviceCaptureLogError,
|
||||||
fmt.Sprintf("start adb log recording failed: %v", err))
|
fmt.Sprintf("start adb log recording failed: %v", err))
|
||||||
@@ -780,7 +780,7 @@ func (ad *ADBDriver) StartCaptureLog(identifier ...string) (err error) {
|
|||||||
func (ad *ADBDriver) StopCaptureLog() (result interface{}, err error) {
|
func (ad *ADBDriver) StopCaptureLog() (result interface{}, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
log.Info().Msg("stop adb log recording")
|
log.Info().Msg("stop adb log recording")
|
||||||
err = ad.Logcat.Stop()
|
err = ad.Device.Logcat.Stop()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("failed to get adb log recording")
|
log.Error().Err(err).Msg("failed to get adb log recording")
|
||||||
}
|
}
|
||||||
@@ -788,7 +788,7 @@ func (ad *ADBDriver) StopCaptureLog() (result interface{}, err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("failed to close adb log writer")
|
log.Error().Err(err).Msg("failed to close adb log writer")
|
||||||
}
|
}
|
||||||
pointRes := ConvertPoints(ad.Logcat.logs)
|
pointRes := ConvertPoints(ad.Device.Logcat.logs)
|
||||||
|
|
||||||
// 没有解析到打点日志,走兜底逻辑
|
// 没有解析到打点日志,走兜底逻辑
|
||||||
if len(pointRes) == 0 {
|
if len(pointRes) == 0 {
|
||||||
|
|||||||
@@ -29,14 +29,14 @@ func NewUIA2Driver(device *AndroidDevice) (*UIA2Driver, error) {
|
|||||||
}
|
}
|
||||||
driver := &UIA2Driver{
|
driver := &UIA2Driver{
|
||||||
ADBDriver: &ADBDriver{
|
ADBDriver: &ADBDriver{
|
||||||
AndroidDevice: device,
|
Device: device,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
err = driver.Session.InitConnection(localPort)
|
err = driver.Session.InitConnection(localPort)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
driver.Logcat = device.Logcat
|
driver.Device.Logcat = device.Logcat
|
||||||
|
|
||||||
err = driver.InitSession(nil)
|
err = driver.InitSession(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -34,12 +34,16 @@ func NewShootsAndroidDriver(device *uixt.AndroidDevice) (driver *ShootsAndroidDr
|
|||||||
log.Err(err).Msg(fmt.Sprintf("failed to connect %s", address))
|
log.Err(err).Msg(fmt.Sprintf("failed to connect %s", address))
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
adbDriver, err := uixt.NewADBDriver(device)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
driver = &ShootsAndroidDriver{
|
driver = &ShootsAndroidDriver{
|
||||||
socket: conn,
|
ADBDriver: adbDriver,
|
||||||
timeout: 10 * time.Second,
|
socket: conn,
|
||||||
|
timeout: 10 * time.Second,
|
||||||
}
|
}
|
||||||
|
|
||||||
driver.InitSession(nil)
|
|
||||||
serverLocalPort, err := device.Device.Forward(douyinServerPort)
|
serverLocalPort, err := device.Device.Forward(douyinServerPort)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(code.DeviceConnectionError,
|
return nil, errors.Wrap(code.DeviceConnectionError,
|
||||||
@@ -50,8 +54,6 @@ func NewShootsAndroidDriver(device *uixt.AndroidDevice) (driver *ShootsAndroidDr
|
|||||||
serverLocalPort, douyinServerPort)
|
serverLocalPort, douyinServerPort)
|
||||||
driver.Session.Init(rawURL)
|
driver.Session.Init(rawURL)
|
||||||
|
|
||||||
driver.Device = device.Device
|
|
||||||
driver.Logcat = device.Logcat
|
|
||||||
return driver, nil
|
return driver, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user