cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alsoro...@apache.org
Subject cordova-plugin-screen-orientation git commit: CB-12271 (windows) Fixed "platform add" error, added new tests
Date Wed, 21 Dec 2016 04:58:24 GMT
Repository: cordova-plugin-screen-orientation
Updated Branches:
  refs/heads/master c704de462 -> 77d471833


CB-12271 (windows) Fixed "platform add" error, added new tests


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/commit/77d47183
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/tree/77d47183
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/diff/77d47183

Branch: refs/heads/master
Commit: 77d471833e8b472f40922ca78f8b1d3e5a807707
Parents: c704de4
Author: Alexander Sorokin <alexander.sorokin@akvelon.com>
Authored: Mon Dec 19 15:13:57 2016 +0300
Committer: Alexander Sorokin <alexander.sorokin@akvelon.com>
Committed: Tue Dec 20 17:18:06 2016 +0300

----------------------------------------------------------------------
 src/windows/CDVOrientation.cs      | 58 ---------------------------------
 src/windows/CDVOrientationProxy.js | 58 +++++++++++++++++++++++++++++++++
 tests/tests.js                     | 18 +++++++++-
 3 files changed, 75 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/blob/77d47183/src/windows/CDVOrientation.cs
----------------------------------------------------------------------
diff --git a/src/windows/CDVOrientation.cs b/src/windows/CDVOrientation.cs
deleted file mode 100644
index 76a6b46..0000000
--- a/src/windows/CDVOrientation.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-var DisplayInfo = Windows.Graphics.Display.DisplayInformation;
-    var Orientations = Windows.Graphics.Display.DisplayOrientations;
-
-module.exports = {
-    setAllowedOrientations: function (win, fail, args) {
-        //console.log("setAllowedOrientations proxy called with " + args);
-
-        try {
-            var prefOrients = args[0];
-            var winPrefs = 0;
-
-            if (prefOrients & 1) { // UIInterfaceOrientationPortrait
-                winPrefs = winPrefs |  Orientations.portrait;
-            }
-            if (prefOrients & 2) { // UIInterfaceOrientationPortraitUpsideDown
-                winPrefs = winPrefs | Orientations.portraitFlipped;
-            }
-            if(prefOrients & 4) { // UIInterfaceOrientationLandscapeLeft
-                winPrefs = winPrefs | Orientations.landscape;
-            }
-            if (prefOrients & 8) { // UIInterfaceOrientationLandscapeRight
-                winPrefs = winPrefs | Orientations.landscapeFlipped;
-            }
-            setTimeout(function () {
-                DisplayInfo.autoRotationPreferences = winPrefs;
-                win();
-            }, 0);
-        }
-        catch (err) {
-            console.log("error :: " + err);
-            fail();
-        }
-
-    }
-}
-
-require("cordova/exec/proxy").add("CDVOrientation", module.exports);

http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/blob/77d47183/src/windows/CDVOrientationProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/CDVOrientationProxy.js b/src/windows/CDVOrientationProxy.js
new file mode 100644
index 0000000..ea28811
--- /dev/null
+++ b/src/windows/CDVOrientationProxy.js
@@ -0,0 +1,58 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+var DisplayInfo = Windows.Graphics.Display.DisplayInformation;
+var Orientations = Windows.Graphics.Display.DisplayOrientations;
+
+module.exports = {
+    screenOrientation: function (win, fail, args) {
+        //console.log("screenOrientation proxy called with " + args);
+
+        try {
+            var prefOrients = args[0];
+            var winPrefs = 0;
+
+            if (prefOrients & 1) { // UIInterfaceOrientationPortrait
+                winPrefs = winPrefs |  Orientations.portrait;
+            }
+            if (prefOrients & 2) { // UIInterfaceOrientationPortraitUpsideDown
+                winPrefs = winPrefs | Orientations.portraitFlipped;
+            }
+            if(prefOrients & 4) { // UIInterfaceOrientationLandscapeLeft
+                winPrefs = winPrefs | Orientations.landscape;
+            }
+            if (prefOrients & 8) { // UIInterfaceOrientationLandscapeRight
+                winPrefs = winPrefs | Orientations.landscapeFlipped;
+            }
+            setTimeout(function () {
+                DisplayInfo.autoRotationPreferences = winPrefs;
+                win();
+            }, 0);
+        }
+        catch (err) {
+            console.log("error :: " + err);
+            fail();
+        }
+
+    }
+}
+
+require("cordova/exec/proxy").add("CDVOrientation", module.exports);

http://git-wip-us.apache.org/repos/asf/cordova-plugin-screen-orientation/blob/77d47183/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 7a28ff5..ee77d28 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -29,8 +29,24 @@ exports.defineAutoTests = function() {
 
     it("should contain a platform specification that is a string", function() {
       expect(window.orientation).toBeDefined();
-      expect((String(window.orientation.type)).length > 0).toBe(true);
+      if (window.orientation) {
+        expect((String(window.orientation.type)).length > 0).toBe(true);
+      }
     });
 
+    it("should successfully lock and unlock screen orientation", function (done) {
+      try {
+        screen.lockOrientation('landscape').then(function () {
+          expect(screen.unlockOrientation).not.toThrow();
+          done();
+        }, function (err) {
+          fail('Promise was rejected: ' + err);
+          done();
+        });
+      } catch (e) {
+        fail(e);
+        done();
+      }
+    });
   });
 };


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


Mime
View raw message