summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-05-09 16:01:38 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-05-09 16:48:08 +0300
commit842ee6b6f5e9cb17cff4654a8f7cbcacea72fdfd (patch)
treefd3a5da2f194eeda1e5764e4f18d815d50eb2135
parentc953fdad24379c20f9e5bccc3f40481bffc25df2 (diff)
downloadqtlocation-mapboxgl-842ee6b6f5e9cb17cff4654a8f7cbcacea72fdfd.tar.gz
[android] Update ImageMissingTest
Make sure that the `addOnStyleImageMissingListener` callback is invoked for missing images if sprite request has failed.
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/ImageMissingTest.kt60
1 files changed, 55 insertions, 5 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/ImageMissingTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/ImageMissingTest.kt
index c4ea4d2c19..ff862b6636 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/ImageMissingTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/ImageMissingTest.kt
@@ -22,12 +22,19 @@ class ImageMissingTest {
var rule = ActivityTestRule(EspressoTestActivity::class.java)
private lateinit var mapView: MapView
- private val latch = CountDownLatch(1)
+ private val latch = CountDownLatch(2)
@Test
fun testMissingImage() {
rule.runOnUiThread {
- initMap().addOnStyleImageMissingListener {
+ initMap(styleJson).addOnStyleImageMissingListener {
+ assertEquals("missing-icon", it)
+ latch.countDown()
+ }
+ }
+
+ rule.runOnUiThread {
+ initMap(styleJsonInvalidSprite).addOnStyleImageMissingListener {
assertEquals("missing-icon", it)
latch.countDown()
}
@@ -38,9 +45,9 @@ class ImageMissingTest {
}
}
- private fun initMap(): MapView {
+ private fun initMap(style :String): MapView {
mapView = rule.activity.findViewById(R.id.mapView)
- mapView.getMapAsync { it.setStyle(Style.Builder().fromJson(styleJson)) }
+ mapView.getMapAsync { it.setStyle(Style.Builder().fromJson(style)) }
return mapView
}
@@ -87,5 +94,48 @@ class ImageMissingTest {
}]
}
"""
+
+ private const val styleJsonInvalidSprite = """
+ {
+ "version": 8,
+ "name": "Mapbox Streets",
+ "sprite": "mapbox://sprites/mapbox/invalid",
+ "glyphs": "mapbox://fonts/mapbox/{fontstack}/{range}.pbf",
+ "sources": {
+ "point": {
+ "type": "geojson",
+ "data": {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Point",
+ "coordinates": [0, 0]
+ }
+ }
+ }
+ },
+ "layers": [{
+ "id": "bg",
+ "type": "background",
+ "paint": {
+ "background-color": "#f00"
+ }
+ }, {
+ "id": "point",
+ "type": "circle",
+ "source": "point",
+ "paint": {
+ "circle-radius": 100
+ }
+ }, {
+ "id": "icon",
+ "type": "symbol",
+ "source": "point",
+ "layout": {
+ "icon-image": "missing-icon"
+ }
+ }]
+ }
+ """
}
-} \ No newline at end of file
+}