diff --git a/.travis.yml b/.travis.yml index daeae3634..1e7b8dbe0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,11 @@ language: android jdk: openjdk7 +sudo: false +env: + global: + - ANDROID_API_LEVEL=21 + - ANDROID_ABI=armeabi-v7a + - ADB_INSTALL_TIMEOUT=8 # minutes (2 minutes by default) android: components: - build-tools-22.0.1 @@ -16,14 +22,13 @@ android: - 'android-sdk-preview-license-52d11cd2' - 'android-sdk-license-.+' - 'google-gdk-license-.+' -# before_script: -# - echo no | android create avd --force -n test -t android-21 --abi armeabi-v7a -# - emulator -avd test -no-skin -no-audio -no-window & -script: - - ./gradlew - - ./gradlew testDebug - - ./gradlew jacocoTestReport coveralls -# don't run instrumentation tests for now -# - android-wait-for-emulator && adb shell input keyevent 82 & -# - ./gradlew connectedAndroidTest +before_script: + - echo no | android create avd --force -n test -t android-$ANDROID_API_LEVEL --abi $ANDROID_ABI + - emulator -avd test -no-skin -no-audio -no-window & + - ./tools/android-wait-for-emulator + - adb shell input keyevent 82 & + +script: + - ./gradlew connectedAndroidTest + - ./gradlew testDebug jacocoTestReport coveralls diff --git a/tools/android-wait-for-emulator b/tools/android-wait-for-emulator new file mode 100755 index 000000000..57d045900 --- /dev/null +++ b/tools/android-wait-for-emulator @@ -0,0 +1,25 @@ +#!/bin/bash + +# Originally written by Ralf Kistner , but placed in the public domain + +set +e + +bootanim="" +failcounter=0 +timeout_in_sec=720 + +until [[ "$bootanim" =~ "stopped" ]]; do + bootanim=`adb -e shell getprop init.svc.bootanim 2>&1 &` + if [[ "$bootanim" =~ "device not found" || "$bootanim" =~ "device offline" + || "$bootanim" =~ "running" ]]; then + let "failcounter += 1" + echo "Waiting for emulator to start" + if [[ $failcounter -gt timeout_in_sec ]]; then + echo "Timeout ($timeout_in_sec seconds) reached; failed to start emulator" + exit 1 + fi + fi + sleep 10 +done + +echo "Emulator is ready"