[android] #4005 move annotations to correct package
This commit is contained in:
@@ -12,9 +12,9 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
* <p>
|
||||
* Builder for composing {@link com.mapbox.mapboxsdk.annotations.Marker} objects.
|
||||
* </p>
|
||||
*
|
||||
* <p/>
|
||||
* <h3>Example</h3>
|
||||
*
|
||||
* <p/>
|
||||
* <pre>
|
||||
* mMapView.addMarker(new MarkerOptions()
|
||||
* .title("Intersection")
|
||||
@@ -77,43 +77,27 @@ public final class MarkerOptions extends BaseMarkerOptions<Marker, MarkerOptions
|
||||
* @return Marker The build marker
|
||||
*/
|
||||
public Marker getMarker() {
|
||||
marker.setPosition(position);
|
||||
marker.setSnippet(snippet);
|
||||
marker.setTitle(title);
|
||||
marker.setIcon(icon);
|
||||
return marker;
|
||||
}
|
||||
|
||||
public LatLng getPosition() {
|
||||
return marker.getPosition();
|
||||
return position;
|
||||
}
|
||||
|
||||
public String getSnippet() {
|
||||
return marker.getSnippet();
|
||||
return snippet;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return marker.getTitle();
|
||||
return title;
|
||||
}
|
||||
|
||||
public Icon getIcon() {
|
||||
return marker.getIcon();
|
||||
}
|
||||
|
||||
public MarkerOptions position(LatLng position) {
|
||||
marker.setPosition(position);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions snippet(String snippet) {
|
||||
marker.setSnippet(snippet);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions icon(@Nullable Icon icon) {
|
||||
marker.setIcon(icon);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MarkerOptions title(String title) {
|
||||
marker.setTitle(title);
|
||||
return this;
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -130,7 +114,6 @@ public final class MarkerOptions extends BaseMarkerOptions<Marker, MarkerOptions
|
||||
if (getIcon() != null ? !getIcon().equals(marker.getIcon()) : marker.getIcon() != null)
|
||||
return false;
|
||||
return !(getTitle() != null ? !getTitle().equals(marker.getTitle()) : marker.getTitle() != null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.mapbox.mapboxsdk.annotations;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
|
||||
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.assertNotEquals;
|
||||
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() {
|
||||
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng(10, 12));
|
||||
Marker marker = markerOptions.getMarker();
|
||||
assertEquals(marker.getPosition(), new LatLng(10, 12));
|
||||
assertEquals(markerOptions.getPosition(), new LatLng(10, 12));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTitle() {
|
||||
MarkerOptions markerOptions = new MarkerOptions().title("Mapbox");
|
||||
Marker marker = markerOptions.getMarker();
|
||||
assertEquals(marker.getTitle(), "Mapbox");
|
||||
assertEquals(markerOptions.getTitle(), "Mapbox");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSnippet() {
|
||||
MarkerOptions markerOptions = new MarkerOptions().snippet("Mapbox");
|
||||
Marker marker = markerOptions.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.getSnippet(), "snippet");
|
||||
|
||||
assertEquals(marker.getPosition(), new LatLng(10, 12));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIcon() {
|
||||
Bitmap bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_4444);
|
||||
Icon icon = IconFactory.recreate("test", bitmap);
|
||||
MarkerOptions markerOptions = new MarkerOptions().icon(icon);
|
||||
Marker marker = markerOptions.getMarker();
|
||||
assertEquals("Icon should match", icon, marker.getIcon());
|
||||
assertEquals("Icon should match", icon, markerOptions.getIcon());
|
||||
}
|
||||
|
||||
@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 testHashCodeBuilder() {
|
||||
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng(10, 12));
|
||||
assertEquals("hash code should match", markerOptions.hashCode(), 579999617);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals() {
|
||||
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 testEqualsItself() {
|
||||
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng(0, 0));
|
||||
Marker marker = markerOptions.getMarker();
|
||||
assertEquals("Marker should match", marker, marker);
|
||||
assertEquals("MarkerOptions should match", markerOptions, markerOptions);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotEquals() {
|
||||
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng(0, 0));
|
||||
Marker marker = markerOptions.getMarker();
|
||||
assertNotEquals("MarkerOptions should match", markerOptions, new Object());
|
||||
assertNotEquals("Marker should match", marker, new Object());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualityBuilder() {
|
||||
MarkerOptions markerOne = new MarkerOptions().position(new LatLng(0, 0));
|
||||
MarkerOptions markerTwo = new MarkerOptions().position(new LatLng(0, 0));
|
||||
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]" + "]]");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.maps;
|
||||
package com.mapbox.mapboxsdk.annotations;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.Polygon;
|
||||
import com.mapbox.mapboxsdk.annotations.PolygonOptions;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.maps;
|
||||
package com.mapbox.mapboxsdk.annotations;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.Polyline;
|
||||
import com.mapbox.mapboxsdk.annotations.PolylineOptions;
|
||||
@@ -1,76 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.maps;
|
||||
|
||||
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 testIcon() {
|
||||
// find a way to test Icon
|
||||
}
|
||||
|
||||
@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]" + "]]");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user