You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by je...@apache.org on 2013/09/27 16:26:42 UTC

[38/50] [abbrv] webworks commit: [CB-4812] Support for "default" value in the orientation preference

[CB-4812] Support for "default" value in the orientation preference

Reviewed by Bryan Higgins <bh...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/006fcbe9
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/006fcbe9
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/006fcbe9

Branch: refs/heads/3.1.x
Commit: 006fcbe91d4b7923925a6b0028eb3a0fe96930a2
Parents: fbe4de9
Author: Kristoffer Flores <kf...@blackberry.com>
Authored: Fri Sep 13 14:34:30 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Tue Sep 17 09:18:29 2013 -0400

----------------------------------------------------------------------
 .../project/cordova/lib/config-parser.js        |  4 +--
 .../test/cordova/unit/spec/lib/config-parser.js | 34 ++++++++++++++++++++
 2 files changed, 36 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/006fcbe9/blackberry10/bin/templates/project/cordova/lib/config-parser.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/config-parser.js b/blackberry10/bin/templates/project/cordova/lib/config-parser.js
index 7746fd0..881f49b 100644
--- a/blackberry10/bin/templates/project/cordova/lib/config-parser.js
+++ b/blackberry10/bin/templates/project/cordova/lib/config-parser.js
@@ -563,12 +563,12 @@ function processCordovaPreferences(data, widgetConfig) {
             widgetConfig.enablePopupBlocker = ((preference.popupblocker + '').toLowerCase() === 'enable') === true;
         }
 
-        // <preference name="orientation" value="portrait, landscape, north or auto" />
+        // <preference name="orientation" value="portrait, landscape, north, auto or default" />
         if (preference.orientation) {
             if (preference.orientation ===  "landscape" || preference.orientation === "portrait" || preference.orientation === "north") {
                 widgetConfig.autoOrientation = false;
                 widgetConfig.orientation = preference.orientation;
-            } else if (preference.orientation !== "auto") {
+            } else if (preference.orientation !== "auto" && preference.orientation !== "default") {
                 throw localize.translate("EXCEPTION_INVALID_ORIENTATION_MODE", preference.orientation);
             }
         }

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/006fcbe9/blackberry10/bin/test/cordova/unit/spec/lib/config-parser.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/cordova/unit/spec/lib/config-parser.js b/blackberry10/bin/test/cordova/unit/spec/lib/config-parser.js
index d857072..8d9a8a5 100644
--- a/blackberry10/bin/test/cordova/unit/spec/lib/config-parser.js
+++ b/blackberry10/bin/test/cordova/unit/spec/lib/config-parser.js
@@ -1138,6 +1138,40 @@ describe("config parser", function () {
             });
         });
 
+        it("orientation remains auto when auto is specified", function () {
+            var data = testUtilities.cloneObj(testData.xml2jsConfig);
+            data['preference'] = { '@': { name: 'orientation', value: 'auto' } };
+
+            mockParsing(data);
+
+            configParser.parse(configPath, session, function (configObj) {
+                expect(configObj.autoOrientation).toEqual(true);
+            });
+        });
+
+        it("orientation remains auto when default is specified", function () {
+            var data = testUtilities.cloneObj(testData.xml2jsConfig);
+            data['preference'] = { '@': { name: 'orientation', value: 'default' } };
+
+            mockParsing(data);
+
+            configParser.parse(configPath, session, function (configObj) {
+                expect(configObj.autoOrientation).toEqual(true);
+            });
+        });
+
+        it("throws an error when preference.orientation value is invalid", function () {
+            var data = testUtilities.cloneObj(testData.xml2jsConfig);
+            data['preference'] = { '@': { name: 'orientation', value: 'invalid' } };
+
+            mockParsing(data);
+
+            expect(function () {
+                configParser.parse(configPath, session, function (configObj) {});
+            }).toThrow(localize.translate("EXCEPTION_INVALID_ORIENTATION_MODE", "invalid"));
+
+        });
+
         it("throws a warning when blackberry.app.orientation exists", function () {
             var data = testUtilities.cloneObj(testData.xml2jsConfig);
             data['feature'] = { '@': { id: 'blackberry.app.orientation', required: true },