tests/emulator: assorted robustness fixes

This commit is contained in:
Alexander Sosedkin 2025-07-21 11:05:11 +02:00
parent 27696cac81
commit 51158ee84f
2 changed files with 22 additions and 5 deletions

View file

@ -5,6 +5,18 @@ import bootstrap_channels
from common import screenshot, wait_for from common import screenshot, wait_for
def expand_notification(d):
session = d.ui(text='1 session')
nix = session.up(text='Nix', resourceId='android:id/app_name_text')
if nix is None: # works on 29, but not on 35
print('android:id/app_name_text not found, '
'go for com.android.systemui:id/notification_title')
nix = session.up(
text='Nix',
resourceId='com.android.systemui:id/notification_title'
)
expand = nix.right(resourceId='android:id/expand_button')
nix.right(resourceId='android:id/expand_button').click()
def run(d): def run(d):
OPENERS = ['termux-open', 'termux-open-url', 'xdg-open'] OPENERS = ['termux-open', 'termux-open-url', 'xdg-open']
@ -28,7 +40,7 @@ def run(d):
screenshot(d, 'pre-switch') screenshot(d, 'pre-switch')
d('input text "nix-on-droid switch && echo integration tools installed"') d('input text "nix-on-droid switch && echo integration tools installed"')
d.ui.press('enter') d.ui.press('enter')
wait_for(d, 'integration tools installed') wait_for(d, 'integration tools installed', timeout=180)
screenshot(d, 'post-switch') screenshot(d, 'post-switch')
# Verify am is there # Verify am is there
@ -115,9 +127,12 @@ def run(d):
wait_for(d, f'{opener} https://example.org') wait_for(d, f'{opener} https://example.org')
# test termux-wake-lock/termux-wake-unlock # test termux-wake-lock/termux-wake-unlock
time.sleep(.5)
d.ui.open_notification() d.ui.open_notification()
time.sleep(.5)
screenshot(d, 'notification-opened') screenshot(d, 'notification-opened')
d.ui(text='Nix').right(resourceId='android:id/expand_button').click() if 'Release wakelock' not in d.ui.dump_hierarchy():
expand_notification(d)
screenshot(d, 'notification-expanded') screenshot(d, 'notification-expanded')
wait_for(d, 'Acquire wakelock') wait_for(d, 'Acquire wakelock')
screenshot(d, 'wakelock-initially-not-acquired') screenshot(d, 'wakelock-initially-not-acquired')
@ -139,7 +154,7 @@ def run(d):
screenshot(d, 'notification-opened') screenshot(d, 'notification-opened')
wait_for(d, '(wake lock held)') wait_for(d, '(wake lock held)')
if 'Release wakelock' not in d.ui.dump_hierarchy(): if 'Release wakelock' not in d.ui.dump_hierarchy():
d.ui(text='Nix').right(resourceId='android:id/expand_button').click() expand_notification(d)
screenshot(d, 'notification-expanded') screenshot(d, 'notification-expanded')
wait_for(d, 'Release wakelock') wait_for(d, 'Release wakelock')
screenshot(d, 'notification-with-wakelock') screenshot(d, 'notification-with-wakelock')
@ -155,7 +170,7 @@ def run(d):
time.sleep(.5) time.sleep(.5)
screenshot(d, 'notification-opened') screenshot(d, 'notification-opened')
if 'Acquire wakelock' not in d.ui.dump_hierarchy(): if 'Acquire wakelock' not in d.ui.dump_hierarchy():
d.ui(text='Nix').right(resourceId='android:id/expand_button').click() expand_notification(d)
screenshot(d, 'notification-expanded') screenshot(d, 'notification-expanded')
wait_for(d, 'Acquire wakelock') wait_for(d, 'Acquire wakelock')
screenshot(d, 'notification-without-wakelock') screenshot(d, 'notification-without-wakelock')

View file

@ -1,3 +1,5 @@
import time
import bootstrap_channels import bootstrap_channels
from common import screenshot, wait_for from common import screenshot, wait_for
@ -45,6 +47,7 @@ def run(d):
screenshot(d, 're-login') screenshot(d, 're-login')
wait_for(d, 'Installing new login-inner...') wait_for(d, 'Installing new login-inner...')
wait_for(d, 'bash-5.2$') wait_for(d, 'bash-5.2$')
time.sleep(1)
screenshot(d, 're-login-done') screenshot(d, 're-login-done')
# And verify zip is still there # And verify zip is still there
@ -55,7 +58,6 @@ def run(d):
def change_shell_and_relogin(shell, descr): def change_shell_and_relogin(shell, descr):
import base64 import base64
import time
config = ('{pkgs, ...}: {user.shell = %SHELL%; ' + config = ('{pkgs, ...}: {user.shell = %SHELL%; ' +
'system.stateVersion = "24.05";}').replace('%SHELL%', shell) 'system.stateVersion = "24.05";}').replace('%SHELL%', shell)
config_base64 = base64.b64encode(config.encode()).decode() config_base64 = base64.b64encode(config.encode()).decode()