summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2016-06-23 16:39:27 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2016-11-17 01:04:16 +0100
commita27bda98510f4a32c4ea7ea3c18489bd12e75cc6 (patch)
tree3ef6e5c97e3dbece01b74af91ea16201f3e38e94
parenta5ac64316642cacb32466ea24ba2bf29b8d35da4 (diff)
downloadqtlocation-mapboxgl-a27bda98510f4a32c4ea7ea3c18489bd12e75cc6.tar.gz
[android] initial setup with a shared test lib and a main class
-rw-r--r--test/src/Main.java13
-rw-r--r--test/src/main.jni.cpp22
-rw-r--r--test/src/mbgl/test/util.hpp6
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 8445822699..79bdfed431 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