Permalink
Browse files

qnx tests

  • Loading branch information...
1 parent c46b140 commit 53110dc9078560adbb285f50f5efafa4a51d9847 Matt Lantz committed with gtanner Nov 23, 2012
@@ -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" };
}
};
@@ -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"
+ });
+ });
+ });
+
+});
@@ -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(){
+
+
+ });
+});
@@ -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"
+ });
+
+ });
+ });
+
+
+});
@@ -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();
+ });
+ });
+
+});
Oops, something went wrong.

0 comments on commit 53110dc

Please sign in to comment.