[OpenLayers-Commits] r11552 - in sandbox/jgrocha/openlayers: examples lib/OpenLayers/Protocol/SQL tests tests/Protocol/SQL

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Sat Feb 26 19:52:10 EST 2011


Author: jgrocha
Date: 2011-02-26 16:52:09 -0800 (Sat, 26 Feb 2011)
New Revision: 11552

Added:
   sandbox/jgrocha/openlayers/tests/Protocol/SQL/WebSQL.html
   sandbox/jgrocha/openlayers/tests/Protocol/SQL/WebSQL2.html
Modified:
   sandbox/jgrocha/openlayers/examples/websql.html
   sandbox/jgrocha/openlayers/examples/websql.js
   sandbox/jgrocha/openlayers/lib/OpenLayers/Protocol/SQL/WebSQL.js
   sandbox/jgrocha/openlayers/tests/list-tests.html
Log:
An updated version of the Web SQL Storage protocol, to be tested on mobile.

Modified: sandbox/jgrocha/openlayers/examples/websql.html
===================================================================
--- sandbox/jgrocha/openlayers/examples/websql.html	2011-02-27 00:39:39 UTC (rev 11551)
+++ sandbox/jgrocha/openlayers/examples/websql.html	2011-02-27 00:52:09 UTC (rev 11552)
@@ -1,7 +1,7 @@
 <!DOCTYPE html>
 <html>
 	<head><meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" /><meta name="apple-mobile-web-app-capable" content="yes" />
-		<title>OpenLayers Polygon Hole Digitizing</title>
+		<title>OpenLayers Local Web SQL Storage</title>
 		<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
 		<link rel="stylesheet" href="style.css" type="text/css">
 		<style>
@@ -61,16 +61,31 @@
 				<input type="radio" name="type" value="remove" id="removeToggle"
 				onclick="toggleControl(this);" />
 				<label for="removeToggle">
-					Remove features
+					Remove features using layer.removeFeatures(). They don't are removed from the storage.
 				</label>
 			</li>
 			<li>
 				<input type="radio" name="type" value="removefromwebsql" id="removefromwebsqlToggle"
 				onclick="toggleControl(this);" />
 				<label for="removefromwebsqlToggle">
-					Remove features using state change and stratergy.save()
+					Remove features using state change and strategy.save()
 				</label>
 			</li>
+			<li>
+				<a href="#"	onclick="addFeatures();">Add features</a>
+			</li>
+			<li>
+				<a href="#"	onclick="saveAddedFeatures();">Save the added features to local storage</a>
+			</li>
+			<li>
+				<a href="#"	onclick="test();">Test (to be removed!)</a>
+			</li>
+			<li>
+				<a href="#"	onclick="deleteFeature();">Delete feature</a>
+			</li>
+			<li>
+				<a href="#"	onclick="clearDatabase();">Clear local storage</a>
+			</li>
 		</ul>
 		<p>
 			Use the shift key to select multiple features.  Use the ctrl key to

Modified: sandbox/jgrocha/openlayers/examples/websql.js
===================================================================
--- sandbox/jgrocha/openlayers/examples/websql.js	2011-02-27 00:39:39 UTC (rev 11551)
+++ sandbox/jgrocha/openlayers/examples/websql.js	2011-02-27 00:52:09 UTC (rev 11552)
@@ -6,14 +6,14 @@
 		featuremodified: function(obj) {
 			console.log('featuremodified');
 		},
-		beforefeatureremoved: function(obj) {
-			console.log('beforefeatureremoved');
-		},
 		featureremoved: function(obj) {
 			console.log('featureremoved');
+		},
+		featureadded: function(obj) {
+			console.log('featureadded');
 		}
 	},
