diff options
author | Tobrun <tobrun.van.nuland@gmail.com> | 2015-12-08 10:12:26 -0800 |
---|---|---|
committer | Tobrun <tobrun.van.nuland@gmail.com> | 2015-12-08 15:04:04 -0800 |
commit | b7037bb4b1ead048fcb8afecb13e74ef2b27080c (patch) | |
tree | 8e49303d771997ab80980452755053b8ef5f3747 /android | |
parent | 55d97c1ad150863f153caad6ba81a7f31ab1941e (diff) | |
download | qtlocation-mapboxgl-b7037bb4b1ead048fcb8afecb13e74ef2b27080c.tar.gz |
[android] #3221 - added unit test for Polyline and Polygon, updated test for Marker
Diffstat (limited to 'android')
3 files changed, 164 insertions, 2 deletions
diff --git a/android/MapboxGLAndroidSDKTestApp/src/test/java/annotations/MarkerTest.java b/android/MapboxGLAndroidSDKTestApp/src/test/java/annotations/MarkerTest.java index b00322db7b..3c6618d83b 100644 --- a/android/MapboxGLAndroidSDKTestApp/src/test/java/annotations/MarkerTest.java +++ b/android/MapboxGLAndroidSDKTestApp/src/test/java/annotations/MarkerTest.java @@ -13,8 +13,14 @@ public class MarkerTest { @Test public void testSanity() { - Marker marker = new MarkerOptions().getMarker(); - assertNotNull("marker should not be null", marker); + MarkerOptions markerOptions = new MarkerOptions(); + assertNotNull("markerOptions should not be null", markerOptions); + } + + @Test + public void testMarker() { + MarkerOptions markerOptions = new MarkerOptions(); + assertNotNull("marker should not be null", markerOptions.getMarker()); } @Test diff --git a/android/MapboxGLAndroidSDKTestApp/src/test/java/annotations/PolygonTest.java b/android/MapboxGLAndroidSDKTestApp/src/test/java/annotations/PolygonTest.java new file mode 100644 index 0000000000..0d15f95b4a --- /dev/null +++ b/android/MapboxGLAndroidSDKTestApp/src/test/java/annotations/PolygonTest.java @@ -0,0 +1,79 @@ +package annotations; + +import com.mapbox.mapboxsdk.annotations.Polygon; +import com.mapbox.mapboxsdk.annotations.PolygonOptions; +import com.mapbox.mapboxsdk.annotations.Polyline; +import com.mapbox.mapboxsdk.annotations.PolylineOptions; +import com.mapbox.mapboxsdk.geometry.LatLng; + +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class PolygonTest { + + @Test + public void testSanity() { + PolygonOptions polygonOptions = new PolygonOptions(); + assertNotNull("polygonOptions should not be null", polygonOptions); + } + + @Test + public void testPolygon() { + Polygon polygon = new PolygonOptions().getPolygon(); + assertNotNull("polyline should not be null", polygon); + } + + @Test + public void testAlpha() { + Polygon polygon = new PolygonOptions().alpha(0.5f).getPolygon(); + assertEquals(0.5f, polygon.getAlpha(), 0.0f); + } + + @Test + public void testStrokeColor() { + Polygon polygon = new PolygonOptions().strokeColor(1).getPolygon(); + assertEquals(1, polygon.getStrokeColor()); + } + + @Test + public void testFillColor() { + Polygon polygon = new PolygonOptions().fillColor(1).getPolygon(); + assertEquals(1, polygon.getFillColor()); + } + + @Test + public void testLatLng() { + Polygon polygon = new PolygonOptions().add(new LatLng(0, 0)).getPolygon(); + assertNotNull("points should not be null", polygon.getPoints()); + assertEquals(new LatLng(0, 0), polygon.getPoints().get(0)); + } + + @Test + public void testAddAllLatLng() { + List<LatLng> coordinates = new ArrayList<>(); + coordinates.add(new LatLng(0, 0)); + Polygon polygon = new PolygonOptions().addAll(coordinates).getPolygon(); + assertNotNull(polygon.getPoints()); + assertEquals(new LatLng(0, 0), polygon.getPoints().get(0)); + } + + @Test + public void testBuilder() { + PolylineOptions polylineOptions = new PolylineOptions(); + polylineOptions.width(1.0f); + polylineOptions.color(2); + polylineOptions.add(new LatLng(0, 0)); + + Polyline polyline = polylineOptions.getPolyline(); + assertEquals(1.0f, polyline.getWidth(), 0); + assertEquals(2, polyline.getColor()); + assertNotNull("Points should not be null", polyline.getPoints()); + assertEquals(new LatLng(0, 0), polyline.getPoints().get(0)); + } + +} diff --git a/android/MapboxGLAndroidSDKTestApp/src/test/java/annotations/PolylineTest.java b/android/MapboxGLAndroidSDKTestApp/src/test/java/annotations/PolylineTest.java new file mode 100644 index 0000000000..967d6ccea5 --- /dev/null +++ b/android/MapboxGLAndroidSDKTestApp/src/test/java/annotations/PolylineTest.java @@ -0,0 +1,77 @@ +package annotations; + +import com.mapbox.mapboxsdk.annotations.Polyline; +import com.mapbox.mapboxsdk.annotations.PolylineOptions; +import com.mapbox.mapboxsdk.geometry.LatLng; + +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class PolylineTest { + + @Test + public void testSanity() { + PolylineOptions polylineOptions = new PolylineOptions(); + assertNotNull("polylineOptions should not be null", polylineOptions); + } + + @Test + public void testPolyline() { + Polyline polyline = new PolylineOptions().getPolyline(); + assertNotNull("polyline should not be null", polyline); + } + + @Test + public void testAlpha() { + Polyline polyline = new PolylineOptions().alpha(0.2f).getPolyline(); + assertEquals(0.2f, polyline.getAlpha(), 0.0f); + } + + @Test + public void testWidth() { + Polyline polyline = new PolylineOptions().width(1).getPolyline(); + assertEquals(1.0f, polyline.getWidth(), 0); + } + + @Test + public void testColor() { + Polyline polyline = new PolylineOptions().color(1).getPolyline(); + assertEquals(1, polyline.getColor()); + } + + @Test + public void testAddLatLng() { + Polyline polyline = new PolylineOptions().add(new LatLng(0, 0)).getPolyline(); + assertNotNull("Points should not be null", polyline.getPoints()); + assertEquals(new LatLng(0, 0), polyline.getPoints().get(0)); + } + + @Test + public void testAddAllLatLng() { + List<LatLng> coordinates = new ArrayList<>(); + coordinates.add(new LatLng(0, 0)); + Polyline polyline = new PolylineOptions().addAll(coordinates).getPolyline(); + assertNotNull(polyline.getPoints()); + assertEquals(new LatLng(0, 0), polyline.getPoints().get(0)); + } + + @Test + public void testBuilder() { + PolylineOptions polylineOptions = new PolylineOptions(); + polylineOptions.width(1.0f); + polylineOptions.color(2); + polylineOptions.add(new LatLng(0, 0)); + + Polyline polyline = polylineOptions.getPolyline(); + assertEquals(1.0f, polyline.getWidth(), 0); + assertEquals(2, polyline.getColor()); + assertNotNull("Points should not be null", polyline.getPoints()); + assertEquals(new LatLng(0, 0), polyline.getPoints().get(0)); + } + +} |