modules/android-integration: termux-wake-lock and termux-wake-unlock

This commit is contained in:
Alexander Sosedkin 2024-07-06 17:38:40 +02:00
parent b195fa0b15
commit 438cf8c620
6 changed files with 100 additions and 6 deletions

View file

@ -7,7 +7,8 @@ from common import screenshot, wait_for
def run(d):
OPENERS = ['termux-open', 'termux-open-url', 'xdg-open']
TOOLS = ['am', 'termux-setup-storage'] + OPENERS
TOOLS = ['am', 'termux-setup-storage',
'termux-wake-lock', 'termux-wake-unlock'] + OPENERS
nod = bootstrap_channels.run(d)
@ -111,3 +112,53 @@ def run(d):
d.ui.press('back')
screenshot(d, f'{opener}-back')
wait_for(d, f'{opener} https://example.org')
# test termux-wake-lock/termux-wake-unlock
d.ui.open_notification()
screenshot(d, 'notification-opened')
d.ui(text='Nix').right(resourceId='android:id/expand_button').click()
screenshot(d, 'notification-expanded')
wait_for(d, 'Acquire wakelock')
screenshot(d, 'wakelock-initially-not-acquired')
d.ui.press('back')
d('input text "termux-wake-lock"')
d.ui.press('enter')
time.sleep(3)
screenshot(d, 'wake-lock-command')
if 'Let app always run in background?' in d.ui.dump_hierarchy():
screenshot(d, 'wake-lock-permission-asked')
if 'text="Allow"' in d.ui.dump_hierarchy():
d.ui(text='Allow').click()
elif 'text="ALLOW"' in d.ui.dump_hierarchy():
d.ui(text='ALLOW').click()
screenshot(d, 'wake-lock-permission-granted')
d.ui.open_notification()
time.sleep(.5)
screenshot(d, 'notification-opened')
wait_for(d, '(wake lock held)')
if 'Release wakelock' not in d.ui.dump_hierarchy():
d.ui(text='Nix').right(resourceId='android:id/expand_button').click()
screenshot(d, 'notification-expanded')
wait_for(d, 'Release wakelock')
screenshot(d, 'notification-with-wakelock')
d.ui.press('back')
screenshot(d, 'back')
wait_for(d, 'termux-wake-lock')
screenshot(d, 'really-back')
d('input text "termux-wake-unlock"')
d.ui.press('enter')
screenshot(d, 'wake-unlock-command')
d.ui.open_notification()
time.sleep(.5)
screenshot(d, 'notification-opened')
if 'Acquire wakelock' not in d.ui.dump_hierarchy():
d.ui(text='Nix').right(resourceId='android:id/expand_button').click()
screenshot(d, 'notification-expanded')
wait_for(d, 'Acquire wakelock')
screenshot(d, 'notification-without-wakelock')
d.ui.press('back')
screenshot(d, 'back')
wait_for(d, 'termux-wake-unlock')
screenshot(d, 'really-back')

View file

@ -8,6 +8,8 @@ load lib
run ! command -v termux-setup-storage
run ! command -v termux-open
run ! command -v termux-open-url
run ! command -v termux-wake-lock
run ! command -v termux-wake-unlock
run ! command -v xdg-open
run ! command -v termux-backup
@ -20,6 +22,8 @@ load lib
command -v termux-setup-storage
command -v termux-open
command -v termux-open-url
command -v termux-wake-lock
command -v termux-wake-unlock
command -v xdg-open
run ! command -v termux-backup
@ -32,6 +36,8 @@ load lib
command -v termux-setup-storage
command -v termux-open
command -v termux-open-url
command -v termux-wake-lock
command -v termux-wake-unlock
command -v xdg-open
command -v termux-backup

View file

@ -7,6 +7,8 @@ _:
termux-open.enable = true;
termux-open-url.enable = true;
termux-setup-storage.enable = true;
termux-wake-lock.enable = true;
termux-wake-unlock.enable = true;
xdg-open.enable = true;
# unsupported.enable = false;
};