You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bh...@apache.org on 2013/06/28 15:42:36 UTC
js commit: [BlackBerry10] [CB-3368] Removing old capture plugin to be
replaced by a native one
Updated Branches:
refs/heads/master f96eefcd3 -> 5ea1a88f2
[BlackBerry10] [CB-3368] Removing old capture plugin to be replaced by a native one
Reviewed by Bryan Higgins <bh...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>
Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/5ea1a88f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/5ea1a88f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/5ea1a88f
Branch: refs/heads/master
Commit: 5ea1a88f240c1d6c9d5707595fd27a06ad3c6fcd
Parents: f96eefc
Author: Jeffrey Heifetz <jh...@blackberry.com>
Authored: Fri May 10 15:35:27 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri Jun 28 09:46:10 2013 -0400
----------------------------------------------------------------------
lib/blackberry10/exec.js | 1 -
lib/blackberry10/plugin/blackberry10/capture.js | 76 -------
test/blackberry10/test.capture.js | 222 -------------------
3 files changed, 299 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/5ea1a88f/lib/blackberry10/exec.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/exec.js b/lib/blackberry10/exec.js
index c22f4a5..dda4d4a 100644
--- a/lib/blackberry10/exec.js
+++ b/lib/blackberry10/exec.js
@@ -22,7 +22,6 @@
var cordova = require('cordova'),
plugins = {
'Compass' : require('cordova/plugin/blackberry10/magnetometer'),
- 'Capture' : require('cordova/plugin/blackberry10/capture'),
'FileTransfer': require('cordova/plugin/blackberry10/fileTransfer')
};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/5ea1a88f/lib/blackberry10/plugin/blackberry10/capture.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/capture.js b/lib/blackberry10/plugin/blackberry10/capture.js
deleted file mode 100644
index 3c8f1cb..0000000
--- a/lib/blackberry10/plugin/blackberry10/capture.js
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- *
- * 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.
- *
-*/
-
-var cordova = require('cordova');
-
-function capture(action, win, fail) {
- var noop = function () {};
-
- blackberry.invoke.card.invokeCamera(action, function (path) {
- var sb = blackberry.io.sandbox;
- blackberry.io.sandbox = false;
- window.webkitRequestFileSystem(window.PERSISTENT, 1024, function (fs) {
- fs.root.getFile(path, {}, function (fe) {
- fe.file(function (file) {
- file.fullPath = fe.fullPath;
- win([file]);
- blackberry.io.sandbox = sb;
- }, fail);
- }, fail);
- }, fail);
- }, noop, noop);
-}
-
-module.exports = {
- getSupportedAudioModes: function (args, win, fail) {
- return {"status": cordova.callbackStatus.OK, "message": []};
- },
- getSupportedImageModes: function (args, win, fail) {
- return {"status": cordova.callbackStatus.OK, "message": []};
- },
- getSupportedVideoModes: function (args, win, fail) {
- return {"status": cordova.callbackStatus.OK, "message": []};
- },
- captureImage: function (args, win, fail) {
- if (args[0].limit > 0) {
- capture("photo", win, fail);
- }
- else {
- win([]);
- }
-
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" };
- },
- captureVideo: function (args, win, fail) {
- if (args[0].limit > 0) {
- capture("video", win, fail);
- }
- else {
- win([]);
- }
-
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" };
- },
- captureAudio: function (args, win, fail) {
- fail("Capturing Audio not supported");
- return {"status": cordova.callbackStatus.NO_RESULT, "message": "WebWorks Is On It"};
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/5ea1a88f/test/blackberry10/test.capture.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.capture.js b/test/blackberry10/test.capture.js
deleted file mode 100644
index 95b48d4..0000000
--- a/test/blackberry10/test.capture.js
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- *
- * 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"
- });
- });
- });
-});