Change Android package and class names away from mapbox (#1201)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bart Louwers <bart@emeel.net>
This commit is contained in:
fynngodau
2023-06-12 14:04:25 +02:00
committed by GitHub
parent 26094930e9
commit c75e3596da
731 changed files with 9473 additions and 9669 deletions

View File

@@ -1,480 +0,0 @@
package com.mapbox.mapboxsdk.maps;
import android.graphics.Color;
import android.view.View;
import androidx.test.espresso.UiController;
import androidx.test.espresso.ViewAction;
import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions;
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.annotations.Polygon;
import com.mapbox.mapboxsdk.annotations.PolygonOptions;
import com.mapbox.mapboxsdk.annotations.Polyline;
import com.mapbox.mapboxsdk.annotations.PolylineOptions;
import com.mapbox.mapboxsdk.exceptions.InvalidMarkerPositionException;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest;
import org.hamcrest.Matcher;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertNotNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* This test is responsible for testing the public API.
* <p>
* Methods executed on MapboxMap are called from a ViewAction to ensure correct synchronisation
* with the application UI-thread.
* </p>
* @deprecated remove this file when removing deprecated annotations
*/
@Deprecated
public class MapboxMapTest extends EspressoTest {
//
// InfoWindow
//
@Test
public void testConcurrentInfoWindowEnabled() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
mapboxMap.setAllowConcurrentMultipleOpenInfoWindows(true);
assertTrue("ConcurrentWindows should be true", mapboxMap.isAllowConcurrentMultipleOpenInfoWindows());
}));
}
@Test
public void testConcurrentInfoWindowDisabled() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
mapboxMap.setAllowConcurrentMultipleOpenInfoWindows(false);
assertFalse("ConcurrentWindows should be false", mapboxMap.isAllowConcurrentMultipleOpenInfoWindows());
}));
}
@Test
public void testInfoWindowAdapter() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
MapboxMap.InfoWindowAdapter infoWindowAdapter = marker -> null;
mapboxMap.setInfoWindowAdapter(infoWindowAdapter);
assertEquals("InfoWindowAdpter should be the same", infoWindowAdapter, mapboxMap.getInfoWindowAdapter());
}));
}
//
// Annotations
//
@Test
public void testAddMarker() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
Marker marker = mapboxMap.addMarker(markerOptions);
assertTrue("Marker should be contained", mapboxMap.getMarkers().contains(marker));
}));
}
@Test(expected = InvalidMarkerPositionException.class)
public void testAddMarkerInvalidPosition() {
new MarkerOptions().getMarker();
}
@Test
public void testAddMarkers() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
List<BaseMarkerOptions> markerList = new ArrayList<>();
MarkerOptions markerOptions1 = new MarkerOptions().position(new LatLng()).title("a");
MarkerOptions markerOptions2 = new MarkerOptions().position(new LatLng()).title("b");
markerList.add(markerOptions1);
markerList.add(markerOptions2);
List<Marker> markers = mapboxMap.addMarkers(markerList);
assertEquals("Markers size should be 2", 2, mapboxMap.getMarkers().size());
assertTrue(mapboxMap.getMarkers().contains(markers.get(0)));
assertTrue(mapboxMap.getMarkers().contains(markers.get(1)));
}));
}
@Test
public void testAddMarkersEmpty() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
List<BaseMarkerOptions> markerList = new ArrayList<>();
mapboxMap.addMarkers(markerList);
assertEquals("Markers size should be 0", 0, mapboxMap.getMarkers().size());
}));
}
@Test
public void testAddMarkersSingleMarker() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
List<BaseMarkerOptions> markerList = new ArrayList<>();
MarkerOptions markerOptions = new MarkerOptions().title("a").position(new LatLng());
markerList.add(markerOptions);
List<Marker> markers = mapboxMap.addMarkers(markerList);
assertEquals("Markers size should be 1", 1, mapboxMap.getMarkers().size());
assertTrue(mapboxMap.getMarkers().contains(markers.get(0)));
}));
}
@Test
public void testAddPolygon() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
PolygonOptions polygonOptions = new PolygonOptions().add(new LatLng());
Polygon polygon = mapboxMap.addPolygon(polygonOptions);
assertTrue("Polygon should be contained", mapboxMap.getPolygons().contains(polygon));
}));
}
@Test
public void testAddEmptyPolygon() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
PolygonOptions polygonOptions = new PolygonOptions();
Polygon polygon = mapboxMap.addPolygon(polygonOptions);
assertTrue("Polygon should be ignored", !mapboxMap.getPolygons().contains(polygon));
}));
}
@Test
public void testAddPolygons() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
List<PolygonOptions> polygonList = new ArrayList<>();
PolygonOptions polygonOptions1 = new PolygonOptions().fillColor(Color.BLACK).add(new LatLng());
PolygonOptions polygonOptions2 = new PolygonOptions().fillColor(Color.WHITE).add(new LatLng());
PolygonOptions polygonOptions3 = new PolygonOptions();
polygonList.add(polygonOptions1);
polygonList.add(polygonOptions2);
polygonList.add(polygonOptions3);
mapboxMap.addPolygons(polygonList);
assertEquals("Polygons size should be 2", 2, mapboxMap.getPolygons().size());
assertTrue(mapboxMap.getPolygons().contains(polygonOptions1.getPolygon()));
assertTrue(mapboxMap.getPolygons().contains(polygonOptions2.getPolygon()));
assertTrue("Polygon should be ignored", !mapboxMap.getPolygons().contains(polygonOptions3.getPolygon()));
}));
}
@Test
public void addPolygonsEmpty() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
mapboxMap.addPolygons(new ArrayList<PolygonOptions>());
assertEquals("Polygons size should be 0", 0, mapboxMap.getPolygons().size());
}));
}
@Test
public void addPolygonsSingle() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
List<PolygonOptions> polygonList = new ArrayList<>();
PolygonOptions polygonOptions = new PolygonOptions().fillColor(Color.BLACK).add(new LatLng());
polygonList.add(polygonOptions);
mapboxMap.addPolygons(polygonList);
assertEquals("Polygons size should be 1", 1, mapboxMap.getPolygons().size());
assertTrue(mapboxMap.getPolygons().contains(polygonOptions.getPolygon()));
}));
}
@Test
public void testAddPolyline() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
PolylineOptions polylineOptions = new PolylineOptions().add(new LatLng());
Polyline polyline = mapboxMap.addPolyline(polylineOptions);
assertTrue("Polyline should be contained", mapboxMap.getPolylines().contains(polyline));
}));
}
@Test
public void testAddEmptyPolyline() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
PolylineOptions polylineOptions = new PolylineOptions();
Polyline polyline = mapboxMap.addPolyline(polylineOptions);
assertTrue("Polyline should be ignored", !mapboxMap.getPolylines().contains(polyline));
}));
}
@Test
public void testAddPolylines() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
List<PolylineOptions> polylineList = new ArrayList<>();
PolylineOptions polygonOptions1 = new PolylineOptions().color(Color.BLACK).add(new LatLng());
PolylineOptions polygonOptions2 = new PolylineOptions().color(Color.WHITE).add(new LatLng());
PolylineOptions polygonOptions3 = new PolylineOptions();
polylineList.add(polygonOptions1);
polylineList.add(polygonOptions2);
polylineList.add(polygonOptions3);
mapboxMap.addPolylines(polylineList);
assertEquals("Polygons size should be 2", 2, mapboxMap.getPolylines().size());
assertTrue(mapboxMap.getPolylines().contains(polygonOptions1.getPolyline()));
assertTrue(mapboxMap.getPolylines().contains(polygonOptions2.getPolyline()));
assertTrue(
"Polyline should be ignored", !mapboxMap.getPolylines().contains(polygonOptions3.getPolyline())
);
}));
}
@Test
public void testAddPolylinesEmpty() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
mapboxMap.addPolylines(new ArrayList<PolylineOptions>());
assertEquals("Polygons size should be 0", 0, mapboxMap.getPolylines().size());
}));
}
@Test
public void testAddPolylinesSingle() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
List<PolylineOptions> polylineList = new ArrayList<>();
PolylineOptions polygonOptions = new PolylineOptions().color(Color.BLACK).add(new LatLng());
polylineList.add(polygonOptions);
mapboxMap.addPolylines(polylineList);
assertEquals("Polygons size should be 1", 1, mapboxMap.getPolylines().size());
assertTrue(mapboxMap.getPolylines().contains(polygonOptions.getPolyline()));
}));
}
@Test
public void testRemoveMarker() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
Marker marker = mapboxMap.addMarker(markerOptions);
mapboxMap.removeMarker(marker);
assertTrue("Markers should be empty", mapboxMap.getMarkers().isEmpty());
}));
}
@Test
public void testRemovePolygon() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
PolygonOptions polygonOptions = new PolygonOptions();
Polygon polygon = mapboxMap.addPolygon(polygonOptions);
mapboxMap.removePolygon(polygon);
assertTrue("Polygons should be empty", mapboxMap.getPolylines().isEmpty());
}));
}
@Test
public void testRemovePolyline() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
PolylineOptions polylineOptions = new PolylineOptions();
Polyline polyline = mapboxMap.addPolyline(polylineOptions);
mapboxMap.removePolyline(polyline);
assertTrue("Polylines should be empty", mapboxMap.getPolylines().isEmpty());
}));
}
@Test
public void testRemoveAnnotation() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
Marker marker = mapboxMap.addMarker(markerOptions);
mapboxMap.removeAnnotation(marker);
assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty());
}));
}
@Test
public void testRemoveAnnotationById() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
mapboxMap.addMarker(markerOptions);
// id will always be 0 in unit tests
mapboxMap.removeAnnotation(0);
assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty());
}));
}
@Test
public void testRemoveAnnotations() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
List<BaseMarkerOptions> markerList = new ArrayList<>();
MarkerOptions markerOptions1 = new MarkerOptions().title("a").position(new LatLng());
MarkerOptions markerOptions2 = new MarkerOptions().title("b").position(new LatLng());
markerList.add(markerOptions1);
markerList.add(markerOptions2);
mapboxMap.addMarkers(markerList);
mapboxMap.removeAnnotations();
assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty());
}));
}
@Test
public void testClear() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
List<BaseMarkerOptions> markerList = new ArrayList<>();
MarkerOptions markerOptions1 = new MarkerOptions().title("a").position(new LatLng());
MarkerOptions markerOptions2 = new MarkerOptions().title("b").position(new LatLng());
markerList.add(markerOptions1);
markerList.add(markerOptions2);
mapboxMap.addMarkers(markerList);
mapboxMap.clear();
assertTrue("Annotations should be empty", mapboxMap.getAnnotations().isEmpty());
}));
}
@Test
public void testRemoveAnnotationsByList() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
List<BaseMarkerOptions> markerList = new ArrayList<>();
MarkerOptions markerOptions1 = new MarkerOptions().title("a").position(new LatLng());
MarkerOptions markerOptions2 = new MarkerOptions().title("b").position(new LatLng());
markerList.add(markerOptions1);
markerList.add(markerOptions2);
List<Marker> markers = mapboxMap.addMarkers(markerList);
Marker marker = mapboxMap.addMarker(new MarkerOptions().position(new LatLng()).title("c"));
mapboxMap.removeAnnotations(markers);
assertTrue("Annotations should not be empty", mapboxMap.getAnnotations().size() == 1);
assertTrue("Marker should be contained", mapboxMap.getAnnotations().contains(marker));
}));
}
@Test
public void testGetAnnotationById() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
Marker initialMarker = mapboxMap.addMarker(markerOptions);
Marker retrievedMarker = (Marker) mapboxMap.getAnnotation(0);
assertEquals("Markers should match", initialMarker, retrievedMarker);
}));
}
@Test
public void testGetAnnotations() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(
new MapboxMapAction((uiController, view) ->
assertNotNull("Annotations should be non null", mapboxMap.getAnnotations()))
);
}
@Test
public void testGetMarkers() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(
new MapboxMapAction((uiController, view) ->
assertNotNull("Markers should be non null", mapboxMap.getMarkers()))
);
}
@Test
public void testGetPolygons() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) ->
assertNotNull("Polygons should be non null", mapboxMap.getPolygons()))
);
}
@Test
public void testGetPolylines() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) ->
assertNotNull("Polylines should be non null", mapboxMap.getPolylines()))
);
}
@Test
public void testGetSelectedMarkers() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) ->
assertNotNull("Selected markers should be non null", mapboxMap.getSelectedMarkers()))
);
}
@Test
public void testSelectMarker() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
Marker marker = mapboxMap.addMarker(markerOptions);
mapboxMap.selectMarker(marker);
assertTrue("Marker should be contained", mapboxMap.getSelectedMarkers().contains(marker));
}));
}
@Test
public void testDeselectMarker() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
Marker marker = mapboxMap.addMarker(markerOptions);
mapboxMap.selectMarker(marker);
mapboxMap.deselectMarker(marker);
assertTrue("Selected markers should be empty", mapboxMap.getSelectedMarkers().isEmpty());
}));
}
@Test
public void testDeselectMarkers() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
Marker marker1 = mapboxMap.addMarker(markerOptions);
Marker marker2 = mapboxMap.addMarker(markerOptions);
mapboxMap.selectMarker(marker1);
mapboxMap.selectMarker(marker2);
mapboxMap.deselectMarkers();
assertTrue("Selected markers should be empty", mapboxMap.getSelectedMarkers().isEmpty());
}));
}
public class MapboxMapAction implements ViewAction {
private InvokeViewAction invokeViewAction;
MapboxMapAction(InvokeViewAction invokeViewAction) {
this.invokeViewAction = invokeViewAction;
}
@Override
public Matcher<View> getConstraints() {
return isDisplayed();
}
@Override
public String getDescription() {
return getClass().getSimpleName();
}
@Override
public void perform(UiController uiController, View view) {
invokeViewAction.onViewAction(uiController, view);
}
}
interface InvokeViewAction {
void onViewAction(UiController uiController, View view);
}
}

View File

@@ -1,77 +0,0 @@
package com.mapbox.mapboxsdk.maps;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import androidx.test.annotation.UiThreadTest;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.mapboxsdk.AppCenter;
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.exceptions.MapboxConfigurationException;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4ClassRunner.class)
public class MapboxTest extends AppCenter {
private static final String API_KEY = "pk.0000000001";
private static final String API_KEY_2 = "pk.0000000002";
@Rule
public ExpectedException expectedException = ExpectedException.none();
private String realToken;
@Before
public void setup() {
realToken = Mapbox.getApiKey();
}
@Test
@UiThreadTest
public void testConnected() {
assertTrue(Mapbox.isConnected());
// test manual connectivity
Mapbox.setConnected(true);
assertTrue(Mapbox.isConnected());
Mapbox.setConnected(false);
assertFalse(Mapbox.isConnected());
// reset to Android connectivity
Mapbox.setConnected(null);
assertTrue(Mapbox.isConnected());
}
@Test
@UiThreadTest
public void setApiKey() {
Mapbox.setApiKey(API_KEY);
assertSame(API_KEY, Mapbox.getApiKey());
Mapbox.setApiKey(API_KEY_2);
assertSame(API_KEY_2, Mapbox.getApiKey());
}
@Test
@UiThreadTest
public void setNullApiKey() {
expectedException.expect(MapboxConfigurationException.class);
expectedException.expectMessage(
"A valid API key is required, currently provided key is: " + null
);
Mapbox.setApiKey(null);
}
@After
public void tearDown() {
Mapbox.setApiKey(realToken);
}
}

View File

@@ -1,33 +0,0 @@
package com.mapbox.mapboxsdk.maps
import androidx.test.espresso.UiController
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest
import org.junit.Assert.assertEquals
import org.junit.Test
class TransformTest : EspressoTest() {
companion object {
val initialCameraUpdate = CameraUpdateFactory.newLatLngZoom(LatLng(12.0, 12.0), 12.0)!!
}
@Test
fun mapboxMapScrollByWithPadding() {
validateTestSetup()
invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap ->
mapboxMap.moveCamera(initialCameraUpdate)
mapboxMap.scrollBy(400.0f, 0.0f)
val expectedCameraPosition = mapboxMap.cameraPosition
mapboxMap.moveCamera(initialCameraUpdate)
mapboxMap.setPadding(250, 250, 0, 0)
mapboxMap.scrollBy(400.0f, 0.0f)
val actualCameraPosition = mapboxMap.cameraPosition
assertEquals("Camera position should match", expectedCameraPosition, actualCameraPosition)
}
}
}

View File

@@ -1,520 +0,0 @@
package com.mapbox.mapboxsdk.maps
import android.graphics.PointF
import androidx.test.espresso.UiController
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.geometry.LatLngBounds
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke
import com.mapbox.mapboxsdk.testapp.activity.BaseTest
import com.mapbox.mapboxsdk.testapp.activity.espresso.PixelTestActivity
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
class VisibleRegionTest : BaseTest() {
override fun getActivityClass(): Class<*> {
return PixelTestActivity::class.java
}
override
fun beforeTest() {
super.beforeTest()
mapView = (rule.activity as PixelTestActivity).mapView
}
@Test
fun visibleRegionTest() {
validateTestSetup()
invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap ->
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 0.0), 8.0))
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(0f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
val visibleRegion = mapboxMap.projection.visibleRegion
assertTrue(latLngs.all { visibleRegion.latLngBounds.contains(it) })
}
}
@Test
fun paddedVisibleRegionTest() {
validateTestSetup()
invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap ->
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 0.0), 8.0))
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(0f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
mapboxMap.setPadding(
mapView.width / 4,
mapView.height / 4,
mapView.width / 4,
mapView.height / 4
)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
assertTrue(filtered.size == 1)
assertTrue(filtered.contains(mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)))
}
}
@Test
fun paddedLeftVisibleRegionTest() {
validateTestSetup()
invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap ->
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 0.0), 8.0))
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(0f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
mapboxMap.setPadding(mapView.width / 4, 0, 0, 0)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
assertTrue(filtered.size == 6)
assertFalse(filtered.contains(mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f)))
}
}
@Test
fun paddedTopVisibleRegionTest() {
validateTestSetup()
invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap ->
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 0.0), 8.0))
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(0f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
mapboxMap.setPadding(0, mapView.height / 4, 0, 0)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
assertTrue(filtered.size == 6)
assertFalse(filtered.contains(mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f)))
}
}
@Test
fun paddedRightVisibleRegionTest() {
validateTestSetup()
invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap ->
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 0.0), 8.0))
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(0f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
mapboxMap.setPadding(0, 0, mapView.width / 4, 0)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
assertTrue(filtered.size == 6)
assertFalse(filtered.contains(mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f)))
}
}
@Test
fun paddedBottomVisibleRegionTest() {
validateTestSetup()
invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap ->
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 0.0), 8.0))
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(0f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
mapboxMap.setPadding(0, 0, 0, mapView.height / 4)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
assertTrue(filtered.size == 6)
assertFalse(filtered.contains(mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat())))
}
}
@Test
fun visibleRegionOverDatelineTest() {
validateTestSetup()
invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap ->
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 180.0), 8.0))
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(0f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f)
.also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f)
.also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat())
.also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
val visibleRegion = mapboxMap.projection.visibleRegion
assertTrue(latLngs.all { visibleRegion.latLngBounds.contains(it) })
}
}
@Test
fun paddedVisibleRegionOverDatelineTest() {
validateTestSetup()
invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap ->
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 180.0), 8.0))
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(0f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
mapboxMap.setPadding(
mapView.width / 4,
mapView.height / 4,
mapView.width / 4,
mapView.height / 4
)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
assertTrue(filtered.size == 1)
assertTrue(filtered.contains(mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)))
}
}
@Test
fun paddedLeftVisibleRegionOverDatelineTest() {
validateTestSetup()
invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap ->
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 180.0), 8.0))
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(0f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f)
.also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f)
.also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat())
.also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
mapboxMap.setPadding(mapView.width / 4, 0, 0, 0)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
assertTrue(filtered.size == 6)
assertFalse(filtered.contains(mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f)))
}
}
@Test
fun paddedTopVisibleRegionOverDatelineTest() {
validateTestSetup()
invoke(mapboxMap) { ui: UiController, mapboxMap: MapboxMap ->
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 180.0), 8.0))
ui.loopMainThreadForAtLeast(5000)
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(0f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f)
.also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f)
.also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat())
.also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
mapboxMap.setPadding(0, mapView.height / 4, 0, 0)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
assertTrue(filtered.size == 6)
assertFalse(filtered.contains(mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f)))
}
}
@Test
fun paddedRightVisibleRegionOverDatelineTest() {
validateTestSetup()
invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap ->
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 180.0), 8.0))
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(0f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f)
.also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f)
.also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat())
.also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
mapboxMap.setPadding(0, 0, mapView.width / 4, 0)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
assertTrue(filtered.size == 6)
assertFalse(filtered.contains(mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f)))
}
}
@Test
fun paddedBottomVisibleRegionOverDatelineTest() {
validateTestSetup()
invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap ->
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 180.0), 8.0))
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(0f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f)
.also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f)
.also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat())
.also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
mapboxMap.setPadding(0, 0, 0, mapView.height / 4)
val visibleRegion = mapboxMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
assertTrue(filtered.size == 6)
assertFalse(filtered.contains(mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat())))
}
}
@Test
fun visibleRotatedRegionTest() {
validateTestSetup()
invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap ->
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 0.0), 8.0))
val d = Math.min(mapboxMap.width, mapboxMap.height) / 4
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f - d / 2f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f + d / 2f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f - d / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f + d / 2f)
)
for (bearing in 45 until 360 step 45) {
mapboxMap.moveCamera(CameraUpdateFactory.bearingTo(bearing.toDouble()))
val visibleRegion = mapboxMap.projection.visibleRegion
assertTrue(latLngs.all { visibleRegion.latLngBounds.contains(it) })
}
}
}
@Test
fun visibleRotatedRegionOverDatelineTest() {
validateTestSetup()
invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap ->
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 180.0), 8.0))
val d = Math.min(mapboxMap.width, mapboxMap.height) / 4
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f - d / 2f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f + d / 2f, mapView.height / 2f)
.also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f - d / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f + d / 2f)
)
for (bearing in 45 until 360 step 45) {
mapboxMap.moveCamera(CameraUpdateFactory.bearingTo(bearing.toDouble()))
val visibleRegion = mapboxMap.projection.visibleRegion
assertTrue(latLngs.all { visibleRegion.latLngBounds.contains(it) })
}
}
}
@Test
fun visibleRegionWithBoundsEqualTest() {
validateTestSetup()
invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap ->
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 0.0), 8.0))
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(0f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
val bounds = doubleArrayOf(0.0, 0.0, 0.0, 0.0)
mapboxMap.projection.getVisibleCoordinateBounds(bounds)
val latLngBounds = LatLngBounds.from(bounds[0], bounds[1], bounds[2], bounds[3])
val visibleRegion = mapboxMap.projection.visibleRegion
assertTrue(latLngBounds == visibleRegion.latLngBounds)
assertTrue(latLngs.all { latLngBounds.contains(it) })
}
}
@Test
fun visibleRegionBoundsOverDatelineTest() {
validateTestSetup()
invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap ->
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 180.0), 8.0))
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(0f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f)
.also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f)
.also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat())
.also { it.longitude += 360 },
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
mapboxMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
val bounds = doubleArrayOf(0.0, 0.0, 0.0, 0.0)
mapboxMap.projection.getVisibleCoordinateBounds(bounds)
val latLngBounds = LatLngBounds.from(bounds[0], bounds[1], bounds[2], bounds[3])
assertTrue(latLngs.all { latLngBounds.contains(it) })
}
}
@Test
fun visibleRegionBoundsOverDatelineLatitudeZeroTest() {
validateTestSetup()
invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap ->
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 180.0), 8.0))
val shift = mapboxMap.getLatLngFromScreenCoords(0f, 0f)
mapboxMap.moveCamera(CameraUpdateFactory.newLatLng(LatLng(0.0, 180.0 - shift.longitude)))
val bounds = doubleArrayOf(0.0, 0.0, 0.0, 0.0)
mapboxMap.projection.getVisibleCoordinateBounds(bounds)
val latLngBounds = LatLngBounds.from(bounds[0], bounds[1], bounds[2], bounds[3])
val visibleRegion = mapboxMap.projection.visibleRegion
assertTrue(latLngBounds == visibleRegion.latLngBounds)
}
}
@Test
fun visibleRotatedRegionBoundEqualTest() {
validateTestSetup()
invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap ->
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 0.0), 8.0))
val d = Math.min(mapboxMap.width, mapboxMap.height) / 4
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f - d / 2f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f + d / 2f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f - d / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f + d / 2f)
)
for (bearing in 45 until 360 step 45) {
mapboxMap.moveCamera(CameraUpdateFactory.bearingTo(bearing.toDouble()))
val bounds = doubleArrayOf(0.0, 0.0, 0.0, 0.0)
mapboxMap.projection.getVisibleCoordinateBounds(bounds)
val latLngBounds = LatLngBounds.from(bounds[0], bounds[1], bounds[2], bounds[3])
val visibleRegion = mapboxMap.projection.visibleRegion
assertTrue(latLngBounds == visibleRegion.latLngBounds)
assertTrue(latLngs.all { latLngBounds.contains(it) })
}
}
}
@Test
fun visibleRotatedRegionBoundsOverDatelineTest() {
validateTestSetup()
invoke(mapboxMap) { _: UiController, mapboxMap: MapboxMap ->
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 179.0), 8.0))
val d = Math.min(mapboxMap.width, mapboxMap.height) / 4
val latLngs = listOf(
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f - d / 2f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f + d / 2f, mapView.height / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f - d / 2f),
mapboxMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f + d / 2f)
)
for (bearing in 45 until 360 step 45) {
mapboxMap.moveCamera(CameraUpdateFactory.bearingTo(bearing.toDouble()))
val bounds = doubleArrayOf(0.0, 0.0, 0.0, 0.0)
mapboxMap.projection.getVisibleCoordinateBounds(bounds)
val latLngBounds = LatLngBounds.from(bounds[0], bounds[1], bounds[2], bounds[3])
assertTrue(latLngs.all { latLngBounds.contains(it) })
}
}
}
private fun MapboxMap.getLatLngFromScreenCoords(x: Float, y: Float): LatLng {
return this.projection.fromScreenLocation(PointF(x, y))
}
}

View File

@@ -1,25 +0,0 @@
package com.mapbox.mapboxsdk.testapp.activity
import androidx.annotation.UiThread
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.maps.Style
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity
/**
* Base class for all tests using EspressoTestActivity as wrapper.
*
*
* Loads "assets/streets.json" as style.
*
*/
open class EspressoTest : BaseTest() {
override fun getActivityClass(): Class<*> {
return EspressoTestActivity::class.java
}
@UiThread
override fun initMap(mapboxMap: MapboxMap) {
mapboxMap.setStyle(Style.Builder().fromUri("asset://streets.json"))
super.initMap(mapboxMap)
}
}

View File

@@ -1,11 +0,0 @@
package com.mapbox.mapboxsdk.testapp.camera;
import com.mapbox.mapboxsdk.camera.CameraUpdate;
import com.mapbox.mapboxsdk.maps.MapboxMap;
public class CameraAnimateTest extends CameraTest {
@Override
void executeCameraMovement(CameraUpdate cameraUpdate, MapboxMap.CancelableCallback callback) {
mapboxMap.animateCamera(cameraUpdate, callback);
}
}

View File

@@ -1,12 +0,0 @@
package com.mapbox.mapboxsdk.testapp.camera;
import com.mapbox.mapboxsdk.camera.CameraUpdate;
import com.mapbox.mapboxsdk.maps.MapboxMap;
public class CameraEaseTest extends CameraTest {
@Override
void executeCameraMovement(CameraUpdate cameraUpdate, MapboxMap.CancelableCallback callback) {
mapboxMap.easeCamera(cameraUpdate, callback);
}
}

View File

@@ -1,12 +0,0 @@
package com.mapbox.mapboxsdk.testapp.camera;
import com.mapbox.mapboxsdk.camera.CameraUpdate;
import com.mapbox.mapboxsdk.maps.MapboxMap;
public class CameraMoveTest extends CameraTest {
@Override
void executeCameraMovement(CameraUpdate cameraUpdate, MapboxMap.CancelableCallback callback) {
mapboxMap.moveCamera(cameraUpdate, callback);
}
}

View File

@@ -1,31 +0,0 @@
package com.mapbox.mapboxsdk.testapp.maps
import androidx.test.espresso.UiController
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.maps.Style
import com.mapbox.mapboxsdk.style.layers.SymbolLayer
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest
import com.mapbox.mapboxsdk.testapp.utils.TestingAsyncUtils
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4ClassRunner::class)
class StyleLoadTest : EspressoTest() {
@Test
fun updateSourceAfterStyleLoad() {
validateTestSetup()
MapboxMapAction.invoke(mapboxMap) { uiController: UiController, mapboxMap: MapboxMap ->
val source = GeoJsonSource("id")
val layer = SymbolLayer("id", "id")
mapboxMap.setStyle(Style.Builder().withSource(source).withLayer(layer))
TestingAsyncUtils.waitForLayer(uiController, mapView)
mapboxMap.setStyle(Style.Builder().fromUrl(Style.getPredefinedStyle("Streets")))
TestingAsyncUtils.waitForLayer(uiController, mapView)
source.setGeoJson("{}")
}
}
}

View File

