[OpenLayers-Commits] r11675 - in sandbox/tschaub/xdomain: lib/OpenLayers/Protocol tests/Protocol

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Tue Mar 8 11:14:29 EST 2011


Author: tschaub
Date: 2011-03-08 08:14:28 -0800 (Tue, 08 Mar 2011)
New Revision: 11675

Modified:
   sandbox/tschaub/xdomain/lib/OpenLayers/Protocol/Script.js
   sandbox/tschaub/xdomain/tests/Protocol/Script.html
Log:
Adding test and default filter serialization from vmische.

Modified: sandbox/tschaub/xdomain/lib/OpenLayers/Protocol/Script.js
===================================================================
--- sandbox/tschaub/xdomain/lib/OpenLayers/Protocol/Script.js	2011-03-08 16:09:24 UTC (rev 11674)
+++ sandbox/tschaub/xdomain/lib/OpenLayers/Protocol/Script.js	2011-03-08 16:14:28 UTC (rev 11675)
@@ -113,6 +113,12 @@
         if (!this.format) {
             this.format = new OpenLayers.Format.GeoJSON();
         }
+
+        if (!this.filterToParams && OpenLayers.Protocol.simpleFilterSerializer) {
+            this.filterToParams = OpenLayers.Function.bind(
+                OpenLayers.Protocol.simpleFilterSerializer, this
+            );
+        }
     },
     
     /**

Modified: sandbox/tschaub/xdomain/tests/Protocol/Script.html
===================================================================
--- sandbox/tschaub/xdomain/tests/Protocol/Script.html	2011-03-08 16:09:24 UTC (rev 11674)
+++ sandbox/tschaub/xdomain/tests/Protocol/Script.html	2011-03-08 16:14:28 UTC (rev 11675)
@@ -92,6 +92,48 @@
             'response priv property set to what the createRequest method returns');
     }
 
+    function test_read_bbox(t) {
+        t.plan(6);
+
+        var _createRequest = OpenLayers.Protocol.Script.prototype.createRequest;
+
+        var bounds = new OpenLayers.Bounds(1, 2, 3, 4);
+        var filter = new OpenLayers.Filter.Spatial({
+            type: OpenLayers.Filter.Spatial.BBOX,
+            value: bounds,
+            projection: new OpenLayers.Projection("foo")
+        });
+
+        // log requests
+        var log, exp;
+        OpenLayers.Protocol.Script.prototype.createRequest = function(url, params,
+                                                               callback) {
+            log.push(params.bbox);
+            return null;
+        };
+
+        // 1) issue request with default protocol
+        log = [];
+        new OpenLayers.Protocol.Script().read({filter: filter});
+
+        t.eq(log.length, 1, "1) createRequest called once");
+        t.ok(log[0] instanceof Array, "1) bbox param is array");
+        exp = bounds.toArray();
+        t.eq(log[0], exp, "1) bbox param doesn't include SRS id by default");
+
+        // 2) issue request with default protocol
+        log = [];
+        new OpenLayers.Protocol.Script({srsInBBOX: true}).read({filter: filter});
+
+        t.eq(log.length, 1, "2) createRequest called once");
+        t.ok(log[0] instanceof Array, "2) bbox param is array");
+        exp = bounds.toArray();
+        exp.push("foo");
+        t.eq(log[0], exp, "2) bbox param includes SRS id if srsInBBOX is true");
+
+        OpenLayers.Protocol.Script.prototype.createRequest = _createRequest;
+    }
+
     function test_createRequest(t) {
         t.plan(3);
         var protocol = new OpenLayers.Protocol.Script({



More information about the Commits mailing list