diff options
author | Tobrun <tobrun.van.nuland@gmail.com> | 2015-12-07 18:30:49 -0800 |
---|---|---|
committer | Tobrun <tobrun.van.nuland@gmail.com> | 2015-12-07 18:30:49 -0800 |
commit | cfd93a803d955c2af041dcdc6d2e6c5cdfcb87bb (patch) | |
tree | a9bd6d48197483542782399944d7d377dabfba18 /android | |
parent | e04c5f650648d150e78da3602745b6190ec4aee3 (diff) | |
download | qtlocation-mapboxgl-cfd93a803d955c2af041dcdc6d2e6c5cdfcb87bb.tar.gz |
[android] #3215 added unit test for marker, moved tests to their own dedicated packages, added toString method to Marker
Diffstat (limited to 'android')
9 files changed, 89 insertions, 0 deletions
diff --git a/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java b/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java index ed8e0d98e4..6ebc8b2259 100644 --- a/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java +++ b/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java @@ -145,4 +145,9 @@ public final class Marker extends Annotation { result = 31 * result + (getPosition() != null ? getPosition().hashCode() : 0); return result; } + + @Override + public String toString() { + return "Marker [position[" + getPosition() + "]]"; + } } diff --git a/android/MapboxGLAndroidSDKTestApp/src/test/java/annotations/MarkerTest.java b/android/MapboxGLAndroidSDKTestApp/src/test/java/annotations/MarkerTest.java new file mode 100644 index 0000000000..b00322db7b --- /dev/null +++ b/android/MapboxGLAndroidSDKTestApp/src/test/java/annotations/MarkerTest.java @@ -0,0 +1,70 @@ +package annotations; + +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() { + Marker marker = new MarkerOptions().getMarker(); + assertNotNull("marker should not be null", marker); + } + + @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/android/MapboxGLAndroidSDKTestApp/src/test/java/BoundingBoxTest.java b/android/MapboxGLAndroidSDKTestApp/src/test/java/geometry/BoundingBoxTest.java index f03766c9e5..b219a621dd 100644 --- a/android/MapboxGLAndroidSDKTestApp/src/test/java/BoundingBoxTest.java +++ b/android/MapboxGLAndroidSDKTestApp/src/test/java/geometry/BoundingBoxTest.java @@ -1,3 +1,5 @@ +package geometry; + import com.mapbox.mapboxsdk.geometry.BoundingBox; import com.mapbox.mapboxsdk.geometry.CoordinateSpan; import com.mapbox.mapboxsdk.geometry.LatLng; diff --git a/android/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateBoundsTest.java b/android/MapboxGLAndroidSDKTestApp/src/test/java/geometry/CoordinateBoundsTest.java index a5d3891305..05bad0901c 100644 --- a/android/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateBoundsTest.java +++ b/android/MapboxGLAndroidSDKTestApp/src/test/java/geometry/CoordinateBoundsTest.java @@ -1,3 +1,5 @@ +package geometry; + import com.mapbox.mapboxsdk.geometry.CoordinateBounds; import com.mapbox.mapboxsdk.geometry.LatLng; diff --git a/android/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateRegionTest.java b/android/MapboxGLAndroidSDKTestApp/src/test/java/geometry/CoordinateRegionTest.java index 4690bd719b..688a244881 100644 --- a/android/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateRegionTest.java +++ b/android/MapboxGLAndroidSDKTestApp/src/test/java/geometry/CoordinateRegionTest.java @@ -1,3 +1,5 @@ +package geometry; + import com.mapbox.mapboxsdk.geometry.CoordinateRegion; import com.mapbox.mapboxsdk.geometry.CoordinateSpan; import com.mapbox.mapboxsdk.geometry.LatLng; diff --git a/android/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateSpanTest.java b/android/MapboxGLAndroidSDKTestApp/src/test/java/geometry/CoordinateSpanTest.java index ef10c5bed1..bfcd81eaad 100644 --- a/android/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateSpanTest.java +++ b/android/MapboxGLAndroidSDKTestApp/src/test/java/geometry/CoordinateSpanTest.java @@ -1,3 +1,5 @@ +package geometry; + import com.mapbox.mapboxsdk.geometry.CoordinateSpan; import org.junit.Test; diff --git a/android/MapboxGLAndroidSDKTestApp/src/test/java/LatLngTest.java b/android/MapboxGLAndroidSDKTestApp/src/test/java/geometry/LatLngTest.java index dd075f327f..b24271ce9c 100644 --- a/android/MapboxGLAndroidSDKTestApp/src/test/java/LatLngTest.java +++ b/android/MapboxGLAndroidSDKTestApp/src/test/java/geometry/LatLngTest.java @@ -1,3 +1,5 @@ +package geometry; + import android.location.Location; import com.mapbox.mapboxsdk.geometry.LatLng; diff --git a/android/MapboxGLAndroidSDKTestApp/src/test/java/LatLngZoomTest.java b/android/MapboxGLAndroidSDKTestApp/src/test/java/geometry/LatLngZoomTest.java index 5aa42459fb..59d35a9c46 100644 --- a/android/MapboxGLAndroidSDKTestApp/src/test/java/LatLngZoomTest.java +++ b/android/MapboxGLAndroidSDKTestApp/src/test/java/geometry/LatLngZoomTest.java @@ -1,3 +1,5 @@ +package geometry; + import com.mapbox.mapboxsdk.geometry.LatLngZoom; import org.junit.Test; diff --git a/android/MapboxGLAndroidSDKTestApp/src/test/java/ProjectedMetersTest.java b/android/MapboxGLAndroidSDKTestApp/src/test/java/geometry/ProjectedMetersTest.java index c79d2dfe3e..da282eecc1 100644 --- a/android/MapboxGLAndroidSDKTestApp/src/test/java/ProjectedMetersTest.java +++ b/android/MapboxGLAndroidSDKTestApp/src/test/java/geometry/ProjectedMetersTest.java @@ -1,3 +1,5 @@ +package geometry; + import com.mapbox.mapboxsdk.geometry.ProjectedMeters; import org.junit.Test; |