-	protocol: new OpenLayers.Protocol.WebSQL({databaseName: 'poi', tableName: 'restaurants', initialSize: 8*1024*1024})
+	protocol: new OpenLayers.Protocol.SQL.WebSQL({databaseName: 'poi', tableName: 'restaurants', initialSize: 8*1024*1024})
 });
 
 function toggleControl(element) {
@@ -40,8 +40,9 @@
 	modify: new OpenLayers.Control.ModifyFeature(vectors),
 	remove: new OpenLayers.Control.SelectFeature(
 	vectors, { onSelect: function(feature) {
-			console.log('feature has been destroyed');
-			vectors.destroyFeatures([feature]);
+			console.log('feature has been removed, but not from the local storage');
+			// vectors.destroyFeatures([feature]);
+			vectors.removeFeatures([feature]);
 		}
 	}),
 	removefromwebsql: new OpenLayers.Control.SelectFeature(
@@ -55,16 +56,118 @@
 	})
 };
 
-var map = new OpenLayers.Map({
-	div: "map",
-	layers: [
-	new OpenLayers.Layer.OSM(),
-	vectors
-	],
-	center: new OpenLayers.LonLat(0,0),
-	zoom: 1
-});
+var ol_wms = new OpenLayers.Layer.WMS(
+"OpenLayers WMS",
+"http://vmap0.tiles.osgeo.org/wms/vmap0",
+{layers: "basic"}
+);
 
+var map = new OpenLayers.Map("map");
+map.addLayers([ol_wms, vectors]);
+map.addControl(new OpenLayers.Control.LayerSwitcher());
+map.zoomToMaxExtent();
+
 for(var key in drawControls) {
 	map.addControl(drawControls[key]);
 }
+
+function addFeatures() {
+	/* point feature */
+	var p;
+	for (p=1; p <= 100; p=p+1) {
+		vectors.addFeatures(new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(-100+p*2, -50+p)));
+	}
+	vectors.addFeatures(new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(-8.04, 41.68)));
+	/* line and polygon feature */
+	var lineGeom = new OpenLayers.Geometry.fromWKT("LINESTRING(-18.00 39.56, -18.18 34.94, -15.28 35.38)");
+	var polyGeom = new OpenLayers.Geometry.fromWKT("POLYGON((-20.90 39.90, -22.66 38.88, -23.10 36.02, -21.17 34.87, -19.41 36.58, -19.50 39.01, -20.90 39.90))");
+	var lineFeature = new OpenLayers.Feature.Vector(lineGeom);
+	var polyFeature = new OpenLayers.Feature.Vector(polyGeom);
+	lineFeature.state = OpenLayers.State.INSERT;
+	polyFeature.state = OpenLayers.State.INSERT;
+	vectors.addFeatures([lineFeature, polyFeature]);
+	/* point feature with attributes */
+	var summitPointFeature = new OpenLayers.Feature.Vector( new OpenLayers.Geometry.Point( -9, 43), {summit: 'Lausanne', elevation: 1234} );
+	summitPointFeature.state = OpenLayers.State.INSERT;
+	vectors.addFeatures([summitPointFeature]);
+	console.debug(vectors.protocol.db);
+}
+
+function saveAddedFeatures() {
+	saveStrategy.save();
+}
+
+function test() {
+
+	var resp;
+	var createOptions = {
+		callback: function(resp) {
+			console.log('Debug da resposta');
+			console.debug(resp);
+		}
+	};
+	var feature = new OpenLayers.Feature.Vector(  new OpenLayers.Geometry.Point( -9, 43), {summit: 'Lausanne', elevation: 1234} );
+	feature.fid = "1000";
+	feature.attributes.fake = "properties";
+	feature.state = OpenLayers.State.INSERT;
+	resp = vectors.protocol.create( feature, createOptions );
+
+	var readOptions = {
+		callback: function(resp) {
+			console.log('Debug do read inside do callback');
+			console.log('E o resultado é...' + resp.features.length);
+			console.debug(resp);
+		}
+	};
+
+	resp = vectors.protocol.read( readOptions );
+
+}
+
+function deleteFeature() {
+	var options = {
+		callback: function(resp) {
+			console.log('Debug do delete inside do callback');
+			console.debug(resp);
+		}
+	};
+	var feature = new OpenLayers.Feature.Vector();
+	feature.fid = 1;
+	vectors.protocol.
+	delete( feature, options );
+}
+
+function clearDatabase() {
+	console.log('vamos limpas a casa, ok?');
+	vectors.protocol.clear();
+	console.log('casa limpa, meus. venha a festa');
+}
+
+/*
+ * These events are beeng fired in Safari BUT NOT on chrome...
+ */
+window.ononline = function(onOnlineState) {
+	console.log('We are online now, and window.navigator.onLine = ' + window.navigator.onLine);
+}
+window.onoffline = function(onOnlineState) {
+	console.log('We are offline now, sorry, and window.navigator.onLine = ' + window.navigator.onLine);
+}
+document.addEventListener("offline", function () {
+	console.log('We are offline now, sorry, and window.navigator.onLine = ' + window.navigator.onLine);
+}, false);
+document.addEventListener("online", function () {
+	console.log('We are online now, and window.navigator.onLine = ' + window.navigator.onLine);
+}, false);
+document.body.addEventListener("offline", function () {
+	console.log('We are offline now, sorry, and window.navigator.onLine = ' + window.navigator.onLine);
+}, false);
+document.body.addEventListener("online", function () {
+	console.log('We are online now, and window.navigator.onLine = ' + window.navigator.onLine);
+}, false);
+/*
+ var online = navigator.onLine;
+ var online = navigator.onLine;
+ Changes to this attribute are indicated through the online and offline events that are both dispatched on the Window object.
+ ts.addEventListener('online', function(e) { console.log('online'); }, false);
+ ts.addEventListener('offline', function(e) { console.log('offline'); }, false);
+ */

