File tree Expand file tree Collapse file tree
app/src/androidTest/java/ai/openbot/shell/test Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -64,9 +64,20 @@ abstract class ShellTestBase {
6464 fun baseSetUp () {
6565 device.wakeUp()
6666 shell(" input keyevent KEYCODE_MENU" )
67+ dismissSystemDialogs()
6768 note(" variant: $variant ($pkg )" )
6869 }
6970
71+ /* * "<app> isn't responding" (a slow emulator's launcher): Wait. Never over our own app. */
72+ fun dismissSystemDialogs () {
73+ repeat(3 ) {
74+ val anr = device.findObject(By .textContains(" isn't responding" )) ? : device.findObject(By .textContains(" isn\u2019 t responding" )) ? : return
75+ note(" system dialog: ${anr.text} ; tapping Wait" )
76+ (device.findObject(By .text(" Wait" )) ? : device.findObject(By .text(" Close app" )))?.click()
77+ sleep(1_000 )
78+ }
79+ }
80+
7081 @After
7182 fun baseTearDown () {
7283 if (softFailures.isNotEmpty()) {
@@ -124,6 +135,7 @@ abstract class ShellTestBase {
124135 instrumentation.targetContext.startActivity(intent)
125136 device.wait(Until .hasObject(By .pkg(pkg).depth(0 )), 15_000 )
126137 sleep(800 )
138+ dismissSystemDialogs()
127139 }
128140
129141 /* * Back from the background: the launcher's intent, no extras, the existing task. */
Original file line number Diff line number Diff line change @@ -50,6 +50,12 @@ boot() {
5050}
5151
5252prepare () {
53+ # A freshly booted emulator's launcher often answers slowly: no "isn't responding" dialogs over the
54+ # tests (Settings.Global.HIDE_ERROR_DIALOGS), and a moment for the system to settle.
55+ adb shell settings put global hide_error_dialogs 1
56+ adb shell settings put global anr_show_background 0
57+ sleep 20
58+ adb shell am broadcast -a android.intent.action.CLOSE_SYSTEM_DIALOGS > /dev/null 2>&1 || true
5359 adb shell settings put global window_animation_scale 0
5460 adb shell settings put global transition_animation_scale 0
5561 adb shell settings put global animator_duration_scale " ${ANIMATOR_SCALE:- 0} "
You can’t perform that action at this time.
0 commit comments