Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A2204D450 for ; Tue, 13 Nov 2012 19:13:43 +0000 (UTC) Received: (qmail 20881 invoked by uid 500); 13 Nov 2012 19:13:43 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 20806 invoked by uid 500); 13 Nov 2012 19:13:43 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 20617 invoked by uid 500); 13 Nov 2012 19:13:43 -0000 Delivered-To: apmail-incubator-callback-commits@incubator.apache.org Received: (qmail 20569 invoked by uid 99); 13 Nov 2012 19:13:43 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Nov 2012 19:13:43 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id B39E3559AD; Tue, 13 Nov 2012 19:13:42 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: gtanner@apache.org To: callback-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [12/16] js commit: Corrections and further test expansions Message-Id: <20121113191342.B39E3559AD@tyr.zones.apache.org> Date: Tue, 13 Nov 2012 19:13:42 +0000 (UTC) Corrections and further test expansions Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/dd0df7d7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/dd0df7d7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/dd0df7d7 Branch: refs/heads/master Commit: dd0df7d7e5eb78e931e0d625876369bb4055d6df Parents: 590874f Author: Matt Lantz Authored: Mon Nov 12 09:37:53 2012 -0500 Committer: Matt Lantz Committed: Mon Nov 12 09:37:53 2012 -0500 ---------------------------------------------------------------------- lib/blackberry/plugin/webworks/media.js | 1 - test/blackberry/webworks/test.accelerometer.js | 11 +- test/blackberry/webworks/test.media.js | 246 ++++++++++++++++++- test/blackberry/webworks/test.notification.js | 44 ++-- 4 files changed, 266 insertions(+), 36 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/dd0df7d7/lib/blackberry/plugin/webworks/media.js ---------------------------------------------------------------------- diff --git a/lib/blackberry/plugin/webworks/media.js b/lib/blackberry/plugin/webworks/media.js index 2499aea..82404c5 100644 --- a/lib/blackberry/plugin/webworks/media.js +++ b/lib/blackberry/plugin/webworks/media.js @@ -98,7 +98,6 @@ module.exports = { result = {"status" : 1, "message" : "Seek to audio succeeded" }; } - return result; }, pausePlayingAudio: function (args, win, fail) { http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/dd0df7d7/test/blackberry/webworks/test.accelerometer.js ---------------------------------------------------------------------- diff --git a/test/blackberry/webworks/test.accelerometer.js b/test/blackberry/webworks/test.accelerometer.js index 8c726d7..b315108 100644 --- a/test/blackberry/webworks/test.accelerometer.js +++ b/test/blackberry/webworks/test.accelerometer.js @@ -27,9 +27,8 @@ describe("accelerometer", function () { spyOn(window, "removeEventListener"); spyOn(window, "addEventListener"); - var callback = function(motion){}, - win = function(){}, - fail = function(){}, + var win = jasmine.createSpy('win'), + fail = jasmine.createSpy('fail'), args = {x:1,y:2,z:3}, aStart = accelerometer.start(args, win, fail); @@ -51,7 +50,10 @@ describe("accelerometer", function () { spyOn(window, "removeEventListener"); var aStop = accelerometer.stop(); - expect(window.removeEventListener).toHaveBeenCalled(); + expect(window.removeEventListener).toHaveBeenCalledWith("devicemotion", jasmine.any(Function)); + + window.removeEventListener.reset(); + expect(aStop.status).toBe(0); expect(aStop.message).toBe('WebWorks Is On It'); @@ -59,4 +61,3 @@ describe("accelerometer", function () { }); }); - http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/dd0df7d7/test/blackberry/webworks/test.media.js ---------------------------------------------------------------------- diff --git a/test/blackberry/webworks/test.media.js b/test/blackberry/webworks/test.media.js index 6ef95a3..ca35da8 100644 --- a/test/blackberry/webworks/test.media.js +++ b/test/blackberry/webworks/test.media.js @@ -21,32 +21,254 @@ describe("media", function () { var media = require('cordova/plugin/webworks/media'), - exec = require('cordova/exec'); + m; + + beforeEach(function(){ + global.Audio = function(src){ + var funcs = { + play: function(){}, + pause: function(){}, + currentTime: 800, + duration: 2100 + } + return funcs; + } + }); + + afterEach(function(){ + delete global.Audio; + }); describe("create", function() { - it("should fail to create a media object", function() { - var m = media.create(8); + m = media.create({}); + expect(m.status).toBe(9); + expect(m.message).toBe('Media Object id was not sent in arguments'); + }); + it("should fail to create a media object", function() { + m = media.create(9); expect(m.status).toBe(9); expect(m.message).toBe('Media Object id was not sent in arguments'); }); it("should create a media object", function() { - - var Audio = jasmine.createSpy('Audio'); - window.Audio = new Audio; + m = media.create(["jammin", "tunes/wejammin.mp3"]); + expect(m.status).toBe(1); + expect(m.message).toBe('Audio object created'); + }); + }); - // spyOn(window, "Audio"); + describe("startPlayingAudio", function(){ + it("should fail to find the media Object", function() { + m = media.startPlayingAudio({}); + expect(m.status).toBe(9); + expect(m.message).toBe('Media Object id was not sent in arguments'); + }); - // var m = media.create(["jammin", "yeah man!"]); + it("should fail to find media Source ", function() { + m = media.startPlayingAudio(["jammin"]); + expect(m.status).toBe(9); + expect(m.message).toBe('Media source argument not found'); + }); + + it("should create a media object ", function() { + m = media.startPlayingAudio(["jammin", "tunes/wejammin.mp3"]); + expect(m.status).toBe(1); + expect(m.message).toBe('Audio play started'); + }); + }); - // expect(window.Audio).toHaveBeenCalled(); - - // expect(m.status).toBe(1); - // expect(m.message).toBe('Audio object created'); + describe("stopPlayingAudio", function(){ + it("should fail to find the media Object", function() { + m = media.stopPlayingAudio(0); + expect(m.status).toBe(9); + expect(m.message).toBe('Media Object id was not sent in arguments'); + }); + + it("should stop the audio playback ", function() { + m = media.stopPlayingAudio(["jammin", "tunes/wejammin.mp3"]); + expect(m.status).toBe(1); + expect(m.message).toBe('Audio play stopped'); + }); + + it("should find that the Audio Object failed to initialze", function() { + global.audio = undefined; + m = media.stopPlayingAudio(["jammin"]); + expect(m.status).toBe(2); + expect(m.message).toBe('Audio Object has not been initialized'); + delete global.audio; }); }); + describe("seekToAudio", function(){ + it("should fail to find the media Object", function() { + m = media.seekToAudio(0); + expect(m.status).toBe(9); + expect(m.message).toBe('Media Object id was not sent in arguments'); + }); + + it("should find that the Audio Object failed to initialze", function() { + global.audio = undefined; + m = media.seekToAudio(["jammin"]); + expect(m.status).toBe(2); + expect(m.message).toBe('Audio Object has not been initialized'); + delete global.audio; + }); + + it("should find that there is no time argument in the function", function() { + media.create(["jammin", "tunes/wejammin.mp3"]); + m = media.seekToAudio(["jammin"]); + expect(m.status).toBe(9); + expect(m.message).toBe('Media seek time argument not found'); + media.release(["jammin"]); + }); + + // TODO: review error generators!!! It should have a listener to see when it changes and make calls based on those changes of that particular variable. + // it("should result in an error seeking audio", function() { + // media.create(["jammin", "tunes/wejammin.mp3"]); + // m = media.seekToAudio(["jammin", 9000]); + + // // expect(m.status).toBe(3); + // expect(m.message).toBe('Seek to audio succeeded'); + + // media.release(["jammin"]); + // }); + + it("should successfully seek to audio", function() { + media.create(["jammin", "tunes/wejammin.mp3"]); + m = media.seekToAudio(["jammin", 800]); + expect(m.status).toBe(1); + expect(m.message).toBe('Seek to audio succeeded'); + media.release(["jammin"]); + }); + + + }); + + describe("pausePlayingAudio", function(){ + it("should fail to find the media Object", function() { + m = media.pausePlayingAudio(0); + expect(m.status).toBe(9); + expect(m.message).toBe('Media Object id was not sent in arguments'); + }); + + it("should find that the Audio Object failed to initialze", function() { + global.audio = undefined; + m = media.pausePlayingAudio(["jammin"]); + expect(m.status).toBe(2); + expect(m.message).toBe('Audio Object has not been initialized'); + delete global.audio; + }); + + it("should successfully pause the audio", function() { + media.create(["jammin", "tunes/wejammin.mp3"]); + m = media.pausePlayingAudio(["jammin"]); + expect(m.status).toBe(1); + expect(m.message).toBe('Audio paused'); + media.release(["jammin"]); + }); + + }); + + describe("getCurrentPositionAudio", function(){ + it("should fail to find the media Object", function() { + m = media.getCurrentPositionAudio(0); + expect(m.status).toBe(9); + expect(m.message).toBe('Media Object id was not sent in arguments'); + }); + + it("should find that the Audio Object failed to initialze", function() { + global.audio = undefined; + m = media.getCurrentPositionAudio(["jammin"]); + expect(m.status).toBe(2); + expect(m.message).toBe('Audio Object has not been initialized'); + delete global.audio; + }); + + it("should successfully pause the audio", function() { + media.create(["jammin", "tunes/wejammin.mp3"]); + m = media.getCurrentPositionAudio(["jammin"]); + expect(m.status).toBe(1); + expect(m.message).toBe(800); + media.release(["jammin"]); + }); + + }); + + describe("getDuration", function(){ + it("should fail to find the media Object", function() { + m = media.getDuration(0); + expect(m.status).toBe(9); + expect(m.message).toBe('Media Object id was not sent in arguments'); + }); + + it("should find that the Audio Object failed to initialze", function() { + global.audio = undefined; + m = media.getDuration(["jammin"]); + expect(m.status).toBe(2); + expect(m.message).toBe('Audio Object has not been initialized'); + delete global.audio; + }); + + it("should successfully pause the audio", function() { + media.create(["jammin", "tunes/wejammin.mp3"]); + m = media.getDuration(["jammin"]); + expect(m.status).toBe(1); + expect(m.message).toBe(2100); + media.release(["jammin"]); + }); + + }); + + describe("startRecordingAudio", function(){ + it("should fail to find the media Object", function() { + m = media.startRecordingAudio(0); + expect(m.status).toBe(9); + expect(m.message).toBe('Media Object id was not sent in arguments'); + }); + + it("should find that the Audio Object failed to initialze", function() { + global.audio = undefined; + m = media.startRecordingAudio(["jammin"]); + expect(m.status).toBe(2); + expect(m.message).toBe('Media start recording, insufficient arguments'); + delete global.audio; + }); + + it("should successfully pause the audio", function() { + media.create(["jammin", "tunes/wejammin.mp3"]); + m = media.startRecordingAudio(["jammin"]); + expect(m.status).toBe(1); + expect(m.message).toBe(2100); + media.release(["jammin"]); + }); + + }); + + // describe("getDuration", function(){ + // it("should fail to find the media Object", function() { + // m = media.getDuration(0); + // expect(m.status).toBe(9); + // expect(m.message).toBe('Media Object id was not sent in arguments'); + // }); + + // it("should find that the Audio Object failed to initialze", function() { + // global.audio = undefined; + // m = media.getDuration(["jammin"]); + // expect(m.status).toBe(2); + // expect(m.message).toBe('Audio Object has not been initialized'); + // delete global.audio; + // }); + + // it("should successfully pause the audio", function() { + // media.create(["jammin", "tunes/wejammin.mp3"]); + // m = media.getDuration(["jammin"]); + // expect(m.status).toBe(1); + // expect(m.message).toBe(2100); + // media.release(["jammin"]); + // }); + + // }); }); http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/dd0df7d7/test/blackberry/webworks/test.notification.js ---------------------------------------------------------------------- diff --git a/test/blackberry/webworks/test.notification.js b/test/blackberry/webworks/test.notification.js index 75c7102..a3375dd 100644 --- a/test/blackberry/webworks/test.notification.js +++ b/test/blackberry/webworks/test.notification.js @@ -20,10 +20,24 @@ */ describe("notification", function () { - var notification = require('cordova/plugin/webworks/notification'), - exec = require('cordova/exec'); + var notification = require('cordova/plugin/webworks/notification'); + + beforeEach(function(){ + global.blackberry = { + ui:{ + dialog:{ + customAskAsync: { + apply: function(args){ return args; } + } + } + } + } + }); + + afterEach(function(){ + delete global.blackberry; + }); - // alerts handled by cordova describe("alert - arguments not equal to three", function() { it("should provide an alert notification", function() { @@ -36,24 +50,17 @@ describe("notification", function () { }); }); - // alerts handled by webworks describe("alert - arguments equal to three", function() { - it("should call blackberry.ui.dialog.customAskAsync", function() { - - // spyOn(blackberry.ui.dialog.customAskAsync, "apply"); + it("should call a webworks action", function() { - // var args = ["Danger, danger Will Robinson", "Panic, is my middle name", "PANIC"], - // n = notification.alert(args); - + var n = notification.alert(["Danger, danger Will Robinson", "Panic, is my middle name", "PANIC"]); - // expect(args.length).toBe(3); - // expect(n.status).toBe(9); - // expect(n.message).toBe('Notification action - alert arguments not found'); + expect(n.status).toBe(0); + expect(n.message).toBe('WebWorks Is On It'); }); }); - // confirm handled by cordova describe("confirm - arguments not equal to three", function() { it("should provide a confirm notification", function() { @@ -68,11 +75,12 @@ describe("notification", function () { // confirm handled by webworks describe("alert - arguments equal to three", function() { - it("should call blackberry", function() { + it("should call a webworks action", function() { - // var args = ["Danger, danger Will Robinson", "Panic, is my middle name", "PANIC"]; - // var n = notification.alert(args); - // TALK TO GORD!!!!! + var n = notification.confirm(["Danger, danger Will Robinson", "Panic, is my middle name", "PANIC"]); + + expect(n.status).toBe(0); + expect(n.message).toBe('WebWorks Is On It'); }); });