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/13 20:13:42 UTC
[3/16] js commit: fixed whitespace and finished up the media tests
for blackberry bb10.
fixed whitespace and finished up the media tests for blackberry bb10.
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/ad3b1c93
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/ad3b1c93
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/ad3b1c93
Branch: refs/heads/master
Commit: ad3b1c934dea7b9f44c6664eb4135c4eb0c4eb9c
Parents: 759bd70
Author: Gord Tanner <gt...@gmail.com>
Authored: Mon Nov 12 23:09:19 2012 -0500
Committer: Gord Tanner <gt...@gmail.com>
Committed: Mon Nov 12 23:09:19 2012 -0500
----------------------------------------------------------------------
lib/blackberry/plugin/webworks/media.js | 8 +-
lib/windowsphone/plugin/windowsphone/DOMStorage.js | 4 +-
test/blackberry/webworks/test.media.js | 85 ++++++++++++---
3 files changed, 75 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/ad3b1c93/lib/blackberry/plugin/webworks/media.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/webworks/media.js b/lib/blackberry/plugin/webworks/media.js
index c2ec671..62c2b1c 100644
--- a/lib/blackberry/plugin/webworks/media.js
+++ b/lib/blackberry/plugin/webworks/media.js
@@ -105,7 +105,7 @@ module.exports = {
return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
}
- var id = args[0],
+ var id = args[0],
audio = audioObjects[id],
result;
@@ -152,12 +152,8 @@ module.exports = {
return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
}
- var id = args[0],
- audio = audioObjects[id],
- result;
-
if (args.length <= 1) {
- result = {"status" : 9, "message" : "Media start recording, insufficient arguments"};
+ return {"status" : 9, "message" : "Media start recording, insufficient arguments"};
}
blackberry.media.microphone.record(args[1], win, fail);
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/ad3b1c93/lib/windowsphone/plugin/windowsphone/DOMStorage.js
----------------------------------------------------------------------
diff --git a/lib/windowsphone/plugin/windowsphone/DOMStorage.js b/lib/windowsphone/plugin/windowsphone/DOMStorage.js
index 67205b8..c546c0f 100644
--- a/lib/windowsphone/plugin/windowsphone/DOMStorage.js
+++ b/lib/windowsphone/plugin/windowsphone/DOMStorage.js
@@ -174,9 +174,9 @@ if (!docDomain || docDomain.length === 0) {
};
// initialize DOMStorage
-
+
if (typeof window.localStorage === "undefined") {
-
+
Object.defineProperty(window, "localStorage", {
writable: false,
configurable: false,
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/ad3b1c93/test/blackberry/webworks/test.media.js
----------------------------------------------------------------------
diff --git a/test/blackberry/webworks/test.media.js b/test/blackberry/webworks/test.media.js
index ae2bacb..dd8f1e7 100644
--- a/test/blackberry/webworks/test.media.js
+++ b/test/blackberry/webworks/test.media.js
@@ -24,6 +24,7 @@ describe("media", function () {
audio = {
play: jasmine.createSpy("play"),
pause: jasmine.createSpy("pause"),
+ src: "file.mp3",
currentTime: 800,
duration: 2100
};
@@ -238,25 +239,81 @@ describe("media", function () {
handlesNoArgs(media.getDuration);
handlesNotFound(media.getDuration);
- it("should return errors", function () {
- expect(media.getDuration(["EndlessLove"])).toEqual({
- status: 2,
- message:'Audio Object has not been initialized'
+ it("should return the duration", function () {
+ media.create(["lollypop", "lollypop.mp3"]);
+ expect(media.getDuration(["lollypop"])).toEqual({
+ status: 1,
+ message: 2100
});
- });
+ });
});
- xdescribe("startRecordingAudio", function(){
+ describe("startRecordingAudio", function(){
handlesNoArgs(media.startRecordingAudio);
- handlesNotFound(media.startRecordingAudio);
- xit("should successfully pause the audio", function() {
- media.create(["jammin", "tunes/wejammin.mp3"]);
- m = media.startRecordingAudio(["jammin"]);
- expect(m.status).toBe(0);
- expect(m.message).toBe('WebWorks Is On It');
- media.release(["jammin"]);
+ beforeEach(function () {
+ global.blackberry = {
+ media: {
+ microphone: {
+ record: jasmine.createSpy("record")
+ }
+ }
+ };
+ });
+
+ afterEach(function () {
+ delete global.blackberry;
+ });
+
+ it("throws an error when not enough arguments", function () {
+ expect(media.startRecordingAudio(["ww"])).toEqual({
+ status: 9,
+ message: "Media start recording, insufficient arguments"
+ });
+ });
+
+ it("calls record", function () {
+ var win = jasmine.createSpy("win"),
+ fail = jasmine.createSpy("fail");
+
+ media.startRecordingAudio(["record", "manifesto.ogg"], win, fail);
+
+ expect(blackberry.media.microphone.record).toHaveBeenCalledWith("manifesto.ogg", win, fail);
+ });
+
+ it("returns no result", function () {
+ expect(media.startRecordingAudio(["foo", "birdcall.mp3"])).toEqual({
+ status: 0,
+ message: "WebWorks Is On It"
+ });
+ });
+ });
+
+ describe("stopRecordingAudio", function () {
+ it("can be called with no args and all is well", function () {
+ expect(media.stopRecordingAudio).not.toThrow();
+ });
+ });
+
+ describe("release", function () {
+ handlesNoArgs(media.release);
+
+ afterEach(function () {
+ audio.src = "file.mp3";
+ });
+
+ it("sets the src of the audio object to undefined", function () {
+ media.create(["video", "killedtheradiostar.mp3"]);
+ media.release(["video"]);
+
+ expect(audio.src).not.toBeDefined();
+ });
+
+ it("returns a message that the resources have been released", function () {
+ expect(media.release(["onaboat"])).toEqual({
+ status: 1,
+ message: "Media resources released"
+ });
});
-
});
});