mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-07 08:49:37 +08:00
feat: lazy setup WDA
This commit is contained in:
@@ -1 +1 @@
|
|||||||
v5.0.0+2502191537
|
v5.0.0+2502191654
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func NewStubIOSDriver(dev *uixt.IOSDevice) (*StubIOSDriver, error) {
|
func NewStubIOSDriver(dev *uixt.IOSDevice) (*StubIOSDriver, error) {
|
||||||
|
// lazy setup WDA
|
||||||
|
dev.Options.LazySetup = true
|
||||||
|
|
||||||
wdaDriver, err := uixt.NewWDADriver(dev)
|
wdaDriver, err := uixt.NewWDADriver(dev)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -37,9 +37,11 @@ func NewWDADriver(device *IOSDevice) (*WDADriver, error) {
|
|||||||
Session: NewDriverSession(),
|
Session: NewDriverSession(),
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup driver
|
if !device.Options.LazySetup {
|
||||||
if err := driver.Setup(); err != nil {
|
// setup driver
|
||||||
return nil, err
|
if err := driver.Setup(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// register driver session reset handler
|
// register driver session reset handler
|
||||||
|
|||||||
@@ -33,6 +33,20 @@ func TestDevice_IOS_Install(t *testing.T) {
|
|||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDriver_WDA_LazySetup(t *testing.T) {
|
||||||
|
device, err := NewIOSDevice(
|
||||||
|
option.WithWDAPort(8700),
|
||||||
|
option.WithWDAMjpegPort(8800),
|
||||||
|
option.WithLazySetup(true))
|
||||||
|
require.Nil(t, err)
|
||||||
|
driver, err := NewWDADriver(device)
|
||||||
|
require.Nil(t, err)
|
||||||
|
err = driver.PressButton(types.DeviceButtonHome)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
err = driver.TapXY(0.5, 0.5)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
func TestDevice_IOS_New(t *testing.T) {
|
func TestDevice_IOS_New(t *testing.T) {
|
||||||
device, err := NewIOSDevice(
|
device, err := NewIOSDevice(
|
||||||
option.WithWDAPort(8700),
|
option.WithWDAPort(8700),
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ type IOSDeviceOptions struct {
|
|||||||
WDAPort int `json:"port,omitempty" yaml:"port,omitempty"` // WDA remote port
|
WDAPort int `json:"port,omitempty" yaml:"port,omitempty"` // WDA remote port
|
||||||
WDAMjpegPort int `json:"mjpeg_port,omitempty" yaml:"mjpeg_port,omitempty"` // WDA remote MJPEG port
|
WDAMjpegPort int `json:"mjpeg_port,omitempty" yaml:"mjpeg_port,omitempty"` // WDA remote MJPEG port
|
||||||
LogOn bool `json:"log_on,omitempty" yaml:"log_on,omitempty"`
|
LogOn bool `json:"log_on,omitempty" yaml:"log_on,omitempty"`
|
||||||
|
LazySetup bool `json:"lazy_setup,omitempty" yaml:"lazy_setup,omitempty"` // lazy setup WDA
|
||||||
|
|
||||||
// switch to iOS springboard before init WDA session
|
// switch to iOS springboard before init WDA session
|
||||||
ResetHomeOnStartup bool `json:"reset_home_on_startup,omitempty" yaml:"reset_home_on_startup,omitempty"`
|
ResetHomeOnStartup bool `json:"reset_home_on_startup,omitempty" yaml:"reset_home_on_startup,omitempty"`
|
||||||
@@ -28,6 +29,9 @@ func (dev *IOSDeviceOptions) Options() (deviceOptions []IOSDeviceOption) {
|
|||||||
if dev.LogOn {
|
if dev.LogOn {
|
||||||
deviceOptions = append(deviceOptions, WithWDALogOn(true))
|
deviceOptions = append(deviceOptions, WithWDALogOn(true))
|
||||||
}
|
}
|
||||||
|
if dev.LazySetup {
|
||||||
|
deviceOptions = append(deviceOptions, WithLazySetup(true))
|
||||||
|
}
|
||||||
if dev.ResetHomeOnStartup {
|
if dev.ResetHomeOnStartup {
|
||||||
deviceOptions = append(deviceOptions, WithResetHomeOnStartup(true))
|
deviceOptions = append(deviceOptions, WithResetHomeOnStartup(true))
|
||||||
}
|
}
|
||||||
@@ -115,6 +119,12 @@ func WithWDALogOn(logOn bool) IOSDeviceOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func WithLazySetup(lazySetup bool) IOSDeviceOption {
|
||||||
|
return func(device *IOSDeviceOptions) {
|
||||||
|
device.LazySetup = lazySetup
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func WithResetHomeOnStartup(reset bool) IOSDeviceOption {
|
func WithResetHomeOnStartup(reset bool) IOSDeviceOption {
|
||||||
return func(device *IOSDeviceOptions) {
|
return func(device *IOSDeviceOptions) {
|
||||||
device.ResetHomeOnStartup = reset
|
device.ResetHomeOnStartup = reset
|
||||||
|
|||||||
Reference in New Issue
Block a user