cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sgreb...@apache.org
Subject cordova-plugin-device-motion git commit: CB-8096 Pended auto tests if accelerometer doesn't exist on the device
Date Fri, 19 Dec 2014 13:26:05 GMT
Repository: cordova-plugin-device-motion
Updated Branches:
  refs/heads/master 67f508de7 -> 213cd4b76


CB-8096 Pended auto tests if accelerometer doesn't exist on the device


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/commit/213cd4b7
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/tree/213cd4b7
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/diff/213cd4b7

Branch: refs/heads/master
Commit: 213cd4b76519428484b78cb4292e0070c23d776d
Parents: 67f508d
Author: maria.bukharina <maria.bukharina@akvelon.com>
Authored: Thu Nov 27 19:14:12 2014 +0300
Committer: sgrebnov <v-segreb@microsoft.com>
Committed: Fri Dec 19 16:24:54 2014 +0300

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


http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/213cd4b7/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 159bf9b..84cb799 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -20,6 +20,12 @@
 */
 
 exports.defineAutoTests = function () {
+    var isWindows = (cordova.platformId === "windows") || (cordova.platformId === "windows8"),
+     // Checking existence of accelerometer for windows platform 
+     // Assumed that accelerometer always exists on other platforms. Extend 
+     // condition to support accelerometer check on other platforms
+     isAccelExist = isWindows ? Windows.Devices.Sensors.Accelerometer.getDefault() !== null
: true;
+
   describe('Accelerometer (navigator.accelerometer)', function () {
     var fail = function(done) {
       expect(true).toBe(false);
@@ -37,6 +43,10 @@ exports.defineAutoTests = function () {
       });
 
       it("accelerometer.spec.3 success callback should be called with an Acceleration object",
function(done) {
+        // skip the test if Accelerometer doesn't exist on this device
+        if (!isAccelExist) {
+          pending();
+        }
         var win = function(a) {
           expect(a).toBeDefined();
           expect(a.x).toBeDefined();
@@ -54,6 +64,10 @@ exports.defineAutoTests = function () {
       });
 
       it("accelerometer.spec.4 success callback Acceleration object should have (reasonable)
values for x, y and z expressed in m/s^2", function(done) {
+        // skip the test if Accelerometer doesn't exist on this device
+        if (!isAccelExist) {
+          pending();
+        }
         var reasonableThreshold = 15;
         var win = function(a) {
           expect(a.x).toBeLessThan(reasonableThreshold);
@@ -69,6 +83,10 @@ exports.defineAutoTests = function () {
       });
 
       it("accelerometer.spec.5 success callback Acceleration object should return a recent
timestamp", function(done) {
+        // skip the test if Accelerometer doesn't exist on this device
+        if (!isAccelExist) {
+          pending();
+        }
         var veryRecently = (new Date()).getTime();
         // Need to check that dates returned are not vastly greater than a recent time stamp.
         // In case the timestamps returned are ridiculously high
@@ -96,6 +114,10 @@ exports.defineAutoTests = function () {
       });
 
       it("accelerometer.spec.7 success callback should be called with an Acceleration object",
function(done) {
+        // skip the test if Accelerometer doesn't exist on this device
+        if (!isAccelExist) {
+          pending();
+        }
         var win = function(a) {
           expect(a).toBeDefined();
           expect(a.x).toBeDefined();
@@ -113,6 +135,10 @@ exports.defineAutoTests = function () {
       });
 
         it("accelerometer.spec.8 success callback Acceleration object should have (reasonable)
values for x, y and z expressed in m/s^2", function(done) {
+          // skip the test if Accelerometer doesn't exist on this device
+          if (!isAccelExist) {
+            pending();
+          }
           var reasonableThreshold = 15;
           var win = function(a) {
             expect(a.x).toBeLessThan(reasonableThreshold);
@@ -128,6 +154,10 @@ exports.defineAutoTests = function () {
         });
 
         it("accelerometer.spec.9 success callback Acceleration object should return a recent
timestamp", function(done) {
+          // skip the test if Accelerometer doesn't exist on this device
+          if (!isAccelExist) {
+            pending();
+          }
           var veryRecently = (new Date()).getTime();
           // Need to check that dates returned are not vastly greater than a recent time
stamp.
           // In case the timestamps returned are ridiculously high
@@ -162,6 +192,10 @@ exports.defineAutoTests = function () {
       });
 
       it("accelerometer.spec.11 should clear an existing watch", function(done) {
+          // skip the test if Accelerometer doesn't exist on this device
+          if (!isAccelExist) {
+              pending();
+          }
           var id;
 
           // expect win to get called exactly once


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


Mime
View raw message