You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by gt...@apache.org on 2012/11/28 22:35:04 UTC

[1/2] js commit: qnx tests

Updated Branches:
  refs/heads/master c46b14085 -> fdfefbf24


qnx tests


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/53110dc9
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/53110dc9
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/53110dc9

Branch: refs/heads/master
Commit: 53110dc9078560adbb285f50f5efafa4a51d9847
Parents: c46b140
Author: Matt Lantz <ma...@rim.com>
Authored: Fri Nov 23 14:09:02 2012 -0500
Committer: Gord Tanner <gt...@gmail.com>
Committed: Wed Nov 28 16:34:05 2012 -0500

----------------------------------------------------------------------
 lib/blackberry/plugin/qnx/magnetometer.js          |    2 +-
 test/blackberry/qnx/test.capture.js                |  140 +++++++++++++++
 test/blackberry/qnx/test.compass.js                |   61 +++++++
 test/blackberry/qnx/test.fileTransfer.js           |   75 ++++++++
 test/blackberry/qnx/test.magnetometer.js           |   82 +++++++++
 test/blackberry/qnx/test.platform.js               |  140 +++++++++++++++
 test/blackberry/qnx/test.requestFileSystem.js      |   32 ++++
 .../qnx/test.resolveLocalFileSystemURI.js          |   32 ++++
 8 files changed, 563 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/53110dc9/lib/blackberry/plugin/qnx/magnetometer.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/magnetometer.js b/lib/blackberry/plugin/qnx/magnetometer.js
index f636ac0..72aa90e 100644
--- a/lib/blackberry/plugin/qnx/magnetometer.js
+++ b/lib/blackberry/plugin/qnx/magnetometer.js
@@ -40,6 +40,6 @@ module.exports = {
     },
     stop: function (args, win, fail) {
         window.removeEventListener("deviceorientation", callback);
-        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" };
+        return { "status" : cordova.callbackStatus.OK, "message" : "removed" };
     }
 };

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/53110dc9/test/blackberry/qnx/test.capture.js
----------------------------------------------------------------------
diff --git a/test/blackberry/qnx/test.capture.js b/test/blackberry/qnx/test.capture.js
new file mode 100644
index 0000000..f134434
--- /dev/null
+++ b/test/blackberry/qnx/test.capture.js
@@ -0,0 +1,140 @@
+/*
+ *
+ * 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("blackberry qnx capture", function () {
+    var capture = require('cordova/plugin/qnx/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: []
+            });
+        });
+    });
+
+    describe("captureImage", function(){
+        it('should call the capture function', function(){
+            var args = [{ limit: -9 }, "nothingness"],
+                win = jasmine.createSpy('win'),
+                fail = jasmine.createSpy('fail');
+
+            capture.captureImage(args, win, fail);
+            expect(win).toHaveBeenCalled();
+            
+        });
+
+        it('should call success function', function(){
+            var args = [""],
+                win = jasmine.createSpy('win'),
+                fail = jasmine.createSpy('fail');
+
+            capture.captureImage(args, win, fail);
+            expect(win).toHaveBeenCalledWith([]);
+        });
+
+        it('should return No Result', function(){
+            var args = [""],
+                win = jasmine.createSpy('win'),
+                fail = jasmine.createSpy('fail');
+
+            expect(capture.captureImage(args, win, fail)).toEqual({
+                status: cordova.callbackStatus.NO_RESULT,
+                message: "WebWorks Is On It"
+            });
+        });
+    });
+
+    describe("captureVideo", function(){
+        it('should call the capture function', function(){
+            var args = [{ limit: -9 }, "nothingness"],
+                win = jasmine.createSpy('win'),
+                fail = jasmine.createSpy('fail');
+
+            capture.captureVideo(args, win, fail);
+            expect(win).toHaveBeenCalled();
+        });
+
+        it('should call success function', function(){
+            var args = [""],
+                win = jasmine.createSpy('win'),
+                fail = jasmine.createSpy('fail');
+
+            capture.captureVideo(args, win, fail);
+            expect(win).toHaveBeenCalledWith([]);
+        });
+
+        it('should return No Result', function(){
+            var args = [""],
+                win = jasmine.createSpy('win'),
+                fail = jasmine.createSpy('fail');
+
+            expect(capture.captureVideo(args, win, fail)).toEqual({
+                status: cordova.callbackStatus.NO_RESULT,
+                message: "WebWorks Is On It"
+            });
+        });
+    });
+
+
+    describe("captureAudio", function(){
+        it('should call the audio capture', function(){
+            
+            var args = "arguments",
+                win = jasmine.createSpy('win'),
+                fail = jasmine.createSpy('fail');
+
+            capture.captureAudio(args, win, fail);
+            expect(fail).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/53110dc9/test/blackberry/qnx/test.compass.js
----------------------------------------------------------------------
diff --git a/test/blackberry/qnx/test.compass.js b/test/blackberry/qnx/test.compass.js
new file mode 100644
index 0000000..445b8ff
--- /dev/null
+++ b/test/blackberry/qnx/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.
+ *
+*/
+
+describe("blackberry qnx compass", function () {
+    var compass = require('cordova/plugin/qnx/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/53110dc9/test/blackberry/qnx/test.fileTransfer.js
----------------------------------------------------------------------
diff --git a/test/blackberry/qnx/test.fileTransfer.js b/test/blackberry/qnx/test.fileTransfer.js
new file mode 100644
index 0000000..723e0a8
--- /dev/null
+++ b/test/blackberry/qnx/test.fileTransfer.js
@@ -0,0 +1,75 @@
+/*
+ *
+ * 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("blackberry qnx fileTransfer", function () {
+    var fileTransfer = require('cordova/plugin/qnx/fileTransfer'),
+        cordova = require('cordova'),
+        win = jasmine.createSpy('win'),
+        fail = jasmine.createSpy('fail');
+
+    beforeEach(function () {
+        global.blackberry = {
+            io:{
+                filetransfer: {
+                    download: jasmine.createSpy('download'),
+                    upload: jasmine.createSpy('upload')
+                }
+            }
+        }
+    });
+
+    afterEach(function () {
+        delete global.blackberry;
+    });
+
+    describe("download", function(){
+        it('should call the blackberry download', function(){
+            fileTransfer.download(["source/file", "target/file"], win, fail);
+            expect(blackberry.io.filetransfer.download).toHaveBeenCalledWith("source/file", "target/file", win, fail);
+        });
+
+        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('uplaod', function(){
+        it('should call the blackberry upload', function(){
+            fileTransfer.upload(["source", "target", "fileKey", "fileName", "mimeType", "params", "chunkedMode"], win, fail);
+
+            expect(blackberry.io.filetransfer.upload).toHaveBeenCalledWith("source", "target", win, fail, {fileKey: "fileKey", fileName: "fileName", mimeType: "mimeType", params: "params", chunkedMode: "chunkedMode"});
+        });
+
+        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/53110dc9/test/blackberry/qnx/test.magnetometer.js
----------------------------------------------------------------------
diff --git a/test/blackberry/qnx/test.magnetometer.js b/test/blackberry/qnx/test.magnetometer.js
new file mode 100644
index 0000000..48ded12
--- /dev/null
+++ b/test/blackberry/qnx/test.magnetometer.js
@@ -0,0 +1,82 @@
+/*
+ *
+ * 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("blackberry qnx magnetometer", function () {
+    var magnetometer = require('cordova/plugin/qnx/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).toHaveBeenCalled();
+        });
+
+        it('should add an event listener', function(){
+            magnetometer.start();
+            expect(window.addEventListener).toHaveBeenCalled();
+        });
+
+        it('should grab the magnetometer', function(){
+            var win = jasmine.createSpy('win');
+            magnetometer.start({}, win);
+
+            window.addEventListener.mostRecentCall.args[1]({
+                alpha: 0,
+                timeStamp: "bout that time, eh chap?"
+            });
+
+            expect(win).toHaveBeenCalledWith({
+                magneticHeading: 360,
+                trueHeading: 360,
+                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).toHaveBeenCalled();
+        });
+    });
+    
+});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/53110dc9/test/blackberry/qnx/test.platform.js
----------------------------------------------------------------------
diff --git a/test/blackberry/qnx/test.platform.js b/test/blackberry/qnx/test.platform.js
new file mode 100644
index 0000000..23a7f0f
--- /dev/null
+++ b/test/blackberry/qnx/test.platform.js
@@ -0,0 +1,140 @@
+/*
+ *
+ * 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("blackberry qnx platform", function () {
+    var platform = require('cordova/plugin/qnx/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("exports", function(){
+        it('should have the qnx id', function(){
+            expect(platform.id).toBe("qnx");
+        });
+    });
+
+    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");
+        });
+
+    });
+
+    describe('export objects', function(){
+        it('should define the requestFileSystem path', function(){
+            expect(platform.objects.requestFileSystem.path).toEqual("cordova/plugin/qnx/requestFileSystem");
+        });
+
+        it('should define the resolveLocalFileSystemURI path', function(){
+            expect(platform.objects.resolveLocalFileSystemURI.path).toEqual("cordova/plugin/qnx/resolveLocalFileSystemURI");
+        });
+    });
+
+    describe('export merges', function(){
+        it('should define the compass path', function(){
+            expect(platform.merges.navigator.children.compass.path).toEqual("cordova/plugin/qnx/compass");
+        });
+    });
+    
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/53110dc9/test/blackberry/qnx/test.requestFileSystem.js
----------------------------------------------------------------------
diff --git a/test/blackberry/qnx/test.requestFileSystem.js b/test/blackberry/qnx/test.requestFileSystem.js
new file mode 100644
index 0000000..c5c4d0b
--- /dev/null
+++ b/test/blackberry/qnx/test.requestFileSystem.js
@@ -0,0 +1,32 @@
+/*
+ *
+ * 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("blackberry qnx requestFileSystem", function () {
+    var requestFileSystem = require('cordova/plugin/qnx/requestFileSystem');
+
+    describe("webkitRequestFileSystem", function(){
+        it('should call on webkitRequestFileSystem', function(){
+            expect(requestFileSystem).toEqual(window.webkitRequestFileSystem);
+        });
+
+    });
+    
+});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/53110dc9/test/blackberry/qnx/test.resolveLocalFileSystemURI.js
----------------------------------------------------------------------
diff --git a/test/blackberry/qnx/test.resolveLocalFileSystemURI.js b/test/blackberry/qnx/test.resolveLocalFileSystemURI.js
new file mode 100644
index 0000000..2d6a3d5
--- /dev/null
+++ b/test/blackberry/qnx/test.resolveLocalFileSystemURI.js
@@ -0,0 +1,32 @@
+/*
+ *
+ * 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("blackberry qnx resolveLocalFileSystemURI", function () {
+    var resolveLocalFileSystemURI = require('cordova/plugin/qnx/resolveLocalFileSystemURI');
+
+    describe("webkitResolveLocalFileSystemURI", function(){
+        it('should call on webkitResolveLocalFileSystemURI', function(){
+            expect(resolveLocalFileSystemURI).toEqual(window.webkitResolveLocalFileSystemURI);
+        });
+
+    });
+    
+});