[android] return color string values in the [0-255] range

This commit is contained in:
Łukasz Paczos
2019-03-26 12:49:33 +01:00
committed by Łukasz Paczos
parent 4224b89a9c
commit b21f9f3e35
15 changed files with 68 additions and 79 deletions

View File

@@ -73,7 +73,7 @@ public class BackgroundLayerTest extends BaseLayerTest {
assertNull(layer.getBackgroundColor().getValue());
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
String propertyValue = "rgba(255,128,0,0.7)";
layer.setProperties(backgroundColor(propertyValue));
assertEquals(layer.getBackgroundColor().getValue(), propertyValue);
}
@@ -85,8 +85,8 @@ public class BackgroundLayerTest extends BaseLayerTest {
assertNotNull(layer);
// Set and Get
layer.setProperties(backgroundColor(Color.RED));
assertEquals(layer.getBackgroundColorAsInt(), Color.RED);
layer.setProperties(backgroundColor(Color.argb(127, 255, 127, 0)));
assertEquals(layer.getBackgroundColorAsInt(), Color.argb(127, 255, 127, 0));
}
@Test

View File

@@ -157,7 +157,7 @@ public class CircleLayerTest extends BaseLayerTest {
assertNull(layer.getCircleColor().getValue());
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
String propertyValue = "rgba(255,128,0,0.7)";
layer.setProperties(circleColor(propertyValue));
assertEquals(layer.getCircleColor().getValue(), propertyValue);
}
@@ -182,8 +182,8 @@ public class CircleLayerTest extends BaseLayerTest {
assertNotNull(layer);
// Set and Get
layer.setProperties(circleColor(Color.RED));
assertEquals(layer.getCircleColorAsInt(), Color.RED);
layer.setProperties(circleColor(Color.argb(127, 255, 127, 0)));
assertEquals(layer.getCircleColorAsInt(), Color.argb(127, 255, 127, 0));
}
@Test
@@ -384,7 +384,7 @@ public class CircleLayerTest extends BaseLayerTest {
assertNull(layer.getCircleStrokeColor().getValue());
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
String propertyValue = "rgba(255,128,0,0.7)";
layer.setProperties(circleStrokeColor(propertyValue));
assertEquals(layer.getCircleStrokeColor().getValue(), propertyValue);
}
@@ -409,8 +409,8 @@ public class CircleLayerTest extends BaseLayerTest {
assertNotNull(layer);
// Set and Get
layer.setProperties(circleStrokeColor(Color.RED));
assertEquals(layer.getCircleStrokeColorAsInt(), Color.RED);
layer.setProperties(circleStrokeColor(Color.argb(127, 255, 127, 0)));
assertEquals(layer.getCircleStrokeColorAsInt(), Color.argb(127, 255, 127, 0));
}
@Test

View File