@@ -1,132 +0,0 @@
<%
const properties = locals.properties;
-%>
package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
import androidx.test.espresso.UiController;
import androidx.test.espresso.ViewAction;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import android.view.View;
import com.mapbox.mapboxsdk.style.light.Light;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import com.mapbox.mapboxsdk.style.light.Position;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.BaseTest;
import com.mapbox.mapboxsdk.testapp.activity.style.FillExtrusionStyleTestActivity;
import timber.log.Timber;
import org.hamcrest.Matcher;
import org.junit.Test;
import org.junit.runner.RunWith;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.mapbox.mapboxsdk.style.expressions.Expression.eq;
import static com.mapbox.mapboxsdk.style.layers.Property.ANCHOR_MAP;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionBase;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionHeight;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionOpacity;
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@RunWith(AndroidJUnit4ClassRunner.class)
public class LightTest extends BaseTest {
private Light light;
<% for (const property of properties) { -%>
<% if (property.transition) { -%>
@Test
public void test<%- camelize(property.name) %>Transition() {
validateTestSetup();
setupLight();
Timber.i("<%- property.name %>TransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(light);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
light.set<%- camelize(property.name) %>Transition(options);
assertEquals("Transition options should match", options, light.get<%- camelize(property.name) %>Transition());
});
}
<% } -%>
<% if (property.name == "position") { -%>
@Test
public void test<%- camelize(property.name) %>() {
validateTestSetup();
setupLight();
Timber.i("<%- property.name %>");
invoke(mapboxMap,(uiController, mapboxMap) -> {
assertNotNull(light);
// Set and Get
Position position = new Position(1, 2, 3);
light.set<%- camelize(property.name) %>(position);
assertEquals("Position should match", position, light.get<%- camelize(property.name) %>());
});
}
<% } else { -%>
@Test
public void test<%- camelize(property.name) %>() {
validateTestSetup();
setupLight();
Timber.i("<%- property.name %>");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(light);
// Set and Get
light.set<%- camelize(property.name) %>(<%- defaultValueJava(property) %>);
<% if (property.name == 'color') { -%>
assertEquals("<%- camelize(property.name) %> should match", <%- defaultValueJava(property) %>, light.get<%- camelize(property.name) %>());
<% } else { -%>
assertEquals("<%- camelize(property.name) %> should match", <%- defaultValueJava(property) %>, light.get<%- camelize(property.name) %>());
<% } -%>
});
}
<% } -%>
<% } -%>
private void setupLight() {
onView(withId(R.id.mapView)).perform(new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isDisplayed();
}
@Override
public String getDescription() {
return getClass().getSimpleName();
}
@Override
public void perform(UiController uiController, View view) {
light = mapboxMap.getStyle().getLight();
FillExtrusionLayer fillExtrusionLayer = new FillExtrusionLayer("3d-buildings", "composite");
fillExtrusionLayer.setSourceLayer("building");
fillExtrusionLayer.setFilter(eq(Expression.get("extrude"), "true"));
fillExtrusionLayer.setMinZoom(15);
fillExtrusionLayer.setProperties(
fillExtrusionColor(Color.LTGRAY),
fillExtrusionHeight(Expression.get("height")),
fillExtrusionBase(Expression.get("min_height")),
fillExtrusionOpacity(0.6f)
);
mapboxMap.getStyle().addLayer(fillExtrusionLayer);
}
});
}
@Override
protected Class getActivityClass() {
return FillExtrusionStyleTestActivity.class;
}
}

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk
package org.maplibre.android
import com.microsoft.appcenter.espresso.Factory
import org.junit.After

View File

@@ -1,6 +1,6 @@
package com.mapbox.mapboxsdk
package org.maplibre.android
import com.mapbox.mapboxsdk.testapp.MapLibreApplication
import org.maplibre.android.testapp.MapLibreApplication
class InstrumentationApplication : MapLibreApplication() {
fun initializeLeakCanary(): Boolean {

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk
package org.maplibre.android
import android.app.Application
import android.content.Context

View File

@@ -1,12 +1,12 @@
package com.mapbox.mapboxsdk.camera
package org.maplibre.android.camera
import android.graphics.PointF
import androidx.test.annotation.UiThreadTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.geometry.LatLngBounds
import com.mapbox.mapboxsdk.testapp.activity.BaseTest
import com.mapbox.mapboxsdk.testapp.activity.espresso.DeviceIndependentTestActivity
import org.maplibre.android.geometry.LatLng
import org.maplibre.android.geometry.LatLngBounds
import org.maplibre.android.testapp.activity.BaseTest
import org.maplibre.android.testapp.activity.espresso.DeviceIndependentTestActivity
import org.junit.Assert
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
@@ -23,7 +23,7 @@ class CameraUpdateFactoryTest : BaseTest() {
@Test
@UiThreadTest
fun testLatLngBoundsUntiltedUnrotated() {
mapboxMap.cameraPosition = CameraPosition.Builder()
maplibreMap.cameraPosition = CameraPosition.Builder()
.target(LatLng(60.0, 24.0))
.bearing(0.0)
.tilt(0.0)
@@ -34,9 +34,9 @@ class CameraUpdateFactoryTest : BaseTest() {
.include(LatLng(58.0, 22.0))
.build()
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0))
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0))
val cameraPosition = mapboxMap.cameraPosition
val cameraPosition = maplibreMap.cameraPosition
assertEquals("latitude should match:", 60.0, cameraPosition.target!!.latitude, 0.1)
assertEquals("longitude should match:", 24.0, cameraPosition.target!!.longitude, 0.1)
assertEquals("bearing should match:", 0.0, cameraPosition.bearing, 0.1)
@@ -47,7 +47,7 @@ class CameraUpdateFactoryTest : BaseTest() {
@Test
@UiThreadTest
fun testLatLngBoundsTilted() {
mapboxMap.cameraPosition = CameraPosition.Builder()
maplibreMap.cameraPosition = CameraPosition.Builder()
.target(LatLng(60.0, 24.0))
.bearing(0.0)
.tilt(45.0)
@@ -58,9 +58,9 @@ class CameraUpdateFactoryTest : BaseTest() {
.include(LatLng(58.0, 22.0))
.build()
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0))
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0))
val cameraPosition = mapboxMap.cameraPosition
val cameraPosition = maplibreMap.cameraPosition
assertEquals("latitude should match:", 60.0, cameraPosition.target!!.latitude, 0.1)
assertEquals("longitude should match:", 24.0, cameraPosition.target!!.longitude, 0.1)
assertEquals("bearing should match:", 0.0, cameraPosition.bearing, 0.1)
@@ -71,7 +71,7 @@ class CameraUpdateFactoryTest : BaseTest() {
@Test
@UiThreadTest
fun testLatLngBoundsRotated() {
mapboxMap.cameraPosition = CameraPosition.Builder()
maplibreMap.cameraPosition = CameraPosition.Builder()
.target(LatLng(60.0, 24.0))
.bearing(30.0)
.tilt(0.0)
@@ -82,9 +82,9 @@ class CameraUpdateFactoryTest : BaseTest() {
.include(LatLng(58.0, 22.0))
.build()
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0))
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0))
val cameraPosition = mapboxMap.cameraPosition
val cameraPosition = maplibreMap.cameraPosition
assertEquals("latitude should match:", 60.0, cameraPosition.target!!.latitude, 0.1)
assertEquals("longitude should match:", 24.0, cameraPosition.target!!.longitude, 0.1)
assertEquals("bearing should match:", 30.0, cameraPosition.bearing, 0.1)
@@ -95,7 +95,7 @@ class CameraUpdateFactoryTest : BaseTest() {
@Test
@UiThreadTest
fun testLatLngBoundsTiltedRotated() {
mapboxMap.cameraPosition = CameraPosition.Builder()
maplibreMap.cameraPosition = CameraPosition.Builder()
.target(LatLng(60.0, 24.0))
.bearing(30.0)
.tilt(45.0)
@@ -106,9 +106,9 @@ class CameraUpdateFactoryTest : BaseTest() {
.include(LatLng(58.0, 22.0))
.build()
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0))
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0))
val cameraPosition = mapboxMap.cameraPosition
val cameraPosition = maplibreMap.cameraPosition
assertEquals("latitude should match:", 60.0, cameraPosition.target!!.latitude, 0.1)
assertEquals("longitude should match:", 24.0, cameraPosition.target!!.longitude, 0.1)
assertEquals("bearing should match:", 30.0, cameraPosition.bearing, 0.1)
@@ -119,7 +119,7 @@ class CameraUpdateFactoryTest : BaseTest() {
@Test
@UiThreadTest
fun testLatLngBoundsWithProvidedTiltAndRotation() {
mapboxMap.cameraPosition = CameraPosition.Builder()
maplibreMap.cameraPosition = CameraPosition.Builder()
.target(LatLng(60.0, 24.0))
.bearing(0.0)
.tilt(0.0)
@@ -130,9 +130,9 @@ class CameraUpdateFactoryTest : BaseTest() {
.include(LatLng(58.0, 22.0))
.build()
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 30.0, 40.0, 0))
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 30.0, 40.0, 0))
val cameraPosition = mapboxMap.cameraPosition
val cameraPosition = maplibreMap.cameraPosition
assertEquals("latitude should match:", 60.0, cameraPosition.target!!.latitude, 0.1)
assertEquals("longitude should match:", 24.0, cameraPosition.target!!.longitude, 0.1)
assertEquals("bearing should match:", 30.0, cameraPosition.bearing, 0.1)
@@ -143,21 +143,21 @@ class CameraUpdateFactoryTest : BaseTest() {
@Test
@UiThreadTest
fun withPadding_cameraInvalidated_paddingPersisting() {
val initialCameraPosition = mapboxMap.cameraPosition
val initialPoint = mapboxMap.projection.toScreenLocation(initialCameraPosition.target!!)
val initialCameraPosition = maplibreMap.cameraPosition
val initialPoint = maplibreMap.projection.toScreenLocation(initialCameraPosition.target!!)
val bottomPadding = mapView.height / 4
val leftPadding = mapView.width / 4
val padding = doubleArrayOf(leftPadding.toDouble(), 0.0, 0.0, bottomPadding.toDouble())
mapboxMap.moveCamera(CameraUpdateFactory.paddingTo(leftPadding.toDouble(), 0.0, 0.0, bottomPadding.toDouble()))
maplibreMap.moveCamera(CameraUpdateFactory.paddingTo(leftPadding.toDouble(), 0.0, 0.0, bottomPadding.toDouble()))
Assert.assertArrayEquals(intArrayOf(leftPadding, 0, 0, bottomPadding), mapboxMap.padding)
Assert.assertArrayEquals(intArrayOf(leftPadding, 0, 0, bottomPadding), maplibreMap.padding)
val resultingCameraPosition = mapboxMap.cameraPosition
val resultingCameraPosition = maplibreMap.cameraPosition
assertEquals(initialCameraPosition.target!!, resultingCameraPosition.target!!)
assertEquals(
PointF(initialPoint.x + leftPadding / 2, initialPoint.y - bottomPadding / 2),
mapboxMap.projection.toScreenLocation(resultingCameraPosition.target!!)
maplibreMap.projection.toScreenLocation(resultingCameraPosition.target!!)
)
Assert.assertArrayEquals(padding, resultingCameraPosition.padding, 0.0001)
}
@@ -170,15 +170,15 @@ class CameraUpdateFactoryTest : BaseTest() {
val topPadding = mapView.height / 4
val rightPadding = mapView.width / 4
val padding = doubleArrayOf(0.0, topPadding.toDouble(), rightPadding.toDouble(), 0.0)
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngPadding(expectedTarget, 0.0, topPadding.toDouble(), rightPadding.toDouble(), 0.0))
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngPadding(expectedTarget, 0.0, topPadding.toDouble(), rightPadding.toDouble(), 0.0))
Assert.assertArrayEquals(intArrayOf(0, topPadding, rightPadding, 0), mapboxMap.padding)
Assert.assertArrayEquals(intArrayOf(0, topPadding, rightPadding, 0), maplibreMap.padding)
val resultingCameraPosition = mapboxMap.cameraPosition
val resultingCameraPosition = maplibreMap.cameraPosition
assertEquals(expectedTarget.latitude, resultingCameraPosition.target!!.latitude, 0.1)
assertEquals(expectedTarget!!.longitude, resultingCameraPosition.target!!.longitude, 0.1)
val centerLatLng = mapboxMap.projection.fromScreenLocation(PointF((mapView.width / 2).toFloat(), (mapView.height / 2).toFloat()))
val centerLatLng = maplibreMap.projection.fromScreenLocation(PointF((mapView.width / 2).toFloat(), (mapView.height / 2).toFloat()))
assertTrue(centerLatLng.latitude > resultingCameraPosition.target!!.latitude)
assertTrue(centerLatLng.longitude > resultingCameraPosition.target!!.longitude)
Assert.assertArrayEquals(padding, resultingCameraPosition.padding, 0.0001)

View File

@@ -1,11 +1,11 @@
package com.mapbox.mapboxsdk.integration
package org.maplibre.android.integration
import android.content.Context
import android.content.Intent
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.*
import com.mapbox.mapboxsdk.AppCenter
import org.maplibre.android.AppCenter
import org.junit.Before
const val TIMEOUT_UI_SEARCH_WAIT = 5000L

View File

@@ -1,10 +1,10 @@
package com.mapbox.mapboxsdk.integration
package org.maplibre.android.integration
import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import androidx.test.uiautomator.UiSelector
import com.mapbox.mapboxsdk.testapp.activity.fragment.FragmentBackStackActivity
import org.maplibre.android.testapp.activity.fragment.FragmentBackStackActivity
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

View File

@@ -1,9 +1,9 @@
package com.mapbox.mapboxsdk.integration
package org.maplibre.android.integration
import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.testapp.activity.maplayout.SimpleMapActivity
import org.maplibre.android.testapp.activity.maplayout.SimpleMapActivity
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

View File

@@ -1,9 +1,9 @@
package com.mapbox.mapboxsdk.integration
package org.maplibre.android.integration
import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.testapp.activity.maplayout.GLSurfaceRecyclerViewActivity
import org.maplibre.android.testapp.activity.maplayout.GLSurfaceRecyclerViewActivity
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

View File

@@ -1,9 +1,9 @@
package com.mapbox.mapboxsdk.integration
package org.maplibre.android.integration
import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.testapp.activity.maplayout.SimpleMapActivity
import org.maplibre.android.testapp.activity.maplayout.SimpleMapActivity
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

View File

@@ -1,9 +1,9 @@
package com.mapbox.mapboxsdk.integration
package org.maplibre.android.integration
import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.testapp.activity.feature.QueryRenderedFeaturesBoxCountActivity
import org.maplibre.android.testapp.activity.feature.QueryRenderedFeaturesBoxCountActivity
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

View File

@@ -1,9 +1,9 @@
package com.mapbox.mapboxsdk.integration
package org.maplibre.android.integration
import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.testapp.activity.textureview.TextureViewDebugModeActivity
import org.maplibre.android.testapp.activity.textureview.TextureViewDebugModeActivity
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

View File

@@ -1,9 +1,9 @@
package com.mapbox.mapboxsdk.integration
package org.maplibre.android.integration
import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.testapp.activity.maplayout.TextureRecyclerViewActivity
import org.maplibre.android.testapp.activity.maplayout.TextureRecyclerViewActivity
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

View File

@@ -1,10 +1,10 @@
package com.mapbox.mapboxsdk.integration
package org.maplibre.android.integration
import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import androidx.test.uiautomator.UiSelector
import com.mapbox.mapboxsdk.testapp.activity.fragment.ViewPagerActivity
import org.maplibre.android.testapp.activity.fragment.ViewPagerActivity
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

View File

