Style constructor accepts a rules array. These rules will be added to the style. r=ahocevar (closes #1964)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@8975 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
+27
-4
@@ -4,13 +4,36 @@
|
||||
<script type="text/javascript">
|
||||
|
||||
function test_Style_constructor(t) {
|
||||
t.plan(3);
|
||||
t.plan(6);
|
||||
|
||||
var options = {'foo': 'bar'};
|
||||
var style = new OpenLayers.Style(null, options);
|
||||
var rules = [
|
||||
new OpenLayers.Rule({
|
||||
symbolizer: {fillColor: "red"},
|
||||
filter: new OpenLayers.Filter.Comparison({
|
||||
type: OpenLayers.Filter.Comparison.EQUAL_TO,
|
||||
property: "type",
|
||||
value: "fire engine"
|
||||
})
|
||||
}),
|
||||
new OpenLayers.Rule({
|
||||
symbolizer: {fillColor: "yellow"},
|
||||
filter: new OpenLayers.Filter.Comparison({
|
||||
type: OpenLayers.Filter.Comparison.EQUAL_TO,
|
||||
property: "type",
|
||||
value: "sports car"
|
||||
})
|
||||
})
|
||||
];
|
||||
var style = new OpenLayers.Style(null, {
|
||||
foo: "bar",
|
||||
rules: rules
|
||||
});
|
||||
t.ok(style instanceof OpenLayers.Style,
|
||||
"new OpenLayers.Style returns object" );
|
||||
t.eq(style.foo, "bar", "constructor sets options correctly");
|
||||
t.eq(style.foo, "bar", "constructor sets options correctly");
|
||||
t.eq(style.rules.length, 2, "correct number of rules added");
|
||||
t.ok(style.rules[0] === rules[0], "correct first rule added");
|
||||
t.ok(style.rules[1] === rules[1], "correct second rule added");
|
||||
t.eq(typeof style.createSymbolizer, "function", "style has a createSymbolizer function");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user