You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by lo...@apache.org on 2013/05/07 17:24:26 UTC

[21/51] [partial] [BlackBerry10] Added support for new platform

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6831bed4/lib/cordova-blackberry/blackberry10/bin/test/cordova/integration/create.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/blackberry10/bin/test/cordova/integration/create.js b/lib/cordova-blackberry/blackberry10/bin/test/cordova/integration/create.js
new file mode 100644
index 0000000..d193580
--- /dev/null
+++ b/lib/cordova-blackberry/blackberry10/bin/test/cordova/integration/create.js
@@ -0,0 +1,158 @@
+/**
+    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 childProcess = require('child_process'),
+    tempFolder = '.tmp/',
+    appFolder = tempFolder + 'tempCordovaApp/',
+    projectFile = 'project.json',
+    wrench = require('wrench'),
+    fs = require('fs'),
+    flag = false,
+    _stdout = "",
+    _stderr = "";
+
+function executeScript(shellCommand) {
+    childProcess.exec(shellCommand, function (error, stdout, stderr) {
+        if (error) {
+            console.log("Error executing command: " + error);
+        }
+        _stdout = stdout.toString().trim();
+        _stderr = stderr.toString().trim();
+        flag = true;
+    });
+}
+
+describe("create tests", function () {
+    it("creates project", function () {
+        var project,
+            appIdRegExp = /id="default\.app\.id"/g;
+        executeScript("bin/create " + appFolder);
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+            project = JSON.parse(fs.readFileSync(appFolder + projectFile, "utf-8"));
+            expect(appIdRegExp.test(fs.readFileSync(appFolder + "www/config.xml", "utf-8"))).toEqual(true);
+            expect(fs.existsSync(appFolder)).toEqual(true);
+            expect(fs.existsSync(appFolder + "/plugins")).toEqual(true);
+            expect(fs.existsSync(appFolder + "/cordova")).toEqual(true);
+            expect(fs.existsSync(appFolder + "/cordova/node_modules")).toEqual(true);
+            expect(fs.existsSync(appFolder + "/cordova/lib")).toEqual(true);
+            expect(fs.existsSync(appFolder + "/cordova/third_party")).toEqual(true);
+            expect(fs.existsSync(appFolder + "/www")).toEqual(true);
+            expect(project.barName).toEqual("cordova-BB10-app");
+            expect(project.keystorepass).toEqual("password");
+            expect(project.defaultTarget).toEqual("");
+            expect(project.targets).toEqual({});
+            expect(fs.existsSync("./build")).toEqual(false);
+            expect(_stdout).toEqual("");
+            expect(_stderr).toEqual("");
+        });
+        this.after(function () {
+            wrench.rmdirSyncRecursive(tempFolder);
+        });
+    });
+
+    it("sets appId", function () {
+        var configEt,
+            appIdRegExp = /id="com\.example\.bb10app"/g;
+        executeScript("bin/create " + appFolder + " com.example.bb10app");
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+            expect(appIdRegExp.test(fs.readFileSync(appFolder + "www/config.xml", "utf-8"))).toEqual(true);
+            expect(_stdout).toEqual("");
+            expect(_stderr).toEqual("");
+        });
+        this.after(function () {
+            wrench.rmdirSyncRecursive(tempFolder);
+        });
+    });
+
+    it("sets appId and barName", function () {
+        var project,
+            appIdRegExp = /id="com\.example\.bb10app"/g;
+        executeScript("bin/create " + appFolder + " com.example.bb10app bb10appV1");
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+            project = JSON.parse(fs.readFileSync(appFolder + projectFile, "utf-8"));
+            expect(appIdRegExp.test(fs.readFileSync(appFolder + "www/config.xml", "utf-8"))).toEqual(true);
+            expect(project.barName).toEqual("bb10appV1");
+            expect(_stdout).toEqual("");
+            expect(_stderr).toEqual("");
+        });
+        this.after(function () {
+            wrench.rmdirSyncRecursive(tempFolder);
+        });
+    });
+
+    it("No args", function () {
+        executeScript("bin/create");
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+            expect(_stdout).toEqual("You must give a project PATH");
+            expect(_stderr).toEqual("");
+        });
+    });
+
+    it("Empty dir error", function () {
+        executeScript("bin/create ./");
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+            expect(_stdout).toEqual("The project path must be an empty directory");
+            expect(_stderr).toEqual("");
+        });
+    });
+
+    it("Invalid appId error", function () {
+        executeScript("bin/create " + appFolder + " 23.21#$");
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+            expect(_stdout).toEqual("App ID must be sequence of alpha-numeric (optionally seperated by '.') characters, no longer than 50 characters");
+            expect(_stderr).toEqual("");
+        });
+    });
+
+    it("Invalid barName error", function () {
+        executeScript("bin/create " + appFolder + " com.example.app %bad@bar^name");
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+            expect(_stdout).toEqual("BAR filename can only contain alpha-numeric, '.', '-' and '_' characters");
+            expect(_stderr).toEqual("");
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6831bed4/lib/cordova-blackberry/blackberry10/bin/test/cordova/integration/target.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/blackberry10/bin/test/cordova/integration/target.js b/lib/cordova-blackberry/blackberry10/bin/test/cordova/integration/target.js
new file mode 100644
index 0000000..e948a87
--- /dev/null
+++ b/lib/cordova-blackberry/blackberry10/bin/test/cordova/integration/target.js
@@ -0,0 +1,237 @@
+/**
+    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 childProcess = require('child_process'),
+    tempFolder = '.tmp/',
+    appFolder = tempFolder + 'tempCordovaApp/',
+    projectFile = 'project.json',
+    wrench = require('wrench'),
+    fs = require('fs'),
+    flag = false,
+    _stdout = "",
+    _stderr = "";
+
+function executeScript(shellCommand) {
+    childProcess.exec(shellCommand, function (error, stdout, stderr) {
+        if (error) {
+            console.log("Error executing command: " + error);
+        }
+        _stdout = stdout.toString().trim();
+        _stderr = stderr.toString().trim();
+        flag = true;
+    });
+}
+
+describe("cordova/target tests", function () {
+    beforeEach(function () {
+        executeScript("bin/create " + appFolder);
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+        });
+    });
+
+    afterEach(function () {
+        wrench.rmdirSyncRecursive(tempFolder);
+    });
+
+    it("should add a target", function () {
+        var project,
+            target;
+        executeScript(appFolder + "cordova/target add z10 169.254.0.1 device -p pass --pin DEADBEEF");
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+            project = JSON.parse(fs.readFileSync(appFolder + projectFile, 'utf-8'));
+            expect(project.defaultTarget).toEqual("z10");
+            expect(Object.keys(project.targets).length).toEqual(1);
+            target = project.targets.z10;
+            expect(target.ip).toEqual("169.254.0.1");
+            expect(target.type).toEqual("device");
+            expect(target.password).toEqual("pass");
+            expect(target.pin).toEqual("DEADBEEF");
+            expect(_stdout).toEqual("");
+            expect(_stderr).toEqual("");
+        });
+    });
+
+    it("should remove a target", function () {
+        var project;
+        executeScript(appFolder + "cordova/target add z10 169.254.0.1 device -p pass --pin DEADBEEF");
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+            executeScript(appFolder + "cordova/target remove z10");
+            waitsFor(function () {
+                return flag;
+            });
+            runs(function () {
+                flag = false;
+                project = JSON.parse(fs.readFileSync(appFolder + projectFile, 'utf-8'));
+                expect(project.defaultTarget).toEqual("");
+                expect(Object.keys(project.targets).length).toEqual(0);
+                expect(_stdout).toEqual("Deleting default target, please set a new default target");
+                expect(_stderr).toEqual("");
+            });
+        });
+    });
+
+    it("should set default target", function () {
+        var project;
+        executeScript(appFolder + "cordova/target add z10 169.254.0.1 device -p pass --pin DEADBEEF");
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+            executeScript(appFolder + "cordova/target add q10 169.254.0.2 device -p p455w02D --pin FACEFACE");
+            waitsFor(function () {
+                return flag;
+            });
+            runs(function () {
+                flag = false;
+                executeScript(appFolder + "cordova/target default q10");
+                waitsFor(function () {
+                    return flag;
+                });
+                runs(function () {
+                    flag = false;
+                    project = JSON.parse(fs.readFileSync(appFolder + projectFile, 'utf-8'));
+                    expect(project.defaultTarget).toEqual("q10");
+                });
+            });
+        });
+    });
+
+    it("should list targets", function () {
+        executeScript(appFolder + "cordova/target add z10 169.254.0.1 device -p pass --pin DEADBEEF");
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+            executeScript(appFolder + "cordova/target add q10 169.254.0.2 device -p p455w02D --pin FACEFACE");
+            waitsFor(function () {
+                return flag;
+            });
+            runs(function () {
+                flag = false;
+                executeScript(appFolder + "cordova/target");
+                waitsFor(function () {
+                    return flag;
+                });
+                runs(function () {
+                    flag = false;
+                    expect(_stdout).toEqual("* z10\n  q10");
+                    expect(_stderr).toEqual("");
+                });
+            });
+        });
+    });
+
+    it("should require name for add/remove", function () {
+        executeScript(appFolder + "cordova/target add");
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+            expect(_stdout).toEqual("Target details not specified");
+            expect(_stderr).toEqual("");
+        });
+    });
+
+    it("should require ip for add", function () {
+        executeScript(appFolder + "cordova/target add z10");
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+            expect(_stdout).toEqual("IP is required");
+            expect(_stderr).toEqual("");
+        });
+    });
+
+    it("should require type for add ", function () {
+        executeScript(appFolder + "cordova/target add z10 169.254.0.1");
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+            expect(_stdout).toEqual("target type is required");
+            expect(_stderr).toEqual("");
+        });
+    });
+
+    it("should warn unregonized command", function () {
+        executeScript(appFolder + "cordova/target bleh");
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+            expect(_stdout).toEqual("Unrecognized command");
+            expect(_stderr).toEqual("");
+        });
+    });
+
+    it("should warn invalid ip", function () {
+        executeScript(appFolder + "cordova/target add z10 256.254.0.1");
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+            expect(_stdout).toEqual("Invalid IP: 256.254.0.1");
+            expect(_stderr).toEqual("");
+        });
+    });
+
+    it("should warn invalid type", function () {
+        executeScript(appFolder + "cordova/target add z10 169.254.0.1 bleh");
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+            expect(_stdout).toEqual("Invalid target type: bleh");
+            expect(_stderr).toEqual("");
+        });
+    });
+
+    it("should warn invalid pin", function () {
+        executeScript(appFolder + "cordova/target add z10 169.254.0.1 device --pin NOTAPIN!");
+        waitsFor(function () {
+            return flag;
+        });
+        runs(function () {
+            flag = false;
+            expect(_stdout).toEqual("Invalid PIN: NOTAPIN!");
+            expect(_stderr).toEqual("");
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6831bed4/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/config-bare-minimum.xml
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/config-bare-minimum.xml b/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/config-bare-minimum.xml
new file mode 100644
index 0000000..90572f4
--- /dev/null
+++ b/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/config-bare-minimum.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<widget xmlns=" http://www.w3.org/ns/widgets"
+        xmlns:rim="http://www.blackberry.com/ns/widgets"
+        version="1.0.0"
+        id="myID">
+    <name>Demo</name>
+    <content src="local:///startPage.html"/>
+    <author>Research In Motion Ltd.</author>
+    <license href="http://www.apache.org/licenses/LICENSE-2.0">
+        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.
+    </license>
+</widget>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6831bed4/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/config-license.xml
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/config-license.xml b/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/config-license.xml
new file mode 100644
index 0000000..ac4ffe9
--- /dev/null
+++ b/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/config-license.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<widget xmlns=" http://www.w3.org/ns/widgets"
+        xmlns:rim="http://www.blackberry.com/ns/widgets"
+        version="1.0.0"
+        id="myID">
+    <name>Demo</name>
+    <content src="local:///startPage.html"/>
+    <author>Research In Motion Ltd.</author>
+    <license href="http://www.apache.org/licenses/LICENSE-2.0"></license>
+</widget>

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6831bed4/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/config.xml
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/config.xml b/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/config.xml
new file mode 100644
index 0000000..8650a90
--- /dev/null
+++ b/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/config.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<widget xmlns=" http://www.w3.org/ns/widgets"
+        xmlns:rim="http://www.blackberry.com/ns/widgets"
+        version="1.0.0"
+        id="My WidgetId"
+        rim:header="RIM-Widget:rim/widget"
+        rim:userAgent="A Test-User-Agent/(Blackberry-Agent)">
+    <name>Demo</name>
+    <content src="local:///startPage.html"/>
+    <author rim:copyright="No Copyright"
+            href="http://www.rim.com/"
+            email = "author@rim.com">Research In Motion Ltd.</author>
+    <description>This app does everything.</description>
+    <license href="http://www.apache.org/licenses/LICENSE-2.0">My License</license>
+    <icon src="test.png" />
+    <rim:permissions>
+        <rim:permit>access_shared</rim:permit>
+        <rim:permit>read_geolocation</rim:permit>
+        <rim:permit>use_camera</rim:permit>
+    </rim:permissions>
+    <feature id="blackberry.app.orientation">
+        <param name="mode" value="portrait" />
+        <param name="other" value="portrait" />
+      </feature>
+    <feature id="blackberry.app" required="true" version="1.0.0.0">
+        <param name="childBrowser" value="disable" />
+        <param name="websecurity" value="disable" />
+        <param name="popupBlocker" value="enable" />
+    </feature>
+    <feature id="blackberry.system" required="true" version="1.0.0.3"/>
+    <access uri="http://www.somedomain1.com" subdomains="true">
+        <feature id="blackberry.app" required="true" version="1.0.0.0"/>
+        <feature id="blackberry.app.event" required="false" version="2.0.0.0"/>
+    </access>
+    <rim:invoke-target id="com.domain.subdomain.appname.app1">
+	<type>APPLICATION</type>
+        <require-source-permissions>invoke_accross_perimeters,access_shared</require-source-permissions>
+        <filter>
+            <action>bb.action.OPEN</action>
+            <action>bb.action.SET</action>
+            <action>bb.action.VIEW</action>
+            <mime-type>image/*</mime-type>
+            <mime-type>text/*</mime-type>
+            <property var="uris" value="ftp://" />
+            <property var="uris" value="http://" />
+            <property var="uris" value="https://" />
+            <property var="exts" value="jpg" />
+            <property var="exts" value="png" />
+            <property var="exts" value="txt" />
+            <property var="exts" value="doc" />
+        </filter>
+    </rim:invoke-target>
+</widget>

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6831bed4/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/data/ascii_text.txt
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/data/ascii_text.txt b/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/data/ascii_text.txt
new file mode 100644
index 0000000..5e1c309
--- /dev/null
+++ b/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/data/ascii_text.txt
@@ -0,0 +1 @@
+Hello World
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6831bed4/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/data/ucs2be_text.txt
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/data/ucs2be_text.txt b/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/data/ucs2be_text.txt
new file mode 100644
index 0000000..f999e5f
Binary files /dev/null and b/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/data/ucs2be_text.txt differ

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6831bed4/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/data/ucs2le_text.txt
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/data/ucs2le_text.txt b/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/data/ucs2le_text.txt
new file mode 100644
index 0000000..088fa80
Binary files /dev/null and b/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/data/ucs2le_text.txt differ

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6831bed4/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/data/utf8_text.txt
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/data/utf8_text.txt b/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/data/utf8_text.txt
new file mode 100644
index 0000000..05eac02
--- /dev/null
+++ b/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/data/utf8_text.txt
@@ -0,0 +1 @@
+Hello World
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6831bed4/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/params-bad.json
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/params-bad.json b/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/params-bad.json
new file mode 100644
index 0000000..16c75eb
--- /dev/null
+++ b/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/params-bad.json
@@ -0,0 +1,10 @@
+{
+EVIL!
+	"blackberry-signer": {
+		"-proxyhost": "abc.com",
+		"-proxyport": "80"
+	},
+	"blackberry-nativepackager": {
+
+	}
+}

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6831bed4/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/params.json
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/params.json b/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/params.json
new file mode 100644
index 0000000..6a3506f
--- /dev/null
+++ b/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/params.json
@@ -0,0 +1,9 @@
+{
+	"blackberry-signer": {
+		"-proxyhost": "abc.com",
+		"-proxyport": "80"
+	},
+	"blackberry-nativepackager": {
+
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6831bed4/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/spec/lib/bar-builder.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/spec/lib/bar-builder.js b/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/spec/lib/bar-builder.js
new file mode 100644
index 0000000..7c99d2c
--- /dev/null
+++ b/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/spec/lib/bar-builder.js
@@ -0,0 +1,40 @@
+var srcPath = __dirname + "/../../../../../templates/project/cordova/lib/",
+    path = require("path"),
+    wrench = require("wrench"),
+    barBuilder = require(srcPath + "bar-builder"),
+    fileMgr = require(srcPath + "file-manager"),
+    nativePkgr = require(srcPath + "native-packager"),
+    logger = require(srcPath + "logger"),
+    testData = require("./test-data"),
+    extManager = null;
+
+describe("BAR builder", function () {
+    it("build() create BAR for specified session", function () {
+        var callback = jasmine.createSpy(),
+            session = testData.session,
+            config = testData.config,
+            target = session.targets[0];
+
+        spyOn(wrench, "mkdirSyncRecursive");
+        spyOn(fileMgr, "copyWWE");
+        spyOn(fileMgr, "copyWebplatform");
+        spyOn(fileMgr, "copyWebworks");
+        spyOn(fileMgr, "copyJnextDependencies");
+        spyOn(fileMgr, "copyExtensions");
+        spyOn(fileMgr, "generateFrameworkModulesJS");
+        spyOn(nativePkgr, "exec").andCallFake(function (session, target, config, callback) {
+            callback(0);
+        });
+
+        barBuilder.build(session, testData.config, callback);
+
+        expect(wrench.mkdirSyncRecursive).toHaveBeenCalledWith(session.outputDir + "/" + target);
+        expect(fileMgr.copyWWE).toHaveBeenCalledWith(session, target);
+        expect(fileMgr.copyWebplatform).toHaveBeenCalledWith(session, target);
+        expect(fileMgr.copyJnextDependencies).toHaveBeenCalledWith(session);
+        expect(fileMgr.copyExtensions).toHaveBeenCalledWith(session, target);
+        expect(fileMgr.generateFrameworkModulesJS).toHaveBeenCalledWith(session);
+        expect(nativePkgr.exec).toHaveBeenCalledWith(session, target, config, jasmine.any(Function));
+        expect(callback).toHaveBeenCalledWith(0);
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6831bed4/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/spec/lib/bbwpignore.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/spec/lib/bbwpignore.js b/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/spec/lib/bbwpignore.js
new file mode 100644
index 0000000..7c68ee9
--- /dev/null
+++ b/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/spec/lib/bbwpignore.js
@@ -0,0 +1,135 @@
+/*
+ *  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/",
+    BBWPignore = require(srcPath + "bbwpignore"),
+    fs = require('fs');
+
+describe("bbwpignore can match", function () {
+    it("a basic file set", function () {
+        var bbwpignore;
+        spyOn(fs, "readFileSync").andReturn("abc.js\n" +
+                                           "x/y/def.js");
+        bbwpignore = new BBWPignore("FileNameIgnoreForTests",
+                                    ["d/e/abc.js", "abc.js", "ted.js", ".DS_Store",
+                                        "x/y/def.js", "x/def.js", "a/b/x/y/def.js"]);
+        expect(bbwpignore.matchedFiles.length).toBe(4);
+        expect(bbwpignore.matchedFiles.indexOf("d/e/abc.js")).not.toBe(-1);
+        expect(bbwpignore.matchedFiles.indexOf("abc.js")).not.toBe(-1);
+        expect(bbwpignore.matchedFiles.indexOf("x/y/def.js")).not.toBe(-1);
+        expect(bbwpignore.matchedFiles.indexOf("a/b/x/y/def.js")).not.toBe(-1);
+    });
+
+    it("a basic file set with directories", function () {
+        var bbwpignore;
+        spyOn(fs, "readFileSync").andReturn("abc.js\n" +
+                                           "x/y/");
+        bbwpignore = new BBWPignore("FileNameIgnoreForTests",
+                                    ["d/e/abc.js", "abc.js", "ted.js", ".DS_Store",
+                                        "x/y/def.js", "x/def.js", "a/b/x/y/def.js"]);
+
+        expect(bbwpignore.matchedFiles.length).toBe(4);
+        expect(bbwpignore.matchedFiles.indexOf("d/e/abc.js")).not.toBe(-1);
+        expect(bbwpignore.matchedFiles.indexOf("abc.js")).not.toBe(-1);
+        expect(bbwpignore.matchedFiles.indexOf("x/y/def.js")).not.toBe(-1);
+        expect(bbwpignore.matchedFiles.indexOf("a/b/x/y/def.js")).not.toBe(-1);
+    });
+
+    it("a basic file set with directories that being with slash", function () {
+        var bbwpignore;
+        spyOn(fs, "readFileSync").andReturn("abc.js\n" +
+                                           "/x/y/");
+        bbwpignore = new BBWPignore("FileNameIgnoreForTests",
+                                    ["d/e/abc.js", "abc.js", "ted.js", ".DS_Store",
+                                        "x/y/def.js", "x/def.js", "a/b/x/y/def.js"]);
+        expect(bbwpignore.matchedFiles.length).toBe(4);
+        expect(bbwpignore.matchedFiles.indexOf("d/e/abc.js")).not.toBe(-1);
+        expect(bbwpignore.matchedFiles.indexOf("abc.js")).not.toBe(-1);
+        expect(bbwpignore.matchedFiles.indexOf("/x/y")).not.toBe(-1);
+        expect(bbwpignore.matchedFiles.indexOf("x/y/def.js")).not.toBe(-1);
+
+    });
+
+    it("a basic file set that begin with a slash on the directory", function () {
+        var bbwpignore;
+        spyOn(fs, "readFileSync").andReturn("abc.js\n" +
+                                           "/x/y/def.js");
+        bbwpignore = new BBWPignore("FileNameIgnoreForTests",
+                                    ["d/e/abc.js", "abc.js", "ted.js", ".DS_Store",
+                                        "x/y/def.js", "x/def.js", "a/b/x/y/def.js"]);
+
+        expect(bbwpignore.matchedFiles.length).toBe(3);
+        expect(bbwpignore.matchedFiles.indexOf("d/e/abc.js")).not.toBe(-1);
+        expect(bbwpignore.matchedFiles.indexOf("abc.js")).not.toBe(-1);
+        expect(bbwpignore.matchedFiles.indexOf("x/y/def.js")).not.toBe(-1);
+
+    });
+
+    it("a basic file set that begin with a slash", function () {
+        var bbwpignore;
+        spyOn(fs, "readFileSync").andReturn("abc.js\n" +
+                                           "/def.js");
+        bbwpignore = new BBWPignore("FileNameIgnoreForTests",
+                                    ["d/e/abc.js", "abc.js", "ted.js", ".DS_Store",
+                                        "x/y/def.js", "x/def.js", "a/b/x/y/def.js"]);
+
+        expect(bbwpignore.matchedFiles.length).toBe(2);
+        expect(bbwpignore.matchedFiles.indexOf("d/e/abc.js")).not.toBe(-1);
+        expect(bbwpignore.matchedFiles.indexOf("abc.js")).not.toBe(-1);
+
+    });
+
+    it("a basic file set that begin with a slash and has a wildcard", function () {
+        var bbwpignore;
+        spyOn(fs, "readFileSync").andReturn("abcd.js\n" +
+                                           "/*.js");
+        bbwpignore = new BBWPignore("FileNameIgnoreForTests",
+                                    ["d/e/abc.js", "abc.js", "ted.js", ".DS_Store",
+                                        "x/y/def.js", "x/def.js", "a/b/x/y/def.js"]);
+
+        expect(bbwpignore.matchedFiles.length).toBe(2);
+        expect(bbwpignore.matchedFiles.indexOf("abc.js")).not.toBe(-1);
+        expect(bbwpignore.matchedFiles.indexOf("ted.js")).not.toBe(-1);
+
+    });
+
+    it("a basic file set that begin with a slash and has a wildcard", function () {
+        var bbwpignore;
+        spyOn(fs, "readFileSync").andReturn("abcd.js\n" +
+                                           "a*.js");
+        bbwpignore = new BBWPignore("FileNameIgnoreForTests",
+                                    ["d/e/abc.js", "abc.js", "ted.js", ".DS_Store",
+                                        "x/y/def.js", "x/def.js", "a/b/x/y/def.js"]);
+
+        expect(bbwpignore.matchedFiles.length).toBe(2);
+        expect(bbwpignore.matchedFiles.indexOf("d/e/abc.js")).not.toBe(-1);
+        expect(bbwpignore.matchedFiles.indexOf("abc.js")).not.toBe(-1);
+
+    });
+
+    it("a basic directory set that begin with a slash", function () {
+        var bbwpignore;
+        spyOn(fs, "readFileSync").andReturn("/simulator/\n" +
+                                           "banana.js");
+        bbwpignore = new BBWPignore("FileNameIgnoreForTests",
+                                    ["simulator/a.js"]);
+
+        expect(bbwpignore.matchedFiles.length).toBe(2);
+        expect(bbwpignore.matchedFiles.indexOf("/simulator")).not.toBe(-1);
+        expect(bbwpignore.matchedFiles.indexOf("simulator/a.js")).not.toBe(-1);
+
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6831bed4/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/spec/lib/cmdline.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/spec/lib/cmdline.js b/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/spec/lib/cmdline.js
new file mode 100644
index 0000000..03eda58
--- /dev/null
+++ b/lib/cordova-blackberry/blackberry10/bin/test/cordova/unit/spec/lib/cmdline.js
@@ -0,0 +1,77 @@
+var srcPath = __dirname + "/../../../../../templates/project/cordova/lib/",
+    localize = require(srcPath + "localize"),
+    cmdline = require(srcPath + "cmdline"),
+    cmd;
+
+describe("Command line", function () {
+    beforeEach(function () {
+        cmd = cmdline
+                .parse(process.argv)
+                .commander;
+    });
+
+    it("accepts -o with argument", function () {
+        cmd.parseOptions(["-o", "outdir"]);
+        expect(cmd.output).toEqual("outdir");
+    });
+
+    it("arg following -o is required", function () {
+        spyOn(process, "exit");
+        spyOn(console, "error");
+        cmd.parseOptions(["-o"]);
+        expect(console.error).toHaveBeenCalled();
+        expect(process.exit).toHaveBeenCalled();
+    });
+
+    it("accepts -s without argument", function () {
+        cmd.parseOptions(["-s"]);
+        expect(cmd.source).toBeTruthy();
+    });
+
+    it("accepts -s with argument", function () {
+        cmd.parseOptions(["-s", "mySourceDir"]);
+        expect(cmd.source).toEqual("mySourceDir");
+    });
+
+    it("accepts -d", function () {
+        cmd.parseOptions(["-d"]);
+        expect(cmd.debug).toBeTruthy();
+    });
+
+    it("accepts --loglevel with argument", function () {
+        cmd.parseOptions(["--loglevel", "warn"]);
+        expect(cmd.loglevel).toBe("warn");
+    });
+
+    it("accepts -ll", function () {
+        cmd.parseOptions(["-ll", "error"]);
+        expect(cmd.loglevel).toBe("error");
+    });
+
+    it("accepts -g with argument", function () {
+        cmd.parseOptions(["-g", "myPassword"]);
+        expect(cmd.password).toEqual("myPassword");
+    });
+
+    it("accepts --buildId with argument", function () {
+        cmd.parseOptions(["--buildId", "100"]);
+        expect(cmd.buildId).toEqual("100");
+    });
+
+    it("accepts -buildId with argument", function () {
+        cmd.parseOptions(["-buildId", "100"]);
+        expect(cmd.buildId).toEqual("100");
+    });
+
+    it("accepts --appdesc with argument", function () {
+        cmd.parseOptions(["--appdesc", "bardescriptor"]);
+        expect(cmd.appdesc).toEqual("bardescriptor");
+    });
+
+    it("throws an error for invalid multi-word arguments", function () {
+        expect(function () {
+            require(srcPath + "cmdline").parse(["--src"]);
+        }).toThrow(localize.translate("EXCEPTION_CMDLINE_ARG_INVALID", "--src"));
+    });
+
+});