@@ -1,40 +1,35 @@
// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
package com.mapbox.mapboxsdk.location;
package org.maplibre.android.location;
import android.graphics.Color;
import androidx.test.annotation.UiThreadTest;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import com.mapbox.geojson.LineString;
import com.mapbox.geojson.MultiLineString;
import com.mapbox.geojson.MultiPoint;
import com.mapbox.geojson.MultiPolygon;
import com.mapbox.geojson.Point;
import com.mapbox.geojson.Polygon;
import org.maplibre.android.maps.BaseLayerTest;
import org.junit.Before;
import timber.log.Timber;
import org.maplibre.android.style.expressions.Expression;
import org.junit.Test;
import org.junit.runner.RunWith;
import timber.log.Timber;
import static org.maplibre.android.style.expressions.Expression.*;
import static org.junit.Assert.*;
import static org.maplibre.android.style.layers.Property.*;
import static org.maplibre.android.location.LocationPropertyFactory.*;
import static com.mapbox.mapboxsdk.location.LocationPropertyFactory.accuracyRadius;
import static com.mapbox.mapboxsdk.location.LocationPropertyFactory.accuracyRadiusBorderColor;
import static com.mapbox.mapboxsdk.location.LocationPropertyFactory.accuracyRadiusColor;
import static com.mapbox.mapboxsdk.location.LocationPropertyFactory.bearing;
import static com.mapbox.mapboxsdk.location.LocationPropertyFactory.bearingImage;
import static com.mapbox.mapboxsdk.location.LocationPropertyFactory.bearingImageSize;
import static com.mapbox.mapboxsdk.location.LocationPropertyFactory.imageTiltDisplacement;
import static com.mapbox.mapboxsdk.location.LocationPropertyFactory.location;
import static com.mapbox.mapboxsdk.location.LocationPropertyFactory.perspectiveCompensation;
import static com.mapbox.mapboxsdk.location.LocationPropertyFactory.shadowImage;
import static com.mapbox.mapboxsdk.location.LocationPropertyFactory.shadowImageSize;
import static com.mapbox.mapboxsdk.location.LocationPropertyFactory.topImage;
import static com.mapbox.mapboxsdk.location.LocationPropertyFactory.topImageSize;
import static com.mapbox.mapboxsdk.location.LocationPropertyFactory.visibility;
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import org.maplibre.android.style.layers.TransitionOptions;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Basic smoke tests for LocationIndicatorLayer
@@ -43,6 +38,19 @@ import static org.junit.Assert.assertNull;
public class LocationIndicatorLayerTest extends BaseLayerTest {
private LocationIndicatorLayer layer;
private final List<Point> pointsList = new ArrayList<Point>() {
{
add(Point.fromLngLat(55.30122473231012, 25.26476622289597));
add(Point.fromLngLat(55.29743486255916, 25.25827212207261));
add(Point.fromLngLat(55.28978863411328, 25.251356725509737));
add(Point.fromLngLat(55.300027931336984, 25.246425506635504));
add(Point.fromLngLat(55.307474692951274, 25.244200378933655));
add(Point.fromLngLat(55.31212891895635, 25.256408010450187));
add(Point.fromLngLat(55.30774064871093, 25.26266169122738));
add(Point.fromLngLat(55.301357710197806, 25.264946609615492));
add(Point.fromLngLat(55.30122473231012, 25.26476622289597));
}
};
@Before
@UiThreadTest

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.location
package org.maplibre.android.location
import android.Manifest
import android.content.Context
@@ -14,20 +14,20 @@ import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.GrantPermissionRule
import androidx.test.rule.GrantPermissionRule.grant
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.location.LocationComponentConstants.*
import com.mapbox.mapboxsdk.location.modes.RenderMode
import com.mapbox.mapboxsdk.location.utils.*
import com.mapbox.mapboxsdk.location.utils.MapboxTestingUtils.Companion.MAPBOX_HEAVY_STYLE
import com.mapbox.mapboxsdk.location.utils.MapboxTestingUtils.Companion.pushSourceUpdates
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.maps.Style
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
import com.mapbox.mapboxsdk.testapp.R
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest
import com.mapbox.mapboxsdk.testapp.utils.TestingAsyncUtils
import com.mapbox.mapboxsdk.utils.BitmapUtils
import org.maplibre.android.camera.CameraUpdateFactory
import org.maplibre.android.geometry.LatLng
import org.maplibre.android.location.LocationComponentConstants.*
import org.maplibre.android.location.modes.RenderMode
import org.maplibre.android.location.utils.*
import org.maplibre.android.location.utils.MapLibreTestingUtils.Companion.MAPBOX_HEAVY_STYLE
import org.maplibre.android.location.utils.MapLibreTestingUtils.Companion.pushSourceUpdates
import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.Style
import org.maplibre.android.style.sources.GeoJsonSource
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.activity.EspressoTest
import org.maplibre.android.testapp.utils.TestingAsyncUtils
import org.maplibre.android.utils.BitmapUtils
import org.hamcrest.CoreMatchers.`is`
import org.hamcrest.CoreMatchers.notNullValue
import org.hamcrest.Matchers.equalTo
@@ -73,7 +73,7 @@ class LocationLayerControllerTest : EspressoTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(
component: LocationComponent,
mapboxMap: MapboxMap,
maplibreMap: MapLibreMap,
style: Style,
uiController: UiController,
context: Context
@@ -103,7 +103,7 @@ class LocationLayerControllerTest : EspressoTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(
component: LocationComponent,
mapboxMap: MapboxMap,
maplibreMap: MapLibreMap,
style: Style,
uiController: UiController,
context: Context
@@ -119,12 +119,12 @@ class LocationLayerControllerTest : EspressoTest() {
component.forceLocationUpdate(location)
TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(true))
assertThat(mapboxMap.isLayerVisible(BACKGROUND_LAYER), `is`(true))
assertThat(mapboxMap.isLayerVisible(SHADOW_LAYER), `is`(true))
assertThat(mapboxMap.isLayerVisible(ACCURACY_LAYER), `is`(true))
assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(false))
assertThat(mapboxMap.isLayerVisible(PULSING_CIRCLE_LAYER), `is`(false))
assertThat(maplibreMap.isLayerVisible(FOREGROUND_LAYER), `is`(true))
assertThat(maplibreMap.isLayerVisible(BACKGROUND_LAYER), `is`(true))
assertThat(maplibreMap.isLayerVisible(SHADOW_LAYER), `is`(true))
assertThat(maplibreMap.isLayerVisible(ACCURACY_LAYER), `is`(true))
assertThat(maplibreMap.isLayerVisible(BEARING_LAYER), `is`(false))
assertThat(maplibreMap.isLayerVisible(PULSING_CIRCLE_LAYER), `is`(false))
}
}
executeComponentTest(componentAction)
@@ -135,7 +135,7 @@ class LocationLayerControllerTest : EspressoTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(
component: LocationComponent,
mapboxMap: MapboxMap,
maplibreMap: MapLibreMap,
style: Style,
uiController: UiController,
context: Context
@@ -154,17 +154,17 @@ class LocationLayerControllerTest : EspressoTest() {
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.NORMAL
component.forceLocationUpdate(location)
styleChangeIdlingResource.waitForStyle(mapboxMap, Style.getPredefinedStyle("Bright"))
styleChangeIdlingResource.waitForStyle(maplibreMap, Style.getPredefinedStyle("Bright"))
TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(component.renderMode, `is`(equalTo(RenderMode.NORMAL)))
// Check that the Source has been re-added to the new map style
val source: GeoJsonSource? = mapboxMap.style!!.getSourceAs(LOCATION_SOURCE)
val source: GeoJsonSource? = maplibreMap.style!!.getSourceAs(LOCATION_SOURCE)
assertThat(source, notNullValue())
// Check that the pulsing circle layer visibilities is set to visible
assertThat(mapboxMap.isLayerVisible(PULSING_CIRCLE_LAYER), `is`(true))
assertThat(maplibreMap.isLayerVisible(PULSING_CIRCLE_LAYER), `is`(true))
}
}
}
@@ -174,7 +174,7 @@ class LocationLayerControllerTest : EspressoTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(
component: LocationComponent,
mapboxMap: MapboxMap,
maplibreMap: MapLibreMap,
style: Style,
uiController: UiController,
context: Context
@@ -190,11 +190,11 @@ class LocationLayerControllerTest : EspressoTest() {
component.forceLocationUpdate(location)
TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(true))
assertThat(mapboxMap.isLayerVisible(BACKGROUND_LAYER), `is`(true))
assertThat(mapboxMap.isLayerVisible(SHADOW_LAYER), `is`(true))
assertThat(mapboxMap.isLayerVisible(ACCURACY_LAYER), `is`(true))
assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(true))
assertThat(maplibreMap.isLayerVisible(FOREGROUND_LAYER), `is`(true))
assertThat(maplibreMap.isLayerVisible(BACKGROUND_LAYER), `is`(true))
assertThat(maplibreMap.isLayerVisible(SHADOW_LAYER), `is`(true))
assertThat(maplibreMap.isLayerVisible(ACCURACY_LAYER), `is`(true))
assertThat(maplibreMap.isLayerVisible(BEARING_LAYER), `is`(true))
}
}
executeComponentTest(componentAction)
@@ -205,7 +205,7 @@ class LocationLayerControllerTest : EspressoTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(
component: LocationComponent,
mapboxMap: MapboxMap,
maplibreMap: MapLibreMap,
style: Style,
uiController: UiController,
context: Context
@@ -225,7 +225,7 @@ class LocationLayerControllerTest : EspressoTest() {
.pulseEnabled(true).build()
)
assertThat(mapboxMap.isLayerVisible(PULSING_CIRCLE_LAYER), `is`(true))
assertThat(maplibreMap.isLayerVisible(PULSING_CIRCLE_LAYER), `is`(true))
}
}
executeComponentTest(componentAction)
@@ -236,7 +236,7 @@ class LocationLayerControllerTest : EspressoTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(
component: LocationComponent,
mapboxMap: MapboxMap,
maplibreMap: MapLibreMap,
style: Style,
uiController: UiController,
context: Context
@@ -251,7 +251,7 @@ class LocationLayerControllerTest : EspressoTest() {
component.forceLocationUpdate(location)
TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(mapboxMap.isLayerVisible(PULSING_CIRCLE_LAYER), `is`(false))
assertThat(maplibreMap.isLayerVisible(PULSING_CIRCLE_LAYER), `is`(false))
}
}
executeComponentTest(componentAction)
@@ -262,7 +262,7 @@ class LocationLayerControllerTest : EspressoTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(
component: LocationComponent,
mapboxMap: MapboxMap,
maplibreMap: MapLibreMap,
style: Style,
uiController: UiController,
context: Context
@@ -291,7 +291,7 @@ class LocationLayerControllerTest : EspressoTest() {
.build()
)
mapboxMap.style.apply {
maplibreMap.style.apply {
assertThat(component.locationComponentOptions.pulseColor(), `is`(Color.BLUE))
}
}
@@ -304,7 +304,7 @@ class LocationLayerControllerTest : EspressoTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(
component: LocationComponent,
mapboxMap: MapboxMap,
maplibreMap: MapLibreMap,
style: Style,
uiController: UiController,
context: Context
@@ -333,7 +333,7 @@ class LocationLayerControllerTest : EspressoTest() {
.build()
)
mapboxMap.style.apply {
maplibreMap.style.apply {
assertThat(component.locationComponentOptions.pulseSingleDuration(), `is`(400f))
}
}
@@ -346,7 +346,7 @@ class LocationLayerControllerTest : EspressoTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(
component: LocationComponent,
mapboxMap: MapboxMap,
maplibreMap: MapLibreMap,
style: Style,
uiController: UiController,
context: Context
@@ -362,11 +362,11 @@ class LocationLayerControllerTest : EspressoTest() {
component.forceLocationUpdate(location)
TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(true))
assertThat(mapboxMap.isLayerVisible(BACKGROUND_LAYER), `is`(true))
assertThat(mapboxMap.isLayerVisible(SHADOW_LAYER), `is`(false))
assertThat(mapboxMap.isLayerVisible(ACCURACY_LAYER), `is`(false))
assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(false))
assertThat(maplibreMap.isLayerVisible(FOREGROUND_LAYER), `is`(true))
assertThat(maplibreMap.isLayerVisible(BACKGROUND_LAYER), `is`(true))
assertThat(maplibreMap.isLayerVisible(SHADOW_LAYER), `is`(false))
assertThat(maplibreMap.isLayerVisible(ACCURACY_LAYER), `is`(false))
assertThat(maplibreMap.isLayerVisible(BEARING_LAYER), `is`(false))
}
}
executeComponentTest(componentAction)
@@ -377,7 +377,7 @@ class LocationLayerControllerTest : EspressoTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(
component: LocationComponent,
mapboxMap: MapboxMap,
maplibreMap: MapLibreMap,
style: Style,
uiController: UiController,
context: Context
@@ -394,11 +394,11 @@ class LocationLayerControllerTest : EspressoTest() {
TestingAsyncUtils.waitForLayer(uiController, mapView)
component.renderMode = RenderMode.GPS
assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(false))
assertThat(mapboxMap.isLayerVisible(BACKGROUND_LAYER), `is`(false))
assertThat(mapboxMap.isLayerVisible(SHADOW_LAYER), `is`(false))
assertThat(mapboxMap.isLayerVisible(ACCURACY_LAYER), `is`(false))
assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(false))
assertThat(maplibreMap.isLayerVisible(FOREGROUND_LAYER), `is`(false))
assertThat(maplibreMap.isLayerVisible(BACKGROUND_LAYER), `is`(false))
assertThat(maplibreMap.isLayerVisible(SHADOW_LAYER), `is`(false))
assertThat(maplibreMap.isLayerVisible(ACCURACY_LAYER), `is`(false))
assertThat(maplibreMap.isLayerVisible(BEARING_LAYER), `is`(false))
}
}
executeComponentTest(componentAction)
@@ -409,7 +409,7 @@ class LocationLayerControllerTest : EspressoTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(
component: LocationComponent,
mapboxMap: MapboxMap,
maplibreMap: MapLibreMap,
style: Style,
uiController: UiController,
context: Context
@@ -427,11 +427,11 @@ class LocationLayerControllerTest : EspressoTest() {
TestingAsyncUtils.waitForLayer(uiController, mapView)
// Check that all layers visibilities are set to none
assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(false))
assertThat(mapboxMap.isLayerVisible(BACKGROUND_LAYER), `is`(false))
assertThat(mapboxMap.isLayerVisible(SHADOW_LAYER), `is`(false))
assertThat(mapboxMap.isLayerVisible(ACCURACY_LAYER), `is`(false))
assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(false))
assertThat(maplibreMap.isLayerVisible(FOREGROUND_LAYER), `is`(false))
assertThat(maplibreMap.isLayerVisible(BACKGROUND_LAYER), `is`(false))
assertThat(maplibreMap.isLayerVisible(SHADOW_LAYER), `is`(false))
assertThat(maplibreMap.isLayerVisible(ACCURACY_LAYER), `is`(false))
assertThat(maplibreMap.isLayerVisible(BEARING_LAYER), `is`(false))
}
}
executeComponentTest(componentAction)
@@ -442,7 +442,7 @@ class LocationLayerControllerTest : EspressoTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(
component: LocationComponent,
mapboxMap: MapboxMap,
maplibreMap: MapLibreMap,
style: Style,
uiController: UiController,
context: Context
@@ -456,21 +456,21 @@ class LocationLayerControllerTest : EspressoTest() {
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.NORMAL
component.forceLocationUpdate(location)
styleChangeIdlingResource.waitForStyle(mapboxMap, Style.getPredefinedStyle("Bright"))
styleChangeIdlingResource.waitForStyle(maplibreMap, Style.getPredefinedStyle("Bright"))
TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(component.renderMode, `is`(equalTo(RenderMode.NORMAL)))
// Check that the Source has been re-added to the new map style
val source: GeoJsonSource? = mapboxMap.style!!.getSourceAs(LOCATION_SOURCE)
val source: GeoJsonSource? = maplibreMap.style!!.getSourceAs(LOCATION_SOURCE)
assertThat(source, notNullValue())
// Check that all layers visibilities are set to visible
assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(true))
assertThat(mapboxMap.isLayerVisible(BACKGROUND_LAYER), `is`(true))
assertThat(mapboxMap.isLayerVisible(SHADOW_LAYER), `is`(true))
assertThat(mapboxMap.isLayerVisible(ACCURACY_LAYER), `is`(true))
assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(false))
assertThat(maplibreMap.isLayerVisible(FOREGROUND_LAYER), `is`(true))
assertThat(maplibreMap.isLayerVisible(BACKGROUND_LAYER), `is`(true))
assertThat(maplibreMap.isLayerVisible(SHADOW_LAYER), `is`(true))
assertThat(maplibreMap.isLayerVisible(ACCURACY_LAYER), `is`(true))
assertThat(maplibreMap.isLayerVisible(BEARING_LAYER), `is`(false))
}
}
executeComponentTest(componentAction)
@@ -481,7 +481,7 @@ class LocationLayerControllerTest : EspressoTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(
component: LocationComponent,
mapboxMap: MapboxMap,
maplibreMap: MapLibreMap,
style: Style,
uiController: UiController,
context: Context
@@ -499,15 +499,15 @@ class LocationLayerControllerTest : EspressoTest() {
uiController.loopMainThreadForAtLeast(150)
assertThat(
mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE),
maplibreMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE),
`is`(true)
)
mapboxMap.setStyle(Style.Builder().fromUrl(Style.getPredefinedStyle("Bright")))
maplibreMap.setStyle(Style.Builder().fromUrl(Style.getPredefinedStyle("Bright")))
TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(
mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE),
maplibreMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE),
`is`(true)
)
}
@@ -520,7 +520,7 @@ class LocationLayerControllerTest : EspressoTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(
component: LocationComponent,
mapboxMap: MapboxMap,
maplibreMap: MapLibreMap,
style: Style,
uiController: UiController,
context: Context
@@ -536,7 +536,7 @@ class LocationLayerControllerTest : EspressoTest() {
TestingAsyncUtils.waitForLayer(uiController, mapView)
component.isLocationComponentEnabled = false
TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(mapboxMap.queryRenderedFeatures(location, FOREGROUND_LAYER).isEmpty(), `is`(true))
assertThat(maplibreMap.queryRenderedFeatures(location, FOREGROUND_LAYER).isEmpty(), `is`(true))
val options = component.locationComponentOptions
.toBuilder()
@@ -545,7 +545,7 @@ class LocationLayerControllerTest : EspressoTest() {
component.applyStyle(options)
TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(mapboxMap.queryRenderedFeatures(location, FOREGROUND_LAYER).isEmpty(), `is`(true))
assertThat(maplibreMap.queryRenderedFeatures(location, FOREGROUND_LAYER).isEmpty(), `is`(true))
}
}
executeComponentTest(componentAction)
@@ -556,7 +556,7 @@ class LocationLayerControllerTest : EspressoTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(
component: LocationComponent,
mapboxMap: MapboxMap,
maplibreMap: MapLibreMap,
style: Style,
uiController: UiController,
context: Context
@@ -569,7 +569,7 @@ class LocationLayerControllerTest : EspressoTest() {
)
component.isLocationComponentEnabled = true
component.applyStyle(LocationComponentOptions.builder(context).staleStateTimeout(1).build())
styleChangeIdlingResource.waitForStyle(mapboxMap, MAPBOX_HEAVY_STYLE)
styleChangeIdlingResource.waitForStyle(maplibreMap, MAPBOX_HEAVY_STYLE)
pushSourceUpdates(styleChangeIdlingResource) {
component.forceLocationUpdate(location)
}
@@ -586,17 +586,17 @@ class LocationLayerControllerTest : EspressoTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(
component: LocationComponent,
mapboxMap: MapboxMap,
maplibreMap: MapLibreMap,
style: Style,
uiController: UiController,
context: Context
) {
styleChangeIdlingResource.waitForStyle(mapboxMap, MAPBOX_HEAVY_STYLE)
styleChangeIdlingResource.waitForStyle(maplibreMap, MAPBOX_HEAVY_STYLE)
uiController.loopMainThreadForAtLeast(100)
var show = true
component.activateLocationComponent(
LocationComponentActivationOptions
.builder(context, mapboxMap.style!!)
.builder(context, maplibreMap.style!!)
.useDefaultLocationEngine(false)
.build()
)
@@ -619,7 +619,7 @@ class LocationLayerControllerTest : EspressoTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(
component: LocationComponent,
mapboxMap: MapboxMap,
maplibreMap: MapLibreMap,
style: Style,
uiController: UiController,
context: Context
@@ -631,14 +631,14 @@ class LocationLayerControllerTest : EspressoTest() {
.build()
)
component.isLocationComponentEnabled = true
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(location), 16.0))
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(location), 16.0))
component.forceLocationUpdate(location)
TestingAsyncUtils.waitForLayer(uiController, mapView)
uiController.loopMainThreadForAtLeast(ACCURACY_RADIUS_ANIMATION_DURATION)
assertEquals(
Utils.calculateZoomLevelRadius(mapboxMap, location) /*meters projected to radius on zoom 16*/,
mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0]
Utils.calculateZoomLevelRadius(maplibreMap, location) /*meters projected to radius on zoom 16*/,
maplibreMap.querySourceFeatures(LOCATION_SOURCE)[0]
.getNumberProperty(PROPERTY_ACCURACY_RADIUS).toFloat(),
0.1f
)
@@ -652,7 +652,7 @@ class LocationLayerControllerTest : EspressoTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(
component: LocationComponent,
mapboxMap: MapboxMap,
maplibreMap: MapLibreMap,
style: Style,
uiController: UiController,
context: Context
@@ -668,22 +668,22 @@ class LocationLayerControllerTest : EspressoTest() {
val target = LatLng(location)
val zoom = 16.0
mapboxMap.easeCamera(CameraUpdateFactory.newLatLngZoom(target, zoom), 300)
maplibreMap.easeCamera(CameraUpdateFactory.newLatLngZoom(target, zoom), 300)
uiController.loopMainThreadForAtLeast(300)
TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(
Math.abs(zoom - mapboxMap.cameraPosition.zoom) < 0.1 &&
Math.abs(target.latitude - mapboxMap.cameraPosition.target!!.latitude) < 0.1 &&
Math.abs(target!!.longitude - mapboxMap.cameraPosition.target!!.longitude) < 0.1,
Math.abs(zoom - maplibreMap.cameraPosition.zoom) < 0.1 &&
Math.abs(target.latitude - maplibreMap.cameraPosition.target!!.latitude) < 0.1 &&
Math.abs(target!!.longitude - maplibreMap.cameraPosition.target!!.longitude) < 0.1,
`is`(true)
)
val expectedRadius =
Utils.calculateZoomLevelRadius(mapboxMap, location) /*meters projected to radius on zoom 16*/
Utils.calculateZoomLevelRadius(maplibreMap, location) /*meters projected to radius on zoom 16*/
assertThat(
Math.abs(
expectedRadius - mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getNumberProperty(
expectedRadius - maplibreMap.querySourceFeatures(LOCATION_SOURCE)[0].getNumberProperty(
PROPERTY_ACCURACY_RADIUS
).toFloat()
) < 0.1,
@@ -699,7 +699,7 @@ class LocationLayerControllerTest : EspressoTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(
component: LocationComponent,
mapboxMap: MapboxMap,
maplibreMap: MapLibreMap,
style: Style,
uiController: UiController,
context: Context
@@ -715,21 +715,21 @@ class LocationLayerControllerTest : EspressoTest() {
val target = LatLng(location)
val zoom = 16.0
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(target, zoom))
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngZoom(target, zoom))
TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(
abs(zoom - mapboxMap.cameraPosition.zoom) < 0.1 &&
abs(target.latitude - mapboxMap.cameraPosition.target!!.latitude) < 0.1 &&
abs(target!!.longitude - mapboxMap.cameraPosition.target!!.longitude) < 0.1,
abs(zoom - maplibreMap.cameraPosition.zoom) < 0.1 &&
abs(target.latitude - maplibreMap.cameraPosition.target!!.latitude) < 0.1 &&
abs(target!!.longitude - maplibreMap.cameraPosition.target!!.longitude) < 0.1,
`is`(true)
)
val expectedRadius =
Utils.calculateZoomLevelRadius(mapboxMap, location) /*meters projected to radius on zoom 16*/
Utils.calculateZoomLevelRadius(maplibreMap, location) /*meters projected to radius on zoom 16*/
assertThat(
Math.abs(
expectedRadius - mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getNumberProperty(
expectedRadius - maplibreMap.querySourceFeatures(LOCATION_SOURCE)[0].getNumberProperty(
PROPERTY_ACCURACY_RADIUS
).toFloat()
) < 0.1,
@@ -745,7 +745,7 @@ class LocationLayerControllerTest : EspressoTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(
component: LocationComponent,
mapboxMap: MapboxMap,
maplibreMap: MapLibreMap,
style: Style,
uiController: UiController,
context: Context
@@ -762,11 +762,11 @@ class LocationLayerControllerTest : EspressoTest() {
component.applyStyle(LocationComponentOptions.builder(context).layerBelow("road-label").build())
assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(true))
assertThat(mapboxMap.isLayerVisible(BACKGROUND_LAYER), `is`(true))
assertThat(mapboxMap.isLayerVisible(SHADOW_LAYER), `is`(true))
assertThat(mapboxMap.isLayerVisible(ACCURACY_LAYER), `is`(true))
assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(false))
assertThat(maplibreMap.isLayerVisible(FOREGROUND_LAYER), `is`(true))
assertThat(maplibreMap.isLayerVisible(BACKGROUND_LAYER), `is`(true))
assertThat(maplibreMap.isLayerVisible(SHADOW_LAYER), `is`(true))
assertThat(maplibreMap.isLayerVisible(ACCURACY_LAYER), `is`(true))
assertThat(maplibreMap.isLayerVisible(BEARING_LAYER), `is`(false))
}
}
executeComponentTest(componentAction)
@@ -787,6 +787,6 @@ class LocationLayerControllerTest : EspressoTest() {
}
private fun executeComponentTest(listener: LocationComponentAction.OnPerformLocationComponentAction) {
onView(withId(android.R.id.content)).perform(LocationComponentAction(mapboxMap, listener))
onView(withId(android.R.id.content)).perform(LocationComponentAction(maplibreMap, listener))
}
}

View File

@@ -1,17 +1,17 @@
package com.mapbox.mapboxsdk.location.utils
package org.maplibre.android.location.utils
import android.content.Context
import android.view.View
import androidx.test.espresso.UiController
import androidx.test.espresso.ViewAction
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import com.mapbox.mapboxsdk.location.LocationComponent
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.maps.Style
import org.maplibre.android.location.LocationComponent
import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.Style
import org.hamcrest.Matcher
class LocationComponentAction(
private val mapboxMap: MapboxMap,
private val maplibreMap: MapLibreMap,
private val onPerformLocationComponentAction: OnPerformLocationComponentAction
) : ViewAction {
@@ -25,15 +25,15 @@ class LocationComponentAction(
override fun perform(uiController: UiController, view: View) {
onPerformLocationComponentAction.onLocationComponentAction(
mapboxMap.locationComponent,
mapboxMap,
mapboxMap.style!!,
maplibreMap.locationComponent,
maplibreMap,
maplibreMap.style!!,
uiController,
view.context
)
}
interface OnPerformLocationComponentAction {
fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, style: Style, uiController: UiController, context: Context)
fun onLocationComponentAction(component: LocationComponent, maplibreMap: MapLibreMap, style: Style, uiController: UiController, context: Context)
}
}

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.location.utils
package org.maplibre.android.location.utils
import android.graphics.Bitmap
import android.graphics.Canvas
@@ -8,26 +8,26 @@ import android.location.Location
import android.os.Handler
import android.os.Looper
import com.mapbox.geojson.Feature
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.style.layers.Property
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
import org.maplibre.android.geometry.LatLng
import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.style.layers.Property
import org.maplibre.android.style.sources.GeoJsonSource
fun MapboxMap.querySourceFeatures(sourceId: String): List<Feature> {
fun MapLibreMap.querySourceFeatures(sourceId: String): List<Feature> {
return this.style!!.getSourceAs<GeoJsonSource>(sourceId)?.querySourceFeatures(null) ?: emptyList()
}
fun MapboxMap.queryRenderedFeatures(location: Location, layerId: String): List<Feature> {
fun MapLibreMap.queryRenderedFeatures(location: Location, layerId: String): List<Feature> {
val latLng = LatLng(location.latitude, location.longitude)
val point = this.projection.toScreenLocation(latLng)
return this.queryRenderedFeatures(point, layerId)
}
fun MapboxMap.isLayerVisible(layerId: String): Boolean {
fun MapLibreMap.isLayerVisible(layerId: String): Boolean {
return this.style!!.getLayer(layerId)?.visibility?.value?.equals(Property.VISIBLE)!!
}
class MapboxTestingUtils {
class MapLibreTestingUtils {
companion object {
/**
@@ -63,7 +63,7 @@ class MapboxTestingUtils {
}
}
fun MapboxMap.addImageFromDrawable(string: String, drawable: Drawable) {
fun MapLibreMap.addImageFromDrawable(string: String, drawable: Drawable) {
val bitmapFromDrawable = getBitmapFromDrawable(drawable)
this.style!!.addImage(string, bitmapFromDrawable)
}

View File

@@ -1,8 +1,8 @@
package com.mapbox.mapboxsdk.location.utils
package org.maplibre.android.location.utils
import androidx.test.espresso.IdlingResource
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.maps.Style
import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.Style
/**
* Resource, that's idling until the provided style is loaded.
@@ -31,9 +31,9 @@ class StyleChangeIdlingResource : IdlingResource {
callback?.onTransitionToIdle()
}
fun waitForStyle(mapboxMap: MapboxMap, styleUrl: String) {
fun waitForStyle(maplibreMap: MapLibreMap, styleUrl: String) {
isIdle = false
mapboxMap.setStyle(Style.Builder().fromUri(styleUrl)) {
maplibreMap.setStyle(Style.Builder().fromUri(styleUrl)) {
setIdle()
}
}

View File

@@ -1,9 +1,9 @@
package com.mapbox.mapboxsdk.maps
package org.maplibre.android.maps
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.platform.app.InstrumentationRegistry
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.style.layers.Layer
import org.maplibre.android.AppCenter
import org.maplibre.android.style.layers.Layer
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4ClassRunner::class)

View File

@@ -1,13 +1,13 @@
package com.mapbox.mapboxsdk.maps
package org.maplibre.android.maps
import androidx.test.annotation.UiThreadTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.platform.app.InstrumentationRegistry
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.Mapbox
import com.mapbox.mapboxsdk.WellKnownTileServer
import com.mapbox.mapboxsdk.storage.FileSource
import com.mapbox.mapboxsdk.util.TileServerOptions
import org.maplibre.android.AppCenter
import org.maplibre.android.MapLibre
import org.maplibre.android.WellKnownTileServer
import org.maplibre.android.storage.FileSource
import org.maplibre.android.util.TileServerOptions
import org.junit.*
import org.junit.runner.RunWith
@@ -19,14 +19,14 @@ class BootstrapTest : AppCenter() {
@Before
@UiThreadTest
fun before() {
apiKeyBackup = Mapbox.getApiKey()
apiKeyBackup = MapLibre.getApiKey()
}
@After
@UiThreadTest
fun after() {
val context = InstrumentationRegistry.getInstrumentation().context
Mapbox.getInstance(context)
MapLibre.getInstance(context)
}
@Test
@@ -34,7 +34,7 @@ class BootstrapTest : AppCenter() {
fun defaultBootstrap() {
val context = InstrumentationRegistry.getInstrumentation().context
Mapbox.getInstance(context)
MapLibre.getInstance(context)
val tileServerOptions = TileServerOptions.get(WellKnownTileServer.MapLibre)
Assert.assertTrue(
@@ -54,7 +54,7 @@ class BootstrapTest : AppCenter() {
val context = InstrumentationRegistry.getInstrumentation().context
val key = "abcdef"
Mapbox.getInstance(context, key, WellKnownTileServer.MapTiler)
MapLibre.getInstance(context, key, WellKnownTileServer.MapTiler)
val tileServerOptions = TileServerOptions.get(WellKnownTileServer.MapTiler)
Assert.assertTrue(
@@ -76,9 +76,9 @@ class BootstrapTest : AppCenter() {
val key = "pk.abcdef"
Mapbox.getInstance(context, key, WellKnownTileServer.MapTiler)
Mapbox.getInstance(context)
Mapbox.getInstance(context, key, WellKnownTileServer.Mapbox)
MapLibre.getInstance(context, key, WellKnownTileServer.MapTiler)
MapLibre.getInstance(context)
MapLibre.getInstance(context, key, WellKnownTileServer.Mapbox)
val tileServerOptions = TileServerOptions.get(WellKnownTileServer.Mapbox)
Assert.assertTrue(

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.maps
package org.maplibre.android.maps
import android.graphics.PointF
import android.os.SystemClock

View File

@@ -1,6 +1,6 @@
package com.mapbox.mapboxsdk.maps;
package org.maplibre.android.maps;
import com.mapbox.mapboxsdk.annotations.Icon;
import org.maplibre.android.annotations.Icon;
import java.lang.reflect.Field;
import java.util.HashMap;
@@ -12,11 +12,11 @@ public class IconManagerResolver {
private IconManager iconManager;
public IconManagerResolver(MapboxMap mapboxMap) {
public IconManagerResolver(MapLibreMap maplibreMap) {
try {
Field annotationManagerField = MapboxMap.class.getDeclaredField("annotationManager");
Field annotationManagerField = MapLibreMap.class.getDeclaredField("annotationManager");
annotationManagerField.setAccessible(true);
AnnotationManager annotationManager = (AnnotationManager) annotationManagerField.get(mapboxMap);
AnnotationManager annotationManager = (AnnotationManager) annotationManagerField.get(maplibreMap);
Field iconManagerField = AnnotationManager.class.getDeclaredField("iconManager");
iconManagerField.setAccessible(true);

View File

@@ -1,16 +1,16 @@
package com.mapbox.mapboxsdk.maps
package org.maplibre.android.maps
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.matcher.ViewMatchers.withId
import com.mapbox.mapboxsdk.camera.CameraPosition
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory
import com.mapbox.mapboxsdk.constants.MapboxConstants
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.maps.GesturesUiTestUtils.move
import com.mapbox.mapboxsdk.maps.GesturesUiTestUtils.quickScale
import com.mapbox.mapboxsdk.testapp.R
import com.mapbox.mapboxsdk.testapp.activity.BaseTest
import com.mapbox.mapboxsdk.testapp.activity.maplayout.SimpleMapActivity
import org.maplibre.android.camera.CameraPosition
import org.maplibre.android.camera.CameraUpdateFactory
import org.maplibre.android.constants.MapLibreConstants
import org.maplibre.android.geometry.LatLng
import org.maplibre.android.maps.GesturesUiTestUtils.move
import org.maplibre.android.maps.GesturesUiTestUtils.quickScale
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.activity.BaseTest
import org.maplibre.android.testapp.activity.maplayout.SimpleMapActivity
import org.junit.Assert
import org.junit.Before
import org.junit.Test
@@ -32,11 +32,11 @@ class MapGestureDetectorTest : BaseTest() {
validateTestSetup()
var initialZoom: Double? = null
rule.runOnUiThread {
initialZoom = mapboxMap.cameraPosition.zoom
initialZoom = maplibreMap.cameraPosition.zoom
}
onView(withId(R.id.mapView)).perform(quickScale(maxHeight / 2f, withVelocity = false))
rule.runOnUiThread {
Assert.assertTrue(mapboxMap.cameraPosition.zoom > initialZoom!!)
Assert.assertTrue(maplibreMap.cameraPosition.zoom > initialZoom!!)
}
}
@@ -47,22 +47,22 @@ class MapGestureDetectorTest : BaseTest() {
var initialCameraPosition: CameraPosition? = null
rule.runOnUiThread {
// zoom in so we can move vertically
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(4.0))
initialCameraPosition = mapboxMap.cameraPosition
mapboxMap.uiSettings.isQuickZoomGesturesEnabled = false
maplibreMap.moveCamera(CameraUpdateFactory.zoomTo(4.0))
initialCameraPosition = maplibreMap.cameraPosition
maplibreMap.uiSettings.isQuickZoomGesturesEnabled = false
}
onView(withId(R.id.mapView)).perform(quickScale(maxHeight / 2f))
rule.runOnUiThread {
// camera did not move
Assert.assertEquals(initialCameraPosition!!, mapboxMap.cameraPosition)
Assert.assertEquals(initialCameraPosition!!, maplibreMap.cameraPosition)
}
// move to expected target
onView(withId(R.id.mapView)).perform(move(-maxWidth / 2f, -maxHeight / 2f, withVelocity = false))
rule.runOnUiThread {
Assert.assertNotEquals(initialCameraPosition!!.target!!.latitude, mapboxMap.cameraPosition.target!!.latitude, 1.0)
Assert.assertNotEquals(initialCameraPosition!!.target!!.longitude, mapboxMap.cameraPosition.target!!.longitude, 1.0)
Assert.assertNotEquals(initialCameraPosition!!.target!!.latitude, maplibreMap.cameraPosition.target!!.latitude, 1.0)
Assert.assertNotEquals(initialCameraPosition!!.target!!.longitude, maplibreMap.cameraPosition.target!!.longitude, 1.0)
}
}
@@ -72,14 +72,14 @@ class MapGestureDetectorTest : BaseTest() {
validateTestSetup()
var initialTarget: LatLng? = null
rule.runOnUiThread {
initialTarget = mapboxMap.cameraPosition.target!!
initialTarget = maplibreMap.cameraPosition.target!!
}
onView(withId(R.id.mapView)).perform(quickScale(maxHeight / 2f))
rule.runOnUiThread {
// camera did not move
Assert.assertEquals(initialTarget!!.latitude, mapboxMap.cameraPosition.target!!.latitude, 1.0)
Assert.assertEquals(initialTarget!!.longitude, mapboxMap.cameraPosition.target!!.longitude, 1.0)
Assert.assertEquals(initialTarget!!.latitude, maplibreMap.cameraPosition.target!!.latitude, 1.0)
Assert.assertEquals(initialTarget!!.longitude, maplibreMap.cameraPosition.target!!.longitude, 1.0)
}
}
@@ -92,16 +92,16 @@ class MapGestureDetectorTest : BaseTest() {
var initialCameraPosition: CameraPosition? = null
rule.runOnUiThread {
// zoom in so we can move vertically
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(4.0))
initialCameraPosition = mapboxMap.cameraPosition
mapboxMap.uiSettings.isQuickZoomGesturesEnabled = false
maplibreMap.moveCamera(CameraUpdateFactory.zoomTo(4.0))
initialCameraPosition = maplibreMap.cameraPosition
maplibreMap.uiSettings.isQuickZoomGesturesEnabled = false
}
// move to expected target
onView(withId(R.id.mapView)).perform(move(-maxWidth / 2f, -maxHeight / 2f, withVelocity = false))
rule.runOnUiThread {
Assert.assertNotEquals(initialCameraPosition!!.target!!.latitude, mapboxMap.cameraPosition.target!!.latitude, 1.0)
Assert.assertNotEquals(initialCameraPosition!!.target!!.longitude, mapboxMap.cameraPosition.target!!.longitude, 1.0)
Assert.assertNotEquals(initialCameraPosition!!.target!!.latitude, maplibreMap.cameraPosition.target!!.latitude, 1.0)
Assert.assertNotEquals(initialCameraPosition!!.target!!.longitude, maplibreMap.cameraPosition.target!!.longitude, 1.0)
}
}
@@ -111,13 +111,13 @@ class MapGestureDetectorTest : BaseTest() {
validateTestSetup()
var initialZoom: Double? = null
rule.runOnUiThread {
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(2.0))
initialZoom = mapboxMap.cameraPosition.zoom
maplibreMap.moveCamera(CameraUpdateFactory.zoomTo(2.0))
initialZoom = maplibreMap.cameraPosition.zoom
}
onView(withId(R.id.mapView)).perform(quickScale(-(mapboxMap.gesturesManager.standardScaleGestureDetector.spanSinceStartThreshold * 2), withVelocity = false, duration = 1000L))
R.id.mapView.loopFor(MapboxConstants.ANIMATION_DURATION.toLong())
onView(withId(R.id.mapView)).perform(quickScale(-(maplibreMap.gesturesManager.standardScaleGestureDetector.spanSinceStartThreshold * 2), withVelocity = false, duration = 1000L))
R.id.mapView.loopFor(MapLibreConstants.ANIMATION_DURATION.toLong())
rule.runOnUiThread {
Assert.assertTrue(mapboxMap.cameraPosition.zoom < initialZoom!!)
Assert.assertTrue(maplibreMap.cameraPosition.zoom < initialZoom!!)
}
}
@@ -126,12 +126,12 @@ class MapGestureDetectorTest : BaseTest() {
validateTestSetup()
var initialZoom: Double? = null
rule.runOnUiThread {
initialZoom = mapboxMap.cameraPosition.zoom
initialZoom = maplibreMap.cameraPosition.zoom
}
onView(withId(R.id.mapView)).perform(quickScale(mapboxMap.gesturesManager.standardScaleGestureDetector.spanSinceStartThreshold / 2, withVelocity = false, duration = 50L))
R.id.mapView.loopFor(MapboxConstants.ANIMATION_DURATION.toLong())
onView(withId(R.id.mapView)).perform(quickScale(maplibreMap.gesturesManager.standardScaleGestureDetector.spanSinceStartThreshold / 2, withVelocity = false, duration = 50L))
R.id.mapView.loopFor(MapLibreConstants.ANIMATION_DURATION.toLong())
rule.runOnUiThread {
Assert.assertEquals(initialZoom!! + 1, mapboxMap.cameraPosition.zoom, 0.1)
Assert.assertEquals(initialZoom!! + 1, maplibreMap.cameraPosition.zoom, 0.1)
}
}
@@ -141,13 +141,13 @@ class MapGestureDetectorTest : BaseTest() {
validateTestSetup()
var initialZoom: Double? = null
rule.runOnUiThread {
initialZoom = mapboxMap.cameraPosition.zoom
mapboxMap.uiSettings.isQuickZoomGesturesEnabled = false
initialZoom = maplibreMap.cameraPosition.zoom
maplibreMap.uiSettings.isQuickZoomGesturesEnabled = false
}
onView(withId(R.id.mapView)).perform(quickScale(mapboxMap.gesturesManager.standardScaleGestureDetector.spanSinceStartThreshold * 2, withVelocity = false, duration = 50L))
R.id.mapView.loopFor(MapboxConstants.ANIMATION_DURATION.toLong())
onView(withId(R.id.mapView)).perform(quickScale(maplibreMap.gesturesManager.standardScaleGestureDetector.spanSinceStartThreshold * 2, withVelocity = false, duration = 50L))
R.id.mapView.loopFor(MapLibreConstants.ANIMATION_DURATION.toLong())
rule.runOnUiThread {
Assert.assertEquals(initialZoom!!, mapboxMap.cameraPosition.zoom, 0.01)
Assert.assertEquals(initialZoom!!, maplibreMap.cameraPosition.zoom, 0.01)
}
}
@@ -156,24 +156,24 @@ class MapGestureDetectorTest : BaseTest() {
validateTestSetup()
rule.runOnUiThread {
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(4.0))
maplibreMap.moveCamera(CameraUpdateFactory.zoomTo(4.0))
}
onView(withId(R.id.mapView)).perform(quickScale(mapboxMap.gesturesManager.standardScaleGestureDetector.spanSinceStartThreshold / 2, withVelocity = false, duration = 50L, interrupt = true))
onView(withId(R.id.mapView)).perform(quickScale(maplibreMap.gesturesManager.standardScaleGestureDetector.spanSinceStartThreshold / 2, withVelocity = false, duration = 50L, interrupt = true))
var initialCameraPosition: CameraPosition? = null
rule.runOnUiThread {
// zoom in so we can move vertically
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(4.0))
initialCameraPosition = mapboxMap.cameraPosition
mapboxMap.uiSettings.isQuickZoomGesturesEnabled = false
maplibreMap.moveCamera(CameraUpdateFactory.zoomTo(4.0))
initialCameraPosition = maplibreMap.cameraPosition
maplibreMap.uiSettings.isQuickZoomGesturesEnabled = false
}
// move to expected target
onView(withId(R.id.mapView)).perform(move(-maxWidth / 2f, -maxHeight / 2f, withVelocity = false))
rule.runOnUiThread {
Assert.assertNotEquals(initialCameraPosition!!.target!!.latitude, mapboxMap.cameraPosition.target!!.latitude, 1.0)
Assert.assertNotEquals(initialCameraPosition!!.target!!.longitude, mapboxMap.cameraPosition.target!!.longitude, 1.0)
Assert.assertNotEquals(initialCameraPosition!!.target!!.latitude, maplibreMap.cameraPosition.target!!.latitude, 1.0)
Assert.assertNotEquals(initialCameraPosition!!.target!!.longitude, maplibreMap.cameraPosition.target!!.longitude, 1.0)
}
}
@@ -181,13 +181,13 @@ class MapGestureDetectorTest : BaseTest() {
fun quickZoom_roundTripping() {
validateTestSetup()
rule.runOnUiThread {
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(51.0, 16.0), 3.0))
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(51.0, 16.0), 3.0))
}
onView(withId(R.id.mapView)).perform(quickScale(300f, withVelocity = false, duration = 750L))
onView(withId(R.id.mapView)).perform(quickScale(-300f, withVelocity = false, duration = 750L))
rule.runOnUiThread {
Assert.assertEquals(3.0, mapboxMap.cameraPosition.zoom, 0.0001)
Assert.assertEquals(3.0, maplibreMap.cameraPosition.zoom, 0.0001)
}
}
}

View File

@@ -0,0 +1,480 @@
package org.maplibre.android.maps;
import android.graphics.Color;
import android.view.View;
import androidx.test.espresso.UiController;
import androidx.test.espresso.ViewAction;
import org.maplibre.android.annotations.BaseMarkerOptions;
import org.maplibre.android.annotations.Marker;
import org.maplibre.android.annotations.MarkerOptions;
import org.maplibre.android.annotations.Polygon;
import org.maplibre.android.annotations.PolygonOptions;
import org.maplibre.android.annotations.Polyline;
import org.maplibre.android.annotations.PolylineOptions;
import org.maplibre.android.exceptions.InvalidMarkerPositionException;
import org.maplibre.android.geometry.LatLng;
import org.maplibre.android.testapp.R;
import org.maplibre.android.testapp.activity.EspressoTest;
import org.hamcrest.Matcher;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertNotNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* This test is responsible for testing the public API.
* <p>
* Methods executed on MapboxMap are called from a ViewAction to ensure correct synchronisation
* with the application UI-thread.
* </p>
* @deprecated remove this file when removing deprecated annotations
*/
@Deprecated
public class MapLibreMapTest extends EspressoTest {
//
// InfoWindow
//
@Test
public void testConcurrentInfoWindowEnabled() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
maplibreMap.setAllowConcurrentMultipleOpenInfoWindows(true);
assertTrue("ConcurrentWindows should be true", maplibreMap.isAllowConcurrentMultipleOpenInfoWindows());
}));
}
@Test
public void testConcurrentInfoWindowDisabled() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
maplibreMap.setAllowConcurrentMultipleOpenInfoWindows(false);
assertFalse("ConcurrentWindows should be false", maplibreMap.isAllowConcurrentMultipleOpenInfoWindows());
}));
}
@Test
public void testInfoWindowAdapter() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
MapLibreMap.InfoWindowAdapter infoWindowAdapter = marker -> null;
maplibreMap.setInfoWindowAdapter(infoWindowAdapter);
assertEquals("InfoWindowAdpter should be the same", infoWindowAdapter, maplibreMap.getInfoWindowAdapter());
}));
}
//
// Annotations
//
@Test
public void testAddMarker() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
Marker marker = maplibreMap.addMarker(markerOptions);
assertTrue("Marker should be contained", maplibreMap.getMarkers().contains(marker));
}));
}
@Test(expected = InvalidMarkerPositionException.class)
public void testAddMarkerInvalidPosition() {
new MarkerOptions().getMarker();
}
@Test
public void testAddMarkers() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
List<BaseMarkerOptions> markerList = new ArrayList<>();
MarkerOptions markerOptions1 = new MarkerOptions().position(new LatLng()).title("a");
MarkerOptions markerOptions2 = new MarkerOptions().position(new LatLng()).title("b");
markerList.add(markerOptions1);
markerList.add(markerOptions2);
List<Marker> markers = maplibreMap.addMarkers(markerList);
assertEquals("Markers size should be 2", 2, maplibreMap.getMarkers().size());
assertTrue(maplibreMap.getMarkers().contains(markers.get(0)));
assertTrue(maplibreMap.getMarkers().contains(markers.get(1)));
}));
}
@Test
public void testAddMarkersEmpty() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
List<BaseMarkerOptions> markerList = new ArrayList<>();
maplibreMap.addMarkers(markerList);
assertEquals("Markers size should be 0", 0, maplibreMap.getMarkers().size());
}));
}
@Test
public void testAddMarkersSingleMarker() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
List<BaseMarkerOptions> markerList = new ArrayList<>();
MarkerOptions markerOptions = new MarkerOptions().title("a").position(new LatLng());
markerList.add(markerOptions);
List<Marker> markers = maplibreMap.addMarkers(markerList);
assertEquals("Markers size should be 1", 1, maplibreMap.getMarkers().size());
assertTrue(maplibreMap.getMarkers().contains(markers.get(0)));
}));
}
@Test
public void testAddPolygon() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
PolygonOptions polygonOptions = new PolygonOptions().add(new LatLng());
Polygon polygon = maplibreMap.addPolygon(polygonOptions);
assertTrue("Polygon should be contained", maplibreMap.getPolygons().contains(polygon));
}));
}
@Test
public void testAddEmptyPolygon() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
PolygonOptions polygonOptions = new PolygonOptions();
Polygon polygon = maplibreMap.addPolygon(polygonOptions);
assertTrue("Polygon should be ignored", !maplibreMap.getPolygons().contains(polygon));
}));
}
@Test
public void testAddPolygons() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
List<PolygonOptions> polygonList = new ArrayList<>();
PolygonOptions polygonOptions1 = new PolygonOptions().fillColor(Color.BLACK).add(new LatLng());
PolygonOptions polygonOptions2 = new PolygonOptions().fillColor(Color.WHITE).add(new LatLng());
PolygonOptions polygonOptions3 = new PolygonOptions();
polygonList.add(polygonOptions1);
polygonList.add(polygonOptions2);
polygonList.add(polygonOptions3);
maplibreMap.addPolygons(polygonList);
assertEquals("Polygons size should be 2", 2, maplibreMap.getPolygons().size());
assertTrue(maplibreMap.getPolygons().contains(polygonOptions1.getPolygon()));
assertTrue(maplibreMap.getPolygons().contains(polygonOptions2.getPolygon()));
assertTrue("Polygon should be ignored", !maplibreMap.getPolygons().contains(polygonOptions3.getPolygon()));
}));
}
@Test
public void addPolygonsEmpty() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
maplibreMap.addPolygons(new ArrayList<PolygonOptions>());
assertEquals("Polygons size should be 0", 0, maplibreMap.getPolygons().size());
}));
}
@Test
public void addPolygonsSingle() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
List<PolygonOptions> polygonList = new ArrayList<>();
PolygonOptions polygonOptions = new PolygonOptions().fillColor(Color.BLACK).add(new LatLng());
polygonList.add(polygonOptions);
maplibreMap.addPolygons(polygonList);
assertEquals("Polygons size should be 1", 1, maplibreMap.getPolygons().size());
assertTrue(maplibreMap.getPolygons().contains(polygonOptions.getPolygon()));
}));
}
@Test
public void testAddPolyline() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
PolylineOptions polylineOptions = new PolylineOptions().add(new LatLng());
Polyline polyline = maplibreMap.addPolyline(polylineOptions);
assertTrue("Polyline should be contained", maplibreMap.getPolylines().contains(polyline));
}));
}
@Test
public void testAddEmptyPolyline() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
PolylineOptions polylineOptions = new PolylineOptions();
Polyline polyline = maplibreMap.addPolyline(polylineOptions);
assertTrue("Polyline should be ignored", !maplibreMap.getPolylines().contains(polyline));
}));
}
@Test
public void testAddPolylines() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
List<PolylineOptions> polylineList = new ArrayList<>();
PolylineOptions polygonOptions1 = new PolylineOptions().color(Color.BLACK).add(new LatLng());
PolylineOptions polygonOptions2 = new PolylineOptions().color(Color.WHITE).add(new LatLng());
PolylineOptions polygonOptions3 = new PolylineOptions();
polylineList.add(polygonOptions1);
polylineList.add(polygonOptions2);
polylineList.add(polygonOptions3);
maplibreMap.addPolylines(polylineList);
assertEquals("Polygons size should be 2", 2, maplibreMap.getPolylines().size());
assertTrue(maplibreMap.getPolylines().contains(polygonOptions1.getPolyline()));
assertTrue(maplibreMap.getPolylines().contains(polygonOptions2.getPolyline()));
assertTrue(
"Polyline should be ignored", !maplibreMap.getPolylines().contains(polygonOptions3.getPolyline())
);
}));
}
@Test
public void testAddPolylinesEmpty() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
maplibreMap.addPolylines(new ArrayList<PolylineOptions>());
assertEquals("Polygons size should be 0", 0, maplibreMap.getPolylines().size());
}));
}
@Test
public void testAddPolylinesSingle() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
List<PolylineOptions> polylineList = new ArrayList<>();
PolylineOptions polygonOptions = new PolylineOptions().color(Color.BLACK).add(new LatLng());
polylineList.add(polygonOptions);
maplibreMap.addPolylines(polylineList);
assertEquals("Polygons size should be 1", 1, maplibreMap.getPolylines().size());
assertTrue(maplibreMap.getPolylines().contains(polygonOptions.getPolyline()));
}));
}
@Test
public void testRemoveMarker() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
Marker marker = maplibreMap.addMarker(markerOptions);
maplibreMap.removeMarker(marker);
assertTrue("Markers should be empty", maplibreMap.getMarkers().isEmpty());
}));
}
@Test
public void testRemovePolygon() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
PolygonOptions polygonOptions = new PolygonOptions();
Polygon polygon = maplibreMap.addPolygon(polygonOptions);
maplibreMap.removePolygon(polygon);
assertTrue("Polygons should be empty", maplibreMap.getPolylines().isEmpty());
}));
}
@Test
public void testRemovePolyline() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
PolylineOptions polylineOptions = new PolylineOptions();
Polyline polyline = maplibreMap.addPolyline(polylineOptions);
maplibreMap.removePolyline(polyline);
assertTrue("Polylines should be empty", maplibreMap.getPolylines().isEmpty());
}));
}
@Test
public void testRemoveAnnotation() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
Marker marker = maplibreMap.addMarker(markerOptions);
maplibreMap.removeAnnotation(marker);
assertTrue("Annotations should be empty", maplibreMap.getAnnotations().isEmpty());
}));
}
@Test
public void testRemoveAnnotationById() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
maplibreMap.addMarker(markerOptions);
// id will always be 0 in unit tests
maplibreMap.removeAnnotation(0);
assertTrue("Annotations should be empty", maplibreMap.getAnnotations().isEmpty());
}));
}
@Test
public void testRemoveAnnotations() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
List<BaseMarkerOptions> markerList = new ArrayList<>();
MarkerOptions markerOptions1 = new MarkerOptions().title("a").position(new LatLng());
MarkerOptions markerOptions2 = new MarkerOptions().title("b").position(new LatLng());
markerList.add(markerOptions1);
markerList.add(markerOptions2);
maplibreMap.addMarkers(markerList);
maplibreMap.removeAnnotations();
assertTrue("Annotations should be empty", maplibreMap.getAnnotations().isEmpty());
}));
}
@Test
public void testClear() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
List<BaseMarkerOptions> markerList = new ArrayList<>();
MarkerOptions markerOptions1 = new MarkerOptions().title("a").position(new LatLng());
MarkerOptions markerOptions2 = new MarkerOptions().title("b").position(new LatLng());
markerList.add(markerOptions1);
markerList.add(markerOptions2);
maplibreMap.addMarkers(markerList);
maplibreMap.clear();
assertTrue("Annotations should be empty", maplibreMap.getAnnotations().isEmpty());
}));
}
@Test
public void testRemoveAnnotationsByList() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
List<BaseMarkerOptions> markerList = new ArrayList<>();
MarkerOptions markerOptions1 = new MarkerOptions().title("a").position(new LatLng());
MarkerOptions markerOptions2 = new MarkerOptions().title("b").position(new LatLng());
markerList.add(markerOptions1);
markerList.add(markerOptions2);
List<Marker> markers = maplibreMap.addMarkers(markerList);
Marker marker = maplibreMap.addMarker(new MarkerOptions().position(new LatLng()).title("c"));
maplibreMap.removeAnnotations(markers);
assertTrue("Annotations should not be empty", maplibreMap.getAnnotations().size() == 1);
assertTrue("Marker should be contained", maplibreMap.getAnnotations().contains(marker));
}));
}
@Test
public void testGetAnnotationById() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
Marker initialMarker = maplibreMap.addMarker(markerOptions);
Marker retrievedMarker = (Marker) maplibreMap.getAnnotation(0);
assertEquals("Markers should match", initialMarker, retrievedMarker);
}));
}
@Test
public void testGetAnnotations() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(
new MapLibreMapAction((uiController, view) ->
assertNotNull("Annotations should be non null", maplibreMap.getAnnotations()))
);
}
@Test
public void testGetMarkers() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(
new MapLibreMapAction((uiController, view) ->
assertNotNull("Markers should be non null", maplibreMap.getMarkers()))
);
}
@Test
public void testGetPolygons() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) ->
assertNotNull("Polygons should be non null", maplibreMap.getPolygons()))
);
}
@Test
public void testGetPolylines() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) ->
assertNotNull("Polylines should be non null", maplibreMap.getPolylines()))
);
}
@Test
public void testGetSelectedMarkers() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) ->
assertNotNull("Selected markers should be non null", maplibreMap.getSelectedMarkers()))
);
}
@Test
public void testSelectMarker() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
Marker marker = maplibreMap.addMarker(markerOptions);
maplibreMap.selectMarker(marker);
assertTrue("Marker should be contained", maplibreMap.getSelectedMarkers().contains(marker));
}));
}
@Test
public void testDeselectMarker() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
Marker marker = maplibreMap.addMarker(markerOptions);
maplibreMap.selectMarker(marker);
maplibreMap.deselectMarker(marker);
assertTrue("Selected markers should be empty", maplibreMap.getSelectedMarkers().isEmpty());
}));
}
@Test
public void testDeselectMarkers() {
validateTestSetup();
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
Marker marker1 = maplibreMap.addMarker(markerOptions);
Marker marker2 = maplibreMap.addMarker(markerOptions);
maplibreMap.selectMarker(marker1);
maplibreMap.selectMarker(marker2);
maplibreMap.deselectMarkers();
assertTrue("Selected markers should be empty", maplibreMap.getSelectedMarkers().isEmpty());
}));
}
public class MapLibreMapAction implements ViewAction {
private InvokeViewAction invokeViewAction;
MapLibreMapAction(InvokeViewAction invokeViewAction) {
this.invokeViewAction = invokeViewAction;
}
@Override
public Matcher<View> getConstraints() {
return isDisplayed();
}
@Override
public String getDescription() {
return getClass().getSimpleName();
}
@Override
public void perform(UiController uiController, View view) {
invokeViewAction.onViewAction(uiController, view);
}
}
interface InvokeViewAction {
void onViewAction(UiController uiController, View view);
}
}

