Adding support for cloning rules and filters. r=ahocevar (closes #1919)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@9071 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2009-03-17 16:08:12 +00:00
parent 7fa74f1b0b
commit 576e931dac
11 changed files with 241 additions and 3 deletions
+43
View File
@@ -40,6 +40,49 @@
t.eq(context.foobar, "world", "value returned by getContext is correct"
+ " if a context is given in constructor options");
}
function test_clone(t) {
t.plan(7);
var rule = new OpenLayers.Rule({
name: "test rule",
minScaleDenominator: 10,
maxScaleDenominator: 20,
filter: new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: "prop",
value: "value"
}),
symbolizer: {
fillColor: "black"
},
context: {
foo: "bar"
}
});
var clone = rule.clone();
t.eq(clone.name, "test rule", "name copied");
t.eq(clone.minScaleDenominator, 10, "minScaleDenominator copied");
t.eq(clone.filter.type, OpenLayers.Filter.Comparison.EQUAL_TO, "clone has correct filter type");
// modify original
rule.filter.property = "new";
rule.symbolizer.fillColor = "white";
rule.context.foo = "baz";
// confirm that clone didn't change
t.eq(clone.filter.property, "prop", "clone has clone of filter");
t.eq(clone.symbolizer.fillColor, "black", "clone has clone of symbolizer");
t.eq(clone.context.foo, "bar", "clone has clone of context");
// confirm that ids are different
t.ok(clone.id !== rule.id, "clone has different id");
rule.destroy();
clone.destroy();
}
function test_Rule_destroy(t) {
t.plan(1);