[android] clear up LocationComponent's z-index positioning docs and add "layer-above" option
This commit is contained in:
committed by
Łukasz Paczos
parent
a67b3fc759
commit
50483cafa6
@@ -67,4 +67,15 @@ public class LocationComponentOptionsTest {
|
||||
.elevation(-500)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void passingBothLayerPositionOptions_throwsException() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("You cannot set both layerAbove and layerBelow options."
|
||||
+ "Choose one or the other.");
|
||||
LocationComponentOptions.builder(context)
|
||||
.layerAbove("above")
|
||||
.layerBelow("below")
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package com.mapbox.mapboxsdk.location
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.Style
|
||||
import com.mapbox.mapboxsdk.style.layers.Layer
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import junit.framework.Assert.assertFalse
|
||||
import junit.framework.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.junit.MockitoJUnitRunner
|
||||
|
||||
@RunWith(MockitoJUnitRunner::class)
|
||||
class LocationComponentPositionManagerTest {
|
||||
|
||||
private lateinit var style: Style
|
||||
private lateinit var layer: Layer
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
style = mockk(relaxed = true)
|
||||
layer = mockk(relaxed = true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun update_noChange_null() {
|
||||
val positionManager = LocationComponentPositionManager(style, null, null)
|
||||
val requiresUpdate = positionManager.update(null, null)
|
||||
assertFalse(requiresUpdate)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun update_noChange_above() {
|
||||
val positionManager = LocationComponentPositionManager(style, "above", null)
|
||||
val requiresUpdate = positionManager.update("above", null)
|
||||
assertFalse(requiresUpdate)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun update_noChange_below() {
|
||||
val positionManager = LocationComponentPositionManager(style, null, "below")
|
||||
val requiresUpdate = positionManager.update(null, "below")
|
||||
assertFalse(requiresUpdate)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun update_fromNull_above() {
|
||||
val positionManager = LocationComponentPositionManager(style, null, null)
|
||||
val requiresUpdate = positionManager.update("above", null)
|
||||
assertTrue(requiresUpdate)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun update_fromNull_below() {
|
||||
val positionManager = LocationComponentPositionManager(style, null, null)
|
||||
val requiresUpdate = positionManager.update(null, "below")
|
||||
assertTrue(requiresUpdate)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun update_toNull_above() {
|
||||
val positionManager = LocationComponentPositionManager(style, "above", null)
|
||||
val requiresUpdate = positionManager.update(null, null)
|
||||
assertTrue(requiresUpdate)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun update_toNull_below() {
|
||||
val positionManager = LocationComponentPositionManager(style, null, "below")
|
||||
val requiresUpdate = positionManager.update(null, null)
|
||||
assertTrue(requiresUpdate)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun update_fromValue_above() {
|
||||
val positionManager = LocationComponentPositionManager(style, "above1", null)
|
||||
val requiresUpdate = positionManager.update("above2", null)
|
||||
assertTrue(requiresUpdate)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun update_fromValue_below() {
|
||||
val positionManager = LocationComponentPositionManager(style, null, "below1")
|
||||
val requiresUpdate = positionManager.update(null, "below2")
|
||||
assertTrue(requiresUpdate)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun addLayer_noModifier() {
|
||||
val positionManager = LocationComponentPositionManager(style, null, null)
|
||||
positionManager.addLayerToMap(layer)
|
||||
|
||||
verify { style.addLayer(layer) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun addLayer_above() {
|
||||
val positionManager = LocationComponentPositionManager(style, "above", null)
|
||||
positionManager.addLayerToMap(layer)
|
||||
|
||||
verify { style.addLayerAbove(layer, "above") }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun addLayer_below() {
|
||||
val positionManager = LocationComponentPositionManager(style, null, "below")
|
||||
positionManager.addLayerToMap(layer)
|
||||
|
||||
verify { style.addLayerBelow(layer, "below") }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun addLayer_afterUpdate_above() {
|
||||
val positionManager = LocationComponentPositionManager(style, null, null)
|
||||
positionManager.update("above", null)
|
||||
positionManager.addLayerToMap(layer)
|
||||
|
||||
verify { style.addLayerAbove(layer, "above") }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun addLayer_afterUpdate_below() {
|
||||
val positionManager = LocationComponentPositionManager(style, null, null)
|
||||
positionManager.update(null, "below")
|
||||
positionManager.addLayerToMap(layer)
|
||||
|
||||
verify { style.addLayerBelow(layer, "below") }
|
||||
}
|
||||
}
|
||||
@@ -400,7 +400,8 @@ public class LocationLayerControllerTest {
|
||||
layerController.applyStyle(options);
|
||||
|
||||
verify(style, times(0)).removeLayer(any(String.class));
|
||||
verify(style, times(5)).addLayerBelow(any(Layer.class), Mockito.<String>any());
|
||||
verify(style, times(1)).addLayer(any(Layer.class));
|
||||
verify(style, times(4)).addLayerBelow(any(Layer.class), Mockito.<String>any());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user