View File

@@ -0,0 +1,68 @@
package org.maplibre.android.maps;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import androidx.test.annotation.UiThreadTest;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import org.maplibre.android.AppCenter;
import org.maplibre.android.MapLibre;
import org.maplibre.android.exceptions.MapLibreConfigurationException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4ClassRunner.class)
public class MapLibreTest extends AppCenter {
private static final String API_KEY = "pk.0000000001";
private static final String API_KEY_2 = "pk.0000000002";
private String realToken;
@Before
public void setup() {
realToken = MapLibre.getApiKey();
}
@Test
@UiThreadTest
public void testConnected() {
assertTrue(MapLibre.isConnected());
// test manual connectivity
MapLibre.setConnected(true);
assertTrue(MapLibre.isConnected());
MapLibre.setConnected(false);
assertFalse(MapLibre.isConnected());
// reset to Android connectivity
MapLibre.setConnected(null);
assertTrue(MapLibre.isConnected());
}
@Test
@UiThreadTest
public void setApiKey() {
MapLibre.setApiKey(API_KEY);
assertSame(API_KEY, MapLibre.getApiKey());
MapLibre.setApiKey(API_KEY_2);
assertSame(API_KEY_2, MapLibre.getApiKey());
}
@Test
@UiThreadTest
public void setNullApiKey() {
assertThrows(MapLibreConfigurationException.class, () -> MapLibre.setApiKey(null));
}
@After
public void tearDown() {
MapLibre.setApiKey(realToken);
}
}

View File

@@ -1,20 +1,20 @@
package com.mapbox.mapboxsdk.maps
package org.maplibre.android.maps
import android.content.Context
import android.graphics.PointF
import androidx.test.annotation.UiThreadTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.platform.app.InstrumentationRegistry
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.Mapbox
import com.mapbox.mapboxsdk.WellKnownTileServer
import com.mapbox.mapboxsdk.camera.CameraPosition
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.geometry.LatLngBounds
import com.mapbox.mapboxsdk.geometry.ProjectedMeters
import com.mapbox.mapboxsdk.maps.renderer.MapRenderer
import com.mapbox.mapboxsdk.style.layers.TransitionOptions
import com.mapbox.mapboxsdk.testapp.utils.TestConstants
import org.maplibre.android.AppCenter
import org.maplibre.android.MapLibre
import org.maplibre.android.WellKnownTileServer
import org.maplibre.android.camera.CameraPosition
import org.maplibre.android.geometry.LatLng
import org.maplibre.android.geometry.LatLngBounds
import org.maplibre.android.geometry.ProjectedMeters
import org.maplibre.android.maps.renderer.MapRenderer
import org.maplibre.android.style.layers.TransitionOptions
import org.maplibre.android.testapp.utils.TestConstants
import org.junit.After
import org.junit.Assert
import org.junit.Assert.*
@@ -43,8 +43,8 @@ class NativeMapViewTest : AppCenter() {
@UiThreadTest
fun before() {
val context = InstrumentationRegistry.getInstrumentation().context
val apiKey = Mapbox.getApiKey()
Mapbox.getInstance(context, apiKey, WellKnownTileServer.MapTiler)
val apiKey = MapLibre.getApiKey()
MapLibre.getInstance(context, apiKey, WellKnownTileServer.MapTiler)
nativeMapView = NativeMapView(context, 2.0f, false, null, null, DummyRenderer(context))
nativeMapView.resizeView(WIDTH, HEIGHT)
}
@@ -53,8 +53,8 @@ class NativeMapViewTest : AppCenter() {
@UiThreadTest
fun after() {
val context = InstrumentationRegistry.getInstrumentation().context
val apiKey = Mapbox.getApiKey()
Mapbox.getInstance(context)
val apiKey = MapLibre.getApiKey()
MapLibre.getInstance(context)
nativeMapView.destroy()
}
@@ -104,7 +104,7 @@ class NativeMapViewTest : AppCenter() {
val actual = nativeMapView.latLng
assertEquals("Latitude should match", expected.latitude, actual.latitude, DELTA)
assertEquals("Longitude should match", expected.longitude, actual.longitude, DELTA)
Assert.assertArrayEquals(PADDING_TEST, nativeMapView.cameraPosition.padding, DELTA)
assertArrayEquals(PADDING_TEST, nativeMapView.cameraPosition.padding, DELTA)
}
@Test
@@ -177,7 +177,7 @@ class NativeMapViewTest : AppCenter() {
assertEquals("Bearing should match", expected.bearing, actual.bearing, DELTA)
assertEquals("Pitch should match", expected.tilt, actual.tilt, DELTA)
assertEquals("Zoom should match", expected.zoom, actual.zoom, DELTA)
Assert.assertArrayEquals(expected.padding, actual.padding, DELTA)
assertArrayEquals(expected.padding, actual.padding, DELTA)
}
@Test
@@ -251,10 +251,10 @@ class NativeMapViewTest : AppCenter() {
val expected = doubleArrayOf(1.0, 2.0, 3.0, 4.0)
nativeMapView.contentPadding = expected
val actual = nativeMapView.contentPadding
assertEquals("Left should match", expected[0], actual[0])
assertEquals("Top should match", expected[1], actual[1])
assertEquals("Right should match", expected[2], actual[2])
assertEquals("Bottom should match", expected[3], actual[3])
assertEquals("Left should match", expected[0], actual[0], 0.0)
assertEquals("Top should match", expected[1], actual[1], 0.0)
assertEquals("Right should match", expected[2], actual[2], 0.0)
assertEquals("Bottom should match", expected[3], actual[3], 0.0)
}
@Test
@@ -263,7 +263,7 @@ class NativeMapViewTest : AppCenter() {
val expected = 12.0
nativeMapView.minZoom = expected
val actual = nativeMapView.minZoom
assertEquals("Min zoom should match", expected, actual)
assertEquals("Min zoom should match", expected, actual, 0.0)
}
@Test
@@ -272,7 +272,7 @@ class NativeMapViewTest : AppCenter() {
val expected = 12.0
nativeMapView.maxZoom = expected
val actual = nativeMapView.maxZoom
assertEquals("Max zoom should match", expected, actual)
assertEquals("Max zoom should match", expected, actual, 0.0)
}
@Test
@@ -298,7 +298,7 @@ class NativeMapViewTest : AppCenter() {
fun testGetProjectedMetersAtLatitude() {
val expected = 77973.67021115532
val actual = nativeMapView.getMetersPerPixelAtLatitude(5.0)
assertEquals("Get projected meters should match", expected, actual)
assertEquals("Get projected meters should match", expected, actual, DELTA)
}
@Test
@@ -351,7 +351,7 @@ class NativeMapViewTest : AppCenter() {
assertEquals("Longitude should match", expected.target!!.longitude, actual.target!!.longitude, TestConstants.LAT_LNG_DELTA)
assertEquals("Tilt should match", expected.tilt, actual.tilt, TestConstants.TILT_DELTA)
assertEquals("Zoom should match", expected.zoom, actual.zoom, TestConstants.ZOOM_DELTA)
Assert.assertArrayEquals(expected.padding, actual.padding, DELTA)
assertArrayEquals(expected.padding, actual.padding, DELTA)
}
@Test
@@ -372,7 +372,7 @@ class NativeMapViewTest : AppCenter() {
assertEquals("Longitude should match", expected.target!!.longitude, actual.target!!.longitude, TestConstants.LAT_LNG_DELTA)
assertEquals("Tilt should match", expected.tilt, actual.tilt, TestConstants.TILT_DELTA)
assertEquals("Zoom should match", expected.zoom, actual.zoom, TestConstants.ZOOM_DELTA)
Assert.assertArrayEquals(expected.padding, actual.padding, DELTA)
assertArrayEquals(expected.padding, actual.padding, DELTA)
}
@Test

View File

@@ -0,0 +1,33 @@
package org.maplibre.android.maps
import androidx.test.espresso.UiController
import org.maplibre.android.camera.CameraUpdateFactory
import org.maplibre.android.geometry.LatLng
import org.maplibre.android.testapp.action.MapLibreMapAction.invoke
import org.maplibre.android.testapp.activity.EspressoTest
import org.junit.Assert.assertEquals
import org.junit.Test
class TransformTest : EspressoTest() {
companion object {
val initialCameraUpdate = CameraUpdateFactory.newLatLngZoom(LatLng(12.0, 12.0), 12.0)!!
}
@Test
fun mapboxMapScrollByWithPadding() {
validateTestSetup()
invoke(maplibreMap) { _: UiController, maplibreMap: MapLibreMap ->
maplibreMap.moveCamera(initialCameraUpdate)
maplibreMap.scrollBy(400.0f, 0.0f)
val expectedCameraPosition = maplibreMap.cameraPosition
maplibreMap.moveCamera(initialCameraUpdate)
maplibreMap.setPadding(250, 250, 0, 0)
maplibreMap.scrollBy(400.0f, 0.0f)
val actualCameraPosition = maplibreMap.cameraPosition
assertEquals("Camera position should match", expectedCameraPosition, actualCameraPosition)
}
}
}

View File

@@ -0,0 +1,520 @@
package org.maplibre.android.maps
import android.graphics.PointF
import androidx.test.espresso.UiController
import org.maplibre.android.camera.CameraUpdateFactory
import org.maplibre.android.geometry.LatLng
import org.maplibre.android.geometry.LatLngBounds
import org.maplibre.android.testapp.action.MapLibreMapAction.invoke
import org.maplibre.android.testapp.activity.BaseTest
import org.maplibre.android.testapp.activity.espresso.PixelTestActivity
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
class VisibleRegionTest : BaseTest() {
override fun getActivityClass(): Class<*> {
return PixelTestActivity::class.java
}
override
fun beforeTest() {
super.beforeTest()
mapView = (rule.activity as PixelTestActivity).mapView
}
@Test
fun visibleRegionTest() {
validateTestSetup()
invoke(maplibreMap) { _: UiController, maplibreMap: MapLibreMap ->
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 0.0), 8.0))
val latLngs = listOf(
maplibreMap.getLatLngFromScreenCoords(0f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
val visibleRegion = maplibreMap.projection.visibleRegion
assertTrue(latLngs.all { visibleRegion.latLngBounds.contains(it) })
}
}
@Test
fun paddedVisibleRegionTest() {
validateTestSetup()
invoke(maplibreMap) { _: UiController, maplibreMap: MapLibreMap ->
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 0.0), 8.0))
val latLngs = listOf(
maplibreMap.getLatLngFromScreenCoords(0f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
maplibreMap.setPadding(
mapView.width / 4,
mapView.height / 4,
mapView.width / 4,
mapView.height / 4
)
val visibleRegion = maplibreMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
assertTrue(filtered.size == 1)
assertTrue(filtered.contains(maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)))
}
}
@Test
fun paddedLeftVisibleRegionTest() {
validateTestSetup()
invoke(maplibreMap) { _: UiController, maplibreMap: MapLibreMap ->
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 0.0), 8.0))
val latLngs = listOf(
maplibreMap.getLatLngFromScreenCoords(0f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
maplibreMap.setPadding(mapView.width / 4, 0, 0, 0)
val visibleRegion = maplibreMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
assertTrue(filtered.size == 6)
assertFalse(filtered.contains(maplibreMap.getLatLngFromScreenCoords(0f, mapView.height / 2f)))
}
}
@Test
fun paddedTopVisibleRegionTest() {
validateTestSetup()
invoke(maplibreMap) { _: UiController, maplibreMap: MapLibreMap ->
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 0.0), 8.0))
val latLngs = listOf(
maplibreMap.getLatLngFromScreenCoords(0f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
maplibreMap.setPadding(0, mapView.height / 4, 0, 0)
val visibleRegion = maplibreMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
assertTrue(filtered.size == 6)
assertFalse(filtered.contains(maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f)))
}
}
@Test
fun paddedRightVisibleRegionTest() {
validateTestSetup()
invoke(maplibreMap) { _: UiController, maplibreMap: MapLibreMap ->
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 0.0), 8.0))
val latLngs = listOf(
maplibreMap.getLatLngFromScreenCoords(0f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
maplibreMap.setPadding(0, 0, mapView.width / 4, 0)
val visibleRegion = maplibreMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
assertTrue(filtered.size == 6)
assertFalse(filtered.contains(maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f)))
}
}
@Test
fun paddedBottomVisibleRegionTest() {
validateTestSetup()
invoke(maplibreMap) { _: UiController, maplibreMap: MapLibreMap ->
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 0.0), 8.0))
val latLngs = listOf(
maplibreMap.getLatLngFromScreenCoords(0f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
maplibreMap.setPadding(0, 0, 0, mapView.height / 4)
val visibleRegion = maplibreMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
assertTrue(filtered.size == 6)
assertFalse(filtered.contains(maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat())))
}
}
@Test
fun visibleRegionOverDatelineTest() {
validateTestSetup()
invoke(maplibreMap) { _: UiController, maplibreMap: MapLibreMap ->
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 180.0), 8.0))
val latLngs = listOf(
maplibreMap.getLatLngFromScreenCoords(0f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f)
.also { it.longitude += 360 },
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f)
.also { it.longitude += 360 },
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat())
.also { it.longitude += 360 },
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
val visibleRegion = maplibreMap.projection.visibleRegion
assertTrue(latLngs.all { visibleRegion.latLngBounds.contains(it) })
}
}
@Test
fun paddedVisibleRegionOverDatelineTest() {
validateTestSetup()
invoke(maplibreMap) { _: UiController, maplibreMap: MapLibreMap ->
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 180.0), 8.0))
val latLngs = listOf(
maplibreMap.getLatLngFromScreenCoords(0f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
maplibreMap.setPadding(
mapView.width / 4,
mapView.height / 4,
mapView.width / 4,
mapView.height / 4
)
val visibleRegion = maplibreMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
assertTrue(filtered.size == 1)
assertTrue(filtered.contains(maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)))
}
}
@Test
fun paddedLeftVisibleRegionOverDatelineTest() {
validateTestSetup()
invoke(maplibreMap) { _: UiController, maplibreMap: MapLibreMap ->
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 180.0), 8.0))
val latLngs = listOf(
maplibreMap.getLatLngFromScreenCoords(0f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f)
.also { it.longitude += 360 },
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f)
.also { it.longitude += 360 },
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat())
.also { it.longitude += 360 },
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
maplibreMap.setPadding(mapView.width / 4, 0, 0, 0)
val visibleRegion = maplibreMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
assertTrue(filtered.size == 6)
assertFalse(filtered.contains(maplibreMap.getLatLngFromScreenCoords(0f, mapView.height / 2f)))
}
}
@Test
fun paddedTopVisibleRegionOverDatelineTest() {
validateTestSetup()
invoke(maplibreMap) { ui: UiController, maplibreMap: MapLibreMap ->
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 180.0), 8.0))
ui.loopMainThreadForAtLeast(5000)
val latLngs = listOf(
maplibreMap.getLatLngFromScreenCoords(0f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f)
.also { it.longitude += 360 },
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f)
.also { it.longitude += 360 },
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat())
.also { it.longitude += 360 },
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
maplibreMap.setPadding(0, mapView.height / 4, 0, 0)
val visibleRegion = maplibreMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
assertTrue(filtered.size == 6)
assertFalse(filtered.contains(maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f)))
}
}
@Test
fun paddedRightVisibleRegionOverDatelineTest() {
validateTestSetup()
invoke(maplibreMap) { _: UiController, maplibreMap: MapLibreMap ->
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 180.0), 8.0))
val latLngs = listOf(
maplibreMap.getLatLngFromScreenCoords(0f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f)
.also { it.longitude += 360 },
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f)
.also { it.longitude += 360 },
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat())
.also { it.longitude += 360 },
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
maplibreMap.setPadding(0, 0, mapView.width / 4, 0)
val visibleRegion = maplibreMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
assertTrue(filtered.size == 6)
assertFalse(filtered.contains(maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f)))
}
}
@Test
fun paddedBottomVisibleRegionOverDatelineTest() {
validateTestSetup()
invoke(maplibreMap) { _: UiController, maplibreMap: MapLibreMap ->
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 180.0), 8.0))
val latLngs = listOf(
maplibreMap.getLatLngFromScreenCoords(0f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f)
.also { it.longitude += 360 },
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f)
.also { it.longitude += 360 },
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat())
.also { it.longitude += 360 },
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
maplibreMap.setPadding(0, 0, 0, mapView.height / 4)
val visibleRegion = maplibreMap.projection.getVisibleRegion(false)
val filtered = latLngs.filter { visibleRegion.latLngBounds.contains(it) }
assertTrue(filtered.size == 6)
assertFalse(filtered.contains(maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat())))
}
}
@Test
fun visibleRotatedRegionTest() {
validateTestSetup()
invoke(maplibreMap) { _: UiController, maplibreMap: MapLibreMap ->
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 0.0), 8.0))
val d = Math.min(maplibreMap.width, maplibreMap.height) / 4
val latLngs = listOf(
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f - d / 2f, mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f + d / 2f, mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f - d / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f + d / 2f)
)
for (bearing in 45 until 360 step 45) {
maplibreMap.moveCamera(CameraUpdateFactory.bearingTo(bearing.toDouble()))
val visibleRegion = maplibreMap.projection.visibleRegion
assertTrue(latLngs.all { visibleRegion.latLngBounds.contains(it) })
}
}
}
@Test
fun visibleRotatedRegionOverDatelineTest() {
validateTestSetup()
invoke(maplibreMap) { _: UiController, maplibreMap: MapLibreMap ->
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 180.0), 8.0))
val d = Math.min(maplibreMap.width, maplibreMap.height) / 4
val latLngs = listOf(
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f - d / 2f, mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f + d / 2f, mapView.height / 2f)
.also { it.longitude += 360 },
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f - d / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f + d / 2f)
)
for (bearing in 45 until 360 step 45) {
maplibreMap.moveCamera(CameraUpdateFactory.bearingTo(bearing.toDouble()))
val visibleRegion = maplibreMap.projection.visibleRegion
assertTrue(latLngs.all { visibleRegion.latLngBounds.contains(it) })
}
}
}
@Test
fun visibleRegionWithBoundsEqualTest() {
validateTestSetup()
invoke(maplibreMap) { _: UiController, maplibreMap: MapLibreMap ->
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 0.0), 8.0))
val latLngs = listOf(
maplibreMap.getLatLngFromScreenCoords(0f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
val bounds = doubleArrayOf(0.0, 0.0, 0.0, 0.0)
maplibreMap.projection.getVisibleCoordinateBounds(bounds)
val latLngBounds = LatLngBounds.from(bounds[0], bounds[1], bounds[2], bounds[3])
val visibleRegion = maplibreMap.projection.visibleRegion
assertTrue(latLngBounds == visibleRegion.latLngBounds)
assertTrue(latLngs.all { latLngBounds.contains(it) })
}
}
@Test
fun visibleRegionBoundsOverDatelineTest() {
validateTestSetup()
invoke(maplibreMap) { _: UiController, maplibreMap: MapLibreMap ->
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 180.0), 8.0))
val latLngs = listOf(
maplibreMap.getLatLngFromScreenCoords(0f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, 0f),
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), 0f)
.also { it.longitude += 360 },
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height / 2f)
.also { it.longitude += 360 },
maplibreMap.getLatLngFromScreenCoords(mapView.width.toFloat(), mapView.height.toFloat())
.also { it.longitude += 360 },
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height.toFloat()),
maplibreMap.getLatLngFromScreenCoords(0f, mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f)
)
val bounds = doubleArrayOf(0.0, 0.0, 0.0, 0.0)
maplibreMap.projection.getVisibleCoordinateBounds(bounds)
val latLngBounds = LatLngBounds.from(bounds[0], bounds[1], bounds[2], bounds[3])
assertTrue(latLngs.all { latLngBounds.contains(it) })
}
}
@Test
fun visibleRegionBoundsOverDatelineLatitudeZeroTest() {
validateTestSetup()
invoke(maplibreMap) { _: UiController, maplibreMap: MapLibreMap ->
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 180.0), 8.0))
val shift = maplibreMap.getLatLngFromScreenCoords(0f, 0f)
maplibreMap.moveCamera(CameraUpdateFactory.newLatLng(LatLng(0.0, 180.0 - shift.longitude)))
val bounds = doubleArrayOf(0.0, 0.0, 0.0, 0.0)
maplibreMap.projection.getVisibleCoordinateBounds(bounds)
val latLngBounds = LatLngBounds.from(bounds[0], bounds[1], bounds[2], bounds[3])
val visibleRegion = maplibreMap.projection.visibleRegion
assertTrue(latLngBounds == visibleRegion.latLngBounds)
}
}
@Test
fun visibleRotatedRegionBoundEqualTest() {
validateTestSetup()
invoke(maplibreMap) { _: UiController, maplibreMap: MapLibreMap ->
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 0.0), 8.0))
val d = Math.min(maplibreMap.width, maplibreMap.height) / 4
val latLngs = listOf(
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f - d / 2f, mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f + d / 2f, mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f - d / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f + d / 2f)
)
for (bearing in 45 until 360 step 45) {
maplibreMap.moveCamera(CameraUpdateFactory.bearingTo(bearing.toDouble()))
val bounds = doubleArrayOf(0.0, 0.0, 0.0, 0.0)
maplibreMap.projection.getVisibleCoordinateBounds(bounds)
val latLngBounds = LatLngBounds.from(bounds[0], bounds[1], bounds[2], bounds[3])
val visibleRegion = maplibreMap.projection.visibleRegion
assertTrue(latLngBounds == visibleRegion.latLngBounds)
assertTrue(latLngs.all { latLngBounds.contains(it) })
}
}
}
@Test
fun visibleRotatedRegionBoundsOverDatelineTest() {
validateTestSetup()
invoke(maplibreMap) { _: UiController, maplibreMap: MapLibreMap ->
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 179.0), 8.0))
val d = Math.min(maplibreMap.width, maplibreMap.height) / 4
val latLngs = listOf(
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f - d / 2f, mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f + d / 2f, mapView.height / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f - d / 2f),
maplibreMap.getLatLngFromScreenCoords(mapView.width / 2f, mapView.height / 2f + d / 2f)
)
for (bearing in 45 until 360 step 45) {
maplibreMap.moveCamera(CameraUpdateFactory.bearingTo(bearing.toDouble()))
val bounds = doubleArrayOf(0.0, 0.0, 0.0, 0.0)
maplibreMap.projection.getVisibleCoordinateBounds(bounds)
val latLngBounds = LatLngBounds.from(bounds[0], bounds[1], bounds[2], bounds[3])
assertTrue(latLngs.all { latLngBounds.contains(it) })
}
}
}
private fun MapLibreMap.getLatLngFromScreenCoords(x: Float, y: Float): LatLng {
return this.projection.fromScreenLocation(PointF(x, y))
}
}

