[OpenLayers-Commits] r4759 - in sandbox/ahocevar/sldRenderer/tests: . Rule

commits at openlayers.org commits at openlayers.org
Tue Oct 2 20:24:40 EDT 2007


Author: ahocevar
Date: 2007-10-02 20:24:39 -0400 (Tue, 02 Oct 2007)
New Revision: 4759

Added:
   sandbox/ahocevar/sldRenderer/tests/Rule/
   sandbox/ahocevar/sldRenderer/tests/Rule/test_Comparison.html
   sandbox/ahocevar/sldRenderer/tests/Rule/test_FeatureId.html
   sandbox/ahocevar/sldRenderer/tests/Rule/test_Logical.html
   sandbox/ahocevar/sldRenderer/tests/test_Rule.html
   sandbox/ahocevar/sldRenderer/tests/test_Style.html
Log:
added tests

Added: sandbox/ahocevar/sldRenderer/tests/Rule/test_Comparison.html
===================================================================
--- sandbox/ahocevar/sldRenderer/tests/Rule/test_Comparison.html	                        (rev 0)
+++ sandbox/ahocevar/sldRenderer/tests/Rule/test_Comparison.html	2007-10-03 00:24:39 UTC (rev 4759)
@@ -0,0 +1,55 @@
+<html> 
+<head> 
+    <script src="../../lib/OpenLayers.js"></script> 
+    <script type="text/javascript">
+
+    function test_Comparison_constructor(t) { 
+        t.plan(3); 
+         
+        var options = {'foo': 'bar'}; 
+        var rule = new OpenLayers.Rule.Comparison(options); 
+        t.ok(rule instanceof OpenLayers.Rule.Comparison, 
+             "new OpenLayers.Rule.Comparison returns object" ); 
+        t.eq(rule.foo, "bar", "constructor sets options correctly"); 
+        t.eq(typeof rule.evaluate, "function", "rule has an evaluate function"); 
+    }
+
+    function test_Comparison_destroy(t) {
+        t.plan(1);
+        
+        var rule = new OpenLayers.Rule.Comparison();
+        rule.destroy();
+		t.ok(rule.symbolizer == null, "symbolizer hash nulled properly");
+    }
+    
+    function test_Comparison_evaluate(t) {
+        t.plan(3);
+        
+        var rule = new OpenLayers.Rule.Comparison({
+                property: "area",
+                lowerBoundary: 1000,
+                upperBoundary: 5000,
+                type: OpenLayers.Rule.Comparison.Type.BETWEEN});
+
+        var features = [
+                new OpenLayers.Feature.Vector(null, {
+                        area: 2000}),
+                new OpenLayers.Feature.Vector(null, {
+                        area: 6000}),
+                new OpenLayers.Feature.Vector(null, {
+                        area: 4999})];
+        var ruleResults = {
+                0: true,
+                1: false,
+                2: true};
+        for (var i in ruleResults) {
+            var result = rule.evaluate(features[i]);
+            t.ok(result == ruleResults[i], "feature "+i+
+                    " evaluates to "+result.toString()+" correctly.");
+        }
+    }
+    </script> 
+</head> 
+<body> 
+</body> 
+</html> 


Property changes on: sandbox/ahocevar/sldRenderer/tests/Rule/test_Comparison.html
___________________________________________________________________
Name: svn:keywords
   + Id Author Date Revision
Name: svn:eol-style
   + native

Added: sandbox/ahocevar/sldRenderer/tests/Rule/test_FeatureId.html
===================================================================
--- sandbox/ahocevar/sldRenderer/tests/Rule/test_FeatureId.html	                        (rev 0)
+++ sandbox/ahocevar/sldRenderer/tests/Rule/test_FeatureId.html	2007-10-03 00:24:39 UTC (rev 4759)
@@ -0,0 +1,47 @@
+<html> 
+<head> 
+    <script src="../../lib/OpenLayers.js"></script> 
+    <script type="text/javascript">
+
+    function test_FeatureId_constructor(t) { 
+        t.plan(3); 
+         
+        var options = {'foo': 'bar'}; 
+        var rule = new OpenLayers.Rule.FeatureId(options); 
+        t.ok(rule instanceof OpenLayers.Rule.FeatureId, 
+             "new OpenLayers.Rule.FeatureId returns object" ); 
+        t.eq(rule.foo, "bar", "constructor sets options correctly"); 
+        t.eq(typeof rule.evaluate, "function", "rule has an evaluate function"); 
+    }
+
+    function test_FeatureId_destroy(t) {
+        t.plan(1);
+        
+        var rule = new OpenLayers.Rule.FeatureId();
+        rule.destroy();
+		t.ok(rule.symbolizer == null, "symbolizer hash nulled properly");
+    }
+    
+    function test_FeatureId_evaluate(t) {
+        t.plan(3);
+        
+        var rule = new OpenLayers.Rule.FeatureId(
+                {fids: ["fid_1", "fid_3"]});
+
+        var ruleResults = {
+                "fid_1" : true,
+                "fid_2" : false,
+                "fid_3" : true};
+        for (var i in ruleResults) {
+            var feature = new OpenLayers.Feature.Vector();
+            feature.fid = i;
+            var result = rule.evaluate(feature);
+            t.ok(result == ruleResults[i], "feature "+i+" evaluates to "+result.toString()+" correctly.");
+            feature.destroy();
+        }
+    }
+    </script> 
+</head> 
+<body> 
+</body> 
+</html> 


