feat: add validator AssertAppInForeground and AssertAppNotInForeground

This commit is contained in:
lilong.129
2023-04-16 18:50:21 +08:00
parent 2249cfab9e
commit 2644c24fae
7 changed files with 97 additions and 14 deletions

View File

@@ -28,7 +28,15 @@
"params": 10
}
]
}
},
"validate": [
{
"check": "ui_foreground_app",
"assert": "equal",
"expect": "com.ss.android.ugc.aweme",
"msg": "app [com.ss.android.ugc.aweme] should be in foreground"
}
]
},
{
"name": "处理青少年弹窗",
@@ -102,6 +110,25 @@
]
},
"loops": 10
},
{
"name": "exit",
"android": {
"actions": [
{
"method": "app_terminate",
"params": "com.ss.android.ugc.aweme"
}
]
},
"validate": [
{
"check": "ui_foreground_app",
"assert": "not_equal",
"expect": "com.ss.android.ugc.aweme",
"msg": "app [com.ss.android.ugc.aweme] should not be in foreground"
}
]
}
]
}

View File

@@ -21,7 +21,9 @@ func TestAndroidDouyinFeedTest(t *testing.T) {
Android().
AppTerminate("com.ss.android.ugc.aweme").
AppLaunch("com.ss.android.ugc.aweme").
Sleep(10),
Sleep(10).
Validate().
AssertAppInForeground("com.ss.android.ugc.aweme"),
hrp.NewStep("处理青少年弹窗").
Android().
TapByOCR("我知道了", uixt.WithIgnoreNotFoundError(true)),
@@ -40,6 +42,11 @@ func TestAndroidDouyinFeedTest(t *testing.T) {
Android().
SwipeUp().
SleepRandom(0, 5, 0.7, 5, 10, 0.3),
hrp.NewStep("exit").
Android().
AppTerminate("com.ss.android.ugc.aweme").
Validate().
AssertAppNotInForeground("com.ss.android.ugc.aweme"),
},
}