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/30 19:48:25 UTC

[1/3] cordova-plugin-device-motion git commit: Return error when accelerometer not available, skip/pending tests when accel not available, use getters for properties

Repository: cordova-plugin-device-motion
Updated Branches:
  refs/heads/master 6b417a1cb -> 680d9f52d


Return error when accelerometer not available, skip/pending tests when accel not available, use getters for properties


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/6b636a7d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/tree/6b636a7d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/diff/6b636a7d

Branch: refs/heads/master
Commit: 6b636a7d92b4b869b027f8377ebbd9b6dacf9a4d
Parents: 6b417a1
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu Oct 29 17:56:40 2015 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu Oct 29 17:56:40 2015 -0700

----------------------------------------------------------------------
 src/ios/CDVAccelerometer.m | 21 ++++++++++++++++-----
 tests/tests.js             | 10 +++++++++-
 2 files changed, 25 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/6b636a7d/src/ios/CDVAccelerometer.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVAccelerometer.m b/src/ios/CDVAccelerometer.m
index e98aacd..b2ef65f 100755
--- a/src/ios/CDVAccelerometer.m
+++ b/src/ios/CDVAccelerometer.m
@@ -24,11 +24,15 @@
 @property (readwrite, assign) BOOL isRunning;
 @property (readwrite, assign) BOOL haveReturnedResult;
 @property (readwrite, strong) CMMotionManager* motionManager;
+@property (readwrite, assign) double x;
+@property (readwrite, assign) double y;
+@property (readwrite, assign) double z;
+@property (readwrite, assign) NSTimeInterval timestamp;
 @end
 
 @implementation CDVAccelerometer
 
-@synthesize callbackId, isRunning;
+@synthesize callbackId, isRunning,x,y,z,timestamp;
 
 // defaults to 10 msec
 #define kAccelerometerInterval 10
@@ -71,10 +75,10 @@
         [self.motionManager setAccelerometerUpdateInterval:kAccelerometerInterval/1000];  // expected in seconds
         __weak CDVAccelerometer* weakSelf = self;
         [self.motionManager startAccelerometerUpdatesToQueue:[NSOperationQueue mainQueue] withHandler:^(CMAccelerometerData *accelerometerData, NSError *error) {
-            x = accelerometerData.acceleration.x;
-            y = accelerometerData.acceleration.y;
-            z = accelerometerData.acceleration.z;
-            timestamp = ([[NSDate date] timeIntervalSince1970] * 1000);
+            weakSelf.x = accelerometerData.acceleration.x;
+            weakSelf.y = accelerometerData.acceleration.y;
+            weakSelf.z = accelerometerData.acceleration.z;
+            weakSelf.timestamp = ([[NSDate date] timeIntervalSince1970] * 1000);
             [weakSelf returnAccelInfo];
         }];
 
@@ -82,6 +86,13 @@
             self.isRunning = YES;
         }
     }
+    else {
+
+        NSLog(@"Running in Simulator? All gyro tests will fail.");
+        CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_INVALID_ACTION messageAsString:@"Error. Accelerometer Not Available."];
+        
+        [self.commandDelegate sendPluginResult:result callbackId:self.callbackId];
+    }
     
 }
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/6b636a7d/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 136b473..af552ef 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -68,7 +68,15 @@ exports.defineAutoTests = function () {
           done();
         };
 
-        navigator.accelerometer.getCurrentAcceleration(win, fail.bind(null, done));
+        var onError = function(err){
+            console.log(err);
+            console.log("Skipping gyroscope tests, marking all as pending.");
+            isAccelExist = false;
+            expect(true).toBe(true);
+            done();
+         }
+
+        navigator.accelerometer.getCurrentAcceleration(win, onError);
       });
 
       it("accelerometer.spec.4 success callback Acceleration object should have (reasonable) values for x, y and z expressed in m/s^2", function(done) {


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


[2/3] cordova-plugin-device-motion git commit: access all accel properties via getters

Posted by pu...@apache.org.
access all accel properties via getters


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/1f4689cf
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/tree/1f4689cf
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/diff/1f4689cf

Branch: refs/heads/master
Commit: 1f4689cffbcae05e1983af34a7f257fe9039fc65
Parents: 6b636a7
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Fri Oct 30 11:46:10 2015 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Fri Oct 30 11:46:10 2015 -0700

----------------------------------------------------------------------
 src/ios/CDVAccelerometer.m | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/1f4689cf/src/ios/CDVAccelerometer.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVAccelerometer.m b/src/ios/CDVAccelerometer.m
index b2ef65f..476de04 100755
--- a/src/ios/CDVAccelerometer.m
+++ b/src/ios/CDVAccelerometer.m
@@ -43,10 +43,10 @@
 {
     self = [super init];
     if (self) {
-        x = 0;
-        y = 0;
-        z = 0;
-        timestamp = 0;
+        self.x = 0;
+        self.y = 0;
+        self.z = 0;
+        self.timestamp = 0;
         self.callbackId = nil;
         self.isRunning = NO;
         self.haveReturnedResult = YES;
@@ -118,10 +118,10 @@
     // Create an acceleration object
     NSMutableDictionary* accelProps = [NSMutableDictionary dictionaryWithCapacity:4];
 
-    [accelProps setValue:[NSNumber numberWithDouble:x * kGravitationalConstant] forKey:@"x"];
-    [accelProps setValue:[NSNumber numberWithDouble:y * kGravitationalConstant] forKey:@"y"];
-    [accelProps setValue:[NSNumber numberWithDouble:z * kGravitationalConstant] forKey:@"z"];
-    [accelProps setValue:[NSNumber numberWithDouble:timestamp] forKey:@"timestamp"];
+    [accelProps setValue:[NSNumber numberWithDouble:self.x * kGravitationalConstant] forKey:@"x"];
+    [accelProps setValue:[NSNumber numberWithDouble:self.y * kGravitationalConstant] forKey:@"y"];
+    [accelProps setValue:[NSNumber numberWithDouble:self.z * kGravitationalConstant] forKey:@"z"];
+    [accelProps setValue:[NSNumber numberWithDouble:self.timestamp] forKey:@"timestamp"];
 
     CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:accelProps];
     [result setKeepCallback:[NSNumber numberWithBool:YES]];


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


[3/3] cordova-plugin-device-motion git commit: This closes #37

Posted by pu...@apache.org.
This closes #37


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/680d9f52
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/tree/680d9f52
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/diff/680d9f52

Branch: refs/heads/master
Commit: 680d9f52dcffe0ee46c52b65d04c8e26435847cf
Parents: 1f4689c
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Fri Oct 30 11:48:22 2015 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Fri Oct 30 11:48:22 2015 -0700

----------------------------------------------------------------------

----------------------------------------------------------------------



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