From 1b58e87f154bf7d3d5f38ef32cc4b171362f73a2 Mon Sep 17 00:00:00 2001 From: zmiao Date: Tue, 19 Nov 2019 20:45:30 +0200 Subject: [render-test] Wrap test data inside RenderTestRunner App + Add a new test app (#15887) * [render-test] Wrap test resources inside app * [render-test] Add test app * fix test app failure * [render-test]add callback + add javaObjectWrapper --- render-test/android/README.md | 8 +---- render-test/android/app/build.gradle | 4 +++ .../java/android/app/NativeActivityTest.java | 29 +++++++++++++++ .../androidTest/java/android/app/TestState.java | 5 +++ .../android/app/src/main/AndroidManifest.xml | 2 +- render-test/android/app/src/main/assets/to_zip.txt | 15 ++++++++ render-test/android/render_test_setup.sh | 42 ---------------------- 7 files changed, 55 insertions(+), 50 deletions(-) create mode 100644 render-test/android/app/src/androidTest/java/android/app/NativeActivityTest.java create mode 100644 render-test/android/app/src/androidTest/java/android/app/TestState.java create mode 100644 render-test/android/app/src/main/assets/to_zip.txt delete mode 100755 render-test/android/render_test_setup.sh (limited to 'render-test/android') diff --git a/render-test/android/README.md b/render-test/android/README.md index 270c970fce..4037419012 100644 --- a/render-test/android/README.md +++ b/render-test/android/README.md @@ -1,9 +1,3 @@ # RenderTestRunner -This app is a purely native application, with no Java source code, that can run **mbgl-render-test-runner** on android devices. - - -## Setup the test environment -- Run render_test_setup.sh so that all the necessary test resources are pushed to the device. - -- Switch on storage permission of the app so that it can read/write data on SD card. \ No newline at end of file +This app is a purely native application, with no Java source code, that can run **mbgl-render-test-runner** on android devices. \ No newline at end of file diff --git a/render-test/android/app/build.gradle b/render-test/android/app/build.gradle index 60609e3ba2..682af85dcf 100644 --- a/render-test/android/app/build.gradle +++ b/render-test/android/app/build.gradle @@ -14,6 +14,7 @@ android { targets 'mbgl-render-test-runner' } } + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } externalNativeBuild { cmake { @@ -26,4 +27,7 @@ android { dependencies { implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + androidTestImplementation 'androidx.test.ext:junit:1.1.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-beta01' + androidTestImplementation 'androidx.test:rules:1.2.0-beta01' } diff --git a/render-test/android/app/src/androidTest/java/android/app/NativeActivityTest.java b/render-test/android/app/src/androidTest/java/android/app/NativeActivityTest.java new file mode 100644 index 0000000000..3d8c333902 --- /dev/null +++ b/render-test/android/app/src/androidTest/java/android/app/NativeActivityTest.java @@ -0,0 +1,29 @@ +package android.app; + +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import android.util.Log; + +@LargeTest +@RunWith(AndroidJUnit4.class) +public class NativeActivityTest { + + @Rule + public ActivityTestRule mActivityTestRule = new ActivityTestRule<>(NativeActivity.class, false, false); + + @Test(timeout = 1200000L) + public void runRenderTests() throws Exception { + Log.v("Test", "Start the test"); + mActivityTestRule.launchActivity(null); + while (TestState.running) { + Log.v("Test", "Test is running"); + Thread.sleep(1000L); + } + Log.v("Test", "End the test"); + } +} \ No newline at end of file diff --git a/render-test/android/app/src/androidTest/java/android/app/TestState.java b/render-test/android/app/src/androidTest/java/android/app/TestState.java new file mode 100644 index 0000000000..44a0653fb6 --- /dev/null +++ b/render-test/android/app/src/androidTest/java/android/app/TestState.java @@ -0,0 +1,5 @@ +package android.app; + +public class TestState { + static boolean running = true; +} \ No newline at end of file diff --git a/render-test/android/app/src/main/AndroidManifest.xml b/render-test/android/app/src/main/AndroidManifest.xml index 6c7af7ed8f..8df48ef97f 100644 --- a/render-test/android/app/src/main/AndroidManifest.xml +++ b/render-test/android/app/src/main/AndroidManifest.xml @@ -9,7 +9,7 @@ android:fullBackupContent="false" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" - android:hasCode="false"> + android:hasCode="true">