summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2016-06-27 18:12:24 +0200
committerIvo van Dongen <info@ivovandongen.nl>2016-07-07 10:08:43 +0200
commit3981747815f80e5edb52b7604cd281e2c0b7ad81 (patch)
treea064cf6027a6e500836004af1ff2ec966aa8d544
parenta09fb9526ad16ba9168c04950cbd656ec3ec8202 (diff)
downloadqtlocation-mapboxgl-3981747815f80e5edb52b7604cd281e2c0b7ad81.tar.gz
[android] #5456- First tests running on the vm - still a lot of hacks to get it going
-rw-r--r--Makefile25
-rw-r--r--platform/android/platform.gyp11
-rwxr-xr-xplatform/android/src/jni.cpp2
-rw-r--r--test/src/Main.java11
-rw-r--r--test/src/main.jni.cpp4
-rw-r--r--test/test.gypi19
6 files changed, 36 insertions, 36 deletions
diff --git a/Makefile b/Makefile
index 293dc9a363..4c4a4abfe5 100644
--- a/Makefile
+++ b/Makefile
@@ -175,10 +175,7 @@ build/android-$1/Makefile: platform/android/platform.gyp build/android-$1/config
$$(shell $(ANDROID_ENV) $1) $(GYP) -f make-android -I build/android-$1/config.gypi \
--generator-output=build/android-$1 $$<
-android-lib-$1: build/android-$1/Makefile
- $$(shell $(ANDROID_ENV) $1) $(MAKE) -j$(JOBS) -C build/android-$1 all
-
-test-android-$1: node_modules android-lib-$1
+android-test-lib-$1: build/android-$1/Makefile
$$(shell $(ANDROID_ENV) $1) $(MAKE) -j$(JOBS) -C build/android-$1 test
android-lib-$1: build/android-$1/Makefile
@@ -192,19 +189,25 @@ $(foreach abi,$(ANDROID_ABIS),$(eval $(call ANDROID_RULES,$(abi))))
android: android-arm-v7
-test-android: test-android-arm-v7
-#TODO Decide where to place the class files and other tmp outputs
+test-android: android-test-lib-arm-v7
+ #TODO Decide where to place the class files and other tmp outputs
+ #Compile main sources and extract the classes (using the test app to get all transitive dependencies in one place)
+ cd platform/android && ./gradlew assembleDebug
+ unzip -o platform/android/MapboxGLAndroidSDKTestApp/build/outputs/apk/MapboxGLAndroidSDKTestApp-debug.apk classes.dex -d build
+ #Compile Test runner
javac -sourcepath test/src -d build -source 1.7 -target 1.7 test/src/Main.java
- cd build && dx --dex --output=test.jar Main.class
+ #Combine and dex
+ cd build && dx --dex --output=test.jar Main.class classes.dex
+ #Push all needed files to the device
adb push build/test.jar /data/local/tmp/
- adb shell "LD_LIBRARY_PATH=/data/local/tmp dalvikvm -cp /data/local/tmp/test.jar Main"
- #cd platform/android && ./gradlew testReleaseUnitTest --continue
+ adb push build/android-arm-v7/Debug/lib.target/libmapbox-gl.so /data/local/tmp/
+ adb push build/android-arm-v7/Debug/lib.target/libtest-jni-lib.so /data/local/tmp/
+ adb shell "LD_LIBRARY_PATH=/data/local/tmp dalvikvm32 -cp /data/local/tmp/test.jar Main"
+ #TODO - Renable platform tests cd platform/android && ./gradlew testReleaseUnitTest --continue
apackage:
cd platform/android && ./gradlew --parallel-threads=$(JOBS) assemble$(BUILDTYPE)
-#test-android-arm-v7: node_modules android-lib-arm-v7
-# $$(shell $(ANDROID_ENV) arm-v7) $(MAKE) -j$(JOBS) -C build/android-arm-v7 test
#### Node targets #####################################################
diff --git a/platform/android/platform.gyp b/platform/android/platform.gyp
index 34524408da..5d0083fde6 100644
--- a/platform/android/platform.gyp
+++ b/platform/android/platform.gyp
@@ -161,9 +161,20 @@
],
'cflags_cc': [
+ '<@(boost_cflags)',
+ '<@(rapidjson_cflags)',
+ '<@(nunicode_cflags)',
+ '<@(sqlite_cflags)',
'<@(jni.hpp_cflags)',
+ '<@(libzip_cflags)',
+ '<@(libpng_cflags)',
+ '<@(libjpeg-turbo_cflags)',
],
+# 'cflags_cc': [
+# '<@(jni.hpp_cflags)',
+# ],
+
'link_settings': {
'libraries': [
'-llog',
diff --git a/platform/android/src/jni.cpp b/platform/android/src/jni.cpp
index 311f97b3d9..3b2f6b3625 100755
--- a/platform/android/src/jni.cpp
+++ b/platform/android/src/jni.cpp
@@ -1540,7 +1540,7 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
static mbgl::util::RunLoop mainRunLoop;
- mbgl::android::RegisterNativeHTTPRequest(env);
+ //XXX Need to figure out why this breaks everything mbgl::android::RegisterNativeHTTPRequest(env);
latLngClass = &jni::FindClass(env, "com/mapbox/mapboxsdk/geometry/LatLng");
latLngClass = jni::NewGlobalRef(env, latLngClass).release();
diff --git a/test/src/Main.java b/test/src/Main.java
index 7cb601f365..87f2a3949c 100644
--- a/test/src/Main.java
+++ b/test/src/Main.java
@@ -1,8 +1,11 @@
public class Main {
- public native void run();
+ public native void runAllTests();
- public static void main(String[] args) {
- System.loadLibrary("test-lib");
- new Main().run();
+ public static void main(String[] args) throws Exception {
+ //System.out.println(Class.forName("com.mapbox.mapboxsdk.geometry.LatLng"));
+ System.loadLibrary("mapbox-gl");
+ System.loadLibrary("test-jni-lib");
+ System.out.println("Libraries loaded");
+ new Main().runAllTests();
}
}
diff --git a/test/src/main.jni.cpp b/test/src/main.jni.cpp
index 0e74698654..aa4d9d07c2 100644
--- a/test/src/main.jni.cpp
+++ b/test/src/main.jni.cpp
@@ -4,16 +4,18 @@
#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::jclass mainClass = jni::Class<Main>::Find(env);
jni::RegisterNatives(env, jni::Class<Main>::Find(env), MAKE_NATIVE_METHOD(runAllTests, "()V"));
return JNI_VERSION_1_6;
diff --git a/test/test.gypi b/test/test.gypi
index 52896379e7..df0ad448aa 100644
--- a/test/test.gypi
+++ b/test/test.gypi
@@ -80,25 +80,6 @@
'include',
],
- # Force the linker to include all the objects from the lib-test archive. Otherwise they'd
- # be discarded because there are no undefined symbols to pull them in, and the resulting
- # executable would run zero tests.
-
- 'conditions': [
- ['OS == "mac"', {
- 'xcode_settings': {
- 'OTHER_LDFLAGS': [
- '-Wl,-force_load,<(PRODUCT_DIR)/libtest-lib.a',
- ],
- }
- }, {
- 'link_settings': {
- 'ldflags': [
- '-Wl,-whole-archive <(PRODUCT_DIR)/libtest-lib.a -Wl,-no-whole-archive',
- ],
- },
- }],
- ],
},
},
]