You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sg...@apache.org on 2016/01/04 09:19:16 UTC

cordova-plugin-geolocation git commit: CB-10285 Added tests for PositionError constants

Repository: cordova-plugin-geolocation
Updated Branches:
  refs/heads/master 49825f17e -> a754436ee


CB-10285 Added tests for PositionError constants

github close #64


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/commit/a754436e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/tree/a754436e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/diff/a754436e

Branch: refs/heads/master
Commit: a754436ee0f051fb2a684f4a59d361647849dd07
Parents: 49825f1
Author: Alexander Sorokin <al...@akvelon.com>
Authored: Thu Dec 31 13:07:48 2015 +0300
Committer: sgrebnov <v-...@microsoft.com>
Committed: Mon Jan 4 11:18:36 2016 +0300

----------------------------------------------------------------------
 tests/tests.js | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/a754436e/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 5d87375..3566211 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -104,6 +104,27 @@ exports.defineAutoTests = function () {
                     });
             });
 
+            it("geolocation.spec.9 on failure should return PositionError object with error code constants", function (done) {
+                // On Windows, this test prompts user for permission to use geolocation and interrupts autotests running.
+                if (isWindowsStore) {
+                    pending();
+                }
+
+                navigator.geolocation.getCurrentPosition(
+                    fail.bind(this, done),
+                    function(gpsError) {
+                        // W3C specs: http://dev.w3.org/geo/api/spec-source.html#position_error_interface
+                        expect(gpsError.PERMISSION_DENIED).toBe(1);
+                        expect(gpsError.POSITION_UNAVAILABLE).toBe(2);
+                        expect(gpsError.TIMEOUT).toBe(3);
+                        done();
+                    },
+                    {
+                        maximumAge: 0,
+                        timeout: 0
+                    });
+            });
+
         });
 
         describe('success callback', function () {
@@ -174,6 +195,32 @@ exports.defineAutoTests = function () {
                     });
             });
 
+            it("geolocation.spec.10 on failure should return PositionError object with error code constants", function (done) {
+                // On Windows, this test prompts user for permission to use geolocation and interrupts autotests running.
+                if (isWindowsStore) {
+                    pending();
+                }
+
+                var context = this;
+                errorWatch = navigator.geolocation.watchPosition(
+                    fail.bind(this, done, context, 'Unexpected win'),
+                    function(gpsError) {
+                        if (context.done) return;
+                        context.done = true;
+
+                        // W3C specs: http://dev.w3.org/geo/api/spec-source.html#position_error_interface
+                        expect(gpsError.PERMISSION_DENIED).toBe(1);
+                        expect(gpsError.POSITION_UNAVAILABLE).toBe(2);
+                        expect(gpsError.TIMEOUT).toBe(3);
+
+                        done();
+                    },
+                    {
+                        maximumAge: 0,
+                        timeout: 0
+                    });
+            });
+
         });
 
         describe('success callback', function () {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org