[android] #5610 - Runtime style api - part 2
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
package com.mapbox.mapboxsdk.style;
|
||||
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.espresso.BaseTest;
|
||||
import com.mapbox.mapboxsdk.testapp.espresso.utils.OnMapReadyIdlingResource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for BackgroundLayer
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class BackgroundLayerTest extends BaseTest {
|
||||
private static final String TAG = BackgroundLayerTest.class.getSimpleName();
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private BackgroundLayer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Log.i(TAG, "Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Log.i(TAG, "visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
//Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Log.i(TAG, "Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Log.i(TAG, "background-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(backgroundColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getBackgroundColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundPattern() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Log.i(TAG, "Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Log.i(TAG, "background-pattern");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(backgroundPattern("pedestrian-polygon"));
|
||||
assertEquals((String) layer.getBackgroundPattern().getValue(), (String) "pedestrian-polygon");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Log.i(TAG, "Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Log.i(TAG, "background-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(backgroundOpacity(0.3f));
|
||||
assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
package com.mapbox.mapboxsdk.style;
|
||||
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.espresso.BaseTest;
|
||||
import com.mapbox.mapboxsdk.testapp.espresso.utils.OnMapReadyIdlingResource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for CircleLayer
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class CircleLayerTest extends BaseTest {
|
||||
private static final String TAG = CircleLayerTest.class.getSimpleName();
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private CircleLayer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
//Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircleRadius() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "circle-radius");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circleRadius(0.3f));
|
||||
assertEquals((Float) layer.getCircleRadius().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircleColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "circle-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circleColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getCircleColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircleBlur() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "circle-blur");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circleBlur(0.3f));
|
||||
assertEquals((Float) layer.getCircleBlur().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircleOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "circle-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circleOpacity(0.3f));
|
||||
assertEquals((Float) layer.getCircleOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircleTranslate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "circle-translate");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circleTranslate(new Float[]{0f,0f}));
|
||||
assertEquals((Float[]) layer.getCircleTranslate().getValue(), (Float[]) new Float[]{0f,0f});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircleTranslateAnchor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "circle-translate-anchor");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circleTranslateAnchor(CIRCLE_TRANSLATE_ANCHOR_MAP));
|
||||
assertEquals((String) layer.getCircleTranslateAnchor().getValue(), (String) CIRCLE_TRANSLATE_ANCHOR_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCirclePitchScale() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "circle-pitch-scale");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(circlePitchScale(CIRCLE_PITCH_SCALE_MAP));
|
||||
assertEquals((String) layer.getCirclePitchScale().getValue(), (String) CIRCLE_PITCH_SCALE_MAP);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
package com.mapbox.mapboxsdk.style;
|
||||
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.FillLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.espresso.BaseTest;
|
||||
import com.mapbox.mapboxsdk.testapp.espresso.utils.OnMapReadyIdlingResource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for FillLayer
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class FillLayerTest extends BaseTest {
|
||||
private static final String TAG = FillLayerTest.class.getSimpleName();
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private FillLayer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
//Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillAntialias() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "fill-antialias");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(fillAntialias(true));
|
||||
assertEquals((Boolean) layer.getFillAntialias().getValue(), (Boolean) true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "fill-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(fillOpacity(0.3f));
|
||||
assertEquals((Float) layer.getFillOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "fill-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(fillColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getFillColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "fill-outline-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(fillOutlineColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getFillOutlineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillTranslate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "fill-translate");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(fillTranslate(new Float[]{0f,0f}));
|
||||
assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[]{0f,0f});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillTranslateAnchor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "fill-translate-anchor");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP));
|
||||
assertEquals((String) layer.getFillTranslateAnchor().getValue(), (String) FILL_TRANSLATE_ANCHOR_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillPattern() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "fill-pattern");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(fillPattern("pedestrian-polygon"));
|
||||
assertEquals((String) layer.getFillPattern().getValue(), (String) "pedestrian-polygon");
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,386 @@
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
package com.mapbox.mapboxsdk.style;
|
||||
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.LineLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.espresso.BaseTest;
|
||||
import com.mapbox.mapboxsdk.testapp.espresso.utils.OnMapReadyIdlingResource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for LineLayer
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class LineLayerTest extends BaseTest {
|
||||
private static final String TAG = LineLayerTest.class.getSimpleName();
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private LineLayer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
//Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineCap() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "line-cap");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineCap(LINE_CAP_BUTT));
|
||||
assertEquals((String) layer.getLineCap().getValue(), (String) LINE_CAP_BUTT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineJoin() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "line-join");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineJoin(LINE_JOIN_BEVEL));
|
||||
assertEquals((String) layer.getLineJoin().getValue(), (String) LINE_JOIN_BEVEL);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineMiterLimit() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "line-miter-limit");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineMiterLimit(0.3f));
|
||||
assertEquals((Float) layer.getLineMiterLimit().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineRoundLimit() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "line-round-limit");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineRoundLimit(0.3f));
|
||||
assertEquals((Float) layer.getLineRoundLimit().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "line-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineOpacity(0.3f));
|
||||
assertEquals((Float) layer.getLineOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "line-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getLineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineTranslate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "line-translate");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineTranslate(new Float[]{0f,0f}));
|
||||
assertEquals((Float[]) layer.getLineTranslate().getValue(), (Float[]) new Float[]{0f,0f});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineTranslateAnchor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "line-translate-anchor");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineTranslateAnchor(LINE_TRANSLATE_ANCHOR_MAP));
|
||||
assertEquals((String) layer.getLineTranslateAnchor().getValue(), (String) LINE_TRANSLATE_ANCHOR_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineWidth() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "line-width");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineWidth(0.3f));
|
||||
assertEquals((Float) layer.getLineWidth().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineGapWidth() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "line-gap-width");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineGapWidth(0.3f));
|
||||
assertEquals((Float) layer.getLineGapWidth().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineOffset() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "line-offset");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineOffset(0.3f));
|
||||
assertEquals((Float) layer.getLineOffset().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineBlur() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "line-blur");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineBlur(0.3f));
|
||||
assertEquals((Float) layer.getLineBlur().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineDasharray() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "line-dasharray");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(lineDasharray(new Float[]{}));
|
||||
assertEquals((Float[]) layer.getLineDasharray().getValue(), (Float[]) new Float[]{});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLinePattern() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "line-pattern");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(linePattern("pedestrian-polygon"));
|
||||
assertEquals((String) layer.getLinePattern().getValue(), (String) "pedestrian-polygon");
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
package com.mapbox.mapboxsdk.style;
|
||||
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.RasterLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.espresso.BaseTest;
|
||||
import com.mapbox.mapboxsdk.testapp.espresso.utils.OnMapReadyIdlingResource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for RasterLayer
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class RasterLayerTest extends BaseTest {
|
||||
private static final String TAG = RasterLayerTest.class.getSimpleName();
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private RasterLayer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
//Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "raster-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(rasterOpacity(0.3f));
|
||||
assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterHueRotate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "raster-hue-rotate");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(rasterHueRotate(0.3f));
|
||||
assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterBrightnessMin() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "raster-brightness-min");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(rasterBrightnessMin(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterBrightnessMax() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "raster-brightness-max");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(rasterBrightnessMax(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterSaturation() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "raster-saturation");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(rasterSaturation(0.3f));
|
||||
assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterContrast() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "raster-contrast");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(rasterContrast(0.3f));
|
||||
assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterFadeDuration() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Log.i(TAG, "raster-fade-duration");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(rasterFadeDuration(0.3f));
|
||||
assertEquals((Float) layer.getRasterFadeDuration().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.mapbox.mapboxsdk.style;
|
||||
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.Property;
|
||||
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for BackgroundLayer
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class RuntimeStyleBackgroundLayerTest
|
||||
extends ActivityInstrumentationTestCase2<RuntimeStyleTestActivity> {
|
||||
private static final String TAG = RuntimeStyleBackgroundLayerTest.class.getSimpleName();
|
||||
|
||||
public RuntimeStyleBackgroundLayerTest() {
|
||||
super(RuntimeStyleTestActivity.class);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
injectInstrumentation(InstrumentationRegistry.getInstrumentation());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
getActivity().mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap mapboxMap) {
|
||||
Log.i(TAG, "visibility");
|
||||
BackgroundLayer layer = mapboxMap.getLayerAs("background");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), Property.VISIBLE);
|
||||
|
||||
//Set
|
||||
layer.setProperties(PropertyFactory.visibility(Property.NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), Property.NONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.mapbox.mapboxsdk.style;
|
||||
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.FillLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.NoSuchLayerException;
|
||||
import com.mapbox.mapboxsdk.style.layers.Property;
|
||||
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
|
||||
import com.mapbox.mapboxsdk.style.sources.VectorSource;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.espresso.BaseTest;
|
||||
import com.mapbox.mapboxsdk.testapp.espresso.utils.OnMapReadyIdlingResource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for Layer and Source
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class RuntimeStyleTests extends BaseTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAddRemoveLayer() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
//Get initial
|
||||
assertNotNull(mapboxMap.getLayer("building"));
|
||||
|
||||
//Remove
|
||||
try {
|
||||
mapboxMap.removeLayer("building");
|
||||
} catch (NoSuchLayerException e) {
|
||||
assertFalse(true);
|
||||
}
|
||||
assertNull(mapboxMap.getLayer("building"));
|
||||
|
||||
//Add
|
||||
FillLayer layer = new FillLayer("building", "composite");
|
||||
layer.setSourceLayer("building");
|
||||
mapboxMap.addLayer(layer);
|
||||
|
||||
assertNotNull(mapboxMap.getLayer("building"));
|
||||
|
||||
try {
|
||||
layer.setProperties(PropertyFactory.visibility(Property.VISIBLE));
|
||||
assertTrue("Never reached as the reference is invalid after adding", false);
|
||||
} catch (Exception e) {
|
||||
//Expected, reference is no longer valid
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddRemoveSource() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
MapboxMap mapboxMap = rule.getActivity().getMapboxMap();
|
||||
mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
|
||||
mapboxMap.removeSource("my-source");
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.mapbox.mapboxsdk.style;
|
||||
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.FillLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.NoSuchLayerException;
|
||||
import com.mapbox.mapboxsdk.style.layers.Property;
|
||||
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
|
||||
import com.mapbox.mapboxsdk.style.sources.VectorSource;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTimingTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.espresso.BaseTest;
|
||||
import com.mapbox.mapboxsdk.testapp.espresso.utils.OnMapReadyIdlingResource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for adding Layer and Source as early as possible (in onCreate)
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class RuntimeStyleTimingTests extends BaseTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTimingTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTimingTestActivity.class);
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
@Before
|
||||
public void registerIdlingResource() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAddRemoveLayer() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
//We're good if it didn't crash
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,116 @@
|
||||
<%
|
||||
const type = locals.type;
|
||||
const properties = locals.properties;
|
||||
-%>
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
package com.mapbox.mapboxsdk.style;
|
||||
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.<%- camelize(type) %>Layer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.espresso.BaseTest;
|
||||
import com.mapbox.mapboxsdk.testapp.espresso.utils.OnMapReadyIdlingResource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for <%- camelize(type) %>Layer
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class <%- camelize(type) %>LayerTest extends BaseTest {
|
||||
private static final String TAG = <%- camelize(type) %>LayerTest.class.getSimpleName();
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private <%- camelize(type) %>Layer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
<% if (type === 'background') { -%>
|
||||
Log.i(TAG, "Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
<% } else { -%>
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new <%- camelize(type) %>Layer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
<% } -%>
|
||||
Log.i(TAG, "visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
//Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
<% for (const property of properties) { -%>
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
<% if (type === 'background') { -%>
|
||||
Log.i(TAG, "Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
<% } else { -%>
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Log.i(TAG, "Adding layer");
|
||||
layer = new <%- camelize(type) %>Layer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
//Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
<% } -%>
|
||||
Log.i(TAG, "<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
|
||||
//Set and Get
|
||||
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>));
|
||||
assertEquals((<%- propertyType(property) %>) layer.get<%- camelize(property.name) %>().getValue(), (<%- propertyType(property) %>) <%- defaultValueJava(property) %>);
|
||||
}
|
||||
|
||||
<% } -%>
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.mapbox.mapboxsdk.testapp.espresso.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.support.test.espresso.IdlingResource;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mapbox.mapboxsdk.constants.MapboxConstants;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class OnMapReadyIdlingResource implements IdlingResource {
|
||||
|
||||
private final Activity activity;
|
||||
private IdlingResource.ResourceCallback resourceCallback;
|
||||
|
||||
public OnMapReadyIdlingResource(Activity activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIdleNow() {
|
||||
boolean idle = isMapboxMapReady();
|
||||
if (idle && resourceCallback != null) {
|
||||
resourceCallback.onTransitionToIdle();
|
||||
}
|
||||
return idle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIdleTransitionCallback(ResourceCallback resourceCallback) {
|
||||
this.resourceCallback = resourceCallback;
|
||||
}
|
||||
|
||||
private boolean isMapboxMapReady() {
|
||||
try {
|
||||
Field field = activity.getClass().getDeclaredField("mapboxMap");
|
||||
field.setAccessible(true);
|
||||
Object value = field.get(activity);
|
||||
Log.e(MapboxConstants.TAG, "isMapboxReady called with value " + (value != null));
|
||||
return value != null;
|
||||
} catch (Exception e) {
|
||||
Log.e(MapboxConstants.TAG, "could not reflect", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user