[android] - instrumented unit tests, add map tests, refactor generated layer tests

This commit is contained in:
Tobrun
2018-11-23 15:43:20 +01:00
committed by Tobrun
parent c043d01e14
commit 5a4a7e7ea8
13 changed files with 2150 additions and 2813 deletions

View File

@@ -0,0 +1,26 @@
package com.mapbox.mapboxsdk.maps
import android.support.test.InstrumentationRegistry
import android.support.test.runner.AndroidJUnit4
import com.mapbox.mapboxsdk.style.layers.Layer
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
abstract class BaseLayerTest {
private lateinit var nativeMapView: NativeMapView
companion object {
const val WIDTH = 500
const val HEIGHT = WIDTH
}
fun before() {
val context = InstrumentationRegistry.getContext()
nativeMapView = NativeMapView(context, false, null, null, NativeMapViewTest.DummyRenderer(context))
nativeMapView.resizeView(WIDTH, HEIGHT)
}
fun setupLayer(layer: Layer) {
nativeMapView.addLayer(layer)
}
}

View File

@@ -0,0 +1,187 @@
package com.mapbox.mapboxsdk.maps
import android.content.Context
import android.graphics.PointF
import android.support.test.InstrumentationRegistry
import android.support.test.annotation.UiThreadTest
import android.support.test.runner.AndroidJUnit4
import com.mapbox.mapboxsdk.camera.CameraPosition
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.maps.renderer.MapRenderer
import junit.framework.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class NativeMapViewTest {
private lateinit var nativeMapView: NativeMapView
companion object {
const val DELTA = 0.000001
const val DELTA_BIG = 1.0
const val BEARING_TEST = 60.0
const val PITCH_TEST = 40.0
const val ZOOM_TEST = 16.0
const val WIDTH = 500
const val HEIGHT = WIDTH
val LATLNG_TEST = LatLng(12.0, 34.0)
}
@Before
@UiThreadTest
fun before() {
val context = InstrumentationRegistry.getContext()
nativeMapView = NativeMapView(context, false, null, null, DummyRenderer(context))
nativeMapView.resizeView(WIDTH, HEIGHT)
}
@Test
@UiThreadTest
fun testBearing() {
val expected = BEARING_TEST
nativeMapView.bearing = expected
val actual = nativeMapView.bearing
assertEquals("Bearing should match", expected, actual, DELTA)
}
@Test
@UiThreadTest
fun testLatLng() {
val expected = LATLNG_TEST
nativeMapView.latLng = expected
val actual = nativeMapView.latLng
assertEquals("Latitude should match", expected.latitude, actual.latitude, DELTA)
assertEquals("Longitude should match", expected.longitude, actual.longitude, DELTA)
}
@Test
@UiThreadTest
fun testLatLngDefault() {
val expected = LatLng()
val actual = nativeMapView.latLng
assertEquals("Latitude should match", expected.latitude, actual.latitude, DELTA)
assertEquals("Longitude should match", expected.longitude, actual.longitude, DELTA)
}
@Test
@UiThreadTest
fun testBearingDefault() {
val expected = 0.0
val actual = nativeMapView.bearing
assertEquals("Bearing should match", expected, actual, DELTA)
}
@Test
@UiThreadTest
fun testPitch() {
val expected = PITCH_TEST
nativeMapView.pitch = expected
val actual = nativeMapView.pitch
assertEquals("Pitch should match", expected, actual, DELTA)
}
@Test
@UiThreadTest
fun testPitchDefault() {
val expected = 0.0
val actual = nativeMapView.pitch
assertEquals("Pitch should match", expected, actual, DELTA)
}
@Test
@UiThreadTest
fun testZoom() {
val expected = ZOOM_TEST
nativeMapView.setZoom(expected, PointF(0.0f, 0.0f), 0)
val actual = nativeMapView.zoom
assertEquals("Zoom should match", expected, actual, DELTA)
}
@Test
@UiThreadTest
fun testZoomDefault() {
val expected = 0.0
val actual = nativeMapView.zoom
assertEquals("Zoom should match", expected, actual, DELTA)
}
@Test
@UiThreadTest
fun testJumpTo() {
val expected = CameraPosition.Builder()
.bearing(BEARING_TEST)
.target(LATLNG_TEST)
.tilt(PITCH_TEST)
.zoom(ZOOM_TEST)
.build()
nativeMapView.jumpTo(BEARING_TEST, LATLNG_TEST, PITCH_TEST, ZOOM_TEST)
val actual = nativeMapView.cameraPosition
assertEquals("Latitude should match", expected.target.latitude, actual.target.latitude, DELTA)
assertEquals("Longitude should match", expected.target.longitude, actual.target.longitude, DELTA)
assertEquals("Bearing should match", expected.bearing, actual.bearing, DELTA)
assertEquals("Pitch should match", expected.tilt, actual.tilt, DELTA)
assertEquals("Zoom should match", expected.zoom, actual.zoom, DELTA)
}
@Test
@UiThreadTest
fun testLatLngForPixel() {
val expected = LATLNG_TEST
nativeMapView.latLng = LATLNG_TEST
val actual = nativeMapView.latLngForPixel(
PointF((WIDTH / 2).toFloat(), (HEIGHT / 2).toFloat())
)
assertEquals("Latitude should match", expected.latitude, actual.latitude, DELTA_BIG)
assertEquals("Longitude should match", expected.longitude, actual.longitude, DELTA_BIG)
}
@Test
@UiThreadTest
fun testPixelForLatLng() {
val expected = PointF((WIDTH / 2).toFloat(), (HEIGHT / 2).toFloat())
nativeMapView.latLng = LATLNG_TEST
val actual = nativeMapView.pixelForLatLng(LATLNG_TEST)
assertEquals("X should match", expected.x.toDouble(), actual.x.toDouble(), DELTA_BIG)
assertEquals("Y should match", expected.y.toDouble(), actual.y.toDouble(), DELTA_BIG)
}
@Test
@UiThreadTest
fun testPrefetchTilesTrue(){
val expected = true
nativeMapView.prefetchesTiles = true
val actual = nativeMapView.prefetchesTiles
assertEquals("Flag should match", expected, actual)
}
@Test
@UiThreadTest
fun testPrefetchTilesFalse(){
val expected = false
nativeMapView.prefetchesTiles = false
val actual = nativeMapView.prefetchesTiles
assertEquals("Flag should match", expected, actual)
}
@Test
@UiThreadTest
fun testPrefetchTilesDefault(){
val expected = true
val actual = nativeMapView.prefetchesTiles
assertEquals("Flag should match", expected, actual)
}
class DummyRenderer(context: Context) : MapRenderer(context, null) {
override fun requestRender() {
//no-op
}
override fun queueEvent(runnable: Runnable?) {
//no-op
}
}
}

View File

@@ -3,167 +3,139 @@
package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
import android.support.test.annotation.UiThreadTest;
import android.support.test.runner.AndroidJUnit4;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
import org.junit.Before;
import timber.log.Timber;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
import static org.junit.Assert.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
/**
* Basic smoke tests for BackgroundLayer
*/
@RunWith(AndroidJUnit4.class)
public class BackgroundLayerTest extends BaseActivityTest {
public class BackgroundLayerTest extends BaseLayerTest {
private BackgroundLayer layer;
@Override
protected Class getActivityClass() {
return EspressoTestActivity.class;
}
private void setupLayer() {
Timber.i("Retrieving layer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
layer = mapboxMap.getStyle().getLayerAs("background");
});
@Before
@UiThreadTest
public void beforeTest(){
super.before();
layer = new BackgroundLayer("my-layer");
setupLayer(layer);
}
@Test
@UiThreadTest
public void testSetVisibility() {
validateTestSetup();
setupLayer();
Timber.i("Visibility");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
// Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
// Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
});
// Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
}
@Test
@UiThreadTest
public void testBackgroundColorTransition() {
validateTestSetup();
setupLayer();
Timber.i("background-colorTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setBackgroundColorTransition(options);
assertEquals(layer.getBackgroundColorTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setBackgroundColorTransition(options);
assertEquals(layer.getBackgroundColorTransition(), options);
}
@Test
@UiThreadTest
public void testBackgroundColorAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("background-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getBackgroundColor().getValue());
assertNotNull(layer);
assertNull(layer.getBackgroundColor().getValue());
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
layer.setProperties(backgroundColor(propertyValue));
assertEquals(layer.getBackgroundColor().getValue(), propertyValue);
});
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
layer.setProperties(backgroundColor(propertyValue));
assertEquals(layer.getBackgroundColor().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testBackgroundColorAsIntConstant() {
validateTestSetup();
setupLayer();
Timber.i("background-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
layer.setProperties(backgroundColor(Color.RED));
assertEquals(layer.getBackgroundColorAsInt(), Color.RED);
});
// Set and Get
layer.setProperties(backgroundColor(Color.RED));
assertEquals(layer.getBackgroundColorAsInt(), Color.RED);
}
@Test
@UiThreadTest
public void testBackgroundPatternTransition() {
validateTestSetup();
setupLayer();
Timber.i("background-patternTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setBackgroundPatternTransition(options);
assertEquals(layer.getBackgroundPatternTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setBackgroundPatternTransition(options);
assertEquals(layer.getBackgroundPatternTransition(), options);
}
@Test
@UiThreadTest
public void testBackgroundPatternAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("background-pattern");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getBackgroundPattern().getValue());
assertNotNull(layer);
assertNull(layer.getBackgroundPattern().getValue());
// Set and Get
String propertyValue = "pedestrian-polygon";
layer.setProperties(backgroundPattern(propertyValue));
assertEquals(layer.getBackgroundPattern().getValue(), propertyValue);
});
// Set and Get
String propertyValue = "pedestrian-polygon";
layer.setProperties(backgroundPattern(propertyValue));
assertEquals(layer.getBackgroundPattern().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testBackgroundOpacityTransition() {
validateTestSetup();
setupLayer();
Timber.i("background-opacityTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setBackgroundOpacityTransition(options);
assertEquals(layer.getBackgroundOpacityTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setBackgroundOpacityTransition(options);
assertEquals(layer.getBackgroundOpacityTransition(), options);
}
@Test
@UiThreadTest
public void testBackgroundOpacityAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("background-opacity");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getBackgroundOpacity().getValue());
assertNotNull(layer);
assertNull(layer.getBackgroundOpacity().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(backgroundOpacity(propertyValue));
assertEquals(layer.getBackgroundOpacity().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(backgroundOpacity(propertyValue));
assertEquals(layer.getBackgroundOpacity().getValue(), propertyValue);
}
}

View File

@@ -3,558 +3,451 @@
package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
import android.support.test.annotation.UiThreadTest;
import android.support.test.runner.AndroidJUnit4;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
import org.junit.Before;
import timber.log.Timber;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
import static org.junit.Assert.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
/**
* Basic smoke tests for CircleLayer
*/
@RunWith(AndroidJUnit4.class)
public class CircleLayerTest extends BaseActivityTest {
public class CircleLayerTest extends BaseLayerTest {
private CircleLayer layer;
@Override
protected Class getActivityClass() {
return EspressoTestActivity.class;
}
private void setupLayer() {
Timber.i("Retrieving layer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
Timber.i("Adding layer");
layer = new CircleLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.getStyle().addLayer(layer);
// Layer reference is now stale, get new reference
layer = mapboxMap.getStyle().getLayerAs("my-layer");
}
});
@Before
@UiThreadTest
public void beforeTest(){
super.before();
layer = new CircleLayer("my-layer", "composite");
layer.setSourceLayer("composite");
setupLayer(layer);
}
@Test
@UiThreadTest
public void testSourceId() {
validateTestSetup();
setupLayer();
Timber.i("SourceId");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
// Get source id
assertEquals(layer.getSourceId(), "composite");
});
assertNotNull(layer);
assertEquals(layer.getSourceId(), "composite");
}
@Test
@UiThreadTest
public void testSetVisibility() {
validateTestSetup();
setupLayer();
Timber.i("Visibility");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
// Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
// Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
});
// Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
}
@Test
@UiThreadTest
public void testSourceLayer() {
validateTestSetup();
setupLayer();
Timber.i("SourceLayer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Get initial
assertEquals(layer.getSourceLayer(), "composite");
// Get initial
assertEquals(layer.getSourceLayer(), "composite");
// Set
final String sourceLayer = "test";
layer.setSourceLayer(sourceLayer);
assertEquals(layer.getSourceLayer(), sourceLayer);
});
// Set
final String sourceLayer = "test";
layer.setSourceLayer(sourceLayer);
assertEquals(layer.getSourceLayer(), sourceLayer);
}
@Test
@UiThreadTest
public void testFilter() {
validateTestSetup();
setupLayer();
Timber.i("Filter");
invoke(mapboxMap, (uiController, mapboxMap1) -> {
assertNotNull(layer);
assertNotNull(layer);
// Get initial
assertEquals(layer.getFilter(), null);
// Get initial
assertEquals(layer.getFilter(), null);
// Set
Expression filter = eq(get("undefined"), literal(1.0));
layer.setFilter(filter);
assertEquals(layer.getFilter().toString(), filter.toString());
// Set
Expression filter = eq(get("undefined"), literal(1.0));
layer.setFilter(filter);
assertEquals(layer.getFilter().toString(), filter.toString());
// Set constant
filter = literal(true);
layer.setFilter(filter);
assertEquals(layer.getFilter().toString(), filter.toString());
});
// Set constant
filter = literal(true);
layer.setFilter(filter);
assertEquals(layer.getFilter().toString(), filter.toString());
}
@Test
@UiThreadTest
public void testCircleRadiusTransition() {
validateTestSetup();
setupLayer();
Timber.i("circle-radiusTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setCircleRadiusTransition(options);
assertEquals(layer.getCircleRadiusTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setCircleRadiusTransition(options);
assertEquals(layer.getCircleRadiusTransition(), options);
}
@Test
@UiThreadTest
public void testCircleRadiusAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("circle-radius");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getCircleRadius().getValue());
assertNotNull(layer);
assertNull(layer.getCircleRadius().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(circleRadius(propertyValue));
assertEquals(layer.getCircleRadius().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(circleRadius(propertyValue));
assertEquals(layer.getCircleRadius().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testCircleRadiusAsExpression() {
validateTestSetup();
setupLayer();
Timber.i("circle-radius-expression");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getCircleRadius().getExpression());
assertNotNull(layer);
assertNull(layer.getCircleRadius().getExpression());
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(circleRadius(expression));
assertEquals(layer.getCircleRadius().getExpression(), expression);
});
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(circleRadius(expression));
assertEquals(layer.getCircleRadius().getExpression(), expression);
}
@Test
@UiThreadTest
public void testCircleColorTransition() {
validateTestSetup();
setupLayer();
Timber.i("circle-colorTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setCircleColorTransition(options);
assertEquals(layer.getCircleColorTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setCircleColorTransition(options);
assertEquals(layer.getCircleColorTransition(), options);
}
@Test
@UiThreadTest
public void testCircleColorAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("circle-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getCircleColor().getValue());
assertNotNull(layer);
assertNull(layer.getCircleColor().getValue());
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
layer.setProperties(circleColor(propertyValue));
assertEquals(layer.getCircleColor().getValue(), propertyValue);
});
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
layer.setProperties(circleColor(propertyValue));
assertEquals(layer.getCircleColor().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testCircleColorAsExpression() {
validateTestSetup();
setupLayer();
Timber.i("circle-color-expression");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getCircleColor().getExpression());
assertNotNull(layer);
assertNull(layer.getCircleColor().getExpression());
// Set and Get
Expression expression = toColor(Expression.get("undefined"));
layer.setProperties(circleColor(expression));
assertEquals(layer.getCircleColor().getExpression(), expression);
});
// Set and Get
Expression expression = toColor(Expression.get("undefined"));
layer.setProperties(circleColor(expression));
assertEquals(layer.getCircleColor().getExpression(), expression);
}
@Test
@UiThreadTest
public void testCircleColorAsIntConstant() {
validateTestSetup();
setupLayer();
Timber.i("circle-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
layer.setProperties(circleColor(Color.RED));
assertEquals(layer.getCircleColorAsInt(), Color.RED);
});
// Set and Get
layer.setProperties(circleColor(Color.RED));
assertEquals(layer.getCircleColorAsInt(), Color.RED);
}
@Test
@UiThreadTest
public void testCircleBlurTransition() {
validateTestSetup();
setupLayer();
Timber.i("circle-blurTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setCircleBlurTransition(options);
assertEquals(layer.getCircleBlurTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setCircleBlurTransition(options);
assertEquals(layer.getCircleBlurTransition(), options);
}
@Test
@UiThreadTest
public void testCircleBlurAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("circle-blur");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getCircleBlur().getValue());
assertNotNull(layer);
assertNull(layer.getCircleBlur().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(circleBlur(propertyValue));
assertEquals(layer.getCircleBlur().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(circleBlur(propertyValue));
assertEquals(layer.getCircleBlur().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testCircleBlurAsExpression() {
validateTestSetup();
setupLayer();
Timber.i("circle-blur-expression");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getCircleBlur().getExpression());
assertNotNull(layer);
assertNull(layer.getCircleBlur().getExpression());
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(circleBlur(expression));
assertEquals(layer.getCircleBlur().getExpression(), expression);
});
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(circleBlur(expression));
assertEquals(layer.getCircleBlur().getExpression(), expression);
}
@Test
@UiThreadTest
public void testCircleOpacityTransition() {
validateTestSetup();
setupLayer();
Timber.i("circle-opacityTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setCircleOpacityTransition(options);
assertEquals(layer.getCircleOpacityTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setCircleOpacityTransition(options);
assertEquals(layer.getCircleOpacityTransition(), options);
}
@Test
@UiThreadTest
public void testCircleOpacityAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("circle-opacity");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getCircleOpacity().getValue());
assertNotNull(layer);
assertNull(layer.getCircleOpacity().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(circleOpacity(propertyValue));
assertEquals(layer.getCircleOpacity().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(circleOpacity(propertyValue));
assertEquals(layer.getCircleOpacity().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testCircleOpacityAsExpression() {
validateTestSetup();
setupLayer();
Timber.i("circle-opacity-expression");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getCircleOpacity().getExpression());
assertNotNull(layer);
assertNull(layer.getCircleOpacity().getExpression());
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(circleOpacity(expression));
assertEquals(layer.getCircleOpacity().getExpression(), expression);
});
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(circleOpacity(expression));
assertEquals(layer.getCircleOpacity().getExpression(), expression);
}
@Test
@UiThreadTest
public void testCircleTranslateTransition() {
validateTestSetup();
setupLayer();
Timber.i("circle-translateTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setCircleTranslateTransition(options);
assertEquals(layer.getCircleTranslateTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setCircleTranslateTransition(options);
assertEquals(layer.getCircleTranslateTransition(), options);
}
@Test
@UiThreadTest
public void testCircleTranslateAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("circle-translate");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getCircleTranslate().getValue());
assertNotNull(layer);
assertNull(layer.getCircleTranslate().getValue());
// Set and Get
Float[] propertyValue = new Float[] {0f, 0f};
layer.setProperties(circleTranslate(propertyValue));
assertEquals(layer.getCircleTranslate().getValue(), propertyValue);
});
// Set and Get
Float[] propertyValue = new Float[] {0f, 0f};
layer.setProperties(circleTranslate(propertyValue));
assertEquals(layer.getCircleTranslate().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testCircleTranslateAnchorAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("circle-translate-anchor");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getCircleTranslateAnchor().getValue());
assertNotNull(layer);
assertNull(layer.getCircleTranslateAnchor().getValue());
// Set and Get
String propertyValue = CIRCLE_TRANSLATE_ANCHOR_MAP;
layer.setProperties(circleTranslateAnchor(propertyValue));
assertEquals(layer.getCircleTranslateAnchor().getValue(), propertyValue);
});
// Set and Get
String propertyValue = CIRCLE_TRANSLATE_ANCHOR_MAP;
layer.setProperties(circleTranslateAnchor(propertyValue));
assertEquals(layer.getCircleTranslateAnchor().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testCirclePitchScaleAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("circle-pitch-scale");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getCirclePitchScale().getValue());
assertNotNull(layer);
assertNull(layer.getCirclePitchScale().getValue());
// Set and Get
String propertyValue = CIRCLE_PITCH_SCALE_MAP;
layer.setProperties(circlePitchScale(propertyValue));
assertEquals(layer.getCirclePitchScale().getValue(), propertyValue);
});
// Set and Get
String propertyValue = CIRCLE_PITCH_SCALE_MAP;
layer.setProperties(circlePitchScale(propertyValue));
assertEquals(layer.getCirclePitchScale().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testCirclePitchAlignmentAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("circle-pitch-alignment");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getCirclePitchAlignment().getValue());
assertNotNull(layer);
assertNull(layer.getCirclePitchAlignment().getValue());
// Set and Get
String propertyValue = CIRCLE_PITCH_ALIGNMENT_MAP;
layer.setProperties(circlePitchAlignment(propertyValue));
assertEquals(layer.getCirclePitchAlignment().getValue(), propertyValue);
});
// Set and Get
String propertyValue = CIRCLE_PITCH_ALIGNMENT_MAP;
layer.setProperties(circlePitchAlignment(propertyValue));
assertEquals(layer.getCirclePitchAlignment().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testCircleStrokeWidthTransition() {
validateTestSetup();
setupLayer();
Timber.i("circle-stroke-widthTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setCircleStrokeWidthTransition(options);
assertEquals(layer.getCircleStrokeWidthTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setCircleStrokeWidthTransition(options);
assertEquals(layer.getCircleStrokeWidthTransition(), options);
}
@Test
@UiThreadTest
public void testCircleStrokeWidthAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("circle-stroke-width");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getCircleStrokeWidth().getValue());
assertNotNull(layer);
assertNull(layer.getCircleStrokeWidth().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(circleStrokeWidth(propertyValue));
assertEquals(layer.getCircleStrokeWidth().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(circleStrokeWidth(propertyValue));
assertEquals(layer.getCircleStrokeWidth().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testCircleStrokeWidthAsExpression() {
validateTestSetup();
setupLayer();
Timber.i("circle-stroke-width-expression");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getCircleStrokeWidth().getExpression());
assertNotNull(layer);
assertNull(layer.getCircleStrokeWidth().getExpression());
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(circleStrokeWidth(expression));
assertEquals(layer.getCircleStrokeWidth().getExpression(), expression);
});
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(circleStrokeWidth(expression));
assertEquals(layer.getCircleStrokeWidth().getExpression(), expression);
}
@Test
@UiThreadTest
public void testCircleStrokeColorTransition() {
validateTestSetup();
setupLayer();
Timber.i("circle-stroke-colorTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setCircleStrokeColorTransition(options);
assertEquals(layer.getCircleStrokeColorTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setCircleStrokeColorTransition(options);
assertEquals(layer.getCircleStrokeColorTransition(), options);
}
@Test
@UiThreadTest
public void testCircleStrokeColorAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("circle-stroke-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getCircleStrokeColor().getValue());
assertNotNull(layer);
assertNull(layer.getCircleStrokeColor().getValue());
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
layer.setProperties(circleStrokeColor(propertyValue));
assertEquals(layer.getCircleStrokeColor().getValue(), propertyValue);
});
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
layer.setProperties(circleStrokeColor(propertyValue));
assertEquals(layer.getCircleStrokeColor().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testCircleStrokeColorAsExpression() {
validateTestSetup();
setupLayer();
Timber.i("circle-stroke-color-expression");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getCircleStrokeColor().getExpression());
assertNotNull(layer);
assertNull(layer.getCircleStrokeColor().getExpression());
// Set and Get
Expression expression = toColor(Expression.get("undefined"));
layer.setProperties(circleStrokeColor(expression));
assertEquals(layer.getCircleStrokeColor().getExpression(), expression);
});
// Set and Get
Expression expression = toColor(Expression.get("undefined"));
layer.setProperties(circleStrokeColor(expression));
assertEquals(layer.getCircleStrokeColor().getExpression(), expression);
}
@Test
@UiThreadTest
public void testCircleStrokeColorAsIntConstant() {
validateTestSetup();
setupLayer();
Timber.i("circle-stroke-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
layer.setProperties(circleStrokeColor(Color.RED));
assertEquals(layer.getCircleStrokeColorAsInt(), Color.RED);
});
// Set and Get
layer.setProperties(circleStrokeColor(Color.RED));
assertEquals(layer.getCircleStrokeColorAsInt(), Color.RED);
}
@Test
@UiThreadTest
public void testCircleStrokeOpacityTransition() {
validateTestSetup();
setupLayer();
Timber.i("circle-stroke-opacityTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setCircleStrokeOpacityTransition(options);
assertEquals(layer.getCircleStrokeOpacityTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setCircleStrokeOpacityTransition(options);
assertEquals(layer.getCircleStrokeOpacityTransition(), options);
}
@Test
@UiThreadTest
public void testCircleStrokeOpacityAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("circle-stroke-opacity");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getCircleStrokeOpacity().getValue());
assertNotNull(layer);
assertNull(layer.getCircleStrokeOpacity().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(circleStrokeOpacity(propertyValue));
assertEquals(layer.getCircleStrokeOpacity().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(circleStrokeOpacity(propertyValue));
assertEquals(layer.getCircleStrokeOpacity().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testCircleStrokeOpacityAsExpression() {
validateTestSetup();
setupLayer();
Timber.i("circle-stroke-opacity-expression");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getCircleStrokeOpacity().getExpression());
assertNotNull(layer);
assertNull(layer.getCircleStrokeOpacity().getExpression());
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(circleStrokeOpacity(expression));
assertEquals(layer.getCircleStrokeOpacity().getExpression(), expression);
});
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(circleStrokeOpacity(expression));
assertEquals(layer.getCircleStrokeOpacity().getExpression(), expression);
}
}

View File

@@ -3,418 +3,338 @@
package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
import android.support.test.annotation.UiThreadTest;
import android.support.test.runner.AndroidJUnit4;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
import org.junit.Before;
import timber.log.Timber;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer;
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
import static org.junit.Assert.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
/**
* Basic smoke tests for FillExtrusionLayer
*/
@RunWith(AndroidJUnit4.class)
public class FillExtrusionLayerTest extends BaseActivityTest {
public class FillExtrusionLayerTest extends BaseLayerTest {
private FillExtrusionLayer layer;
@Override
protected Class getActivityClass() {
return EspressoTestActivity.class;
}
private void setupLayer() {
Timber.i("Retrieving layer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
Timber.i("Adding layer");
layer = new FillExtrusionLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.getStyle().addLayer(layer);
// Layer reference is now stale, get new reference
layer = mapboxMap.getStyle().getLayerAs("my-layer");
}
});
@Before
@UiThreadTest
public void beforeTest(){
super.before();
layer = new FillExtrusionLayer("my-layer", "composite");
layer.setSourceLayer("composite");
setupLayer(layer);
}
@Test
@UiThreadTest
public void testSourceId() {
validateTestSetup();
setupLayer();
Timber.i("SourceId");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
// Get source id
assertEquals(layer.getSourceId(), "composite");
});
assertNotNull(layer);
assertEquals(layer.getSourceId(), "composite");
}
@Test
@UiThreadTest
public void testSetVisibility() {
validateTestSetup();
setupLayer();
Timber.i("Visibility");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
// Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
// Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
});
// Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
}
@Test
@UiThreadTest
public void testSourceLayer() {
validateTestSetup();
setupLayer();
Timber.i("SourceLayer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Get initial
assertEquals(layer.getSourceLayer(), "composite");
// Get initial
assertEquals(layer.getSourceLayer(), "composite");
// Set
final String sourceLayer = "test";
layer.setSourceLayer(sourceLayer);
assertEquals(layer.getSourceLayer(), sourceLayer);
});
// Set
final String sourceLayer = "test";
layer.setSourceLayer(sourceLayer);
assertEquals(layer.getSourceLayer(), sourceLayer);
}
@Test
@UiThreadTest
public void testFilter() {
validateTestSetup();
setupLayer();
Timber.i("Filter");
invoke(mapboxMap, (uiController, mapboxMap1) -> {
assertNotNull(layer);
assertNotNull(layer);
// Get initial
assertEquals(layer.getFilter(), null);
// Get initial
assertEquals(layer.getFilter(), null);
// Set
Expression filter = eq(get("undefined"), literal(1.0));
layer.setFilter(filter);
assertEquals(layer.getFilter().toString(), filter.toString());
// Set
Expression filter = eq(get("undefined"), literal(1.0));
layer.setFilter(filter);
assertEquals(layer.getFilter().toString(), filter.toString());
// Set constant
filter = literal(true);
layer.setFilter(filter);
assertEquals(layer.getFilter().toString(), filter.toString());
});
// Set constant
filter = literal(true);
layer.setFilter(filter);
assertEquals(layer.getFilter().toString(), filter.toString());
}
@Test
@UiThreadTest
public void testFillExtrusionOpacityTransition() {
validateTestSetup();
setupLayer();
Timber.i("fill-extrusion-opacityTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setFillExtrusionOpacityTransition(options);
assertEquals(layer.getFillExtrusionOpacityTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setFillExtrusionOpacityTransition(options);
assertEquals(layer.getFillExtrusionOpacityTransition(), options);
}
@Test
@UiThreadTest
public void testFillExtrusionOpacityAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("fill-extrusion-opacity");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getFillExtrusionOpacity().getValue());
assertNotNull(layer);
assertNull(layer.getFillExtrusionOpacity().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(fillExtrusionOpacity(propertyValue));
assertEquals(layer.getFillExtrusionOpacity().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(fillExtrusionOpacity(propertyValue));
assertEquals(layer.getFillExtrusionOpacity().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testFillExtrusionColorTransition() {
validateTestSetup();
setupLayer();
Timber.i("fill-extrusion-colorTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setFillExtrusionColorTransition(options);
assertEquals(layer.getFillExtrusionColorTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setFillExtrusionColorTransition(options);
assertEquals(layer.getFillExtrusionColorTransition(), options);
}
@Test
@UiThreadTest
public void testFillExtrusionColorAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("fill-extrusion-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getFillExtrusionColor().getValue());
assertNotNull(layer);
assertNull(layer.getFillExtrusionColor().getValue());
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
layer.setProperties(fillExtrusionColor(propertyValue));
assertEquals(layer.getFillExtrusionColor().getValue(), propertyValue);
});
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
layer.setProperties(fillExtrusionColor(propertyValue));
assertEquals(layer.getFillExtrusionColor().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testFillExtrusionColorAsExpression() {
validateTestSetup();
setupLayer();
Timber.i("fill-extrusion-color-expression");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getFillExtrusionColor().getExpression());
assertNotNull(layer);
assertNull(layer.getFillExtrusionColor().getExpression());
// Set and Get
Expression expression = toColor(Expression.get("undefined"));
layer.setProperties(fillExtrusionColor(expression));
assertEquals(layer.getFillExtrusionColor().getExpression(), expression);
});
// Set and Get
Expression expression = toColor(Expression.get("undefined"));
layer.setProperties(fillExtrusionColor(expression));
assertEquals(layer.getFillExtrusionColor().getExpression(), expression);
}
@Test
@UiThreadTest
public void testFillExtrusionColorAsIntConstant() {
validateTestSetup();
setupLayer();
Timber.i("fill-extrusion-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
layer.setProperties(fillExtrusionColor(Color.RED));
assertEquals(layer.getFillExtrusionColorAsInt(), Color.RED);
});
// Set and Get
layer.setProperties(fillExtrusionColor(Color.RED));
assertEquals(layer.getFillExtrusionColorAsInt(), Color.RED);
}
@Test
@UiThreadTest
public void testFillExtrusionTranslateTransition() {
validateTestSetup();
setupLayer();
Timber.i("fill-extrusion-translateTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setFillExtrusionTranslateTransition(options);
assertEquals(layer.getFillExtrusionTranslateTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setFillExtrusionTranslateTransition(options);
assertEquals(layer.getFillExtrusionTranslateTransition(), options);
}
@Test
@UiThreadTest
public void testFillExtrusionTranslateAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("fill-extrusion-translate");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getFillExtrusionTranslate().getValue());
assertNotNull(layer);
assertNull(layer.getFillExtrusionTranslate().getValue());
// Set and Get
Float[] propertyValue = new Float[] {0f, 0f};
layer.setProperties(fillExtrusionTranslate(propertyValue));
assertEquals(layer.getFillExtrusionTranslate().getValue(), propertyValue);
});
// Set and Get
Float[] propertyValue = new Float[] {0f, 0f};
layer.setProperties(fillExtrusionTranslate(propertyValue));
assertEquals(layer.getFillExtrusionTranslate().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testFillExtrusionTranslateAnchorAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("fill-extrusion-translate-anchor");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getFillExtrusionTranslateAnchor().getValue());
assertNotNull(layer);
assertNull(layer.getFillExtrusionTranslateAnchor().getValue());
// Set and Get
String propertyValue = FILL_EXTRUSION_TRANSLATE_ANCHOR_MAP;
layer.setProperties(fillExtrusionTranslateAnchor(propertyValue));
assertEquals(layer.getFillExtrusionTranslateAnchor().getValue(), propertyValue);
});
// Set and Get
String propertyValue = FILL_EXTRUSION_TRANSLATE_ANCHOR_MAP;
layer.setProperties(fillExtrusionTranslateAnchor(propertyValue));
assertEquals(layer.getFillExtrusionTranslateAnchor().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testFillExtrusionPatternTransition() {
validateTestSetup();
setupLayer();
Timber.i("fill-extrusion-patternTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setFillExtrusionPatternTransition(options);
assertEquals(layer.getFillExtrusionPatternTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setFillExtrusionPatternTransition(options);
assertEquals(layer.getFillExtrusionPatternTransition(), options);
}
@Test
@UiThreadTest
public void testFillExtrusionPatternAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("fill-extrusion-pattern");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getFillExtrusionPattern().getValue());
assertNotNull(layer);
assertNull(layer.getFillExtrusionPattern().getValue());
// Set and Get
String propertyValue = "pedestrian-polygon";
layer.setProperties(fillExtrusionPattern(propertyValue));
assertEquals(layer.getFillExtrusionPattern().getValue(), propertyValue);
});
// Set and Get
String propertyValue = "pedestrian-polygon";
layer.setProperties(fillExtrusionPattern(propertyValue));
assertEquals(layer.getFillExtrusionPattern().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testFillExtrusionPatternAsExpression() {
validateTestSetup();
setupLayer();
Timber.i("fill-extrusion-pattern-expression");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getFillExtrusionPattern().getExpression());
assertNotNull(layer);
assertNull(layer.getFillExtrusionPattern().getExpression());
// Set and Get
Expression expression = string(Expression.get("undefined"));
layer.setProperties(fillExtrusionPattern(expression));
assertEquals(layer.getFillExtrusionPattern().getExpression(), expression);
});
// Set and Get
Expression expression = string(Expression.get("undefined"));
layer.setProperties(fillExtrusionPattern(expression));
assertEquals(layer.getFillExtrusionPattern().getExpression(), expression);
}
@Test
@UiThreadTest
public void testFillExtrusionHeightTransition() {
validateTestSetup();
setupLayer();
Timber.i("fill-extrusion-heightTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setFillExtrusionHeightTransition(options);
assertEquals(layer.getFillExtrusionHeightTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setFillExtrusionHeightTransition(options);
assertEquals(layer.getFillExtrusionHeightTransition(), options);
}
@Test
@UiThreadTest
public void testFillExtrusionHeightAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("fill-extrusion-height");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getFillExtrusionHeight().getValue());
assertNotNull(layer);
assertNull(layer.getFillExtrusionHeight().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(fillExtrusionHeight(propertyValue));
assertEquals(layer.getFillExtrusionHeight().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(fillExtrusionHeight(propertyValue));
assertEquals(layer.getFillExtrusionHeight().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testFillExtrusionHeightAsExpression() {
validateTestSetup();
setupLayer();
Timber.i("fill-extrusion-height-expression");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getFillExtrusionHeight().getExpression());
assertNotNull(layer);
assertNull(layer.getFillExtrusionHeight().getExpression());
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(fillExtrusionHeight(expression));
assertEquals(layer.getFillExtrusionHeight().getExpression(), expression);
});
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(fillExtrusionHeight(expression));
assertEquals(layer.getFillExtrusionHeight().getExpression(), expression);
}
@Test
@UiThreadTest
public void testFillExtrusionBaseTransition() {
validateTestSetup();
setupLayer();
Timber.i("fill-extrusion-baseTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setFillExtrusionBaseTransition(options);
assertEquals(layer.getFillExtrusionBaseTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setFillExtrusionBaseTransition(options);
assertEquals(layer.getFillExtrusionBaseTransition(), options);
}
@Test
@UiThreadTest
public void testFillExtrusionBaseAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("fill-extrusion-base");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getFillExtrusionBase().getValue());
assertNotNull(layer);
assertNull(layer.getFillExtrusionBase().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(fillExtrusionBase(propertyValue));
assertEquals(layer.getFillExtrusionBase().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(fillExtrusionBase(propertyValue));
assertEquals(layer.getFillExtrusionBase().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testFillExtrusionBaseAsExpression() {
validateTestSetup();
setupLayer();
Timber.i("fill-extrusion-base-expression");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getFillExtrusionBase().getExpression());
assertNotNull(layer);
assertNull(layer.getFillExtrusionBase().getExpression());
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(fillExtrusionBase(expression));
assertEquals(layer.getFillExtrusionBase().getExpression(), expression);
});
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(fillExtrusionBase(expression));
assertEquals(layer.getFillExtrusionBase().getExpression(), expression);
}
@Test
@UiThreadTest
public void testFillExtrusionVerticalGradientAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("fill-extrusion-vertical-gradient");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getFillExtrusionVerticalGradient().getValue());
assertNotNull(layer);
assertNull(layer.getFillExtrusionVerticalGradient().getValue());
// Set and Get
Boolean propertyValue = true;
layer.setProperties(fillExtrusionVerticalGradient(propertyValue));
assertEquals(layer.getFillExtrusionVerticalGradient().getValue(), propertyValue);
});
// Set and Get
Boolean propertyValue = true;
layer.setProperties(fillExtrusionVerticalGradient(propertyValue));
assertEquals(layer.getFillExtrusionVerticalGradient().getValue(), propertyValue);
}
}

View File

@@ -3,401 +3,324 @@
package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
import android.support.test.annotation.UiThreadTest;
import android.support.test.runner.AndroidJUnit4;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
import org.junit.Before;
import timber.log.Timber;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.FillLayer;
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
import static org.junit.Assert.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
/**
* Basic smoke tests for FillLayer
*/
@RunWith(AndroidJUnit4.class)
public class FillLayerTest extends BaseActivityTest {
public class FillLayerTest extends BaseLayerTest {
private FillLayer layer;
@Override
protected Class getActivityClass() {
return EspressoTestActivity.class;
}
private void setupLayer() {
Timber.i("Retrieving layer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
Timber.i("Adding layer");
layer = new FillLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.getStyle().addLayer(layer);
// Layer reference is now stale, get new reference
layer = mapboxMap.getStyle().getLayerAs("my-layer");
}
});
@Before
@UiThreadTest
public void beforeTest(){
super.before();
layer = new FillLayer("my-layer", "composite");
layer.setSourceLayer("composite");
setupLayer(layer);
}
@Test
@UiThreadTest
public void testSourceId() {
validateTestSetup();
setupLayer();
Timber.i("SourceId");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
// Get source id
assertEquals(layer.getSourceId(), "composite");
});
assertNotNull(layer);
assertEquals(layer.getSourceId(), "composite");
}
@Test
@UiThreadTest
public void testSetVisibility() {
validateTestSetup();
setupLayer();
Timber.i("Visibility");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
// Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
// Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
});
// Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
}
@Test
@UiThreadTest
public void testSourceLayer() {
validateTestSetup();
setupLayer();
Timber.i("SourceLayer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Get initial
assertEquals(layer.getSourceLayer(), "composite");
// Get initial
assertEquals(layer.getSourceLayer(), "composite");
// Set
final String sourceLayer = "test";
layer.setSourceLayer(sourceLayer);
assertEquals(layer.getSourceLayer(), sourceLayer);
});
// Set
final String sourceLayer = "test";
layer.setSourceLayer(sourceLayer);
assertEquals(layer.getSourceLayer(), sourceLayer);
}
@Test
@UiThreadTest
public void testFilter() {
validateTestSetup();
setupLayer();
Timber.i("Filter");
invoke(mapboxMap, (uiController, mapboxMap1) -> {
assertNotNull(layer);
assertNotNull(layer);
// Get initial
assertEquals(layer.getFilter(), null);
// Get initial
assertEquals(layer.getFilter(), null);
// Set
Expression filter = eq(get("undefined"), literal(1.0));
layer.setFilter(filter);
assertEquals(layer.getFilter().toString(), filter.toString());
// Set
Expression filter = eq(get("undefined"), literal(1.0));
layer.setFilter(filter);
assertEquals(layer.getFilter().toString(), filter.toString());
// Set constant
filter = literal(true);
layer.setFilter(filter);
assertEquals(layer.getFilter().toString(), filter.toString());
});
// Set constant
filter = literal(true);
layer.setFilter(filter);
assertEquals(layer.getFilter().toString(), filter.toString());
}
@Test
@UiThreadTest
public void testFillAntialiasAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("fill-antialias");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getFillAntialias().getValue());
assertNotNull(layer);
assertNull(layer.getFillAntialias().getValue());
// Set and Get
Boolean propertyValue = true;
layer.setProperties(fillAntialias(propertyValue));
assertEquals(layer.getFillAntialias().getValue(), propertyValue);
});
// Set and Get
Boolean propertyValue = true;
layer.setProperties(fillAntialias(propertyValue));
assertEquals(layer.getFillAntialias().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testFillOpacityTransition() {
validateTestSetup();
setupLayer();
Timber.i("fill-opacityTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setFillOpacityTransition(options);
assertEquals(layer.getFillOpacityTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setFillOpacityTransition(options);
assertEquals(layer.getFillOpacityTransition(), options);
}
@Test
@UiThreadTest
public void testFillOpacityAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("fill-opacity");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getFillOpacity().getValue());
assertNotNull(layer);
assertNull(layer.getFillOpacity().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(fillOpacity(propertyValue));
assertEquals(layer.getFillOpacity().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(fillOpacity(propertyValue));
assertEquals(layer.getFillOpacity().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testFillOpacityAsExpression() {
validateTestSetup();
setupLayer();
Timber.i("fill-opacity-expression");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getFillOpacity().getExpression());
assertNotNull(layer);
assertNull(layer.getFillOpacity().getExpression());
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(fillOpacity(expression));
assertEquals(layer.getFillOpacity().getExpression(), expression);
});
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(fillOpacity(expression));
assertEquals(layer.getFillOpacity().getExpression(), expression);
}
@Test
@UiThreadTest
public void testFillColorTransition() {
validateTestSetup();
setupLayer();
Timber.i("fill-colorTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setFillColorTransition(options);
assertEquals(layer.getFillColorTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setFillColorTransition(options);
assertEquals(layer.getFillColorTransition(), options);
}
@Test
@UiThreadTest
public void testFillColorAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("fill-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getFillColor().getValue());
assertNotNull(layer);
assertNull(layer.getFillColor().getValue());
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
layer.setProperties(fillColor(propertyValue));
assertEquals(layer.getFillColor().getValue(), propertyValue);
});
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
layer.setProperties(fillColor(propertyValue));
assertEquals(layer.getFillColor().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testFillColorAsExpression() {
validateTestSetup();
setupLayer();
Timber.i("fill-color-expression");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getFillColor().getExpression());
assertNotNull(layer);
assertNull(layer.getFillColor().getExpression());
// Set and Get
Expression expression = toColor(Expression.get("undefined"));
layer.setProperties(fillColor(expression));
assertEquals(layer.getFillColor().getExpression(), expression);
});
// Set and Get
Expression expression = toColor(Expression.get("undefined"));
layer.setProperties(fillColor(expression));
assertEquals(layer.getFillColor().getExpression(), expression);
}
@Test
@UiThreadTest
public void testFillColorAsIntConstant() {
validateTestSetup();
setupLayer();
Timber.i("fill-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
layer.setProperties(fillColor(Color.RED));
assertEquals(layer.getFillColorAsInt(), Color.RED);
});
// Set and Get
layer.setProperties(fillColor(Color.RED));
assertEquals(layer.getFillColorAsInt(), Color.RED);
}
@Test
@UiThreadTest
public void testFillOutlineColorTransition() {
validateTestSetup();
setupLayer();
Timber.i("fill-outline-colorTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setFillOutlineColorTransition(options);
assertEquals(layer.getFillOutlineColorTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setFillOutlineColorTransition(options);
assertEquals(layer.getFillOutlineColorTransition(), options);
}
@Test
@UiThreadTest
public void testFillOutlineColorAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("fill-outline-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getFillOutlineColor().getValue());
assertNotNull(layer);
assertNull(layer.getFillOutlineColor().getValue());
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
layer.setProperties(fillOutlineColor(propertyValue));
assertEquals(layer.getFillOutlineColor().getValue(), propertyValue);
});
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
layer.setProperties(fillOutlineColor(propertyValue));
assertEquals(layer.getFillOutlineColor().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testFillOutlineColorAsExpression() {
validateTestSetup();
setupLayer();
Timber.i("fill-outline-color-expression");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getFillOutlineColor().getExpression());
assertNotNull(layer);
assertNull(layer.getFillOutlineColor().getExpression());
// Set and Get
Expression expression = toColor(Expression.get("undefined"));
layer.setProperties(fillOutlineColor(expression));
assertEquals(layer.getFillOutlineColor().getExpression(), expression);
});
// Set and Get
Expression expression = toColor(Expression.get("undefined"));
layer.setProperties(fillOutlineColor(expression));
assertEquals(layer.getFillOutlineColor().getExpression(), expression);
}
@Test
@UiThreadTest
public void testFillOutlineColorAsIntConstant() {
validateTestSetup();
setupLayer();
Timber.i("fill-outline-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
layer.setProperties(fillOutlineColor(Color.RED));
assertEquals(layer.getFillOutlineColorAsInt(), Color.RED);
});
// Set and Get
layer.setProperties(fillOutlineColor(Color.RED));
assertEquals(layer.getFillOutlineColorAsInt(), Color.RED);
}
@Test
@UiThreadTest
public void testFillTranslateTransition() {
validateTestSetup();
setupLayer();
Timber.i("fill-translateTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setFillTranslateTransition(options);
assertEquals(layer.getFillTranslateTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setFillTranslateTransition(options);
assertEquals(layer.getFillTranslateTransition(), options);
}
@Test
@UiThreadTest
public void testFillTranslateAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("fill-translate");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getFillTranslate().getValue());
assertNotNull(layer);
assertNull(layer.getFillTranslate().getValue());
// Set and Get
Float[] propertyValue = new Float[] {0f, 0f};
layer.setProperties(fillTranslate(propertyValue));
assertEquals(layer.getFillTranslate().getValue(), propertyValue);
});
// Set and Get
Float[] propertyValue = new Float[] {0f, 0f};
layer.setProperties(fillTranslate(propertyValue));
assertEquals(layer.getFillTranslate().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testFillTranslateAnchorAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("fill-translate-anchor");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getFillTranslateAnchor().getValue());
assertNotNull(layer);
assertNull(layer.getFillTranslateAnchor().getValue());
// Set and Get
String propertyValue = FILL_TRANSLATE_ANCHOR_MAP;
layer.setProperties(fillTranslateAnchor(propertyValue));
assertEquals(layer.getFillTranslateAnchor().getValue(), propertyValue);
});
// Set and Get
String propertyValue = FILL_TRANSLATE_ANCHOR_MAP;
layer.setProperties(fillTranslateAnchor(propertyValue));
assertEquals(layer.getFillTranslateAnchor().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testFillPatternTransition() {
validateTestSetup();
setupLayer();
Timber.i("fill-patternTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setFillPatternTransition(options);
assertEquals(layer.getFillPatternTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setFillPatternTransition(options);
assertEquals(layer.getFillPatternTransition(), options);
}
@Test
@UiThreadTest
public void testFillPatternAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("fill-pattern");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getFillPattern().getValue());
assertNotNull(layer);
assertNull(layer.getFillPattern().getValue());
// Set and Get
String propertyValue = "pedestrian-polygon";
layer.setProperties(fillPattern(propertyValue));
assertEquals(layer.getFillPattern().getValue(), propertyValue);
});
// Set and Get
String propertyValue = "pedestrian-polygon";
layer.setProperties(fillPattern(propertyValue));
assertEquals(layer.getFillPattern().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testFillPatternAsExpression() {
validateTestSetup();
setupLayer();
Timber.i("fill-pattern-expression");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getFillPattern().getExpression());
assertNotNull(layer);
assertNull(layer.getFillPattern().getExpression());
// Set and Get
Expression expression = string(Expression.get("undefined"));
layer.setProperties(fillPattern(expression));
assertEquals(layer.getFillPattern().getExpression(), expression);
});
// Set and Get
Expression expression = string(Expression.get("undefined"));
layer.setProperties(fillPattern(expression));
assertEquals(layer.getFillPattern().getExpression(), expression);
}
}

