mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-12 16:01:27 +08:00
refactor: NewADBDriver
This commit is contained in:
@@ -38,6 +38,12 @@ func NewAndroidDeviceConfig(opts ...AndroidDeviceOption) *AndroidDeviceConfig {
|
||||
|
||||
type AndroidDeviceOption func(*AndroidDeviceConfig)
|
||||
|
||||
func WithDriverTypeADB() AndroidDeviceOption {
|
||||
return func(device *AndroidDeviceConfig) {
|
||||
device.STUB = false
|
||||
}
|
||||
}
|
||||
|
||||
func WithSerialNumber(serial string) AndroidDeviceOption {
|
||||
return func(device *AndroidDeviceConfig) {
|
||||
device.SerialNumber = serial
|
||||
|
||||
@@ -7,14 +7,12 @@ type DriverOptions struct {
|
||||
Plugin funplugin.IPlugin
|
||||
WithImageService bool
|
||||
WithResultFolder bool
|
||||
WithUIAction bool
|
||||
}
|
||||
|
||||
func NewDriverOptions(opts ...DriverOption) *DriverOptions {
|
||||
driverOptions := &DriverOptions{
|
||||
WithImageService: true,
|
||||
WithResultFolder: true,
|
||||
WithUIAction: true,
|
||||
}
|
||||
for _, option := range opts {
|
||||
option(driverOptions)
|
||||
@@ -42,12 +40,6 @@ func WithDriverResultFolder(withResultFolder bool) DriverOption {
|
||||
}
|
||||
}
|
||||
|
||||
func WithUIAction(withUIAction bool) DriverOption {
|
||||
return func(options *DriverOptions) {
|
||||
options.WithUIAction = withUIAction
|
||||
}
|
||||
}
|
||||
|
||||
func WithDriverPlugin(plugin funplugin.IPlugin) DriverOption {
|
||||
return func(options *DriverOptions) {
|
||||
options.Plugin = plugin
|
||||
|
||||
Reference in New Issue
Block a user