You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2013/09/30 16:23:14 UTC
spec commit: CB-4894 handle correctly when geolocation not available
Updated Branches:
refs/heads/master 4cba23f05 -> 32d806a11
CB-4894 handle correctly when geolocation not available
Project: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/commit/32d806a1
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/32d806a1
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/32d806a1
Branch: refs/heads/master
Commit: 32d806a11fbd460aef2dc3b7fabd2adfe4b3e6a7
Parents: 4cba23f
Author: David Kemp <dr...@chromium.org>
Authored: Tue Sep 24 06:56:52 2013 -0400
Committer: David Kemp <dr...@chromium.org>
Committed: Tue Sep 24 06:56:52 2013 -0400
----------------------------------------------------------------------
autotest/tests/geolocation.tests.js | 32 +++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/32d806a1/autotest/tests/geolocation.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/geolocation.tests.js b/autotest/tests/geolocation.tests.js
index 6837f44..1d2410c 100644
--- a/autotest/tests/geolocation.tests.js
+++ b/autotest/tests/geolocation.tests.js
@@ -63,11 +63,16 @@ describe('Geolocation (navigator.geolocation)', function () {
describe('success callback', function() {
it("geolocation.spec.6 should be called with a Position object", function() {
+ var providerAvailable=true;
var win = jasmine.createSpy().andCallFake(function(p) {
expect(p.coords).toBeDefined();
expect(p.timestamp).toBeDefined();
}),
- fail = jasmine.createSpy();
+ fail = jasmine.createSpy().andCallFake(function(e) {
+ if(e.code == 2) {
+ providerAvailable=false;
+ }
+ });
runs(function () {
navigator.geolocation.getCurrentPosition(win, fail, {
@@ -75,10 +80,12 @@ describe('Geolocation (navigator.geolocation)', function () {
});
});
- waitsFor(function () { return win.wasCalled; }, "win never called", 20000);
+ waitsFor(function () { return (win.wasCalled || fail.wasCalled); }, "win/fail never called", 20000);
runs(function () {
- expect(fail).not.toHaveBeenCalled();
+ if(providerAvailable) {
+ expect(fail).not.toHaveBeenCalled();
+ }
});
});
});
@@ -91,7 +98,7 @@ describe('Geolocation (navigator.geolocation)', function () {
afterEach(function() {
navigator.geolocation.clearWatch(errorWatch);
});
- it("geolocation.spec.5 should be called if we set timeout to 0 and maximumAge to a very small number", function() {
+ it("geolocation.spec.7 should be called if we set timeout to 0 and maximumAge to a very small number", function() {
var win = jasmine.createSpy(),
fail = jasmine.createSpy();
@@ -112,16 +119,21 @@ describe('Geolocation (navigator.geolocation)', function () {
describe('success callback', function() {
var successWatch = null;
-
+
afterEach(function() {
navigator.geolocation.clearWatch(successWatch);
});
- it("geolocation.spec.6 should be called with a Position object", function() {
+ it("geolocation.spec.8 should be called with a Position object", function() {
+ var providerAvailable=true;
var win = jasmine.createSpy().andCallFake(function(p) {
expect(p.coords).toBeDefined();
expect(p.timestamp).toBeDefined();
}),
- fail = jasmine.createSpy();
+ fail = jasmine.createSpy().andCallFake(function(e) {
+ if(e.code ==2) {
+ providerAvailable=false;
+ }
+ });
runs(function () {
successWatch = navigator.geolocation.watchPosition(win, fail, {
@@ -129,10 +141,12 @@ describe('Geolocation (navigator.geolocation)', function () {
});
});
- waitsFor(function () { return win.wasCalled; }, "win never called", 20000);
+ waitsFor(function () { return (win.wasCalled || fail.wasCalled); }, "win/fail never called", 20000);
runs(function () {
- expect(fail).not.toHaveBeenCalled();
+ if(providerAvailable) {
+ expect(fail).not.toHaveBeenCalled();
+ }
});
});
});