Skip to content
Snippets Groups Projects
Commit 3d708220 authored by Pierre Nicolas's avatar Pierre Nicolas :joy: Committed by Pierre Nicolas
Browse files

test: install assets pack on CI emulator

Install files we need to test the app on the ci emulator and use them on tests.
If not running on a CI emulator, will download the files from remote location.

Change-Id: I991fdb4e7998002b397dec8d9e1721ce8f972880
parent c8c3850e
No related branches found
No related tags found
No related merge requests found
Showing with 29 additions and 6 deletions
...@@ -25,6 +25,7 @@ if [ -z "$ANDROID_SDK_ROOT" ]; then ...@@ -25,6 +25,7 @@ if [ -z "$ANDROID_SDK_ROOT" ]; then
fi fi
SCRIPT_DIRECTORY=$(dirname "$0") SCRIPT_DIRECTORY=$(dirname "$0")
TEST_ASSETS_DIRECTORY_PATH=$SCRIPT_DIRECTORY/test_assets/
APK_PATH=$SCRIPT_DIRECTORY/../jami-android/app/build/outputs/apk/noPush/debug/app-noPush-debug.apk APK_PATH=$SCRIPT_DIRECTORY/../jami-android/app/build/outputs/apk/noPush/debug/app-noPush-debug.apk
TEST_APK_PATH=$SCRIPT_DIRECTORY/../jami-android/app/build/outputs/apk/androidTest/noPush/debug/app-noPush-debug-androidTest.apk TEST_APK_PATH=$SCRIPT_DIRECTORY/../jami-android/app/build/outputs/apk/androidTest/noPush/debug/app-noPush-debug-androidTest.apk
...@@ -40,6 +41,10 @@ if [ ! -f "$TEST_APK_PATH" ]; then ...@@ -40,6 +41,10 @@ if [ ! -f "$TEST_APK_PATH" ]; then
exit 1 exit 1
fi fi
# Install test assets on emulator (images, videos, audios, files, ...)
sh adb push $TEST_ASSETS_DIRECTORY_PATH "/data/local/tmp/jami_test_assets"
# Launch test execution
"$JAVA_HOME"/bin/java -jar "$SPOON_RUNNER_PATH" --apk "$APK_PATH" --test-apk "$TEST_APK_PATH" --sdk "$ANDROID_SDK_ROOT" --fail-on-failure "$JAVA_HOME"/bin/java -jar "$SPOON_RUNNER_PATH" --apk "$APK_PATH" --test-apk "$TEST_APK_PATH" --sdk "$ANDROID_SDK_ROOT" --fail-on-failure
# Capture the exit code # Capture the exit code
......
File added
File added
File added
File added
File added
ci/test_assets/image/image1.jpg

344 KiB

ci/test_assets/image/image2.jpg

533 KiB

ci/test_assets/image/image3.jpg

582 KiB

ci/test_assets/image/image4.jpg

469 KiB

File added
File added
...@@ -122,9 +122,18 @@ class AccountSettings { ...@@ -122,9 +122,18 @@ class AccountSettings {
accountCreated = true accountCreated = true
Log.d(TAG, "Account created.") Log.d(TAG, "Account created.")
// Download image from URL. // Get assets if installed (should be in /data/local/tmp/jami_test_assets).
mActivityScenarioRule.scenario.onActivity { activity -> val image1 = File("/data/local/tmp/jami_test_assets/image/image1.jpg")
downloadedImagesUri = ImageProvider().downloadImagesToUri(activity, 2) val image2 = File("/data/local/tmp/jami_test_assets/image/image1.jpg")
if(image1.exists() && image2.exists()) {
Log.d(TAG, "Images found in assets. Using them.")
downloadedImagesUri = listOf(Uri.fromFile(image1), Uri.fromFile(image2))
}
else { // Download images from URL.
Log.d(TAG, "Downloading images ...")
InstrumentationRegistry.getInstrumentation().targetContext
.let { downloadedImagesUri = ImageProvider().downloadImagesToUri(it, 2) }
Log.d(TAG, "Images downloaded.")
} }
} }
......
...@@ -55,6 +55,7 @@ import org.junit.Rule ...@@ -55,6 +55,7 @@ import org.junit.Rule
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.junit.runners.MethodSorters import org.junit.runners.MethodSorters
import java.io.File
@LargeTest @LargeTest
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
...@@ -75,9 +76,17 @@ class AccountCreation { ...@@ -75,9 +76,17 @@ class AccountCreation {
@Test @Test
fun a_setup() { fun a_setup() {
// Download image from URL. // Get assets if installed (should be in /data/local/tmp/jami_test_assets).
mActivityScenarioRule.scenario.onActivity { activity -> val image1 = File("/data/local/tmp/jami_test_assets/image/image1.jpg")
downloadedImagesUri = ImageProvider().downloadImagesToUri(activity, 2) val image2 = File("/data/local/tmp/jami_test_assets/image/image1.jpg")
if(image1.exists() && image2.exists()) {
Log.d(TAG, "Images found in assets. Using them.")
downloadedImagesUri = listOf(Uri.fromFile(image1), Uri.fromFile(image2))
} else { // Download image from URL.
Log.d(TAG, "Downloading images ...")
InstrumentationRegistry.getInstrumentation().targetContext
.let { downloadedImagesUri = ImageProvider().downloadImagesToUri(it, 2) }
Log.d(TAG, "Images downloaded.")
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment