[android] #5858 - added convenience methods for color properties

This commit is contained in:
Ivo van Dongen
2016-08-03 16:03:03 -04:00
parent f94c979886
commit 52cb6122f8
19 changed files with 718 additions and 80 deletions

View File

@@ -1,6 +1,7 @@
// 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.graphics.Color;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
@@ -85,6 +86,22 @@ public class BackgroundLayerTest extends BaseTest {
assertEquals((String) layer.getBackgroundColor().getValue(), (String) "rgba(0, 0, 0, 1)");
}
@Test
public void testBackgroundColorAsInt() {
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(Color.RED));
assertEquals(layer.getBackgroundColorAsInt(), Color.RED);
}
@Test
public void testBackgroundPattern() {
checkViewIsDisplayed(R.id.mapView);

View File

@@ -1,6 +1,7 @@
// 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.graphics.Color;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
@@ -114,6 +115,28 @@ public class CircleLayerTest extends BaseTest {
assertEquals((String) layer.getCircleColor().getValue(), (String) "rgba(0, 0, 0, 1)");
}
@Test
public void testCircleColorAsInt() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
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(Color.RED));
assertEquals(layer.getCircleColorAsInt(), Color.RED);
}
@Test
public void testCircleBlur() {
checkViewIsDisplayed(R.id.mapView);

View File

@@ -1,6 +1,7 @@
// 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.graphics.Color;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
@@ -146,6 +147,28 @@ public class FillLayerTest extends BaseTest {
assertEquals((String) layer.getFillColor().getValue(), (String) "rgba(0, 0, 0, 1)");
}
@Test
public void testFillColorAsInt() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
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(Color.RED));
assertEquals(layer.getFillColorAsInt(), Color.RED);
}
@Test
public void testFillOutlineColor() {
checkViewIsDisplayed(R.id.mapView);
@@ -168,6 +191,28 @@ public class FillLayerTest extends BaseTest {
assertEquals((String) layer.getFillOutlineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
}
@Test
public void testFillOutlineColorAsInt() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
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(Color.RED));
assertEquals(layer.getFillOutlineColorAsInt(), Color.RED);
}
@Test
public void testFillTranslate() {
checkViewIsDisplayed(R.id.mapView);

View File

@@ -1,6 +1,7 @@
// 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.graphics.Color;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
@@ -221,6 +222,28 @@ public class LineLayerTest extends BaseTest {
assertEquals((String) layer.getLineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
}
@Test
public void testLineColorAsInt() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
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(Color.RED));
assertEquals(layer.getLineColorAsInt(), Color.RED);
}
@Test
public void testLineTranslate() {
checkViewIsDisplayed(R.id.mapView);

View File

@@ -1,6 +1,7 @@
// 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.graphics.Color;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

View File

@@ -1,6 +1,7 @@
// 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.graphics.Color;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
@@ -922,6 +923,28 @@ public class SymbolLayerTest extends BaseTest {
assertEquals((String) layer.getIconColor().getValue(), (String) "rgba(0, 0, 0, 1)");
}
@Test
public void testIconColorAsInt() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new SymbolLayer("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, "icon-color");
assertNotNull(layer);
//Set and Get
layer.setProperties(iconColor(Color.RED));
assertEquals(layer.getIconColorAsInt(), Color.RED);
}
@Test
public void testIconHaloColor() {
checkViewIsDisplayed(R.id.mapView);
@@ -944,6 +967,28 @@ public class SymbolLayerTest extends BaseTest {
assertEquals((String) layer.getIconHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)");
}
@Test
public void testIconHaloColorAsInt() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new SymbolLayer("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, "icon-halo-color");
assertNotNull(layer);
//Set and Get
layer.setProperties(iconHaloColor(Color.RED));
assertEquals(layer.getIconHaloColorAsInt(), Color.RED);
}
@Test
public void testIconHaloWidth() {
checkViewIsDisplayed(R.id.mapView);
@@ -1076,6 +1121,28 @@ public class SymbolLayerTest extends BaseTest {
assertEquals((String) layer.getTextColor().getValue(), (String) "rgba(0, 0, 0, 1)");
}
@Test
public void testTextColorAsInt() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new SymbolLayer("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, "text-color");
assertNotNull(layer);
//Set and Get
layer.setProperties(textColor(Color.RED));
assertEquals(layer.getTextColorAsInt(), Color.RED);
}
@Test
public void testTextHaloColor() {
checkViewIsDisplayed(R.id.mapView);
@@ -1098,6 +1165,28 @@ public class SymbolLayerTest extends BaseTest {
assertEquals((String) layer.getTextHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)");
}
@Test
public void testTextHaloColorAsInt() {
checkViewIsDisplayed(R.id.mapView);
mapboxMap = rule.getActivity().getMapboxMap();
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
Log.i(TAG, "Adding layer");
layer = new SymbolLayer("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, "text-halo-color");
assertNotNull(layer);
//Set and Get
layer.setProperties(textHaloColor(Color.RED));
assertEquals(layer.getTextHaloColorAsInt(), Color.RED);
}
@Test
public void testTextHaloWidth() {
checkViewIsDisplayed(R.id.mapView);

View File

@@ -5,6 +5,7 @@
// 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.graphics.Color;
import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
@@ -106,6 +107,35 @@ public class <%- camelize(type) %>LayerTest extends BaseTest {
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>));
assertEquals((<%- propertyType(property) %>) layer.get<%- camelize(property.name) %>().getValue(), (<%- propertyType(property) %>) <%- defaultValueJava(property) %>);
}
<% if (property.type == 'color') { -%>
@Test
public void test<%- camelize(property.name) %>AsInt() {
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) %>(Color.RED));
assertEquals(layer.get<%- camelize(property.name) %>AsInt(), Color.RED);
}
<% } -%>
<% } -%>