refactor: move ios options to pkg/uixt/options

This commit is contained in:
lilong.129
2025-02-06 14:54:10 +08:00
parent 0c5b60b94a
commit 14c81ea142
25 changed files with 203 additions and 186 deletions

View File

@@ -5,6 +5,7 @@ import (
"github.com/httprunner/httprunner/v5/internal/builtin"
"github.com/httprunner/httprunner/v5/pkg/uixt"
"github.com/httprunner/httprunner/v5/pkg/uixt/options"
)
type IConfig interface {
@@ -117,23 +118,23 @@ func (c *TConfig) SetWebSocket(times, interval, timeout, size int64) *TConfig {
return c
}
func (c *TConfig) SetIOS(options ...uixt.IOSDeviceOption) *TConfig {
wdaOptions := &uixt.IOSDevice{}
for _, option := range options {
option(wdaOptions)
func (c *TConfig) SetIOS(opts ...options.IOSDeviceOption) *TConfig {
iosOptions := options.NewIOSDeviceConfig(opts...)
device := &uixt.IOSDevice{
IOSDeviceConfig: iosOptions,
}
// each device can have its own settings
if wdaOptions.UDID != "" {
c.IOS = append(c.IOS, wdaOptions)
if iosOptions.UDID != "" {
c.IOS = append(c.IOS, device)
return c
}
// device UDID is not specified, settings will be shared
if len(c.IOS) == 0 {
c.IOS = append(c.IOS, wdaOptions)
c.IOS = append(c.IOS, device)
} else {
c.IOS[0] = wdaOptions
c.IOS[0] = device
}
return c
}