kiwix-android/contrib/instrumentation.sh
MohitMaliFtechiz 606bea4405 Improved our instrumentation.sh bash script, if our test fails then after restarting the emulator if our application is installed we clear its cache data so that test cases will perform properly. We have made this change to fix a scenario that comes locally after testing so many times where downloading is stuck due to lag of emulator.
* * Improved the LibkiwixBookmarkTest. In this, before performing the test case we are removing the existing bookmarks if any so that the saved bookmark will not go outside the screen(We faced an occurrence of this type locally).
* Improved the ZIM file path in many scenarios so that the created ZIM file will show in the LocalLibraryScreen and we can delete it so that we can free up the memory.
2024-03-09 19:38:58 +05:30

41 lines
983 B
Bash

#!/usr/bin/env bash
# Enable Wi-Fi on the emulator
adb shell svc wifi enable
adb logcat -c
# shellcheck disable=SC2035
adb logcat *:E -v color &
retry=0
while [ $retry -le 3 ]; do
if ./gradlew jacocoInstrumentationTestReport; then
echo "jacocoInstrumentationTestReport succeeded" >&2
break
else
adb kill-server
adb start-server
# Enable Wi-Fi on the emulator
adb shell svc wifi enable
adb logcat -c
# shellcheck disable=SC2035
adb logcat *:E -v color &
PACKAGE_NAME="org.kiwix.kiwixmobile"
# Function to check if the application is installed
is_app_installed() {
adb shell pm list packages | grep -q "${PACKAGE_NAME}"
}
if is_app_installed; then
# Clear application data to properly run the test cases.
adb shell pm clear "${PACKAGE_NAME}"
fi
./gradlew clean
retry=$(( retry + 1 ))
if [ $retry -eq 3 ]; then
adb exec-out screencap -p >screencap.png
exit 1
fi
fi
done