[OpenLayers-Commits] r11767 - sandbox/tschaub/canvas/tests/Renderer

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Wed Mar 30 01:45:24 EDT 2011


Author: tschaub
Date: 2011-03-29 22:45:23 -0700 (Tue, 29 Mar 2011)
New Revision: 11767

Modified:
   sandbox/tschaub/canvas/tests/Renderer/Canvas.html
Log:
Tests for feature id to hex and rgb conversion.

Modified: sandbox/tschaub/canvas/tests/Renderer/Canvas.html
===================================================================
--- sandbox/tschaub/canvas/tests/Renderer/Canvas.html	2011-03-30 05:43:19 UTC (rev 11766)
+++ sandbox/tschaub/canvas/tests/Renderer/Canvas.html	2011-03-30 05:45:23 UTC (rev 11767)
@@ -56,6 +56,75 @@
         t.eq(r.resolution, resolution, "resolution is correctly set");
     }
 
+    function test_featureIdToRGB(t) {
+        if (!supported) {
+            t.plan(0); 
+            return;
+        }
+        t.plan(2);
+        var el = document.body;
+        el.id = "foo";
+        var renderer = new OpenLayers.Renderer.Canvas(el.id);
+        
+        var cases = [{
+            id: "foo_0", rgb: [0, 0, 1]
+        }, {
+            id: "foo_10", rgb: [0, 0, 11]
+        }, {
+            id: "foo_100", rgb: [0, 0, 101]
+        }, {
+            id: "foo_1000000", rgb: [15, 66, 65]
+        }, {
+            id: "foo_16777214", rgb: [255, 255, 255]
+        }, {
+            id: "foo_16777215", rgb: [0, 0, 1]
+        }];
+        t.plan(cases.length);
+        
+        var c;
+        for (var i=0; i<cases.length; ++i) {
+            c = cases[i];
+            t.eq(renderer.featureIdToRGB(c.id), c.rgb, c.id);
+        }
+        
+        renderer.destroy();
+    }
+
+    function test_featureIdToHex(t) {
+        if (!supported) {
+            t.plan(0); 
+            return;
+        }
+        t.plan(2);
+        var el = document.body;
+        el.id = "foo";
+        var renderer = new OpenLayers.Renderer.Canvas(el.id);
+        
+        var cases = [{
+            id: "foo_0", hex: "#000001"
+        }, {
+            id: "foo_10", hex: "#00000b"
+        }, {
+            id: "foo_100", hex: "#000065"
+        }, {
+            id: "foo_1000000", hex: "#0f4241"
+        }, {
+            id: "foo_16777214", hex: "#ffffff"
+        }, {
+            id: "foo_16777215", hex: "#000001"
+        }];
+        t.plan(cases.length);
+        
+        var c;
+        for (var i=0; i<cases.length; ++i) {
+            c = cases[i];
+            t.eq(renderer.featureIdToHex(c.id), c.hex, c.id);
+        }
+        
+        renderer.destroy();
+    }
+
+
     function test_Renderer_Canvas_destroy(t) {
         if (!supported) { t.plan(0); return; }
         t.plan(5);



More information about the Commits mailing list