You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2013/06/14 19:30:49 UTC
[20/83] [abbrv] [partial] start of lazy loading: axe all vendored-in
libs
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/67fa7ebb/lib/cordova-blackberry/bin/test/cordova/unit/spec/lib/config-parser.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/test/cordova/unit/spec/lib/config-parser.js b/lib/cordova-blackberry/bin/test/cordova/unit/spec/lib/config-parser.js
deleted file mode 100644
index 41775f4..0000000
--- a/lib/cordova-blackberry/bin/test/cordova/unit/spec/lib/config-parser.js
+++ /dev/null
@@ -1,1411 +0,0 @@
-/*jshint sub:true*/
-
-var testData = require("./test-data"),
- configParser = require(testData.libPath + "/config-parser"),
- packagerUtils = require(testData.libPath + "/packager-utils"),
- fileManager = require(testData.libPath + "/file-manager"),
- logger = require(testData.libPath + "./logger"),
- testUtilities = require("./test-utilities"),
- xml2js = require('xml2js'),
- localize = require(testData.libPath + "/localize"),
- path = require("path"),
- fs = require("fs"),
- session = testData.session,
- configPath = path.resolve("bin/test/cordova/unit/config.xml"),
- configBadPath = path.resolve("test2/config.xml"),
- configBareMinimumPath = path.resolve("bin/test/cordova/unit/config-bare-minimum.xml"),
- mockParsing = testUtilities.mockParsing;
-
-describe("config parser", function () {
- beforeEach(function () {
- spyOn(logger, "warn");
- spyOn(packagerUtils, "copyFile");
- });
-
- it("tries to open a config.xml file that doesn't exist", function () {
- expect(function () {
- configParser.parse(configBadPath, session, {});
- }).toThrow(localize.translate("EXCEPTION_CONFIG_NOT_FOUND"));
- });
-
- it("parses standard elements in a config.xml", function () {
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.content).toEqual("local:///startPage.html");
- expect(configObj.id).toEqual("My WidgetId");
- expect(configObj.customHeaders).toEqual({ 'RIM-Widget' : 'rim/widget'});
- expect(configObj.version).toEqual("1.0.0");
- expect(configObj.license).toEqual("My License");
- expect(configObj.licenseURL).toEqual("http://www.apache.org/licenses/LICENSE-2.0");
- expect(configObj.icon).toEqual(["test.png"]);
- expect(configObj.configXML).toEqual("config.xml");
- expect(configObj.author).toEqual("Research In Motion Ltd.");
- expect(configObj.authorURL).toEqual("http://www.rim.com/");
- expect(configObj.copyright).toEqual("No Copyright");
- expect(configObj.authorEmail).toEqual("author@rim.com");
- expect(configObj.name).toEqual({ default : 'Demo' });
- expect(configObj.description).toEqual({ default : 'This app does everything.' });
- expect(configObj.permissions).toContain('access_shared');
- expect(configObj.permissions).toContain('read_geolocation');
- expect(configObj.permissions).toContain('use_camera');
- expect(configObj.enableChildWebView).toBe(false);
- expect(configObj.enableChildWebView).toBe(false);
- });
- });
-
- it("parses Feature elements in a config.xml", function () {
- var localAccessList,
- accessListFeature;
-
- configParser.parse(configPath, session, function (configObj) {
- //validate WIDGET_LOCAL accessList
- localAccessList = testUtilities.getAccessListForUri(configObj.accessList, "WIDGET_LOCAL");
- expect(localAccessList).toBeDefined();
- expect(localAccessList.uri).toEqual("WIDGET_LOCAL");
- expect(localAccessList.allowSubDomain).toEqual(true);
- });
- });
-
- it("parses Access elements a config.xml", function () {
- var customAccessList,
- accessListFeature;
-
- configParser.parse(configPath, session, function (configObj) {
- //validate http://www.somedomain1.com accessList
- customAccessList = testUtilities.getAccessListForUri(configObj.accessList, "http://www.somedomain1.com");
- expect(customAccessList).toBeDefined();
- expect(customAccessList.uri).toEqual("http://www.somedomain1.com");
- expect(customAccessList.allowSubDomain).toEqual(true);
- });
- });
-
- it("parses a bare minimum config.xml without error", function () {
- var bareMinimumConfigPath = path.resolve("bin/test/cordova/unit/config-bare-minimum.xml");
-
- configParser.parse(bareMinimumConfigPath, session, function (configObj) {
- expect(configObj.content).toEqual("local:///startPage.html");
- expect(configObj.version).toEqual("1.0.0");
- });
- });
-
- it("license url is set even if license body is empty", function () {
- var licenseConfigPath = path.resolve("bin/test/cordova/unit/config-license.xml");
-
- configParser.parse(licenseConfigPath, session, function (configObj) {
- expect(configObj.license).toEqual("");
- expect(configObj.licenseURL).toEqual("http://www.apache.org/licenses/LICENSE-2.0");
- });
- });
-
- it("fails when id is undefined", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["@"].id = undefined;
-
- mockParsing(data);
-
- //Should throw an EXCEPTION_INVALID_ID error
- expect(function () {
- configParser.parse(configPath, session, {});
- }).toThrow(localize.translate("EXCEPTION_INVALID_ID"));
- });
-
- it("fails when id is empty", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["@"].id = "";
-
- mockParsing(data);
-
- //Should throw an EXCEPTION_INVALID_ID error
- expect(function () {
- configParser.parse(configPath, session, {});
- }).toThrow(localize.translate("EXCEPTION_INVALID_ID"));
- });
-
- it("Fails when no name was provided - single element", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data.name = "";
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, {});
- }).toThrow(localize.translate("EXCEPTION_INVALID_NAME"));
- });
-
- it("Fails when no name was provided - multiple elements", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data.name = ["",
- { '#': 'API Smoke Test-FR', '@': { 'xml:lang': 'fr' } },
- ];
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, {});
- }).toThrow(localize.translate("EXCEPTION_INVALID_NAME"));
- });
-
- it("Fails when localized name was provided but empty", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data.name = ["API Smoke Test",
- { '#': '', '@': { 'xml:lang': 'fr' } },
- ];
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, {});
- }).toThrow(localize.translate("EXCEPTION_INVALID_NAME"));
- });
-
- it("Parses a name element - single element", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data.name = "API Smoke Test";
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.name).toEqual({"default": "API Smoke Test"});
- });
- });
-
- it("Parses a name element with xml:lang - single element", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data.name = { '#': 'EN VALUE', '@': { 'xml:lang': 'en' } };
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.name).toEqual({"en": "EN VALUE"});
- });
- });
-
- it("Parses a name element that is not case sensitive", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data.name = { '#': 'EN VALUE', '@': { 'xml:lang': 'eN' } };
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.name).toEqual({"en": "EN VALUE"});
- });
- });
-
- it("Parses a name element with xml:lang - multi element", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data.name = ['API Smoke Test',
- { '#': 'EN VALUE', '@': { 'xml:lang': 'en' } },
- { '#': 'FR VALUE', '@': { 'xml:lang': 'fr' } }
-
- ];
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.name).toEqual({"default": "API Smoke Test", "en": "EN VALUE", "fr": "FR VALUE"});
- });
- });
-
- it("Fails when localized name was provided but empty", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data.name = ['API Smoke Test',
- { '#': '', '@': { 'xml:lang': 'fr' } },
- ];
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, {});
- }).toThrow(localize.translate("EXCEPTION_INVALID_NAME"));
- });
-
- it("Parses a description element - single element", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data.description = "This is my app";
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.description).toEqual({"default": "This is my app"});
- });
- });
-
- it("Parses a description element with xml:lang - single element", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data.description = { '#': 'EN VALUE', '@': { 'xml:lang': 'en' } };
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.description).toEqual({"en": "EN VALUE"});
- });
- });
-
- it("Parses a description element that is not case sensitive", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data.description = { '#': 'EN VALUE', '@': { 'xml:lang': 'eN' } };
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.description).toEqual({"en": "EN VALUE"});
- });
- });
-
- it("Parses a description element with xml:lang - multi element", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data.description = ['This is my app',
- { '#': 'EN VALUE', '@': { 'xml:lang': 'en' } },
- { '#': 'FR VALUE', '@': { 'xml:lang': 'fr' } }
-
- ];
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.description).toEqual({"default": "This is my app", "en": "EN VALUE", "fr": "FR VALUE"});
- });
- });
-
- it("Fails when missing content error is not shown", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data.content = "";
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, {});
- }).toThrow(localize.translate("EXCEPTION_INVALID_CONTENT"));
- });
-
- it("adds local:/// protocol to urls", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data.content["@"].src = "localFile.html";
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.content).toEqual("local:///localFile.html");
- });
- });
-
- it("cleans source folder on error", function () {
- mockParsing({}, "ERROR");
-
- spyOn(logger, "error");
- spyOn(fileManager, "cleanSource");
-
- configParser.parse(configPath, session, function () {});
-
- expect(fileManager.cleanSource).toHaveBeenCalled();
- });
-
- it("parses a single permission (comes in as string)", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data['rim:permissions'] = {};
- data['rim:permissions']['rim:permit'] = 'onePermissionNoAttribs';
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.permissions).toContain('onePermissionNoAttribs');
- });
- });
-
- it("parses a single permission with attribs (comes in as object)", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data['rim:permissions'] = {};
- data['rim:permissions']['rim:permit'] = { '#': 'systemPerm', '@': { system: 'true' } };
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.permissions).toContain({ '#': 'systemPerm', '@': { system: 'true' } });
- });
- });
-
- it("parses multiple permissions with no attribs (comes in as array)", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data['rim:permissions'] = {};
- data['rim:permissions']['rim:permit'] = [ 'access_shared', 'read_geolocation', 'use_camera' ];
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.permissions).toContain('access_shared');
- expect(configObj.permissions).toContain('read_geolocation');
- expect(configObj.permissions).toContain('use_camera');
- });
- });
-
- it("parses multiple permissions with attribs (comes in as array)", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data['rim:permissions'] = {};
- data['rim:permissions']['rim:permit'] = [
- { '#': 'systemPerm', '@': { system: 'true' } },
- { '#': 'nonSystemPerm', '@': { system: 'false' } }
- ];
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.permissions).toContain({ '#': 'systemPerm', '@': { system: 'true' } });
- expect(configObj.permissions).toContain({ '#': 'nonSystemPerm', '@': { system: 'false' } });
- });
- });
-
- it("parses a config with no permissions set", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- delete data['rim:permissions']; //No permissions set in config
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.permissions).toEqual([]);
- });
- });
-
- it("enables the enable-flash feature when specified", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
-
- //Add the enable-flash feature element
- data['feature'] = {'@': {id: 'enable-flash'}};
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.enableFlash).toEqual(true);
- });
- });
-
- it("does not enable the enable-flash feature when specified in an access element", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
-
- //Add the enable-flash to an access element
- data['access'] = {"@" : {"uri" : "http://somewebsite.com"}, "feature" : {"@": {id: 'enable-flash'}}};
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.enableFlash).toEqual(false);
- });
- });
-
- it("disables the enable-flash feature by default", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data['feature'] = undefined;//no features
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.enableFlash).toEqual(false);
- });
- });
-
- it("sets autoDeferNetworkingAndJavaScript to false when the blackberry.push feature is specified", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
-
- //Add the blackberry.push feature element
- data["rim:permissions"] = {}; // ensure no run_when_backgrounded permission exists
- data['feature'] = {'@': {id: 'blackberry.push'}};
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.autoDeferNetworkingAndJavaScript).toEqual(false);
- });
- });
-
- it("sets autoDeferNetworkingAndJavaScript to false when the run_when_backgrounded permission is specified", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
-
- //Add the run_when_backgrounded permission
- data['feature'] = undefined; // no features
- data["rim:permissions"] = {
- "rim:permit" : [ 'read_geolocation', 'run_when_backgrounded', 'access_internet' ]
- };
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.permissions).toContain('run_when_backgrounded');
- expect(configObj.autoDeferNetworkingAndJavaScript).toEqual(false);
- });
- });
-
- it("sets autoDeferNetworkingAndJavaScript to true by default", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
-
- data['feature'] = undefined; // no features
- data["rim:permissions"] = {}; // ensure no run_when_backgrounded permission exists
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.autoDeferNetworkingAndJavaScript).toEqual(true);
- });
- });
-
- it("does not throw an exception with empty permit tags", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data['rim:permit'] = ['read_geolocation', {}, 'access_internet' ];
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).not.toThrow();
- });
-
- it("multi access should be false if no access", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- //hasMultiAccess was set to false
- expect(configObj.hasMultiAccess).toEqual(false);
- expect(configObj.accessList).toEqual([ {
- uri : 'WIDGET_LOCAL',
- allowSubDomain : true
- } ]);
- });
- });
-
- it("multi access should be false if no uri is equal to *", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data['access'] = {"@" : {"uri" : "http://www.somedomain1.com"}};
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- //hasMultiAccess was set to false
- expect(configObj.hasMultiAccess).toEqual(false);
- expect(configObj.accessList).toEqual([ {
- uri : 'WIDGET_LOCAL',
- allowSubDomain : true
- }, {
- "uri" : "http://www.somedomain1.com"
- } ]);
- });
- });
-
- it("multi access should be true with the uri being equal to *", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data['access'] = {"@" : {"uri" : "*"}};
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- //hasMultiAccess was set to true
- expect(configObj.hasMultiAccess).toEqual(true);
- expect(configObj.accessList).toEqual([ {
- uri : 'WIDGET_LOCAL',
- allowSubDomain : true
- } ]);
- });
- });
-
- it("multi access should be true with one uri being equal to *", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data['access'] = [{"@" : {"uri" : "*"}}, {"@" : {"uri" : "http://www.somedomain1.com"}}];
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- //hasMultiAccess was set to true
- expect(configObj.hasMultiAccess).toEqual(true);
- expect(configObj.accessList).toEqual([ {
- uri : 'WIDGET_LOCAL',
- allowSubDomain : true
- }, {
- "uri" : "http://www.somedomain1.com"
- } ]);
- });
- });
-
- it("should fail when feature is defined with the uri being equal to *", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data['access'] = {"@" : {"uri" : "*"}, "feature" : {"@": {"id": "blackberry.app"}}};
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).toThrow(localize.translate("EXCEPTION_FEATURE_DEFINED_WITH_WILDCARD_ACCESS_URI"));
- });
-
- it("should fail when multi features are defined with the uri being equal to *", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data['access'] = {"@" : {"uri" : "*"}, "feature" : [{"@": {"id": "blackberry.app"}}, {"@": {"id": "blackberry.system"}}, {"@": {"id": "blackberry.invoke"}}]};
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).toThrow(localize.translate("EXCEPTION_FEATURE_DEFINED_WITH_WILDCARD_ACCESS_URI"));
- });
-
- it("should fail when the access uri attribute does not specify a protocol", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
-
- //Add an access element with one feature
- data['access'] = {
- '@': {
- uri: 'rim.net',
- subdomains: 'true'
- },
- feature: {
- '@': { id: 'blackberry.system' }
- }
- };
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).toThrow(localize.translate("EXCEPTION_INVALID_ACCESS_URI_NO_PROTOCOL", data['access']['@'].uri));
- });
-
- it("should fail when the access uri attribute does not specify a URN", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
-
- //Add an access element with one feature
- data['access'] = {
- '@': {
- uri: 'http://',
- subdomains: 'true'
- },
- feature: {
- '@': { id: 'blackberry.system' }
- }
- };
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).toThrow(localize.translate("EXCEPTION_INVALID_ACCESS_URI_NO_URN", data['access']['@'].uri));
- });
-
- it("does not fail when there is a single feature element in the access list", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
-
- //Add an access element with one feature
- data['access'] = {
- '@': {
- uri: 'http://rim.net',
- subdomains: 'true'
- },
- feature: {
- '@': { id: 'blackberry.system' }
- }
- };
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).not.toThrow();
- });
-
- it("supports 4 digit version [build id]", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["@"].version = "1.0.0.50";
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.version).toEqual("1.0.0");
- expect(configObj.buildId).toEqual("50");
- });
- });
-
- it("uses --buildId when set", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
-
- //--buildId 100
- session.buildId = "100";
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.buildId).toEqual("100");
- });
- });
-
- it("overides the build id specified in version with --buildId flag", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["@"].version = "1.0.0.50";
-
- //--buildId 100
- session.buildId = "100";
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.version).toEqual("1.0.0");
- expect(configObj.buildId).toEqual("100");
- });
- });
-
- it("throws a proper error when author tag is empty", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data.author = {};
-
- mockParsing(data);
-
- //Should throw an EXCEPTION_INVALID_AUTHOR error
- expect(function () {
- configParser.parse(configPath, session, {});
- }).toThrow(localize.translate("EXCEPTION_INVALID_AUTHOR"));
- });
-
- it("can parse a standard rim:invoke-target element", function () {
-
- configParser.parse(configPath, session, function (configObj) {
- var invokeTarget = configObj["invoke-target"][0];
-
- expect(invokeTarget).toBeDefined();
- expect(invokeTarget["@"]).toBeDefined();
- expect(invokeTarget["@"]["id"]).toBeDefined();
- expect(invokeTarget["@"]["id"]).toEqual("com.domain.subdomain.appname.app1");
- expect(invokeTarget.type).toBeDefined();
- expect(invokeTarget.type).toEqual("APPLICATION");
- expect(invokeTarget["require-source-permissions"]).toBeDefined();
- expect(invokeTarget["require-source-permissions"]).toEqual("invoke_accross_perimeters,access_shared");
- expect(invokeTarget.filter).toBeDefined();
- expect(invokeTarget.filter[0].action).toBeDefined();
- expect(invokeTarget.filter[0].action).toContain("bb.action.VIEW");
- expect(invokeTarget.filter[0].action).toContain("bb.action.SET");
- expect(invokeTarget.filter[0].action).toContain("bb.action.OPEN");
- expect(invokeTarget.filter[0]["mime-type"]).toBeDefined();
- expect(invokeTarget.filter[0]["mime-type"]).toContain("image/*");
- expect(invokeTarget.filter[0]["mime-type"]).toContain("text/*");
- expect(invokeTarget.filter[0].property).toBeDefined();
-
- invokeTarget.filter[0].property.forEach(function (property) {
- expect(property["@"]).toBeDefined();
- expect(property["@"]["var"]).toBeDefined();
- expect(property["@"]["var"]).toMatch("^(exts|uris)$");
- if (property["@"]["var"] === "uris") {
- expect(property["@"]["value"]).toMatch("^(ftp|http|https):\/\/$");
- } else if (property["@"]["var"] === "exts") {
- expect(property["@"]["value"]).toMatch("^(jpg|png|txt|doc)$");
- }
- });
- });
- });
-
- it("can parse multiple filters in one element", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["rim:invoke-target"] = {
- "@": {
- "id": "com.domain.subdomain.appName.app"
- },
- "type": "application",
- "filter": [{
- "action": "bb.action.OPEN",
- "mime-type": ["text/*", "image/*"]
- }, {
- "action": "bb.action.SET",
- "mime-type": "image/*"
- }]
- };
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).not.toThrow();
- });
-
- it("can parse multiple invoke targets", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["rim:invoke-target"] = [{
- "@": {
- "id": "com.domain.subdomain.appName.app"
- },
- "type": "application"
- }, {
- "@": {
- "id": "com.domain.subdomain.appName.viewer"
- },
- "type": "viewer"
- }];
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).not.toThrow();
-
- });
-
- it("throws an error when an invoke target doesn't specify an invocation id", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["rim:invoke-target"] = {
- type: "APPLICATION"
- };
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).toThrow(localize.translate("EXCEPTION_INVOKE_TARGET_INVALID_ID"));
- });
-
- it("throws and error when an invoke target xml doesn't specify an invocation type", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["rim:invoke-target"] = {
- "@": {
- "id": "com.domain.subdomain.appName.app"
- },
- type: {}
- };
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).toThrow(localize.translate("EXCEPTION_INVOKE_TARGET_INVALID_TYPE"));
- });
-
- it("throws an error when an invoke target doesn't specify an invocation type", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["rim:invoke-target"] = {
- "@": {
- "id": "com.domain.subdomain.appName.app"
- }
- };
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).toThrow(localize.translate("EXCEPTION_INVOKE_TARGET_INVALID_TYPE"));
- });
-
- it("throws an error when an invoke target filter doesn't contain an action", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["rim:invoke-target"] = {
- "@": {
- "id": "com.domain.subdomain.appName.app"
- },
- "type": "APPLICATION",
- "filter": {
- "mime-type": "text/*",
- "property": [{
- "@": {
- "var": "uris",
- "value": "https://"
- }
- }, {
- "@": {
- "var": "exts",
- "value": "html"
- }
- }, {
- "@": {
- "var": "exts",
- "value": "htm"
- }
- }]
- }
- };
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).toThrow(localize.translate("EXCEPTION_INVOKE_TARGET_ACTION_INVALID"));
- });
-
- it("throws an error when a filter doesn't contain a mime-type", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["rim:invoke-target"] = {
- "@": {
- "id": "com.domain.subdomain.appName.app"
- },
- "type": "application",
- "filter": {
- "action": "bb.action.OPEN",
- "property": [{
- "@": {
- "var": "uris",
- "value": "https://"
- }
- }, {
- "@": {
- "var": "exts",
- "value": "html"
- }
- }]
- }
- };
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).toThrow(localize.translate("EXCEPTION_INVOKE_TARGET_MIME_TYPE_INVALID"));
- });
-
- describe("splash screen", function () {
- it("throws error when rim:splash element does not contain src attribute", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["rim:splash"] = {};
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).toThrow(localize.translate("EXCEPTION_INVALID_SPLASH_SRC"));
- });
-
- it("throws error when rim:splash element contains empty src attribute", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["rim:splash"] = {
- "@": {
- "src": ""
- }
- };
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).toThrow(localize.translate("EXCEPTION_INVALID_SPLASH_SRC"));
- });
-
- it("throws error when one of many rim:splash elements does not contain attribute", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["rim:splash"] = [{
- "@": {
- "src": "a.jpg"
- }
- }, {
- "#": "blah"
- }];
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).toThrow(localize.translate("EXCEPTION_INVALID_SPLASH_SRC"));
- });
-
- it("allow one rim:splash element that contains non-empty src attribute", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["rim:splash"] = {
- "@": {
- "src": "a.jpg"
- }
- };
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).not.toThrow();
- });
-
- it("allow multiple rim:splash elements that contain non-empty src attribute", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["rim:splash"] = [{
- "@": {
- "src": "a.jpg"
- }
- }, {
- "@": {
- "src": "b.jpg"
- }
- }];
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).not.toThrow();
- });
-
- it("throws error when rim:splash src starts with 'locales' subfolder", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["rim:splash"] = [{
- "@": {
- "src": "a.jpg"
- }
- }, {
- "@": {
- "src": "locales/en/b.jpg"
- }
- }];
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).toThrow(localize.translate("EXCEPTION_INVALID_SPLASH_SRC_LOCALES"));
- });
- });
-
- describe("icon", function () {
- it("throws error when icon element does not contain src attribute", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["icon"] = {};
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).toThrow(localize.translate("EXCEPTION_INVALID_ICON_SRC"));
- });
-
- it("throws error when icon element contains empty src attribute", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["icon"] = {
- "@": {
- "src": ""
- }
- };
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).toThrow(localize.translate("EXCEPTION_INVALID_ICON_SRC"));
- });
-
- it("throws error when one of many icon elements does not contain attribute", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["icon"] = [{
- "@": {
- "src": "a.jpg"
- }
- }, {
- "#": "blah"
- }];
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).toThrow(localize.translate("EXCEPTION_INVALID_ICON_SRC"));
- });
-
- it("allow one icon element that contains non-empty src attribute", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["icon"] = {
- "@": {
- "src": "a.jpg"
- }
- };
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).not.toThrow();
- });
-
- it("allow multiple icon elements that contain non-empty src attribute", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["icon"] = [{
- "@": {
- "src": "a.jpg"
- }
- }, {
- "@": {
- "src": "b.jpg"
- }
- }];
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).not.toThrow();
- });
-
- it("throws error when icon src starts with 'locales' subfolder", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["icon"] = [{
- "@": {
- "src": "a.jpg"
- }
- }, {
- "@": {
- "src": "locales/en/b.jpg"
- }
- }];
-
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).toThrow(localize.translate("EXCEPTION_INVALID_ICON_SRC_LOCALES"));
- });
-
- it("should copy the default icon to the src dir when no icon specified", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- mockParsing(data);
-
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).not.toThrow();
-
- expect(packagerUtils.copyFile).toHaveBeenCalled();
- });
-
- it("should use the default icon config when no icon is specified", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
-
- mockParsing(data);
-
- configParser.parse(configBareMinimumPath, session, function (configObj) {
- expect(configObj.icon).toEqual(["default-icon.png"]);
- });
- });
-
- it("should not use the default icon config when icon is specified", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["icon"] = {
- "@": {
- "src": "test.png"
- }
- };
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.icon).toEqual(["test.png"]);
- expect(configObj.icon).not.toEqual(["default-icon.png"]);
- expect(configObj.icon).not.toContain("default-icon.png");
- });
- });
-
- it("sets orientation to landscape when specified", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data['feature'] = { '@': { id: 'blackberry.app', required: true },
- param: { '@': { name: 'orientation', value: 'landscape' } } };
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.orientation).toEqual("landscape");
- expect(configObj.autoOrientation).toEqual(false);
- });
- });
-
- it("sets orientation to portrait when specified", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data['feature'] = { '@': { id: 'blackberry.app', required: true },
- param: { '@': { name: 'orientation', value: 'portrait' } } };
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.orientation).toEqual("portrait");
- expect(configObj.autoOrientation).toEqual(false);
- });
- });
-
- it("sets auto orientation to true by default", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- delete data["feature"];//Remove any orientation data
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.autoOrientation).toEqual(true);
- });
- });
-
- it("throws a warning when blackberry.app.orientation exists", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data['feature'] = { '@': { id: 'blackberry.app.orientation', required: true },
- param: { '@': { name: 'mode', value: 'portrait' } } };
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {});
- expect(logger.warn).toHaveBeenCalled();
- });
-
- it("throws an error when blackberry.app orientation exists with an invalid mode param", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data['feature'] = { '@': { id: 'blackberry.app', required: true },
- param: { '@': { name: 'orientation', value: 'notAValidMode' } } };
-
- mockParsing(data);
-
- //Should throw an EXCEPTION_INVALID_ORIENTATION_MODE error
- expect(function () {
- configParser.parse(configPath, session, function (configObj) {});
- }).toThrow(localize.translate("EXCEPTION_INVALID_ORIENTATION_MODE", "notAValidMode"));
- });
-
- it("sets backgroundColor when specified via blackberry.app namespace", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data['feature'] = { '@': { id: 'blackberry.app', required: true },
- param: { '@': { name: 'backgroundColor', value: '0xffffff' } } };
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.backgroundColor).toEqual(16777215);//Decimal value of 0xffffff
- });
- });
-
- it("throws an error when blackberry.app backgroundColor param is not a number", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data['feature'] = { '@': { id: 'blackberry.app', required: true },
- param: { '@': { name: 'backgroundColor', value: '$UI*@@$' } } };
-
- mockParsing(data);
-
- //Should throw an EXCEPTION_BGCOLOR_INVALID error
- expect(function () {
- configParser.parse(configPath, session, {});
- }).toThrow(localize.translate("EXCEPTION_BGCOLOR_INVALID", "$UI*@@$"));
- });
-
- it("can properly parse the custom RIM-Wiget:rim/wiget element", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.customHeaders).toEqual({ 'RIM-Widget' : 'rim/widget'});
- });
- });
-
- it("can properly parse the custom attributes but ignores improper headers", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["@"] = {
- "xmlns": " http://www.w3.org/ns/widgets",
- "xmlns:rim": "http://www.blackberry.com/ns/widgets",
- "version": "1.0.0",
- "id": "myID"
- };
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.id).toEqual("myID");
- expect(configObj.customHeaders).toEqual(undefined);
- });
- });
-
- it("can properly parse the custom attributes but ignores improper headers", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data["@"] = {
- "xmlns": " http://www.w3.org/ns/widgets",
- "xmlns:rim": "http://www.blackberry.com/ns/widgets",
- "version": "1.0.0",
- "id": "myID",
- "rim:userAgent" : "A Test-User-Agent/(Blackberry-Agent)"
- };
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.id).toEqual("myID");
- expect(configObj.userAgent).toEqual("A Test-User-Agent/(Blackberry-Agent)");
- });
- });
-
- describe('disabling childBrowser (childWebView)', function () {
-
- // { '@': { id: 'blackberry.app', required: true, version: '1.0.0.0' },
- // param: { '@': { name: 'childBrowser', value: 'disable' } } }
-
-
- it("sets enableChildWebView to true when childBrowser value is enable", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data['feature'] = { '@': { id: 'blackberry.app' },
- param: { '@': { name: 'childBrowser', value: 'enable' } } };
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.enableChildWebView).toBe(true);
- });
- });
-
- it("sets enableChildWebView to false when value is disable", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data['feature'] = { '@': { id: 'blackberry.app' },
- param: { '@': { name: 'childBrowser', value: 'disable' } } };
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.enableChildWebView).toBe(false);
- });
- });
- });
-
- describe('disabling formcontrol', function () {
-
- it("sets enableFormControl to true when formControl value is enable", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data['feature'] = { '@': { id: 'blackberry.app' },
- param: { '@': { name: 'formControl', value: 'enable' } } };
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.enableFormControl).toBe(true);
- });
- });
-
- it("sets enableFormControl to false when value is disable", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data['feature'] = { '@': { id: 'blackberry.app' },
- param: { '@': { name: 'formControl', value: 'disable' } } };
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.enableFormControl).toBe(false);
- });
- });
- });
-
- describe('setting theme for some core ui elements', function () {
- function testTheme(themeInConfig, themeParsed) {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
-
- if (themeInConfig) {
- data['feature'] = { '@': { id: 'blackberry.app' },
- param: { '@': { name: 'theme', value: themeInConfig } } };
-
- mockParsing(data);
- }
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.theme).toBe(themeParsed);
- });
- }
-
- it("sets theme to dark when config has theme with dark", function () {
- testTheme("dark", "dark");
- });
-
- it("sets theme to bright when config has theme with bright", function () {
- testTheme("bright", "bright");
- });
-
- it("sets theme to inherit when config has theme with inherit", function () {
- testTheme("inherit", "inherit");
- });
-
- it("sets theme to default when config has theme with default", function () {
- testTheme("default", "default");
- });
-
- it("sets theme to default when config has unsupported theme", function () {
- testTheme("unsupportedthemename", "default");
- });
-
- it("sets theme to default when config has no theme provided", function () {
- testTheme(undefined, "default");
- });
-
- it("sets theme to dark when config has theme with case insensitive dark", function () {
- testTheme("dArK", "dark");
- });
-
- it("sets theme to bright when config has theme with case insensitive bright", function () {
- testTheme("BriGht", "bright");
- });
-
- it("sets theme to inherit when config has theme with case insensitive inherit", function () {
- testTheme("inHerIt", "inherit");
- });
-
- it("sets theme to inherit when config has theme with case insensitive inherit", function () {
- testTheme("DefAulT", "default");
- });
-
- it("sets theme to default when config has NO theme tag provided", function () {
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.theme).toBe("default");
- });
- });
- });
-
- describe('disabling WebSecurity', function () {
-
- // { '@': { id: 'blackberry.app', required: true, version: '1.0.0.0' },
- // param: { '@': { name: 'childBrowser', value: 'disable' } } }
-
-
- it("doesn't set enableWebSecurity to anything when param value is anything but disable", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data.feature = { '@': { id: 'blackberry.app' },
- param: { '@': { name: 'websecurity', value: (new Date()).toString() } } };
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.enableWebSecurity).toBe(undefined);
- expect(logger.warn).not.toHaveBeenCalledWith(localize.translate("WARNING_WEBSECURITY_DISABLED"));
- });
- });
-
- it("sets enableWebSecurity to false when value is disable", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data.feature = { '@': { id: 'blackberry.app' },
- param: { '@': { name: 'websecurity', value: 'disable' } } };
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.enableWebSecurity).toBe(false);
- expect(logger.warn).toHaveBeenCalledWith(localize.translate("WARNING_WEBSECURITY_DISABLED"));
- });
- });
-
- it("sets enableWebSecurity to false when value is disable case insensitive", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data.feature = { '@': { id: 'blackberry.app' },
- param: { '@': { name: 'websecurity', value: 'DisAble' } } };
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.enableWebSecurity).toBe(false);
- expect(logger.warn).toHaveBeenCalledWith(localize.translate("WARNING_WEBSECURITY_DISABLED"));
- });
- });
- });
-
- describe('enabling popupBlocker', function () {
-
- // { '@': { id: 'blackberry.app', required: true, version: '1.0.0.0' },
- // param: { '@': { name: 'childBrowser', value: 'disable' } } }
-
- it("sets enableWebSecurity to false when value is disable", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data.feature = { '@': { id: 'blackberry.app' },
- param: { '@': { name: 'popupBlocker', value: 'enable' } } };
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.enablePopupBlocker).toBe(true);
- });
- });
-
- it("sets enableWebSecurity to false when value is disable case insensitive", function () {
- var data = testUtilities.cloneObj(testData.xml2jsConfig);
- data.feature = { '@': { id: 'blackberry.app' },
- param: { '@': { name: 'popupBlocker', value: 'EnAbLe' } } };
-
- mockParsing(data);
-
- configParser.parse(configPath, session, function (configObj) {
- expect(configObj.enablePopupBlocker).toBe(true);
- });
- });
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/67fa7ebb/lib/cordova-blackberry/bin/test/cordova/unit/spec/lib/file-manager.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/test/cordova/unit/spec/lib/file-manager.js b/lib/cordova-blackberry/bin/test/cordova/unit/spec/lib/file-manager.js
deleted file mode 100644
index 1b1c6ff..0000000
--- a/lib/cordova-blackberry/bin/test/cordova/unit/spec/lib/file-manager.js
+++ /dev/null
@@ -1,67 +0,0 @@
-var srcPath = __dirname + "/../../../../../templates/project/cordova/lib/",
- barconf = require(srcPath + "bar-conf.js"),
- fs = require("fs"),
- path = require("path"),
- util = require("util"),
- packager_utils = require(srcPath + "packager-utils"),
- localize = require(srcPath + "localize"),
- wrench = require("wrench"),
- logger = require(srcPath + "logger"),
- conf = require(srcPath + "conf"),
- fileMgr = require(srcPath + "file-manager"),
- testData = require("./test-data"),
- testUtilities = require("./test-utilities"),
- session = testData.session,
- extManager = {
- getAllExtensionsToCopy: function (accessList) {
- return ["app"];
- },
- getFeatureIdByExtensionBasename: function (extBasename) {
- return "blackberry." + extBasename;
- }
- };
-
-describe("File manager", function () {
-
- beforeEach(function () {
- wrench.mkdirSyncRecursive(testData.session.outputDir);
- });
-
- afterEach(function () {
- //cleanup packager-tests temp folder
- wrench.rmdirSyncRecursive(testData.session.outputDir);
- });
-
- it("unzip() should extract 'from' zip file to 'to' directory", function () {
- var from = session.archivePath,
- to = session.sourceDir;
-
- fileMgr.unzip(from, to);
-
- expect(fs.statSync(session.sourceDir + "/a").isDirectory()).toBeTruthy();
- expect(fs.statSync(session.sourceDir + "/a/dummy.txt").isFile()).toBeTruthy();
- expect(fs.statSync(session.sourceDir + "/a/b").isDirectory()).toBeTruthy();
- expect(fs.statSync(session.sourceDir + "/a/b/dummy2.txt").isFile()).toBeTruthy();
- expect(fs.statSync(session.sourceDir + "/startPage.html").isFile()).toBeTruthy();
- expect(fs.statSync(session.sourceDir + "/config.xml").isFile()).toBeTruthy();
- expect(fs.statSync(session.sourceDir + "/test.png").isFile()).toBeTruthy();
- });
-
- it("cleanSource() should delete source folder", function () {
- //Create packager-tests source folder
- wrench.mkdirSyncRecursive(session.sourceDir);
-
- fileMgr.cleanSource(session);
- expect(fs.existsSync(session.sourceDir)).toBeFalsy();
- });
-
- it("prepareOutputFiles() should throw an error if the archive path doesn't exist", function () {
- spyOn(wrench, "copyDirSyncRecursive");
- var tempSession = testUtilities.cloneObj(session);
- tempSession.archivePath = path.resolve("test/non-existant.zip");
- expect(function () {
- fileMgr.prepareOutputFiles(tempSession);
- }).toThrow(localize.translate("EXCEPTION_INVALID_ARCHIVE_PATH", tempSession.archivePath));
- });
-
-});
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/67fa7ebb/lib/cordova-blackberry/bin/test/cordova/unit/spec/lib/i18n-manager.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/test/cordova/unit/spec/lib/i18n-manager.js b/lib/cordova-blackberry/bin/test/cordova/unit/spec/lib/i18n-manager.js
deleted file mode 100644
index 50d7225..0000000
--- a/lib/cordova-blackberry/bin/test/cordova/unit/spec/lib/i18n-manager.js
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * Copyright 2012 Research In Motion Limited.
- *
- * Licensed 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 testData = require("./test-data"),
- i18nMgr = require(testData.libPath + "/i18n-manager"),
- session = testData.session,
- fs = require("fs"),
- wrench = require("wrench"),
- pkgrUtils = require(testData.libPath + "/packager-utils");
-
-function mockOSReturnFiles(files) {
- if (pkgrUtils.isWindows()) {
- var newFiles = [];
- files.forEach(function (f) {
- newFiles.push(session.sourceDir + "\\locales\\" + f.split("/").join("\\"));
- });
- return newFiles;
- } else {
- return files;
- }
-}
-
-describe("i18n manager", function () {
- it("generate correct metadata for icon", function () {
- var config = {
- icon: ["logo.png"]
- },
- xmlObject = {};
-
- spyOn(fs, "existsSync").andReturn(true);
- spyOn(wrench, "readdirSyncRecursive").andReturn(mockOSReturnFiles([
- 'fr',
- 'fr/logo.png'
- ]));
-
- i18nMgr.generateLocalizedMetadata(session, config, xmlObject, "icon");
-
- expect(xmlObject.icon).toBeDefined();
- expect(xmlObject.icon.image).toBeDefined();
- expect(xmlObject.icon.image.length).toBe(2);
- expect(xmlObject.icon.image).toContain({
- _value: "logo.png"
- });
- expect(xmlObject.icon.image).toContain({
- text: {
- _attr: {
- "xml:lang": "fr"
- },
- _value: "locales/fr/logo.png"
- }
- });
- });
-
- it("generate correct metadata for icon when locales folder does not exist", function () {
- var config = {
- icon: ["logo.png"]
- },
- xmlObject = {};
-
- spyOn(fs, "existsSync").andReturn(false);
-
- i18nMgr.generateLocalizedMetadata(session, config, xmlObject, "icon");
-
- expect(xmlObject.icon).toBeDefined();
- expect(xmlObject.icon.image).toBeDefined();
- expect(xmlObject.icon.image.length).toBe(1);
- expect(xmlObject.icon.image).toContain({
- _value: "logo.png"
- });
- });
-
- it("generate correct metadata for icon when locale folder does not contain matching image", function () {
- var config = {
- icon: ["logo.png"]
- },
- xmlObject = {};
-
- spyOn(fs, "existsSync").andReturn(true);
- spyOn(wrench, "readdirSyncRecursive").andReturn(mockOSReturnFiles([
- 'fr',
- 'fr/logo-mismatch.png'
- ]));
-
- i18nMgr.generateLocalizedMetadata(session, config, xmlObject, "icon");
-
- expect(xmlObject.icon).toBeDefined();
- expect(xmlObject.icon.image).toBeDefined();
- expect(xmlObject.icon.image.length).toBe(1);
- expect(xmlObject.icon.image).toContain({
- _value: "logo.png"
- });
- });
-
- it("generate correct metadata for icon when image is in subfolder", function () {
- var config = {
- icon: ["assets\\images\\logo.png"]
- },
- xmlObject = {};
-
- spyOn(fs, "existsSync").andReturn(true);
- spyOn(wrench, "readdirSyncRecursive").andReturn(mockOSReturnFiles([
- 'fr',
- 'fr/assets/images/logo.png'
- ]));
-
- i18nMgr.generateLocalizedMetadata(session, config, xmlObject, "icon");
-
- expect(xmlObject.icon).toBeDefined();
- expect(xmlObject.icon.image).toBeDefined();
- expect(xmlObject.icon.image.length).toBe(2);
- expect(xmlObject.icon.image).toContain({
- _value: "assets/images/logo.png"
- });
- expect(xmlObject.icon.image).toContain({
- text: {
- _attr: {
- "xml:lang": "fr"
- },
- _value: "locales/fr/assets/images/logo.png"
- }
- });
- });
-
- it("generate correct metadata for icon when image is in subfolder and OS is windows", function () {
- var config = {
- icon: ["assets\\images\\logo.png"]
- },
- xmlObject = {};
-
- spyOn(pkgrUtils, 'isWindows').andReturn(true);
- spyOn(fs, "existsSync").andReturn(true);
- spyOn(wrench, "readdirSyncRecursive").andReturn(mockOSReturnFiles([
- 'fr',
- 'fr\\assets\\images\\logo.png'
- ]));
-
- i18nMgr.generateLocalizedMetadata(session, config, xmlObject, "icon");
-
- expect(xmlObject.icon).toBeDefined();
- expect(xmlObject.icon.image).toBeDefined();
- expect(xmlObject.icon.image.length).toBe(1);
- expect(xmlObject.icon.image).toContain({
- _value: "assets/images/logo.png"
- });
- });
-
- it("generate correct metadata for splash and OS is *nx", function () {
- var config = {
- "rim:splash": ["splash-1280x768.jpg", "splash-768x1280.jpg"]
- },
- xmlObject = {};
-
- spyOn(pkgrUtils, 'isWindows').andReturn(false);
- spyOn(fs, "existsSync").andReturn(true);
- spyOn(wrench, "readdirSyncRecursive").andReturn(mockOSReturnFiles([
- 'fr',
- 'fr/splash-1280x768.jpg',
- 'fr/splash-768x1280.jpg'
- ]));
-
- i18nMgr.generateLocalizedMetadata(session, config, xmlObject, "rim:splash");
-
- expect(xmlObject.splashScreens).toBeDefined();
- expect(xmlObject.splashScreens.image).toBeDefined();
- expect(xmlObject.splashScreens.image.length).toBe(4);
- expect(xmlObject.splashScreens.image).toContain({
- _value: "splash-1280x768.jpg"
- });
- expect(xmlObject.splashScreens.image).toContain({
- _value: "splash-768x1280.jpg"
- });
- expect(xmlObject.splashScreens.image).toContain({
- text: {
- _attr: {
- "xml:lang": "fr"
- },
- _value: "locales/fr/splash-1280x768.jpg"
- }
- });
- expect(xmlObject.splashScreens.image).toContain({
- text: {
- _attr: {
- "xml:lang": "fr"
- },
- _value: "locales/fr/splash-768x1280.jpg"
- }
- });
- });
-
- it("generate correct metadata for splash when locales folder does not exist", function () {
- var config = {
- "rim:splash": ["splash-1280x768.jpg", "splash-768x1280.jpg"]
- },
- xmlObject = {};
-
- spyOn(fs, "existsSync").andReturn(false);
-
- i18nMgr.generateLocalizedMetadata(session, config, xmlObject, "rim:splash");
-
- expect(xmlObject.splashScreens).toBeDefined();
- expect(xmlObject.splashScreens.image).toBeDefined();
- expect(xmlObject.splashScreens.image.length).toBe(2);
- expect(xmlObject.splashScreens.image).toContain({
- _value: "splash-1280x768.jpg"
- });
- expect(xmlObject.splashScreens.image).toContain({
- _value: "splash-768x1280.jpg"
- });
- });
-
- it("generate correct metadata for splash when locale folder does not contain matching image", function () {
- var config = {
- "rim:splash": ["splash-1280x768.jpg", "splash-768x1280.jpg"]
- },
- xmlObject = {};
-
- spyOn(fs, "existsSync").andReturn(true);
- spyOn(wrench, "readdirSyncRecursive").andReturn(mockOSReturnFiles([
- 'fr',
- 'fr/splash-1280x768-mismatch.jpg',
- 'fr/splash-768x1280.jpg'
- ]));
-
- i18nMgr.generateLocalizedMetadata(session, config, xmlObject, "rim:splash");
-
- expect(xmlObject.splashScreens).toBeDefined();
- expect(xmlObject.splashScreens.image).toBeDefined();
- expect(xmlObject.splashScreens.image.length).toBe(3);
- expect(xmlObject.splashScreens.image).toContain({
- _value: "splash-1280x768.jpg"
- });
- expect(xmlObject.splashScreens.image).toContain({
- _value: "splash-768x1280.jpg"
- });
- expect(xmlObject.splashScreens.image).toContain({
- text: {
- _attr: {
- "xml:lang": "fr"
- },
- _value: "locales/fr/splash-768x1280.jpg"
- }
- });
- });
-
- it("generate correct metadata for splash when image is in subfolder", function () {
- var config = {
- "rim:splash": ["assets\\images\\splash-1280x768.jpg", "assets\\images\\splash-768x1280.jpg"]
- },
- xmlObject = {};
-
- spyOn(fs, "existsSync").andReturn(true);
- spyOn(wrench, "readdirSyncRecursive").andReturn(mockOSReturnFiles([
- 'fr',
- 'fr/assets/images/splash-1280x768.jpg',
- 'fr/assets/images/splash-768x1280.jpg'
- ]));
-
- i18nMgr.generateLocalizedMetadata(session, config, xmlObject, "rim:splash");
-
- expect(xmlObject.splashScreens).toBeDefined();
- expect(xmlObject.splashScreens.image).toBeDefined();
- expect(xmlObject.splashScreens.image.length).toBe(4);
- expect(xmlObject.splashScreens.image).toContain({
- _value: "assets/images/splash-1280x768.jpg"
- });
- expect(xmlObject.splashScreens.image).toContain({
- _value: "assets/images/splash-768x1280.jpg"
- });
- expect(xmlObject.splashScreens.image).toContain({
- text: {
- _attr: {
- "xml:lang": "fr"
- },
- _value: "locales/fr/assets/images/splash-1280x768.jpg"
- }
- });
- expect(xmlObject.splashScreens.image).toContain({
- text: {
- _attr: {
- "xml:lang": "fr"
- },
- _value: "locales/fr/assets/images/splash-768x1280.jpg"
- }
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/67fa7ebb/lib/cordova-blackberry/bin/test/cordova/unit/spec/lib/logger.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/test/cordova/unit/spec/lib/logger.js b/lib/cordova-blackberry/bin/test/cordova/unit/spec/lib/logger.js
deleted file mode 100644
index c8aadb9..0000000
--- a/lib/cordova-blackberry/bin/test/cordova/unit/spec/lib/logger.js
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright 2012 Research In Motion Limited.
- *
- * Licensed 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 srcPath = __dirname + "/../../../../../templates/project/cordova/lib/",
- logger = require(srcPath + "logger");
-
-describe("logger", function () {
- describe("when the log level is verbose", function () {
- beforeEach(function () {
- spyOn(console, "log");
- logger.level('verbose');
- });
-
- it("logs info messages", function () {
- logger.info("cheese is made from milk");
- expect(console.log).toHaveBeenCalledWith("[INFO] cheese is made from milk");
- });
-
- it("logs error messages", function () {
- logger.error("PC LOAD LETTER");
- expect(console.log).toHaveBeenCalledWith("[ERROR] PC LOAD LETTER");
- });
-
- it("logs warning messages", function () {
- logger.warn("beware the ides of march");
- expect(console.log).toHaveBeenCalledWith("[WARN] beware the ides of march");
- });
-
- it("logs messages", function () {
- logger.log("Hulk Smash!");
- expect(console.log).toHaveBeenCalledWith("[BUILD] Hulk Smash!");
- });
- });
-
- describe("when the log level is warn", function () {
- beforeEach(function () {
- spyOn(console, "log");
- logger.level('warn');
- });
-
- it("doesn't log info messages", function () {
- logger.info("cheese is made from milk");
- expect(console.log).not.toHaveBeenCalledWith("[INFO] cheese is made from milk");
- });
-
- it("logs error messages", function () {
- logger.error("PC LOAD LETTER");
- expect(console.log).toHaveBeenCalledWith("[ERROR] PC LOAD LETTER");
- });
-
- it("logs warning messages", function () {
- logger.warn("beware the ides of march");
- expect(console.log).toHaveBeenCalledWith("[WARN] beware the ides of march");
- });
-
- it("logs messages", function () {
- logger.log("Hulk Smash!");
- expect(console.log).toHaveBeenCalledWith("[BUILD] Hulk Smash!");
- });
- });
-
- describe("when the log level is error", function () {
- beforeEach(function () {
- spyOn(console, "log");
- logger.level('error');
- });
-
- it("doesn't log info messages", function () {
- logger.info("cheese is made from milk");
- expect(console.log).not.toHaveBeenCalledWith("[INFO] cheese is made from milk");
- });
-
- it("logs error messages", function () {
- logger.error("PC LOAD LETTER");
- expect(console.log).toHaveBeenCalledWith("[ERROR] PC LOAD LETTER");
- });
-
- it("doesn't log warning messages", function () {
- logger.warn("beware the ides of march");
- expect(console.log).not.toHaveBeenCalledWith("[WARN] beware the ides of march");
- });
-
- it("logs messages", function () {
- logger.log("Hulk Smash!");
- expect(console.log).toHaveBeenCalledWith("[BUILD] Hulk Smash!");
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/67fa7ebb/lib/cordova-blackberry/bin/test/cordova/unit/spec/lib/native-packager.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/test/cordova/unit/spec/lib/native-packager.js b/lib/cordova-blackberry/bin/test/cordova/unit/spec/lib/native-packager.js
deleted file mode 100644
index a4ab63e..0000000
--- a/lib/cordova-blackberry/bin/test/cordova/unit/spec/lib/native-packager.js
+++ /dev/null
@@ -1,347 +0,0 @@
-var path = require("path"),
- util = require("util"),
- fs = require("fs"),
- childProcess = require("child_process"),
- wrench = require("wrench"),
- srcPath = __dirname + "/../../../../../templates/project/cordova/lib/",
- nativePkgr = require(srcPath + "/native-packager"),
- pkgrUtils = require(srcPath + "/packager-utils"),
- testUtils = require("./test-utilities"),
- testData = require("./test-data"),
- logger = require(srcPath + "logger"),
- localize = require(srcPath + "/localize"),
- conf = require(srcPath + "./conf"),
- callback,
- config,
- session,
- target,
- result,
- orgDebugEnabled,
- orgDebugTokenPath,
- NL = pkgrUtils.isWindows() ? "\r\n" : "\n";
-
-describe("Native packager", function () {
- beforeEach(function () {
- callback = jasmine.createSpy();
- config = testData.config;
- session = testData.session;
- target = session.targets[0];
- result = {
- stdout: {
- on: jasmine.createSpy()
- },
- stderr: {
- on: jasmine.createSpy()
- },
- on: function (eventName, callback) {
- callback(0);
- }
- };
-
- // Store original debug token setting and later restore them in afterEach
- // to be able to test positive and negative cases of each.
- orgDebugEnabled = session.debug;
- orgDebugTokenPath = session.conf.DEBUG_TOKEN;
-
- spyOn(wrench, "readdirSyncRecursive").andReturn(["abc", "xyz"]);
- spyOn(fs, "statSync").andReturn({
- isDirectory: function () {
- return false;
- }
- });
- spyOn(fs, "writeFileSync");
- spyOn(childProcess, "spawn").andReturn(result);
- spyOn(fs, "existsSync").andCallFake(function (path) {
- //Return true if this is the bbndk folder check
- return path.indexOf("bbndk") !== -1;
- });
- });
-
- afterEach(function () {
- session.debug = orgDebugEnabled;
- session.conf.DEBUG_TOKEN = orgDebugTokenPath;
- });
-
- it("should not display empty messages in logger", function () {
- spyOn(pkgrUtils, "writeFile");
- spyOn(logger, "warn");
- spyOn(logger, "error");
- spyOn(logger, "info");
-
- nativePkgr.exec(session, target, testData.config, callback);
-
- expect(logger.warn).not.toHaveBeenCalledWith("");
- expect(logger.error).not.toHaveBeenCalledWith("");
- expect(logger.info).not.toHaveBeenCalledWith("");
- });
-
- it("shows debug token warning when path to file is not valid", function () {
- spyOn(pkgrUtils, "writeFile");
- spyOn(logger, "warn");
-
- session.debug = true;
- //Current time will ensure that the file doesn't exist.
- session.conf.DEBUG_TOKEN = new Date().getTime() + ".bar";
-
- nativePkgr.exec(session, target, testData.config, callback);
-
- expect(logger.warn).toHaveBeenCalledWith(localize.translate("EXCEPTION_DEBUG_TOKEN_NOT_FOUND"));
- });
-
- it("won't show debug token warning when -d options wasn't provided", function () {
- spyOn(pkgrUtils, "writeFile");
- spyOn(logger, "warn");
-
- session.debug = false;
- //Current time will ensure that the file doesn't exist.
- session.conf.DEBUG_TOKEN = new Date().getTime() + ".bar";
-
- nativePkgr.exec(session, target, testData.config, callback);
-
- expect(logger.warn).not.toHaveBeenCalled();
- });
-
- it("shows debug token warning when debug token not a .bar file", function () {
- spyOn(pkgrUtils, "writeFile");
- spyOn(logger, "warn");
-
- session.debug = true;
- //Current time will ensure that the file doesn't exist.
- session.conf.DEBUG_TOKEN = new Date().getTime() + ".xyz";
-
- nativePkgr.exec(session, target, testData.config, callback);
- expect(logger.warn).toHaveBeenCalledWith(localize.translate("EXCEPTION_DEBUG_TOKEN_WRONG_FILE_EXTENSION"));
- });
-
- it("exec blackberry-nativepackager", function () {
- var bbTabletXML = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
- "<qnx><id>" + config.id + "</id>" +
- "<versionNumber>" + config.version + "</versionNumber>" +
- "<author>" + config.author + "</author>" +
- "<asset entry=\"true\" type=\"qnx/elf\">wwe</asset>" +
- "<asset>abc</asset>" +
- "<asset>xyz</asset>" +
- "<entryPointType>Qnx/WebKit</entryPointType>" +
- "<cascadesTheme>" + config.theme + "</cascadesTheme>" +
- "<initialWindow><systemChrome>none</systemChrome><transparent>true</transparent><autoOrients>true</autoOrients></initialWindow>",
- bbTabletXML2 = "<permission system=\"true\">run_native</permission>" +
- "<permission system=\"false\">access_internet</permission>" +
- "<name>" + config.name['default'] + "</name>" +
- "<description>" + config.description['default'] + "</description></qnx>",
- cmd = path.normalize(session.conf.DEPENDENCIES_TOOLS + "/bin/blackberry-nativepackager" + (pkgrUtils.isWindows() ? ".bat" : ""));
-
- spyOn(pkgrUtils, "writeFile").andCallFake(function (sourceDir, outputDir, data) {
- expect(sourceDir).toEqual(session.sourceDir);
- expect(outputDir).toEqual(conf.BAR_DESCRIPTOR);
-
- //We have to validate the xml data in 2 chucks, because the WEBWORKS_VERSION env variable
- //has a different value for SCM builds and we can't mock the webworks-info file
- expect(data).toContain(bbTabletXML);
- expect(data).toContain(bbTabletXML2);
- });
- nativePkgr.exec(session, target, testData.config, callback);
-
- expect(fs.writeFileSync).toHaveBeenCalledWith(jasmine.any(String), jasmine.any(String));
- expect(childProcess.spawn).toHaveBeenCalledWith(cmd, ["@options"], {"cwd": session.sourceDir, "env": process.env});
- expect(callback).toHaveBeenCalledWith(0);
- });
-
- it("makes sure slog2 logging is enabled in debug mode", function () {
- var tabletXMLEntry = "<env value=\"slog2\" var=\"CONSOLE_MODE\"></env>";
-
- //Silence the logger during unit tests
- spyOn(logger, "warn").andCallFake(function () { });
- spyOn(pkgrUtils, "writeFile").andCallFake(function (sourceDir, outputDir, data) {
- expect(data).toContain(tabletXMLEntry);
- });
-
- session.debug = true;
- nativePkgr.exec(session, target, testData.config, callback);
- });
-
- it("makes sure slog2 logging is not enabled when not in debug mode", function () {
- var tabletXMLEntry = "<env value=\"slog2\" var=\"CONSOLE_MODE\"></env>";
-
- spyOn(pkgrUtils, "writeFile").andCallFake(function (sourceDir, outputDir, data) {
- expect(data).not.toContain(tabletXMLEntry);
- });
-
- session.debug = false;
- nativePkgr.exec(session, target, testData.config, callback);
- });
-
- it("can process application name", function () {
- var config = testUtils.cloneObj(testData.config);
- config.name = {"default": "API Smoke Test"};
-
- spyOn(pkgrUtils, "writeFile").andCallFake(function (fileLocation, fileName, fileData) {
- expect(fileData).toContain("<name>API Smoke Test</name>");
- });
-
- nativePkgr.exec(session, target, config, callback);
-
- });
-
- it("can process localized application name", function () {
- var config = testUtils.cloneObj(testData.config);
- config.name = {"FR": "API Smoke Test - FR"};
-
- spyOn(pkgrUtils, "writeFile").andCallFake(function (fileLocation, fileName, fileData) {
- expect(fileData).toContain('<name><text xml:lang="FR">API Smoke Test - FR</text></name>');
- });
-
- nativePkgr.exec(session, target, config, callback);
- });
-
- it("can process mutiple application names", function () {
- var config = testUtils.cloneObj(testData.config);
- config.name = {
- "default": "API Smoke Test",
- "EN": "API Smoke Test - EN",
- "FR": "API Smoke Test - FR"
- };
-
- spyOn(pkgrUtils, "writeFile").andCallFake(function (fileLocation, fileName, fileData) {
- expect(fileData).toContain('<name>API Smoke Test<text xml:lang="EN">API Smoke Test - EN</text><text xml:lang="FR">API Smoke Test - FR</text></name>');
- });
-
- nativePkgr.exec(session, target, config, callback);
- });
-
- it("can process application description", function () {
- var config = testUtils.cloneObj(testData.config);
- config.description = {"default": "My app description"};
-
- spyOn(pkgrUtils, "writeFile").andCallFake(function (fileLocation, fileName, fileData) {
- expect(fileData).toContain("<description>My app description</description>");
- });
-
- nativePkgr.exec(session, target, config, callback);
-
- });
-
- it("can process localized application description", function () {
- var config = testUtils.cloneObj(testData.config);
- config.description = {"FR": "My app description - FR"};
-
- spyOn(pkgrUtils, "writeFile").andCallFake(function (fileLocation, fileName, fileData) {
- expect(fileData).toContain('<description><text xml:lang="FR">My app description - FR</text></description>');
- });
-
- nativePkgr.exec(session, target, config, callback);
- });
-
- it("can process mutiple application descriptions", function () {
- var config = testUtils.cloneObj(testData.config);
- config.description = {
- "default": "My app description",
- "EN": "My app description - EN",
- "FR": "My app description - FR"
- };
-
- spyOn(pkgrUtils, "writeFile").andCallFake(function (fileLocation, fileName, fileData) {
- expect(fileData).toContain('<description>My app description<text xml:lang="EN">My app description - EN</text><text xml:lang="FR">My app description - FR</text></description>');
- });
-
- nativePkgr.exec(session, target, config, callback);
- });
-
- it("can process permissions with no attributes", function () {
- var config = testUtils.cloneObj(testData.config);
- config.permissions = ['read_device_identifying_information'];
-
- spyOn(pkgrUtils, "writeFile").andCallFake(function (fileLocation, fileName, fileData) {
- expect(fileData).toContain("<permission>read_device_identifying_information</permission>");
- });
-
- nativePkgr.exec(session, target, config, callback);
-
- });
-
- it("can process permissions with attributes", function () {
- var config = testUtils.cloneObj(testData.config);
- config.permissions = [{ '#': 'systemPerm', '@': {"system": "true"}}];
-
- spyOn(pkgrUtils, "writeFile").andCallFake(function (fileLocation, fileName, fileData) {
- expect(fileData).toContain("<permission system=\"true\">systemPerm</permission>");
- });
-
- nativePkgr.exec(session, target, config, callback);
-
- });
-
- it("adds the mandatory permissions for webworks", function () {
- var config = testUtils.cloneObj(testData.config);
- config.permissions = [];
-
- spyOn(pkgrUtils, "writeFile").andCallFake(function (fileLocation, fileName, fileData) {
- expect(fileData).toContain("<permission system=\"false\">access_internet</permission>");
- expect(fileData).toContain("<permission system=\"true\">run_native</permission>");
- });
-
- nativePkgr.exec(session, target, config, callback);
-
- });
-
- it("omits -devMode when signing and specifying -d", function () {
- testUtils.mockResolve(path);
- spyOn(pkgrUtils, "writeFile");
-
- var session = testUtils.cloneObj(testData.session),
- config = testUtils.cloneObj(testData.config),
- target = "device",
- optionsFile = "-package" + NL +
- "-buildId" + NL +
- "100" + NL +
- path.normalize("c:/device/Demo.bar") + NL +
- "-barVersion" + NL +
- "1.5" + NL +
- "-C" + NL +
- path.normalize("c:/src/") + NL +
- conf.BAR_DESCRIPTOR + NL +
- path.normalize("c:/src/abc") + NL +
- path.normalize("c:/src/xyz") + NL;
-
- //Set signing params [-g --buildId]
- session.keystore = path.normalize("c:/author.p12");
- session.storepass = "password";
- config.buildId = "100";
-
- session.barPath = path.normalize("c:/%s/" + "Demo.bar");
- session.sourceDir = path.normalize("c:/src/");
- session.isSigningRequired = function () {
- return true;
- };
-
- //Set -d param
- session.debug = "";
-
- nativePkgr.exec(session, target, config, callback);
-
- //options file should NOT contain -devMode
- expect(fs.writeFileSync).toHaveBeenCalledWith(jasmine.any(String), optionsFile);
- });
-
- it("exec blackberry-nativepackager with additional params", function () {
- var cmd = path.normalize(session.conf.DEPENDENCIES_TOOLS + "/bin/blackberry-nativepackager" + (pkgrUtils.isWindows() ? ".bat" : ""));
- spyOn(pkgrUtils, "writeFile");
-
- session.getParams = jasmine.createSpy("session getParams").andReturn({
- "-installApp": "",
- "-device": "192.168.1.114",
- "-password": "abc"
- });
-
- nativePkgr.exec(session, "simulator", testData.config, callback);
-
- expect(fs.writeFileSync.mostRecentCall.args[0]).toBe(path.resolve(session.sourceDir, "options"));
- expect(fs.writeFileSync.mostRecentCall.args[1]).toContain("-package" + NL);
- expect(fs.writeFileSync.mostRecentCall.args[1]).toContain("-password" + NL);
- expect(fs.writeFileSync.mostRecentCall.args[1]).toContain("abc" + NL);
- expect(fs.writeFileSync.mostRecentCall.args[1]).toContain("-device" + NL);
- expect(fs.writeFileSync.mostRecentCall.args[1]).toContain("192.168.1.114" + NL);
- expect(fs.writeFileSync.mostRecentCall.args[1]).toContain("-installApp" + NL);
- expect(childProcess.spawn).toHaveBeenCalledWith(cmd, ["@options"], {"cwd": session.sourceDir, "env": process.env});
- expect(callback).toHaveBeenCalledWith(0);
- });
-});