cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alsoro...@apache.org
Subject cordova-plugin-device-orientation git commit: CB-13028 (CI) Browser builds on Travis and AppVeyor
Date Mon, 31 Jul 2017 08:02:29 GMT
Repository: cordova-plugin-device-orientation
Updated Branches:
  refs/heads/master c67827428 -> fc8d07f96


CB-13028 (CI) Browser builds on Travis and AppVeyor


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

Branch: refs/heads/master
Commit: fc8d07f9629c148e5f299219dbc2f4f4a26147d1
Parents: c678274
Author: Alexander Sorokin <alexander.sorokin@akvelon.com>
Authored: Mon Jul 31 10:49:31 2017 +0300
Committer: Alexander Sorokin <alexander.sorokin@akvelon.com>
Committed: Mon Jul 31 11:02:12 2017 +0300

----------------------------------------------------------------------
 .appveyor.yml               |  5 +++--
 .travis.yml                 | 16 ++++++++++++++++
 src/browser/CompassProxy.js | 20 +++++++-------------
 tests/tests.js              | 37 +++++++++++++++++++++++--------------
 4 files changed, 49 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation/blob/fc8d07f9/.appveyor.yml
----------------------------------------------------------------------
diff --git a/.appveyor.yml b/.appveyor.yml
index 4cd6d53..6eea8b6 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -15,7 +15,8 @@ environment:
   nodejs_version: "4"
   matrix:
     - PLATFORM: windows-10-store
-
+      JUST_BUILD: --justBuild
+    - PLATFORM: local\browser
 install:
   - npm cache clean -f
   - node --version
@@ -25,4 +26,4 @@ install:
 build: off
 
 test_script:
-  - cordova-paramedic --config pr\%PLATFORM% --plugin . --justBuild
+  - cordova-paramedic --config pr\%PLATFORM% --plugin . %JUST_BUILD%

http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation/blob/fc8d07f9/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 9d2c89d..06d6a66 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,6 +8,22 @@ env:
   - TRAVIS_NODE_VERSION="4.2"
 matrix:
   include:
+  - env: PLATFORM=browser-chrome
+    os: linux
+    language: node_js
+    node_js: '4.2'
+  - env: PLATFORM=browser-firefox
+    os: linux
+    language: node_js
+    node_js: '4.2'
+  - env: PLATFORM=browser-safari
+    os: linux
+    language: node_js
+    node_js: '4.2'
+  - env: PLATFORM=browser-edge
+    os: linux
+    language: node_js
+    node_js: '4.2'
   - env: PLATFORM=ios-9.3
     os: osx
     osx_image: xcode7.3

http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation/blob/fc8d07f9/src/browser/CompassProxy.js
----------------------------------------------------------------------
diff --git a/src/browser/CompassProxy.js b/src/browser/CompassProxy.js
index 24e571a..860c258 100644
--- a/src/browser/CompassProxy.js
+++ b/src/browser/CompassProxy.js
@@ -21,21 +21,15 @@
 
 var Compass = {
     getHeading: function(success, error) {
-        var listener = function() {
-            var orient = {};
-            var heading = (Math.round((Math.random() * 360) * 100) / 100);
+        var orient = {};
+        var heading = (Math.round((Math.random() * 360) * 100) / 100);
 
-            orient.trueHeading = heading;
-            orient.magneticHeading = heading;
-            orient.headingAccuracy = 0;
-            orient.timestamp = new Date().getTime();
+        orient.trueHeading = heading;
+        orient.magneticHeading = heading;
+        orient.headingAccuracy = 0;
+        orient.timestamp = new Date().getTime();
 
-            success(orient);
-
-            window.removeEventListener('deviceorientation', listener, false);
-        };
-
-        return window.addEventListener('deviceorientation', listener, false);
+        success(orient);
     }
 };
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation/blob/fc8d07f9/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 7d56214..387aa58 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -49,22 +49,31 @@ exports.defineAutoTests = function () {
             });
         });
 
-        var isCompassAvailable = true;
+        var isCompassAvailable = null;
 
         beforeEach(function (done) {
-            if (!isCompassAvailable) {
+            if (isCompassAvailable === false) {
                 // if we're already ensured that compass is not available, no need to check
it again
                 done();
                 return;
+            } else if (isCompassAvailable === null) {
+                // Try to access compass device, and if it is not available
+                // set hardwarefailure flag to mark some tests pending
+                navigator.compass.getCurrentHeading(function () {
+                    isCompassAvailable = true;
+                    done();
+                }, function (error) {
+                    if (error.code == CompassError.COMPASS_NOT_SUPPORTED) {
+                        isCompassAvailable = false;
+                    }
+                    done();
+                });
+            } else {
+                // wait a little
+                setTimeout(function () {
+                    done();
+                }, 200);
             }
-            // 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 () {
@@ -175,16 +184,16 @@ exports.defineAutoTests = function () {
                 var watchCleared = false;
 
                 var watchId = navigator.compass.watchHeading(
-                    function (a){
+                    function (a) {
                         // Don't invoke this function if we have cleared the watch
                         expect(watchCleared).toBe(false);
 
-                        if (calledOnce) {
+                        if (calledOnce && !watchCleared) {
                             navigator.compass.clearWatch(watchId);
                             watchCleared = true;
-                            setInterval(function(){
+                            setTimeout(function(){
                                 done();
-                            }, 100);
+                            }, 1000);
                         }
 
                         calledOnce = true;


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


Mime
View raw message