[android] - introduce validateState, add illegal state exception to all invocations, add test

This commit is contained in:
tobrun
2018-12-10 13:23:42 +01:00
committed by Tobrun
parent a018c0f7b5
commit 16aa48151c
2 changed files with 55 additions and 129 deletions

View File

@@ -14,6 +14,7 @@ import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import java.lang.IllegalStateException
@RunWith(RobolectricTestRunner::class)
class StyleTest {
@@ -304,4 +305,15 @@ class StyleTest {
mapboxMap.setStyle(Style.MAPBOX_STREETS)
verify(exactly = 1) { callback.onStyleLoaded(any()) }
}
@Test(expected = IllegalStateException::class)
fun testIllegalStateExceptionWithStyleReload() {
val builder = Style.Builder().fromUrl(Style.MAPBOX_STREETS)
mapboxMap.setStyle(builder)
mapboxMap.notifyStyleLoaded()
val style = mapboxMap.style
mapboxMap.setStyle(Style.Builder().fromUrl(Style.DARK))
style!!.addLayer(mockk<SymbolLayer>())
}
}