@@ -378,7 +378,7 @@ public class ExpressionTest extends EspressoTest {
);
assertNull(layer.getTextField().getExpression());
assertEquals(new Formatted(
new FormattedSection("test", null, null, "rgba(255, 255, 0, 1)")
new FormattedSection("test", null, null, "rgba(255,255,0,1)")
), layer.getTextField().getValue());
});
}
@@ -398,7 +398,7 @@ public class ExpressionTest extends EspressoTest {
"test",
formatFontScale(0.5),
formatTextFont(new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"}),
formatTextColor(rgb(126.7, 0, 0))
formatTextColor(rgb(126, 0, 0))
)
);
layer.setProperties(textField(expression));
@@ -412,7 +412,7 @@ public class ExpressionTest extends EspressoTest {
new FormattedSection("test",
0.5,
new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"},
"rgba(126, 0, 0, 1)")
"rgba(126,0,0,1)")
), layer.getTextField().getValue());
});
}
@@ -433,7 +433,8 @@ public class ExpressionTest extends EspressoTest {
formatFontScale(1.5),
formatTextFont(new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"})
),
formatEntry("\ntest2", formatFontScale(2), formatTextColor(Color.BLUE))
formatEntry("\ntest2", formatFontScale(2), formatTextColor(Color.BLUE)),
formatEntry("\ntest3", formatFontScale(2.5), formatTextColor(toColor(literal("rgba(0, 128, 255, 0.5)"))))
);
layer.setProperties(textField(expression));
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
@@ -445,7 +446,8 @@ public class ExpressionTest extends EspressoTest {
assertEquals(new Formatted(
new FormattedSection("test", 1.5,
new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"}),
new FormattedSection("\ntest2", 2.0, null, "rgba(0, 0, 255, 1)")
new FormattedSection("\ntest2", 2.0, null, "rgba(0,0,255,1)"),
new FormattedSection("\ntest3", 2.5, null, "rgba(0,128,255,0.5)")
), layer.getTextField().getValue());
});
}
@@ -547,9 +549,9 @@ public class ExpressionTest extends EspressoTest {
Formatted formatted = new Formatted(
new FormattedSection("test", 1.5),
new FormattedSection("\ntest", 0.5, new String[] {"Arial Unicode MS Regular", "DIN Offc Pro Regular"}),
new FormattedSection("test", null, null, "rgba(0, 255, 0, 1)")
new FormattedSection("test", null, null, "rgba(0,255,0,1)")
);
layer.setProperties(textField(formatted), textColor("rgba(128, 0, 0, 1)"));
layer.setProperties(textField(formatted), textColor("rgba(128,0,0,1)"));
TestingAsyncUtils.INSTANCE.waitForLayer(uiController, mapView);
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")

View File

@@ -144,7 +144,7 @@ public class FillExtrusionLayerTest extends BaseLayerTest {
assertNull(layer.getFillExtrusionColor().getValue());
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
String propertyValue = "rgba(255,128,0,0.7)";
layer.setProperties(fillExtrusionColor(propertyValue));
assertEquals(layer.getFillExtrusionColor().getValue(), propertyValue);
}
@@ -169,8 +169,8 @@ public class FillExtrusionLayerTest extends BaseLayerTest {
assertNotNull(layer);
// Set and Get
layer.setProperties(fillExtrusionColor(Color.RED));
assertEquals(layer.getFillExtrusionColorAsInt(), Color.RED);
layer.setProperties(fillExtrusionColor(Color.argb(127, 255, 127, 0)));
assertEquals(layer.getFillExtrusionColorAsInt(), Color.argb(127, 255, 127, 0));
}
@Test

View File

@@ -170,7 +170,7 @@ public class FillLayerTest extends BaseLayerTest {
assertNull(layer.getFillColor().getValue());
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
String propertyValue = "rgba(255,128,0,0.7)";
layer.setProperties(fillColor(propertyValue));
assertEquals(layer.getFillColor().getValue(), propertyValue);
}
@@ -195,8 +195,8 @@ public class FillLayerTest extends BaseLayerTest {
assertNotNull(layer);
// Set and Get
layer.setProperties(fillColor(Color.RED));
assertEquals(layer.getFillColorAsInt(), Color.RED);
layer.setProperties(fillColor(Color.argb(127, 255, 127, 0)));
assertEquals(layer.getFillColorAsInt(), Color.argb(127, 255, 127, 0));
}
@Test
@@ -219,7 +219,7 @@ public class FillLayerTest extends BaseLayerTest {
assertNull(layer.getFillOutlineColor().getValue());
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
String propertyValue = "rgba(255,128,0,0.7)";
layer.setProperties(fillOutlineColor(propertyValue));
assertEquals(layer.getFillOutlineColor().getValue(), propertyValue);
}
@@ -244,8 +244,8 @@ public class FillLayerTest extends BaseLayerTest {
assertNotNull(layer);
// Set and Get
layer.setProperties(fillOutlineColor(Color.RED));
assertEquals(layer.getFillOutlineColorAsInt(), Color.RED);
layer.setProperties(fillOutlineColor(Color.argb(127, 255, 127, 0)));
assertEquals(layer.getFillOutlineColorAsInt(), Color.argb(127, 255, 127, 0));
}
@Test

View File

@@ -133,7 +133,7 @@ public class HillshadeLayerTest extends BaseLayerTest {
assertNull(layer.getHillshadeShadowColor().getValue());
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
String propertyValue = "rgba(255,128,0,0.7)";
layer.setProperties(hillshadeShadowColor(propertyValue));
assertEquals(layer.getHillshadeShadowColor().getValue(), propertyValue);
}
@@ -145,8 +145,8 @@ public class HillshadeLayerTest extends BaseLayerTest {
assertNotNull(layer);
// Set and Get
layer.setProperties(hillshadeShadowColor(Color.RED));
assertEquals(layer.getHillshadeShadowColorAsInt(), Color.RED);
layer.setProperties(hillshadeShadowColor(Color.argb(127, 255, 127, 0)));
assertEquals(layer.getHillshadeShadowColorAsInt(), Color.argb(127, 255, 127, 0));
}
@Test
@@ -169,7 +169,7 @@ public class HillshadeLayerTest extends BaseLayerTest {
assertNull(layer.getHillshadeHighlightColor().getValue());
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
String propertyValue = "rgba(255,128,0,0.7)";
layer.setProperties(hillshadeHighlightColor(propertyValue));
assertEquals(layer.getHillshadeHighlightColor().getValue(), propertyValue);
}
@@ -181,8 +181,8 @@ public class HillshadeLayerTest extends BaseLayerTest {
assertNotNull(layer);
// Set and Get
layer.setProperties(hillshadeHighlightColor(Color.RED));
assertEquals(layer.getHillshadeHighlightColorAsInt(), Color.RED);
layer.setProperties(hillshadeHighlightColor(Color.argb(127, 255, 127, 0)));
assertEquals(layer.getHillshadeHighlightColorAsInt(), Color.argb(127, 255, 127, 0));
}
@Test
@@ -205,7 +205,7 @@ public class HillshadeLayerTest extends BaseLayerTest {
assertNull(layer.getHillshadeAccentColor().getValue());
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
String propertyValue = "rgba(255,128,0,0.7)";
layer.setProperties(hillshadeAccentColor(propertyValue));
assertEquals(layer.getHillshadeAccentColor().getValue(), propertyValue);
}
@@ -217,7 +217,7 @@ public class HillshadeLayerTest extends BaseLayerTest {
assertNotNull(layer);
// Set and Get
layer.setProperties(hillshadeAccentColor(Color.RED));
assertEquals(layer.getHillshadeAccentColorAsInt(), Color.RED);
layer.setProperties(hillshadeAccentColor(Color.argb(127, 255, 127, 0)));
assertEquals(layer.getHillshadeAccentColorAsInt(), Color.argb(127, 255, 127, 0));
}
}

