refactor: IDriver

This commit is contained in:
lilong.129
2025-02-11 17:08:25 +08:00
parent 804a2cd90f
commit 0839ef5bd6
22 changed files with 105 additions and 347 deletions

View File

@@ -186,7 +186,7 @@ func TestDriver_Drag(t *testing.T) {
func TestDriver_SendKeys(t *testing.T) {
setupAndroidUIA2Driver(t)
err := driverExt.SendKeys("辽宁省沈阳市新民市民族街36-4",
err := driverExt.Input("辽宁省沈阳市新民市民族街36-4",
option.WithIdentifier("test"))
if err != nil {
t.Fatal(err)
@@ -208,7 +208,7 @@ func TestDriver_SendKeys(t *testing.T) {
}
func TestDriver_PressBack(t *testing.T) {
err := driver.PressBack()
err := driver.Back()
if err != nil {
t.Fatal(err)
}
@@ -227,7 +227,7 @@ func TestDriver_GetOrientation(t *testing.T) {
_, _ = driverExt.AppTerminate("com.quark.browser")
_ = driverExt.AppLaunch("com.quark.browser")
time.Sleep(2 * time.Second)
_ = driverExt.Homescreen()
_ = driverExt.Home()
}
func Test_getFreePort(t *testing.T) {
@@ -265,7 +265,7 @@ func TestDriver_IsAppInForeground(t *testing.T) {
err := driverExt.AppLaunch("com.android.settings")
checkErr(t, err)
app, err := driverExt.GetForegroundApp()
app, err := driverExt.ForegroundInfo()
checkErr(t, err)
if app.PackageName != "com.android.settings" {
t.FailNow()
@@ -273,22 +273,6 @@ func TestDriver_IsAppInForeground(t *testing.T) {
if app.Activity != ".Settings" {
t.FailNow()
}
err = driverExt.AssertForegroundApp("com.android.settings")
if err != nil {
t.Fatal(err)
}
time.Sleep(2 * time.Second)
_, err = driverExt.AppTerminate("com.android.settings")
if err != nil {
t.Fatal(err)
}
err = driverExt.AssertForegroundApp("com.android.settings")
if err == nil {
t.Fatal(err)
}
}
func TestDriver_KeepAlive(t *testing.T) {
@@ -345,7 +329,7 @@ func TestDriver_ShellInputUnicode(t *testing.T) {
t.Fatal(err)
}
err = driver.SendKeys("test中文输入&")
err = driver.Input("test中文输入&")
if err != nil {
t.Fatal(err)
}