summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortobrun <tobrun.van.nuland@gmail.com>2018-07-09 11:31:16 +0200
committerTobrun <tobrun@mapbox.com>2018-07-09 19:55:41 +0200
commitcd01c29082500e67d446a42df7b01344b0995599 (patch)
tree1e737c7b5277df5f63e91d0138475dfbf1be051a
parent94b8e00d781d732128c89bb68678eab1da90fa9a (diff)
downloadqtlocation-mapboxgl-cd01c29082500e67d446a42df7b01344b0995599.tar.gz
- fix jni method lookup of GeometryCollection accessor geometries, add regression test
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/GeoJsonConversionTest.java49
-rw-r--r--platform/android/src/geojson/geometry_collection.cpp2
2 files changed, 50 insertions, 1 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/GeoJsonConversionTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/GeoJsonConversionTest.java
new file mode 100644
index 0000000000..197ab744e4
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/GeoJsonConversionTest.java
@@ -0,0 +1,49 @@
+package com.mapbox.mapboxsdk.testapp.geometry;
+
+import com.mapbox.geojson.Feature;
+import com.mapbox.geojson.FeatureCollection;
+import com.mapbox.geojson.GeometryCollection;
+import com.mapbox.mapboxsdk.geometry.LatLngBounds;
+import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
+import com.mapbox.mapboxsdk.style.sources.CustomGeometrySource;
+import com.mapbox.mapboxsdk.style.sources.GeometryTileProvider;
+import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
+import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
+import org.junit.Test;
+
+import java.util.Collections;
+
+import static junit.framework.Assert.assertNotNull;
+
+/**
+ * Instrumentation test to validate java geojson conversion to c++
+ */
+public class GeoJsonConversionTest extends BaseActivityTest {
+
+ // Regression test for #12343
+ @Test
+ public void testGetCameraForLatLngBounds() {
+ validateTestSetup();
+ onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
+ mapboxMap.addSource(new CustomGeometrySource("test-id", new CustomProvider()));
+ mapboxMap.addLayer(new SymbolLayer("test-id", "test-id"));
+ assertNotNull(mapboxMap);
+ }));
+ }
+
+ @Override
+ protected Class getActivityClass() {
+ return EspressoTestActivity.class;
+ }
+
+ class CustomProvider implements GeometryTileProvider {
+ @Override
+ public FeatureCollection getFeaturesForBounds(LatLngBounds bounds, int zoom) {
+ return FeatureCollection.fromFeatures(
+ Collections.singletonList(
+ Feature.fromGeometry(
+ GeometryCollection.fromGeometries(
+ Collections.emptyList()))));
+ }
+ }
+}
diff --git a/platform/android/src/geojson/geometry_collection.cpp b/platform/android/src/geojson/geometry_collection.cpp
index eb3a790404..770cb9a5d6 100644
--- a/platform/android/src/geojson/geometry_collection.cpp
+++ b/platform/android/src/geojson/geometry_collection.cpp
@@ -30,7 +30,7 @@ jni::Object<GeometryCollection> GeometryCollection::New(jni::JNIEnv& env, const
mapbox::geometry::geometry_collection<double> GeometryCollection::convert(jni::JNIEnv &env, jni::Object<GeometryCollection> jCollection) {
// Get geometries
- static auto getGeometries = javaClass.GetMethod<jni::Object<java::util::List> ()>(env, "getGeometries");
+ static auto getGeometries = javaClass.GetMethod<jni::Object<java::util::List> ()>(env, "geometries");
auto jList = jCollection.Call(env, getGeometries);
// Turn into array