summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortobrun <tobrun.van.nuland@gmail.com>2018-07-10 12:15:49 +0200
committertobrun <tobrun.van.nuland@gmail.com>2018-07-11 16:39:22 +0200
commitc1148a5fcd9edaae888f11ede2e0560cc21695e0 (patch)
treecec8de0810eecfc5861c9dc880154359cebb183b
parentec8ac3c64fd4a89b0744da970eb221af3567707c (diff)
downloadqtlocation-mapboxgl-upstream/tvn-geojson-methodlookup-test.tar.gz
[android] - add geojson regression tests for java method look up from JNIupstream/tvn-geojson-methodlookup-test
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/GeoJsonConversionTest.java116
1 files changed, 103 insertions, 13 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
index 197ab744e4..773a81705d 100644
--- 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
@@ -1,8 +1,8 @@
package com.mapbox.mapboxsdk.testapp.geometry;
-import com.mapbox.geojson.Feature;
import com.mapbox.geojson.FeatureCollection;
-import com.mapbox.geojson.GeometryCollection;
+import com.mapbox.geojson.Point;
+import com.mapbox.geojson.Polygon;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
import com.mapbox.mapboxsdk.style.sources.CustomGeometrySource;
@@ -11,9 +11,14 @@ 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;
+import static com.mapbox.geojson.Feature.fromGeometry;
+import static com.mapbox.geojson.FeatureCollection.fromFeatures;
+import static com.mapbox.geojson.GeometryCollection.fromGeometries;
+import static com.mapbox.geojson.LineString.fromLngLats;
+import static com.mapbox.geojson.MultiLineString.fromLineString;
+import static com.mapbox.geojson.MultiPolygon.fromPolygon;
+import static java.util.Collections.emptyList;
+import static java.util.Collections.singletonList;
/**
* Instrumentation test to validate java geojson conversion to c++
@@ -22,12 +27,94 @@ public class GeoJsonConversionTest extends BaseActivityTest {
// Regression test for #12343
@Test
- public void testGetCameraForLatLngBounds() {
+ public void testEmptyFeatureCollection() {
+ validateTestSetup();
+ onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
+ mapboxMap.addSource(
+ new CustomGeometrySource("test-id",
+ new CustomProvider(fromFeatures(singletonList(fromGeometry(fromGeometries(emptyList())))))
+ )
+ );
+ mapboxMap.addLayer(new SymbolLayer("test-id", "test-id"));
+ }));
+ }
+
+ @Test
+ public void testPointFeatureCollection() {
+ validateTestSetup();
+ onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
+ mapboxMap.addSource(
+ new CustomGeometrySource("test-id",
+ new CustomProvider(fromFeatures(singletonList(fromGeometry(Point.fromLngLat(0.0,0.0)))))
+ )
+ );
+ mapboxMap.addLayer(new SymbolLayer("test-id", "test-id"));
+ }));
+ }
+
+ @Test
+ public void testMultiPointFeatureCollection() {
+ validateTestSetup();
+ onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
+ mapboxMap.addSource(
+ new CustomGeometrySource("test-id",
+ new CustomProvider(fromFeatures(singletonList(fromGeometry(fromLngLats(emptyList())))))
+ )
+ );
+ mapboxMap.addLayer(new SymbolLayer("test-id", "test-id"));
+ }));
+ }
+
+
+ @Test
+ public void testPolygonFeatureCollection() {
+ validateTestSetup();
+ onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
+ mapboxMap.addSource(
+ new CustomGeometrySource("test-id",
+ new CustomProvider(fromFeatures(singletonList(fromGeometry(Polygon.fromLngLats(emptyList())))))
+ )
+ );
+ mapboxMap.addLayer(new SymbolLayer("test-id", "test-id"));
+ }));
+ }
+
+ @Test
+ public void testMultiPolygonFeatureCollection() {
+ validateTestSetup();
+ onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
+ mapboxMap.addSource(
+ new CustomGeometrySource("test-id",
+ new CustomProvider(fromFeatures(singletonList(fromGeometry(fromPolygon(Polygon.fromLngLats(emptyList()))))))
+ )
+ );
+ mapboxMap.addLayer(new SymbolLayer("test-id", "test-id"));
+ }));
+ }
+
+ @Test
+ public void testLineStringFeatureCollection() {
+ validateTestSetup();
+ onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
+ mapboxMap.addSource(
+ new CustomGeometrySource("test-id",
+ new CustomProvider(fromFeatures(singletonList(fromGeometry(fromLngLats(emptyList())))))
+ )
+ );
+ mapboxMap.addLayer(new SymbolLayer("test-id", "test-id"));
+ }));
+ }
+
+ @Test
+ public void testMultiLineStringFeatureCollection() {
validateTestSetup();
onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- mapboxMap.addSource(new CustomGeometrySource("test-id", new CustomProvider()));
+ mapboxMap.addSource(
+ new CustomGeometrySource("test-id",
+ new CustomProvider(fromFeatures(singletonList(fromGeometry(fromLineString(fromLngLats(emptyList()))))))
+ )
+ );
mapboxMap.addLayer(new SymbolLayer("test-id", "test-id"));
- assertNotNull(mapboxMap);
}));
}
@@ -37,13 +124,16 @@ public class GeoJsonConversionTest extends BaseActivityTest {
}
class CustomProvider implements GeometryTileProvider {
+
+ private FeatureCollection featureCollection;
+
+ CustomProvider(FeatureCollection featureCollection) {
+ this.featureCollection = featureCollection;
+ }
+
@Override
public FeatureCollection getFeaturesForBounds(LatLngBounds bounds, int zoom) {
- return FeatureCollection.fromFeatures(
- Collections.singletonList(
- Feature.fromGeometry(
- GeometryCollection.fromGeometries(
- Collections.emptyList()))));
+ return featureCollection;
}
}
}