You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2015/10/31 01:17:49 UTC
cordova-plugin-geolocation git commit: CB-9907 Handle ios tests that
fail when ios simulator does not have a location
Repository: cordova-plugin-geolocation
Updated Branches:
refs/heads/master f9dd314b2 -> 9714f49f9
CB-9907 Handle ios tests that fail when ios simulator does not have a location
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/9714f49f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/tree/9714f49f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/diff/9714f49f
Branch: refs/heads/master
Commit: 9714f49f90ebf40917d3576a350685d68720ec43
Parents: f9dd314
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Fri Oct 30 17:12:45 2015 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Fri Oct 30 17:12:45 2015 -0700
----------------------------------------------------------------------
tests/tests.js | 87 ++++++++++++++++++++++++++++++-----------------------
1 file changed, 50 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/9714f49f/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 2d32e40..ddd5c18 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -20,41 +20,45 @@
*/
exports.defineAutoTests = function () {
var fail = function (done, context, message) {
- // prevents done() to be called several times
- if (context) {
- if (context.done) return;
- context.done = true;
- }
-
- if (message) {
- expect(false).toBe(true, message);
- } else {
- expect(false).toBe(true);
- }
-
- // watchPosition could call its callback sync (before returning the value)
- // so we invoke done async to make sure we know watcher id to .clear in afterEach
- setTimeout(function () {
- done();
- });
- },
- succeed = function (done, context) {
- // prevents done() to be called several times
- if (context) {
- if (context.done) return;
- context.done = true;
- }
-
- expect(true).toBe(true);
-
- // watchPosition could call its callback sync (before returning the value)
- // so we invoke done async to make sure we know watcher id to .clear in afterEach
- setTimeout(function () {
- done();
- });
- },
- isWindowsStore = (cordova.platformId == "windows8") || (cordova.platformId == "windows" && !WinJS.Utilities.isPhone),
- isAndroid = cordova.platformId == "android";
+ // prevents done() to be called several times
+ if (context) {
+ if (context.done) return;
+ context.done = true;
+ }
+
+ if (message) {
+ expect(false).toBe(true, message);
+ } else {
+ expect(false).toBe(true);
+ }
+
+ // watchPosition could call its callback sync (before returning the value)
+ // so we invoke done async to make sure we know watcher id to .clear in afterEach
+ setTimeout(function () {
+ done();
+ });
+ };
+
+ var succeed = function (done, context) {
+ // prevents done() to be called several times
+ if (context) {
+ if (context.done) return;
+ context.done = true;
+ }
+
+ expect(true).toBe(true);
+
+ // watchPosition could call its callback sync (before returning the value)
+ // so we invoke done async to make sure we know watcher id to .clear in afterEach
+ setTimeout(function () {
+ done();
+ });
+ };
+
+ var isWindowsStore = (cordova.platformId == "windows8") || (cordova.platformId == "windows" && !WinJS.Utilities.isPhone);
+ var isAndroid = cordova.platformId == "android";
+ var isIOSSim = false; // if iOS simulator does not have a location set, it will fail.
+
describe('Geolocation (navigator.geolocation)', function () {
@@ -116,8 +120,17 @@ exports.defineAutoTests = function () {
expect(p.coords).toBeDefined();
expect(p.timestamp).toBeDefined();
done();
+ }, function(err){
+ if(err.message && err.message.indexOf('kCLErrorDomain') > -1){
+ console.log("Error: Location not set in simulator, tests will fail.");
+ expect(true).toBe(true);
+ isIOSSim = true;
+ done();
+ }
+ else {
+ fail(done);
+ }
},
- fail.bind(null, done),
{
maximumAge: (5 * 60 * 1000) // 5 minutes maximum age of cached position
});
@@ -174,7 +187,7 @@ exports.defineAutoTests = function () {
// On Windows, this test prompts user for permission to use geolocation and interrupts autotests running.
// On Android geolocation Api is not available on emulator so we pended tests until we found the way to detect
// whether we run on emulator or real device from JavaScript. You can still run the tests on Android manually.
- if (isWindowsStore || isAndroid) {
+ if (isWindowsStore || isAndroid || isIOSSim) {
pending();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org