Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 01DB617339 for ; Wed, 11 Feb 2015 14:50:00 +0000 (UTC) Received: (qmail 53328 invoked by uid 500); 11 Feb 2015 14:49:59 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 53300 invoked by uid 500); 11 Feb 2015 14:49:59 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 53291 invoked by uid 99); 11 Feb 2015 14:49:59 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Feb 2015 14:49:59 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 791B0E03A1; Wed, 11 Feb 2015 14:49:59 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: an-selm@apache.org To: commits@cordova.apache.org Message-Id: <4633b43c728e46f2b94c0d667398b14f@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: cordova-plugin-device-orientation git commit: CB-8458 Fixes false failure of test, when compass hardware is not available Date: Wed, 11 Feb 2015 14:49:59 +0000 (UTC) Repository: cordova-plugin-device-orientation Updated Branches: refs/heads/master 4d36668cb -> 7f813a89a CB-8458 Fixes false failure of test, when compass hardware is not available * Factor out compass detection to beforeEach * Remove false-failure spec Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation/commit/7f813a89 Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation/tree/7f813a89 Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation/diff/7f813a89 Branch: refs/heads/master Commit: 7f813a89a1438bbdc35d5df63fbbd380a7bc1ee5 Parents: 4d36668 Author: Vladimir Kotikov Authored: Wed Feb 11 17:48:46 2015 +0300 Committer: Vladimir Kotikov Committed: Wed Feb 11 17:48:46 2015 +0300 ---------------------------------------------------------------------- tests/tests.js | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation/blob/7f813a89/tests/tests.js ---------------------------------------------------------------------- diff --git a/tests/tests.js b/tests/tests.js index c5ddc59..2812453 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -29,7 +29,6 @@ exports.defineAutoTests = function () { unexpectedFailure = "Forced failure: error callback should not have been called"; describe('Compass (navigator.compass)', function () { - var hardwarefailure = false; beforeEach(function () { jasmine.Expectation.addMatchers({ toFailWithMessage: function () { @@ -49,15 +48,22 @@ exports.defineAutoTests = function () { }); }); - it("compass.hardwarecheck is compass supported", function (done) { - navigator.compass.getCurrentHeading(function onSuccess() { done(); }, - function onError(error) { - if (error.code == CompassError.COMPASS_NOT_SUPPORTED) { - hardwarefailure = true; - expect(this).toFailWithMessage("The device does not have compass support. Any tests relying on support will be marked pending."); - } - done(); - }); + var isCompassAvailable = true; + + beforeEach(function (done) { + if (!isCompassAvailable) { + // if we're already ensured that compass is not available, no need to check it again + done(); + return; + } + // Try to access compass device, and if it is not available + // set hardwarefailure flag to mark some tests pending + navigator.compass.getCurrentHeading(done, function (error) { + if (error.code == CompassError.COMPASS_NOT_SUPPORTED) { + isCompassAvailable = false; + } + done(); + }); }); it("compass.spec.1 should exist", function () { @@ -71,7 +77,7 @@ exports.defineAutoTests = function () { }); it("compass.spec.3 getCurrentHeading success callback should be called with a Heading object", function (done) { - if (hardwarefailure) { + if (!isCompassAvailable) { pending(); } navigator.compass.getCurrentHeading(function (a) { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org For additional commands, e-mail: commits-help@cordova.apache.org