diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2016-06-23 16:39:27 +0200 |
---|---|---|
committer | Ivo van Dongen <info@ivovandongen.nl> | 2016-10-25 16:48:26 +0200 |
commit | 848f2c24cfbe9d1c32cfdd6988067cb58cd691c8 (patch) | |
tree | 469e6209777f1afc137808c513fd55c53fa79e3d | |
parent | b14e83ea403662f3e10b9bce95f9b78e5cacea39 (diff) | |
download | qtlocation-mapboxgl-848f2c24cfbe9d1c32cfdd6988067cb58cd691c8.tar.gz |
[android] initial setup with a shared test lib and a main class
-rw-r--r-- | test/src/Main.java | 13 | ||||
-rw-r--r-- | test/src/main.jni.cpp | 22 | ||||
-rw-r--r-- | test/src/mbgl/test/util.hpp | 6 |
3 files changed, 36 insertions, 5 deletions
diff --git a/test/src/Main.java b/test/src/Main.java new file mode 100644 index 0000000000..e20aa7db3f --- /dev/null +++ b/test/src/Main.java @@ -0,0 +1,13 @@ +public class Main { + public native void runAllTests(); + + public static void main(String[] args) throws Exception { + //Need to load the mapbox-gl library explicitly first + System.loadLibrary("mapbox-gl"); + //Load the tests + System.loadLibrary("test-jni-lib"); + System.out.println("Libraries loaded"); + //Run the tests + new Main().runAllTests(); + } +} diff --git a/test/src/main.jni.cpp b/test/src/main.jni.cpp new file mode 100644 index 0000000000..aa4d9d07c2 --- /dev/null +++ b/test/src/main.jni.cpp @@ -0,0 +1,22 @@ +#include <jni/jni.hpp> +#include <mbgl/test.hpp> + +#pragma clang diagnostic ignored "-Wunused-parameter" + +void runAllTests(JNIEnv *env, jni::jobject* obj) { + std::cout << "Starting tests"; + mbgl::runTests(0, nullptr); +} + +extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) { + std::cout << "Loading tests"; + + struct Main { static constexpr auto Name() { return "Main"; } }; + + jni::JNIEnv& env = jni::GetEnv(*vm, jni::jni_version_1_6); + + #define MAKE_NATIVE_METHOD(name, sig) jni::MakeNativeMethod<decltype(name), name>( #name, sig ) + jni::RegisterNatives(env, jni::Class<Main>::Find(env), MAKE_NATIVE_METHOD(runAllTests, "()V")); + + return JNI_VERSION_1_6; +} diff --git a/test/src/mbgl/test/util.hpp b/test/src/mbgl/test/util.hpp index ce0069131c..7ec395ed00 100644 --- a/test/src/mbgl/test/util.hpp +++ b/test/src/mbgl/test/util.hpp @@ -4,13 +4,9 @@ #include <TargetConditionals.h> #endif -#if TARGET_OS_IOS #define TEST_READ_ONLY 1 #define TEST_HAS_SERVER 0 -#else -#define TEST_READ_ONLY 0 -#define TEST_HAS_SERVER 1 -#endif + #if TARGET_OS_SIMULATOR #define TEST_IS_SIMULATOR 1 |