[android] data driven style implementation
This commit is contained in:
committed by
John Firebaugh
parent
8a5bff8ee6
commit
f562ecdfc3
@@ -1,141 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for BackgroundLayer
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class BackgroundLayerStyleTest extends BaseStyleTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private BackgroundLayer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getBackgroundColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundColor(Color.RED));
|
||||
assertEquals(layer.getBackgroundColorAsInt(), Color.RED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundPattern() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-pattern");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundPattern("pedestrian-polygon"));
|
||||
assertEquals((String) layer.getBackgroundPattern().getValue(), (String) "pedestrian-polygon");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundOpacity(0.3f));
|
||||
assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,23 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.functions.CompositeFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.SourceFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CompositeStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
@@ -18,16 +29,14 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import timber.log.Timber;
|
||||
import java.util.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.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 com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for BackgroundLayer
|
||||
@@ -48,17 +57,16 @@ public class BackgroundLayerTest extends BaseStyleTest {
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("visibility");
|
||||
Timber.i("Visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
@@ -70,13 +78,8 @@ public class BackgroundLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundColor() {
|
||||
public void testBackgroundColorAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -86,13 +89,34 @@ public class BackgroundLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundColorAsInt() {
|
||||
public void testBackgroundColorAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("background-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
backgroundColor(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, backgroundColor("rgba(0, 0, 0, 1)"))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
// Verify
|
||||
assertNotNull(layer.getBackgroundColor());
|
||||
assertNotNull(layer.getBackgroundColor().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getBackgroundColor().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getBackgroundColor().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getBackgroundColor().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getBackgroundColor().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundColorAsIntConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("background-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -102,13 +126,8 @@ public class BackgroundLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundPattern() {
|
||||
public void testBackgroundPatternAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-pattern");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -118,13 +137,33 @@ public class BackgroundLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundOpacity() {
|
||||
public void testBackgroundPatternAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("background-pattern");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
backgroundPattern(
|
||||
zoom(
|
||||
interval(
|
||||
stop(2, backgroundPattern("pedestrian-polygon"))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
// Verify
|
||||
assertNotNull(layer.getBackgroundPattern());
|
||||
assertNotNull(layer.getBackgroundPattern().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getBackgroundPattern().getFunction().getClass());
|
||||
assertEquals(IntervalStops.class, layer.getBackgroundPattern().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((IntervalStops) layer.getBackgroundPattern().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundOpacityAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("background-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -133,6 +172,32 @@ public class BackgroundLayerTest extends BaseStyleTest {
|
||||
assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundOpacityAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("background-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
backgroundOpacity(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, backgroundOpacity(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getBackgroundOpacity());
|
||||
assertNotNull(layer.getBackgroundOpacity().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getBackgroundOpacity().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getBackgroundOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getBackgroundOpacity().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getBackgroundOpacity().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
|
||||
@@ -1,265 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
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.circlePitchScale;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for CircleLayer
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class CircleLayerStyleTest extends BaseStyleTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private CircleLayer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircleRadius() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-radius");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(circleRadius(0.3f));
|
||||
assertEquals((Float) layer.getCircleRadius().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircleColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(circleColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getCircleColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircleColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(circleColor(Color.RED));
|
||||
assertEquals(layer.getCircleColorAsInt(), Color.RED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircleBlur() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-blur");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(circleBlur(0.3f));
|
||||
assertEquals((Float) layer.getCircleBlur().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircleOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(circleOpacity(0.3f));
|
||||
assertEquals((Float) layer.getCircleOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircleTranslate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-translate");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(circleTranslate(new Float[] {0f, 0f}));
|
||||
assertEquals((Float[]) layer.getCircleTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircleTranslateAnchor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-translate-anchor");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(circleTranslateAnchor(CIRCLE_TRANSLATE_ANCHOR_MAP));
|
||||
assertEquals((String) layer.getCircleTranslateAnchor().getValue(), (String) CIRCLE_TRANSLATE_ANCHOR_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCirclePitchScale() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-pitch-scale");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(circlePitchScale(CIRCLE_PITCH_SCALE_MAP));
|
||||
assertEquals((String) layer.getCirclePitchScale().getValue(), (String) CIRCLE_PITCH_SCALE_MAP);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,286 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.FillLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
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.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;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for FillLayer
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class FillLayerStyleTest extends BaseStyleTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private FillLayer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillAntialias() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-antialias");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillAntialias(true));
|
||||
assertEquals((Boolean) layer.getFillAntialias().getValue(), (Boolean) true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillOpacity(0.3f));
|
||||
assertEquals((Float) layer.getFillOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getFillColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillColor(Color.RED));
|
||||
assertEquals(layer.getFillColorAsInt(), Color.RED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-outline-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillOutlineColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getFillOutlineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-outline-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillOutlineColor(Color.RED));
|
||||
assertEquals(layer.getFillOutlineColorAsInt(), Color.RED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillTranslate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-translate");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillTranslate(new Float[] {0f, 0f}));
|
||||
assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillTranslateAnchor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-translate-anchor");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP));
|
||||
assertEquals((String) layer.getFillTranslateAnchor().getValue(), (String) FILL_TRANSLATE_ANCHOR_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillPattern() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-pattern");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillPattern("pedestrian-polygon"));
|
||||
assertEquals((String) layer.getFillPattern().getValue(), (String) "pedestrian-polygon");
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,23 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.functions.CompositeFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.SourceFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CompositeStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.layers.FillLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
@@ -18,21 +29,14 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import timber.log.Timber;
|
||||
import java.util.Map;
|
||||
|
||||
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.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 com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for FillLayer
|
||||
@@ -53,12 +57,6 @@ public class FillLayerTest extends BaseStyleTest {
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
@@ -69,7 +67,12 @@ public class FillLayerTest extends BaseStyleTest {
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("Visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
@@ -81,19 +84,8 @@ public class FillLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillAntialias() {
|
||||
public void testFillAntialiasAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-antialias");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -103,19 +95,33 @@ public class FillLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOpacity() {
|
||||
public void testFillAntialiasAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-antialias");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillAntialias(
|
||||
zoom(
|
||||
interval(
|
||||
stop(2, fillAntialias(true))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getFillAntialias());
|
||||
assertNotNull(layer.getFillAntialias().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getFillAntialias().getFunction().getClass());
|
||||
assertEquals(IntervalStops.class, layer.getFillAntialias().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((IntervalStops) layer.getFillAntialias().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOpacityAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -125,19 +131,142 @@ public class FillLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillColor() {
|
||||
public void testFillOpacityAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOpacity(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, fillOpacity(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOpacity());
|
||||
assertNotNull(layer.getFillOpacity().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getFillOpacity().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getFillOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getFillOpacity().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getFillOpacity().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOpacityAsIdentitySourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOpacity(property("FeaturePropertyA", Stops.<Float>identity()))
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOpacity());
|
||||
assertNotNull(layer.getFillOpacity().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillOpacity().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOpacity().getFunction()).getProperty());
|
||||
assertEquals(IdentityStops.class, layer.getFillOpacity().getFunction().getStops().getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOpacityAsExponentialSourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOpacity(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
stop(0.3f, fillOpacity(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOpacity());
|
||||
assertNotNull(layer.getFillOpacity().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillOpacity().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOpacity().getFunction()).getProperty());
|
||||
assertEquals(ExponentialStops.class, layer.getFillOpacity().getFunction().getStops().getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOpacityAsCategoricalSourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOpacity(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
categorical(
|
||||
stop(1.0f, fillOpacity(0.3f))
|
||||
)
|
||||
).withDefaultValue(0.3f)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOpacity());
|
||||
assertNotNull(layer.getFillOpacity().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillOpacity().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOpacity().getFunction()).getProperty());
|
||||
assertEquals(CategoricalStops.class, layer.getFillOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(0.3f, ((SourceFunction) layer.getFillOpacity().getFunction()).getDefaultValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOpacityAsCompositeFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOpacity(
|
||||
composite(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
stop(0, 0.3f, fillOpacity(0.9f))
|
||||
).withBase(0.5f)
|
||||
).withDefaultValue(0.3f)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOpacity());
|
||||
assertNotNull(layer.getFillOpacity().getFunction());
|
||||
assertEquals(CompositeFunction.class, layer.getFillOpacity().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getFillOpacity().getFunction()).getProperty());
|
||||
assertEquals(CompositeStops.class, layer.getFillOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((CompositeStops) layer.getFillOpacity().getFunction().getStops()).size());
|
||||
|
||||
CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>> stops =
|
||||
(CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>>) layer.getFillOpacity().getFunction().getStops();
|
||||
Map.Entry<Float, ExponentialStops<Float, Float>> stop = stops.iterator().next();
|
||||
assertEquals(ExponentialStops.class, stop.getValue().getClass());
|
||||
assertEquals(0f, stop.getKey(), 0.001);
|
||||
assertEquals(1, stop.getValue().size());
|
||||
assertEquals(0.3f, stop.getValue().iterator().next().in, 0.001f);
|
||||
assertEquals(0.9f, stop.getValue().iterator().next().out, 0.001f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillColorAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -147,19 +276,105 @@ public class FillLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillColorAsInt() {
|
||||
public void testFillColorAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillColor(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, fillColor("rgba(0, 0, 0, 1)"))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getFillColor());
|
||||
assertNotNull(layer.getFillColor().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getFillColor().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getFillColor().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getFillColor().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getFillColor().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillColorAsIdentitySourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillColor(property("FeaturePropertyA", Stops.<String>identity()))
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillColor());
|
||||
assertNotNull(layer.getFillColor().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillColor().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillColor().getFunction()).getProperty());
|
||||
assertEquals(IdentityStops.class, layer.getFillColor().getFunction().getStops().getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillColorAsExponentialSourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillColor(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
stop(Color.RED, fillColor(Color.RED))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillColor());
|
||||
assertNotNull(layer.getFillColor().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillColor().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillColor().getFunction()).getProperty());
|
||||
assertEquals(ExponentialStops.class, layer.getFillColor().getFunction().getStops().getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillColorAsCategoricalSourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillColor(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
categorical(
|
||||
stop("valueA", fillColor(Color.RED))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillColor());
|
||||
assertNotNull(layer.getFillColor().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillColor().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillColor().getFunction()).getProperty());
|
||||
assertEquals(CategoricalStops.class, layer.getFillColor().getFunction().getStops().getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillColorAsIntConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -169,19 +384,8 @@ public class FillLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColor() {
|
||||
public void testFillOutlineColorAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-outline-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -191,19 +395,105 @@ public class FillLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColorAsInt() {
|
||||
public void testFillOutlineColorAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-outline-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOutlineColor(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, fillOutlineColor("rgba(0, 0, 0, 1)"))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOutlineColor());
|
||||
assertNotNull(layer.getFillOutlineColor().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getFillOutlineColor().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getFillOutlineColor().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getFillOutlineColor().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getFillOutlineColor().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColorAsIdentitySourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-outline-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOutlineColor(property("FeaturePropertyA", Stops.<String>identity()))
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOutlineColor());
|
||||
assertNotNull(layer.getFillOutlineColor().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillOutlineColor().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOutlineColor().getFunction()).getProperty());
|
||||
assertEquals(IdentityStops.class, layer.getFillOutlineColor().getFunction().getStops().getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColorAsExponentialSourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-outline-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOutlineColor(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
stop(Color.RED, fillOutlineColor(Color.RED))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOutlineColor());
|
||||
assertNotNull(layer.getFillOutlineColor().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillOutlineColor().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOutlineColor().getFunction()).getProperty());
|
||||
assertEquals(ExponentialStops.class, layer.getFillOutlineColor().getFunction().getStops().getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColorAsCategoricalSourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-outline-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOutlineColor(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
categorical(
|
||||
stop("valueA", fillOutlineColor(Color.RED))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOutlineColor());
|
||||
assertNotNull(layer.getFillOutlineColor().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillOutlineColor().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOutlineColor().getFunction()).getProperty());
|
||||
assertEquals(CategoricalStops.class, layer.getFillOutlineColor().getFunction().getStops().getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColorAsIntConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-outline-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -213,41 +503,45 @@ public class FillLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillTranslate() {
|
||||
public void testFillTranslateAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-translate");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillTranslate(new Float[] {0f, 0f}));
|
||||
assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
|
||||
layer.setProperties(fillTranslate(new Float[]{0f,0f}));
|
||||
assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[]{0f,0f});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillTranslateAnchor() {
|
||||
public void testFillTranslateAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-translate");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillTranslate(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, fillTranslate(new Float[]{0f,0f}))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getFillTranslate());
|
||||
assertNotNull(layer.getFillTranslate().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getFillTranslate().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getFillTranslate().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getFillTranslate().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getFillTranslate().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillTranslateAnchorAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-translate-anchor");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -257,19 +551,33 @@ public class FillLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillPattern() {
|
||||
public void testFillTranslateAnchorAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-translate-anchor");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillTranslateAnchor(
|
||||
zoom(
|
||||
interval(
|
||||
stop(2, fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getFillTranslateAnchor());
|
||||
assertNotNull(layer.getFillTranslateAnchor().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getFillTranslateAnchor().getFunction().getClass());
|
||||
assertEquals(IntervalStops.class, layer.getFillTranslateAnchor().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((IntervalStops) layer.getFillTranslateAnchor().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillPatternAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-pattern");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -278,6 +586,31 @@ public class FillLayerTest extends BaseStyleTest {
|
||||
assertEquals((String) layer.getFillPattern().getValue(), (String) "pedestrian-polygon");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillPatternAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-pattern");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillPattern(
|
||||
zoom(
|
||||
interval(
|
||||
stop(2, fillPattern("pedestrian-polygon"))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillPattern());
|
||||
assertNotNull(layer.getFillPattern().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getFillPattern().getFunction().getClass());
|
||||
assertEquals(IntervalStops.class, layer.getFillPattern().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((IntervalStops) layer.getFillPattern().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
|
||||
@@ -1,427 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.LineLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
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.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;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for LineLayer
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class LineLayerStyleTest extends BaseStyleTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private LineLayer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineCap() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-cap");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineCap(LINE_CAP_BUTT));
|
||||
assertEquals((String) layer.getLineCap().getValue(), (String) LINE_CAP_BUTT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineJoin() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-join");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineJoin(LINE_JOIN_BEVEL));
|
||||
assertEquals((String) layer.getLineJoin().getValue(), (String) LINE_JOIN_BEVEL);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineMiterLimit() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-miter-limit");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineMiterLimit(0.3f));
|
||||
assertEquals((Float) layer.getLineMiterLimit().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineRoundLimit() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-round-limit");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineRoundLimit(0.3f));
|
||||
assertEquals((Float) layer.getLineRoundLimit().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineOpacity(0.3f));
|
||||
assertEquals((Float) layer.getLineOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getLineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineColor(Color.RED));
|
||||
assertEquals(layer.getLineColorAsInt(), Color.RED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineTranslate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-translate");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineTranslate(new Float[] {0f, 0f}));
|
||||
assertEquals((Float[]) layer.getLineTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineTranslateAnchor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-translate-anchor");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineTranslateAnchor(LINE_TRANSLATE_ANCHOR_MAP));
|
||||
assertEquals((String) layer.getLineTranslateAnchor().getValue(), (String) LINE_TRANSLATE_ANCHOR_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineWidth() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-width");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineWidth(0.3f));
|
||||
assertEquals((Float) layer.getLineWidth().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineGapWidth() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-gap-width");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineGapWidth(0.3f));
|
||||
assertEquals((Float) layer.getLineGapWidth().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineOffset() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-offset");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineOffset(0.3f));
|
||||
assertEquals((Float) layer.getLineOffset().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineBlur() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-blur");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineBlur(0.3f));
|
||||
assertEquals((Float) layer.getLineBlur().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineDasharray() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-dasharray");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineDasharray(new Float[] {}));
|
||||
assertEquals((Float[]) layer.getLineDasharray().getValue(), (Float[]) new Float[] {});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLinePattern() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-pattern");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(linePattern("pedestrian-polygon"));
|
||||
assertEquals((String) layer.getLinePattern().getValue(), (String) "pedestrian-polygon");
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,240 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.RasterLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
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.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.rasterSaturation;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for RasterLayer
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class RasterLayerStyleTest extends BaseStyleTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private RasterLayer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("raster-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterOpacity(0.3f));
|
||||
assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterHueRotate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("raster-hue-rotate");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterHueRotate(0.3f));
|
||||
assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterBrightnessMin() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("raster-brightness-min");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterBrightnessMin(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterBrightnessMax() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("raster-brightness-max");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterBrightnessMax(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterSaturation() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("raster-saturation");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterSaturation(0.3f));
|
||||
assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterContrast() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("raster-contrast");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterContrast(0.3f));
|
||||
assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterFadeDuration() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("raster-fade-duration");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterFadeDuration(0.3f));
|
||||
assertEquals((Float) layer.getRasterFadeDuration().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,23 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.functions.CompositeFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.SourceFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CompositeStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.layers.RasterLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
@@ -17,20 +29,14 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import timber.log.Timber;
|
||||
import java.util.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.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.rasterSaturation;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for RasterLayer
|
||||
@@ -51,12 +57,6 @@ public class RasterLayerTest extends BaseStyleTest {
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
@@ -67,7 +67,12 @@ public class RasterLayerTest extends BaseStyleTest {
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("Visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
@@ -79,19 +84,8 @@ public class RasterLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterOpacity() {
|
||||
public void testRasterOpacityAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("raster-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -101,19 +95,34 @@ public class RasterLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterHueRotate() {
|
||||
public void testRasterOpacityAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterOpacity(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterOpacity(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterOpacity());
|
||||
assertNotNull(layer.getRasterOpacity().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterOpacity().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterOpacity().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterOpacity().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterHueRotateAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-hue-rotate");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -123,19 +132,34 @@ public class RasterLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterBrightnessMin() {
|
||||
public void testRasterHueRotateAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-hue-rotate");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterHueRotate(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterHueRotate(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterHueRotate());
|
||||
assertNotNull(layer.getRasterHueRotate().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterHueRotate().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterHueRotate().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterHueRotate().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterHueRotate().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterBrightnessMinAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-brightness-min");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -145,19 +169,34 @@ public class RasterLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterBrightnessMax() {
|
||||
public void testRasterBrightnessMinAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-brightness-min");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterBrightnessMin(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterBrightnessMin(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterBrightnessMin());
|
||||
assertNotNull(layer.getRasterBrightnessMin().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterBrightnessMin().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterBrightnessMin().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterBrightnessMin().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterBrightnessMin().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterBrightnessMaxAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-brightness-max");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -167,19 +206,34 @@ public class RasterLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterSaturation() {
|
||||
public void testRasterBrightnessMaxAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-brightness-max");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterBrightnessMax(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterBrightnessMax(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterBrightnessMax());
|
||||
assertNotNull(layer.getRasterBrightnessMax().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterBrightnessMax().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterBrightnessMax().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterBrightnessMax().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterBrightnessMax().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterSaturationAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-saturation");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -189,19 +243,34 @@ public class RasterLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterContrast() {
|
||||
public void testRasterSaturationAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-saturation");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterSaturation(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterSaturation(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterSaturation());
|
||||
assertNotNull(layer.getRasterSaturation().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterSaturation().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterSaturation().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterSaturation().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterSaturation().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterContrastAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-contrast");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -211,19 +280,34 @@ public class RasterLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterFadeDuration() {
|
||||
public void testRasterContrastAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-contrast");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterContrast(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterContrast(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterContrast());
|
||||
assertNotNull(layer.getRasterContrast().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterContrast().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterContrast().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterContrast().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterContrast().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterFadeDurationAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-fade-duration");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -232,6 +316,32 @@ public class RasterLayerTest extends BaseStyleTest {
|
||||
assertEquals((Float) layer.getRasterFadeDuration().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterFadeDurationAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-fade-duration");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterFadeDuration(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterFadeDuration(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterFadeDuration());
|
||||
assertNotNull(layer.getRasterFadeDuration().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterFadeDuration().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterFadeDuration().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterFadeDuration().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterFadeDuration().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,7 @@
|
||||
const properties = locals.properties;
|
||||
-%>
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
|
||||
import android.graphics.Color;
|
||||
@@ -12,6 +13,15 @@ import android.support.test.runner.AndroidJUnit4;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.functions.CompositeFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.SourceFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CompositeStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.layers.<%- camelize(type) %>Layer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
@@ -23,6 +33,11 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
@@ -33,112 +48,310 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class <%- camelize(type) %>LayerTest extends BaseStyleTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private <%- camelize(type) %>Layer layer;
|
||||
private <%- camelize(type) %>Layer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
<% if (type === 'background') { -%>
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
<% } else { -%>
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new <%- camelize(type) %>Layer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
<% } -%>
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new <%- camelize(type) %>Layer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
<% } -%>
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("Visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
<% for (const property of properties) { -%>
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set and Get
|
||||
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>));
|
||||
assertEquals((<%- propertyType(property) %>) layer.get<%- camelize(property.name) %>().getValue(), (<%- propertyType(property) %>) <%- defaultValueJava(property) %>);
|
||||
}
|
||||
<% if (supportsZoomFunction(property)) { -%>
|
||||
|
||||
<% if (type === 'background') { -%>
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
zoom(
|
||||
<% if (property.function == 'piecewise-constant') { -%>
|
||||
interval(
|
||||
stop(2, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
)
|
||||
<% } else { -%>
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new <%- camelize(type) %>Layer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
exponential(
|
||||
stop(2, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
).withBase(0.5f)
|
||||
<% } -%>
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>));
|
||||
assertEquals((<%- propertyType(property) %>) layer.get<%- camelize(property.name) %>().getValue(), (<%- propertyType(property) %>) <%- defaultValueJava(property) %>);
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
<% if (property.function == 'piecewise-constant') { -%>
|
||||
assertEquals(IntervalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((IntervalStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).size());
|
||||
<% } else { -%>
|
||||
assertEquals(ExponentialStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).size());
|
||||
<% } -%>
|
||||
}
|
||||
<% } -%>
|
||||
<% if (supportsPropertyFunction(property)) { -%>
|
||||
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsIdentitySourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(property("FeaturePropertyA", Stops.<<%- propertyType(property) %>>identity()))
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(IdentityStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
}
|
||||
<% if (property.function == 'piecewise-constant') { -%>
|
||||
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsIntervalSourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
interval(
|
||||
<% if (property.type == 'color') { -%>
|
||||
stop(Color.RED, <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED))
|
||||
<% } else {-%>
|
||||
1, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
<% } -%>
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(IdentityStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
}
|
||||
<% } else if (property.type === 'array') { -%>
|
||||
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsIntervalSourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
interval(
|
||||
<% if (property.type == 'color') { -%>
|
||||
stop(Color.RED, <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED))
|
||||
<% } else {-%>
|
||||
stop(1, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
<% } -%>
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(IntervalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
}
|
||||
<% } else { -%>
|
||||
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsExponentialSourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
<% if (property.type == 'color') { -%>
|
||||
stop(Color.RED, <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED))
|
||||
<% } else {-%>
|
||||
stop(<%- defaultValueJava(property) %>, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
<% } -%>
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(ExponentialStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsCategoricalSourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
categorical(
|
||||
<% if (property.type == 'color') { -%>
|
||||
stop("valueA", <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED))
|
||||
)
|
||||
)
|
||||
<% } else {-%>
|
||||
stop(1.0f, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
)
|
||||
).withDefaultValue(<%- defaultValueJava(property) %>)
|
||||
<% } -%>
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(CategoricalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
<% if (property.type !== 'color') { -%>
|
||||
assertEquals(<%- defaultValueJava(property) %>, ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getDefaultValue());
|
||||
<% } -%>
|
||||
}
|
||||
<% if (property.type !== 'color') { -%>
|
||||
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsCompositeFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
composite(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
stop(0, 0.3f, <%- camelizeWithLeadingLowercase(property.name) %>(0.9f))
|
||||
).withBase(0.5f)
|
||||
<% if (property.type == 'number') { -%>
|
||||
).withDefaultValue(<%- defaultValueJava(property) %>)
|
||||
<% } else { -%>
|
||||
)
|
||||
<% } -%>
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(CompositeFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(CompositeStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((CompositeStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).size());
|
||||
|
||||
CompositeStops<Float, <%- propertyType(property) %>, <%- propertyType(property) %>, ExponentialStops<<%- propertyType(property) %>, <%- propertyType(property) %>>> stops =
|
||||
(CompositeStops<Float, <%- propertyType(property) %>, <%- propertyType(property) %>, ExponentialStops<<%- propertyType(property) %>, <%- propertyType(property) %>>>) layer.get<%- camelize(property.name) %>().getFunction().getStops();
|
||||
Map.Entry<Float, ExponentialStops<<%- propertyType(property) %>, <%- propertyType(property) %>>> stop = stops.iterator().next();
|
||||
assertEquals(ExponentialStops.class, stop.getValue().getClass());
|
||||
assertEquals(0f, stop.getKey(), 0.001);
|
||||
assertEquals(1, stop.getValue().size());
|
||||
assertEquals(0.3f, stop.getValue().iterator().next().in, 0.001f);
|
||||
assertEquals(0.9f, stop.getValue().iterator().next().out, 0.001f);
|
||||
}
|
||||
<% } -%>
|
||||
<% } -%>
|
||||
<% } -%>
|
||||
<% if (property.type == 'color') { -%>
|
||||
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsIntConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
<% if (type === 'background') { -%>
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
<% } else { -%>
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new <%- camelize(type) %>Layer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
<% } -%>
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(Color.RED));
|
||||
assertEquals(layer.get<%- camelize(property.name) %>AsInt(), Color.RED);
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(Color.RED));
|
||||
assertEquals(layer.get<%- camelize(property.name) %>AsInt(), Color.RED);
|
||||
}
|
||||
<% } -%>
|
||||
|
||||
<% } -%>
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user