From 2cfcb2318c7484a1f32ef1069758ac412a632610 Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Fri, 6 May 2016 13:45:23 +0200 Subject: [PATCH] Run sample instrumented unit test in Travis --- .travis.yml | 27 +++++++++++++++++++++------ build.gradle | 4 ---- wait_for_emulator.sh | 19 +++++++++++++++++++ 3 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 wait_for_emulator.sh diff --git a/.travis.yml b/.travis.yml index 52317c850a..7777bf1f4f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,17 +2,32 @@ sudo: false language: android android: components: + - platform-tools + - tools - build-tools-23.0.3 - android-23 - - android-22 - - android-19 + - extra-android-m2repository + - sys-img-armeabi-v7a-android-23 +before_install: + - echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI -c 20M + - emulator -avd test -no-skin -no-audio -no-window & + - chmod +x ./wait_for_emulator.sh + - ./wait_for_emulator.sh script: - - ./setup_env.sh ant - - ant clean - - ant debug -# - ./gradlew connectedAndroidTest +# build app and assemble APK, in debug mode + - ./gradlew assembleDebug +# run all the local unit tests + - ./gradlew testDebug +# - ./gradlew connectedAndroidTest +# install app, then assemble and install instrumented tests + - ./gradlew installDebug + - ./gradlew installDebugAndroidTest +# run sample instrumented unit test + - adb shell am instrument -w -e debug false -e class com.owncloud.android.datamodel.OCFileUnitTest com.owncloud.android.test/android.support.test.runner.AndroidJUnitRunner env: global: - secure: bm8mkBKaujxI/C7Kp2NjwDl0vsfWd3qDGZ+7WiLPGTbXnwJf8urxFQLrMkhqIR4wZs2M1LSW+P9SfD2FwL5Y0GDo29IeYLqhW5LIT8tGCZevBUfMDqd4w+eFHY73FXEAwLWVavfKmeuyisK/JNwGr75penOuQkZXTow6wgNLBjs= - secure: EqLPMLaAcr+6NKeXWJdaUiNfMHJ+zdocKw7SyWsezKMMfsY6hME22m8TNHJZpt0nPCDoX7iPjJoh8svOe2RZo6UZG2q4hjcLxBu29b7QvJeChq7oJvjXPVNRUg2P2zJ2OUBbnyOhpw3cZruIncSr+QasSD8FGI7j3kw3t/86YE0= - secure: pfNH4RVBy0vRPKRY3z4EQD9SRPyCuqYISQ+87cOlfpVbYHOc7xspaQSg7L9sB/sBMumOuMgGSLD6RincRrSy6nHhd70Vm4ccJxJYOynqDxC3EXNihDesw9Q+MJh1mr7WpTP21sXpP4+HkLQV0U+bKl3xcnGgeR4FU3BWYigNMkA= + matrix: + - ANDROID_TARGET=android-23 ANDROID_ABI=armeabi-v7a diff --git a/build.gradle b/build.gradle index 211cc8908e..56f06e3f84 100644 --- a/build.gradle +++ b/build.gradle @@ -66,10 +66,6 @@ android { defaultConfig { testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - buildConfigField "String", "TEST_USER", "${TEST_USER}" - buildConfigField "String", "TEST_PASSWORD", "${TEST_PASSWORD}" - buildConfigField "String", "TEST_SERVER_URL", "${TEST_SERVER_URL}" - testInstrumentationRunnerArguments TEST_USER: "${TEST_USER}" testInstrumentationRunnerArguments TEST_PASSWORD: "${TEST_PASSWORD}" testInstrumentationRunnerArguments TEST_SERVER_URL: "${TEST_SERVER_URL}" diff --git a/wait_for_emulator.sh b/wait_for_emulator.sh new file mode 100644 index 0000000000..7f6443c794 --- /dev/null +++ b/wait_for_emulator.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +bootanim="" +failcounter=0 +checkcounter=0 +until [[ "$bootanim" =~ "stopped" ]]; do + bootanim=`adb -e shell getprop init.svc.bootanim 2>&1` + echo "($checkcounter) $bootanim" + if [[ "$bootanim" =~ "not found" ]]; then + let "failcounter += 1" + if [[ $failcounter -gt 30 ]]; then + echo "Failed to start emulator" + exit 1 + fi + fi + let "checkcounter += 1" + sleep 10 +done +echo "Done"