View File

@@ -1,11 +1,11 @@
package com.mapbox.mapboxsdk.offline
package org.maplibre.android.offline
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.geojson.Point
import com.mapbox.mapboxsdk.log.Logger
import com.mapbox.mapboxsdk.maps.Style
import com.mapbox.mapboxsdk.testapp.activity.FeatureOverviewActivity
import org.maplibre.android.log.Logger
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.activity.FeatureOverviewActivity
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

View File

@@ -1,13 +1,13 @@
package com.mapbox.mapboxsdk.snapshotter
package org.maplibre.android.snapshotter
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.camera.CameraPosition
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.maps.Style
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer
import com.mapbox.mapboxsdk.style.layers.PropertyFactory
import com.mapbox.mapboxsdk.testapp.activity.FeatureOverviewActivity
import org.maplibre.android.camera.CameraPosition
import org.maplibre.android.geometry.LatLng
import org.maplibre.android.maps.Style
import org.maplibre.android.style.layers.BackgroundLayer
import org.maplibre.android.style.layers.PropertyFactory
import org.maplibre.android.testapp.activity.FeatureOverviewActivity
import org.junit.Assert
import org.junit.Assert.assertNotNull
import org.junit.Rule

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.style.sources
package org.maplibre.android.style.sources
import androidx.test.annotation.UiThreadTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.testapp.action;
package org.maplibre.android.testapp.action;
import android.view.View;
@@ -6,7 +6,7 @@ import androidx.annotation.NonNull;
import androidx.test.espresso.UiController;
import androidx.test.espresso.ViewAction;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import org.maplibre.android.maps.MapLibreMap;
import org.hamcrest.Matcher;
@@ -14,14 +14,14 @@ import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
public class MapboxMapAction implements ViewAction {
public class MapLibreMapAction implements ViewAction {
private OnInvokeActionListener invokeViewAction;
private MapboxMap mapboxMap;
private MapLibreMap maplibreMap;
public MapboxMapAction(OnInvokeActionListener invokeViewAction, MapboxMap mapboxMap) {
public MapLibreMapAction(OnInvokeActionListener invokeViewAction, MapLibreMap maplibreMap) {
this.invokeViewAction = invokeViewAction;
this.mapboxMap = mapboxMap;
this.maplibreMap = maplibreMap;
}
@Override
@@ -36,15 +36,15 @@ public class MapboxMapAction implements ViewAction {
@Override
public void perform(UiController uiController, View view) {
invokeViewAction.onInvokeAction(uiController, mapboxMap);
invokeViewAction.onInvokeAction(uiController, maplibreMap);
}
public static void invoke(MapboxMap mapboxMap, OnInvokeActionListener invokeViewAction) {
onView(withId(android.R.id.content)).perform(new MapboxMapAction(invokeViewAction, mapboxMap));
public static void invoke(MapLibreMap maplibreMap, OnInvokeActionListener invokeViewAction) {
onView(withId(android.R.id.content)).perform(new MapLibreMapAction(invokeViewAction, maplibreMap));
}
public interface OnInvokeActionListener {
void onInvokeAction(@NonNull UiController uiController, @NonNull MapboxMap mapboxMap);
void onInvokeAction(@NonNull UiController uiController, @NonNull MapLibreMap maplibreMap);
}
}

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.testapp.action;
package org.maplibre.android.testapp.action;
import android.app.Activity;
import android.content.Context;

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.testapp.activity;
package org.maplibre.android.testapp.activity;
import android.content.Context;
@@ -7,11 +7,11 @@ import androidx.annotation.UiThread;
import androidx.test.rule.ActivityTestRule;
import androidx.test.rule.GrantPermissionRule;
import com.mapbox.mapboxsdk.AppCenter;
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.testapp.R;
import org.maplibre.android.AppCenter;
import org.maplibre.android.MapLibre;
import org.maplibre.android.maps.MapView;
import org.maplibre.android.maps.MapLibreMap;
import org.maplibre.android.testapp.R;
import org.junit.After;
import org.junit.Before;
@@ -43,7 +43,7 @@ public abstract class BaseTest extends AppCenter {
public GrantPermissionRule grantLocationPermissionRule = GrantPermissionRule
.grant(android.Manifest.permission.ACCESS_FINE_LOCATION);
protected MapboxMap mapboxMap;
protected MapLibreMap maplibreMap;
protected MapView mapView;
private final CountDownLatch latch = new CountDownLatch(1);
@@ -62,19 +62,19 @@ public abstract class BaseTest extends AppCenter {
@UiThread
@CallSuper
protected void initMap(MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
mapboxMap.getStyle(style -> latch.countDown());
protected void initMap(MapLibreMap maplibreMap) {
this.maplibreMap = maplibreMap;
maplibreMap.getStyle(style -> latch.countDown());
}
protected void validateTestSetup() {
if (!Mapbox.isConnected()) {
if (!MapLibre.isConnected()) {
Timber.e("Not connected to the internet while running test");
}
assertNotNull("MapView isn't initialised", mapView);
assertNotNull("MapboxMap isn't initialised", mapboxMap);
assertNotNull("Style isn't initialised", mapboxMap.getStyle());
assertTrue("Style isn't fully loaded", mapboxMap.getStyle().isFullyLoaded());
assertNotNull("MapLibreMap isn't initialised", maplibreMap);
assertNotNull("Style isn't initialised", maplibreMap.getStyle());
assertTrue("Style isn't fully loaded", maplibreMap.getStyle().isFullyLoaded());
}
protected abstract Class getActivityClass();

View File

@@ -0,0 +1,25 @@
package org.maplibre.android.testapp.activity
import androidx.annotation.UiThread
import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.activity.espresso.EspressoTestActivity
/**
* Base class for all tests using EspressoTestActivity as wrapper.
*
*
* Loads "assets/streets.json" as style.
*
*/
open class EspressoTest : BaseTest() {
override fun getActivityClass(): Class<*> {
return EspressoTestActivity::class.java
}
@UiThread
override fun initMap(maplibreMap: MapLibreMap) {
maplibreMap.setStyle(Style.Builder().fromUri("asset://streets.json"))
super.initMap(maplibreMap)
}
}

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.testapp.annotations;
package org.maplibre.android.testapp.annotations;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -10,15 +10,15 @@ import android.app.Activity;
import androidx.core.content.res.ResourcesCompat;
import androidx.test.annotation.UiThreadTest;
import com.mapbox.mapboxsdk.annotations.Icon;
import com.mapbox.mapboxsdk.annotations.IconFactory;
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.IconManagerResolver;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest;
import com.mapbox.mapboxsdk.testapp.utils.IconUtils;
import org.maplibre.android.annotations.Icon;
import org.maplibre.android.annotations.IconFactory;
import org.maplibre.android.annotations.Marker;
import org.maplibre.android.annotations.MarkerOptions;
import org.maplibre.android.geometry.LatLng;
import org.maplibre.android.maps.IconManagerResolver;
import org.maplibre.android.testapp.R;
import org.maplibre.android.testapp.activity.EspressoTest;
import org.maplibre.android.testapp.utils.IconUtils;
import org.junit.Before;
import org.junit.Test;
@@ -35,7 +35,7 @@ public class IconTest extends EspressoTest {
@Before
public void beforeTest() {
super.beforeTest();
iconMap = new IconManagerResolver(mapboxMap).getIconMap();
iconMap = new IconManagerResolver(maplibreMap).getIconMap();
}
@Test
@@ -43,8 +43,8 @@ public class IconTest extends EspressoTest {
public void testAddSameIconMarker() {
validateTestSetup();
Icon defaultMarker = IconFactory.getInstance(rule.getActivity()).defaultMarker();
mapboxMap.addMarker(new MarkerOptions().position(new LatLng()));
mapboxMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
maplibreMap.addMarker(new MarkerOptions().position(new LatLng()));
maplibreMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
assertEquals(1, iconMap.size());
assertEquals(2, iconMap.get(defaultMarker), 0);
}
@@ -54,8 +54,8 @@ public class IconTest extends EspressoTest {
public void testAddDifferentIconMarker() {
validateTestSetup();
Icon icon = IconFactory.getInstance(rule.getActivity()).fromResource(R.drawable.maplibre_logo_icon);
mapboxMap.addMarker(new MarkerOptions().icon(icon).position(new LatLng()));
mapboxMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
maplibreMap.addMarker(new MarkerOptions().icon(icon).position(new LatLng()));
maplibreMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
assertEquals(iconMap.size(), 2);
assertTrue(iconMap.containsKey(icon));
assertTrue(iconMap.get(icon) == 1);
@@ -66,13 +66,13 @@ public class IconTest extends EspressoTest {
public void testAddRemoveIconMarker() {
validateTestSetup();
Icon icon = IconFactory.getInstance(rule.getActivity()).fromResource(R.drawable.maplibre_logo_icon);
Marker marker = mapboxMap.addMarker(new MarkerOptions().icon(icon).position(new LatLng()));
mapboxMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
Marker marker = maplibreMap.addMarker(new MarkerOptions().icon(icon).position(new LatLng()));
maplibreMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
assertEquals(iconMap.size(), 2);
assertTrue(iconMap.containsKey(icon));
assertTrue(iconMap.get(icon) == 1);
mapboxMap.removeMarker(marker);
maplibreMap.removeMarker(marker);
assertEquals(iconMap.size(), 1);
assertFalse(iconMap.containsKey(icon));
}
@@ -81,13 +81,13 @@ public class IconTest extends EspressoTest {
@UiThreadTest
public void testAddRemoveDefaultMarker() {
validateTestSetup();
Marker marker = mapboxMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
Marker marker = maplibreMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
assertEquals(iconMap.size(), 1);
mapboxMap.removeMarker(marker);
maplibreMap.removeMarker(marker);
assertEquals(iconMap.size(), 0);
mapboxMap.addMarker(new MarkerOptions().position(new LatLng()));
maplibreMap.addMarker(new MarkerOptions().position(new LatLng()));
assertEquals(iconMap.size(), 1);
}
@@ -99,25 +99,25 @@ public class IconTest extends EspressoTest {
IconFactory iconFactory = IconFactory.getInstance(activity);
// add 2 default icon markers
Marker defaultMarkerOne = mapboxMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
Marker defaultMarkerTwo = mapboxMap.addMarker(new MarkerOptions().position(new LatLng(2, 1)));
Marker defaultMarkerOne = maplibreMap.addMarker(new MarkerOptions().position(new LatLng(1, 1)));
Marker defaultMarkerTwo = maplibreMap.addMarker(new MarkerOptions().position(new LatLng(2, 1)));
// add 4 unique icon markers
mapboxMap.addMarker(new MarkerOptions()
maplibreMap.addMarker(new MarkerOptions()
.icon(iconFactory.fromResource(R.drawable.maplibre_logo_icon))
.position(new LatLng(3, 1))
);
mapboxMap.addMarker(new MarkerOptions()
maplibreMap.addMarker(new MarkerOptions()
.icon(iconFactory.fromResource(R.drawable.maplibre_compass_icon))
.position(new LatLng(4, 1))
);
mapboxMap.addMarker(new MarkerOptions()
maplibreMap.addMarker(new MarkerOptions()
.icon(IconUtils.drawableToIcon(activity, R.drawable.ic_stars,
ResourcesCompat.getColor(activity.getResources(),
R.color.blueAccent, activity.getTheme())))
.position(new LatLng(5, 1))
);
mapboxMap.addMarker(new MarkerOptions()
maplibreMap.addMarker(new MarkerOptions()
.icon(iconFactory.fromResource(R.drawable.ic_android))
.position(new LatLng(6, 1))
);
@@ -125,17 +125,17 @@ public class IconTest extends EspressoTest {
assertEquals("Amount of icons should match 5", 5, iconMap.size());
assertEquals("Refcounter of default marker should match 2", 2, iconMap.get(iconFactory.defaultMarker()), 0);
mapboxMap.removeMarker(defaultMarkerOne);
maplibreMap.removeMarker(defaultMarkerOne);
assertEquals("Amount of icons should match 5", 5, iconMap.size());
assertEquals("Refcounter of default marker should match 1", 1, iconMap.get(iconFactory.defaultMarker()), 0);
mapboxMap.removeMarker(defaultMarkerTwo);
maplibreMap.removeMarker(defaultMarkerTwo);
assertEquals("Amount of icons should match 4", 4, iconMap.size());
assertNull("DefaultMarker shouldn't exist anymore", iconMap.get(iconFactory.defaultMarker()));
mapboxMap.clear();
maplibreMap.clear();
assertEquals("Amount of icons should match 0", 0, iconMap.size());
}
}

View File

@@ -1,11 +1,11 @@
package com.mapbox.mapboxsdk.testapp.annotations;
package org.maplibre.android.testapp.annotations;
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest;
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
import org.maplibre.android.annotations.Marker;
import org.maplibre.android.annotations.MarkerOptions;
import org.maplibre.android.geometry.LatLng;
import org.maplibre.android.testapp.action.MapLibreMapAction;
import org.maplibre.android.testapp.activity.EspressoTest;
import org.maplibre.android.testapp.utils.TestConstants;
import org.junit.Ignore;
import org.junit.Test;
@@ -14,7 +14,7 @@ import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
import static org.maplibre.android.testapp.action.MapLibreMapAction.invoke;
import static org.junit.Assert.assertEquals;
public class MarkerTest extends EspressoTest {
@@ -25,7 +25,7 @@ public class MarkerTest extends EspressoTest {
@Ignore
public void addMarkerTest() {
validateTestSetup();
MapboxMapAction.invoke(mapboxMap, (uiController, mapboxMap) -> {
MapLibreMapAction.invoke(maplibreMap, (uiController, mapboxMap) -> {
assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size());
MarkerOptions options = new MarkerOptions();
@@ -48,7 +48,7 @@ public class MarkerTest extends EspressoTest {
@Ignore
public void showInfoWindowTest() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
final MarkerOptions options = new MarkerOptions();
options.setPosition(new LatLng());
options.setSnippet(TestConstants.TEXT_MARKER_SNIPPET);

View File

@@ -1,16 +1,16 @@
package com.mapbox.mapboxsdk.testapp.annotations;
package org.maplibre.android.testapp.annotations;
import android.graphics.Color;
import com.mapbox.mapboxsdk.annotations.Polygon;
import com.mapbox.mapboxsdk.annotations.PolygonOptions;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest;
import org.maplibre.android.annotations.Polygon;
import org.maplibre.android.annotations.PolygonOptions;
import org.maplibre.android.geometry.LatLng;
import org.maplibre.android.testapp.activity.EspressoTest;
import org.junit.Ignore;
import org.junit.Test;
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
import static org.maplibre.android.testapp.action.MapLibreMapAction.invoke;
import static org.junit.Assert.assertEquals;
public class PolygonTest extends EspressoTest {
@@ -19,7 +19,7 @@ public class PolygonTest extends EspressoTest {
@Ignore
public void addPolygonTest() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
LatLng latLngOne = new LatLng();
LatLng latLngTwo = new LatLng(1, 0);
LatLng latLngThree = new LatLng(1, 1);

View File

@@ -1,16 +1,16 @@
package com.mapbox.mapboxsdk.testapp.annotations;
package org.maplibre.android.testapp.annotations;
import android.graphics.Color;
import com.mapbox.mapboxsdk.annotations.Polyline;
import com.mapbox.mapboxsdk.annotations.PolylineOptions;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest;
import org.maplibre.android.annotations.Polyline;
import org.maplibre.android.annotations.PolylineOptions;
import org.maplibre.android.geometry.LatLng;
import org.maplibre.android.testapp.activity.EspressoTest;
import org.junit.Ignore;
import org.junit.Test;
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
import static org.maplibre.android.testapp.action.MapLibreMapAction.invoke;
import static org.junit.Assert.assertEquals;
public class PolylineTest extends EspressoTest {
@@ -19,7 +19,7 @@ public class PolylineTest extends EspressoTest {
@Ignore
public void addPolylineTest() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
LatLng latLngOne = new LatLng();
LatLng latLngTwo = new LatLng(1, 0);

View File

@@ -0,0 +1,11 @@
package org.maplibre.android.testapp.camera;
import org.maplibre.android.camera.CameraUpdate;
import org.maplibre.android.maps.MapLibreMap;
public class CameraAnimateTest extends CameraTest {
@Override
void executeCameraMovement(CameraUpdate cameraUpdate, MapLibreMap.CancelableCallback callback) {
maplibreMap.animateCamera(cameraUpdate, callback);
}
}

View File

@@ -0,0 +1,12 @@
package org.maplibre.android.testapp.camera;
import org.maplibre.android.camera.CameraUpdate;
import org.maplibre.android.maps.MapLibreMap;
public class CameraEaseTest extends CameraTest {
@Override
void executeCameraMovement(CameraUpdate cameraUpdate, MapLibreMap.CancelableCallback callback) {
maplibreMap.easeCamera(cameraUpdate, callback);
}
}

View File

@@ -1,15 +1,15 @@
package com.mapbox.mapboxsdk.testapp.camera;
package org.maplibre.android.testapp.camera;
import androidx.annotation.NonNull;
import androidx.test.annotation.UiThreadTest;
import com.mapbox.geojson.Point;
import com.mapbox.geojson.Polygon;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.testapp.activity.BaseTest;
import com.mapbox.mapboxsdk.testapp.activity.espresso.DeviceIndependentTestActivity;
import org.maplibre.android.camera.CameraPosition;
import org.maplibre.android.geometry.LatLng;
import org.maplibre.android.geometry.LatLngBounds;
import org.maplibre.android.testapp.activity.BaseTest;
import org.maplibre.android.testapp.activity.espresso.DeviceIndependentTestActivity;
import org.junit.Test;
@@ -24,7 +24,7 @@ public class CameraForTest extends BaseTest {
@UiThreadTest
public void testGetCameraForLatLngBounds() {
validateTestSetup();
CameraPosition actualPosition = mapboxMap.getCameraForLatLngBounds(
CameraPosition actualPosition = maplibreMap.getCameraForLatLngBounds(
LatLngBounds.from(10, 10, -10, -10));
CameraPosition expectedPosition = new CameraPosition.Builder()
.target(new LatLng()).zoom(4.16).tilt(0).bearing(0).build();
@@ -41,7 +41,7 @@ public class CameraForTest extends BaseTest {
@UiThreadTest
public void testGetCameraForLatLngBoundsPadding() {
validateTestSetup();
CameraPosition actualPosition = mapboxMap.getCameraForLatLngBounds(
CameraPosition actualPosition = maplibreMap.getCameraForLatLngBounds(
LatLngBounds.from(10, 10, -10, -10), new int[] {5, 5, 5, 5});
CameraPosition expectedPosition = new CameraPosition.Builder()
.target(new LatLng()).zoom(4.13).tilt(0).bearing(0).build();
@@ -61,7 +61,7 @@ public class CameraForTest extends BaseTest {
@UiThreadTest
public void testGetCameraForLatLngBoundsBearing() {
validateTestSetup();
CameraPosition actualPosition = mapboxMap.getCameraForLatLngBounds(
CameraPosition actualPosition = maplibreMap.getCameraForLatLngBounds(
LatLngBounds.from(10, 10, -10, -10), 45, 0);
CameraPosition expectedPosition = new CameraPosition.Builder()
.target(new LatLng()).zoom(3.66).tilt(0).bearing(45).build();
@@ -81,7 +81,7 @@ public class CameraForTest extends BaseTest {
@UiThreadTest
public void testGetCameraForLatLngBoundsTilt() {
validateTestSetup();
CameraPosition actualPosition = mapboxMap.getCameraForLatLngBounds(
CameraPosition actualPosition = maplibreMap.getCameraForLatLngBounds(
LatLngBounds.from(10, 10, -10, -10), 0, 45);
CameraPosition expectedPosition = new CameraPosition.Builder()
.target(new LatLng(-0.264576975267, 0)).zoom(4.13).tilt(45).bearing(0).build();
@@ -101,7 +101,7 @@ public class CameraForTest extends BaseTest {
@UiThreadTest
public void testGetCameraForLatLngBoundsAll() {
validateTestSetup();
CameraPosition actualPosition = mapboxMap.getCameraForLatLngBounds(
CameraPosition actualPosition = maplibreMap.getCameraForLatLngBounds(
LatLngBounds.from(10, 10, -10, -10), new int[] {5, 5, 5, 5}, 45, 45);
CameraPosition expectedPosition = new CameraPosition.Builder()
.target(new LatLng(-0.3732134634, -0.3713191053)).zoom(3.63).tilt(45).bearing(45).build();
@@ -122,7 +122,7 @@ public class CameraForTest extends BaseTest {
public void testGetCameraForGeometry() {
validateTestSetup();
List<List<Point>> polygonDefinition = getPolygonDefinition();
CameraPosition actualPosition = mapboxMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition));
CameraPosition actualPosition = maplibreMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition));
CameraPosition expectedPosition = new CameraPosition.Builder()
.target(new LatLng()).zoom(4.16).tilt(0).bearing(0).build();
assertEquals("Latitude should match",
@@ -155,7 +155,7 @@ public class CameraForTest extends BaseTest {
public void testGetCameraForGeometryPadding() {
validateTestSetup();
List<List<Point>> polygonDefinition = getPolygonDefinition();
CameraPosition actualPosition = mapboxMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition),
CameraPosition actualPosition = maplibreMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition),
new int[] {5, 5, 5, 5});
CameraPosition expectedPosition = new CameraPosition.Builder()
.target(new LatLng()).zoom(4.13).tilt(0).bearing(0).build();
@@ -176,7 +176,7 @@ public class CameraForTest extends BaseTest {
public void testGetCameraForGeometryBearing() {
validateTestSetup();
List<List<Point>> polygonDefinition = getPolygonDefinition();
CameraPosition actualPosition = mapboxMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition), 45, 0);
CameraPosition actualPosition = maplibreMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition), 45, 0);
CameraPosition expectedPosition = new CameraPosition.Builder()
.target(new LatLng()).zoom(3.66).tilt(0).bearing(45).build();
assertEquals("Latitude should match",
@@ -196,7 +196,7 @@ public class CameraForTest extends BaseTest {
public void testGetCameraForGeometryTilt() {
validateTestSetup();
List<List<Point>> polygonDefinition = getPolygonDefinition();
CameraPosition actualPosition = mapboxMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition), 0, 45);
CameraPosition actualPosition = maplibreMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition), 0, 45);
CameraPosition expectedPosition = new CameraPosition.Builder()
.target(new LatLng(-0.2645769752, 0)).zoom(4.13).tilt(45).bearing(0).build();
assertEquals("Latitude should match",
@@ -216,7 +216,7 @@ public class CameraForTest extends BaseTest {
public void testGetCameraForGeometryAll() {
validateTestSetup();
List<List<Point>> polygonDefinition = getPolygonDefinition();
CameraPosition actualPosition = mapboxMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition),
CameraPosition actualPosition = maplibreMap.getCameraForGeometry(Polygon.fromLngLats(polygonDefinition),
new int[] {5, 5, 5, 5}, 45, 45);
CameraPosition expectedPosition = new CameraPosition.Builder()
.target(new LatLng(-0.373213463, -0.37131910534)).zoom(3.63).tilt(45).bearing(45).build();
@@ -237,7 +237,7 @@ public class CameraForTest extends BaseTest {
public void testGetCameraForGeometryDeprecatedApi() {
validateTestSetup();
List<List<Point>> polygonDefinition = getPolygonDefinition();
CameraPosition actualPosition = mapboxMap.getCameraForGeometry(
CameraPosition actualPosition = maplibreMap.getCameraForGeometry(
Polygon.fromLngLats(polygonDefinition),
new int[] {5, 5, 5, 5},
45, 0);

View File

@@ -0,0 +1,12 @@
package org.maplibre.android.testapp.camera;
import org.maplibre.android.camera.CameraUpdate;
import org.maplibre.android.maps.MapLibreMap;
public class CameraMoveTest extends CameraTest {
@Override
void executeCameraMovement(CameraUpdate cameraUpdate, MapLibreMap.CancelableCallback callback) {
maplibreMap.moveCamera(cameraUpdate, callback);
}
}

View File

@@ -1,14 +1,14 @@
package com.mapbox.mapboxsdk.testapp.camera;
package org.maplibre.android.testapp.camera;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdate;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.testapp.activity.BaseTest;
import com.mapbox.mapboxsdk.testapp.activity.espresso.DeviceIndependentTestActivity;
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
import org.maplibre.android.camera.CameraPosition;
import org.maplibre.android.camera.CameraUpdate;
import org.maplibre.android.camera.CameraUpdateFactory;
import org.maplibre.android.geometry.LatLng;
import org.maplibre.android.geometry.LatLngBounds;
import org.maplibre.android.maps.MapLibreMap;
import org.maplibre.android.testapp.activity.BaseTest;
import org.maplibre.android.testapp.activity.espresso.DeviceIndependentTestActivity;
import org.maplibre.android.testapp.utils.TestConstants;
import org.junit.Assert;
import org.junit.Test;
@@ -16,7 +16,7 @@ import org.junit.Test;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
import static org.maplibre.android.testapp.action.MapLibreMapAction.invoke;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
@@ -38,7 +38,7 @@ public abstract class CameraTest extends BaseTest {
@Test
public void testToCameraPositionTarget() throws InterruptedException {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
float zoom = 1.0f;
LatLng moveTarget = new LatLng(1, 1);
CameraPosition initialPosition = new CameraPosition.Builder().target(
@@ -46,7 +46,7 @@ public abstract class CameraTest extends BaseTest {
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
assertEquals("Default camera position should match default", cameraPosition, initialPosition);
executeCameraMovement(CameraUpdateFactory.newLatLng(moveTarget), new MapboxMap.CancelableCallback() {
executeCameraMovement(CameraUpdateFactory.newLatLng(moveTarget), new MapLibreMap.CancelableCallback() {
@Override
public void onCancel() {
verifyCameraPosition(mapboxMap, moveTarget, zoom, 0, 0, new double[4]);
@@ -69,12 +69,12 @@ public abstract class CameraTest extends BaseTest {
@Test
public void testToCameraPositionTargetZoom() throws InterruptedException {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
final float moveZoom = 15.5f;
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
executeCameraMovement(CameraUpdateFactory.newLatLngZoom(moveTarget, moveZoom),
new MapboxMap.CancelableCallback() {
new MapLibreMap.CancelableCallback() {
@Override
public void onCancel() {
verifyCameraPosition(mapboxMap, moveTarget, moveZoom, 0, 0, new double[4]);
@@ -97,7 +97,7 @@ public abstract class CameraTest extends BaseTest {
@Test
public void testToCameraPosition() throws InterruptedException {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
final LatLng moveTarget = new LatLng(1.0000000001, 1.0000000003);
final float moveZoom = 15.5f;
final float moveTilt = 45.5f;
@@ -112,7 +112,7 @@ public abstract class CameraTest extends BaseTest {
.bearing(moveBearing)
.padding(movePadding)
.build()),
new MapboxMap.CancelableCallback() {
new MapLibreMap.CancelableCallback() {
@Override
public void onCancel() {
verifyCameraPosition(mapboxMap, moveTarget, moveZoom, moveBearing, moveTilt, movePadding);
@@ -135,7 +135,7 @@ public abstract class CameraTest extends BaseTest {
@Test
public void testToBounds() throws InterruptedException {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
final LatLng centerBounds = new LatLng(1, 1);
LatLng cornerOne = new LatLng();
LatLng cornerTwo = new LatLng(2, 2);
@@ -144,7 +144,7 @@ public abstract class CameraTest extends BaseTest {
builder.include(cornerTwo);
executeCameraMovement(CameraUpdateFactory.newLatLngBounds(builder.build(), 0),
new MapboxMap.CancelableCallback() {
new MapLibreMap.CancelableCallback() {
@Override
public void onCancel() {
verifyCameraPosition(mapboxMap, centerBounds, mapboxMap.getCameraPosition().zoom, 0, 0, new double[4]);
@@ -167,10 +167,10 @@ public abstract class CameraTest extends BaseTest {
@Test
public void testToZoomIn() throws InterruptedException {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
float zoom = 1.0f;
executeCameraMovement(CameraUpdateFactory.zoomIn(), new MapboxMap.CancelableCallback() {
executeCameraMovement(CameraUpdateFactory.zoomIn(), new MapLibreMap.CancelableCallback() {
@Override
public void onCancel() {
verifyCameraPosition(mapboxMap, mapboxMap.getCameraPosition().target, zoom + 1, 0, 0, new double[4]);
@@ -194,21 +194,22 @@ public abstract class CameraTest extends BaseTest {
public void testToZoomOut() throws InterruptedException {
float zoom = 10.0f;
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
executeCameraMovement(CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom), new MapboxMap.CancelableCallback() {
@Override
public void onCancel() {
verifyCameraPosition(mapboxMap, mapboxMap.getCameraPosition().target, zoom, 0, 0, new double[4]);
latch.countDown();
}
invoke(maplibreMap, (uiController, mapboxMap) ->
executeCameraMovement(CameraUpdateFactory.newLatLngZoom(new LatLng(), zoom),
new MapLibreMap.CancelableCallback() {
@Override
public void onCancel() {
verifyCameraPosition(mapboxMap, mapboxMap.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]);
latch.countDown();
}
});
});
@Override
public void onFinish() {
verifyCameraPosition(mapboxMap, mapboxMap.getCameraPosition().target, zoom, 0, 0, new double[4]);
latch.countDown();
}
})
);
if (!latch.await(10, TimeUnit.SECONDS)) {
Assert.fail("timeout");
@@ -216,8 +217,8 @@ public abstract class CameraTest extends BaseTest {
latch = new CountDownLatch(1);
invoke(mapboxMap, (uiController, mapboxMap) -> {
executeCameraMovement(CameraUpdateFactory.zoomOut(), new MapboxMap.CancelableCallback() {
invoke(maplibreMap, (uiController, mapboxMap) -> {
executeCameraMovement(CameraUpdateFactory.zoomOut(), new MapLibreMap.CancelableCallback() {
@Override
public void onCancel() {
verifyCameraPosition(mapboxMap, mapboxMap.getCameraPosition().target, zoom - 1, 0, 0, new double[4]);
@@ -240,11 +241,11 @@ public abstract class CameraTest extends BaseTest {
@Test
public void testToZoomBy() throws InterruptedException {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
float zoom = 1.0f;
final float zoomBy = 2.45f;
executeCameraMovement(CameraUpdateFactory.zoomBy(zoomBy), new MapboxMap.CancelableCallback() {
executeCameraMovement(CameraUpdateFactory.zoomBy(zoomBy), new MapLibreMap.CancelableCallback() {
@Override
public void onCancel() {
verifyCameraPosition(mapboxMap, mapboxMap.getCameraPosition().target, zoom + zoomBy, 0, 0, new double[4]);
@@ -267,10 +268,10 @@ public abstract class CameraTest extends BaseTest {
@Test
public void testToZoomTo() throws InterruptedException {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
final float zoomTo = 2.45f;
executeCameraMovement(CameraUpdateFactory.zoomTo(zoomTo), new MapboxMap.CancelableCallback() {
executeCameraMovement(CameraUpdateFactory.zoomTo(zoomTo), new MapLibreMap.CancelableCallback() {
@Override
public void onCancel() {
verifyCameraPosition(mapboxMap, mapboxMap.getCameraPosition().target, zoomTo, 0, 0, new double[4]);
@@ -290,11 +291,11 @@ public abstract class CameraTest extends BaseTest {
}
}
abstract void executeCameraMovement(CameraUpdate cameraUpdate, MapboxMap.CancelableCallback callback);
abstract void executeCameraMovement(CameraUpdate cameraUpdate, MapLibreMap.CancelableCallback callback);
private void verifyCameraPosition(MapboxMap mapboxMap, LatLng moveTarget, double moveZoom, double moveBearing,
private void verifyCameraPosition(MapLibreMap maplibreMap, LatLng moveTarget, double moveZoom, double moveBearing,
double moveTilt, double[] padding) {
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
CameraPosition cameraPosition = maplibreMap.getCameraPosition();
assertEquals("Moved camera position latitude should match", cameraPosition.target.getLatitude(),
moveTarget.getLatitude(), TestConstants.LAT_LNG_DELTA);
assertEquals("Moved camera position longitude should match", cameraPosition.target.getLongitude(),

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.testapp.fragment
package org.maplibre.android.testapp.fragment
import androidx.test.espresso.Espresso
import androidx.test.espresso.Espresso.onView
@@ -7,9 +7,9 @@ import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.testapp.R
import com.mapbox.mapboxsdk.testapp.activity.maplayout.MapInDialogActivity
import org.maplibre.android.AppCenter
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.activity.maplayout.MapInDialogActivity
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.testapp.geometry;
package org.maplibre.android.testapp.geometry;
import androidx.test.annotation.UiThreadTest;
@@ -6,14 +6,14 @@ import com.google.gson.JsonArray;
import com.mapbox.geojson.Feature;
import com.mapbox.geojson.Point;
import com.mapbox.geojson.Polygon;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest;
import com.mapbox.mapboxsdk.testapp.utils.TestingAsyncUtils;
import org.maplibre.android.geometry.LatLng;
import org.maplibre.android.style.expressions.Expression;
import org.maplibre.android.style.layers.PropertyFactory;
import org.maplibre.android.style.layers.SymbolLayer;
import org.maplibre.android.style.sources.GeoJsonSource;
import org.maplibre.android.testapp.action.MapLibreMapAction;
import org.maplibre.android.testapp.activity.EspressoTest;
import org.maplibre.android.testapp.utils.TestingAsyncUtils;
import org.junit.Test;
@@ -39,91 +39,91 @@ public class GeoJsonConversionTest extends EspressoTest {
@UiThreadTest
public void testEmptyFeatureCollection() {
validateTestSetup();
mapboxMap.getStyle().addSource(
maplibreMap.getStyle().addSource(
new GeoJsonSource("test-id",
fromFeatures(singletonList(fromGeometry(fromGeometries(emptyList()))))
)
);
mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
maplibreMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
}
@Test
@UiThreadTest
public void testPointFeatureCollection() {
validateTestSetup();
mapboxMap.getStyle().addSource(
maplibreMap.getStyle().addSource(
new GeoJsonSource("test-id",
fromFeatures(singletonList(fromGeometry(Point.fromLngLat(0.0, 0.0))))
)
);
mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
maplibreMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
}
@Test
@UiThreadTest
public void testMultiPointFeatureCollection() {
validateTestSetup();
mapboxMap.getStyle().addSource(
maplibreMap.getStyle().addSource(
new GeoJsonSource("test-id",
fromFeatures(singletonList(fromGeometry(fromLngLats(emptyList()))))
)
);
mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
maplibreMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
}
@Test
@UiThreadTest
public void testPolygonFeatureCollection() {
validateTestSetup();
mapboxMap.getStyle().addSource(
maplibreMap.getStyle().addSource(
new GeoJsonSource("test-id",
fromFeatures(singletonList(fromGeometry(Polygon.fromLngLats(emptyList()))))
)
);
mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
maplibreMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
}
@Test
@UiThreadTest
public void testMultiPolygonFeatureCollection() {
validateTestSetup();
mapboxMap.getStyle().addSource(
maplibreMap.getStyle().addSource(
new GeoJsonSource("test-id",
fromFeatures(singletonList(fromGeometry(fromPolygon(Polygon.fromLngLats(emptyList())))))
)
);
mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
maplibreMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
}
@Test
@UiThreadTest
public void testLineStringFeatureCollection() {
validateTestSetup();
mapboxMap.getStyle().addSource(
maplibreMap.getStyle().addSource(
new GeoJsonSource("test-id",
fromFeatures(singletonList(fromGeometry(fromLngLats(emptyList()))))
)
);
mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
maplibreMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
}
@Test
@UiThreadTest
public void testMultiLineStringFeatureCollection() {
validateTestSetup();
mapboxMap.getStyle().addSource(
maplibreMap.getStyle().addSource(
new GeoJsonSource("test-id",
fromFeatures(singletonList(fromGeometry(fromLineString(fromLngLats(emptyList())))))
)
);
mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
maplibreMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
}
@Test
public void testNegativeNumberPropertyConversion() {
validateTestSetup();
onView(isRoot()).perform(new MapboxMapAction((uiController, mapboxMap) -> {
onView(isRoot()).perform(new MapLibreMapAction((uiController, mapboxMap) -> {
LatLng latLng = new LatLng();
Feature feature = Feature.fromGeometry(Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude()));
@@ -145,6 +145,6 @@ public class GeoJsonConversionTest extends EspressoTest {
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng)).isEmpty());
}, mapboxMap));
}, maplibreMap));
}
}

View File

@@ -1,14 +1,14 @@
package com.mapbox.mapboxsdk.testapp.geometry;
package org.maplibre.android.testapp.geometry;
import static org.junit.Assert.assertEquals;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
import com.mapbox.mapboxsdk.testapp.activity.BaseTest;
import com.mapbox.mapboxsdk.testapp.activity.feature.QueryRenderedFeaturesBoxHighlightActivity;
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
import org.maplibre.android.camera.CameraUpdateFactory;
import org.maplibre.android.geometry.LatLng;
import org.maplibre.android.geometry.LatLngBounds;
import org.maplibre.android.testapp.action.MapLibreMapAction;
import org.maplibre.android.testapp.activity.BaseTest;
import org.maplibre.android.testapp.activity.feature.QueryRenderedFeaturesBoxHighlightActivity;
import org.maplibre.android.testapp.utils.TestConstants;
import org.junit.Test;
@@ -28,7 +28,7 @@ public class LatLngBoundsTest extends BaseTest {
public void testLatLngBounds() {
// regression test for #9322
validateTestSetup();
MapboxMapAction.invoke(mapboxMap, (uiController, mapboxMap) -> {
MapLibreMapAction.invoke(maplibreMap, (uiController, mapboxMap) -> {
LatLngBounds bounds = new LatLngBounds.Builder()
.include(new LatLng(48.8589506, 2.2773457))
.include(new LatLng(47.2383171, -1.6309316))
@@ -41,7 +41,7 @@ public class LatLngBoundsTest extends BaseTest {
public void testLatLngBoundsBearing() {
// regression test for #12549
validateTestSetup();
MapboxMapAction.invoke(mapboxMap, (uiController, mapboxMap) -> {
MapLibreMapAction.invoke(maplibreMap, (uiController, mapboxMap) -> {
LatLngBounds bounds = new LatLngBounds.Builder()
.include(new LatLng(48.8589506, 2.2773457))
.include(new LatLng(47.2383171, -1.6309316))

View File

@@ -1,12 +1,12 @@
package com.mapbox.mapboxsdk.testapp.maps
package org.maplibre.android.testapp.maps
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.maps.MapView
import com.mapbox.mapboxsdk.maps.Style
import com.mapbox.mapboxsdk.testapp.R
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity
import org.maplibre.android.AppCenter
import org.maplibre.android.maps.MapView
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.activity.espresso.EspressoTestActivity
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Rule

View File

@@ -1,16 +1,16 @@
package com.mapbox.mapboxsdk.testapp.maps
package org.maplibre.android.testapp.maps
import android.graphics.Bitmap
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.maps.MapView
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.maps.Style
import com.mapbox.mapboxsdk.testapp.R
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity
import org.maplibre.android.AppCenter
import org.maplibre.android.camera.CameraUpdateFactory
import org.maplibre.android.geometry.LatLng
import org.maplibre.android.maps.MapView
import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.activity.espresso.EspressoTestActivity
import org.junit.Assert.*
import org.junit.Before
import org.junit.Rule
@@ -28,7 +28,7 @@ class RemoveUnusedImagesTest : AppCenter() {
var rule = ActivityTestRule(EspressoTestActivity::class.java)
private lateinit var mapView: MapView
private lateinit var mapboxMap: MapboxMap
private lateinit var maplibreMap: MapLibreMap
private val latch = CountDownLatch(1)
@Before
@@ -36,8 +36,8 @@ class RemoveUnusedImagesTest : AppCenter() {
rule.runOnUiThread {
mapView = rule.activity.findViewById(R.id.mapView)
mapView.getMapAsync {
mapboxMap = it
mapboxMap.setStyle(Style.Builder().fromJson(styleJson))
maplibreMap = it
maplibreMap.setStyle(Style.Builder().fromJson(styleJson))
}
}
}
@@ -47,22 +47,22 @@ class RemoveUnusedImagesTest : AppCenter() {
var callbackLatch = CountDownLatch(2)
rule.runOnUiThread {
mapView.addOnStyleImageMissingListener {
mapboxMap.style!!.addImage(it, Bitmap.createBitmap(512, 512, Bitmap.Config.ARGB_8888))
maplibreMap.style!!.addImage(it, Bitmap.createBitmap(512, 512, Bitmap.Config.ARGB_8888))
}
// Remove layer and source, so that rendered tiles are no longer used, therefore, map must
// notify client about unused images.
mapView.addOnDidBecomeIdleListener {
mapboxMap.style!!.removeLayer("icon")
mapboxMap.style!!.removeSource("geojson")
maplibreMap.style!!.removeLayer("icon")
maplibreMap.style!!.removeSource("geojson")
}
mapView.addOnCanRemoveUnusedStyleImageListener {
callbackLatch.countDown()
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 120.0), 8.0))
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 120.0), 8.0))
mapView.addOnDidFinishRenderingFrameListener {
assertNotNull(mapboxMap.style!!.getImage("small"))
assertNotNull(mapboxMap.style!!.getImage("large"))
assertNotNull(maplibreMap.style!!.getImage("small"))
assertNotNull(maplibreMap.style!!.getImage("large"))
latch.countDown()
}
return@addOnCanRemoveUnusedStyleImageListener false
@@ -78,19 +78,19 @@ class RemoveUnusedImagesTest : AppCenter() {
fun testRemoveUnusedImagesDefaultListener() {
rule.runOnUiThread {
mapView.addOnStyleImageMissingListener {
mapboxMap.style!!.addImage(it, Bitmap.createBitmap(512, 512, Bitmap.Config.ARGB_8888))
maplibreMap.style!!.addImage(it, Bitmap.createBitmap(512, 512, Bitmap.Config.ARGB_8888))
}
// Remove layer and source, so that rendered tiles are no longer used, thus
// map must request removal of unused images.
mapView.addOnDidBecomeIdleListener {
mapboxMap.style!!.removeLayer("icon")
mapboxMap.style!!.removeSource("geojson")
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 120.0), 8.0))
maplibreMap.style!!.removeLayer("icon")
maplibreMap.style!!.removeSource("geojson")
maplibreMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(0.0, 120.0), 8.0))
// Wait for the next frame and check that images were removed from the style.
mapView.addOnDidFinishRenderingFrameListener {
if (mapboxMap.style!!.getImage("small") == null && mapboxMap.style!!.getImage("large") == null) {
if (maplibreMap.style!!.getImage("small") == null && maplibreMap.style!!.getImage("large") == null) {
latch.countDown()
}
}
@@ -107,7 +107,7 @@ class RemoveUnusedImagesTest : AppCenter() {
"""
{
"version": 8,
"name": "Mapbox Streets",
"name": "MapLibre Streets",
"sources": {
"geojson": {
"type": "geojson",

View File

@@ -1,15 +1,15 @@
package com.mapbox.mapboxsdk.testapp.maps
package org.maplibre.android.testapp.maps
import android.view.TextureView
import android.view.ViewGroup
import androidx.test.annotation.UiThreadTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.maps.MapView
import com.mapbox.mapboxsdk.maps.MapboxMapOptions
import com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.MapboxGLSurfaceView
import com.mapbox.mapboxsdk.testapp.activity.FeatureOverviewActivity
import org.maplibre.android.AppCenter
import org.maplibre.android.maps.MapView
import org.maplibre.android.maps.MapLibreMapOptions
import org.maplibre.android.maps.renderer.glsurfaceview.MapLibreGLSurfaceView
import org.maplibre.android.testapp.activity.FeatureOverviewActivity
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue
import org.junit.Rule
@@ -34,7 +34,7 @@ class RenderViewGetterTest : AppCenter() {
rootView = rule.activity.findViewById(android.R.id.content)
mapView = MapView(rule.activity)
assertNotNull(mapView.renderView)
assertTrue(mapView.renderView is MapboxGLSurfaceView)
assertTrue(mapView.renderView is MapLibreGLSurfaceView)
}
@Test
@@ -43,7 +43,7 @@ class RenderViewGetterTest : AppCenter() {
rootView = rule.activity.findViewById(android.R.id.content)
mapView = MapView(
rule.activity,
MapboxMapOptions.createFromAttributes(rule.activity, null)
MapLibreMapOptions.createFromAttributes(rule.activity, null)
.textureMode(true)
)
assertNotNull(mapView.renderView)

View File

@@ -1,13 +1,14 @@
package com.mapbox.mapboxsdk.testapp.maps
package org.maplibre.android.testapp.maps
import android.graphics.PointF
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.maps.MapView
import com.mapbox.mapboxsdk.testapp.R
import com.mapbox.mapboxsdk.testapp.activity.espresso.DeviceIndependentTestActivity
import org.junit.Assert.assertArrayEquals
import org.maplibre.android.AppCenter
import org.maplibre.android.geometry.LatLng
import org.maplibre.android.maps.MapView
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.activity.espresso.DeviceIndependentTestActivity
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Before
@@ -86,7 +87,7 @@ class ScreenCoordinateConversion : AppCenter() {
val projection = it.projection
projection.fromScreenLocations(doubleArrayOf(1.0, 2.0, 3.0, 4.0), actual)
// check all values at once
assertTrue(expected.contentEquals(actual))
assertArrayEquals(expected, actual, DELTA_DOUBLE)
// check first latlng value
val latLngFirst = LatLng(expected[0], expected[1])

View File

@@ -0,0 +1,31 @@
package org.maplibre.android.testapp.maps
import androidx.test.espresso.UiController
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.Style
import org.maplibre.android.style.layers.SymbolLayer
import org.maplibre.android.style.sources.GeoJsonSource
import org.maplibre.android.testapp.action.MapLibreMapAction
import org.maplibre.android.testapp.activity.EspressoTest
import org.maplibre.android.testapp.utils.TestingAsyncUtils
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4ClassRunner::class)
class StyleLoadTest : EspressoTest() {
@Test
fun updateSourceAfterStyleLoad() {
validateTestSetup()
MapLibreMapAction.invoke(maplibreMap) { uiController: UiController, maplibreMap: MapLibreMap ->
val source = GeoJsonSource("id")
val layer = SymbolLayer("id", "id")
maplibreMap.setStyle(Style.Builder().withSource(source).withLayer(layer))
TestingAsyncUtils.waitForLayer(uiController, mapView)
maplibreMap.setStyle(Style.Builder().fromUrl(Style.getPredefinedStyle("Streets")))
TestingAsyncUtils.waitForLayer(uiController, mapView)
source.setGeoJson("{}")
}
}
}

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.testapp.maps.widgets;
package org.maplibre.android.testapp.maps.widgets;
import android.app.Instrumentation;
import android.content.Intent;
@@ -13,10 +13,10 @@ import androidx.test.espresso.UiController;
import androidx.test.espresso.ViewAction;
import androidx.test.espresso.intent.Intents;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.sources.Source;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest;
import org.maplibre.android.maps.MapLibreMap;
import org.maplibre.android.style.sources.Source;
import org.maplibre.android.testapp.R;
import org.maplibre.android.testapp.activity.EspressoTest;
import org.hamcrest.Matcher;
import org.junit.After;
@@ -60,7 +60,7 @@ public class AttributionTest extends EspressoTest {
// Disabled
onView(withTagValue(is("attrView")))
.perform(new DisableAction(mapboxMap))
.perform(new DisableAction(maplibreMap))
.check(matches(not(isDisplayed())));
}
@@ -134,8 +134,8 @@ public class AttributionTest extends EspressoTest {
}
private void buildUrlSpans() {
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
for (Source source : mapboxMap.getStyle().getSources()) {
onView(withId(R.id.mapView)).perform(new MapLibreMapAction((uiController, view) -> {
for (Source source : maplibreMap.getStyle().getSources()) {
String attributionSource = source.getAttribution();
if (!TextUtils.isEmpty(attributionSource)) {
SpannableStringBuilder htmlBuilder = (SpannableStringBuilder) Html.fromHtml(attributionSource);
@@ -147,10 +147,10 @@ public class AttributionTest extends EspressoTest {
private class DisableAction implements ViewAction {
private MapboxMap mapboxMap;
private MapLibreMap maplibreMap;
DisableAction(MapboxMap map) {
mapboxMap = map;
DisableAction(MapLibreMap map) {
maplibreMap = map;
}
@Override
@@ -165,15 +165,15 @@ public class AttributionTest extends EspressoTest {
@Override
public void perform(UiController uiController, View view) {
mapboxMap.getUiSettings().setAttributionEnabled(false);
maplibreMap.getUiSettings().setAttributionEnabled(false);
}
}
private class MapboxMapAction implements ViewAction {
private class MapLibreMapAction implements ViewAction {
private InvokeViewAction invokeViewAction;
MapboxMapAction(InvokeViewAction invokeViewAction) {
MapLibreMapAction(InvokeViewAction invokeViewAction) {
this.invokeViewAction = invokeViewAction;
}

View File

@@ -1,11 +1,11 @@
package com.mapbox.mapboxsdk.testapp.maps.widgets;
package org.maplibre.android.testapp.maps.widgets;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.testapp.action.WaitAction;
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest;
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
import org.maplibre.android.camera.CameraPosition;
import org.maplibre.android.camera.CameraUpdateFactory;
import org.maplibre.android.geometry.LatLng;
import org.maplibre.android.testapp.action.WaitAction;
import org.maplibre.android.testapp.activity.EspressoTest;
import org.maplibre.android.testapp.utils.TestConstants;
import org.junit.Ignore;
import org.junit.Test;
@@ -15,7 +15,7 @@ import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withTagValue;
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
import static org.maplibre.android.testapp.action.MapLibreMapAction.invoke;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
@@ -32,7 +32,7 @@ public class CompassViewTest extends EspressoTest {
@Ignore("No explanation given")
public void testVisible() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
new CameraPosition.Builder()
.bearing(45)
@@ -49,7 +49,7 @@ public class CompassViewTest extends EspressoTest {
@Ignore("No explanation given")
public void testClick() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
invoke(maplibreMap, (uiController, mapboxMap) -> mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
new CameraPosition.Builder()
.bearing(45)
.zoom(1)
@@ -59,7 +59,7 @@ public class CompassViewTest extends EspressoTest {
onView(withTagValue(is("compassView"))).perform(click());
WaitAction.invoke(500);
onView(withTagValue(is("compassView"))).check(matches(not(isDisplayed())));
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
assertEquals("Camera bearing should face north, ", 0, cameraPosition.bearing, TestConstants.BEARING_DELTA);
});

View File

@@ -1,12 +1,12 @@
package com.mapbox.mapboxsdk.testapp.maps.widgets;
package org.maplibre.android.testapp.maps.widgets;
import android.view.View;
import androidx.test.espresso.UiController;
import androidx.test.espresso.ViewAction;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest;
import org.maplibre.android.maps.MapLibreMap;
import org.maplibre.android.testapp.activity.EspressoTest;
import org.hamcrest.Matcher;
import org.junit.Test;
@@ -31,16 +31,16 @@ public class LogoTest extends EspressoTest {
validateTestSetup();
onView(withTagValue(is("logoView")))
.perform(new DisableAction(mapboxMap))
.perform(new DisableAction(maplibreMap))
.check(matches(not(isDisplayed())));
}
private class DisableAction implements ViewAction {
private MapboxMap mapboxMap;
private MapLibreMap maplibreMap;
DisableAction(MapboxMap map) {
mapboxMap = map;
DisableAction(MapLibreMap map) {
maplibreMap = map;
}
@Override
@@ -55,7 +55,7 @@ public class LogoTest extends EspressoTest {
@Override
public void perform(UiController uiController, View view) {
mapboxMap.getUiSettings().setLogoEnabled(false);
maplibreMap.getUiSettings().setLogoEnabled(false);
}
}
}

View File

@@ -1,10 +1,10 @@
package com.mapbox.mapboxsdk.testapp.offline
package org.maplibre.android.testapp.offline
import android.content.Context
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.offline.OfflineManager
import com.mapbox.mapboxsdk.testapp.activity.FeatureOverviewActivity
import org.maplibre.android.offline.OfflineManager
import org.maplibre.android.testapp.activity.FeatureOverviewActivity
import org.junit.Assert
import org.junit.Rule
import org.junit.Test

View File

@@ -1,14 +1,14 @@
package com.mapbox.mapboxsdk.testapp.offline
package org.maplibre.android.testapp.offline
import android.content.Context
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.offline.OfflineManager
import com.mapbox.mapboxsdk.offline.OfflineRegion
import com.mapbox.mapboxsdk.storage.FileSource
import com.mapbox.mapboxsdk.testapp.activity.FeatureOverviewActivity
import com.mapbox.mapboxsdk.testapp.utils.FileUtils
import org.maplibre.android.AppCenter
import org.maplibre.android.offline.OfflineManager
import org.maplibre.android.offline.OfflineRegion
import org.maplibre.android.storage.FileSource
import org.maplibre.android.testapp.activity.FeatureOverviewActivity
import org.maplibre.android.testapp.utils.FileUtils
import org.junit.FixMethodOrder
import org.junit.Rule
import org.junit.Test

View File

@@ -1,9 +1,9 @@
package com.mapbox.mapboxsdk.testapp.offline
package org.maplibre.android.testapp.offline
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.testapp.activity.offline.OfflineActivity
import com.mapbox.mapboxsdk.testapp.utils.OfflineUtils.convertRegionName
import org.maplibre.android.AppCenter
import org.maplibre.android.testapp.activity.offline.OfflineActivity
import org.maplibre.android.testapp.utils.OfflineUtils.convertRegionName
import org.junit.Assert
import org.junit.Test
import org.junit.runner.RunWith

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.testapp.render;
package org.maplibre.android.testapp.render;
import android.Manifest;
@@ -9,9 +9,9 @@ import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import androidx.test.rule.ActivityTestRule;
import androidx.test.rule.GrantPermissionRule;
import com.mapbox.mapboxsdk.AppCenter;
import com.mapbox.mapboxsdk.testapp.activity.render.RenderTestActivity;
import com.mapbox.mapboxsdk.testapp.utils.SnapshotterIdlingResource;
import org.maplibre.android.AppCenter;
import org.maplibre.android.testapp.activity.render.RenderTestActivity;
import org.maplibre.android.testapp.utils.SnapshotterIdlingResource;
import org.junit.After;
import org.junit.Before;

View File

@@ -1,11 +1,11 @@
package com.mapbox.mapboxsdk.testapp.storage
package org.maplibre.android.testapp.storage
import androidx.test.annotation.UiThreadTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.storage.FileSource
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity
import org.maplibre.android.AppCenter
import org.maplibre.android.storage.FileSource
import org.maplibre.android.testapp.activity.espresso.EspressoTestActivity
import org.junit.After
import org.junit.Assert
import org.junit.Before

View File

@@ -1,11 +1,11 @@
package com.mapbox.mapboxsdk.testapp.storage
package org.maplibre.android.testapp.storage
import androidx.test.annotation.UiThreadTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.storage.FileSource
import com.mapbox.mapboxsdk.testapp.activity.FeatureOverviewActivity
import org.maplibre.android.AppCenter
import org.maplibre.android.storage.FileSource
import org.maplibre.android.testapp.activity.FeatureOverviewActivity
import org.junit.*
import org.junit.rules.TestName
import org.junit.runner.RunWith

View File

@@ -1,9 +1,9 @@
package com.mapbox.mapboxsdk.testapp.storage
package org.maplibre.android.testapp.storage
import android.app.Activity
import androidx.annotation.WorkerThread
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.storage.FileSource
import org.maplibre.android.AppCenter
import org.maplibre.android.storage.FileSource
import org.junit.Assert
import java.io.File
import java.util.concurrent.CountDownLatch

View File

@@ -1,10 +1,10 @@
package com.mapbox.mapboxsdk.testapp.string;
package org.maplibre.android.testapp.string;
import static org.junit.Assert.assertEquals;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest;
import org.maplibre.android.testapp.activity.EspressoTest;
import org.junit.Test;
import org.junit.runner.RunWith;

View File

@@ -1,36 +1,37 @@
// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
package com.mapbox.mapboxsdk.testapp.style;
package org.maplibre.android.testapp.style;
import android.graphics.Color;
import androidx.test.annotation.UiThreadTest;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.geojson.LineString;
import com.mapbox.geojson.MultiLineString;
import com.mapbox.geojson.MultiPoint;
import com.mapbox.geojson.MultiPolygon;
import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import com.mapbox.geojson.Polygon;
import org.maplibre.android.maps.BaseLayerTest;
import org.junit.Before;
import timber.log.Timber;
import org.maplibre.android.style.expressions.Expression;
import org.maplibre.android.style.layers.BackgroundLayer;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.maplibre.android.style.expressions.Expression.*;
import static org.junit.Assert.*;
import static org.maplibre.android.style.layers.Property.*;
import static org.maplibre.android.style.layers.PropertyFactory.*;
import org.maplibre.android.style.layers.TransitionOptions;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import timber.log.Timber;
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundOpacity;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundPattern;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
/**
* Basic smoke tests for BackgroundLayer
*/

View File

@@ -1,9 +1,8 @@
// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
package com.mapbox.mapboxsdk.testapp.style;
package org.maplibre.android.testapp.style;
import android.graphics.Color;
import androidx.test.annotation.UiThreadTest;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
@@ -13,51 +12,26 @@ import com.mapbox.geojson.MultiPoint;
import com.mapbox.geojson.MultiPolygon;
import com.mapbox.geojson.Point;
import com.mapbox.geojson.Polygon;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import org.maplibre.android.maps.BaseLayerTest;
import org.junit.Before;
import timber.log.Timber;
import org.maplibre.android.style.expressions.Expression;
import org.maplibre.android.style.layers.CircleLayer;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.maplibre.android.style.expressions.Expression.*;
import static org.junit.Assert.*;
import static org.maplibre.android.style.layers.Property.*;
import static org.maplibre.android.style.layers.PropertyFactory.*;
import org.maplibre.android.style.layers.TransitionOptions;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import timber.log.Timber;
import static com.mapbox.mapboxsdk.style.expressions.Expression.distance;
import static com.mapbox.mapboxsdk.style.expressions.Expression.eq;
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
import static com.mapbox.mapboxsdk.style.expressions.Expression.lt;
import static com.mapbox.mapboxsdk.style.expressions.Expression.number;
import static com.mapbox.mapboxsdk.style.expressions.Expression.toColor;
import static com.mapbox.mapboxsdk.style.expressions.Expression.within;
import static com.mapbox.mapboxsdk.style.layers.Property.CIRCLE_PITCH_ALIGNMENT_MAP;
import static com.mapbox.mapboxsdk.style.layers.Property.CIRCLE_PITCH_SCALE_MAP;
import static com.mapbox.mapboxsdk.style.layers.Property.CIRCLE_TRANSLATE_ANCHOR_MAP;
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleBlur;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleOpacity;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circlePitchAlignment;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circlePitchScale;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleSortKey;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleStrokeColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleStrokeOpacity;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleStrokeWidth;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleTranslate;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleTranslateAnchor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
/**
* Basic smoke tests for CircleLayer
*/

View File

@@ -1,18 +1,18 @@
package com.mapbox.mapboxsdk.testapp.style
package org.maplibre.android.testapp.style
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.matcher.ViewMatchers.isRoot
import com.mapbox.mapboxsdk.style.sources.CustomGeometrySource.Companion.THREAD_POOL_LIMIT
import com.mapbox.mapboxsdk.style.sources.CustomGeometrySource.Companion.THREAD_PREFIX
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke
import com.mapbox.mapboxsdk.testapp.action.OrientationAction.orientationLandscape
import com.mapbox.mapboxsdk.testapp.action.OrientationAction.orientationPortrait
import com.mapbox.mapboxsdk.testapp.action.WaitAction
import com.mapbox.mapboxsdk.testapp.activity.BaseTest
import com.mapbox.mapboxsdk.testapp.activity.style.GridSourceActivity
import com.mapbox.mapboxsdk.testapp.activity.style.GridSourceActivity.Companion.ID_GRID_LAYER
import com.mapbox.mapboxsdk.testapp.activity.style.GridSourceActivity.Companion.ID_GRID_SOURCE
import com.mapbox.mapboxsdk.testapp.utils.TestingAsyncUtils
import org.maplibre.android.style.sources.CustomGeometrySource.Companion.THREAD_POOL_LIMIT
import org.maplibre.android.style.sources.CustomGeometrySource.Companion.THREAD_PREFIX
import org.maplibre.android.testapp.action.MapLibreMapAction.invoke
import org.maplibre.android.testapp.action.OrientationAction.orientationLandscape
import org.maplibre.android.testapp.action.OrientationAction.orientationPortrait
import org.maplibre.android.testapp.action.WaitAction
import org.maplibre.android.testapp.activity.BaseTest
import org.maplibre.android.testapp.activity.style.GridSourceActivity
import org.maplibre.android.testapp.activity.style.GridSourceActivity.Companion.ID_GRID_LAYER
import org.maplibre.android.testapp.activity.style.GridSourceActivity.Companion.ID_GRID_SOURCE
import org.maplibre.android.testapp.utils.TestingAsyncUtils
import org.junit.Assert
import org.junit.Assert.*
import org.junit.Test
@@ -40,7 +40,7 @@ class CustomGeometrySourceTest : BaseTest() {
@Test
fun threadsShutdownWhenSourceRemovedTest() {
validateTestSetup()
invoke(mapboxMap) { uiController, mapboxMap ->
invoke(maplibreMap) { uiController, mapboxMap ->
mapboxMap.style!!.removeLayer(ID_GRID_LAYER)
TestingAsyncUtils.waitForLayer(uiController, mapView)
mapboxMap.style!!.removeSource(ID_GRID_SOURCE)
@@ -57,7 +57,7 @@ class CustomGeometrySourceTest : BaseTest() {
@Test
fun threadsRestartedWhenSourceReAddedTest() {
validateTestSetup()
invoke(mapboxMap) { uiController, mapboxMap ->
invoke(maplibreMap) { uiController, mapboxMap ->
mapboxMap.style!!.removeLayer((rule.activity as GridSourceActivity).layer!!)
TestingAsyncUtils.waitForLayer(uiController, mapView)
mapboxMap.style!!.removeSource(ID_GRID_SOURCE)
@@ -77,7 +77,7 @@ class CustomGeometrySourceTest : BaseTest() {
@Test
fun sourceZoomDeltaTest() {
validateTestSetup()
invoke(mapboxMap) { uiController, mapboxMap ->
invoke(maplibreMap) { uiController, mapboxMap ->
mapboxMap.prefetchZoomDelta = 3
mapboxMap.style!!.getSource(ID_GRID_SOURCE)!!.let {
assertNull(it.prefetchZoomDelta)
@@ -93,7 +93,7 @@ class CustomGeometrySourceTest : BaseTest() {
@Test
fun isVolatileTest() {
validateTestSetup()
invoke(mapboxMap) { uiController, mapboxMap ->
invoke(maplibreMap) { uiController, mapboxMap ->
mapboxMap.style!!.getSource(ID_GRID_SOURCE)!!.let {
assertFalse(it.isVolatile)
it.isVolatile = true
@@ -105,7 +105,7 @@ class CustomGeometrySourceTest : BaseTest() {
@Test
fun minimumTileUpdateIntervalTest() {
validateTestSetup()
invoke(mapboxMap) { uiController, mapboxMap ->
invoke(maplibreMap) { uiController, mapboxMap ->
mapboxMap.style!!.getSource(ID_GRID_SOURCE)!!.let {
assertEquals(0, it.minimumTileUpdateInterval)
it.minimumTileUpdateInterval = 1000

View File

@@ -1,22 +1,22 @@
package com.mapbox.mapboxsdk.testapp.style;
package org.maplibre.android.testapp.style;
import com.mapbox.geojson.Feature;
import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
import com.mapbox.mapboxsdk.style.layers.FillLayer;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
import com.mapbox.mapboxsdk.style.sources.Source;
import com.mapbox.mapboxsdk.style.types.Formatted;
import com.mapbox.mapboxsdk.style.types.FormattedSection;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest;
import com.mapbox.mapboxsdk.testapp.utils.ResourceUtils;
import com.mapbox.mapboxsdk.testapp.utils.TestingAsyncUtils;
import com.mapbox.mapboxsdk.utils.ColorUtils;
import org.maplibre.android.geometry.LatLng;
import org.maplibre.android.style.expressions.Expression;
import org.maplibre.android.style.layers.CircleLayer;
import org.maplibre.android.style.layers.FillLayer;
import org.maplibre.android.style.layers.Layer;
import org.maplibre.android.style.layers.SymbolLayer;
import org.maplibre.android.style.sources.GeoJsonSource;
import org.maplibre.android.style.sources.Source;
import org.maplibre.android.style.types.Formatted;
import org.maplibre.android.style.types.FormattedSection;
import org.maplibre.android.testapp.R;
import org.maplibre.android.testapp.activity.EspressoTest;
import org.maplibre.android.testapp.utils.ResourceUtils;
import org.maplibre.android.testapp.utils.TestingAsyncUtils;
import org.maplibre.android.utils.ColorUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -28,40 +28,40 @@ import java.util.HashMap;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import timber.log.Timber;
import static com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption.formatFontScale;
import static com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption.formatTextColor;
import static com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption.formatTextFont;
import static com.mapbox.mapboxsdk.style.expressions.Expression.NumberFormatOption.currency;
import static com.mapbox.mapboxsdk.style.expressions.Expression.NumberFormatOption.locale;
import static com.mapbox.mapboxsdk.style.expressions.Expression.NumberFormatOption.maxFractionDigits;
import static com.mapbox.mapboxsdk.style.expressions.Expression.NumberFormatOption.minFractionDigits;
import static com.mapbox.mapboxsdk.style.expressions.Expression.collator;
import static com.mapbox.mapboxsdk.style.expressions.Expression.color;
import static com.mapbox.mapboxsdk.style.expressions.Expression.eq;
import static com.mapbox.mapboxsdk.style.expressions.Expression.exponential;
import static com.mapbox.mapboxsdk.style.expressions.Expression.format;
import static com.mapbox.mapboxsdk.style.expressions.Expression.formatEntry;
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
import static com.mapbox.mapboxsdk.style.expressions.Expression.interpolate;
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
import static com.mapbox.mapboxsdk.style.expressions.Expression.match;
import static com.mapbox.mapboxsdk.style.expressions.Expression.number;
import static com.mapbox.mapboxsdk.style.expressions.Expression.numberFormat;
import static com.mapbox.mapboxsdk.style.expressions.Expression.rgb;
import static com.mapbox.mapboxsdk.style.expressions.Expression.rgba;
import static com.mapbox.mapboxsdk.style.expressions.Expression.step;
import static com.mapbox.mapboxsdk.style.expressions.Expression.stop;
import static com.mapbox.mapboxsdk.style.expressions.Expression.string;
import static com.mapbox.mapboxsdk.style.expressions.Expression.switchCase;
import static com.mapbox.mapboxsdk.style.expressions.Expression.toColor;
import static com.mapbox.mapboxsdk.style.expressions.Expression.zoom;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillAntialias;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOutlineColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textField;
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
import static org.maplibre.android.style.expressions.Expression.FormatOption.formatFontScale;
import static org.maplibre.android.style.expressions.Expression.FormatOption.formatTextColor;
import static org.maplibre.android.style.expressions.Expression.FormatOption.formatTextFont;
import static org.maplibre.android.style.expressions.Expression.NumberFormatOption.currency;
import static org.maplibre.android.style.expressions.Expression.NumberFormatOption.locale;
import static org.maplibre.android.style.expressions.Expression.NumberFormatOption.maxFractionDigits;
import static org.maplibre.android.style.expressions.Expression.NumberFormatOption.minFractionDigits;
import static org.maplibre.android.style.expressions.Expression.collator;
import static org.maplibre.android.style.expressions.Expression.color;
import static org.maplibre.android.style.expressions.Expression.eq;
import static org.maplibre.android.style.expressions.Expression.exponential;
import static org.maplibre.android.style.expressions.Expression.format;
import static org.maplibre.android.style.expressions.Expression.formatEntry;
import static org.maplibre.android.style.expressions.Expression.get;
import static org.maplibre.android.style.expressions.Expression.interpolate;
import static org.maplibre.android.style.expressions.Expression.literal;
import static org.maplibre.android.style.expressions.Expression.match;
import static org.maplibre.android.style.expressions.Expression.number;
import static org.maplibre.android.style.expressions.Expression.numberFormat;
import static org.maplibre.android.style.expressions.Expression.rgb;
import static org.maplibre.android.style.expressions.Expression.rgba;
import static org.maplibre.android.style.expressions.Expression.step;
import static org.maplibre.android.style.expressions.Expression.stop;
import static org.maplibre.android.style.expressions.Expression.string;
import static org.maplibre.android.style.expressions.Expression.switchCase;
import static org.maplibre.android.style.expressions.Expression.toColor;
import static org.maplibre.android.style.expressions.Expression.zoom;
import static org.maplibre.android.style.layers.PropertyFactory.circleColor;
import static org.maplibre.android.style.layers.PropertyFactory.fillAntialias;
import static org.maplibre.android.style.layers.PropertyFactory.fillColor;
import static org.maplibre.android.style.layers.PropertyFactory.fillOutlineColor;
import static org.maplibre.android.style.layers.PropertyFactory.textColor;
import static org.maplibre.android.style.layers.PropertyFactory.textField;
import static org.maplibre.android.testapp.action.MapLibreMapAction.invoke;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -78,7 +78,7 @@ public class ExpressionTest extends EspressoTest {
setupStyle();
Timber.i("camera function");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
// 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(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
// create get expression
Expression inputExpression = get("fill");
@@ -127,7 +127,7 @@ public class ExpressionTest extends EspressoTest {
setupStyle();
Timber.i("camera function");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
// 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(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
// create camera function expression
Expression inputExpression = toColor(get("fill"));
@@ -178,7 +178,7 @@ public class ExpressionTest extends EspressoTest {
setupStyle();
Timber.i("camera function");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
// 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(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
layer.setProperties(
fillColor(literal("#4286f4"))
);
@@ -222,7 +222,7 @@ public class ExpressionTest extends EspressoTest {
public void testLiteralMatchExpression() {
validateTestSetup();
setupStyle();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
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(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
Expression expression1 = eq(literal("Łukasz"), literal("lukasz"), collator(true, true));
@@ -288,7 +288,7 @@ public class ExpressionTest extends EspressoTest {
@Test
public void testConstFormatExpression() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle()
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
@@ -311,7 +311,7 @@ public class ExpressionTest extends EspressoTest {
@Test
public void testConstFormatExpressionFontScaleParam() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle()
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
@@ -334,7 +334,7 @@ public class ExpressionTest extends EspressoTest {
@Test
public void testConstFormatExpressionTextFontParam() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle()
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
@@ -364,7 +364,7 @@ public class ExpressionTest extends EspressoTest {
@Test
public void testConstFormatExpressionTextColorParam() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle()
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
@@ -393,7 +393,7 @@ public class ExpressionTest extends EspressoTest {
@Test
public void testConstFormatExpressionAllParams() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle()
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
@@ -427,7 +427,7 @@ public class ExpressionTest extends EspressoTest {
@Test
public void testConstFormatExpressionMultipleInputs() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle()
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
@@ -464,7 +464,7 @@ public class ExpressionTest extends EspressoTest {
@Test
public void testVariableFormatExpression() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
Feature feature = Feature.fromGeometry(Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude()));
feature.addStringProperty("test_property", "test");
@@ -495,7 +495,7 @@ public class ExpressionTest extends EspressoTest {
@Test
public void testVariableFormatExpressionMultipleInputs() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
Feature feature = Feature.fromGeometry(Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude()));
feature.addStringProperty("test_property", "test");
@@ -527,7 +527,7 @@ public class ExpressionTest extends EspressoTest {
@Test
public void testFormatExpressionPlainTextCoercion() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle()
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
@@ -548,7 +548,7 @@ public class ExpressionTest extends EspressoTest {
@Test
public void testTextFieldFormattedArgument() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle()
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
@@ -574,7 +574,7 @@ public class ExpressionTest extends EspressoTest {
@Test
public void testNumberFormatCurrencyExpression() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle()
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
@@ -599,7 +599,7 @@ public class ExpressionTest extends EspressoTest {
@Test
public void testNumberFormatMaxExpression() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle()
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
@@ -624,7 +624,7 @@ public class ExpressionTest extends EspressoTest {
@Test
public void testNumberFormatMinExpression() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle()
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
@@ -649,7 +649,7 @@ public class ExpressionTest extends EspressoTest {
@Test
public void testNumberFormatLocaleExpression() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle()
.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
@@ -675,7 +675,7 @@ public class ExpressionTest extends EspressoTest {
@Test
public void testNumberFormatNonConstantExpression() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
Feature feature = Feature.fromGeometry(Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude()));
feature.addNumberProperty("number_value", 12.345678);
@@ -741,7 +741,7 @@ public class ExpressionTest extends EspressoTest {
@Test
public void testDoubleConversion() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
mapboxMap.getStyle().addSource(
new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude()))
@@ -764,7 +764,7 @@ public class ExpressionTest extends EspressoTest {
}
private void setupStyle() {
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
// Add a source
Source source;
source = new GeoJsonSource("amsterdam-parks-source",

View File

@@ -1,9 +1,8 @@
// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
package com.mapbox.mapboxsdk.testapp.style;
package org.maplibre.android.testapp.style;
import android.graphics.Color;
import androidx.test.annotation.UiThreadTest;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
@@ -13,47 +12,26 @@ import com.mapbox.geojson.MultiPoint;
import com.mapbox.geojson.MultiPolygon;
import com.mapbox.geojson.Point;
import com.mapbox.geojson.Polygon;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import org.maplibre.android.maps.BaseLayerTest;
import org.junit.Before;
import timber.log.Timber;
import org.maplibre.android.style.expressions.Expression;
import org.maplibre.android.style.layers.FillExtrusionLayer;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.maplibre.android.style.expressions.Expression.*;
import static org.junit.Assert.*;
import static org.maplibre.android.style.layers.Property.*;
import static org.maplibre.android.style.layers.PropertyFactory.*;
import org.maplibre.android.style.layers.TransitionOptions;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import timber.log.Timber;
import static com.mapbox.mapboxsdk.style.expressions.Expression.distance;
import static com.mapbox.mapboxsdk.style.expressions.Expression.eq;
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
import static com.mapbox.mapboxsdk.style.expressions.Expression.image;
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
import static com.mapbox.mapboxsdk.style.expressions.Expression.lt;
import static com.mapbox.mapboxsdk.style.expressions.Expression.number;
import static com.mapbox.mapboxsdk.style.expressions.Expression.string;
import static com.mapbox.mapboxsdk.style.expressions.Expression.toColor;
import static com.mapbox.mapboxsdk.style.expressions.Expression.within;
import static com.mapbox.mapboxsdk.style.layers.Property.FILL_EXTRUSION_TRANSLATE_ANCHOR_MAP;
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionBase;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionHeight;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionOpacity;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionPattern;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionTranslate;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionTranslateAnchor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionVerticalGradient;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
/**
* Basic smoke tests for FillExtrusionLayer
*/

View File

@@ -1,9 +1,8 @@
// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
package com.mapbox.mapboxsdk.testapp.style;
package org.maplibre.android.testapp.style;
import android.graphics.Color;
import androidx.test.annotation.UiThreadTest;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
@@ -13,47 +12,26 @@ import com.mapbox.geojson.MultiPoint;
import com.mapbox.geojson.MultiPolygon;
import com.mapbox.geojson.Point;
import com.mapbox.geojson.Polygon;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.FillLayer;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import org.maplibre.android.maps.BaseLayerTest;
import org.junit.Before;
import timber.log.Timber;
import org.maplibre.android.style.expressions.Expression;
import org.maplibre.android.style.layers.FillLayer;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.maplibre.android.style.expressions.Expression.*;
import static org.junit.Assert.*;
import static org.maplibre.android.style.layers.Property.*;
import static org.maplibre.android.style.layers.PropertyFactory.*;
import org.maplibre.android.style.layers.TransitionOptions;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import timber.log.Timber;
import static com.mapbox.mapboxsdk.style.expressions.Expression.distance;
import static com.mapbox.mapboxsdk.style.expressions.Expression.eq;
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
import static com.mapbox.mapboxsdk.style.expressions.Expression.image;
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
import static com.mapbox.mapboxsdk.style.expressions.Expression.lt;
import static com.mapbox.mapboxsdk.style.expressions.Expression.number;
import static com.mapbox.mapboxsdk.style.expressions.Expression.string;
import static com.mapbox.mapboxsdk.style.expressions.Expression.toColor;
import static com.mapbox.mapboxsdk.style.expressions.Expression.within;
import static com.mapbox.mapboxsdk.style.layers.Property.FILL_TRANSLATE_ANCHOR_MAP;
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillAntialias;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOpacity;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOutlineColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillPattern;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillSortKey;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillTranslate;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillTranslateAnchor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
/**
* Basic smoke tests for FillLayer
*/

View File

@@ -1,17 +1,17 @@
package com.mapbox.mapboxsdk.testapp.style;
package org.maplibre.android.testapp.style;
import com.mapbox.geojson.Feature;
import com.mapbox.geojson.FeatureCollection;
import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest;
import com.mapbox.mapboxsdk.testapp.utils.ResourceUtils;
import com.mapbox.mapboxsdk.testapp.utils.TestingAsyncUtils;
import org.maplibre.android.geometry.LatLng;
import org.maplibre.android.style.layers.CircleLayer;
import org.maplibre.android.style.layers.Layer;
import org.maplibre.android.style.sources.GeoJsonSource;
import org.maplibre.android.testapp.R;
import org.maplibre.android.testapp.action.MapLibreMapAction;
import org.maplibre.android.testapp.activity.EspressoTest;
import org.maplibre.android.testapp.utils.ResourceUtils;
import org.maplibre.android.testapp.utils.TestingAsyncUtils;
import org.hamcrest.Matcher;
import org.junit.Test;
@@ -38,7 +38,7 @@ public class GeoJsonSourceTests extends EspressoTest {
@Test
public void testFeatureCollection() {
validateTestSetup();
MapboxMapAction.invoke(mapboxMap, (uiController, mapboxMap) -> {
MapLibreMapAction.invoke(maplibreMap, (uiController, mapboxMap) -> {
GeoJsonSource source = null;
source = new GeoJsonSource("source", FeatureCollection
.fromJson(ResourceUtils.readRawResource(rule.getActivity(), R.raw.test_feature_collection)));
@@ -50,7 +50,7 @@ public class GeoJsonSourceTests extends EspressoTest {
@Test
public void testPointGeometry() {
validateTestSetup();
MapboxMapAction.invoke(mapboxMap, (uiController, mapboxMap) -> {
MapLibreMapAction.invoke(maplibreMap, (uiController, mapboxMap) -> {
GeoJsonSource source = new GeoJsonSource("source", Point.fromLngLat(0d, 0d));
mapboxMap.getStyle().addSource(source);
mapboxMap.getStyle().addLayer(new CircleLayer("layer", source.getId()));
@@ -60,7 +60,7 @@ public class GeoJsonSourceTests extends EspressoTest {
@Test
public void testFeatureProperties() {
validateTestSetup();
MapboxMapAction.invoke(mapboxMap, (uiController, mapboxMap) -> {
MapLibreMapAction.invoke(maplibreMap, (uiController, mapboxMap) -> {
GeoJsonSource source = null;
source = new GeoJsonSource("source",
ResourceUtils.readRawResource(rule.getActivity(), R.raw.test_feature_properties));
@@ -72,7 +72,7 @@ public class GeoJsonSourceTests extends EspressoTest {
@Test
public void testUpdateCoalescing() {
validateTestSetup();
MapboxMapAction.invoke(mapboxMap, (uiController, mapboxMap) -> {
MapLibreMapAction.invoke(maplibreMap, (uiController, mapboxMap) -> {
GeoJsonSource source = new GeoJsonSource("source");
mapboxMap.getStyle().addSource(source);
mapboxMap.getStyle().addLayer(new CircleLayer("layer", source.getId()));
@@ -93,7 +93,7 @@ public class GeoJsonSourceTests extends EspressoTest {
public void testClearCollectionDuringConversion() {
// https://github.com/mapbox/mapbox-gl-native/issues/14565
validateTestSetup();
MapboxMapAction.invoke(mapboxMap, (uiController, mapboxMap) -> {
MapLibreMapAction.invoke(maplibreMap, (uiController, mapboxMap) -> {
for (int j = 0; j < 1000; j++) {
List<Feature> features = new ArrayList<>();
for (int i = 0; i < 100; i++) {
@@ -142,7 +142,7 @@ public class GeoJsonSourceTests extends EspressoTest {
protected void testFeatureFromResource(final @RawRes int resource) {
validateTestSetup();
MapboxMapAction.invoke(mapboxMap, (uiController, mapboxMap) -> {
MapLibreMapAction.invoke(maplibreMap, (uiController, mapboxMap) -> {
GeoJsonSource source = new GeoJsonSource("source");
mapboxMap.getStyle().addSource(source);
Layer layer = new CircleLayer("layer", source.getId());

View File

@@ -1,7 +1,8 @@
// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
package com.mapbox.mapboxsdk.testapp.style;
package org.maplibre.android.testapp.style;
import android.graphics.Color;
import androidx.test.annotation.UiThreadTest;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
@@ -11,39 +12,26 @@ import com.mapbox.geojson.MultiPoint;
import com.mapbox.geojson.MultiPolygon;
import com.mapbox.geojson.Point;
import com.mapbox.geojson.Polygon;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.HeatmapLayer;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import org.maplibre.android.maps.BaseLayerTest;
import org.junit.Before;
import timber.log.Timber;
import org.maplibre.android.style.expressions.Expression;
import org.maplibre.android.style.layers.HeatmapLayer;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.maplibre.android.style.expressions.Expression.*;
import static org.junit.Assert.*;
import static org.maplibre.android.style.layers.Property.*;
import static org.maplibre.android.style.layers.PropertyFactory.*;
import org.maplibre.android.style.layers.TransitionOptions;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import timber.log.Timber;
import static com.mapbox.mapboxsdk.style.expressions.Expression.distance;
import static com.mapbox.mapboxsdk.style.expressions.Expression.eq;
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
import static com.mapbox.mapboxsdk.style.expressions.Expression.lt;
import static com.mapbox.mapboxsdk.style.expressions.Expression.number;
import static com.mapbox.mapboxsdk.style.expressions.Expression.within;
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.heatmapIntensity;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.heatmapOpacity;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.heatmapRadius;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.heatmapWeight;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
/**
* Basic smoke tests for HeatmapLayer
*/

View File

@@ -1,40 +1,37 @@
// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
package com.mapbox.mapboxsdk.testapp.style;
package org.maplibre.android.testapp.style;
import android.graphics.Color;
import androidx.test.annotation.UiThreadTest;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.geojson.LineString;
import com.mapbox.geojson.MultiLineString;
import com.mapbox.geojson.MultiPoint;
import com.mapbox.geojson.MultiPolygon;
import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
import com.mapbox.mapboxsdk.style.layers.HillshadeLayer;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import com.mapbox.geojson.Polygon;
import org.maplibre.android.maps.BaseLayerTest;
import org.junit.Before;
import timber.log.Timber;
import org.maplibre.android.style.expressions.Expression;
import org.maplibre.android.style.layers.HillshadeLayer;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.maplibre.android.style.expressions.Expression.*;
import static org.junit.Assert.*;
import static org.maplibre.android.style.layers.Property.*;
import static org.maplibre.android.style.layers.PropertyFactory.*;
import org.maplibre.android.style.layers.TransitionOptions;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import timber.log.Timber;
import static com.mapbox.mapboxsdk.style.layers.Property.HILLSHADE_ILLUMINATION_ANCHOR_MAP;
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.hillshadeAccentColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.hillshadeExaggeration;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.hillshadeHighlightColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.hillshadeIlluminationAnchor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.hillshadeIlluminationDirection;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.hillshadeShadowColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
/**
* Basic smoke tests for HillshadeLayer
*/

View File

@@ -1,11 +1,11 @@
package com.mapbox.mapboxsdk.testapp.style
package org.maplibre.android.testapp.style
import android.graphics.Bitmap
import android.graphics.drawable.BitmapDrawable
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import com.mapbox.mapboxsdk.testapp.R
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.action.MapLibreMapAction
import org.maplibre.android.testapp.activity.EspressoTest
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Test
@@ -25,7 +25,7 @@ class ImageTest : EspressoTest() {
@Test
fun testAddGetImage() {
validateTestSetup()
MapboxMapAction.invoke(mapboxMap) { uiController, mapboxMap ->
MapLibreMapAction.invoke(maplibreMap) { uiController, mapboxMap ->
val drawable = rule.activity.resources.getDrawable(R.drawable.ic_launcher_round)
assertTrue(drawable is BitmapDrawable)

View File

@@ -1,37 +1,37 @@
package com.mapbox.mapboxsdk.testapp.style;
package org.maplibre.android.testapp.style;
import android.graphics.Color;
import android.view.View;
import androidx.test.espresso.UiController;
import androidx.test.espresso.ViewAction;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import android.view.View;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import com.mapbox.mapboxsdk.style.light.Light;
import com.mapbox.mapboxsdk.style.light.Position;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.BaseTest;
import com.mapbox.mapboxsdk.testapp.activity.style.FillExtrusionStyleTestActivity;
import org.maplibre.android.style.light.Light;
import org.maplibre.android.style.expressions.Expression;
import org.maplibre.android.style.layers.FillExtrusionLayer;
import org.maplibre.android.style.layers.TransitionOptions;
import org.maplibre.android.style.light.Position;
import org.maplibre.android.testapp.R;
import org.maplibre.android.testapp.activity.BaseTest;
import org.maplibre.android.testapp.activity.style.FillExtrusionStyleTestActivity;
import timber.log.Timber;
import org.hamcrest.Matcher;
import org.junit.Test;
import org.junit.runner.RunWith;
import timber.log.Timber;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.mapbox.mapboxsdk.style.expressions.Expression.eq;
import static com.mapbox.mapboxsdk.style.layers.Property.ANCHOR_MAP;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionBase;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionHeight;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionOpacity;
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
import static org.maplibre.android.style.expressions.Expression.eq;
import static org.maplibre.android.style.layers.Property.ANCHOR_MAP;
import static org.maplibre.android.style.layers.PropertyFactory.fillExtrusionBase;
import static org.maplibre.android.style.layers.PropertyFactory.fillExtrusionColor;
import static org.maplibre.android.style.layers.PropertyFactory.fillExtrusionHeight;
import static org.maplibre.android.style.layers.PropertyFactory.fillExtrusionOpacity;
import static org.maplibre.android.testapp.action.MapLibreMapAction.invoke;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -45,7 +45,7 @@ public class LightTest extends BaseTest {
validateTestSetup();
setupLight();
Timber.i("anchor");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
assertNotNull(light);
// Set and Get
light.setAnchor(ANCHOR_MAP);
@@ -58,7 +58,7 @@ public class LightTest extends BaseTest {
validateTestSetup();
setupLight();
Timber.i("positionTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
assertNotNull(light);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
@@ -72,7 +72,7 @@ public class LightTest extends BaseTest {
validateTestSetup();
setupLight();
Timber.i("position");
invoke(mapboxMap,(uiController, mapboxMap) -> {
invoke(maplibreMap,(uiController, mapboxMap) -> {
assertNotNull(light);
// Set and Get
Position position = new Position(1, 2, 3);
@@ -86,7 +86,7 @@ public class LightTest extends BaseTest {
validateTestSetup();
setupLight();
Timber.i("colorTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
assertNotNull(light);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
@@ -100,7 +100,7 @@ public class LightTest extends BaseTest {
validateTestSetup();
setupLight();
Timber.i("color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
assertNotNull(light);
// Set and Get
light.setColor("rgba(255,128,0,0.7)");
@@ -113,7 +113,7 @@ public class LightTest extends BaseTest {
validateTestSetup();
setupLight();
Timber.i("intensityTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
assertNotNull(light);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
@@ -127,11 +127,11 @@ public class LightTest extends BaseTest {
validateTestSetup();
setupLight();
Timber.i("intensity");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
assertNotNull(light);
// Set and Get
light.setIntensity(0.3f);
assertEquals("Intensity should match", 0.3f, light.getIntensity());
assertEquals("Intensity should match", 0.3f, light.getIntensity(), 0f);
});
}
@@ -149,7 +149,7 @@ public class LightTest extends BaseTest {
@Override
public void perform(UiController uiController, View view) {
light = mapboxMap.getStyle().getLight();
light = maplibreMap.getStyle().getLight();
FillExtrusionLayer fillExtrusionLayer = new FillExtrusionLayer("3d-buildings", "composite");
fillExtrusionLayer.setSourceLayer("building");
fillExtrusionLayer.setFilter(eq(Expression.get("extrude"), "true"));
@@ -160,7 +160,7 @@ public class LightTest extends BaseTest {
fillExtrusionBase(Expression.get("min_height")),
fillExtrusionOpacity(0.6f)
);
mapboxMap.getStyle().addLayer(fillExtrusionLayer);
maplibreMap.getStyle().addLayer(fillExtrusionLayer);
}
});
}

View File

@@ -1,9 +1,8 @@
// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
package com.mapbox.mapboxsdk.testapp.style;
package org.maplibre.android.testapp.style;
import android.graphics.Color;
import androidx.test.annotation.UiThreadTest;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
@@ -13,56 +12,26 @@ import com.mapbox.geojson.MultiPoint;
import com.mapbox.geojson.MultiPolygon;
import com.mapbox.geojson.Point;
import com.mapbox.geojson.Polygon;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.LineLayer;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import org.maplibre.android.maps.BaseLayerTest;
import org.junit.Before;
import timber.log.Timber;
import org.maplibre.android.style.expressions.Expression;
import org.maplibre.android.style.layers.LineLayer;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.maplibre.android.style.expressions.Expression.*;
import static org.junit.Assert.*;
import static org.maplibre.android.style.layers.Property.*;
import static org.maplibre.android.style.layers.PropertyFactory.*;
import org.maplibre.android.style.layers.TransitionOptions;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import timber.log.Timber;
import static com.mapbox.mapboxsdk.style.expressions.Expression.distance;
import static com.mapbox.mapboxsdk.style.expressions.Expression.eq;
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
import static com.mapbox.mapboxsdk.style.expressions.Expression.image;
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
import static com.mapbox.mapboxsdk.style.expressions.Expression.lt;
import static com.mapbox.mapboxsdk.style.expressions.Expression.number;
import static com.mapbox.mapboxsdk.style.expressions.Expression.string;
import static com.mapbox.mapboxsdk.style.expressions.Expression.toColor;
import static com.mapbox.mapboxsdk.style.expressions.Expression.within;
import static com.mapbox.mapboxsdk.style.layers.Property.LINE_CAP_BUTT;
import static com.mapbox.mapboxsdk.style.layers.Property.LINE_JOIN_BEVEL;
import static com.mapbox.mapboxsdk.style.layers.Property.LINE_TRANSLATE_ANCHOR_MAP;
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineBlur;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineCap;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineDasharray;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineGapWidth;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineJoin;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineMiterLimit;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineOffset;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineOpacity;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.linePattern;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineRoundLimit;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineSortKey;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineTranslate;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineTranslateAnchor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineWidth;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
/**
* Basic smoke tests for LineLayer
*/

View File

@@ -1,40 +1,37 @@
// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
package com.mapbox.mapboxsdk.testapp.style;
package org.maplibre.android.testapp.style;
import android.graphics.Color;
import androidx.test.annotation.UiThreadTest;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.geojson.LineString;
import com.mapbox.geojson.MultiLineString;
import com.mapbox.geojson.MultiPoint;
import com.mapbox.geojson.MultiPolygon;
import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
import com.mapbox.mapboxsdk.style.layers.RasterLayer;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import com.mapbox.geojson.Polygon;
import org.maplibre.android.maps.BaseLayerTest;
import org.junit.Before;
import timber.log.Timber;
import org.maplibre.android.style.expressions.Expression;
import org.maplibre.android.style.layers.RasterLayer;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.maplibre.android.style.expressions.Expression.*;
import static org.junit.Assert.*;
import static org.maplibre.android.style.layers.Property.*;
import static org.maplibre.android.style.layers.PropertyFactory.*;
import org.maplibre.android.style.layers.TransitionOptions;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import timber.log.Timber;
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
import static com.mapbox.mapboxsdk.style.layers.Property.RASTER_RESAMPLING_LINEAR;
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterBrightnessMax;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterBrightnessMin;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterContrast;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterFadeDuration;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterHueRotate;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterOpacity;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterResampling;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterSaturation;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
/**
* Basic smoke tests for RasterLayer
*/

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.testapp.style;
package org.maplibre.android.testapp.style;
import android.graphics.Color;
import android.graphics.PointF;
@@ -8,20 +8,20 @@ import androidx.test.espresso.UiController;
import androidx.test.espresso.ViewAction;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.mapboxsdk.style.layers.CannotAddLayerException;
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
import com.mapbox.mapboxsdk.style.layers.FillLayer;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.layers.LineLayer;
import com.mapbox.mapboxsdk.style.layers.Property;
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
import com.mapbox.mapboxsdk.style.sources.CannotAddSourceException;
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
import com.mapbox.mapboxsdk.style.sources.RasterSource;
import com.mapbox.mapboxsdk.style.sources.Source;
import com.mapbox.mapboxsdk.style.sources.VectorSource;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest;
import org.maplibre.android.style.layers.CannotAddLayerException;
import org.maplibre.android.style.layers.CircleLayer;
import org.maplibre.android.style.layers.FillLayer;
import org.maplibre.android.style.layers.Layer;
import org.maplibre.android.style.layers.LineLayer;
import org.maplibre.android.style.layers.Property;
import org.maplibre.android.style.layers.PropertyFactory;
import org.maplibre.android.style.sources.CannotAddSourceException;
import org.maplibre.android.style.sources.GeoJsonSource;
import org.maplibre.android.style.sources.RasterSource;
import org.maplibre.android.style.sources.Source;
import org.maplibre.android.style.sources.VectorSource;
import org.maplibre.android.testapp.R;
import org.maplibre.android.testapp.activity.EspressoTest;
import org.hamcrest.Matcher;
import org.junit.Assert;
@@ -35,7 +35,7 @@ import timber.log.Timber;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
import static org.maplibre.android.testapp.action.MapLibreMapAction.invoke;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -56,7 +56,7 @@ public class RuntimeStyleTests extends EspressoTest {
@Override
public void perform(UiController uiController, View view) {
List<Layer> layers = mapboxMap.getStyle().getLayers();
List<Layer> layers = maplibreMap.getStyle().getLayers();
assertNotNull(layers);
assertTrue(layers.size() > 0);
for (Layer layer : layers) {
@@ -79,12 +79,12 @@ public class RuntimeStyleTests extends EspressoTest {
onView(withId(R.id.mapView)).perform(new BaseViewAction() {
@Override
public void perform(UiController uiController, View view) {
List<Layer> layers = mapboxMap.getStyle().getLayers();
Source source = mapboxMap.getStyle().getSources().get(0);
List<Layer> layers = maplibreMap.getStyle().getLayers();
Source source = maplibreMap.getStyle().getSources().get(0);
// Test inserting with invalid above-id
try {
mapboxMap.getStyle().addLayerAbove(
maplibreMap.getStyle().addLayerAbove(
new CircleLayer("invalid-id-layer-test", source.getId()), "no-such-layer-here-man"
);
fail("Should have thrown exception");
@@ -95,14 +95,14 @@ public class RuntimeStyleTests extends EspressoTest {
// Insert as last
CircleLayer last = new CircleLayer("this is the last one", source.getId());
mapboxMap.getStyle().addLayerAbove(last, layers.get(layers.size() - 1).getId());
layers = mapboxMap.getStyle().getLayers();
maplibreMap.getStyle().addLayerAbove(last, layers.get(layers.size() - 1).getId());
layers = maplibreMap.getStyle().getLayers();
assertEquals(last.getId(), layers.get(layers.size() - 1).getId());
// Insert
CircleLayer second = new CircleLayer("this is the second one", source.getId());
mapboxMap.getStyle().addLayerAbove(second, layers.get(0).getId());
layers = mapboxMap.getStyle().getLayers();
maplibreMap.getStyle().addLayerAbove(second, layers.get(0).getId());
layers = maplibreMap.getStyle().getLayers();
assertEquals(second.getId(), layers.get(1).getId());
}
});
@@ -116,14 +116,14 @@ public class RuntimeStyleTests extends EspressoTest {
@Override
public void perform(UiController uiController, View view) {
// Remove by index
Layer firstLayer = mapboxMap.getStyle().getLayers().get(0);
boolean removed = mapboxMap.getStyle().removeLayerAt(0);
Layer firstLayer = maplibreMap.getStyle().getLayers().get(0);
boolean removed = maplibreMap.getStyle().removeLayerAt(0);
assertTrue(removed);
assertNotNull(firstLayer);
// Test remove by index bounds checks
Timber.i("Remove layer at index > size");
assertFalse(mapboxMap.getStyle().removeLayerAt(Integer.MAX_VALUE));
assertFalse(maplibreMap.getStyle().removeLayerAt(Integer.MAX_VALUE));
}
});
}
@@ -133,12 +133,12 @@ public class RuntimeStyleTests extends EspressoTest {
onView(withId(R.id.mapView)).perform(new BaseViewAction() {
@Override
public void perform(UiController uiController, View view) {
List<Layer> layers = mapboxMap.getStyle().getLayers();
Source source = mapboxMap.getStyle().getSources().get(0);
List<Layer> layers = maplibreMap.getStyle().getLayers();
Source source = maplibreMap.getStyle().getSources().get(0);
// Test inserting out of range
try {
mapboxMap.getStyle().addLayerAt(new CircleLayer("invalid-id-layer-test", source.getId()), layers.size());
maplibreMap.getStyle().addLayerAt(new CircleLayer("invalid-id-layer-test", source.getId()), layers.size());
fail("Should have thrown exception");
} catch (CannotAddLayerException ex) {
// Yeah
@@ -147,14 +147,14 @@ public class RuntimeStyleTests extends EspressoTest {
// Insert at current last position
CircleLayer last = new CircleLayer("this is the last one", source.getId());
mapboxMap.getStyle().addLayerAt(last, layers.size() - 1);
layers = mapboxMap.getStyle().getLayers();
maplibreMap.getStyle().addLayerAt(last, layers.size() - 1);
layers = maplibreMap.getStyle().getLayers();
assertEquals(last.getId(), layers.get(layers.size() - 2).getId());
// Insert at start
CircleLayer second = new CircleLayer("this is the first one", source.getId());
mapboxMap.getStyle().addLayerAt(second, 0);
layers = mapboxMap.getStyle().getLayers();
maplibreMap.getStyle().addLayerAt(second, 0);
layers = maplibreMap.getStyle().getLayers();
assertEquals(second.getId(), layers.get(0).getId());
}
});
@@ -168,7 +168,7 @@ public class RuntimeStyleTests extends EspressoTest {
@Override
public void perform(UiController uiController, View view) {
List<Source> sources = mapboxMap.getStyle().getSources();
List<Source> sources = maplibreMap.getStyle().getSources();
assertNotNull(sources);
assertTrue(sources.size() > 0);
for (Source source : sources) {
@@ -182,7 +182,7 @@ public class RuntimeStyleTests extends EspressoTest {
@Test
public void testAddRemoveSource() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
mapboxMap.getStyle().addSource(new VectorSource("my-source", "maptiler://sources/hillshades"));
mapboxMap.getStyle().removeSource("my-source");
@@ -222,7 +222,7 @@ public class RuntimeStyleTests extends EspressoTest {
@Test
public void testVectorSourceUrlGetter() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
VectorSource source = new VectorSource("my-source", "maptiler://sources/hillshades");
mapboxMap.getStyle().addSource(source);
assertEquals("maptiler://sources/hillshades", source.getUri());
@@ -232,7 +232,7 @@ public class RuntimeStyleTests extends EspressoTest {
@Test
public void testRasterSourceUrlGetter() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
RasterSource source = new RasterSource("my-source", "maptiler://sources/hillshades");
mapboxMap.getStyle().addSource(source);
assertEquals("maptiler://sources/hillshades", source.getUri());
@@ -242,7 +242,7 @@ public class RuntimeStyleTests extends EspressoTest {
@Test
public void testGeoJsonSourceUrlGetter() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
GeoJsonSource source = new GeoJsonSource("my-source");
mapboxMap.getStyle().addSource(source);
assertNull(source.getUri());
@@ -259,10 +259,10 @@ public class RuntimeStyleTests extends EspressoTest {
@Override
public void perform(UiController uiController, View view) {
mapboxMap.getStyle().addSource(new VectorSource("my-source", "maptiler://sources/hillshades"));
mapboxMap.getStyle().addLayer(new LineLayer("my-layer", "my-source"));
mapboxMap.getStyle().removeSource("my-source");
assertNotNull(mapboxMap.getStyle().getSource("my-source"));
maplibreMap.getStyle().addSource(new VectorSource("my-source", "maptiler://sources/hillshades"));
maplibreMap.getStyle().addLayer(new LineLayer("my-layer", "my-source"));
maplibreMap.getStyle().removeSource("my-source");
assertNotNull(maplibreMap.getStyle().getSource("my-source"));
}
});
@@ -270,12 +270,12 @@ public class RuntimeStyleTests extends EspressoTest {
@Test
public void testRemoveNonExistingSource() {
invoke(mapboxMap, (uiController, mapboxMap) -> mapboxMap.getStyle().removeSource("source"));
invoke(maplibreMap, (uiController, mapboxMap) -> mapboxMap.getStyle().removeSource("source"));
}
@Test
public void testRemoveNonExistingLayer() {
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
assertFalse(mapboxMap.getStyle().removeLayer("layer"));
assertFalse(mapboxMap.getStyle().removeLayerAt(mapboxMap.getStyle().getLayers().size() + 1));
assertFalse(mapboxMap.getStyle().removeLayerAt(-1));
@@ -284,7 +284,7 @@ public class RuntimeStyleTests extends EspressoTest {
@Test
public void testRemoveExistingLayer() {
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, mapboxMap) -> {
Layer firstLayer = mapboxMap.getStyle().getLayers().get(0);
assertTrue(mapboxMap.getStyle().removeLayer(firstLayer));
@@ -309,7 +309,7 @@ public class RuntimeStyleTests extends EspressoTest {
for (int i = 0; i < layerIds.length; i++) {
layerIds[i] = "layer-" + i;
}
mapboxMap.queryRenderedFeatures(new PointF(100, 100), layerIds);
maplibreMap.queryRenderedFeatures(new PointF(100, 100), layerIds);
}
});
@@ -320,37 +320,37 @@ public class RuntimeStyleTests extends EspressoTest {
@Override
public void perform(UiController uiController, View view) {
// Get initial
assertNotNull(mapboxMap.getStyle().getLayer("building"));
assertNotNull(maplibreMap.getStyle().getLayer("building"));
// Remove
boolean removed = mapboxMap.getStyle().removeLayer("building");
boolean removed = maplibreMap.getStyle().removeLayer("building");
assertTrue(removed);
assertNull(mapboxMap.getStyle().getLayer("building"));
assertNull(maplibreMap.getStyle().getLayer("building"));
// Add
FillLayer layer = new FillLayer("building", "composite");
layer.setSourceLayer("building");
mapboxMap.getStyle().addLayer(layer);
assertNotNull(mapboxMap.getStyle().getLayer("building"));
maplibreMap.getStyle().addLayer(layer);
assertNotNull(maplibreMap.getStyle().getLayer("building"));
// Assure the reference still works
layer.setProperties(PropertyFactory.visibility(Property.VISIBLE));
// Remove, preserving the reference
mapboxMap.getStyle().removeLayer(layer);
maplibreMap.getStyle().removeLayer(layer);
// Property setters should still work
layer.setProperties(PropertyFactory.fillColor(Color.RED));
// Re-add the reference...
mapboxMap.getStyle().addLayer(layer);
maplibreMap.getStyle().addLayer(layer);
// Ensure it's there
Assert.assertNotNull(mapboxMap.getStyle().getLayer(layer.getId()));
Assert.assertNotNull(maplibreMap.getStyle().getLayer(layer.getId()));
// Test adding a duplicate layer
try {
mapboxMap.getStyle().addLayer(new FillLayer("building", "composite"));
maplibreMap.getStyle().addLayer(new FillLayer("building", "composite"));
fail("Should not have been allowed to add a layer with a duplicate id");
} catch (CannotAddLayerException cannotAddLayerException) {
// OK

View File

@@ -1,9 +1,9 @@
package com.mapbox.mapboxsdk.testapp.style;
package org.maplibre.android.testapp.style;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.mapboxsdk.testapp.activity.BaseTest;
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTimingTestActivity;
import org.maplibre.android.testapp.activity.BaseTest;
import org.maplibre.android.testapp.activity.style.RuntimeStyleTimingTestActivity;
import org.junit.Test;
import org.junit.runner.RunWith;

View File

@@ -1,14 +1,14 @@
package com.mapbox.mapboxsdk.testapp.style
package org.maplibre.android.testapp.style
import android.view.View
import androidx.test.espresso.UiController
import com.mapbox.mapboxsdk.maps.MapView
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.maps.Style
import com.mapbox.mapboxsdk.testapp.R
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction
import com.mapbox.mapboxsdk.testapp.activity.EspressoTest
import com.mapbox.mapboxsdk.testapp.utils.ResourceUtils.readRawResource
import org.maplibre.android.maps.MapView
import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.action.MapLibreMapAction
import org.maplibre.android.testapp.activity.EspressoTest
import org.maplibre.android.testapp.utils.ResourceUtils.readRawResource
import org.junit.Assert
import org.junit.Test
import java.io.IOException
@@ -20,17 +20,17 @@ class StyleLoaderTest : EspressoTest() {
@Test
fun testSetGetStyleJsonString() {
validateTestSetup()
MapboxMapAction.invoke(
mapboxMap
) { uiController: UiController?, mapboxMap: MapboxMap ->
MapLibreMapAction.invoke(
maplibreMap
) { uiController: UiController?, maplibreMap: MapLibreMap ->
try {
val expected =
readRawResource(
rule.activity,
R.raw.local_style
)
mapboxMap.setStyle(Style.Builder().fromJson(expected))
val actual = mapboxMap.style!!.json
maplibreMap.setStyle(Style.Builder().fromJson(expected))
val actual = maplibreMap.style!!.json
Assert.assertEquals("Style json should match", expected, actual)
} catch (exception: IOException) {
exception.printStackTrace()
@@ -41,16 +41,16 @@ class StyleLoaderTest : EspressoTest() {
@Test
fun testDefaultStyleLoadWithActivityLifecycleChange() {
validateTestSetup()
MapboxMapAction.invoke(
mapboxMap
) { uiController: UiController?, mapboxMap: MapboxMap ->
MapLibreMapAction.invoke(
maplibreMap
) { uiController: UiController?, maplibreMap: MapLibreMap ->
try {
val expected =
readRawResource(
rule.activity,
R.raw.local_style
)
mapboxMap.setStyle(Style.Builder().fromJson(expected))
maplibreMap.setStyle(Style.Builder().fromJson(expected))
// fake activity stop/start
val mapView =
@@ -59,11 +59,11 @@ class StyleLoaderTest : EspressoTest() {
mapView.onStop()
mapView.onStart()
mapView.onResume()
val actual = mapboxMap.style!!.json
val actual = maplibreMap.style!!.json
Assert.assertEquals(
"Style URL should be empty",
"",
mapboxMap.style!!.uri
maplibreMap.style!!.uri
)
Assert.assertEquals("Style json should match", expected, actual)
} catch (exception: IOException) {

View File

@@ -1,9 +1,8 @@
// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
package com.mapbox.mapboxsdk.testapp.style;
package org.maplibre.android.testapp.style;
import android.graphics.Color;
import androidx.test.annotation.UiThreadTest;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
@@ -13,110 +12,28 @@ import com.mapbox.geojson.MultiPoint;
import com.mapbox.geojson.MultiPolygon;
import com.mapbox.geojson.Point;
import com.mapbox.geojson.Polygon;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import com.mapbox.mapboxsdk.style.types.Formatted;
import com.mapbox.mapboxsdk.style.types.FormattedSection;
import org.maplibre.android.maps.BaseLayerTest;
import org.junit.Before;
import timber.log.Timber;
import org.maplibre.android.style.expressions.Expression;
import org.maplibre.android.style.layers.SymbolLayer;
import org.maplibre.android.style.types.Formatted;
import org.maplibre.android.style.types.FormattedSection;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.maplibre.android.style.expressions.Expression.*;
import static org.junit.Assert.*;
import static org.maplibre.android.style.layers.Property.*;
import static org.maplibre.android.style.layers.PropertyFactory.*;
import org.maplibre.android.style.layers.TransitionOptions;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import timber.log.Timber;
import static com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption;
import static com.mapbox.mapboxsdk.style.expressions.Expression.distance;
import static com.mapbox.mapboxsdk.style.expressions.Expression.eq;
import static com.mapbox.mapboxsdk.style.expressions.Expression.format;
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
import static com.mapbox.mapboxsdk.style.expressions.Expression.image;
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
import static com.mapbox.mapboxsdk.style.expressions.Expression.lt;
import static com.mapbox.mapboxsdk.style.expressions.Expression.number;
import static com.mapbox.mapboxsdk.style.expressions.Expression.string;
import static com.mapbox.mapboxsdk.style.expressions.Expression.toColor;
import static com.mapbox.mapboxsdk.style.expressions.Expression.within;
import static com.mapbox.mapboxsdk.style.layers.Property.ICON_ANCHOR_CENTER;
import static com.mapbox.mapboxsdk.style.layers.Property.ICON_PITCH_ALIGNMENT_MAP;
import static com.mapbox.mapboxsdk.style.layers.Property.ICON_ROTATION_ALIGNMENT_MAP;
import static com.mapbox.mapboxsdk.style.layers.Property.ICON_TEXT_FIT_NONE;
import static com.mapbox.mapboxsdk.style.layers.Property.ICON_TRANSLATE_ANCHOR_MAP;
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
import static com.mapbox.mapboxsdk.style.layers.Property.SYMBOL_PLACEMENT_POINT;
import static com.mapbox.mapboxsdk.style.layers.Property.SYMBOL_Z_ORDER_AUTO;
import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_ANCHOR_CENTER;
import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_JUSTIFY_AUTO;
import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_PITCH_ALIGNMENT_MAP;
import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_ROTATION_ALIGNMENT_MAP;
import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_TRANSFORM_NONE;
import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_TRANSLATE_ANCHOR_MAP;
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconAllowOverlap;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconAnchor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconHaloBlur;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconHaloColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconHaloWidth;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconIgnorePlacement;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconKeepUpright;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconOffset;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconOpacity;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconOptional;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconPadding;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconPitchAlignment;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconRotate;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconRotationAlignment;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconSize;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTextFit;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTextFitPadding;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTranslate;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTranslateAnchor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolAvoidEdges;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolPlacement;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolSortKey;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolSpacing;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolZOrder;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textAllowOverlap;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textAnchor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textField;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textFont;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textHaloBlur;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textHaloColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textHaloWidth;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textIgnorePlacement;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textJustify;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textKeepUpright;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textLetterSpacing;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textLineHeight;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textMaxAngle;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textMaxWidth;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textOffset;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textOpacity;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textOptional;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textPadding;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textPitchAlignment;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textRadialOffset;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textRotate;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textRotationAlignment;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textSize;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textTransform;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textTranslate;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textTranslateAnchor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textVariableAnchor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textWritingMode;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
/**
* Basic smoke tests for SymbolLayer
*/

View File

@@ -5,47 +5,47 @@
// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
<% if (type === 'location-indicator') { -%>
package com.mapbox.mapboxsdk.location;
package org.maplibre.android.location;
<% } else { -%>
package com.mapbox.mapboxsdk.testapp.style;
package org.maplibre.android.testapp.style;
<% } -%>
import android.graphics.Color;
import androidx.test.annotation.UiThreadTest;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import com.mapbox.geojson.LineString;
import com.mapbox.geojson.MultiLineString;
import com.mapbox.geojson.MultiPoint;
import com.mapbox.geojson.MultiPolygon;
import com.mapbox.geojson.Point;
import com.mapbox.geojson.Polygon;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
import com.maplibre.geojson.LineString;
import com.maplibre.geojson.MultiLineString;
import com.maplibre.geojson.MultiPoint;
import com.maplibre.geojson.MultiPolygon;
import com.maplibre.geojson.Point;
import com.maplibre.geojson.Polygon;
import org.maplibre.android.maps.BaseLayerTest;
import org.junit.Before;
import timber.log.Timber;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import org.maplibre.android.style.expressions.Expression;
<% if (type !== 'location-indicator') { -%>
import com.mapbox.mapboxsdk.style.layers.<%- camelize(type) %>Layer;
import org.maplibre.android.style.layers.<%- camelize(type) %>Layer;
<% } -%>
<% if (type === 'symbol') { -%>
import com.mapbox.mapboxsdk.style.types.Formatted;
import com.mapbox.mapboxsdk.style.types.FormattedSection;
import org.maplibre.android.style.types.Formatted;
import org.maplibre.android.style.types.FormattedSection;
<% } -%>
import org.junit.Test;
import org.junit.runner.RunWith;
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
import static org.maplibre.android.style.expressions.Expression.*;
import static org.junit.Assert.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static org.maplibre.android.style.layers.Property.*;
<% if (type === 'location-indicator') { -%>
import static com.mapbox.mapboxsdk.location.LocationPropertyFactory.*;
import static org.maplibre.android.location.LocationPropertyFactory.*;
<% } else { -%>
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
import static org.maplibre.android.style.layers.PropertyFactory.*;
<% } -%>
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import org.maplibre.android.style.layers.TransitionOptions;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

View File

@@ -0,0 +1,68 @@
<% const properties = locals.properties; -%> package
org.maplibre.android.testapp.style; import android.graphics.Color; import
androidx.test.espresso.UiController; import androidx.test.espresso.ViewAction;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner; import
android.view.View; import org.maplibre.android.style.light.Light; import
org.maplibre.android.style.expressions.Expression; import
org.maplibre.android.style.layers.FillExtrusionLayer; import
org.maplibre.android.style.layers.TransitionOptions; import
org.maplibre.android.style.light.Position; import
org.maplibre.android.testapp.R; import
org.maplibre.android.testapp.activity.BaseTest; import
org.maplibre.android.testapp.activity.style.FillExtrusionStyleTestActivity;
import timber.log.Timber; import org.hamcrest.Matcher; import org.junit.Test;
import org.junit.runner.RunWith; import static
androidx.test.espresso.Espresso.onView; import static
androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static
androidx.test.espresso.matcher.ViewMatchers.withId; import static
org.maplibre.android.style.expressions.Expression.eq; import static
org.maplibre.android.style.layers.Property.ANCHOR_MAP; import static
org.maplibre.android.style.layers.PropertyFactory.fillExtrusionBase; import
static org.maplibre.android.style.layers.PropertyFactory.fillExtrusionColor;
import static
org.maplibre.android.style.layers.PropertyFactory.fillExtrusionHeight; import
static org.maplibre.android.style.layers.PropertyFactory.fillExtrusionOpacity;
import static org.maplibre.android.testapp.action.MapLibreMapAction.invoke;
import static org.junit.Assert.assertEquals; import static
org.junit.Assert.assertNotNull; @RunWith(AndroidJUnit4ClassRunner.class) public
class LightTest extends BaseTest { private Light light; <% for (const property
of properties) { -%> <% if (property.transition) { -%> @Test public void test<%-
camelize(property.name) %>Transition() { validateTestSetup(); setupLight();
Timber.i("<%- property.name %>TransitionOptions"); invoke(maplibreMap,
(uiController, maplibreMap) -> { assertNotNull(light); // Set and Get
TransitionOptions options = new TransitionOptions(300, 100); light.set<%-
camelize(property.name) %>Transition(options); assertEquals("Transition options
should match", options, light.get<%- camelize(property.name) %>Transition());
}); } <% } -%> <% if (property.name == "position") { -%> @Test public void
test<%- camelize(property.name) %>() { validateTestSetup(); setupLight();
Timber.i("<%- property.name %>"); invoke(maplibreMap,(uiController, maplibreMap)
-> { assertNotNull(light); // Set and Get Position position = new Position(1, 2,
3); light.set<%- camelize(property.name) %>(position); assertEquals("Position
should match", position, light.get<%- camelize(property.name) %>()); }); } <% }
else { -%> @Test public void test<%- camelize(property.name) %>() {
validateTestSetup(); setupLight(); Timber.i("<%- property.name %>");
invoke(maplibreMap, (uiController, maplibreMap) -> { assertNotNull(light); //
Set and Get light.set<%- camelize(property.name) %>(<%-
defaultValueJava(property) %>); <% if (property.name == 'color') { -%>
assertEquals("<%- camelize(property.name) %> should match", <%-
defaultValueJava(property) %>, light.get<%- camelize(property.name) %>()); <% }
else { -%> assertEquals("<%- camelize(property.name) %> should match", <%-
defaultValueJava(property) %>, light.get<%- camelize(property.name) %>()); <% }
-%> }); } <% } -%> <% } -%> private void setupLight() {
onView(withId(R.id.mapView)).perform(new ViewAction() { @Override public
Matcher<View>
getConstraints() { return isDisplayed(); } @Override public String
getDescription() { return getClass().getSimpleName(); } @Override public void
perform(UiController uiController, View view) { light =
maplibreMap.getStyle().getLight(); FillExtrusionLayer fillExtrusionLayer = new
FillExtrusionLayer("3d-buildings", "composite");
fillExtrusionLayer.setSourceLayer("building");
fillExtrusionLayer.setFilter(eq(Expression.get("extrude"), "true"));
fillExtrusionLayer.setMinZoom(15); fillExtrusionLayer.setProperties(
fillExtrusionColor(Color.LTGRAY),
fillExtrusionHeight(Expression.get("height")),
fillExtrusionBase(Expression.get("min_height")), fillExtrusionOpacity(0.6f) );
maplibreMap.getStyle().addLayer(fillExtrusionLayer); } }); } @Override
protected Class getActivityClass() { return
FillExtrusionStyleTestActivity.class; } }</View
>

View File

@@ -1,8 +1,8 @@
package com.mapbox.mapboxsdk.testapp.utils;
package org.maplibre.android.testapp.utils;
import androidx.test.espresso.IdlingResource;
import com.mapbox.mapboxsdk.testapp.activity.render.RenderTestActivity;
import org.maplibre.android.testapp.activity.render.RenderTestActivity;
public class SnapshotterIdlingResource implements IdlingResource, RenderTestActivity.OnRenderTestCompletionListener {

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.testapp.utils;
package org.maplibre.android.testapp.utils;
public class TestConstants {
public static final double LAT_LNG_DELTA = 0.1;

View File

@@ -1,7 +1,7 @@
package com.mapbox.mapboxsdk.testapp.utils
package org.maplibre.android.testapp.utils
import androidx.test.espresso.UiController
import com.mapbox.mapboxsdk.maps.MapView
import org.maplibre.android.maps.MapView
object TestingAsyncUtils {
private const val DEFAULT_TIMEOUT = 15_000L

View File

@@ -1,7 +1,7 @@
package com.mapbox.mapboxsdk.utils
package org.maplibre.android.utils
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import com.mapbox.mapboxsdk.constants.MapboxConstants
import org.maplibre.android.constants.MapLibreConstants
import org.junit.Assert
import org.junit.Test
import org.junit.runner.RunWith
@@ -12,7 +12,7 @@ class FontUtilsTest {
fun testExtractedFontShouldMatchDefault() {
val fonts = arrayOf("foo", "bar")
val actual = FontUtils.extractValidFont(*fonts)
Assert.assertEquals("Selected font should match", MapboxConstants.DEFAULT_FONT, actual)
Assert.assertEquals("Selected font should match", MapLibreConstants.DEFAULT_FONT, actual)
}
@Test