diff --git a/uixt/android_test.go b/uixt/android_test.go index af76109d..794b9160 100644 --- a/uixt/android_test.go +++ b/uixt/android_test.go @@ -16,29 +16,47 @@ import ( ) func setupADBDriverExt(t *testing.T) *XTDriver { - device, err := NewAndroidDevice() - require.Nil(t, err) - device.Options.UIA2 = false - device.Options.LogOn = false - driver, err := device.NewDriver() - require.Nil(t, err) - driverExt, err := NewXTDriver(driver, - option.WithCVService(option.CVServiceTypeVEDEM), - // option.WithLLMService(option.DOUBAO_1_5_UI_TARS_250328), - ) + config := DriverCacheConfig{ + Platform: "android", + Serial: "", // Let it auto-detect the device serial + AIOptions: []option.AIServiceOption{ + option.WithCVService(option.CVServiceTypeVEDEM), + option.WithLLMConfig( + option.NewLLMServiceConfig(option.DOUBAO_1_5_UI_TARS_250328). + WithPlannerModel(option.WINGS_SERVICE). + WithAsserterModel(option.WINGS_SERVICE), + ), + }, + } + + driverExt, err := GetOrCreateXTDriver(config) require.Nil(t, err) return driverExt } func setupUIA2DriverExt(t *testing.T) *XTDriver { - device, err := NewAndroidDevice() - require.Nil(t, err) - device.Options.UIA2 = true // use uiautomator2 driver - device.Options.LogOn = false - driver, err := device.NewDriver() - require.Nil(t, err) - driverExt, err := NewXTDriver(driver, - option.WithCVService(option.CVServiceTypeVEDEM)) + // Use cache mechanism with UIA2 enabled + deviceOpts := option.NewDeviceOptions( + option.WithPlatform("android"), + option.WithDeviceUIA2(true), + option.WithDeviceLogOn(false), + ) + + config := DriverCacheConfig{ + Platform: "android", + Serial: "", // Let it auto-detect the device serial + DeviceOpts: deviceOpts, + AIOptions: []option.AIServiceOption{ + option.WithCVService(option.CVServiceTypeVEDEM), + option.WithLLMConfig( + option.NewLLMServiceConfig(option.DOUBAO_1_5_UI_TARS_250328). + WithPlannerModel(option.WINGS_SERVICE). + WithAsserterModel(option.WINGS_SERVICE), + ), + }, + } + + driverExt, err := GetOrCreateXTDriver(config) require.Nil(t, err) return driverExt } diff --git a/uixt/harmony_test.go b/uixt/harmony_test.go index dff5f75b..71dfb440 100644 --- a/uixt/harmony_test.go +++ b/uixt/harmony_test.go @@ -5,17 +5,28 @@ package uixt import ( "testing" - "github.com/httprunner/httprunner/v5/uixt/option" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/httprunner/httprunner/v5/uixt/option" ) func setupHDCDriverExt(t *testing.T) *XTDriver { - device, err := NewHarmonyDevice() - require.Nil(t, err) - hdcDriver, err := NewHDCDriver(device) - require.Nil(t, err) - driverExt, err := NewXTDriver(hdcDriver, option.WithCVService(option.CVServiceTypeVEDEM)) + // Use cache mechanism for Harmony HDC driver + config := DriverCacheConfig{ + Platform: "harmony", + Serial: "", // Let it auto-detect the device serial + AIOptions: []option.AIServiceOption{ + option.WithCVService(option.CVServiceTypeVEDEM), + option.WithLLMConfig( + option.NewLLMServiceConfig(option.DOUBAO_1_5_UI_TARS_250328). + WithPlannerModel(option.WINGS_SERVICE). + WithAsserterModel(option.WINGS_SERVICE), + ), + }, + } + + driverExt, err := GetOrCreateXTDriver(config) require.Nil(t, err) return driverExt } diff --git a/uixt/ios_test.go b/uixt/ios_test.go index 55283f3f..0a0bbde0 100644 --- a/uixt/ios_test.go +++ b/uixt/ios_test.go @@ -16,14 +16,29 @@ import ( ) func setupWDADriverExt(t *testing.T) *XTDriver { - device, err := NewIOSDevice( - option.WithWDAPort(8700), - option.WithWDAMjpegPort(8800), - option.WithWDALogOn(true)) - require.Nil(t, err) - driver, err := device.NewDriver() - require.Nil(t, err) - driverExt, err := NewXTDriver(driver, option.WithCVService(option.CVServiceTypeVEDEM)) + // Use cache mechanism with unified DeviceOptions for iOS WDA driver + deviceOpts := option.NewDeviceOptions( + option.WithPlatform("ios"), + option.WithDeviceWDAPort(8700), + option.WithDeviceWDAMjpegPort(8800), + option.WithDeviceLogOn(true), + ) + + config := DriverCacheConfig{ + Platform: "ios", + Serial: "", // Let it auto-detect the device serial + DeviceOpts: deviceOpts, + AIOptions: []option.AIServiceOption{ + option.WithCVService(option.CVServiceTypeVEDEM), + option.WithLLMConfig( + option.NewLLMServiceConfig(option.DOUBAO_1_5_UI_TARS_250328). + WithPlannerModel(option.WINGS_SERVICE). + WithAsserterModel(option.WINGS_SERVICE), + ), + }, + } + + driverExt, err := GetOrCreateXTDriver(config) require.Nil(t, err) return driverExt }