forked from trustwallet/wallet-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathandroid-test
executable file
·51 lines (41 loc) · 1.28 KB
/
android-test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
#
# This script runs the Android tests.
set -e
AVD_NAME="integration-tests"
PORT=5556
# Make sure it builds before starting an emulator
pushd android
./gradlew assembleAndroidTest
popd
#Calculate the Serial Number of the emulator instance
SERIAL=emulator-${PORT}
# We have to echo "no" because it will ask us if we want to use a custom hardware profile, and we don't.
echo -e "\nCreating Android emulator...\n"
echo "no" | "$ANDROID_HOME/cmdline-tools/latest/bin/avdmanager" create avd \
-n "${AVD_NAME}" \
-k "system-images;android-26;google_apis;x86" \
-f
echo -e "\nAVD ${AVD_NAME} created."
# Start the Android Emulator
"$ANDROID_HOME/emulator/emulator" \
-avd ${AVD_NAME} \
-netspeed full \
-netdelay none \
-port ${PORT} &
# Ensure Android Emulator has booted successfully before continuing
echo -e "\nWaiting for emulator to boot...\n"
EMU_BOOTED='unknown'
while [[ ${EMU_BOOTED} != *"stopped"* ]]; do
sleep 5
EMU_BOOTED=`adb -s ${SERIAL} shell getprop init.svc.bootanim || echo unknown`
done
duration=$(( SECONDS - start ))
echo -e "Android Emulator started after $duration seconds.\n\n"
# Run tests
pushd android
./gradlew connectedAndroidTest
popd
# Stop the Android Emulator
echo -e "\nKilling the Android Emulator"
adb -s ${SERIAL} emu kill