Replace mapboxMap with maplibreMap (#2314)
This commit is contained in:
@@ -28,7 +28,7 @@ import org.maplibre.android.testapp.activity.EspressoTest
|
||||
* This test is responsible for testing the public API.
|
||||
*
|
||||
*
|
||||
* Methods executed on MapboxMap are called from a ViewAction to ensure correct synchronisation
|
||||
* Methods executed on MapLibreMap are called from a ViewAction to ensure correct synchronisation
|
||||
* with the application UI-thread.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -15,7 +15,7 @@ class TransformTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun mapboxMapScrollByWithPadding() {
|
||||
fun maplibreMapScrollByWithPadding() {
|
||||
validateTestSetup()
|
||||
invoke(maplibreMap) { _: UiController, maplibreMap: MapLibreMap ->
|
||||
maplibreMap.moveCamera(initialCameraUpdate)
|
||||
|
||||
@@ -25,22 +25,22 @@ public class MarkerTest extends EspressoTest {
|
||||
@Ignore
|
||||
public void addMarkerTest() {
|
||||
validateTestSetup();
|
||||
MapLibreMapAction.invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size());
|
||||
MapLibreMapAction.invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
assertEquals("Markers should be empty", 0, maplibreMap.getMarkers().size());
|
||||
|
||||
MarkerOptions options = new MarkerOptions();
|
||||
options.setPosition(new LatLng());
|
||||
options.setSnippet(TestConstants.TEXT_MARKER_SNIPPET);
|
||||
options.setTitle(TestConstants.TEXT_MARKER_TITLE);
|
||||
marker = mapboxMap.addMarker(options);
|
||||
marker = maplibreMap.addMarker(options);
|
||||
|
||||
assertEquals("Markers size should be 1, ", 1, mapboxMap.getMarkers().size());
|
||||
assertEquals("Markers size should be 1, ", 1, maplibreMap.getMarkers().size());
|
||||
assertEquals("Marker id should be 0", 0, marker.getId());
|
||||
assertEquals("Marker target should match", new LatLng(), marker.getPosition());
|
||||
assertEquals("Marker snippet should match", TestConstants.TEXT_MARKER_SNIPPET, marker.getSnippet());
|
||||
assertEquals("Marker target should match", TestConstants.TEXT_MARKER_TITLE, marker.getTitle());
|
||||
mapboxMap.clear();
|
||||
assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size());
|
||||
maplibreMap.clear();
|
||||
assertEquals("Markers should be empty", 0, maplibreMap.getMarkers().size());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -48,13 +48,13 @@ public class MarkerTest extends EspressoTest {
|
||||
@Ignore
|
||||
public void showInfoWindowTest() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
final MarkerOptions options = new MarkerOptions();
|
||||
options.setPosition(new LatLng());
|
||||
options.setSnippet(TestConstants.TEXT_MARKER_SNIPPET);
|
||||
options.setTitle(TestConstants.TEXT_MARKER_TITLE);
|
||||
marker = mapboxMap.addMarker(options);
|
||||
mapboxMap.selectMarker(marker);
|
||||
marker = maplibreMap.addMarker(options);
|
||||
maplibreMap.selectMarker(marker);
|
||||
});
|
||||
onView(withText(TestConstants.TEXT_MARKER_TITLE)).check(matches(isDisplayed()));
|
||||
onView(withText(TestConstants.TEXT_MARKER_SNIPPET)).check(matches(isDisplayed()));
|
||||
|
||||
@@ -19,12 +19,12 @@ public class PolygonTest extends EspressoTest {
|
||||
@Ignore
|
||||
public void addPolygonTest() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
LatLng latLngOne = new LatLng();
|
||||
LatLng latLngTwo = new LatLng(1, 0);
|
||||
LatLng latLngThree = new LatLng(1, 1);
|
||||
|
||||
assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size());
|
||||
assertEquals("Polygons should be empty", 0, maplibreMap.getPolygons().size());
|
||||
|
||||
final PolygonOptions options = new PolygonOptions();
|
||||
options.strokeColor(Color.BLUE);
|
||||
@@ -32,15 +32,15 @@ public class PolygonTest extends EspressoTest {
|
||||
options.add(latLngOne);
|
||||
options.add(latLngTwo);
|
||||
options.add(latLngThree);
|
||||
Polygon polygon = mapboxMap.addPolygon(options);
|
||||
Polygon polygon = maplibreMap.addPolygon(options);
|
||||
|
||||
assertEquals("Polygons should be 1", 1, mapboxMap.getPolygons().size());
|
||||
assertEquals("Polygons should be 1", 1, maplibreMap.getPolygons().size());
|
||||
assertEquals("Polygon id should be 0", 0, polygon.getId());
|
||||
assertEquals("Polygon points size should match", 3, polygon.getPoints().size());
|
||||
assertEquals("Polygon stroke color should match", Color.BLUE, polygon.getStrokeColor());
|
||||
assertEquals("Polygon target should match", Color.RED, polygon.getFillColor());
|
||||
mapboxMap.clear();
|
||||
assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size());
|
||||
maplibreMap.clear();
|
||||
assertEquals("Polygons should be empty", 0, maplibreMap.getPolygons().size());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,24 +19,24 @@ public class PolylineTest extends EspressoTest {
|
||||
@Ignore
|
||||
public void addPolylineTest() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
LatLng latLngOne = new LatLng();
|
||||
LatLng latLngTwo = new LatLng(1, 0);
|
||||
|
||||
assertEquals("Polygons should be empty", 0, mapboxMap.getPolygons().size());
|
||||
assertEquals("Polygons should be empty", 0, maplibreMap.getPolygons().size());
|
||||
|
||||
final PolylineOptions options = new PolylineOptions();
|
||||
options.color(Color.BLUE);
|
||||
options.add(latLngOne);
|
||||
options.add(latLngTwo);
|
||||
Polyline polyline = mapboxMap.addPolyline(options);
|
||||
Polyline polyline = maplibreMap.addPolyline(options);
|
||||
|
||||
assertEquals("Polylines should be 1", 1, mapboxMap.getPolylines().size());
|
||||
assertEquals("Polylines should be 1", 1, maplibreMap.getPolylines().size());
|
||||
assertEquals("Polyline id should be 0", 0, polyline.getId());
|
||||
assertEquals("Polyline points size should match", 2, polyline.getPoints().size());
|
||||
assertEquals("Polyline stroke color should match", Color.BLUE, polyline.getColor());
|
||||
mapboxMap.clear();
|
||||
assertEquals("Polyline should be empty", 0, mapboxMap.getPolylines().size());
|
||||
maplibreMap.clear();
|
||||
assertEquals("Polyline should be empty", 0, maplibreMap.getPolylines().size());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,24 +38,24 @@ public abstract class CameraTest extends BaseTest {
|
||||
@Test
|
||||
public void testToCameraPositionTarget() throws InterruptedException {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
float zoom = 1.0f;
|
||||
LatLng moveTarget = new LatLng(1, 1);
|
||||
CameraPosition initialPosition = new CameraPosition.Builder().target(
|
||||
new LatLng()).zoom(zoom).bearing(0).tilt(0).padding(new double[4]).build();
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
CameraPosition cameraPosition = maplibreMap.getCameraPosition();
|
||||
assertEquals("Default camera position should match default", cameraPosition, initialPosition);
|
||||
|
||||
executeCameraMovement(CameraUpdateFactory.newLatLng(moveTarget), new MapLibreMap.CancelableCallback() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
verifyCameraPosition(mapboxMap, moveTarget, zoom, 0, 0, new double[4]);
|
||||
verifyCameraPosition(maplibreMap, moveTarget, zoom, 0, 0, new double[4]);
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
verifyCameraPosition(mapboxMap, moveTarget, zoom, 0, 0, new double[4]);
|
||||
verifyCameraPosition(maplibreMap, moveTarget, zoom, 0, 0, new double[4]);
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
@@ -69,7 +69,7 @@ public abstract class CameraTest extends BaseTest {
|
||||
@Test
|
||||
public void testToCameraPositionTargetZoom() throws InterruptedException {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
final float moveZoom = 15.5f;
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
|
||||
@@ -77,13 +77,13 @@ public abstract class CameraTest extends BaseTest {
|
||||
new MapLibreMap.CancelableCallback() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
verifyCameraPosition(mapboxMap, moveTarget, moveZoom, 0, 0, new double[4]);
|
||||
verifyCameraPosition(maplibreMap, moveTarget, moveZoom, 0, 0, new double[4]);
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
verifyCameraPosition(mapboxMap, moveTarget, moveZoom, 0, 0, new double[4]);
|
||||
verifyCameraPosition(maplibreMap, moveTarget, moveZoom, 0, 0, new double[4]);
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
@@ -97,7 +97,7 @@ public abstract class CameraTest extends BaseTest {
|
||||
@Test
|
||||
public void testToCameraPosition() throws InterruptedException {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
|
||||
final float moveZoom = 15.5f;
|
||||
final float moveTilt = 45.5f;
|
||||
@@ -115,13 +115,13 @@ public abstract class CameraTest extends BaseTest {
|
||||
new MapLibreMap.CancelableCallback() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
verifyCameraPosition(mapboxMap, moveTarget, moveZoom, moveBearing, moveTilt, movePadding);
|
||||
verifyCameraPosition(maplibreMap, moveTarget, moveZoom, moveBearing, moveTilt, movePadding);
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
verifyCameraPosition(mapboxMap, moveTarget, moveZoom, moveBearing, moveTilt, movePadding);
|
||||
verifyCameraPosition(maplibreMap, moveTarget, moveZoom, moveBearing, moveTilt, movePadding);
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
@@ -135,7 +135,7 @@ public abstract class CameraTest extends BaseTest {
|
||||
@Test
|
||||
public void testToBounds() throws InterruptedException {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
final LatLng centerBounds = new LatLng(1, 1);
|
||||
LatLng cornerOne = new LatLng();
|
||||
LatLng cornerTwo = new LatLng(2, 2);
|
||||
@@ -147,13 +147,13 @@ public abstract class CameraTest extends BaseTest {
|
||||
new MapLibreMap.CancelableCallback() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
verifyCameraPosition(mapboxMap, centerBounds, mapboxMap.getCameraPosition().zoom, 0, 0, new double[4]);
|
||||
verifyCameraPosition(maplibreMap, centerBounds, maplibreMap.getCameraPosition().zoom, 0, 0, new double[4]);
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
verifyCameraPosition(mapboxMap, centerBounds, mapboxMap.getCameraPosition().zoom, 0, 0, new double[4]);
|
||||
verifyCameraPosition(maplibreMap, centerBounds, maplibreMap.getCameraPosition().zoom, 0, 0, new double[4]);
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
@@ -167,19 +167,19 @@ public abstract class CameraTest extends BaseTest {
|
||||
@Test
|
||||
public void testToZoomIn() throws InterruptedException {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
float zoom = 1.0f;
|
||||
|
||||
executeCameraMovement(CameraUpdateFactory.zoomIn(), new MapLibreMap.CancelableCallback() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
verifyCameraPosition(mapboxMap, mapboxMap.getCameraPosition().target, zoom + 1, 0, 0, new double[4]);
|
||||
verifyCameraPosition(maplibreMap, maplibreMap.getCameraPosition().target, zoom + 1, 0, 0, new double[4]);
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
verifyCameraPosition(mapboxMap, mapboxMap.getCameraPosition().target, zoom + 1, 0, 0, new double[4]);
|
||||
verifyCameraPosition(maplibreMap, maplibreMap.getCameraPosition().target, zoom + 1, 0, 0, new double[4]);
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
@@ -194,18 +194,18 @@ public abstract class CameraTest extends BaseTest {
|
||||
public void testToZoomOut() throws InterruptedException {
|
||||
float zoom = 10.0f;
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) ->
|
||||
invoke(maplibreMap, (uiController, maplibreMap) ->
|
||||
executeCameraMovement(CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom),
|
||||
new MapLibreMap.CancelableCallback() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
verifyCameraPosition(mapboxMap, mapboxMap.getCameraPosition().target, zoom, 0, 0, new double[4]);
|
||||
verifyCameraPosition(maplibreMap, maplibreMap.getCameraPosition().target, zoom, 0, 0, new double[4]);
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
verifyCameraPosition(mapboxMap, mapboxMap.getCameraPosition().target, zoom, 0, 0, new double[4]);
|
||||
verifyCameraPosition(maplibreMap, maplibreMap.getCameraPosition().target, zoom, 0, 0, new double[4]);
|
||||
latch.countDown();
|
||||
}
|
||||
})
|
||||
@@ -217,17 +217,17 @@ public abstract class CameraTest extends BaseTest {
|
||||
|
||||
latch = new CountDownLatch(1);
|
||||
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
executeCameraMovement(CameraUpdateFactory.zoomOut(), new MapLibreMap.CancelableCallback() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
verifyCameraPosition(mapboxMap, mapboxMap.getCameraPosition().target, zoom - 1, 0, 0, new double[4]);
|
||||
verifyCameraPosition(maplibreMap, maplibreMap.getCameraPosition().target, zoom - 1, 0, 0, new double[4]);
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
verifyCameraPosition(mapboxMap, mapboxMap.getCameraPosition().target, zoom - 1, 0, 0, new double[4]);
|
||||
verifyCameraPosition(maplibreMap, maplibreMap.getCameraPosition().target, zoom - 1, 0, 0, new double[4]);
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
@@ -241,20 +241,20 @@ public abstract class CameraTest extends BaseTest {
|
||||
@Test
|
||||
public void testToZoomBy() throws InterruptedException {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
float zoom = 1.0f;
|
||||
final float zoomBy = 2.45f;
|
||||
|
||||
executeCameraMovement(CameraUpdateFactory.zoomBy(zoomBy), new MapLibreMap.CancelableCallback() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
verifyCameraPosition(mapboxMap, mapboxMap.getCameraPosition().target, zoom + zoomBy, 0, 0, new double[4]);
|
||||
verifyCameraPosition(maplibreMap, maplibreMap.getCameraPosition().target, zoom + zoomBy, 0, 0, new double[4]);
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
verifyCameraPosition(mapboxMap, mapboxMap.getCameraPosition().target, zoom + zoomBy, 0, 0, new double[4]);
|
||||
verifyCameraPosition(maplibreMap, maplibreMap.getCameraPosition().target, zoom + zoomBy, 0, 0, new double[4]);
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
@@ -268,19 +268,19 @@ public abstract class CameraTest extends BaseTest {
|
||||
@Test
|
||||
public void testToZoomTo() throws InterruptedException {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
final float zoomTo = 2.45f;
|
||||
|
||||
executeCameraMovement(CameraUpdateFactory.zoomTo(zoomTo), new MapLibreMap.CancelableCallback() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
verifyCameraPosition(mapboxMap, mapboxMap.getCameraPosition().target, zoomTo, 0, 0, new double[4]);
|
||||
verifyCameraPosition(maplibreMap, maplibreMap.getCameraPosition().target, zoomTo, 0, 0, new double[4]);
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
verifyCameraPosition(mapboxMap, mapboxMap.getCameraPosition().target, zoomTo, 0, 0, new double[4]);
|
||||
verifyCameraPosition(maplibreMap, maplibreMap.getCameraPosition().target, zoomTo, 0, 0, new double[4]);
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -123,7 +123,7 @@ public class GeoJsonConversionTest extends EspressoTest {
|
||||
@Test
|
||||
public void testNegativeNumberPropertyConversion() {
|
||||
validateTestSetup();
|
||||
onView(isRoot()).perform(new MapLibreMapAction((uiController, mapboxMap) -> {
|
||||
onView(isRoot()).perform(new MapLibreMapAction((uiController, maplibreMap) -> {
|
||||
LatLng latLng = new LatLng();
|
||||
Feature feature = Feature.fromGeometry(Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude()));
|
||||
|
||||
@@ -133,18 +133,18 @@ public class GeoJsonConversionTest extends EspressoTest {
|
||||
feature.addProperty("property", foregroundJsonArray);
|
||||
|
||||
GeoJsonSource source = new GeoJsonSource("source", feature);
|
||||
mapboxMap.getStyle().addSource(source);
|
||||
maplibreMap.getStyle().addSource(source);
|
||||
|
||||
SymbolLayer layer = new SymbolLayer("layer", "source")
|
||||
.withProperties(
|
||||
PropertyFactory.iconOffset(Expression.get("property")),
|
||||
PropertyFactory.iconImage("zoo-15")
|
||||
);
|
||||
mapboxMap.getStyle().addLayer(layer);
|
||||
maplibreMap.getStyle().addLayer(layer);
|
||||
|
||||
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
|
||||
|
||||
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng)).isEmpty());
|
||||
assertFalse(maplibreMap.queryRenderedFeatures(maplibreMap.getProjection().toScreenLocation(latLng)).isEmpty());
|
||||
}, maplibreMap));
|
||||
}
|
||||
}
|
||||
@@ -28,12 +28,12 @@ public class LatLngBoundsTest extends BaseTest {
|
||||
public void testLatLngBounds() {
|
||||
// regression test for #9322
|
||||
validateTestSetup();
|
||||
MapLibreMapAction.invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
MapLibreMapAction.invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
LatLngBounds bounds = new LatLngBounds.Builder()
|
||||
.include(new LatLng(48.8589506, 2.2773457))
|
||||
.include(new LatLng(47.2383171, -1.6309316))
|
||||
.build();
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0));
|
||||
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -41,23 +41,23 @@ public class LatLngBoundsTest extends BaseTest {
|
||||
public void testLatLngBoundsBearing() {
|
||||
// regression test for #12549
|
||||
validateTestSetup();
|
||||
MapLibreMapAction.invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
MapLibreMapAction.invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
LatLngBounds bounds = new LatLngBounds.Builder()
|
||||
.include(new LatLng(48.8589506, 2.2773457))
|
||||
.include(new LatLng(47.2383171, -1.6309316))
|
||||
.build();
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0));
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.bearingTo(MAP_BEARING));
|
||||
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0));
|
||||
maplibreMap.moveCamera(CameraUpdateFactory.bearingTo(MAP_BEARING));
|
||||
assertEquals(
|
||||
"Initial bearing should match for latlngbounds",
|
||||
mapboxMap.getCameraPosition().bearing,
|
||||
maplibreMap.getCameraPosition().bearing,
|
||||
MAP_BEARING,
|
||||
TestConstants.BEARING_DELTA
|
||||
);
|
||||
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0));
|
||||
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0));
|
||||
assertEquals("Bearing should match after resetting latlngbounds",
|
||||
mapboxMap.getCameraPosition().bearing,
|
||||
maplibreMap.getCameraPosition().bearing,
|
||||
MAP_BEARING,
|
||||
TestConstants.BEARING_DELTA);
|
||||
});
|
||||
|
||||
@@ -32,8 +32,8 @@ public class CompassViewTest extends EspressoTest {
|
||||
@Ignore("No explanation given")
|
||||
public void testVisible() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
maplibreMap.moveCamera(CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.bearing(45)
|
||||
.zoom(1)
|
||||
@@ -49,7 +49,7 @@ public class CompassViewTest extends EspressoTest {
|
||||
@Ignore("No explanation given")
|
||||
public void testClick() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> maplibreMap.moveCamera(CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.bearing(45)
|
||||
.zoom(1)
|
||||
@@ -59,8 +59,8 @@ public class CompassViewTest extends EspressoTest {
|
||||
onView(withTagValue(is("compassView"))).perform(click());
|
||||
WaitAction.invoke(500);
|
||||
onView(withTagValue(is("compassView"))).check(matches(not(isDisplayed())));
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
CameraPosition cameraPosition = maplibreMap.getCameraPosition();
|
||||
assertEquals("Camera bearing should face north, ", 0, cameraPosition.bearing, TestConstants.BEARING_DELTA);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -40,10 +40,10 @@ class CustomGeometrySourceTest : BaseTest() {
|
||||
@Test
|
||||
fun threadsShutdownWhenSourceRemovedTest() {
|
||||
validateTestSetup()
|
||||
invoke(maplibreMap) { uiController, mapboxMap ->
|
||||
mapboxMap.style!!.removeLayer(ID_GRID_LAYER)
|
||||
invoke(maplibreMap) { uiController, maplibreMap ->
|
||||
maplibreMap.style!!.removeLayer(ID_GRID_LAYER)
|
||||
TestingAsyncUtils.waitForLayer(uiController, mapView)
|
||||
mapboxMap.style!!.removeSource(ID_GRID_SOURCE)
|
||||
maplibreMap.style!!.removeSource(ID_GRID_SOURCE)
|
||||
TestingAsyncUtils.waitForLayer(uiController, mapView)
|
||||
Assert.assertTrue(
|
||||
"There should be no threads running when the source is removed.",
|
||||
@@ -57,13 +57,13 @@ class CustomGeometrySourceTest : BaseTest() {
|
||||
@Test
|
||||
fun threadsRestartedWhenSourceReAddedTest() {
|
||||
validateTestSetup()
|
||||
invoke(maplibreMap) { uiController, mapboxMap ->
|
||||
mapboxMap.style!!.removeLayer((rule.activity as GridSourceActivity).layer!!)
|
||||
invoke(maplibreMap) { uiController, maplibreMap ->
|
||||
maplibreMap.style!!.removeLayer((rule.activity as GridSourceActivity).layer!!)
|
||||
TestingAsyncUtils.waitForLayer(uiController, mapView)
|
||||
mapboxMap.style!!.removeSource(ID_GRID_SOURCE)
|
||||
maplibreMap.style!!.removeSource(ID_GRID_SOURCE)
|
||||
TestingAsyncUtils.waitForLayer(uiController, mapView)
|
||||
mapboxMap.style!!.addSource((rule.activity as GridSourceActivity).source!!)
|
||||
mapboxMap.style!!.addLayer((rule.activity as GridSourceActivity).layer!!)
|
||||
maplibreMap.style!!.addSource((rule.activity as GridSourceActivity).source!!)
|
||||
maplibreMap.style!!.addLayer((rule.activity as GridSourceActivity).layer!!)
|
||||
TestingAsyncUtils.waitForLayer(uiController, mapView)
|
||||
Assert.assertTrue(
|
||||
"Threads should be restarted when the source is re-added to the map.",
|
||||
@@ -77,9 +77,9 @@ class CustomGeometrySourceTest : BaseTest() {
|
||||
@Test
|
||||
fun sourceZoomDeltaTest() {
|
||||
validateTestSetup()
|
||||
invoke(maplibreMap) { uiController, mapboxMap ->
|
||||
mapboxMap.prefetchZoomDelta = 3
|
||||
mapboxMap.style!!.getSource(ID_GRID_SOURCE)!!.let {
|
||||
invoke(maplibreMap) { uiController, maplibreMap ->
|
||||
maplibreMap.prefetchZoomDelta = 3
|
||||
maplibreMap.style!!.getSource(ID_GRID_SOURCE)!!.let {
|
||||
assertNull(it.prefetchZoomDelta)
|
||||
it.prefetchZoomDelta = 5
|
||||
assertNotNull(it.prefetchZoomDelta)
|
||||
@@ -93,8 +93,8 @@ class CustomGeometrySourceTest : BaseTest() {
|
||||
@Test
|
||||
fun isVolatileTest() {
|
||||
validateTestSetup()
|
||||
invoke(maplibreMap) { uiController, mapboxMap ->
|
||||
mapboxMap.style!!.getSource(ID_GRID_SOURCE)!!.let {
|
||||
invoke(maplibreMap) { uiController, maplibreMap ->
|
||||
maplibreMap.style!!.getSource(ID_GRID_SOURCE)!!.let {
|
||||
assertFalse(it.isVolatile)
|
||||
it.isVolatile = true
|
||||
assertTrue(it.isVolatile)
|
||||
@@ -105,8 +105,8 @@ class CustomGeometrySourceTest : BaseTest() {
|
||||
@Test
|
||||
fun minimumTileUpdateIntervalTest() {
|
||||
validateTestSetup()
|
||||
invoke(maplibreMap) { uiController, mapboxMap ->
|
||||
mapboxMap.style!!.getSource(ID_GRID_SOURCE)!!.let {
|
||||
invoke(maplibreMap) { uiController, maplibreMap ->
|
||||
maplibreMap.style!!.getSource(ID_GRID_SOURCE)!!.let {
|
||||
assertEquals(0, it.minimumTileUpdateInterval)
|
||||
it.minimumTileUpdateInterval = 1000
|
||||
assertEquals(1000, it.minimumTileUpdateInterval)
|
||||
|
||||
@@ -78,7 +78,7 @@ public class ExpressionTest extends EspressoTest {
|
||||
setupStyle();
|
||||
Timber.i("camera function");
|
||||
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
// create color expression
|
||||
Expression inputExpression = rgba(255.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
@@ -101,7 +101,7 @@ public class ExpressionTest extends EspressoTest {
|
||||
setupStyle();
|
||||
Timber.i("camera function");
|
||||
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
// create get expression
|
||||
Expression inputExpression = get("fill");
|
||||
|
||||
@@ -127,7 +127,7 @@ public class ExpressionTest extends EspressoTest {
|
||||
setupStyle();
|
||||
Timber.i("camera function");
|
||||
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
// create camera function expression
|
||||
Expression inputExpression = interpolate(
|
||||
exponential(0.5f), zoom(),
|
||||
@@ -155,7 +155,7 @@ public class ExpressionTest extends EspressoTest {
|
||||
setupStyle();
|
||||
Timber.i("camera function");
|
||||
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
// create camera function expression
|
||||
Expression inputExpression = toColor(get("fill"));
|
||||
|
||||
@@ -178,7 +178,7 @@ public class ExpressionTest extends EspressoTest {
|
||||
setupStyle();
|
||||
Timber.i("camera function");
|
||||
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
// create camera function expression
|
||||
Expression inputExpression = step(zoom(),
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f),
|
||||
@@ -211,7 +211,7 @@ public class ExpressionTest extends EspressoTest {
|
||||
public void testLiteralProperty() {
|
||||
validateTestSetup();
|
||||
setupStyle();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
layer.setProperties(
|
||||
fillColor(literal("#4286f4"))
|
||||
);
|
||||
@@ -222,7 +222,7 @@ public class ExpressionTest extends EspressoTest {
|
||||
public void testLiteralMatchExpression() {
|
||||
validateTestSetup();
|
||||
setupStyle();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
Expression expression = match(literal("something"), literal(0f),
|
||||
stop("1", get("1")),
|
||||
stop("2", get("2")),
|
||||
@@ -240,7 +240,7 @@ public class ExpressionTest extends EspressoTest {
|
||||
@Test
|
||||
public void testCollatorExpression() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
LatLng latLng = new LatLng(51, 17);
|
||||
|
||||
Expression expression1 = eq(literal("Łukasz"), literal("lukasz"), collator(true, true));
|
||||
@@ -249,7 +249,7 @@ public class ExpressionTest extends EspressoTest {
|
||||
Expression expression3 = eq(literal("Łukasz"), literal("lukasz"), collator(literal(false), eq(literal(2),
|
||||
literal(1))));
|
||||
|
||||
mapboxMap.getStyle()
|
||||
maplibreMap.getStyle()
|
||||
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
|
||||
Layer layer = new CircleLayer("layer", "source")
|
||||
.withProperties(circleColor(
|
||||
@@ -258,9 +258,9 @@ public class ExpressionTest extends EspressoTest {
|
||||
literal(ColorUtils.colorToRgbaString(Color.RED))
|
||||
)
|
||||
));
|
||||
mapboxMap.getStyle().addLayer(layer);
|
||||
maplibreMap.getStyle().addLayer(layer);
|
||||
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
|
||||
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
|
||||
assertFalse(maplibreMap.queryRenderedFeatures(maplibreMap.getProjection().toScreenLocation(latLng), "layer")
|
||||
.isEmpty());
|
||||
|
||||
layer.setProperties(circleColor(
|
||||
@@ -270,7 +270,7 @@ public class ExpressionTest extends EspressoTest {
|
||||
)
|
||||
));
|
||||
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
|
||||
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
|
||||
assertFalse(maplibreMap.queryRenderedFeatures(maplibreMap.getProjection().toScreenLocation(latLng), "layer")
|
||||
.isEmpty());
|
||||
|
||||
layer.setProperties(circleColor(
|
||||
@@ -280,7 +280,7 @@ public class ExpressionTest extends EspressoTest {
|
||||
)
|
||||
));
|
||||
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
|
||||
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
|
||||
assertFalse(maplibreMap.queryRenderedFeatures(maplibreMap.getProjection().toScreenLocation(latLng), "layer")
|
||||
.isEmpty());
|
||||
});
|
||||
}
|
||||
@@ -288,12 +288,12 @@ public class ExpressionTest extends EspressoTest {
|
||||
@Test
|
||||
public void testConstFormatExpression() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
LatLng latLng = new LatLng(51, 17);
|
||||
mapboxMap.getStyle()
|
||||
maplibreMap.getStyle()
|
||||
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
|
||||
SymbolLayer layer = new SymbolLayer("layer", "source");
|
||||
mapboxMap.getStyle().addLayer(layer);
|
||||
maplibreMap.getStyle().addLayer(layer);
|
||||
|
||||
Expression expression = format(
|
||||
formatEntry("test")
|
||||
@@ -301,7 +301,7 @@ public class ExpressionTest extends EspressoTest {
|
||||
layer.setProperties(textField(expression));
|
||||
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
|
||||
|
||||
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
|
||||
assertFalse(maplibreMap.queryRenderedFeatures(maplibreMap.getProjection().toScreenLocation(latLng), "layer")
|
||||
.isEmpty());
|
||||
assertNull(layer.getTextField().getExpression());
|
||||
assertEquals(new Formatted(new FormattedSection("test")), layer.getTextField().getValue());
|
||||
@@ -311,12 +311,12 @@ public class ExpressionTest extends EspressoTest {
|
||||
@Test
|
||||
public void testConstFormatExpressionFontScaleParam() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
LatLng latLng = new LatLng(51, 17);
|
||||
mapboxMap.getStyle()
|
||||
maplibreMap.getStyle()
|
||||
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
|
||||
SymbolLayer layer = new SymbolLayer("layer", "source");
|
||||
mapboxMap.getStyle().addLayer(layer);
|
||||
maplibreMap.getStyle().addLayer(layer);
|
||||
|
||||
Expression expression = format(
|
||||
formatEntry("test", formatFontScale(1.75))
|
||||
@@ -324,7 +324,7 @@ public class ExpressionTest extends EspressoTest {
|
||||
layer.setProperties(textField(expression));
|
||||
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
|
||||
|
||||
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
|
||||
assertFalse(maplibreMap.queryRenderedFeatures(maplibreMap.getProjection().toScreenLocation(latLng), "layer")
|
||||
.isEmpty());
|
||||
assertNull(layer.getTextField().getExpression());
|
||||
assertEquals(new Formatted(new FormattedSection("test", 1.75)), layer.getTextField().getValue());
|
||||
@@ -334,12 +334,12 @@ public class ExpressionTest extends EspressoTest {
|
||||
@Test
|
||||
public void testConstFormatExpressionTextFontParam() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
LatLng latLng = new LatLng(51, 17);
|
||||
mapboxMap.getStyle()
|
||||
maplibreMap.getStyle()
|
||||
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
|
||||
SymbolLayer layer = new SymbolLayer("layer", "source");
|
||||
mapboxMap.getStyle().addLayer(layer);
|
||||
maplibreMap.getStyle().addLayer(layer);
|
||||
|
||||
Expression expression = format(
|
||||
formatEntry(
|
||||
@@ -351,7 +351,7 @@ public class ExpressionTest extends EspressoTest {
|
||||
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
|
||||
|
||||
assertFalse(
|
||||
mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
|
||||
maplibreMap.queryRenderedFeatures(maplibreMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
|
||||
);
|
||||
assertNull(layer.getTextField().getExpression());
|
||||
assertEquals(new Formatted(
|
||||
@@ -364,12 +364,12 @@ public class ExpressionTest extends EspressoTest {
|
||||
@Test
|
||||
public void testConstFormatExpressionTextColorParam() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
LatLng latLng = new LatLng(51, 17);
|
||||
mapboxMap.getStyle()
|
||||
maplibreMap.getStyle()
|
||||
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
|
||||
SymbolLayer layer = new SymbolLayer("layer", "source");
|
||||
mapboxMap.getStyle().addLayer(layer);
|
||||
maplibreMap.getStyle().addLayer(layer);
|
||||
|
||||
Expression expression = format(
|
||||
formatEntry(
|
||||
@@ -381,7 +381,7 @@ public class ExpressionTest extends EspressoTest {
|
||||
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
|
||||
|
||||
assertFalse(
|
||||
mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
|
||||
maplibreMap.queryRenderedFeatures(maplibreMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
|
||||
);
|
||||
assertNull(layer.getTextField().getExpression());
|
||||
assertEquals(new Formatted(
|
||||
@@ -393,12 +393,12 @@ public class ExpressionTest extends EspressoTest {
|
||||
@Test
|
||||
public void testConstFormatExpressionAllParams() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
LatLng latLng = new LatLng(51, 17);
|
||||
mapboxMap.getStyle()
|
||||
maplibreMap.getStyle()
|
||||
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
|
||||
SymbolLayer layer = new SymbolLayer("layer", "source");
|
||||
mapboxMap.getStyle().addLayer(layer);
|
||||
maplibreMap.getStyle().addLayer(layer);
|
||||
|
||||
Expression expression = format(
|
||||
formatEntry(
|
||||
@@ -412,7 +412,7 @@ public class ExpressionTest extends EspressoTest {
|
||||
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
|
||||
|
||||
assertFalse(
|
||||
mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
|
||||
maplibreMap.queryRenderedFeatures(maplibreMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
|
||||
);
|
||||
assertNull(layer.getTextField().getExpression());
|
||||
assertEquals(new Formatted(
|
||||
@@ -427,12 +427,12 @@ public class ExpressionTest extends EspressoTest {
|
||||
@Test
|
||||
public void testConstFormatExpressionMultipleInputs() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
LatLng latLng = new LatLng(51, 17);
|
||||
mapboxMap.getStyle()
|
||||
maplibreMap.getStyle()
|
||||
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
|
||||
SymbolLayer layer = new SymbolLayer("layer", "source");
|
||||
mapboxMap.getStyle().addLayer(layer);
|
||||
maplibreMap.getStyle().addLayer(layer);
|
||||
|
||||
Expression expression = format(
|
||||
formatEntry(
|
||||
@@ -448,7 +448,7 @@ public class ExpressionTest extends EspressoTest {
|
||||
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
|
||||
|
||||
assertFalse(
|
||||
mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
|
||||
maplibreMap.queryRenderedFeatures(maplibreMap.getProjection().toScreenLocation(latLng), "layer")
|
||||
.isEmpty()
|
||||
);
|
||||
assertNull(layer.getTextField().getExpression());
|
||||
@@ -464,15 +464,15 @@ public class ExpressionTest extends EspressoTest {
|
||||
@Test
|
||||
public void testVariableFormatExpression() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
LatLng latLng = new LatLng(51, 17);
|
||||
Feature feature = Feature.fromGeometry(Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude()));
|
||||
feature.addStringProperty("test_property", "test");
|
||||
feature.addNumberProperty("test_property_number", 1.5);
|
||||
feature.addStringProperty("test_property_color", "green");
|
||||
mapboxMap.getStyle().addSource(new GeoJsonSource("source", feature));
|
||||
maplibreMap.getStyle().addSource(new GeoJsonSource("source", feature));
|
||||
SymbolLayer layer = new SymbolLayer("layer", "source");
|
||||
mapboxMap.getStyle().addLayer(layer);
|
||||
maplibreMap.getStyle().addLayer(layer);
|
||||
|
||||
Expression expression = format(
|
||||
formatEntry(
|
||||
@@ -485,7 +485,7 @@ public class ExpressionTest extends EspressoTest {
|
||||
layer.setProperties(textField(expression));
|
||||
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
|
||||
|
||||
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
|
||||
assertFalse(maplibreMap.queryRenderedFeatures(maplibreMap.getProjection().toScreenLocation(latLng), "layer")
|
||||
.isEmpty());
|
||||
assertEquals(expression, layer.getTextField().getExpression());
|
||||
assertNull(layer.getTextField().getValue());
|
||||
@@ -495,15 +495,15 @@ public class ExpressionTest extends EspressoTest {
|
||||
@Test
|
||||
public void testVariableFormatExpressionMultipleInputs() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
LatLng latLng = new LatLng(51, 17);
|
||||
Feature feature = Feature.fromGeometry(Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude()));
|
||||
feature.addStringProperty("test_property", "test");
|
||||
feature.addNumberProperty("test_property_number", 1.5);
|
||||
feature.addStringProperty("test_property_color", "rgba(0, 255, 0, 1)");
|
||||
mapboxMap.getStyle().addSource(new GeoJsonSource("source", feature));
|
||||
maplibreMap.getStyle().addSource(new GeoJsonSource("source", feature));
|
||||
SymbolLayer layer = new SymbolLayer("layer", "source");
|
||||
mapboxMap.getStyle().addLayer(layer);
|
||||
maplibreMap.getStyle().addLayer(layer);
|
||||
|
||||
Expression expression = format(
|
||||
formatEntry(
|
||||
@@ -517,7 +517,7 @@ public class ExpressionTest extends EspressoTest {
|
||||
layer.setProperties(textField(expression), textColor("rgba(128, 0, 0, 1)"));
|
||||
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
|
||||
|
||||
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
|
||||
assertFalse(maplibreMap.queryRenderedFeatures(maplibreMap.getProjection().toScreenLocation(latLng), "layer")
|
||||
.isEmpty());
|
||||
assertEquals(expression, layer.getTextField().getExpression());
|
||||
assertNull(layer.getTextField().getValue());
|
||||
@@ -527,17 +527,17 @@ public class ExpressionTest extends EspressoTest {
|
||||
@Test
|
||||
public void testFormatExpressionPlainTextCoercion() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
LatLng latLng = new LatLng(51, 17);
|
||||
mapboxMap.getStyle()
|
||||
maplibreMap.getStyle()
|
||||
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
|
||||
SymbolLayer layer = new SymbolLayer("layer", "source");
|
||||
mapboxMap.getStyle().addLayer(layer);
|
||||
maplibreMap.getStyle().addLayer(layer);
|
||||
|
||||
layer.setProperties(textField("test"));
|
||||
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
|
||||
|
||||
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
|
||||
assertFalse(maplibreMap.queryRenderedFeatures(maplibreMap.getProjection().toScreenLocation(latLng), "layer")
|
||||
.isEmpty());
|
||||
assertNull(layer.getTextField().getExpression());
|
||||
assertEquals(new Formatted(
|
||||
@@ -548,12 +548,12 @@ public class ExpressionTest extends EspressoTest {
|
||||
@Test
|
||||
public void testTextFieldFormattedArgument() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
LatLng latLng = new LatLng(51, 17);
|
||||
mapboxMap.getStyle()
|
||||
maplibreMap.getStyle()
|
||||
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
|
||||
SymbolLayer layer = new SymbolLayer("layer", "source");
|
||||
mapboxMap.getStyle().addLayer(layer);
|
||||
maplibreMap.getStyle().addLayer(layer);
|
||||
|
||||
Formatted formatted = new Formatted(
|
||||
new FormattedSection("test", 1.5),
|
||||
@@ -564,7 +564,7 @@ public class ExpressionTest extends EspressoTest {
|
||||
layer.setProperties(textField(formatted), textColor("rgba(128,0,0,1)"));
|
||||
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
|
||||
|
||||
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
|
||||
assertFalse(maplibreMap.queryRenderedFeatures(maplibreMap.getProjection().toScreenLocation(latLng), "layer")
|
||||
.isEmpty());
|
||||
assertNull(layer.getTextField().getExpression());
|
||||
assertEquals(formatted, layer.getTextField().getValue());
|
||||
@@ -574,12 +574,12 @@ public class ExpressionTest extends EspressoTest {
|
||||
@Test
|
||||
public void testNumberFormatCurrencyExpression() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
LatLng latLng = new LatLng(51, 17);
|
||||
mapboxMap.getStyle()
|
||||
maplibreMap.getStyle()
|
||||
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
|
||||
SymbolLayer layer = new SymbolLayer("layer", "source");
|
||||
mapboxMap.getStyle().addLayer(layer);
|
||||
maplibreMap.getStyle().addLayer(layer);
|
||||
|
||||
layer.setProperties(
|
||||
textField(
|
||||
@@ -588,8 +588,8 @@ public class ExpressionTest extends EspressoTest {
|
||||
);
|
||||
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
|
||||
|
||||
assertFalse(mapboxMap.queryRenderedFeatures(
|
||||
mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
|
||||
assertFalse(maplibreMap.queryRenderedFeatures(
|
||||
maplibreMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
|
||||
);
|
||||
assertNull(layer.getTextField().getExpression());
|
||||
assertEquals("$12.35", layer.getTextField().getValue().getFormattedSections()[0].getText());
|
||||
@@ -599,12 +599,12 @@ public class ExpressionTest extends EspressoTest {
|
||||
@Test
|
||||
public void testNumberFormatMaxExpression() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
LatLng latLng = new LatLng(51, 17);
|
||||
mapboxMap.getStyle()
|
||||
maplibreMap.getStyle()
|
||||
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
|
||||
SymbolLayer layer = new SymbolLayer("layer", "source");
|
||||
mapboxMap.getStyle().addLayer(layer);
|
||||
maplibreMap.getStyle().addLayer(layer);
|
||||
|
||||
layer.setProperties(
|
||||
textField(
|
||||
@@ -613,8 +613,8 @@ public class ExpressionTest extends EspressoTest {
|
||||
);
|
||||
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
|
||||
|
||||
assertFalse(mapboxMap.queryRenderedFeatures(
|
||||
mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
|
||||
assertFalse(maplibreMap.queryRenderedFeatures(
|
||||
maplibreMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
|
||||
);
|
||||
assertNull(layer.getTextField().getExpression());
|
||||
assertEquals("12.34568", layer.getTextField().getValue().getFormattedSections()[0].getText());
|
||||
@@ -624,12 +624,12 @@ public class ExpressionTest extends EspressoTest {
|
||||
@Test
|
||||
public void testNumberFormatMinExpression() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
LatLng latLng = new LatLng(51, 17);
|
||||
mapboxMap.getStyle()
|
||||
maplibreMap.getStyle()
|
||||
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
|
||||
SymbolLayer layer = new SymbolLayer("layer", "source");
|
||||
mapboxMap.getStyle().addLayer(layer);
|
||||
maplibreMap.getStyle().addLayer(layer);
|
||||
|
||||
layer.setProperties(
|
||||
textField(
|
||||
@@ -638,8 +638,8 @@ public class ExpressionTest extends EspressoTest {
|
||||
);
|
||||
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
|
||||
|
||||
assertFalse(mapboxMap.queryRenderedFeatures(
|
||||
mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
|
||||
assertFalse(maplibreMap.queryRenderedFeatures(
|
||||
maplibreMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
|
||||
);
|
||||
assertNull(layer.getTextField().getExpression());
|
||||
assertEquals("12", layer.getTextField().getValue().getFormattedSections()[0].getText());
|
||||
@@ -649,12 +649,12 @@ public class ExpressionTest extends EspressoTest {
|
||||
@Test
|
||||
public void testNumberFormatLocaleExpression() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
LatLng latLng = new LatLng(51, 17);
|
||||
mapboxMap.getStyle()
|
||||
maplibreMap.getStyle()
|
||||
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
|
||||
SymbolLayer layer = new SymbolLayer("layer", "source");
|
||||
mapboxMap.getStyle().addLayer(layer);
|
||||
maplibreMap.getStyle().addLayer(layer);
|
||||
|
||||
layer.setProperties(
|
||||
textField(
|
||||
@@ -664,8 +664,8 @@ public class ExpressionTest extends EspressoTest {
|
||||
);
|
||||
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
|
||||
|
||||
assertFalse(mapboxMap.queryRenderedFeatures(
|
||||
mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
|
||||
assertFalse(maplibreMap.queryRenderedFeatures(
|
||||
maplibreMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
|
||||
);
|
||||
assertNull(layer.getTextField().getExpression());
|
||||
assertEquals("12,0", layer.getTextField().getValue().getFormattedSections()[0].getText());
|
||||
@@ -675,7 +675,7 @@ public class ExpressionTest extends EspressoTest {
|
||||
@Test
|
||||
public void testNumberFormatNonConstantExpression() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
LatLng latLng = new LatLng(51, 17);
|
||||
Feature feature = Feature.fromGeometry(Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude()));
|
||||
feature.addNumberProperty("number_value", 12.345678);
|
||||
@@ -684,9 +684,9 @@ public class ExpressionTest extends EspressoTest {
|
||||
feature.addNumberProperty("min_value", 1);
|
||||
|
||||
|
||||
mapboxMap.getStyle().addSource(new GeoJsonSource("source", feature));
|
||||
maplibreMap.getStyle().addSource(new GeoJsonSource("source", feature));
|
||||
SymbolLayer layer = new SymbolLayer("layer", "source");
|
||||
mapboxMap.getStyle().addLayer(layer);
|
||||
maplibreMap.getStyle().addLayer(layer);
|
||||
|
||||
Expression numberFormatExpression = numberFormat(
|
||||
number(number(get("number_value"))),
|
||||
@@ -698,8 +698,8 @@ public class ExpressionTest extends EspressoTest {
|
||||
layer.setProperties(textField(numberFormatExpression));
|
||||
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
|
||||
|
||||
assertFalse(mapboxMap.queryRenderedFeatures(
|
||||
mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
|
||||
assertFalse(maplibreMap.queryRenderedFeatures(
|
||||
maplibreMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
|
||||
);
|
||||
|
||||
assertNotNull(layer.getTextField().getExpression());
|
||||
@@ -741,14 +741,14 @@ public class ExpressionTest extends EspressoTest {
|
||||
@Test
|
||||
public void testDoubleConversion() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
LatLng latLng = new LatLng(51, 17);
|
||||
mapboxMap.getStyle().addSource(
|
||||
maplibreMap.getStyle().addSource(
|
||||
new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude()))
|
||||
);
|
||||
|
||||
CircleLayer layer = new CircleLayer("layer", "source");
|
||||
mapboxMap.getStyle().addLayer(layer);
|
||||
maplibreMap.getStyle().addLayer(layer);
|
||||
|
||||
Expression input = interpolate(
|
||||
exponential(0.5f), zoom(),
|
||||
@@ -764,15 +764,15 @@ public class ExpressionTest extends EspressoTest {
|
||||
}
|
||||
|
||||
private void setupStyle() {
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
// Add a source
|
||||
Source source;
|
||||
source = new GeoJsonSource("amsterdam-parks-source",
|
||||
ResourceUtils.readRawResource(rule.getActivity(), R.raw.amsterdam));
|
||||
mapboxMap.getStyle().addSource(source);
|
||||
maplibreMap.getStyle().addSource(source);
|
||||
|
||||
// Add a fill layer
|
||||
mapboxMap.getStyle().addLayer(layer = new FillLayer("amsterdam-parks-layer", source.getId())
|
||||
maplibreMap.getStyle().addLayer(layer = new FillLayer("amsterdam-parks-layer", source.getId())
|
||||
.withProperties(
|
||||
fillColor(rgba(0.0f, 0.0f, 0.0f, 0.5f)),
|
||||
fillOutlineColor(rgb(0, 0, 255)),
|
||||
|
||||
@@ -38,44 +38,44 @@ public class GeoJsonSourceTests extends EspressoTest {
|
||||
@Test
|
||||
public void testFeatureCollection() {
|
||||
validateTestSetup();
|
||||
MapLibreMapAction.invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
MapLibreMapAction.invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
GeoJsonSource source = null;
|
||||
source = new GeoJsonSource("source", FeatureCollection
|
||||
.fromJson(ResourceUtils.readRawResource(rule.getActivity(), R.raw.test_feature_collection)));
|
||||
mapboxMap.getStyle().addSource(source);
|
||||
mapboxMap.getStyle().addLayer(new CircleLayer("layer", source.getId()));
|
||||
maplibreMap.getStyle().addSource(source);
|
||||
maplibreMap.getStyle().addLayer(new CircleLayer("layer", source.getId()));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPointGeometry() {
|
||||
validateTestSetup();
|
||||
MapLibreMapAction.invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
MapLibreMapAction.invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
GeoJsonSource source = new GeoJsonSource("source", Point.fromLngLat(0d, 0d));
|
||||
mapboxMap.getStyle().addSource(source);
|
||||
mapboxMap.getStyle().addLayer(new CircleLayer("layer", source.getId()));
|
||||
maplibreMap.getStyle().addSource(source);
|
||||
maplibreMap.getStyle().addLayer(new CircleLayer("layer", source.getId()));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFeatureProperties() {
|
||||
validateTestSetup();
|
||||
MapLibreMapAction.invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
MapLibreMapAction.invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
GeoJsonSource source = null;
|
||||
source = new GeoJsonSource("source",
|
||||
ResourceUtils.readRawResource(rule.getActivity(), R.raw.test_feature_properties));
|
||||
mapboxMap.getStyle().addSource(source);
|
||||
mapboxMap.getStyle().addLayer(new CircleLayer("layer", source.getId()));
|
||||
maplibreMap.getStyle().addSource(source);
|
||||
maplibreMap.getStyle().addLayer(new CircleLayer("layer", source.getId()));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateCoalescing() {
|
||||
validateTestSetup();
|
||||
MapLibreMapAction.invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
MapLibreMapAction.invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
GeoJsonSource source = new GeoJsonSource("source");
|
||||
mapboxMap.getStyle().addSource(source);
|
||||
mapboxMap.getStyle().addLayer(new CircleLayer("layer", source.getId()));
|
||||
maplibreMap.getStyle().addSource(source);
|
||||
maplibreMap.getStyle().addLayer(new CircleLayer("layer", source.getId()));
|
||||
|
||||
source.setGeoJson(Point.fromLngLat(0, 0));
|
||||
source.setGeoJson(Point.fromLngLat(-25, -25));
|
||||
@@ -83,8 +83,8 @@ public class GeoJsonSourceTests extends EspressoTest {
|
||||
|
||||
source.setGeoJson(Point.fromLngLat(20, 55));
|
||||
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
|
||||
assertEquals(1, mapboxMap.queryRenderedFeatures(
|
||||
mapboxMap.getProjection().toScreenLocation(
|
||||
assertEquals(1, maplibreMap.queryRenderedFeatures(
|
||||
maplibreMap.getProjection().toScreenLocation(
|
||||
new LatLng(55, 20)), "layer").size());
|
||||
});
|
||||
}
|
||||
@@ -93,13 +93,13 @@ public class GeoJsonSourceTests extends EspressoTest {
|
||||
public void testClearCollectionDuringConversion() {
|
||||
// https://github.com/mapbox/mapbox-gl-native/issues/14565
|
||||
validateTestSetup();
|
||||
MapLibreMapAction.invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
MapLibreMapAction.invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
for (int j = 0; j < 1000; j++) {
|
||||
List<Feature> features = new ArrayList<>();
|
||||
for (int i = 0; i < 100; i++) {
|
||||
features.add(Feature.fromGeometry(Point.fromLngLat(0, 0)));
|
||||
}
|
||||
mapboxMap.getStyle().addSource(new GeoJsonSource("source" + j, FeatureCollection.fromFeatures(features)));
|
||||
maplibreMap.getStyle().addSource(new GeoJsonSource("source" + j, FeatureCollection.fromFeatures(features)));
|
||||
features.clear();
|
||||
}
|
||||
});
|
||||
@@ -142,16 +142,16 @@ public class GeoJsonSourceTests extends EspressoTest {
|
||||
|
||||
protected void testFeatureFromResource(final @RawRes int resource) {
|
||||
validateTestSetup();
|
||||
MapLibreMapAction.invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
MapLibreMapAction.invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
GeoJsonSource source = new GeoJsonSource("source");
|
||||
mapboxMap.getStyle().addSource(source);
|
||||
maplibreMap.getStyle().addSource(source);
|
||||
Layer layer = new CircleLayer("layer", source.getId());
|
||||
mapboxMap.getStyle().addLayer(layer);
|
||||
maplibreMap.getStyle().addLayer(layer);
|
||||
|
||||
source.setGeoJson(Feature.fromJson(ResourceUtils.readRawResource(rule.getActivity(), resource)));
|
||||
|
||||
mapboxMap.getStyle().removeLayer(layer);
|
||||
mapboxMap.getStyle().removeSource(source);
|
||||
maplibreMap.getStyle().removeLayer(layer);
|
||||
maplibreMap.getStyle().removeSource(source);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -25,21 +25,21 @@ class ImageTest : EspressoTest() {
|
||||
@Test
|
||||
fun testAddGetImage() {
|
||||
validateTestSetup()
|
||||
MapLibreMapAction.invoke(maplibreMap) { uiController, mapboxMap ->
|
||||
MapLibreMapAction.invoke(maplibreMap) { uiController, maplibreMap ->
|
||||
val drawable = rule.activity.resources.getDrawable(R.drawable.ic_launcher_round)
|
||||
assertTrue(drawable is BitmapDrawable)
|
||||
|
||||
val bitmapSet = (drawable as BitmapDrawable).bitmap
|
||||
mapboxMap.style!!.addImage(IMAGE_ID, bitmapSet)
|
||||
maplibreMap.style!!.addImage(IMAGE_ID, bitmapSet)
|
||||
|
||||
// adding an image requires converting the image with an asynctask
|
||||
uiController.loopMainThreadForAtLeast(200)
|
||||
|
||||
val bitmapGet = mapboxMap.style!!.getImage(IMAGE_ID)
|
||||
val bitmapGet = maplibreMap.style!!.getImage(IMAGE_ID)
|
||||
assertTrue(bitmapGet!!.similarTo(bitmapSet))
|
||||
|
||||
mapboxMap.style!!.removeImage(IMAGE_ID)
|
||||
assertNull(mapboxMap.style!!.getImage(IMAGE_ID))
|
||||
maplibreMap.style!!.removeImage(IMAGE_ID)
|
||||
assertNull(maplibreMap.style!!.getImage(IMAGE_ID))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,35 +183,35 @@ public class RuntimeStyleTests extends EspressoTest {
|
||||
@Test
|
||||
public void testAddRemoveSource() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
mapboxMap.getStyle().addSource(new VectorSource("my-source", "maptiler://sources/hillshades"));
|
||||
mapboxMap.getStyle().removeSource("my-source");
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
maplibreMap.getStyle().addSource(new VectorSource("my-source", "maptiler://sources/hillshades"));
|
||||
maplibreMap.getStyle().removeSource("my-source");
|
||||
|
||||
// Add initial source
|
||||
mapboxMap.getStyle().addSource(new VectorSource("my-source", "maptiler://sources/hillshades"));
|
||||
maplibreMap.getStyle().addSource(new VectorSource("my-source", "maptiler://sources/hillshades"));
|
||||
|
||||
// Remove
|
||||
boolean removeOk = mapboxMap.getStyle().removeSource("my-source");
|
||||
boolean removeOk = maplibreMap.getStyle().removeSource("my-source");
|
||||
assertTrue(removeOk);
|
||||
assertNull(mapboxMap.getStyle().getLayer("my-source"));
|
||||
assertNull(maplibreMap.getStyle().getLayer("my-source"));
|
||||
|
||||
// Add
|
||||
Source source = new VectorSource("my-source", "maptiler://sources/hillshades");
|
||||
mapboxMap.getStyle().addSource(source);
|
||||
maplibreMap.getStyle().addSource(source);
|
||||
|
||||
// Remove, preserving the reference
|
||||
mapboxMap.getStyle().removeSource(source);
|
||||
maplibreMap.getStyle().removeSource(source);
|
||||
|
||||
// Re-add the reference...
|
||||
mapboxMap.getStyle().addSource(source);
|
||||
maplibreMap.getStyle().addSource(source);
|
||||
|
||||
// Ensure it's there
|
||||
Assert.assertNotNull(mapboxMap.getStyle().getSource(source.getId()));
|
||||
Assert.assertNotNull(maplibreMap.getStyle().getSource(source.getId()));
|
||||
|
||||
// Test adding a duplicate source
|
||||
try {
|
||||
Source source2 = new VectorSource("my-source", "maptiler://sources/hillshades");
|
||||
mapboxMap.getStyle().addSource(source2);
|
||||
maplibreMap.getStyle().addSource(source2);
|
||||
fail("Should not have been allowed to add a source with a duplicate id");
|
||||
} catch (CannotAddSourceException cannotAddSourceException) {
|
||||
// OK
|
||||
@@ -223,9 +223,9 @@ public class RuntimeStyleTests extends EspressoTest {
|
||||
@Test
|
||||
public void testVectorSourceUrlGetter() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
VectorSource source = new VectorSource("my-source", "maptiler://sources/hillshades");
|
||||
mapboxMap.getStyle().addSource(source);
|
||||
maplibreMap.getStyle().addSource(source);
|
||||
assertEquals("maptiler://sources/hillshades", source.getUri());
|
||||
});
|
||||
}
|
||||
@@ -233,9 +233,9 @@ public class RuntimeStyleTests extends EspressoTest {
|
||||
@Test
|
||||
public void testRasterSourceUrlGetter() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
RasterSource source = new RasterSource("my-source", "maptiler://sources/hillshades");
|
||||
mapboxMap.getStyle().addSource(source);
|
||||
maplibreMap.getStyle().addSource(source);
|
||||
assertEquals("maptiler://sources/hillshades", source.getUri());
|
||||
});
|
||||
}
|
||||
@@ -243,9 +243,9 @@ public class RuntimeStyleTests extends EspressoTest {
|
||||
@Test
|
||||
public void testGeoJsonSourceUrlGetter() {
|
||||
validateTestSetup();
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
GeoJsonSource source = new GeoJsonSource("my-source");
|
||||
mapboxMap.getStyle().addSource(source);
|
||||
maplibreMap.getStyle().addSource(source);
|
||||
assertNull(source.getUri());
|
||||
source.setUri("http://mapbox.com/my-file.json");
|
||||
assertEquals("http://mapbox.com/my-file.json", source.getUri());
|
||||
@@ -271,28 +271,28 @@ public class RuntimeStyleTests extends EspressoTest {
|
||||
|
||||
@Test
|
||||
public void testRemoveNonExistingSource() {
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> mapboxMap.getStyle().removeSource("source"));
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> maplibreMap.getStyle().removeSource("source"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveNonExistingLayer() {
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
assertFalse(mapboxMap.getStyle().removeLayer("layer"));
|
||||
assertFalse(mapboxMap.getStyle().removeLayerAt(mapboxMap.getStyle().getLayers().size() + 1));
|
||||
assertFalse(mapboxMap.getStyle().removeLayerAt(-1));
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
assertFalse(maplibreMap.getStyle().removeLayer("layer"));
|
||||
assertFalse(maplibreMap.getStyle().removeLayerAt(maplibreMap.getStyle().getLayers().size() + 1));
|
||||
assertFalse(maplibreMap.getStyle().removeLayerAt(-1));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveExistingLayer() {
|
||||
invoke(maplibreMap, (uiController, mapboxMap) -> {
|
||||
Layer firstLayer = mapboxMap.getStyle().getLayers().get(0);
|
||||
assertTrue(mapboxMap.getStyle().removeLayer(firstLayer));
|
||||
invoke(maplibreMap, (uiController, maplibreMap) -> {
|
||||
Layer firstLayer = maplibreMap.getStyle().getLayers().get(0);
|
||||
assertTrue(maplibreMap.getStyle().removeLayer(firstLayer));
|
||||
|
||||
firstLayer = mapboxMap.getStyle().getLayers().get(0);
|
||||
assertTrue(mapboxMap.getStyle().removeLayer(firstLayer.getId()));
|
||||
firstLayer = maplibreMap.getStyle().getLayers().get(0);
|
||||
assertTrue(maplibreMap.getStyle().removeLayer(firstLayer.getId()));
|
||||
|
||||
assertTrue(mapboxMap.getStyle().removeLayerAt(0));
|
||||
assertTrue(maplibreMap.getStyle().removeLayerAt(0));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user