Toggle tile cache final API (#2723)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bart Louwers <bart.louwers@gmail.com>
This commit is contained in:
Alex Cristici
2024-08-21 00:28:00 +03:00
committed by GitHub
parent d544da140b
commit a4258ccbb8
21 changed files with 170 additions and 63 deletions

View File

@@ -32,12 +32,12 @@ import org.maplibre.android.testapp.activity.EspressoTest
* with the application UI-thread.
*
*/
@Deprecated("remove this file when removing deprecated annotations")
class MapLibreMapTest : EspressoTest() {
//
// InfoWindow
//
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testConcurrentInfoWindowEnabled() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -47,6 +47,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testConcurrentInfoWindowDisabled() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -56,6 +57,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testInfoWindowAdapter() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -69,6 +71,7 @@ class MapLibreMapTest : EspressoTest() {
// Annotations
//
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testAddMarker() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -79,11 +82,13 @@ class MapLibreMapTest : EspressoTest() {
}
@Test(expected = InvalidMarkerPositionException::class)
@Deprecated("remove this test when removing deprecated annotations")
fun testAddMarkerInvalidPosition() {
MarkerOptions().marker
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testAddMarkers() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -100,6 +105,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testAddMarkersEmpty() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -110,6 +116,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testAddMarkersSingleMarker() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -123,6 +130,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testAddPolygon() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -133,6 +141,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testAddEmptyPolygon() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -143,6 +152,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testAddPolygons() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -162,6 +172,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun addPolygonsEmpty() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -171,6 +182,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun addPolygonsSingle() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -184,6 +196,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testAddPolyline() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -194,6 +207,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testAddEmptyPolyline() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -204,6 +218,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testAddPolylines() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -219,12 +234,13 @@ class MapLibreMapTest : EspressoTest() {
assertTrue(maplibreMap.polylines.contains(polygonOptions1.polyline))
assertTrue(maplibreMap.polylines.contains(polygonOptions2.polyline))
assertTrue(
"Polyline should be ignored", !maplibreMap.polylines.contains(polygonOptions3.polyline)
"Polyline should be ignored", !maplibreMap.polylines.contains(polygonOptions3.polyline)
)
})
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testAddPolylinesEmpty() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -234,6 +250,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testAddPolylinesSingle() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -247,6 +264,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testRemoveMarker() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -258,6 +276,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testRemovePolygon() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -269,6 +288,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testRemovePolyline() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -280,6 +300,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testRemoveAnnotation() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -291,6 +312,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testRemoveAnnotationById() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -303,6 +325,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testRemoveAnnotations() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -318,6 +341,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testClear() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -333,6 +357,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testRemoveAnnotationsByList() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -350,6 +375,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testGetAnnotationById() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -361,22 +387,25 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testGetAnnotations() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(
MapLibreMapAction { uiController: UiController?, view: View? -> TestCase.assertNotNull("Annotations should be non null", maplibreMap.annotations) }
MapLibreMapAction { uiController: UiController?, view: View? -> TestCase.assertNotNull("Annotations should be non null", maplibreMap.annotations) }
)
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testGetMarkers() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(
MapLibreMapAction { uiController: UiController?, view: View? -> TestCase.assertNotNull("Markers should be non null", maplibreMap.markers) }
MapLibreMapAction { uiController: UiController?, view: View? -> TestCase.assertNotNull("Markers should be non null", maplibreMap.markers) }
)
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testGetPolygons() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? -> TestCase.assertNotNull("Polygons should be non null", maplibreMap.polygons) }
@@ -384,6 +413,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testGetPolylines() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? -> TestCase.assertNotNull("Polylines should be non null", maplibreMap.polylines) }
@@ -391,6 +421,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testGetSelectedMarkers() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? -> TestCase.assertNotNull("Selected markers should be non null", maplibreMap.selectedMarkers) }
@@ -398,6 +429,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testSelectMarker() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -409,6 +441,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testDeselectMarker() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -421,6 +454,7 @@ class MapLibreMapTest : EspressoTest() {
}
@Test
@Deprecated("remove this test when removing deprecated annotations")
fun testDeselectMarkers() {
validateTestSetup()
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
@@ -434,6 +468,19 @@ class MapLibreMapTest : EspressoTest() {
})
}
@Test
fun testTileCache() {
validateTestSetup()
rule.runOnUiThread {
maplibreMap.tileCacheEnabled = false
assertTrue(maplibreMap.tileCacheEnabled == false)
maplibreMap.tileCacheEnabled = true
assertTrue(maplibreMap.tileCacheEnabled == true)
}
}
@Deprecated("remove this class when removing deprecated annotations")
inner class MapLibreMapAction internal constructor(private val invokeViewAction: InvokeViewAction) : ViewAction {
override fun getConstraints(): Matcher<View> {
return ViewMatchers.isDisplayed()
@@ -448,6 +495,7 @@ class MapLibreMapTest : EspressoTest() {
}
}
@Deprecated("remove this interface when removing deprecated annotations")
internal fun interface InvokeViewAction {
fun onViewAction(uiController: UiController?, view: View?)
}