[android] #3215 added unit test for marker, moved tests to their own dedicated packages, added toString method to Marker

This commit is contained in:
Tobrun
2015-12-07 18:30:49 -08:00
parent e04c5f6506
commit cfd93a803d
9 changed files with 89 additions and 0 deletions

View File

@@ -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() + "]]";
}
}

View File

@@ -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]" + "]]");
}
}

View File

@@ -1,3 +1,5 @@
package geometry;
import com.mapbox.mapboxsdk.geometry.BoundingBox;
import com.mapbox.mapboxsdk.geometry.CoordinateSpan;
import com.mapbox.mapboxsdk.geometry.LatLng;

View File

@@ -1,3 +1,5 @@
package geometry;
import com.mapbox.mapboxsdk.geometry.CoordinateBounds;
import com.mapbox.mapboxsdk.geometry.LatLng;

View File

@@ -1,3 +1,5 @@
package geometry;
import com.mapbox.mapboxsdk.geometry.CoordinateRegion;
import com.mapbox.mapboxsdk.geometry.CoordinateSpan;
import com.mapbox.mapboxsdk.geometry.LatLng;

View File

@@ -1,3 +1,5 @@
package geometry;
import com.mapbox.mapboxsdk.geometry.CoordinateSpan;
import org.junit.Test;

View File

@@ -1,3 +1,5 @@
package geometry;
import android.location.Location;
import com.mapbox.mapboxsdk.geometry.LatLng;

View File

@@ -1,3 +1,5 @@
package geometry;
import com.mapbox.mapboxsdk.geometry.LatLngZoom;
import org.junit.Test;

View File

@@ -1,3 +1,5 @@
package geometry;
import com.mapbox.mapboxsdk.geometry.ProjectedMeters;
import org.junit.Test;