Property changes on: sandbox/ahocevar/sldRenderer/tests/Rule/test_FeatureId.html
___________________________________________________________________
Name: svn:keywords
   + Id Author Date Revision
Name: svn:eol-style
   + native

Added: sandbox/ahocevar/sldRenderer/tests/Rule/test_Logical.html
===================================================================
--- sandbox/ahocevar/sldRenderer/tests/Rule/test_Logical.html	                        (rev 0)
+++ sandbox/ahocevar/sldRenderer/tests/Rule/test_Logical.html	2007-10-03 00:24:39 UTC (rev 4759)
@@ -0,0 +1,41 @@
+<html> 
+<head> 
+    <script src="../../lib/OpenLayers.js"></script> 
+    <script type="text/javascript">
+
+    function test_Logical_constructor(t) { 
+        t.plan(3); 
+         
+        var options = {'foo': 'bar'}; 
+        var rule = new OpenLayers.Rule.Logical(options); 
+        t.ok(rule instanceof OpenLayers.Rule.Logical, 
+             "new OpenLayers.Rule.Logical returns object" ); 
+        t.eq(rule.foo, "bar", "constructor sets options correctly"); 
+        t.eq(typeof rule.evaluate, "function", "rule has an evaluate function"); 
+    }
+
+    function test_Logical_destroy(t) {
+        t.plan(1);
+        
+        var rule = new OpenLayers.Rule.Logical();
+        rule.destroy();
+		t.ok(rule.children == null, "children array nulled properly");
+    }
+    
+    function test_Logical_evaluate(t) {
+        t.plan(1);
+        
+        var rule = new OpenLayers.Rule.Logical({
+                type: OpenLayers.Rule.Logical.Type.NOT});
+        rule.children.push(new OpenLayers.Rule());
+        
+        var feature = new OpenLayers.Feature.Vector();
+
+        t.ok(rule.evaluate(feature) == false,
+                "feature evaluates to false correctly.");
+    }
+    </script> 
+</head> 
+<body> 
+</body> 
+</html> 


Property changes on: sandbox/ahocevar/sldRenderer/tests/Rule/test_Logical.html
___________________________________________________________________
Name: svn:keywords
   + Id Author Date Revision
Name: svn:eol-style
   + native

Added: sandbox/ahocevar/sldRenderer/tests/test_Rule.html
===================================================================
--- sandbox/ahocevar/sldRenderer/tests/test_Rule.html	                        (rev 0)
+++ sandbox/ahocevar/sldRenderer/tests/test_Rule.html	2007-10-03 00:24:39 UTC (rev 4759)
@@ -0,0 +1,29 @@
+<html> 
+<head> 
+    <script src="../lib/OpenLayers.js"></script> 
+    <script type="text/javascript">
+
+    function test_Rule_constructor(t) { 
+        t.plan(3); 
+         
+        var options = {'foo': 'bar'}; 
+        var rule = new OpenLayers.Rule(options); 
+        t.ok(rule instanceof OpenLayers.Rule, 
+             "new OpenLayers.Rule returns object" ); 
+        t.eq(rule.foo, "bar", "constructor sets options correctly"); 
+        t.eq(typeof rule.evaluate, "function", "rule has an evaluate function"); 
+    }
+
+    function test_Rule_destroy(t) {
+        t.plan(1);
+        
+        var rule = new OpenLayers.Rule();
+        rule.destroy();
+		t.ok(rule.symbolizer == null, "symbolizer hash nulled properly");
+    }
+
+    </script> 
+</head> 
+<body> 
+</body> 
+</html> 


Property changes on: sandbox/ahocevar/sldRenderer/tests/test_Rule.html
___________________________________________________________________
Name: svn:keywords
   + Id Author Date Revision
Name: svn:eol-style
   + native

Added: sandbox/ahocevar/sldRenderer/tests/test_Style.html
===================================================================
--- sandbox/ahocevar/sldRenderer/tests/test_Style.html	                        (rev 0)
+++ sandbox/ahocevar/sldRenderer/tests/test_Style.html	2007-10-03 00:24:39 UTC (rev 4759)
@@ -0,0 +1,29 @@
+<html> 
+<head> 
+    <script src="../lib/OpenLayers.js"></script> 
+    <script type="text/javascript">
+
+    function test_Style_constructor(t) { 
+        t.plan(3); 
+         
+        var options = {'foo': 'bar'}; 
+        var style = new OpenLayers.Style(options); 
+        t.ok(style instanceof OpenLayers.Style, 
+             "new OpenLayers.Style returns object" ); 
+        t.eq(style.foo, "bar", "constructor sets options correctly"); 
+        t.eq(typeof style.createStyle, "function", "style has a createStyle function"); 
+    }
+
+    function test_Style_destroy(t) {
+        t.plan(1);
+        
+        var style = new OpenLayers.Style();
+        style.destroy();
+		t.ok(style.rules == null, "rules array nulled properly");
+    }
+
+    </script> 
+</head> 
+<body> 
+</body> 
+</html> 


Property changes on: sandbox/ahocevar/sldRenderer/tests/test_Style.html
___________________________________________________________________
Name: svn:keywords
   + Id Author Date Revision
Name: svn:eol-style
   + native



More information about the Commits mailing list