View File

@@ -103,8 +103,8 @@ public class LightTest extends BaseTest {
invoke(mapboxMap, (uiController, mapboxMap) -> {
assertNotNull(light);
// Set and Get
light.setColor("rgba(0, 0, 0, 1)");
assertEquals("Color should match", "rgba(0, 0, 0, 1)".replaceAll("\\s+", ""), light.getColor());
light.setColor("rgba(255,128,0,0.7)");
assertEquals("Color should match", "rgba(255,128,0,0.7)", light.getColor());
});
}

View File

@@ -222,7 +222,7 @@ public class LineLayerTest extends BaseLayerTest {
assertNull(layer.getLineColor().getValue());
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
String propertyValue = "rgba(255,128,0,0.7)";
layer.setProperties(lineColor(propertyValue));
assertEquals(layer.getLineColor().getValue(), propertyValue);
}
@@ -247,8 +247,8 @@ public class LineLayerTest extends BaseLayerTest {
assertNotNull(layer);
// Set and Get
layer.setProperties(lineColor(Color.RED));
assertEquals(layer.getLineColorAsInt(), Color.RED);
layer.setProperties(lineColor(Color.argb(127, 255, 127, 0)));
assertEquals(layer.getLineColorAsInt(), Color.argb(127, 255, 127, 0));
}
@Test

View File