Modified: sandbox/jgrocha/openlayers/lib/OpenLayers/Protocol/SQL/WebSQL.js
===================================================================
--- sandbox/jgrocha/openlayers/lib/OpenLayers/Protocol/SQL/WebSQL.js	2011-02-27 00:39:39 UTC (rev 11551)
+++ sandbox/jgrocha/openlayers/lib/OpenLayers/Protocol/SQL/WebSQL.js	2011-02-27 00:52:09 UTC (rev 11552)
@@ -3,7 +3,7 @@
  * @requires OpenLayers/Format/GeoJSON.js
  */
 
-OpenLayers.Protocol.WebSQL = OpenLayers.Class(OpenLayers.Protocol.SQL, {
+OpenLayers.Protocol.SQL.WebSQL = OpenLayers.Class(OpenLayers.Protocol.SQL, {
     
     /**
      * Property: maxId
@@ -85,6 +85,7 @@
             this.format.destroy();
         }
         this.format = null;
+        this.db = null;
         OpenLayers.Protocol.SQL.prototype.destroy.apply(this, arguments);
     },
     
@@ -182,6 +183,7 @@
                 }
             );
         });
+        return response;
     },
     
     /**
@@ -218,6 +220,7 @@
                 }
             );
         });
+        return response;
     },
 
     /**
@@ -256,6 +259,7 @@
                 }
             );
         });
+        return response;
     },
 
     /**
@@ -289,9 +293,20 @@
                 }
             );
         });
+        return response;
     },
-    
+
     /**
+     * Method: delete all items from database
+     */     
+
+    clear: function(options) {
+        this.transaction(function(tx) {
+            this.executeSql(tx, "DELETE FROM " + this.tableName);
+        });
+    },
+    	
+    /**
      * Method: handleResponse
      * Deals with responses and calls any specified callback.
      *
@@ -448,6 +463,6 @@
     },
 
     
-    CLASS_NAME: "OpenLayers.Protocol.WebSQL"
+    CLASS_NAME: "OpenLayers.Protocol.SQL.WebSQL"
 });    
 

Added: sandbox/jgrocha/openlayers/tests/Protocol/SQL/WebSQL.html
===================================================================
--- sandbox/jgrocha/openlayers/tests/Protocol/SQL/WebSQL.html	                        (rev 0)
+++ sandbox/jgrocha/openlayers/tests/Protocol/SQL/WebSQL.html	2011-02-27 00:52:09 UTC (rev 11552)
@@ -0,0 +1,279 @@
+<html>
+	<head>
+		<script src="../../OLLoader.js">
+		</script>
+		<script type="text/javascript">
+
+	function test_initialize(t) {
+		var protocol = new OpenLayers.Protocol.SQL.WebSQL();
+		if (!protocol.supported) {
+			t.plan(0);
+			return;
+		}
+
+		t.plan(3); /* number of tests */
+
+		t.eq(protocol.CLASS_NAME, "OpenLayers.Protocol.SQL.WebSQL",
+		"ctor returns correct value");
+
+		t.eq(protocol.format.CLASS_NAME,
+		"OpenLayers.Format.GeoJSON",
+		"ctor creates a JSON parser");
+
+		t.ok(typeof protocol.db == "object",
+		"ctor creates a db object");
+
+		protocol.destroy();
+	}
+
+	function test_destroy(t) {
+		var protocol = new OpenLayers.Protocol.SQL.WebSQL();
+		if (!protocol.supported) {
+			t.plan(0);
+			return;
+		}
+
+		t.plan(1);
+
+		protocol.destroy();
+
+		/*
+ 		t.eq(protocol.db, null,
+ 		"destroy nullifies db");
+ 		*/
+		t.eq(protocol.jsonParser, null,
+		"destroy nullifies jsonParser");
+
+	}
+
+	function pausecomp(millis) {
+		var date = new Date();
+		var curDate = null;
+
+		do {
+			curDate = new Date();
+		} while(curDate-date < millis);
+	}
+
+	function test_read(t) {
+		var protocol = new OpenLayers.Protocol.SQL.WebSQL();
+		if (!protocol.supported) {
+			t.plan(0);
+			return;
+		}
+		t.plan(2);
+		var resp;
+		// 2 tests
+		var readOptions = {
+			callback: function(resp) {
+				t.eq(resp.CLASS_NAME, "OpenLayers.Protocol.Response",
+				"read calls correct callback with a response object");
+			}
+		};
+		// 2 test
+		resp = protocol.read(readOptions);
+		t.eq(resp.CLASS_NAME, "OpenLayers.Protocol.Response",
+		"read returns a response object");
+		t.wait_result( 1.5 );
+
+		protocol.clear();
+		protocol.destroy();
+	}
+
+	function test_create(t) {
+		var protocol = OpenLayers.Protocol.SQL.WebSQL({databaseName: 'poi', tableName: 'pharmacy'});
+		if (!protocol.supported) {
+			t.plan(0);
+			return;
+		}
+
+		t.plan(4);
+
+		var resp;
+		var scope = {"fake": "scope"};
+
+		var options = {
+			callback: function(resp) {
+				t.eq(resp.CLASS_NAME, "OpenLayers.Protocol.Response",
+				"user callback is passed a response");
+				t.eq(resp.requestType, "create",
+				"user callback is passed correct request type in resp");
+				t.ok(this == scope,
+				"user callback called with correct scope");
+			},
+			scope: scope
+		};
+
+		// 4 tests
+		var feature = new OpenLayers.Feature.Vector();
+		// feature.fid = "1000";
+		feature.attributes.fake = "foo";
+		feature.state = OpenLayers.State.INSERT;
+		resp = protocol.create(feature, options);
+		t.eq(resp.CLASS_NAME, "OpenLayers.Protocol.Response",
+		"create returns a response");
+		t.wait_result( 3 ); // seconds
+
+		/*
+		var p;
+		for (p=1; p <= 100; p=p+1) {
+			protocol.create(new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(-100+p*2, -50+p)));
+		}
+		
+		t.plan(3);
+		var resp;
+		// 2 tests
+		var readOptions = {
+			callback: function(resp) {
+				t.eq(resp.CLASS_NAME, "OpenLayers.Protocol.Response",
+				"read calls correct callback with a response object");
+				t.eq(resp.festures.length, 101,
+				"read correctly reports 101 features in the database");
+			}
+		};
+		// 2 test
+		resp = protocol.read(readOptions);
+		t.eq(resp.CLASS_NAME, "OpenLayers.Protocol.Response",
+		"read returns a response object");
+		t.wait_result( 2 );					
+		*/
+		
+		// protocol.clear();
+		// protocol.destroy();
+	}
+
+	function test_delete(t) {
+		var protocol = new OpenLayers.Protocol.SQL.WebSQL();
+		if (!protocol.supported) {
+			t.plan(0);
+			return;
+		}
+
+		t.plan(4);
+
+		function createOneAndDeleteOne(fid, deleteOptions) {
+			var feature = new OpenLayers.Feature.Vector();
+			feature.fid = fid;
+			feature.attributes.fake = "properties";
+			feature.state = OpenLayers.State.INSERT;
+			var r = protocol.create([feature]);
+			protocol["delete"](r.reqFeatures, deleteOptions);
+		}
+
+		var resp, fid;
+
+		// 1 test
+		fid = 1000;
+		// protocol.saveFeatureState = false;
+		createOneAndDeleteOne(fid)
+		resp = protocol.read();
+		t.eq(resp.features.length, 0,
+		"delete deletes feature if saveFeatureState is false");
+
+		// 1 test
+		fid = 1000;
+		protocol.saveFeatureState = true;
+		createOneAndDeleteOne(fid);
+		resp = protocol.read();
+		t.eq(resp.features.length, 1,
+		"delete does not delete feature if saveFeatureState is true");
+
+		// 1 test
+		fid = "1000";
+		protocol.saveFeatureState = true;
+		createOneAndDeleteOne(fid);
+		resp = protocol.read();
+		t.eq(resp.features.length, 1,
+		"delete does not delete feature if saveFeatureState is true");
+
+		// 1 test
+		fid = protocol.FID_PREFIX + "1000";
+		protocol.saveFeatureState = true;
+		createOneAndDeleteOne(fid, {dontDelete: true});
+		resp = protocol.read();
+		t.eq(resp.features.length, 0,
+		"delete deletes feature if saveFeatureState is true and fid is prefixed");
+
+		protocol.destroy();
+	}
+
+	/*
+ 	function test_callUserCallback(t) {
+ 	var protocol = new OpenLayers.Protocol.SQL.WebSQL();
+ 	if (!protocol.supported) {
+ 	t.plan(0);
+ 	return;
+ 	}
+
+ 	t.plan(6);
+
+ 	var options, resp;
+ 	var scope = {'fake': 'scope'};
+
+ 	// test commit callback
+ 	// 1 tests
+ 	options = {
+ 	'callback': function() {
+ 	t.ok(this == scope, 'callback called with correct scope');
+ 	},
+ 	'scope': scope
+ 	};
+ 	resp = {'requestType': 'create', 'last': true};
+ 	protocol.callUserCallback(options, resp);
+ 	// 0 test
+ 	resp = {'requestType': 'create', 'last': false};
+ 	protocol.callUserCallback(options, resp);
+
+ 	// test create callback
+ 	// 2 tests
+ 	options = {
+ 	'create': {
+ 	'callback': function(r) {
+ 	t.ok(this == scope, 'callback called with correct scope');
+ 	t.ok(r == resp, 'callback called with correct response');
+ 	},
+ 	'scope': scope
+ 	}
+ 	};
+ 	resp = {'requestType': 'create'};
+ 	protocol.callUserCallback(options, resp);
+
+ 	// test with both callbacks set
+ 	// 3 tests
+ 	options = {
+ 	'create': {
+ 	'callback': function(r) {
+ 	t.ok(this == scope, 'callback called with correct scope');
+ 	t.ok(r == resp, 'callback called with correct response');
+ 	},
+ 	'scope': scope
+ 	},
+ 	'callback': function() {
+ 	t.ok(this == scope, 'callback called with correct scope');
+ 	},
+ 	'scope': scope
+ 	};
+ 	resp = {'requestType': 'create', 'last': true};
+ 	protocol.callUserCallback(options, resp);
+
+ 	// no callback set
+ 	// 0 test
+ 	options = {
+ 	'delete': {
+ 	'callback': function(resp) {
+ 	t.fail('callback should not get called');
+ 	}
+ 	}
+ 	};
+ 	resp = {'requestType': 'create'};
+ 	protocol.callUserCallback(options, resp);
+
+ 	// cleanup
+ 	protocol.destroy();
+ 	}
+ 	*/
+		</script>
+	</head>
+	<body>
+	</body>
+</html>

Added: sandbox/jgrocha/openlayers/tests/Protocol/SQL/WebSQL2.html
===================================================================
--- sandbox/jgrocha/openlayers/tests/Protocol/SQL/WebSQL2.html	                        (rev 0)
+++ sandbox/jgrocha/openlayers/tests/Protocol/SQL/WebSQL2.html	2011-02-27 00:52:09 UTC (rev 11552)
@@ -0,0 +1,183 @@
+<html>
+	<head>
+		<script src="../../OLLoader.js">
+		</script>
+		<script type="text/javascript">
+
+	var currentTime = new Date();
+	var hours = currentTime.getHours();
+	var minutes = currentTime.getMinutes();
+	var seconds = currentTime.getSeconds();
+	var testTableName = 'ol_' + hours + minutes + seconds;
+
+	var protocol = null;
+
+	/*
+ 	* Note: Chromium 9.0 Tools -> Developer Tools associates de local database with the URL under its was created
+ 	* So, to see eventually the databases created by these tests, you should use the URL:
+ 	* tests/Protocol/SQL/WebSQL2.html
+ 	* instead of the default URL for testing
+ 	*
+ 	*/
+	function test_initialize(t) {
+		protocol = new OpenLayers.Protocol.SQL.WebSQL({tableName: testTableName});
+		if (!protocol.supported) {
+			t.plan(0);
+			return;
+		}
+
+		t.plan(4); /* number of tests */
+
+		t.eq(protocol.CLASS_NAME, "OpenLayers.Protocol.SQL.WebSQL",
+		"initialize returns correct value");
+
+		t.eq(protocol.format.CLASS_NAME,
+		"OpenLayers.Format.GeoJSON",
+		"initialize creates a JSON parser");
+
+		t.ok(typeof protocol.db == "object",
+		"initialize creates a db object");
+
+		t.ok(protocol.tableName == testTableName,
+		"initialize uses the passed " + testTableName + " table name");
+
+		// protocol.destroy();
+	}
+
+	function test_read(t) {
+		// var protocol = new OpenLayers.Protocol.SQL.WebSQL();
+		if (!protocol.supported) {
+			t.plan(0);
+			return;
+		}
+		t.plan(3);
+		var resp;
+		// 2 tests
+		var readOptions = {
+			callback: function(resp) {
+				t.eq(resp.CLASS_NAME, "OpenLayers.Protocol.Response",
+				"read calls correct callback with a response object");
+				t.eq(resp.features.length, 0,
+				"read correctly reports 0 features in the database");
+			}
+		};
+		// 2 test
+		resp = protocol.read(readOptions);
+		t.eq(resp.CLASS_NAME, "OpenLayers.Protocol.Response",
+		"read returns a response object");
+		t.wait_result( 2 );
+
+		// protocol.clear();
+		// protocol.destroy();
+	}
+
+	function test_create(t) {
+		// var protocol = new OpenLayers.Protocol.SQL.WebSQL();
+		if (!protocol.supported) {
+			t.plan(0);
+			return;
+		}
+		t.plan(5);
+
+		var resp;
+		var scope = {"fake": "scope"};
+		var createOptions = {
+			callback: function(response) {
+				t.eq(response.CLASS_NAME, "OpenLayers.Protocol.Response",
+				"create callback is passed a response");
+				t.eq(response.requestType, "create",
+				"create callback is passed correct request type in resp");
+			},
+			scope: scope
+		};
+		// 3 tests
+		var feature = new OpenLayers.Feature.Vector( new OpenLayers.Geometry.Point( -9, 43), {summit: 'Lausanne', elevation: 1234} );
+		// feature.fid = "1000";
+		feature.state = OpenLayers.State.INSERT;
+		resp = protocol.create(feature, createOptions);
+		t.eq(resp.CLASS_NAME, "OpenLayers.Protocol.Response",
+		"create returns a response");
+		t.wait_result( 2 ); // seconds
+
+		// 2 tests more
+		var readOptions = {
+			callback: function(resp) {
+				t.eq(resp.features.length, 1,
+				"read correctly reports 1 features in the database after the insert");
+			}
+		};
+		resp = protocol.read(readOptions);
+		t.eq(resp.CLASS_NAME, "OpenLayers.Protocol.Response",
+		"read returns a response object");
+		t.wait_result( 2 );
+
+		var p;
+		var f;
+		for (p=1; p <= 100; p=p+1) {
+			f = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(-100+p*2, -50+p));
+			f.state = OpenLayers.State.INSERT;
+			protocol.create(f);
+		}
+
+		// 2 tests
+		var readOptions2 = {
+			callback: function(resp) {
+				t.eq(resp.features.length, 101,
+				"read correctly reports 101 features in the database after 1+100 inserts");
+			}
+		};
+		// 2 test
+		resp = protocol.read(readOptions2);
+		t.wait_result( 5 );
+
+		// protocol.clear();
+		// protocol.destroy();
+	}
+
+	function test_delete(t) {
+		// var protocol = new OpenLayers.Protocol.SQL.WebSQL();
+		if (!protocol.supported) {
+			t.plan(0);
+			return;
+		}
+
+		var s='OpenLayers';
+		t.eq(s, 'OpenLayers',
+		"test_delete is not yet!");
+		// protocol.destroy();
+	}
+
+	function test_test(t) {
+		var s='OpenLayers';
+
+		t.eq(s, 'OpenLayers',
+		"testing is grest!");
+
+	}
+
+	function test_destroy(t) {
+		// var protocol = new OpenLayers.Protocol.SQL.WebSQL();
+		if (!protocol.supported) {
+			t.plan(0);
+			return;
+		}
+
+		t.plan(2);
+
+		protocol.clear();
+		protocol.destroy();
+
+		t.eq(protocol.db, null,
+		"destroy nullifies db");
+
+		t.eq(protocol.jsonParser, null,
+		"destroy nullifies jsonParser");
+
+		protocol = null;
+	}
+
+		</script>
+	</head>
+	<body>
+	</body>
+</html>

Modified: sandbox/jgrocha/openlayers/tests/list-tests.html
===================================================================
--- sandbox/jgrocha/openlayers/tests/list-tests.html	2011-02-27 00:39:39 UTC (rev 11551)
+++ sandbox/jgrocha/openlayers/tests/list-tests.html	2011-02-27 00:52:09 UTC (rev 11552)
@@ -177,6 +177,7 @@
     <li>Protocol/HTTP.html</li>
     <li>Protocol/SQL.html</li>
     <li>Protocol/SQL/Gears.html</li>
+    <li>Protocol/SQL/WebSQL2.html</li>
     <li>Protocol/WFS.html</li>
     <li>Protocol/SOS.html</li>
     <li>Renderer.html</li>



More information about the Commits mailing list