diff --git a/.github/scripts/run_tests.sh b/.github/scripts/run_tests.sh index 7b8d189db..358c197a5 100755 --- a/.github/scripts/run_tests.sh +++ b/.github/scripts/run_tests.sh @@ -3,21 +3,12 @@ # SPDX-License-Identifier: Apache-2.0 # -adb root -sleep 5 -adb remount +echo "Disable auto-restore" +adb shell bmgr autorestore false echo "Installing Seedvault app..." -adb shell mkdir -p /system/priv-app/Seedvault -adb push app/build/outputs/apk/release/app-release.apk /system/priv-app/Seedvault/Seedvault.apk - -echo "Installing Seedvault permissions..." -adb push permissions_com.stevesoltys.seedvault.xml /system/etc/permissions/privapp-permissions-seedvault.xml -adb push allowlist_com.stevesoltys.seedvault.xml /system/etc/sysconfig/allowlist-seedvault.xml - -echo "Setting Seedvault transport..." -sleep 10 -adb shell bmgr transport com.stevesoltys.seedvault.transport.ConfigurableBackupTransport +./gradlew --stacktrace :app:installDebugAndroidTest +sleep 60 D2D_BACKUP_TEST=$1 diff --git a/app/development/scripts/install_app.sh b/app/development/scripts/install_app.sh index e4f8cda38..cfd44d90b 100755 --- a/app/development/scripts/install_app.sh +++ b/app/development/scripts/install_app.sh @@ -11,10 +11,9 @@ if [ -z "$ANDROID_HOME" ]; then fi SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) -DEVELOPMENT_DIR=$SCRIPT_DIR/.. ROOT_PROJECT_DIR=$SCRIPT_DIR/../../.. -EMULATOR_DEVICE_NAME=$($ANDROID_HOME/platform-tools/adb devices | grep emulator | cut -f1) +EMULATOR_DEVICE_NAME=$("$ANDROID_HOME"/platform-tools/adb devices | grep emulator | cut -f1) if [ -z "$EMULATOR_DEVICE_NAME" ]; then echo "Emulator device name not found" @@ -29,13 +28,9 @@ $ADB remount # remount /system as writable echo "Installing Seedvault app..." $ADB shell mkdir -p /system/priv-app/Seedvault -$ADB push $ROOT_PROJECT_DIR/app/build/outputs/apk/release/app-release.apk /system/priv-app/Seedvault/Seedvault.apk +$ADB push "$ROOT_PROJECT_DIR"/app/build/outputs/apk/release/app-release.apk /system/priv-app/Seedvault/Seedvault.apk echo "Installing Seedvault permissions..." -$ADB push $ROOT_PROJECT_DIR/permissions_com.stevesoltys.seedvault.xml /system/etc/permissions/privapp-permissions-seedvault.xml -$ADB push $ROOT_PROJECT_DIR/allowlist_com.stevesoltys.seedvault.xml /system/etc/sysconfig/allowlist-seedvault.xml -$ADB shell am force-stop com.stevesoltys.seedvault +$ADB push "$ROOT_PROJECT_DIR"/permissions_com.stevesoltys.seedvault.xml /system/etc/permissions/privapp-permissions-seedvault.xml +$ADB push "$ROOT_PROJECT_DIR"/allowlist_com.stevesoltys.seedvault.xml /system/etc/sysconfig/allowlist-seedvault.xml $ADB shell am broadcast -a android.intent.action.BOOT_COMPLETED - -echo "Setting Seedvault transport..." -$ADB shell bmgr transport com.stevesoltys.seedvault.transport.ConfigurableBackupTransport diff --git a/app/development/scripts/provision_emulator.sh b/app/development/scripts/provision_emulator.sh index 9219c9bf5..6e0161cfa 100755 --- a/app/development/scripts/provision_emulator.sh +++ b/app/development/scripts/provision_emulator.sh @@ -20,25 +20,23 @@ EMULATOR_NAME=$1 SYSTEM_IMAGE=$2 SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) -DEVELOPMENT_DIR=$SCRIPT_DIR/.. -ROOT_PROJECT_DIR=$SCRIPT_DIR/../../.. echo "Downloading system image..." -yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install "$SYSTEM_IMAGE" +yes | "$ANDROID_HOME"/cmdline-tools/latest/bin/sdkmanager --install "$SYSTEM_IMAGE" # create AVD if it doesn't exist -if $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager list avd | grep -q "$EMULATOR_NAME"; then +if "$ANDROID_HOME"/cmdline-tools/latest/bin/avdmanager list avd | grep -q "$EMULATOR_NAME"; then echo "AVD already exists. Skipping creation." else echo "Creating AVD..." - echo 'no' | $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -n "$EMULATOR_NAME" -k "$SYSTEM_IMAGE" + echo 'no' | "$ANDROID_HOME"/cmdline-tools/latest/bin/avdmanager create avd -n "$EMULATOR_NAME" -k "$SYSTEM_IMAGE" sleep 1 fi -EMULATOR_DEVICE_NAME=$($ANDROID_HOME/platform-tools/adb devices | grep emulator | cut -f1) +EMULATOR_DEVICE_NAME=$("$ANDROID_HOME"/platform-tools/adb devices | grep emulator | cut -f1) if [ -z "$EMULATOR_DEVICE_NAME" ]; then - $SCRIPT_DIR/start_emulator.sh "$EMULATOR_NAME" + "$SCRIPT_DIR"/start_emulator.sh "$EMULATOR_NAME" fi # wait for emulator device to appear with 180 second timeout @@ -47,7 +45,7 @@ echo "Waiting for emulator device..." for i in {1..180}; do if [ -z "$EMULATOR_DEVICE_NAME" ]; then sleep 1 - EMULATOR_DEVICE_NAME=$($ANDROID_HOME/platform-tools/adb devices | grep emulator | cut -f1) + EMULATOR_DEVICE_NAME=$("$ANDROID_HOME"/platform-tools/adb devices | grep emulator | cut -f1) else break fi @@ -73,16 +71,14 @@ $ADB reboot # need to reboot first time we remount $ADB wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;' echo "Provisioning emulator for Seedvault..." -$SCRIPT_DIR/install_app.sh +"$SCRIPT_DIR"/install_app.sh echo "Rebooting emulator..." $ADB reboot $ADB wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;' -echo "Setting backup transport to Seedvault..." -$ADB shell bmgr enable true -sleep 5 -$ADB shell bmgr transport com.stevesoltys.seedvault.transport.ConfigurableBackupTransport +echo "Disabling backup..." +$ADB shell bmgr enable false echo "Downloading and extracting test backup to '/sdcard/seedvault_baseline'..." diff --git a/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/LargeTestBase.kt b/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/LargeTestBase.kt index af052e3a9..ea648ddcf 100644 --- a/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/LargeTestBase.kt +++ b/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/LargeTestBase.kt @@ -113,9 +113,11 @@ internal interface LargeTestBase : KoinComponent { } fun testResultFilename(testName: String): String { + val arguments = InstrumentationRegistry.getArguments() + val d2d = if (arguments.getString("d2d_backup_test") == "true") "d2d" else "" val simpleDateFormat = SimpleDateFormat("yyyyMMdd_hhmmss") val timeStamp = simpleDateFormat.format(Calendar.getInstance().time) - return "${timeStamp}_${testName.replace(" ", "_")}" + return "${timeStamp}_${d2d}_${testName.replace(" ", "_")}" } @OptIn(DelicateCoroutinesApi::class) diff --git a/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/SeedvaultLargeTest.kt b/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/SeedvaultLargeTest.kt index 568bd1c23..ba66e3d78 100644 --- a/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/SeedvaultLargeTest.kt +++ b/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/SeedvaultLargeTest.kt @@ -16,6 +16,7 @@ import org.junit.rules.TestName import org.junit.runner.RunWith import org.koin.core.component.KoinComponent import java.io.File +import java.lang.Thread.sleep import java.util.concurrent.atomic.AtomicBoolean @RunWith(AndroidJUnit4::class) @@ -44,6 +45,11 @@ internal abstract class SeedvaultLargeTest : resetApplicationState() clearTestBackups() + runCommand("bmgr enable true") + sleep(60_000) + runCommand("bmgr transport com.stevesoltys.seedvault.transport.ConfigurableBackupTransport") + sleep(60_000) + startRecordingTest(keepRecordingScreen, name.methodName) restoreBaselineBackup()