@@ -856,7 +856,7 @@ public class SymbolLayerTest extends BaseLayerTest {
assertNull(layer.getIconColor().getValue());
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
String propertyValue = "rgba(255,128,0,0.7)";
layer.setProperties(iconColor(propertyValue));
assertEquals(layer.getIconColor().getValue(), propertyValue);
}
@@ -881,8 +881,8 @@ public class SymbolLayerTest extends BaseLayerTest {
assertNotNull(layer);
// Set and Get
layer.setProperties(iconColor(Color.RED));
assertEquals(layer.getIconColorAsInt(), Color.RED);
layer.setProperties(iconColor(Color.argb(127, 255, 127, 0)));
assertEquals(layer.getIconColorAsInt(), Color.argb(127, 255, 127, 0));
}
@Test
@@ -905,7 +905,7 @@ public class SymbolLayerTest extends BaseLayerTest {
assertNull(layer.getIconHaloColor().getValue());
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
String propertyValue = "rgba(255,128,0,0.7)";
layer.setProperties(iconHaloColor(propertyValue));
assertEquals(layer.getIconHaloColor().getValue(), propertyValue);
}
@@ -930,8 +930,8 @@ public class SymbolLayerTest extends BaseLayerTest {
assertNotNull(layer);
// Set and Get
layer.setProperties(iconHaloColor(Color.RED));
assertEquals(layer.getIconHaloColorAsInt(), Color.RED);
layer.setProperties(iconHaloColor(Color.argb(127, 255, 127, 0)));
assertEquals(layer.getIconHaloColorAsInt(), Color.argb(127, 255, 127, 0));
}
@Test
@@ -1106,7 +1106,7 @@ public class SymbolLayerTest extends BaseLayerTest {
assertNull(layer.getTextColor().getValue());
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
String propertyValue = "rgba(255,128,0,0.7)";
layer.setProperties(textColor(propertyValue));
assertEquals(layer.getTextColor().getValue(), propertyValue);
}
@@ -1131,8 +1131,8 @@ public class SymbolLayerTest extends BaseLayerTest {
assertNotNull(layer);
// Set and Get
layer.setProperties(textColor(Color.RED));
assertEquals(layer.getTextColorAsInt(), Color.RED);
layer.setProperties(textColor(Color.argb(127, 255, 127, 0)));
assertEquals(layer.getTextColorAsInt(), Color.argb(127, 255, 127, 0));
}
@Test
@@ -1155,7 +1155,7 @@ public class SymbolLayerTest extends BaseLayerTest {
assertNull(layer.getTextHaloColor().getValue());
// Set and Get
String propertyValue = "rgba(0, 0, 0, 1)";
String propertyValue = "rgba(255,128,0,0.7)";
layer.setProperties(textHaloColor(propertyValue));
assertEquals(layer.getTextHaloColor().getValue(), propertyValue);
}
@@ -1180,8 +1180,8 @@ public class SymbolLayerTest extends BaseLayerTest {
assertNotNull(layer);
// Set and Get
layer.setProperties(textHaloColor(Color.RED));
assertEquals(layer.getTextHaloColorAsInt(), Color.RED);
layer.setProperties(textHaloColor(Color.argb(127, 255, 127, 0)));
assertEquals(layer.getTextHaloColorAsInt(), Color.argb(127, 255, 127, 0));
}
@Test

View File

@@ -186,8 +186,8 @@ public class <%- camelize(type) %>LayerTest extends BaseLayerTest {
assertNotNull(layer);
// Set and Get
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(Color.RED));
assertEquals(layer.get<%- camelize(property.name) %>AsInt(), Color.RED);
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(Color.argb(127, 255, 127, 0)));
assertEquals(layer.get<%- camelize(property.name) %>AsInt(), Color.argb(127, 255, 127, 0));
}
<% } -%>
<% } -%>

View File

@@ -86,7 +86,7 @@ public class LightTest extends BaseTest {
// Set and Get
light.set<%- camelize(property.name) %>(<%- defaultValueJava(property) %>);
<% if (property.name == 'color') { -%>
assertEquals("<%- camelize(property.name) %> should match", <%- defaultValueJava(property) %>.replaceAll("\\s+", ""), light.get<%- camelize(property.name) %>());
assertEquals("<%- camelize(property.name) %> should match", <%- defaultValueJava(property) %>, light.get<%- camelize(property.name) %>());
<% } else { -%>
assertEquals("<%- camelize(property.name) %> should match", <%- defaultValueJava(property) %>, light.get<%- camelize(property.name) %>());
<% } -%>