mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-12-10 02:51:07 +01:00
modules/android-integration: add am command
This commit is contained in:
parent
8b48f7a229
commit
e7d2d97007
10 changed files with 157 additions and 0 deletions
53
tests/emulator/android_integration.py
Normal file
53
tests/emulator/android_integration.py
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import bootstrap_channels
|
||||
|
||||
from common import screenshot, wait_for
|
||||
|
||||
|
||||
def run(d):
|
||||
nod = bootstrap_channels.run(d)
|
||||
|
||||
d('input text "am"')
|
||||
d.ui.press('enter')
|
||||
wait_for(d, 'bash: am: command not found')
|
||||
screenshot(d, 'no-am')
|
||||
|
||||
# Apply a config that enables am
|
||||
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\'')
|
||||
d.ui.press('enter')
|
||||
screenshot(d, 'pre-switch')
|
||||
d('input text "nix-on-droid switch"')
|
||||
d.ui.press('enter')
|
||||
screenshot(d, 'post-switch')
|
||||
|
||||
# Verify am is there
|
||||
d('input text "am | head -n2"')
|
||||
d.ui.press('enter')
|
||||
wait_for(d, 'termux-am is a wrapper script')
|
||||
screenshot(d, 'am-appears')
|
||||
|
||||
# Smoke-test that am doesn't work yet
|
||||
d('input text "am start -a android.settings.SETTINGS 2>&1 | head -n5"')
|
||||
d.ui.press('enter')
|
||||
screenshot(d, 'am-invoked for the first time')
|
||||
wait_for(d, 'Nix requires "Display over other apps" permission')
|
||||
wait_for(d, 'https://dontkillmyapp.com')
|
||||
screenshot(d, 'am-wants-permission')
|
||||
|
||||
# Grant nix app 'Draw over other apps' permission
|
||||
nod.permissions += 'android.permission.SYSTEM_ALERT_WINDOW'
|
||||
|
||||
# Smoke-test that am works
|
||||
d('input text "am start -a android.settings.SETTINGS"')
|
||||
d.ui.press('enter')
|
||||
screenshot(d, 'settings-opening')
|
||||
wait_for(d, 'Search settings')
|
||||
wait_for(d, 'Network')
|
||||
d.ui.press('back')
|
||||
screenshot(d, 'back-from-settings')
|
||||
|
||||
# Verify we're back
|
||||
d('input text "am | head -n2"')
|
||||
d.ui.press('enter')
|
||||
wait_for(d, 'termux-am is a wrapper script')
|
||||
|
|
@ -52,3 +52,5 @@ def run(d):
|
|||
wait_for(d, 'c21va2UtdGVzdAo=')
|
||||
|
||||
screenshot(d, 'success-bootstrap-channels')
|
||||
|
||||
return nod
|
||||
|
|
|
|||
|
|
@ -52,3 +52,5 @@ def run(d):
|
|||
wait_for(d, 'c21va2UtdGVzdAo=')
|
||||
|
||||
screenshot(d, 'success-bootstrap-flakes')
|
||||
|
||||
return nod
|
||||
|
|
|
|||
16
tests/on-device/config-android-integration.bats
Normal file
16
tests/on-device/config-android-integration.bats
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# Copyright (c) 2019-2024, see AUTHORS. Licensed under MIT License, see LICENSE.
|
||||
|
||||
load lib
|
||||
|
||||
@test 'android-integration options can be used' {
|
||||
run ! command -v am
|
||||
|
||||
cp \
|
||||
"$ON_DEVICE_TESTS_DIR/config-android-integration.nix" \
|
||||
~/.config/nixpkgs/nix-on-droid.nix
|
||||
nix-on-droid switch
|
||||
|
||||
command -v am
|
||||
|
||||
switch_to_default_config
|
||||
}
|
||||
8
tests/on-device/config-android-integration.nix
Normal file
8
tests/on-device/config-android-integration.nix
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
_:
|
||||
|
||||
{
|
||||
system.stateVersion = "23.11";
|
||||
android-integration = {
|
||||
am.enable = true;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue