Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
[CB-4812] Support for "default" value in the orientation preference
Reviewed by Bryan Higgins <bhiggins@blackberry.com>
  • Loading branch information
Kristoffer Flores authored and bryanhiggins committed Sep 17, 2013
1 parent fbe4de9 commit 006fcbe91d4b7923925a6b0028eb3a0fe96930a2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
@@ -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);
}
}
@@ -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 },

0 comments on commit 006fcbe

Please sign in to comment.