cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i..@apache.org
Subject [3/3] spec commit: CB-4894 handle correctly when geolocation not available
Date Mon, 30 Sep 2013 19:26:40 GMT
CB-4894 handle correctly when geolocation not available

(cherry picked from commit 32d806a11fbd460aef2dc3b7fabd2adfe4b3e6a7)


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/ace274f6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/ace274f6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/ace274f6

Branch: refs/heads/3.1.x
Commit: ace274f6c48edd0a8300ae8680734370bcfde0da
Parents: 00669d3
Author: David Kemp <drkemp@chromium.org>
Authored: Tue Sep 24 06:56:52 2013 -0400
Committer: Ian Clelland <iclelland@chromium.org>
Committed: Mon Sep 30 15:25:32 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/ace274f6/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();
+                    }
                 });
             });
         });


Mime
View raw message