[test-android] Tests are now runnable as ./gradlew connectedCheck

This commit is contained in:
atsushieno 2021-06-12 00:57:37 +09:00
parent f176cd8e7b
commit 7dd8f0118c
4 changed files with 19 additions and 22 deletions

View file

@ -2,6 +2,7 @@ package org.fluidsynth.fluidsynth_tests
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.fluidsynth.fluidsynthtests.TestRunner
import org.junit.Test
import org.junit.runner.RunWith
@ -20,5 +21,7 @@ class ExampleInstrumentedTest {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("org.fluidsynth.fluidsynth_tests", appContext.packageName)
TestRunner.runTests()
}
}

View file

@ -1,14 +1,9 @@
#include <jni.h>
#include <string>
#include <jni.h>
extern "C" int run_all_fluidsynth_tests();
extern "C" JNIEXPORT jstring JNICALL
Java_org_fluidsynth_fluidsynthtests_MainActivity_stringFromJNI(
JNIEnv* env,
jobject /* this */) {
extern "C" JNIEXPORT void JNICALL Java_org_fluidsynth_fluidsynthtests_TestRunner_00024Companion_runTests(JNIEnv* env, jobject thiz) {
run_all_fluidsynth_tests();
std::string hello = "Hello from C++";
return env->NewStringUTF(hello.c_str());
}
}

View file

@ -14,20 +14,9 @@ class MainActivity : AppCompatActivity() {
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
TestRunner.runTests()
// Example of a call to a native method
binding.sampleText.text = stringFromJNI()
}
/**
* A native method that is implemented by the 'native-lib' native library,
* which is packaged with this application.
*/
external fun stringFromJNI(): String
companion object {
// Used to load the 'native-lib' library on application startup.
init {
System.loadLibrary("native-lib")
}
binding.sampleText.text = "If this shows up then there was no reported test failure!"
}
}

View file

@ -0,0 +1,10 @@
package org.fluidsynth.fluidsynthtests
class TestRunner {
companion object {
external fun runTests()
init {
System.loadLibrary("native-lib")
}
}
}