View File

@@ -3,263 +3,213 @@
package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
import android.support.test.annotation.UiThreadTest;
import android.support.test.runner.AndroidJUnit4;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
import org.junit.Before;
import timber.log.Timber;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.HeatmapLayer;
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
import static org.junit.Assert.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
/**
* Basic smoke tests for HeatmapLayer
*/
@RunWith(AndroidJUnit4.class)
public class HeatmapLayerTest extends BaseActivityTest {
public class HeatmapLayerTest extends BaseLayerTest {
private HeatmapLayer layer;
@Override
protected Class getActivityClass() {
return EspressoTestActivity.class;
}
private void setupLayer() {
Timber.i("Retrieving layer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
Timber.i("Adding layer");
layer = new HeatmapLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.getStyle().addLayer(layer);
// Layer reference is now stale, get new reference
layer = mapboxMap.getStyle().getLayerAs("my-layer");
}
});
@Before
@UiThreadTest
public void beforeTest(){
super.before();
layer = new HeatmapLayer("my-layer", "composite");
layer.setSourceLayer("composite");
setupLayer(layer);
}
@Test
@UiThreadTest
public void testSourceId() {
validateTestSetup();
setupLayer();
Timber.i("SourceId");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
// Get source id
assertEquals(layer.getSourceId(), "composite");
});
assertNotNull(layer);
assertEquals(layer.getSourceId(), "composite");
}
@Test
@UiThreadTest
public void testSetVisibility() {
validateTestSetup();
setupLayer();
Timber.i("Visibility");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
// Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
// Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
});
// Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
}
@Test
@UiThreadTest
public void testSourceLayer() {
validateTestSetup();
setupLayer();
Timber.i("SourceLayer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Get initial
assertEquals(layer.getSourceLayer(), "composite");
// Get initial
assertEquals(layer.getSourceLayer(), "composite");
// Set
final String sourceLayer = "test";
layer.setSourceLayer(sourceLayer);
assertEquals(layer.getSourceLayer(), sourceLayer);
});
// Set
final String sourceLayer = "test";
layer.setSourceLayer(sourceLayer);
assertEquals(layer.getSourceLayer(), sourceLayer);
}
@Test
@UiThreadTest
public void testFilter() {
validateTestSetup();
setupLayer();
Timber.i("Filter");
invoke(mapboxMap, (uiController, mapboxMap1) -> {
assertNotNull(layer);
assertNotNull(layer);
// Get initial
assertEquals(layer.getFilter(), null);
// Get initial
assertEquals(layer.getFilter(), null);
// Set
Expression filter = eq(get("undefined"), literal(1.0));
layer.setFilter(filter);
assertEquals(layer.getFilter().toString(), filter.toString());
// Set
Expression filter = eq(get("undefined"), literal(1.0));
layer.setFilter(filter);
assertEquals(layer.getFilter().toString(), filter.toString());
// Set constant
filter = literal(true);
layer.setFilter(filter);
assertEquals(layer.getFilter().toString(), filter.toString());
});
// Set constant
filter = literal(true);
layer.setFilter(filter);
assertEquals(layer.getFilter().toString(), filter.toString());
}
@Test
@UiThreadTest
public void testHeatmapRadiusTransition() {
validateTestSetup();
setupLayer();
Timber.i("heatmap-radiusTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setHeatmapRadiusTransition(options);
assertEquals(layer.getHeatmapRadiusTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setHeatmapRadiusTransition(options);
assertEquals(layer.getHeatmapRadiusTransition(), options);
}
@Test
@UiThreadTest
public void testHeatmapRadiusAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("heatmap-radius");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getHeatmapRadius().getValue());
assertNotNull(layer);
assertNull(layer.getHeatmapRadius().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(heatmapRadius(propertyValue));
assertEquals(layer.getHeatmapRadius().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(heatmapRadius(propertyValue));
assertEquals(layer.getHeatmapRadius().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testHeatmapRadiusAsExpression() {
validateTestSetup();
setupLayer();
Timber.i("heatmap-radius-expression");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getHeatmapRadius().getExpression());
assertNotNull(layer);
assertNull(layer.getHeatmapRadius().getExpression());
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(heatmapRadius(expression));
assertEquals(layer.getHeatmapRadius().getExpression(), expression);
});
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(heatmapRadius(expression));
assertEquals(layer.getHeatmapRadius().getExpression(), expression);
}
@Test
@UiThreadTest
public void testHeatmapWeightAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("heatmap-weight");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getHeatmapWeight().getValue());
assertNotNull(layer);
assertNull(layer.getHeatmapWeight().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(heatmapWeight(propertyValue));
assertEquals(layer.getHeatmapWeight().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(heatmapWeight(propertyValue));
assertEquals(layer.getHeatmapWeight().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testHeatmapWeightAsExpression() {
validateTestSetup();
setupLayer();
Timber.i("heatmap-weight-expression");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getHeatmapWeight().getExpression());
assertNotNull(layer);
assertNull(layer.getHeatmapWeight().getExpression());
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(heatmapWeight(expression));
assertEquals(layer.getHeatmapWeight().getExpression(), expression);
});
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(heatmapWeight(expression));
assertEquals(layer.getHeatmapWeight().getExpression(), expression);
}
@Test
@UiThreadTest
public void testHeatmapIntensityTransition() {
validateTestSetup();
setupLayer();
Timber.i("heatmap-intensityTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setHeatmapIntensityTransition(options);
assertEquals(layer.getHeatmapIntensityTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setHeatmapIntensityTransition(options);
assertEquals(layer.getHeatmapIntensityTransition(), options);
}
@Test
@UiThreadTest
public void testHeatmapIntensityAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("heatmap-intensity");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getHeatmapIntensity().getValue());
assertNotNull(layer);
assertNull(layer.getHeatmapIntensity().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(heatmapIntensity(propertyValue));
assertEquals(layer.getHeatmapIntensity().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(heatmapIntensity(propertyValue));
assertEquals(layer.getHeatmapIntensity().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testHeatmapOpacityTransition() {
validateTestSetup();
setupLayer();
Timber.i("heatmap-opacityTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setHeatmapOpacityTransition(options);
assertEquals(layer.getHeatmapOpacityTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setHeatmapOpacityTransition(options);
assertEquals(layer.getHeatmapOpacityTransition(), options);
}
@Test
@UiThreadTest
public void testHeatmapOpacityAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("heatmap-opacity");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getHeatmapOpacity().getValue());
assertNotNull(layer);
assertNull(layer.getHeatmapOpacity().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(heatmapOpacity(propertyValue));
assertEquals(layer.getHeatmapOpacity().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(heatmapOpacity(propertyValue));
assertEquals(layer.getHeatmapOpacity().getValue(), propertyValue);
}
}

View File

@@ -3,277 +3,221 @@
package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
import android.support.test.annotation.UiThreadTest;
import android.support.test.runner.AndroidJUnit4;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
import org.junit.Before;
import timber.log.Timber;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.HillshadeLayer;
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
import static org.junit.Assert.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
/**
* Basic smoke tests for HillshadeLayer
*/
@RunWith(AndroidJUnit4.class)
public class HillshadeLayerTest extends BaseActivityTest {
public class HillshadeLayerTest extends BaseLayerTest {
private HillshadeLayer layer;
@Override
protected Class getActivityClass() {
return EspressoTestActivity.class;
}
private void setupLayer() {
Timber.i("Retrieving layer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
Timber.i("Adding layer");
layer = new HillshadeLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.getStyle().addLayer(layer);
// Layer reference is now stale, get new reference
layer = mapboxMap.getStyle().getLayerAs("my-layer");
}
});
@Before
@UiThreadTest
public void beforeTest(){
super.before();
layer = new HillshadeLayer("my-layer", "composite");
layer.setSourceLayer("composite");
setupLayer(layer);
}
@Test
@UiThreadTest
public void testSourceId() {
validateTestSetup();
setupLayer();
Timber.i("SourceId");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
// Get source id
assertEquals(layer.getSourceId(), "composite");
});
assertNotNull(layer);
assertEquals(layer.getSourceId(), "composite");
}
@Test
@UiThreadTest
public void testSetVisibility() {
validateTestSetup();
setupLayer();
Timber.i("Visibility");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
// Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
// Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
});
// Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
}
@Test
@UiThreadTest
public void testHillshadeIlluminationDirectionAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("hillshade-illumination-direction");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getHillshadeIlluminationDirection().getValue());
assertNotNull(layer);
assertNull(layer.getHillshadeIlluminationDirection().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(hillshadeIlluminationDirection(propertyValue));
assertEquals(layer.getHillshadeIlluminationDirection().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(hillshadeIlluminationDirection(propertyValue));
assertEquals(layer.getHillshadeIlluminationDirection().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testHillshadeIlluminationAnchorAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("hillshade-illumination-anchor");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getHillshadeIlluminationAnchor().getValue());
assertNotNull(layer);
assertNull(layer.getHillshadeIlluminationAnchor().getValue());
// Set and Get
String propertyValue = HILLSHADE_ILLUMINATION_ANCHOR_MAP;
layer.setProperties(hillshadeIlluminationAnchor(propertyValue));
assertEquals(layer.getHillshadeIlluminationAnchor().getValue(), propertyValue);
});
// Set and Get
String propertyValue = HILLSHADE_ILLUMINATION_ANCHOR_MAP;
layer.setProperties(hillshadeIlluminationAnchor(propertyValue));
assertEquals(layer.getHillshadeIlluminationAnchor().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testHillshadeExaggerationTransition() {
validateTestSetup();
setupLayer();
Timber.i("hillshade-exaggerationTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setHillshadeExaggerationTransition(options);
assertEquals(layer.getHillshadeExaggerationTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setHillshadeExaggerationTransition(options);
assertEquals(layer.getHillshadeExaggerationTransition(), options);
}
@Test
@UiThreadTest
public void testHillshadeExaggerationAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("hillshade-exaggeration");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getHillshadeExaggeration().getValue());
assertNotNull(layer);
assertNull(layer.getHillshadeExaggeration().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(hillshadeExaggeration(propertyValue));
assertEquals(layer.getHillshadeExaggeration().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(hillshadeExaggeration(propertyValue));
assertEquals(layer.getHillshadeExaggeration().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testHillshadeShadowColorTransition() {
validateTestSetup();
setupLayer();
Timber.i("hillshade-shadow-colorTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setHillshadeShadowColorTransition(options);
assertEquals(layer.getHillshadeShadowColorTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setHillshadeShadowColorTransition(options);
assertEquals(layer.getHillshadeShadowColorTransition(), options);
}
@Test
@UiThreadTest
public void testHillshadeShadowColorAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("hillshade-shadow-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getHillshadeShadowColor().getValue());
assertNotNull(layer);
assertNull(layer.getHillshadeShadowColor().getValue());
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
layer.setProperties(hillshadeShadowColor(propertyValue));
assertEquals(layer.getHillshadeShadowColor().getValue(), propertyValue);
});
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
layer.setProperties(hillshadeShadowColor(propertyValue));
assertEquals(layer.getHillshadeShadowColor().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testHillshadeShadowColorAsIntConstant() {
validateTestSetup();
setupLayer();
Timber.i("hillshade-shadow-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
layer.setProperties(hillshadeShadowColor(Color.RED));
assertEquals(layer.getHillshadeShadowColorAsInt(), Color.RED);
});
// Set and Get
layer.setProperties(hillshadeShadowColor(Color.RED));
assertEquals(layer.getHillshadeShadowColorAsInt(), Color.RED);
}
@Test
@UiThreadTest
public void testHillshadeHighlightColorTransition() {
validateTestSetup();
setupLayer();
Timber.i("hillshade-highlight-colorTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setHillshadeHighlightColorTransition(options);
assertEquals(layer.getHillshadeHighlightColorTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setHillshadeHighlightColorTransition(options);
assertEquals(layer.getHillshadeHighlightColorTransition(), options);
}
@Test
@UiThreadTest
public void testHillshadeHighlightColorAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("hillshade-highlight-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getHillshadeHighlightColor().getValue());
assertNotNull(layer);
assertNull(layer.getHillshadeHighlightColor().getValue());
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
layer.setProperties(hillshadeHighlightColor(propertyValue));
assertEquals(layer.getHillshadeHighlightColor().getValue(), propertyValue);
});
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
layer.setProperties(hillshadeHighlightColor(propertyValue));
assertEquals(layer.getHillshadeHighlightColor().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testHillshadeHighlightColorAsIntConstant() {
validateTestSetup();
setupLayer();
Timber.i("hillshade-highlight-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
layer.setProperties(hillshadeHighlightColor(Color.RED));
assertEquals(layer.getHillshadeHighlightColorAsInt(), Color.RED);
});
// Set and Get
layer.setProperties(hillshadeHighlightColor(Color.RED));
assertEquals(layer.getHillshadeHighlightColorAsInt(), Color.RED);
}
@Test
@UiThreadTest
public void testHillshadeAccentColorTransition() {
validateTestSetup();
setupLayer();
Timber.i("hillshade-accent-colorTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setHillshadeAccentColorTransition(options);
assertEquals(layer.getHillshadeAccentColorTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setHillshadeAccentColorTransition(options);
assertEquals(layer.getHillshadeAccentColorTransition(), options);
}
@Test
@UiThreadTest
public void testHillshadeAccentColorAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("hillshade-accent-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getHillshadeAccentColor().getValue());
assertNotNull(layer);
assertNull(layer.getHillshadeAccentColor().getValue());
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
layer.setProperties(hillshadeAccentColor(propertyValue));
assertEquals(layer.getHillshadeAccentColor().getValue(), propertyValue);
});
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
layer.setProperties(hillshadeAccentColor(propertyValue));
assertEquals(layer.getHillshadeAccentColor().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testHillshadeAccentColorAsIntConstant() {
validateTestSetup();
setupLayer();
Timber.i("hillshade-accent-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
layer.setProperties(hillshadeAccentColor(Color.RED));
assertEquals(layer.getHillshadeAccentColorAsInt(), Color.RED);
});
// Set and Get
layer.setProperties(hillshadeAccentColor(Color.RED));
assertEquals(layer.getHillshadeAccentColorAsInt(), Color.RED);
}
}

View File

@@ -3,607 +3,491 @@
package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
import android.support.test.annotation.UiThreadTest;
import android.support.test.runner.AndroidJUnit4;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
import org.junit.Before;
import timber.log.Timber;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.LineLayer;
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
import static org.junit.Assert.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
/**
* Basic smoke tests for LineLayer
*/
@RunWith(AndroidJUnit4.class)
public class LineLayerTest extends BaseActivityTest {
public class LineLayerTest extends BaseLayerTest {
private LineLayer layer;
@Override
protected Class getActivityClass() {
return EspressoTestActivity.class;
}
private void setupLayer() {
Timber.i("Retrieving layer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
Timber.i("Adding layer");
layer = new LineLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.getStyle().addLayer(layer);
// Layer reference is now stale, get new reference
layer = mapboxMap.getStyle().getLayerAs("my-layer");
}
});
@Before
@UiThreadTest
public void beforeTest(){
super.before();
layer = new LineLayer("my-layer", "composite");
layer.setSourceLayer("composite");
setupLayer(layer);
}
@Test
@UiThreadTest
public void testSourceId() {
validateTestSetup();
setupLayer();
Timber.i("SourceId");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
// Get source id
assertEquals(layer.getSourceId(), "composite");
});
assertNotNull(layer);
assertEquals(layer.getSourceId(), "composite");
}
@Test
@UiThreadTest
public void testSetVisibility() {
validateTestSetup();
setupLayer();
Timber.i("Visibility");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
// Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
// Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
});
// Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
}
@Test
@UiThreadTest
public void testSourceLayer() {
validateTestSetup();
setupLayer();
Timber.i("SourceLayer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Get initial
assertEquals(layer.getSourceLayer(), "composite");
// Get initial
assertEquals(layer.getSourceLayer(), "composite");
// Set
final String sourceLayer = "test";
layer.setSourceLayer(sourceLayer);
assertEquals(layer.getSourceLayer(), sourceLayer);
});
// Set
final String sourceLayer = "test";
layer.setSourceLayer(sourceLayer);
assertEquals(layer.getSourceLayer(), sourceLayer);
}
@Test
@UiThreadTest
public void testFilter() {
validateTestSetup();
setupLayer();
Timber.i("Filter");
invoke(mapboxMap, (uiController, mapboxMap1) -> {
assertNotNull(layer);
assertNotNull(layer);
// Get initial
assertEquals(layer.getFilter(), null);
// Get initial
assertEquals(layer.getFilter(), null);
// Set
Expression filter = eq(get("undefined"), literal(1.0));
layer.setFilter(filter);
assertEquals(layer.getFilter().toString(), filter.toString());
// Set
Expression filter = eq(get("undefined"), literal(1.0));
layer.setFilter(filter);
assertEquals(layer.getFilter().toString(), filter.toString());
// Set constant
filter = literal(true);
layer.setFilter(filter);
assertEquals(layer.getFilter().toString(), filter.toString());
});
// Set constant
filter = literal(true);
layer.setFilter(filter);
assertEquals(layer.getFilter().toString(), filter.toString());
}
@Test
@UiThreadTest
public void testLineCapAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("line-cap");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getLineCap().getValue());
assertNotNull(layer);
assertNull(layer.getLineCap().getValue());
// Set and Get
String propertyValue = LINE_CAP_BUTT;
layer.setProperties(lineCap(propertyValue));
assertEquals(layer.getLineCap().getValue(), propertyValue);
});
// Set and Get
String propertyValue = LINE_CAP_BUTT;
layer.setProperties(lineCap(propertyValue));
assertEquals(layer.getLineCap().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testLineJoinAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("line-join");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getLineJoin().getValue());
assertNotNull(layer);
assertNull(layer.getLineJoin().getValue());
// Set and Get
String propertyValue = LINE_JOIN_BEVEL;
layer.setProperties(lineJoin(propertyValue));
assertEquals(layer.getLineJoin().getValue(), propertyValue);
});
// Set and Get
String propertyValue = LINE_JOIN_BEVEL;
layer.setProperties(lineJoin(propertyValue));
assertEquals(layer.getLineJoin().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testLineJoinAsExpression() {
validateTestSetup();
setupLayer();
Timber.i("line-join-expression");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getLineJoin().getExpression());
assertNotNull(layer);
assertNull(layer.getLineJoin().getExpression());
// Set and Get
Expression expression = string(Expression.get("undefined"));
layer.setProperties(lineJoin(expression));
assertEquals(layer.getLineJoin().getExpression(), expression);
});
// Set and Get
Expression expression = string(Expression.get("undefined"));
layer.setProperties(lineJoin(expression));
assertEquals(layer.getLineJoin().getExpression(), expression);
}
@Test
@UiThreadTest
public void testLineMiterLimitAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("line-miter-limit");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getLineMiterLimit().getValue());
assertNotNull(layer);
assertNull(layer.getLineMiterLimit().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(lineMiterLimit(propertyValue));
assertEquals(layer.getLineMiterLimit().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(lineMiterLimit(propertyValue));
assertEquals(layer.getLineMiterLimit().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testLineRoundLimitAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("line-round-limit");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getLineRoundLimit().getValue());
assertNotNull(layer);
assertNull(layer.getLineRoundLimit().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(lineRoundLimit(propertyValue));
assertEquals(layer.getLineRoundLimit().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(lineRoundLimit(propertyValue));
assertEquals(layer.getLineRoundLimit().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testLineOpacityTransition() {
validateTestSetup();
setupLayer();
Timber.i("line-opacityTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setLineOpacityTransition(options);
assertEquals(layer.getLineOpacityTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setLineOpacityTransition(options);
assertEquals(layer.getLineOpacityTransition(), options);
}
@Test
@UiThreadTest
public void testLineOpacityAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("line-opacity");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getLineOpacity().getValue());
assertNotNull(layer);
assertNull(layer.getLineOpacity().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(lineOpacity(propertyValue));
assertEquals(layer.getLineOpacity().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(lineOpacity(propertyValue));
assertEquals(layer.getLineOpacity().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testLineOpacityAsExpression() {
validateTestSetup();
setupLayer();
Timber.i("line-opacity-expression");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getLineOpacity().getExpression());
assertNotNull(layer);
assertNull(layer.getLineOpacity().getExpression());
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(lineOpacity(expression));
assertEquals(layer.getLineOpacity().getExpression(), expression);
});
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(lineOpacity(expression));
assertEquals(layer.getLineOpacity().getExpression(), expression);
}
@Test
@UiThreadTest
public void testLineColorTransition() {
validateTestSetup();
setupLayer();
Timber.i("line-colorTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setLineColorTransition(options);
assertEquals(layer.getLineColorTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setLineColorTransition(options);
assertEquals(layer.getLineColorTransition(), options);
}
@Test
@UiThreadTest
public void testLineColorAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("line-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getLineColor().getValue());
assertNotNull(layer);
assertNull(layer.getLineColor().getValue());
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
layer.setProperties(lineColor(propertyValue));
assertEquals(layer.getLineColor().getValue(), propertyValue);
});
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
layer.setProperties(lineColor(propertyValue));
assertEquals(layer.getLineColor().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testLineColorAsExpression() {
validateTestSetup();
setupLayer();
Timber.i("line-color-expression");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getLineColor().getExpression());
assertNotNull(layer);
assertNull(layer.getLineColor().getExpression());
// Set and Get
Expression expression = toColor(Expression.get("undefined"));
layer.setProperties(lineColor(expression));
assertEquals(layer.getLineColor().getExpression(), expression);
});
// Set and Get
Expression expression = toColor(Expression.get("undefined"));
layer.setProperties(lineColor(expression));
assertEquals(layer.getLineColor().getExpression(), expression);
}
@Test
@UiThreadTest
public void testLineColorAsIntConstant() {
validateTestSetup();
setupLayer();
Timber.i("line-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
layer.setProperties(lineColor(Color.RED));
assertEquals(layer.getLineColorAsInt(), Color.RED);
});
// Set and Get
layer.setProperties(lineColor(Color.RED));
assertEquals(layer.getLineColorAsInt(), Color.RED);
}
@Test
@UiThreadTest
public void testLineTranslateTransition() {
validateTestSetup();
setupLayer();
Timber.i("line-translateTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setLineTranslateTransition(options);
assertEquals(layer.getLineTranslateTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setLineTranslateTransition(options);
assertEquals(layer.getLineTranslateTransition(), options);
}
@Test
@UiThreadTest
public void testLineTranslateAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("line-translate");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getLineTranslate().getValue());
assertNotNull(layer);
assertNull(layer.getLineTranslate().getValue());
// Set and Get
Float[] propertyValue = new Float[] {0f, 0f};
layer.setProperties(lineTranslate(propertyValue));
assertEquals(layer.getLineTranslate().getValue(), propertyValue);
});
// Set and Get
Float[] propertyValue = new Float[] {0f, 0f};
layer.setProperties(lineTranslate(propertyValue));
assertEquals(layer.getLineTranslate().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testLineTranslateAnchorAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("line-translate-anchor");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getLineTranslateAnchor().getValue());
assertNotNull(layer);
assertNull(layer.getLineTranslateAnchor().getValue());
// Set and Get
String propertyValue = LINE_TRANSLATE_ANCHOR_MAP;
layer.setProperties(lineTranslateAnchor(propertyValue));
assertEquals(layer.getLineTranslateAnchor().getValue(), propertyValue);
});
// Set and Get
String propertyValue = LINE_TRANSLATE_ANCHOR_MAP;
layer.setProperties(lineTranslateAnchor(propertyValue));
assertEquals(layer.getLineTranslateAnchor().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testLineWidthTransition() {
validateTestSetup();
setupLayer();
Timber.i("line-widthTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setLineWidthTransition(options);
assertEquals(layer.getLineWidthTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setLineWidthTransition(options);
assertEquals(layer.getLineWidthTransition(), options);
}
@Test
@UiThreadTest
public void testLineWidthAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("line-width");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getLineWidth().getValue());
assertNotNull(layer);
assertNull(layer.getLineWidth().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(lineWidth(propertyValue));
assertEquals(layer.getLineWidth().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(lineWidth(propertyValue));
assertEquals(layer.getLineWidth().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testLineWidthAsExpression() {
validateTestSetup();
setupLayer();
Timber.i("line-width-expression");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getLineWidth().getExpression());
assertNotNull(layer);
assertNull(layer.getLineWidth().getExpression());
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(lineWidth(expression));
assertEquals(layer.getLineWidth().getExpression(), expression);
});
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(lineWidth(expression));
assertEquals(layer.getLineWidth().getExpression(), expression);
}
@Test
@UiThreadTest
public void testLineGapWidthTransition() {
validateTestSetup();
setupLayer();
Timber.i("line-gap-widthTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setLineGapWidthTransition(options);
assertEquals(layer.getLineGapWidthTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setLineGapWidthTransition(options);
assertEquals(layer.getLineGapWidthTransition(), options);
}
@Test
@UiThreadTest
public void testLineGapWidthAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("line-gap-width");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getLineGapWidth().getValue());
assertNotNull(layer);
assertNull(layer.getLineGapWidth().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(lineGapWidth(propertyValue));
assertEquals(layer.getLineGapWidth().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(lineGapWidth(propertyValue));
assertEquals(layer.getLineGapWidth().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testLineGapWidthAsExpression() {
validateTestSetup();
setupLayer();
Timber.i("line-gap-width-expression");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getLineGapWidth().getExpression());
assertNotNull(layer);
assertNull(layer.getLineGapWidth().getExpression());
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(lineGapWidth(expression));
assertEquals(layer.getLineGapWidth().getExpression(), expression);
});
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(lineGapWidth(expression));
assertEquals(layer.getLineGapWidth().getExpression(), expression);
}
@Test
@UiThreadTest
public void testLineOffsetTransition() {
validateTestSetup();
setupLayer();
Timber.i("line-offsetTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setLineOffsetTransition(options);
assertEquals(layer.getLineOffsetTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setLineOffsetTransition(options);
assertEquals(layer.getLineOffsetTransition(), options);
}
@Test
@UiThreadTest
public void testLineOffsetAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("line-offset");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getLineOffset().getValue());
assertNotNull(layer);
assertNull(layer.getLineOffset().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(lineOffset(propertyValue));
assertEquals(layer.getLineOffset().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(lineOffset(propertyValue));
assertEquals(layer.getLineOffset().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testLineBlurTransition() {
validateTestSetup();
setupLayer();
Timber.i("line-blurTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setLineBlurTransition(options);
assertEquals(layer.getLineBlurTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setLineBlurTransition(options);
assertEquals(layer.getLineBlurTransition(), options);
}
@Test
@UiThreadTest
public void testLineBlurAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("line-blur");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getLineBlur().getValue());
assertNotNull(layer);
assertNull(layer.getLineBlur().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(lineBlur(propertyValue));
assertEquals(layer.getLineBlur().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(lineBlur(propertyValue));
assertEquals(layer.getLineBlur().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testLineBlurAsExpression() {
validateTestSetup();
setupLayer();
Timber.i("line-blur-expression");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getLineBlur().getExpression());
assertNotNull(layer);
assertNull(layer.getLineBlur().getExpression());
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(lineBlur(expression));
assertEquals(layer.getLineBlur().getExpression(), expression);
});
// Set and Get
Expression expression = number(Expression.get("undefined"));
layer.setProperties(lineBlur(expression));
assertEquals(layer.getLineBlur().getExpression(), expression);
}
@Test
@UiThreadTest
public void testLineDasharrayTransition() {
validateTestSetup();
setupLayer();
Timber.i("line-dasharrayTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setLineDasharrayTransition(options);
assertEquals(layer.getLineDasharrayTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setLineDasharrayTransition(options);
assertEquals(layer.getLineDasharrayTransition(), options);
}
@Test
@UiThreadTest
public void testLineDasharrayAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("line-dasharray");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getLineDasharray().getValue());
assertNotNull(layer);
assertNull(layer.getLineDasharray().getValue());
// Set and Get
Float[] propertyValue = new Float[] {};
layer.setProperties(lineDasharray(propertyValue));
assertEquals(layer.getLineDasharray().getValue(), propertyValue);
});
// Set and Get
Float[] propertyValue = new Float[] {};
layer.setProperties(lineDasharray(propertyValue));
assertEquals(layer.getLineDasharray().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testLinePatternTransition() {
validateTestSetup();
setupLayer();
Timber.i("line-patternTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setLinePatternTransition(options);
assertEquals(layer.getLinePatternTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setLinePatternTransition(options);
assertEquals(layer.getLinePatternTransition(), options);
}
@Test
@UiThreadTest
public void testLinePatternAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("line-pattern");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getLinePattern().getValue());
assertNotNull(layer);
assertNull(layer.getLinePattern().getValue());
// Set and Get
String propertyValue = "pedestrian-polygon";
layer.setProperties(linePattern(propertyValue));
assertEquals(layer.getLinePattern().getValue(), propertyValue);
});
// Set and Get
String propertyValue = "pedestrian-polygon";
layer.setProperties(linePattern(propertyValue));
assertEquals(layer.getLinePattern().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testLinePatternAsExpression() {
validateTestSetup();
setupLayer();
Timber.i("line-pattern-expression");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getLinePattern().getExpression());
assertNotNull(layer);
assertNull(layer.getLinePattern().getExpression());
// Set and Get
Expression expression = string(Expression.get("undefined"));
layer.setProperties(linePattern(expression));
assertEquals(layer.getLinePattern().getExpression(), expression);
});
// Set and Get
Expression expression = string(Expression.get("undefined"));
layer.setProperties(linePattern(expression));
assertEquals(layer.getLinePattern().getExpression(), expression);
}
}

View File

@@ -3,297 +3,238 @@
package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
import android.support.test.annotation.UiThreadTest;
import android.support.test.runner.AndroidJUnit4;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
import org.junit.Before;
import timber.log.Timber;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.RasterLayer;
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
import static org.junit.Assert.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
/**
* Basic smoke tests for RasterLayer
*/
@RunWith(AndroidJUnit4.class)
public class RasterLayerTest extends BaseActivityTest {
public class RasterLayerTest extends BaseLayerTest {
private RasterLayer layer;
@Override
protected Class getActivityClass() {
return EspressoTestActivity.class;
}
private void setupLayer() {
Timber.i("Retrieving layer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
Timber.i("Adding layer");
layer = new RasterLayer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.getStyle().addLayer(layer);
// Layer reference is now stale, get new reference
layer = mapboxMap.getStyle().getLayerAs("my-layer");
}
});
@Before
@UiThreadTest
public void beforeTest(){
super.before();
layer = new RasterLayer("my-layer", "composite");
layer.setSourceLayer("composite");
setupLayer(layer);
}
@Test
@UiThreadTest
public void testSourceId() {
validateTestSetup();
setupLayer();
Timber.i("SourceId");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
// Get source id
assertEquals(layer.getSourceId(), "composite");
});
assertNotNull(layer);
assertEquals(layer.getSourceId(), "composite");
}
@Test
@UiThreadTest
public void testSetVisibility() {
validateTestSetup();
setupLayer();
Timber.i("Visibility");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
// Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
// Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
});
// Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
}
@Test
@UiThreadTest
public void testRasterOpacityTransition() {
validateTestSetup();
setupLayer();
Timber.i("raster-opacityTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setRasterOpacityTransition(options);
assertEquals(layer.getRasterOpacityTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setRasterOpacityTransition(options);
assertEquals(layer.getRasterOpacityTransition(), options);
}
@Test
@UiThreadTest
public void testRasterOpacityAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("raster-opacity");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getRasterOpacity().getValue());
assertNotNull(layer);
assertNull(layer.getRasterOpacity().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(rasterOpacity(propertyValue));
assertEquals(layer.getRasterOpacity().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(rasterOpacity(propertyValue));
assertEquals(layer.getRasterOpacity().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testRasterHueRotateTransition() {
validateTestSetup();
setupLayer();
Timber.i("raster-hue-rotateTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setRasterHueRotateTransition(options);
assertEquals(layer.getRasterHueRotateTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setRasterHueRotateTransition(options);
assertEquals(layer.getRasterHueRotateTransition(), options);
}
@Test
@UiThreadTest
public void testRasterHueRotateAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("raster-hue-rotate");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getRasterHueRotate().getValue());
assertNotNull(layer);
assertNull(layer.getRasterHueRotate().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(rasterHueRotate(propertyValue));
assertEquals(layer.getRasterHueRotate().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(rasterHueRotate(propertyValue));
assertEquals(layer.getRasterHueRotate().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testRasterBrightnessMinTransition() {
validateTestSetup();
setupLayer();
Timber.i("raster-brightness-minTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setRasterBrightnessMinTransition(options);
assertEquals(layer.getRasterBrightnessMinTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setRasterBrightnessMinTransition(options);
assertEquals(layer.getRasterBrightnessMinTransition(), options);
}
@Test
@UiThreadTest
public void testRasterBrightnessMinAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("raster-brightness-min");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getRasterBrightnessMin().getValue());
assertNotNull(layer);
assertNull(layer.getRasterBrightnessMin().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(rasterBrightnessMin(propertyValue));
assertEquals(layer.getRasterBrightnessMin().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(rasterBrightnessMin(propertyValue));
assertEquals(layer.getRasterBrightnessMin().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testRasterBrightnessMaxTransition() {
validateTestSetup();
setupLayer();
Timber.i("raster-brightness-maxTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setRasterBrightnessMaxTransition(options);
assertEquals(layer.getRasterBrightnessMaxTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setRasterBrightnessMaxTransition(options);
assertEquals(layer.getRasterBrightnessMaxTransition(), options);
}
@Test
@UiThreadTest
public void testRasterBrightnessMaxAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("raster-brightness-max");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getRasterBrightnessMax().getValue());
assertNotNull(layer);
assertNull(layer.getRasterBrightnessMax().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(rasterBrightnessMax(propertyValue));
assertEquals(layer.getRasterBrightnessMax().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(rasterBrightnessMax(propertyValue));
assertEquals(layer.getRasterBrightnessMax().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testRasterSaturationTransition() {
validateTestSetup();
setupLayer();
Timber.i("raster-saturationTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setRasterSaturationTransition(options);
assertEquals(layer.getRasterSaturationTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setRasterSaturationTransition(options);
assertEquals(layer.getRasterSaturationTransition(), options);
}
@Test
@UiThreadTest
public void testRasterSaturationAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("raster-saturation");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getRasterSaturation().getValue());
assertNotNull(layer);
assertNull(layer.getRasterSaturation().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(rasterSaturation(propertyValue));
assertEquals(layer.getRasterSaturation().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(rasterSaturation(propertyValue));
assertEquals(layer.getRasterSaturation().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testRasterContrastTransition() {
validateTestSetup();
setupLayer();
Timber.i("raster-contrastTransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setRasterContrastTransition(options);
assertEquals(layer.getRasterContrastTransition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setRasterContrastTransition(options);
assertEquals(layer.getRasterContrastTransition(), options);
}
@Test
@UiThreadTest
public void testRasterContrastAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("raster-contrast");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getRasterContrast().getValue());
assertNotNull(layer);
assertNull(layer.getRasterContrast().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(rasterContrast(propertyValue));
assertEquals(layer.getRasterContrast().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(rasterContrast(propertyValue));
assertEquals(layer.getRasterContrast().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testRasterResamplingAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("raster-resampling");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getRasterResampling().getValue());
assertNotNull(layer);
assertNull(layer.getRasterResampling().getValue());
// Set and Get
String propertyValue = RASTER_RESAMPLING_LINEAR;
layer.setProperties(rasterResampling(propertyValue));
assertEquals(layer.getRasterResampling().getValue(), propertyValue);
});
// Set and Get
String propertyValue = RASTER_RESAMPLING_LINEAR;
layer.setProperties(rasterResampling(propertyValue));
assertEquals(layer.getRasterResampling().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testRasterFadeDurationAsConstant() {
validateTestSetup();
setupLayer();
Timber.i("raster-fade-duration");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.getRasterFadeDuration().getValue());
assertNotNull(layer);
assertNull(layer.getRasterFadeDuration().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(rasterFadeDuration(propertyValue));
assertEquals(layer.getRasterFadeDuration().getValue(), propertyValue);
});
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(rasterFadeDuration(propertyValue));
assertEquals(layer.getRasterFadeDuration().getValue(), propertyValue);
}
}

View File

@@ -7,8 +7,11 @@
package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
import android.support.test.annotation.UiThreadTest;
import android.support.test.runner.AndroidJUnit4;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
import org.junit.Before;
import timber.log.Timber;
import com.mapbox.mapboxsdk.style.expressions.Expression;
@@ -17,125 +20,96 @@ import com.mapbox.mapboxsdk.style.layers.<%- camelize(type) %>Layer;
import com.mapbox.mapboxsdk.style.types.Formatted;
import com.mapbox.mapboxsdk.style.types.FormattedSection;
<% } -%>
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
import static org.junit.Assert.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
/**
* Basic smoke tests for <%- camelize(type) %>Layer
*/
@RunWith(AndroidJUnit4.class)
public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
public class <%- camelize(type) %>LayerTest extends BaseLayerTest {
private <%- camelize(type) %>Layer layer;
@Override
protected Class getActivityClass() {
return EspressoTestActivity.class;
}
private void setupLayer() {
@Before
@UiThreadTest
public void beforeTest(){
super.before();
<% if (type === 'background') { -%>
Timber.i("Retrieving layer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
layer = mapboxMap.getStyle().getLayerAs("background");
});
layer = new <%- camelize(type) %>Layer("my-layer");
<% } else { -%>
Timber.i("Retrieving layer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
Timber.i("Adding layer");
layer = new <%- camelize(type) %>Layer("my-layer", "composite");
layer.setSourceLayer("composite");
mapboxMap.getStyle().addLayer(layer);
// Layer reference is now stale, get new reference
layer = mapboxMap.getStyle().getLayerAs("my-layer");
}
});
layer = new <%- camelize(type) %>Layer("my-layer", "composite");
layer.setSourceLayer("composite");
<% } -%>
setupLayer(layer);
}
<% if (type !== 'background') { -%>
@Test
@UiThreadTest
public void testSourceId() {
validateTestSetup();
setupLayer();
Timber.i("SourceId");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
// Get source id
assertEquals(layer.getSourceId(), "composite");
});
assertNotNull(layer);
assertEquals(layer.getSourceId(), "composite");
}
<% } -%>
@Test
@UiThreadTest
public void testSetVisibility() {
validateTestSetup();
setupLayer();
Timber.i("Visibility");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
// Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
// Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
});
// Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
}
<% if (!(type === 'background' || type === 'raster' || type === 'hillshade')) { -%>
@Test
@UiThreadTest
public void testSourceLayer() {
validateTestSetup();
setupLayer();
Timber.i("SourceLayer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Get initial
assertEquals(layer.getSourceLayer(), "composite");
// Get initial
assertEquals(layer.getSourceLayer(), "composite");
// Set
final String sourceLayer = "test";
layer.setSourceLayer(sourceLayer);
assertEquals(layer.getSourceLayer(), sourceLayer);
});
// Set
final String sourceLayer = "test";
layer.setSourceLayer(sourceLayer);
assertEquals(layer.getSourceLayer(), sourceLayer);
}
@Test
@UiThreadTest
public void testFilter() {
validateTestSetup();
setupLayer();
Timber.i("Filter");
invoke(mapboxMap, (uiController, mapboxMap1) -> {
assertNotNull(layer);
assertNotNull(layer);
// Get initial
assertEquals(layer.getFilter(), null);
// Get initial
assertEquals(layer.getFilter(), null);
// Set
Expression filter = eq(get("undefined"), literal(1.0));
layer.setFilter(filter);
assertEquals(layer.getFilter().toString(), filter.toString());
// Set
Expression filter = eq(get("undefined"), literal(1.0));
layer.setFilter(filter);
assertEquals(layer.getFilter().toString(), filter.toString());
// Set constant
filter = literal(true);
layer.setFilter(filter);
assertEquals(layer.getFilter().toString(), filter.toString());
});
// Set constant
filter = literal(true);
layer.setFilter(filter);
assertEquals(layer.getFilter().toString(), filter.toString());
}
@@ -145,89 +119,75 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
<% if (property.transition) { -%>
@Test
@UiThreadTest
public void test<%- camelize(property.name) %>Transition() {
validateTestSetup();
setupLayer();
Timber.i("<%- property.name %>TransitionOptions");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.set<%- camelize(property.name) %>Transition(options);
assertEquals(layer.get<%- camelize(property.name) %>Transition(), options);
});
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.set<%- camelize(property.name) %>Transition(options);
assertEquals(layer.get<%- camelize(property.name) %>Transition(), options);
}
<% } -%>
@Test
@UiThreadTest
public void test<%- camelize(property.name) %>AsConstant() {
validateTestSetup();
setupLayer();
Timber.i("<%- property.name %>");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.get<%- camelize(property.name) %>().getValue());
assertNotNull(layer);
assertNull(layer.get<%- camelize(property.name) %>().getValue());
// Set and Get
<%- propertyType(property) %> propertyValue = <%- defaultValueJava(property) %>;
// Set and Get
<%- propertyType(property) %> propertyValue = <%- defaultValueJava(property) %>;
<% if (property.type === 'formatted') { -%>
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>("default"));
assertEquals(layer.get<%- camelize(property.name) %>().getValue(), propertyValue);
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>("default"));
assertEquals(layer.get<%- camelize(property.name) %>().getValue(), propertyValue);
<% } -%>
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(propertyValue));
assertEquals(layer.get<%- camelize(property.name) %>().getValue(), propertyValue);
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(propertyValue));
assertEquals(layer.get<%- camelize(property.name) %>().getValue(), propertyValue);
<% if (property.tokens) { -%>
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>("{token}"));
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>("{token}"));
<% if (property.type === 'formatted') { -%>
assertEquals(layer.get<%- camelize(property.name) %>().getExpression(), <%- defaultExpressionJava(property) %>(Expression.formatEntry(Expression.toString(Expression.get("token")))));
assertEquals(layer.get<%- camelize(property.name) %>().getExpression(), <%- defaultExpressionJava(property) %>(Expression.formatEntry(Expression.toString(Expression.get("token")))));
<% } else {-%>
assertEquals(layer.get<%- camelize(property.name) %>().getExpression(), Expression.toString(Expression.get("token")));
assertEquals(layer.get<%- camelize(property.name) %>().getExpression(), Expression.toString(Expression.get("token")));
<% } -%>
<% } -%>
});
}
<% if (property['property-type'] === 'data-driven' || property['property-type'] === 'cross-faded-data-driven') { -%>
<% if (!(property.name.endsWith("-font")||property.name.endsWith("-offset"))) { -%>
@Test
@UiThreadTest
public void test<%- camelize(property.name) %>AsExpression() {
validateTestSetup();
setupLayer();
Timber.i("<%- property.name %>-expression");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
assertNull(layer.get<%- camelize(property.name) %>().getExpression());
assertNotNull(layer);
assertNull(layer.get<%- camelize(property.name) %>().getExpression());
// Set and Get
// Set and Get
<% if (property.type === 'formatted') { -%>
Expression expression = <%- defaultExpressionJava(property) %>(Expression.formatEntry(Expression.get("undefined"), FormatOption.formatFontScale(2.0), FormatOption.formatTextFont(new String[]{"Open Sans Regular", "Arial Unicode MS Regular"})));
Expression expression = <%- defaultExpressionJava(property) %>(Expression.formatEntry(Expression.get("undefined"), FormatOption.formatFontScale(2.0), FormatOption.formatTextFont(new String[]{"Open Sans Regular", "Arial Unicode MS Regular"})));
<% } else { -%>
Expression expression = <%- defaultExpressionJava(property) %>(Expression.get("undefined"));
Expression expression = <%- defaultExpressionJava(property) %>(Expression.get("undefined"));
<% } -%>
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(expression));
assertEquals(layer.get<%- camelize(property.name) %>().getExpression(), expression);
});
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(expression));
assertEquals(layer.get<%- camelize(property.name) %>().getExpression(), expression);
}
<% } -%>
<% } -%>
<% if (property.type == 'color') { -%>
@Test
@UiThreadTest
public void test<%- camelize(property.name) %>AsIntConstant() {
validateTestSetup();
setupLayer();
Timber.i("<%- property.name %>");
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(layer);
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);
}
<% } -%>
<% } -%>