From 5290d7ed4c05d842ff1eda65ed08e11eb94be246 Mon Sep 17 00:00:00 2001 From: Pablo Guardiola Date: Thu, 11 May 2017 12:06:11 +0200 Subject: [android] refactor move unit tests from test app to sdk and add some annotation manager tests (add marker and add markers) (#8261) --- .../mapboxsdk/geometry/LatLngBoundsTest.java | 284 --------------------- 1 file changed, 284 deletions(-) delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java') diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java deleted file mode 100644 index 8d9a360714..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java +++ /dev/null @@ -1,284 +0,0 @@ -package com.mapbox.mapboxsdk.geometry; - -import android.os.Parcelable; - -import com.mapbox.mapboxsdk.exceptions.InvalidLatLngBoundsException; -import com.mapbox.mapboxsdk.utils.MockParcel; - -import org.junit.Before; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -import static junit.framework.Assert.assertNotNull; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -public class LatLngBoundsTest { - - private static final double DELTA = 1e-15; - - private LatLngBounds latLngBounds; - private static final LatLng LAT_LNG_NULL_ISLAND = new LatLng(0, 0); - private static final LatLng LAT_LNG_NOT_NULL_ISLAND = new LatLng(2, 2); - - @Before - public void beforeTest() { - latLngBounds = new LatLngBounds.Builder() - .include(LAT_LNG_NULL_ISLAND) - .include(LAT_LNG_NOT_NULL_ISLAND) - .build(); - } - - @Test - public void testSanity() { - LatLngBounds.Builder latLngBoundsBuilder = new LatLngBounds.Builder(); - latLngBoundsBuilder.include(LAT_LNG_NULL_ISLAND).include(LAT_LNG_NOT_NULL_ISLAND); - assertNotNull("latLng should not be null", latLngBoundsBuilder.build()); - } - - @Test(expected = InvalidLatLngBoundsException.class) - public void noLatLngs() { - new LatLngBounds.Builder().build(); - } - - @Test(expected = InvalidLatLngBoundsException.class) - public void oneLatLngs() { - new LatLngBounds.Builder().include(LAT_LNG_NULL_ISLAND).build(); - } - - @Test - public void latitiudeSpan() { - assertEquals("Span should be the same", 2, latLngBounds.getLatitudeSpan(), DELTA); - } - - @Test - public void longitudeSpan() { - assertEquals("Span should be the same", 2, latLngBounds.getLongitudeSpan(), DELTA); - } - - @Test - public void coordinateSpan() { - LatLngSpan latLngSpan = latLngBounds.getSpan(); - assertEquals("LatLngSpan should be the same", new LatLngSpan(2, 2), latLngSpan); - } - - @Test - public void center() { - LatLng center = latLngBounds.getCenter(); - assertEquals("Center should match", new LatLng(1, 1), center); - } - - @Test - public void emptySpan() { - latLngBounds = new LatLngBounds.Builder() - .include(LAT_LNG_NOT_NULL_ISLAND) - .include(LAT_LNG_NOT_NULL_ISLAND) - .build(); - assertTrue("Should be empty", latLngBounds.isEmptySpan()); - } - - @Test - public void notEmptySpan() { - latLngBounds = new LatLngBounds.Builder() - .include(LAT_LNG_NOT_NULL_ISLAND) - .include(LAT_LNG_NULL_ISLAND) - .build(); - assertFalse("Should not be empty", latLngBounds.isEmptySpan()); - } - - @Test - public void toLatLngs() { - latLngBounds = new LatLngBounds.Builder() - .include(LAT_LNG_NOT_NULL_ISLAND) - .include(LAT_LNG_NULL_ISLAND) - .build(); - - assertArrayEquals("LatLngs should match", - new LatLng[] {LAT_LNG_NOT_NULL_ISLAND, LAT_LNG_NULL_ISLAND}, - latLngBounds.toLatLngs()); - } - - @Test - public void include() { - assertTrue("LatLng should be included", latLngBounds.contains(new LatLng(1, 1))); - } - - @Test - public void includes() { - List points = new ArrayList<>(); - points.add(LAT_LNG_NULL_ISLAND); - points.add(LAT_LNG_NOT_NULL_ISLAND); - - LatLngBounds latLngBounds1 = new LatLngBounds.Builder() - .includes(points) - .build(); - - LatLngBounds latLngBounds2 = new LatLngBounds.Builder() - .include(LAT_LNG_NULL_ISLAND) - .include(LAT_LNG_NOT_NULL_ISLAND) - .build(); - - assertEquals("LatLngBounds should match", latLngBounds1, latLngBounds2); - } - - @Test - public void containsNot() { - assertFalse("LatLng should not be included", latLngBounds.contains(new LatLng(3, 1))); - } - - @Test - public void containsBoundsInWorld() { - assertTrue("LatLngBounds should be contained in the world", LatLngBounds.world().contains(latLngBounds)); - } - - @Test - public void containsBounds() { - LatLngBounds inner = new LatLngBounds.Builder() - .include(new LatLng(-5, -5)) - .include(new LatLng(5, 5)) - .build(); - LatLngBounds outer = new LatLngBounds.Builder() - .include(new LatLng(-10, -10)) - .include(new LatLng(10, 10)) - .build(); - assertTrue(outer.contains(inner)); - assertFalse(inner.contains(outer)); - } - - @Test - public void testHashCode() { - assertEquals(2147483647, latLngBounds.hashCode(), -1946419200); - } - - @Test - public void equality() { - LatLngBounds latLngBounds = new LatLngBounds.Builder() - .include(LAT_LNG_NULL_ISLAND) - .include(LAT_LNG_NOT_NULL_ISLAND) - .build(); - assertEquals("equality should match", this.latLngBounds, latLngBounds); - assertEquals("not equal to a different object type", this.latLngBounds.equals(LAT_LNG_NOT_NULL_ISLAND), false); - } - - @Test - public void testToString() { - assertEquals(latLngBounds.toString(), "N:2.0; E:2.0; S:0.0; W:0.0"); - } - - @Test - public void intersect() { - LatLngBounds latLngBounds = new LatLngBounds.Builder() - .include(new LatLng(1, 1)) - .include(LAT_LNG_NULL_ISLAND) - .build(); - assertEquals("intersect should match", latLngBounds, latLngBounds.intersect(this.latLngBounds.getLatNorth(), - this.latLngBounds.getLonEast(), this.latLngBounds.getLatSouth(), this.latLngBounds.getLonWest())); - } - - @Test - public void intersectNot() { - LatLngBounds latLngBounds = new LatLngBounds.Builder() - .include(new LatLng(10, 10)) - .include(new LatLng(9, 8)) - .build(); - assertNull(latLngBounds.intersect(this.latLngBounds)); - } - - @Test - public void innerUnion() { - LatLngBounds latLngBounds = new LatLngBounds.Builder() - .include(new LatLng(1, 1)) - .include(LAT_LNG_NULL_ISLAND) - .build(); - assertEquals("union should match", latLngBounds, latLngBounds.intersect(this.latLngBounds)); - } - - @Test - public void outerUnion() { - LatLngBounds latLngBounds = new LatLngBounds.Builder() - .include(new LatLng(10, 10)) - .include(new LatLng(9, 8)) - .build(); - assertEquals("outer union should match", - latLngBounds.union(this.latLngBounds), - new LatLngBounds.Builder() - .include(new LatLng(10, 10)) - .include(LAT_LNG_NULL_ISLAND) - .build()); - } - - @Test - public void northWest() { - double minLat = 5; - double minLon = 6; - double maxLat = 20; - double maxLon = 21; - - LatLngBounds latLngBounds = new LatLngBounds.Builder() - .include(new LatLng(minLat, minLon)) - .include(new LatLng(maxLat, maxLon)) - .build(); - - assertEquals("NorthWest should match", latLngBounds.getNorthWest(), new LatLng(maxLat, minLon)); - } - - @Test - public void southWest() { - double minLat = 5; - double minLon = 6; - double maxLat = 20; - double maxLon = 21; - - LatLngBounds latLngBounds = new LatLngBounds.Builder() - .include(new LatLng(minLat, minLon)) - .include(new LatLng(maxLat, maxLon)) - .build(); - - assertEquals("SouthWest should match", latLngBounds.getSouthWest(), new LatLng(minLat, minLon)); - } - - @Test - public void northEast() { - double minLat = 5; - double minLon = 6; - double maxLat = 20; - double maxLon = 21; - - LatLngBounds latLngBounds = new LatLngBounds.Builder() - .include(new LatLng(minLat, minLon)) - .include(new LatLng(maxLat, maxLon)) - .build(); - - assertEquals("NorthEast should match", latLngBounds.getNorthEast(), new LatLng(maxLat, maxLon)); - } - - @Test - public void southEast() { - double minLat = 5; - double minLon = 6; - double maxLat = 20; - double maxLon = 21; - - LatLngBounds latLngBounds = new LatLngBounds.Builder() - .include(new LatLng(minLat, minLon)) - .include(new LatLng(maxLat, maxLon)) - .build(); - - assertEquals("SouthEast should match", latLngBounds.getSouthEast(), new LatLng(minLat, maxLon)); - } - - @Test - public void testParcelable() { - LatLngBounds latLngBounds = new LatLngBounds.Builder() - .include(new LatLng(10, 10)) - .include(new LatLng(9, 8)) - .build(); - Parcelable parcel = MockParcel.obtain(latLngBounds); - assertEquals("Parcel should match original object", parcel, latLngBounds); - } -} -- cgit v1.2.1