incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject spec commit: added more geolocation tests for timeout + maximumage parameters
Date Tue, 27 Mar 2012 00:09:53 GMT
Updated Branches:
  refs/heads/master c838e043d -> 5f7ff8a7d


added more geolocation tests for timeout + maximumage parameters


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/commit/5f7ff8a7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/tree/5f7ff8a7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/diff/5f7ff8a7

Branch: refs/heads/master
Commit: 5f7ff8a7dd51a3e4ad1af1351b1e411e24406f11
Parents: c838e04
Author: Fil Maj <maj.fil@gmail.com>
Authored: Mon Mar 26 17:10:29 2012 -0700
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Mon Mar 26 17:10:29 2012 -0700

----------------------------------------------------------------------
 autotest/tests/geolocation.tests.js |   47 +++++++++++++++++++++++++----
 1 files changed, 40 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/blob/5f7ff8a7/autotest/tests/geolocation.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/geolocation.tests.js b/autotest/tests/geolocation.tests.js
index 17f37ce..7890b40 100644
--- a/autotest/tests/geolocation.tests.js
+++ b/autotest/tests/geolocation.tests.js
@@ -21,19 +21,52 @@ Tests.prototype.GeoLocationTests = function() {
 	});
 	test("getCurrentPosition success callback should be called with a Position object", function()
{
 		expect(2);
-		QUnit.stop(Tests.TEST_TIMEOUT);
+		QUnit.stop(15000);
 		var win = function(p) {
 			ok(p.coords != null, "Position object returned in getCurrentPosition success callback
has a 'coords' property.");
 			ok(p.timestamp != null, "Position object returned in getCurrentPosition success callback
has a 'timestamp' property.");
-			start();
+			QUnit.start();
 		};
-		var fail = function() { start(); };
-		navigator.geolocation.getCurrentPosition(win, fail);
+		var fail = function() { 
+        ok(false, "Error callback fired, test failed.");
+        QUnit.start();
+    };
+		navigator.geolocation.getCurrentPosition(win, fail, {
+        maximumAge:300000 // 5 minutes maximum age of cached position
+    });
 	});
+  test("getCurrentPosition success callback should be called with a cached Position", function()
{
+    expect(1);
+    QUnit.stop(Tests.TEST_TIMEOUT);
+    var win = function(p) {
+      ok(p.coords instanceof Position, "Position object returned is an instance of Position");
+      QUnit.start();
+    };
+    var fail = function(e) {
+      ok(false, "Error callback called, test failed.");
+    };
+    navigator.geolocation.getCurrentPosition(win, fail, {
+        maximumAge:300000 // 5 minutes
+    });
+  });
+  test("getCurrentPosition error callback should be called if we set timeout to 0 and maximumAge
to a very small number", function() {
+    expect(1);
+    QUnit.stop(Tests.TEST_TIMEOUT);
+    var win = function(p) {
+      ok(false, "success callback called, test failed.");
+      QUnit.start();
+    };
+    var fail = function(e) {
+      ok(true, "error callback called");
+      QUnit.start();
+    };
+    navigator.geolocation.getCurrentPosition(win, fail, {
+        maximumAge: 0,
+        timeout: 0
+    });
+  });
 	// TODO: Need to test error callback... how?
 	// TODO: Need to test watchPosition success callback, test that makes sure clearPosition
works (how to test that a timer is getting cleared?)
-	// TODO: Need to test options object passed in. Members that need to be tested so far include:
-	//				- options.frequency: this is also labelled differently on some implementations (internval
on iPhone/BlackBerry currently). 
 	module('Geolocation model');
 	test("should be able to define a Position object with coords and timestamp properties",
function() {
 		expect(3);
@@ -54,4 +87,4 @@ Tests.prototype.GeoLocationTests = function() {
 		ok(typeof coords.speed != 'undefined' && coords.speed != null, "new Coordinates()
should include a 'speed' property.");
 		ok(typeof coords.altitudeAccuracy != 'undefined' && coords.altitudeAccuracy !=
null, "new Coordinates() should include a 'altitudeAccuracy' property.");
 	});
-};
\ No newline at end of file
+};


Mime
View raw message