Updated Branches:
  refs/heads/master 82c2664c4 -> 3218fc2d0

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry10/test.camera.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.camera.js b/test/blackberry10/test.camera.js
new file mode 100644
index 0000000..e08809f
--- /dev/null
+++ b/test/blackberry10/test.camera.js
@@ -0,0 +1,59 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+describe("blackberry10 camera", function () {
+    var camera = require('cordova/plugin/blackberry10/camera'),
+        cordova = require('cordova');
+
+    beforeEach(function () {
+        global.blackberry = {
+            invoke: {
+                card: {
+                    invokeCamera: jasmine.createSpy("invokeCamera")
+                }
+            }
+        };
+    });
+
+    afterEach(function () {
+        delete global.blackberry;
+    });
+    
+    it("returns no_result when calling takePicture", function () {
+        expect(camera.takePicture()).toEqual({
+            status: cordova.callbackStatus.NO_RESULT,
+            message: "WebWorks Is On It"
+        });
+    });
+
+    it("calls blackberry.invoke.card.invokeCamera", function () {
+        camera.takePicture();
+        
expect(blackberry.invoke.card.invokeCamera).toHaveBeenCalledWith("photo", 
jasmine.any(Function), jasmine.any(Function), jasmine.any(Function));
+    });
+
+    it("adds file:// to the path provided to the callback and calls success", 
function () {
+        var win = jasmine.createSpy("win");
+        camera.takePicture({}, win);
+
+        
blackberry.invoke.card.invokeCamera.mostRecentCall.args[1]("pics/ponies.jpg");
+        expect(win).toHaveBeenCalledWith("file://pics/ponies.jpg");
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry10/test.capture.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.capture.js 
b/test/blackberry10/test.capture.js
new file mode 100644
index 0000000..95b48d4
--- /dev/null
+++ b/test/blackberry10/test.capture.js
@@ -0,0 +1,222 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+describe("blackberry10 capture", function () {
+    var capture = require('cordova/plugin/blackberry10/capture'),
+        cordova = require('cordova');
+
+    describe("getSupportedAudioModes", function(){
+        it('should return Ok', function(){
+            expect(capture.getSupportedAudioModes()).toEqual({
+                status: cordova.callbackStatus.OK,
+                message: []
+            });
+        });
+    });
+
+    describe("getSupportedImageModes", function(){
+        it('should return Ok', function(){
+            expect(capture.getSupportedImageModes()).toEqual({
+                status: cordova.callbackStatus.OK,
+                message: []
+            });
+        });
+    });
+
+    describe("getSupportedVideoModes", function(){
+        it('should return Ok', function(){
+            expect(capture.getSupportedVideoModes()).toEqual({
+                status: cordova.callbackStatus.OK,
+                message: []
+            });
+        });
+    });
+
+    function testCapture(method, action) {
+        describe(method, function(){
+            beforeEach(function () {
+                global.blackberry = {
+                    invoke: {
+                        card: {
+                            invokeCamera: 
jasmine.createSpy('blackberry.invoke.card.invokeCamera')
+                        }
+                    }
+                };
+            });
+
+            afterEach(function () {
+                delete global.blackberry;
+            });
+
+            it('should return No Result', function(){
+                var args = [{limit: 0}],
+                    win = jasmine.createSpy('win'),
+                    fail = jasmine.createSpy('fail');
+
+                expect(capture[method](args, win, fail)).toEqual({
+                    status: cordova.callbackStatus.NO_RESULT,
+                    message: "WebWorks Is On It"
+                });
+            });
+
+            describe("when the limit is 0 or less", function () {
+                it('calls the win callback with an empty array', function(){
+                    var args = [{ limit: -9 }],
+                        win = jasmine.createSpy('win'),
+                        fail = jasmine.createSpy('fail');
+
+                    capture[method](args, win, fail);
+                    expect(win).toHaveBeenCalled();
+                });
+            });
+
+            describe("when the limit is greater than 0", function () {
+                var win, fail;
+
+                beforeEach(function () {
+                    win = jasmine.createSpy("win");
+                    fail = jasmine.createSpy("fail");
+                });
+
+                it("calls the invokeCamera method", function () {
+                    capture[method]([{limit: 1}], win, fail);
+                    
expect(blackberry.invoke.card.invokeCamera).toHaveBeenCalledWith(action, 
+                                                                               
      jasmine.any(Function),
+                                                                               
      jasmine.any(Function),
+                                                                               
      jasmine.any(Function));
+                });
+
+                describe("inside the invokeCamera callback", function () {
+                    var onsave;
+
+                    beforeEach(function () {
+                        window.webkitRequestFileSystem = 
jasmine.createSpy("window.webkitRequestFileSystem");
+                        global.blackberry.io = { sandbox: true };
+
+                        capture[method]([{limit: 1}], win, fail);
+                        onsave = 
blackberry.invoke.card.invokeCamera.mostRecentCall.args[1];
+                    });
+
+                    afterEach(function () {
+                        delete window.webkitRequestFileSystem;
+                    });
+
+                    it("sets the sandbox to false", function () {
+                        onsave();
+                        expect(blackberry.io.sandbox).toBe(false);
+                    });
+
+                    it("calls webkitRequestFileSystem", function () {
+                        onsave();
+                        
expect(window.webkitRequestFileSystem).toHaveBeenCalledWith(
+                            window.PERSISTENT, 
+                            1024, 
+                            jasmine.any(Function), 
+                            fail);
+                    });
+
+                    describe("in the webkitRequestFileSystem callback", 
function () {
+                        var callback,
+                            fs = { root: { getFile: 
jasmine.createSpy("getFile") } };
+
+                        beforeEach(function () {
+                            onsave('/foo/bar/baz.gif');
+                            callback = 
window.webkitRequestFileSystem.mostRecentCall.args[2];
+                        });
+
+                        it("calls getfile on the provided filesystem", 
function () {
+                            callback(fs);
+                            
expect(fs.root.getFile).toHaveBeenCalledWith('/foo/bar/baz.gif', 
+                                                                         {},
+                                                                         
jasmine.any(Function), 
+                                                                         fail);
+                        });
+
+                        it("calls the file method of the fileEntity", function 
() {
+                            var fe = { file: jasmine.createSpy('file') };
+                            callback(fs);
+                            fs.root.getFile.mostRecentCall.args[2](fe);
+                            
expect(fe.file).toHaveBeenCalledWith(jasmine.any(Function), fail);
+                        });
+
+                        describe("in the file callback", function () {
+                            var fe = { 
+                                    file: jasmine.createSpy('file'),
+                                    fullPath: 
'file://this/is/the/full/path/eh.png'
+                                },
+                                fileCB;
+
+                            beforeEach(function () {
+                                callback(fs);
+                                fs.root.getFile.mostRecentCall.args[2](fe);
+                                fileCB = fe.file.mostRecentCall.args[0];
+                            });
+
+                            it("sets the fullPath of the file object", 
function () {
+                                var file = {};
+                                fileCB(file);
+                                expect(file.fullPath).toBe(fe.fullPath);
+                            });
+
+                            it("calls the win callback with an array 
containing the file", function () {
+                                var file = {};
+                                fileCB(file);
+                                expect(win).toHaveBeenCalledWith([file]);
+                            });
+
+                            it("resets the value of blackberry.io.sandbox", 
function () {
+                                var file = {};
+                                fileCB(file);
+                                expect(blackberry.io.sandbox).toBe(true);
+                            });
+                        });
+                    });
+                });
+            });
+        });
+    }
+
+    testCapture('captureImage', 'photo');
+    testCapture('captureVideo', 'video');
+
+    describe("captureAudio", function(){
+        it('should call the fail callback', function(){
+            var args = {},
+                win = jasmine.createSpy('win'),
+                fail = jasmine.createSpy('fail');
+
+            capture.captureAudio(args, win, fail);
+            expect(fail).toHaveBeenCalled();
+            expect(win).not.toHaveBeenCalled();
+        });
+
+        it('should return no result', function(){
+            var args = "arguments",
+                win = jasmine.createSpy('win'),
+                fail = jasmine.createSpy('fail');
+
+            expect(capture.captureAudio(args, win, fail)).toEqual({
+                status: cordova.callbackStatus.NO_RESULT,
+                message: "WebWorks Is On It"
+            });
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry10/test.compass.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.compass.js 
b/test/blackberry10/test.compass.js
new file mode 100644
index 0000000..19b231b
--- /dev/null
+++ b/test/blackberry10/test.compass.js
@@ -0,0 +1,61 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+xdescribe("blackberry10 compass", function () {
+    var compass = require('cordova/plugin/blackberry10/compass'),
+        cordova = require('cordova'),
+        exec = require('cordova/exec'),
+        utils = require('cordova/utils'),
+        CompassHeading = require('cordova/plugin/CompassHeading'),
+        CompassError = require('cordova/plugin/CompassError'),
+        win = jasmine.createSpy('win'),
+        fail = jasmine.createSpy('fail');
+
+    beforeEach(function () {
+        window.start = jasmine.createSpy('start');
+        window.stop = jasmine.createSpy('stop');
+        window.removeListeners = jasmine.createSpy('removeListeners');
+        global.listeners = [];
+
+    });
+
+    afterEach(function () {
+
+    });
+
+
+    describe("watchHeading", function(){
+        it('should return that successCallback is not a function', function(){
+            expect(compass.getCurrentHeading).toThrow("getCurrentHeading must 
be called with at least a success callback function as first parameter.");
+        });
+
+        it('should see that start() was called', function(){
+            compass.getCurrentHeading(win, fail);
+            expect(listeners).toHaveBeenCalled();
+        });
+
+    });
+
+    describe("clearWatch", function(){
+
+
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry10/test.device.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.device.js b/test/blackberry10/test.device.js
new file mode 100644
index 0000000..66f3813
--- /dev/null
+++ b/test/blackberry10/test.device.js
@@ -0,0 +1,48 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+describe("blackberry10 device", function () {
+    var device = require('cordova/plugin/blackberry10/device');
+    
+    it("calls the win callback with the device info", function () {
+        global.blackberry = {
+            system: {
+                softwareVersion: "NaN"
+            },
+            identity: {
+                uuid: 1
+            }
+        };
+
+        var info;
+
+        //HACK: I know this is a sync call ;)
+        device.getDeviceInfo({}, function (i) { info = i; });
+
+        expect(info.platform).toBe("BlackBerry");
+        expect(info.version).toBe("NaN");
+        expect(info.name).toBe("Dev Alpha");
+        expect(info.uuid).toBe(1);
+        expect(info.cordova).toBeDefined();
+        
+        delete global.blackberry;
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry10/test.fileTransfer.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.fileTransfer.js 
b/test/blackberry10/test.fileTransfer.js
new file mode 100644
index 0000000..1d7ed57
--- /dev/null
+++ b/test/blackberry10/test.fileTransfer.js
@@ -0,0 +1,85 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+describe("blackberry10 fileTransfer", function () {
+    var fileTransfer = require('cordova/plugin/blackberry10/fileTransfer'),
+        cordova = require('cordova'),
+        win = jasmine.createSpy('win'),
+        fail = jasmine.createSpy('fail')
+        xhrSend = jasmine.createSpy('xhr send');
+        xhrOpen = jasmine.createSpy('xhr open');
+
+    beforeEach(function () {
+        global.blackberry = {
+            io:{
+                filetransfer: {
+                    download: jasmine.createSpy('download'),
+                    upload: jasmine.createSpy('upload')
+                }
+            }
+        };
+        XMLHttpRequest = function () {
+            var xhr = {
+                send: xhrSend,
+                open: xhrOpen
+            };
+            return xhr;
+        };
+        window.webkitResolveLocalFileSystemURL = jasmine.createSpy("resolveFS")
+    });
+
+    afterEach(function () {
+        delete global.blackberry;
+        delete XMLHttpRequest;
+        delete webkitResolveLocalFileSystemURL;
+        delete window.webkitResolveLocalFileSystemURL;
+    });
+
+    describe("download", function(){
+        it('should call the blackberry download', function () {
+            fileTransfer.download(["source/file", "target/file"], win, fail);
+            expect(xhrOpen).toHaveBeenCalled();
+            expect(xhrSend).toHaveBeenCalled();
+        });
+
+        it('should return No Result', function(){
+            expect(fileTransfer.download(["location/source", 
"location/place/here"], win, fail)).toEqual({
+                status: cordova.callbackStatus.NO_RESULT,
+                message: "async"
+            });
+        });
+    });
+
+    describe('upload', function(){
+        it('should call the blackberry upload', function(){
+            fileTransfer.upload(["source", "target", "fileKey", "fileName", 
"mimeType", "params", "chunkedMode"], win, fail);
+            expect(xhrOpen).toHaveBeenCalled();
+            expect(xhrSend).toHaveBeenCalled();
+        });
+
+        it('should return No Result', function(){
+            expect(fileTransfer.upload(["location/source", 
"location/place/here"], win, fail)).toEqual({
+                status: cordova.callbackStatus.NO_RESULT,
+                message: "async"
+            });
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry10/test.magnetometer.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.magnetometer.js 
b/test/blackberry10/test.magnetometer.js
new file mode 100644
index 0000000..f9ad9b3
--- /dev/null
+++ b/test/blackberry10/test.magnetometer.js
@@ -0,0 +1,80 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+describe("blackberry10 magnetometer", function () {
+    var magnetometer = require('cordova/plugin/blackberry10/magnetometer'),
+        cordova = require('cordova');
+
+    beforeEach(function () {
+        spyOn(window, "removeEventListener");
+        spyOn(window, "addEventListener");
+    });
+
+    describe("start", function(){
+        it('should return no result', function(){
+            expect(magnetometer.start()).toEqual({
+                status: cordova.callbackStatus.NO_RESULT,
+                message: "WebWorks Is On It"
+            });
+        });
+
+        it('should remove the event listener', function(){
+            magnetometer.start();
+            
expect(window.removeEventListener).toHaveBeenCalledWith("deviceorientation", 
jasmine.any(Function));
+        });
+
+        it('should add an event listener', function(){
+            magnetometer.start();
+            
expect(window.addEventListener).toHaveBeenCalledWith("deviceorientation", 
jasmine.any(Function));
+        });
+
+        it('call the win callback with the data from the event', function(){
+            var win = jasmine.createSpy('win');
+            magnetometer.start({}, win);
+
+            window.addEventListener.mostRecentCall.args[1]({
+                alpha: 60,
+                timeStamp: "bout that time, eh chap?"
+            });
+
+            expect(win).toHaveBeenCalledWith({
+                magneticHeading: 300,
+                trueHeading: 300,
+                headingAccuracy: 0,
+                timestamp: "bout that time, eh chap?"
+            });
+        });
+    });
+
+    describe('stop', function(){
+        it('should return OK', function(){
+            expect(magnetometer.stop()).toEqual({
+                status: cordova.callbackStatus.OK,
+                message: "removed"
+            });
+        });
+
+        it('should remove the event listener', function(){
+            magnetometer.stop();
+            
expect(window.removeEventListener).toHaveBeenCalledWith("deviceorientation", 
jasmine.any(Function));
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry10/test.manager.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.manager.js 
b/test/blackberry10/test.manager.js
new file mode 100644
index 0000000..5899fd3
--- /dev/null
+++ b/test/blackberry10/test.manager.js
@@ -0,0 +1,56 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+describe("blackberry10 manager", function () {
+    var manager = require('cordova/plugin/blackberry10/manager');
+
+    it("calls the plugin", function () {
+        var device = require('cordova/plugin/blackberry10/device'),
+            win = jasmine.createSpy('win'),
+            fail = jasmine.createSpy('fail'),
+            args = {};
+
+        spyOn(device, "getDeviceInfo");
+
+        manager.exec(win, fail, "Device", "getDeviceInfo", args);
+        expect(device.getDeviceInfo).toHaveBeenCalledWith(args, win, fail);
+    });
+
+    it("returns the result of the plugin", function () {
+        var camera = require('cordova/plugin/blackberry10/camera');
+        spyOn(camera, "takePicture").andReturn("duckface");
+        expect(manager.exec(null, null, "Camera", 
"takePicture")).toBe("duckface");
+    });
+
+    it("returns class not found when no plugin", function () {
+        expect(manager.exec(null, null, "Ruby", "method_missing")).toEqual({
+           status: cordova.callbackStatus.CLASS_NOT_FOUND_EXCEPTION,
+           message: "Class Ruby cannot be found"
+        });
+    });
+
+    it("returns invalid action when no action", function () {
+        expect(manager.exec(null, null, "Camera", "makePonies")).toEqual({
+            status: cordova.callbackStatus.INVALID_ACTION,
+            message: "Action not found: makePonies"
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry10/test.network.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.network.js 
b/test/blackberry10/test.network.js
new file mode 100644
index 0000000..5917269
--- /dev/null
+++ b/test/blackberry10/test.network.js
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+describe("blackberry10 network", function () {
+    var cordova = require('cordova'),
+        network = require('cordova/plugin/blackberry10/network');
+
+    it("returns the connection info", function () {
+        global.blackberry = {
+            connection: {
+                type: "pigeon"
+            }
+        };
+        expect(network.getConnectionInfo()).toEqual({
+            status: cordova.callbackStatus.OK,
+            message: "pigeon"
+        });
+
+        delete global.blackberry;
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry10/test.platform.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.platform.js 
b/test/blackberry10/test.platform.js
new file mode 100644
index 0000000..98789a1
--- /dev/null
+++ b/test/blackberry10/test.platform.js
@@ -0,0 +1,117 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+describe("blackberry10 platform", function () {
+    var platform = require('cordova/plugin/blackberry10/platform'),
+        cordova = require('cordova');
+
+    beforeEach(function () {
+
+        global.blackberry = {
+            event:{
+                addEventListener: jasmine.createSpy('addEventListener')
+            }
+        }
+
+        spyOn(cordova, "fireDocumentEvent");
+
+        spyOn(document, "addEventListener").andCallFake(function(){
+            blackberry.event.addEventListener("pause", function(){
+                cordova.fireDocumentEvent("pause")
+            });
+            blackberry.event.addEventListener("resume", function(){
+                cordova.fireDocumentEvent("resume")
+            });
+
+            window.addEventListener("online", function(){
+                cordova.fireDocumentEvent("online");
+            });
+            window.addEventListener("offline", function(){
+                cordova.fireDocumentEvent("offline");
+            });
+        });
+        
+        spyOn(window, "addEventListener").andCallFake(function(){
+            cordova.fireDocumentEvent("online");
+            cordova.fireDocumentEvent("offline");
+        });
+    });
+
+    afterEach(function(){
+        delete global.blackberry;
+    });
+
+    describe("initialize", function(){
+        it('should add an event listener to document', function(){
+            platform.initialize();
+            
expect(document.addEventListener).toHaveBeenCalledWith("deviceready", 
jasmine.any(Function));
+        });
+        it('should check if blackberry event addEventListener was called for 
pause', function(){
+            platform.initialize();
+            
expect(blackberry.event.addEventListener).toHaveBeenCalledWith("pause", 
jasmine.any(Function));
+        });
+        it('should check if blackberry event addEventListener was called for 
resume', function(){
+            platform.initialize();     
+            
expect(blackberry.event.addEventListener).toHaveBeenCalledWith("resume", 
jasmine.any(Function));
+        });
+        it('should check if window.addEventListener was called for online', 
function(){
+            platform.initialize();
+            expect(window.addEventListener).toHaveBeenCalledWith("online", 
jasmine.any(Function));
+            
+        });
+        it('should check if window.addEventListener was called for offline', 
function(){
+            platform.initialize();
+            expect(window.addEventListener).toHaveBeenCalledWith("offline", 
jasmine.any(Function));
+        });
+
+        it('should call cordova.fireDocumentEvent online', function(){
+            platform.initialize();
+            expect(cordova.fireDocumentEvent).toHaveBeenCalledWith("online");
+        });
+        it('should call cordova.fireDocumentEvent offline', function(){
+            platform.initialize();
+            expect(cordova.fireDocumentEvent).toHaveBeenCalledWith("offline");
+        });
+        it('should call cordova.fireDocumentEvent pause', function(){
+            delete global.blackberry;
+            global.blackberry = { event: { addEventListener: function(){ } } };
+            spyOn(blackberry.event, "addEventListener").andCallFake(function(){
+                cordova.fireDocumentEvent("pause");
+            });
+
+            platform.initialize();
+            
+            expect(cordova.fireDocumentEvent).toHaveBeenCalledWith("pause");
+        });
+        it('should call cordova.fireDocumentEvent resume', function(){
+            delete global.blackberry;
+            global.blackberry = { event: { addEventListener: function(){ } } };
+            spyOn(blackberry.event, "addEventListener").andCallFake(function(){
+                cordova.fireDocumentEvent("resume");
+            });
+
+            platform.initialize();
+            
+            expect(cordova.fireDocumentEvent).toHaveBeenCalledWith("resume");
+        });
+
+    });
+});

Reply via email to