modules/android_integration: termux-setup-storage & unsupported

This commit is contained in:
Alexander Sosedkin 2024-07-05 22:52:18 +02:00
parent c4c4f09e3d
commit 733a9fe55c
7 changed files with 265 additions and 4 deletions

View file

@ -8,12 +8,17 @@ from common import screenshot, wait_for
def run(d):
nod = bootstrap_channels.run(d)
# Verify that android-integration tools aren't installed by default
d('input text "am"')
d.ui.press('enter')
wait_for(d, 'bash: am: command not found')
screenshot(d, 'no-am')
d('input text "termux-setup-storage"')
d.ui.press('enter')
wait_for(d, 'bash: termux-setup-storage: command not found')
screenshot(d, 'no-termux-setup-storage')
# Apply a config that enables am
# Apply a config that enables android-integration tools
cfg = ('/data/local/tmp/n-o-d/unpacked/tests/on-device/'
'config-android-integration.nix')
d(f'input text \'cp {cfg} .config/nixpkgs/nix-on-droid.nix\'')
@ -67,3 +72,31 @@ def run(d):
d('input text "am | head -n2"')
d.ui.press('enter')
wait_for(d, 'termux-am is a wrapper script')
# Verify termux-setup-storage is there
d('input text "termux-setup-storage"')
d.ui.press('enter')
screenshot(d, 'termux-setup-storage-invoked')
wait_for(d, 'Allow Nix to access')
screenshot(d, 'permission-requested')
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, 'permission-granted')
d('input text "ls -l storage"')
d.ui.press('enter')
screenshot(d, 'storage-listed')
wait_for(d, 'pictures -> /storage/emulated/0/Pictures')
wait_for(d, 'shared -> /storage/emulated/0')
screenshot(d, 'storage-listed-ok')
# Invoke termux-setup-storage again
d('input text "termux-setup-storage"')
d.ui.press('enter')
screenshot(d, 'termux-setup-storage-invoked-again')
wait_for(d, 'already exists')
wait_for(d, 'Do you want to continue?')
d.ui.press('enter')
wait_for(d, 'Aborting configuration and leaving')

View file

@ -5,6 +5,8 @@ load lib
@test 'android-integration options can be used' {
bats_require_minimum_version 1.5.0
run ! command -v am
run ! command -v termux-setup-storage
run ! command -v termux-open-url
cp \
"$ON_DEVICE_TESTS_DIR/config-android-integration.nix" \
@ -12,6 +14,17 @@ load lib
nix-on-droid switch
command -v am
command -v termux-setup-storage
run ! command -v termux-open-url
_sed \
-e "s|# unsupported.enable = false;|unsupported.enable = true;|" \
-e "s|am.enable = true;|am.enable = false;|" \
-i ~/.config/nixpkgs/nix-on-droid.nix
nix-on-droid switch
run ! command -v am
command -v termux-setup-storage
command -v termux-open-url
switch_to_default_config
}

View file

@ -4,5 +4,7 @@ _:
system.stateVersion = "23.11";
android-integration = {
am.enable = true;
termux-setup-storage.enable = true;
# unsupported.enable = false;
};
}