You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2014/01/08 21:26:58 UTC
spec commit: CB-3481: Fixed the compass not supported issue
Updated Branches:
refs/heads/master d662dd36a -> ccf92cfe7
CB-3481: Fixed the compass not supported issue
- added a new jasmine test to check if the compass hardware is supported
- added a custom matcher that trys to run a compass command, if a
COMPASS_NOT_SUPPORTED error is caught then the device doesn't support
compass.
- on failure of the hardware check, none of the other compass tests are
ran and a friendly message is shown to the user
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/ccf92cfe
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/ccf92cfe
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/ccf92cfe
Branch: refs/heads/master
Commit: ccf92cfe72e359e213ef562c4e86db0d67228e9b
Parents: d662dd3
Author: ldeluca <ld...@us.ibm.com>
Authored: Thu May 23 12:00:08 2013 -0400
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Wed Jan 8 12:26:41 2014 -0800
----------------------------------------------------------------------
autotest/tests/compass.tests.js | 40 +++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/ccf92cfe/autotest/tests/compass.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/compass.tests.js b/autotest/tests/compass.tests.js
index 3b32bcd..332daea 100644
--- a/autotest/tests/compass.tests.js
+++ b/autotest/tests/compass.tests.js
@@ -20,7 +20,45 @@
*/
describe('Compass (navigator.compass)', function () {
- it("compass.spec.1 should exist", function() {
+ var hardwarefailure = false;
+ beforeEach(function() {
+ this.addMatchers({
+ // check to see if the device has a compass, if it doesn't fail gracefully
+ hasHardware: function() {
+ var toreturn = true;
+
+ try{
+ this.actual;
+ toreturn = true;
+ } catch (error){
+ if (error.code == CompassError.COMPASS_NOT_SUPPORTED){
+ hardwarefailure = true;
+ toreturn = false;
+ }
+ }
+ this.message = function () {
+ return "The device does not have compass support. The remaining compass tests will be ignored.";
+ }
+
+ return toreturn;
+ }
+ });
+ });
+
+ afterEach(function () {
+ // We want to gracefully fail if there is a hardware failure
+ if(this.results_.failedCount > 0 && hardwarefailure == true) {
+ //there was a hardware failure, cancelling all tests
+ jasmine.Queue.prototype.next_ = function () { this.onComplete();}
+ }
+ });
+
+ it("compass.hardwarecheck is compass supported", function() {
+ var f = function(){navigator.compass.getCurrentHeading(function onSuccess(){}, function onError(error) {})};
+ expect(f).hasHardware();
+ });
+
+ it("compass.spec.1 should exist", function() {
expect(navigator.compass).toBeDefined();
});