mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-09 17:59:36 +08:00
refactor: android ui automation
This commit is contained in:
@@ -44,11 +44,15 @@ func InitUIAClient(device *AndroidDevice) (*DriverExt, error) {
|
||||
fmt.Println(driver)
|
||||
|
||||
var driverExt *DriverExt
|
||||
// TODO
|
||||
// driverExt, err = Extend(driver)
|
||||
// if err != nil {
|
||||
// return nil, errors.Wrap(err, "failed to extend UIA Driver")
|
||||
// }
|
||||
|
||||
driverExt, err = Extend(driver)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to extend UIA Driver")
|
||||
}
|
||||
|
||||
if device.LogOn {
|
||||
// TODO
|
||||
}
|
||||
|
||||
return driverExt, nil
|
||||
}
|
||||
@@ -61,6 +65,12 @@ func WithSerialNumber(serial string) AndroidDeviceOption {
|
||||
}
|
||||
}
|
||||
|
||||
func WithMjpegPortA(port int) AndroidDeviceOption {
|
||||
return func(device *AndroidDevice) {
|
||||
device.MjpegPort = port
|
||||
}
|
||||
}
|
||||
|
||||
func WithAdbIP(ip string) AndroidDeviceOption {
|
||||
return func(device *AndroidDevice) {
|
||||
device.IP = ip
|
||||
@@ -113,6 +123,7 @@ type AndroidDevice struct {
|
||||
SerialNumber string `json:"serial,omitempty" yaml:"serial,omitempty"`
|
||||
IP string `json:"ip,omitempty" yaml:"ip,omitempty"`
|
||||
Port int `json:"port,omitempty" yaml:"port,omitempty"`
|
||||
MjpegPort int `json:"mjpeg_port,omitempty" yaml:"mjpeg_port,omitempty"`
|
||||
LogOn bool `json:"log_on,omitempty" yaml:"log_on,omitempty"`
|
||||
}
|
||||
|
||||
@@ -149,12 +160,6 @@ func (dev *AndroidDevice) NewUSBDriver(capabilities Capabilities) (driver *uiaDr
|
||||
driver.adbDevice = dev.d
|
||||
driver.localPort = localPort
|
||||
|
||||
conn, err := net.Dial("tcp", fmt.Sprintf(":%d", localPort))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("adb forward: %w", err)
|
||||
}
|
||||
driver.client = convertToHTTPClient(conn)
|
||||
|
||||
return driver, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user