diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/test/java')
10 files changed, 694 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/BoundingBoxTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/BoundingBoxTest.java new file mode 100644 index 0000000000..f03766c9e5 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/BoundingBoxTest.java @@ -0,0 +1,180 @@ +import com.mapbox.mapboxsdk.geometry.BoundingBox; +import com.mapbox.mapboxsdk.geometry.CoordinateSpan; +import com.mapbox.mapboxsdk.geometry.LatLng; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +public class BoundingBoxTest { + + private BoundingBox mBoundingBox; + + @Before + public void setup() { + mBoundingBox = new BoundingBox(20.0, 10.0, 0.0, 0.0); + } + + @Test + public void testSanity() { + BoundingBox boundingBox = new BoundingBox(0.0, 0.0, 0.0, 0.0); + assertNotNull("boundingBox should not be null", boundingBox); + } + + @Test + public void testDefaultConstructor() { + mBoundingBox = new BoundingBox(0, 0, 0, 0); + assertEquals(mBoundingBox, new BoundingBox()); + } + + @Test + public void testEqualityConstructors() { + BoundingBox cornerBoundingBox = new BoundingBox(new LatLng(20.0, 10.0), new LatLng(0.0, 0.0)); + BoundingBox cloneBoundingBox = new BoundingBox(mBoundingBox); + assertEquals("boundingBoxes should match", mBoundingBox, cornerBoundingBox); + assertEquals("boundingBoxes should match", mBoundingBox, cloneBoundingBox); + } + + @Test + public void testValidBox() { + assertTrue(mBoundingBox.isValid()); + } + + @Test + public void testInvalidLatitudeSpanBox() { + mBoundingBox = new BoundingBox(0.0, 10.0, 10.0, 0.0); + assertFalse(mBoundingBox.isValid()); + } + + @Test + public void testInvalidLongitudeSpanBox() { + mBoundingBox = new BoundingBox(10.0, 0.0, 0.0, 20.0); + assertFalse(mBoundingBox.isValid()); + } + + @Test + public void testCenterCoordinate() { + LatLng center = new LatLng(10.0, 5.0); + assertEquals("boundingBox center should match", center, mBoundingBox.getCenter()); + } + + @Test + public void testUnionSameBox() { + assertEquals(mBoundingBox, mBoundingBox.union(mBoundingBox)); + } + + @Test + public void testUnionInnerBox() { + BoundingBox innerBox = new BoundingBox(2.0, 2.0, 1.0, 1.0); + assertEquals(mBoundingBox.union(innerBox), mBoundingBox); + } + + @Test + public void testUnionOverlapBox() { + BoundingBox resultBox = new BoundingBox(22.0, 12.0, 0.0, 0.0); + BoundingBox overlapBox = new BoundingBox(22.0, 12.0, 1.0, 1.0); + assertEquals(resultBox, mBoundingBox.union(overlapBox)); + } + + @Test + public void testUnionOuterBox() { + BoundingBox resultBox = new BoundingBox(40.0, 40.0, 0.0, 0.0); + BoundingBox outerBox = new BoundingBox(40.0, 40.0, 0.0, 0.0); + assertEquals(resultBox, mBoundingBox.union(outerBox)); + } + + @Test + public void testIntersectSameBox() { + assertEquals(mBoundingBox, mBoundingBox.intersect(mBoundingBox)); + } + + @Test + public void testIntersectInnerBox() { + BoundingBox innerBox = new BoundingBox(2.0, 2.0, 1.0, 1.0); + assertEquals(innerBox, mBoundingBox.intersect(innerBox)); + } + + @Test + public void testIntersectOuterBox() { + BoundingBox outerBox = new BoundingBox(40.0, 40.0, 0.0, 0.0); + assertEquals(mBoundingBox, mBoundingBox.intersect(outerBox)); + } + + @Test + public void testIntersectOverlapBox() { + BoundingBox resultBox = new BoundingBox(20.0, 10.0, 1.0, 1.0); + BoundingBox overlapBox = new BoundingBox(22.0, 12.0, 1.0, 1.0); + assertEquals(resultBox, mBoundingBox.intersect(overlapBox)); + } + + @Test + public void testIntersectNoneBox() { + BoundingBox outsideBox = new BoundingBox(100.0, 100.0, 50.0, 50.0); + assertNull(mBoundingBox.intersect(outsideBox)); + } + + @Test + public void testContainsCoordinate() { + LatLng coordinate = new LatLng(1.0, 1.0); + assertTrue(mBoundingBox.contains(coordinate)); + } + + @Test + public void testContainsCoordinateOnBoundary() { + LatLng coordinate = new LatLng(20.0, 9.0); + assertFalse(mBoundingBox.contains(coordinate)); + } + + @Test + public void testContainsNoCoordinate() { + LatLng coordinate = new LatLng(100.0, 100.0); + assertFalse(mBoundingBox.contains(coordinate)); + } + + @Test + public void testSpan() { + CoordinateSpan span = new CoordinateSpan(20.0, 10.0); + assertTrue(mBoundingBox.getSpan().equals(span)); + } + + @Test + public void testLatitudeSpan() { + double height = 20.0; + assertTrue(mBoundingBox.getLatitudeSpan() == height); + } + + @Test + public void testLongitudeSpan() { + double width = 10.0; + assertTrue(mBoundingBox.getLongitudeSpan() == width); + } + + @Test + public void testEmptySpanEmptyNotEmptyBox(){ + assertFalse(mBoundingBox.isEmpty()); + } + + @Test + public void testEmptySpanEmptyBox() { + mBoundingBox = new BoundingBox(); + assertTrue(mBoundingBox.isEmpty()); + } + + @Test + public void testEmptySpanEmptyLatitude() { + mBoundingBox = new BoundingBox(1.0, 2.0, 0.0, 2.0); + assertTrue(mBoundingBox.isEmpty()); + } + + @Test + public void testEmptySpanEmptyLongitude(){ + mBoundingBox = new BoundingBox(0.0, 3.0, 0.0, 1.0); + assertTrue(mBoundingBox.isEmpty()); + } + +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateBoundsTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateBoundsTest.java new file mode 100644 index 0000000000..a5d3891305 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateBoundsTest.java @@ -0,0 +1,58 @@ +import com.mapbox.mapboxsdk.geometry.CoordinateBounds; +import com.mapbox.mapboxsdk.geometry.LatLng; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +public class CoordinateBoundsTest { + + @Test + public void testSanity() { + CoordinateBounds coordinateBounds = new CoordinateBounds(null, null); + assertNotNull("coordinateBounds should not be null", coordinateBounds); + } + + @Test + public void testSouthWestConstructor() { + LatLng southWest = new LatLng(12, 12); + CoordinateBounds coordinateBounds = new CoordinateBounds(southWest, null); + assertEquals("southWest should match", southWest, coordinateBounds.getSouthWest()); + } + + @Test + public void testNorthEastConstructor() { + LatLng northEast = new LatLng(12, 12); + CoordinateBounds coordinateBounds = new CoordinateBounds(null, northEast); + assertEquals("northEast should match", northEast, coordinateBounds.getNorthEast()); + } + + @Test + public void testHashCode() { + LatLng northEast = new LatLng(60, 60); + LatLng southWest = new LatLng(43, 26); + CoordinateBounds coordinateBounds = new CoordinateBounds(northEast, southWest); + assertEquals("hash code should match", coordinateBounds.hashCode(), -1515487232); + } + + @Test + public void testToString() { + LatLng northEast = new LatLng(60, 60); + LatLng southWest = new LatLng(43, 26); + CoordinateBounds coordinateBounds = new CoordinateBounds(northEast, southWest); + assertEquals("string should match", + coordinateBounds.toString(), + "CoordinateBounds [northEast[" + coordinateBounds.getNorthEast() + "], southWest[]" + coordinateBounds.getSouthWest() + "]"); + } + + @Test + public void testEquals() { + LatLng northEast = new LatLng(60, 60); + LatLng southWest = new LatLng(43, 26); + CoordinateBounds firstBounds = new CoordinateBounds(northEast, southWest); + CoordinateBounds sameBounds = new CoordinateBounds(northEast, southWest); + assertTrue(firstBounds.equals(sameBounds)); + } +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateRegionTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateRegionTest.java new file mode 100644 index 0000000000..4690bd719b --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateRegionTest.java @@ -0,0 +1,54 @@ +import com.mapbox.mapboxsdk.geometry.CoordinateRegion; +import com.mapbox.mapboxsdk.geometry.CoordinateSpan; +import com.mapbox.mapboxsdk.geometry.LatLng; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class CoordinateRegionTest { + + @Test + public void testSanity() { + LatLng center = new LatLng(1.2, 3.4, 5.6); + CoordinateSpan span = new CoordinateSpan(9.8, 7.6); + CoordinateRegion coordinateRegion = new CoordinateRegion(center, span); + assertNotNull("coordinateRegion should not be null", coordinateRegion); + } + + @Test + public void testCenterConstructor() { + LatLng center = new LatLng(1.2, 3.4, 5.6); + CoordinateSpan span = new CoordinateSpan(9.8, 7.6); + CoordinateRegion coordinateRegion = new CoordinateRegion(center, span); + assertEquals("center should match", coordinateRegion.getCenter(), center); + } + + @Test + public void testSpanConstructor() { + LatLng center = new LatLng(1.2, 3.4, 5.6); + CoordinateSpan span = new CoordinateSpan(9.8, 7.6); + CoordinateRegion coordinateRegion = new CoordinateRegion(center, span); + assertEquals("span should match", coordinateRegion.getSpan(), span); + } + + @Test + public void testCenterMethod() { + LatLng center = new LatLng(1.2, 3.4, 5.6); + CoordinateSpan span = new CoordinateSpan(9.8, 7.6); + CoordinateRegion coordinateRegion = new CoordinateRegion(null, span); + coordinateRegion.setCenter(center); + assertEquals("center should match", coordinateRegion.getCenter(), center); + } + + @Test + public void testSpanMethod() { + LatLng center = new LatLng(1.2, 3.4, 5.6); + CoordinateSpan span = new CoordinateSpan(9.8, 7.6); + CoordinateRegion coordinateRegion = new CoordinateRegion(center, null); + coordinateRegion.setSpan(span); + assertEquals("span should match", coordinateRegion.getSpan(), span); + } + +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateSpanTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateSpanTest.java new file mode 100644 index 0000000000..ef10c5bed1 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateSpanTest.java @@ -0,0 +1,48 @@ +import com.mapbox.mapboxsdk.geometry.CoordinateSpan; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class CoordinateSpanTest { + + private static final double DELTA = 1e-15; + + @Test + public void testSanity() { + CoordinateSpan coordinateSpan = new CoordinateSpan(0.0, 0.0); + assertNotNull("coordinateSpan should not be null", coordinateSpan); + } + + @Test + public void testLatitudeConstructor() { + double latitude = 1.23; + CoordinateSpan coordinateSpan = new CoordinateSpan(latitude, 0.0); + assertEquals("latitude in constructor", coordinateSpan.getLatitudeSpan(), latitude, DELTA); + } + + @Test + public void testLongitudeConstructor() { + double longitude = 1.23; + CoordinateSpan coordinateSpan = new CoordinateSpan(0.0, longitude); + assertEquals("latitude in constructor", coordinateSpan.getLongitudeSpan(), longitude, DELTA); + } + + @Test + public void testLatitudeMethod() { + double latitude = 1.23; + CoordinateSpan coordinateSpan = new CoordinateSpan(0.0, 0.0); + coordinateSpan.setLatitudeSpan(latitude); + assertEquals("latitude in constructor", coordinateSpan.getLatitudeSpan(), latitude, DELTA); + } + + @Test + public void testLongitudeMethod() { + double longitude = 1.23; + CoordinateSpan coordinateSpan = new CoordinateSpan(0.0, 0.0); + coordinateSpan.setLongitudeSpan(longitude); + assertEquals("latitude in constructor", coordinateSpan.getLongitudeSpan(), longitude, DELTA); + } + +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/LatLngTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/LatLngTest.java new file mode 100644 index 0000000000..dd075f327f --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/LatLngTest.java @@ -0,0 +1,98 @@ +import android.location.Location; + +import com.mapbox.mapboxsdk.geometry.LatLng; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class LatLngTest { + + private static final double DELTA = 1e-15; + + @Test + public void testSanity() { + LatLng latLng = new LatLng(0.0, 0.0); + assertNotNull("latLng should not be null", latLng); + } + + @Test + public void testLatitudeConstructor() { + double latitude = 1.2; + LatLng latLng = new LatLng(latitude, 3.4); + assertEquals("latitude should match", latLng.getLatitude(), latitude, DELTA); + } + + @Test + public void testLongitudeConstructor() { + double longitude = 3.4; + LatLng latLng = new LatLng(1.2, longitude); + assertEquals("longitude should match", latLng.getLongitude(), longitude, DELTA); + } + + @Test + public void testAltitudeConstructor() { + LatLng latLng1 = new LatLng(1.2, 3.4); + assertEquals("altitude default value", latLng1.getAltitude(), 0.0, DELTA); + + double altitude = 5.6; + LatLng latLng2 = new LatLng(1.2, 3.4, altitude); + assertEquals("altitude default value", latLng2.getAltitude(), altitude, DELTA); + } + + /* + * A sample test where Mockito is necessary + */ + + @Test + public void testLocationProvider() { + double latitude = 1.2; + double longitude = 3.4; + double altitude = 5.6; + + // Mock the location class + Location locationMocked = mock(Location.class); + when(locationMocked.getLatitude()).thenReturn(latitude); + when(locationMocked.getLongitude()).thenReturn(longitude); + when(locationMocked.getAltitude()).thenReturn(altitude); + + // Test the constructor + LatLng latLng = new LatLng(locationMocked); + assertEquals("latitude should match", latLng.getLatitude(), latitude, DELTA); + assertEquals("longitude should match", latLng.getLongitude(), longitude, DELTA); + assertEquals("altitude should match", latLng.getAltitude(), altitude, DELTA); + } + + @Test + public void testHashCode() { + double latitude = 1.2; + double longitude = 3.4; + double altitude = 5.6; + LatLng latLng = new LatLng(latitude, longitude, altitude); + assertEquals("hash code should match", latLng.hashCode(), -151519232); + } + + @Test + public void testToString() { + double latitude = 1.2; + double longitude = 3.4; + double altitude = 5.6; + LatLng latLng = new LatLng(latitude, longitude, altitude); + assertEquals("string should match", + latLng.toString(), + "LatLng [longitude=3.4, latitude=1.2, altitude=5.6]"); + } + + @Test + public void testDistanceTo() { + LatLng latLng1 = new LatLng(0.0, 0.0); + LatLng latLng2 = new LatLng(1.0, 1.0); + assertEquals("distances should match", + latLng1.distanceTo(latLng2), + 157425.53710839353, DELTA); + } + +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/LatLngZoomTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/LatLngZoomTest.java new file mode 100644 index 0000000000..5aa42459fb --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/LatLngZoomTest.java @@ -0,0 +1,15 @@ +import com.mapbox.mapboxsdk.geometry.LatLngZoom; + +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; + +public class LatLngZoomTest { + + @Test + public void testSanity() { + LatLngZoom latLngZoom = new LatLngZoom(0.0, 0.0, 0.0); + assertNotNull("latLngZoom should not be null", latLngZoom); + } + +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/MarkerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/MarkerTest.java new file mode 100644 index 0000000000..200c018b86 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/MarkerTest.java @@ -0,0 +1,74 @@ +import com.mapbox.mapboxsdk.annotations.Marker; +import com.mapbox.mapboxsdk.annotations.MarkerOptions; +import com.mapbox.mapboxsdk.geometry.LatLng; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class MarkerTest { + + @Test + public void testSanity() { + 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 + public void testPosition() { + Marker marker = new MarkerOptions().position(new LatLng(10, 12)).getMarker(); + assertEquals(marker.getPosition(), new LatLng(10, 12)); + } + + @Test + public void testTitle() { + Marker marker = new MarkerOptions().title("Mapbox").getMarker(); + assertEquals(marker.getTitle(), "Mapbox"); + } + + @Test + public void testSnippet() { + Marker marker = new MarkerOptions().snippet("Mapbox").getMarker(); + assertEquals(marker.getSnippet(), "Mapbox"); + } + + @Test + public void testBuilder() { + Marker marker = new MarkerOptions().title("title").snippet("snippet").position(new LatLng(10, 12)).getMarker(); + assertEquals(marker.getTitle(), "title"); + assertEquals(marker.getSnippet(), "snippet"); + assertEquals(marker.getPosition(), new LatLng(10, 12)); + } + + @Test + public void testSprite() { + // find a way to test Sprite + } + + @Test + public void testHashCode() { + Marker marker = new MarkerOptions().position(new LatLng(10, 12)).getMarker(); + assertEquals("hash code should match", marker.hashCode(), -1946419200); + } + + @Test + public void testEquality() { + Marker markerOne = new MarkerOptions().position(new LatLng(0, 0)).getMarker(); + Marker markerTwo = new MarkerOptions().position(new LatLng(0, 0)).getMarker(); + assertEquals(markerOne, markerTwo); + } + + @Test + public void testToString() { + Marker marker = new MarkerOptions().position(new LatLng(0, 0)).getMarker(); + assertEquals(marker.toString(), "Marker [position[" + "LatLng [longitude=0.0, latitude=0.0, altitude=0.0]" + "]]"); + } + +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/PolygonTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/PolygonTest.java new file mode 100644 index 0000000000..2053a8c6b1 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/PolygonTest.java @@ -0,0 +1,77 @@ +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/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/PolylineTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/PolylineTest.java new file mode 100644 index 0000000000..1c740a423c --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/PolylineTest.java @@ -0,0 +1,75 @@ +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)); + } + +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/ProjectedMetersTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/ProjectedMetersTest.java new file mode 100644 index 0000000000..c79d2dfe3e --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/ProjectedMetersTest.java @@ -0,0 +1,15 @@ +import com.mapbox.mapboxsdk.geometry.ProjectedMeters; + +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; + +public class ProjectedMetersTest { + + @Test + public void testSanity() { + ProjectedMeters projectedMeters = new ProjectedMeters(0.0, 0.0); + assertNotNull("projectedMeters should not be null", projectedMeters); + } + +} |