From 86bedccba5c3ab89bf6e295ef257030eb82c12b0 Mon Sep 17 00:00:00 2001 From: Alexander Sosedkin Date: Sat, 6 Jul 2024 15:51:10 +0200 Subject: [PATCH] fixup! modules/android-integration: add am command --- pkgs/android-integration/termux-am.nix | 11 ++++++----- tests/emulator/android_integration.py | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/pkgs/android-integration/termux-am.nix b/pkgs/android-integration/termux-am.nix index e3d1549..18c8a30 100644 --- a/pkgs/android-integration/termux-am.nix +++ b/pkgs/android-integration/termux-am.nix @@ -19,11 +19,12 @@ stdenv.mkDerivation rec { patchPhase = '' # Header generation doesn't seem to work on android echo "#define SOCKET_PATH \"${socketPath}\"" > termux-am.h - - cat termux-am.h - # Fix the bash link so that nix can patch it - substituteInPlace termux-am.sh.in --replace @TERMUX_PREFIX@ "" - head termux-am.sh.in + # Fix the bash link so that nix can patch it + path to termux-am-socket + substituteInPlace termux-am.sh.in \ + --replace @TERMUX_PREFIX@/bin/bash /bin/bash \ + --replace \ + "termux-am-socket \"\$am_command_string\"" \ + "$out/bin/termux-am-socket \"\$am_command_string\"" ''; postInstall = '' # Scripts use 'am' as an alias. diff --git a/tests/emulator/android_integration.py b/tests/emulator/android_integration.py index dc696e9..87d8c06 100644 --- a/tests/emulator/android_integration.py +++ b/tests/emulator/android_integration.py @@ -1,3 +1,5 @@ +import time + import bootstrap_channels from common import screenshot, wait_for @@ -17,8 +19,9 @@ def run(d): 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('input text "nix-on-droid switch && echo integration tools installed"') d.ui.press('enter') + wait_for(d, 'integration tools installed') screenshot(d, 'post-switch') # Verify am is there @@ -35,6 +38,18 @@ def run(d): wait_for(d, 'https://dontkillmyapp.com') screenshot(d, 'am-wants-permission') + # ... there might be a notification now, get rid of it + time.sleep(3) + screenshot(d, 'am-wants-permission-3-seconds-later') + if 'text="TermuxAm Socket Server Error"' in d.ui.dump_hierarchy(): + d.ui.open_notification() + time.sleep(1) + screenshot(d, 'notification-opened') + d.ui(text='TermuxAm Socket Server Error').swipe('right') + screenshot(d, 'error-notification-swiped-right') + d.ui.press('back') + screenshot(d, 'back') + # Grant nix app 'Draw over other apps' permission nod.permissions += 'android.permission.SYSTEM_ALERT_WINDOW' @@ -44,6 +59,7 @@ def run(d): screenshot(d, 'settings-opening') wait_for(d, 'Search settings') wait_for(d, 'Network') + screenshot(d, 'settings-awaited') d.ui.press('back') screenshot(d, 'back-from-settings')