You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2014/08/07 22:32:36 UTC
[1/5] git commit: [CB-6959] Port capture tests to
plugin-test-framework
Repository: cordova-plugin-media-capture
Updated Branches:
refs/heads/master 4c8b67ebf -> 7fece155c
[CB-6959] Port capture tests to plugin-test-framework
Ported the compass plugin (device-orientation) from mobile-spec to the
new test framework with Jasmine 2.0
-Added test folder
-Added test.js file inside the test folder.
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/commit/19f625a7
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/tree/19f625a7
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/diff/19f625a7
Branch: refs/heads/master
Commit: 19f625a793988d976996a3afbf4edc7e78a2bdc9
Parents: 1bef8d0
Author: Samir Silva <ss...@gmail.com>
Authored: Mon Jun 30 11:57:31 2014 -0700
Committer: Samir Silva <ss...@gmail.com>
Committed: Mon Jun 30 11:57:31 2014 -0700
----------------------------------------------------------------------
test/tests.js | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 114 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/19f625a7/test/tests.js
----------------------------------------------------------------------
diff --git a/test/tests.js b/test/tests.js
new file mode 100644
index 0000000..a433aa5
--- /dev/null
+++ b/test/tests.js
@@ -0,0 +1,114 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+exports.defineAutoTests = function() {
+ describe('Capture (navigator.device.capture)', function () {
+ it("capture.spec.1 should exist", function() {
+ expect(navigator.device).toBeDefined();
+ expect(navigator.device.capture).toBeDefined();
+ });
+
+ it("capture.spec.2 should have the correct properties ", function() {
+ expect(navigator.device.capture.supportedAudioModes).toBeDefined();
+ expect(navigator.device.capture.supportedImageModes).toBeDefined();
+ expect(navigator.device.capture.supportedVideoModes).toBeDefined();
+ });
+
+ it("capture.spec.3 should contain a captureAudio function", function() {
+ expect(navigator.device.capture.captureAudio).toBeDefined();
+ expect(typeof navigator.device.capture.captureAudio == 'function').toBe(true);
+ });
+
+ it("capture.spec.4 should contain a captureImage function", function() {
+ expect(navigator.device.capture.captureImage).toBeDefined();
+ expect(typeof navigator.device.capture.captureImage == 'function').toBe(true);
+ });
+
+ it("capture.spec.5 should contain a captureVideo function", function() {
+ expect(navigator.device.capture.captureVideo).toBeDefined();
+ expect(typeof navigator.device.capture.captureVideo == 'function').toBe(true);
+ });
+
+ describe('CaptureAudioOptions', function () {
+ it("capture.spec.6 CaptureAudioOptions constructor should exist", function() {
+ var options = new CaptureAudioOptions();
+ expect(options).toBeDefined();
+ expect(options.limit).toBeDefined();
+ expect(options.duration).toBeDefined();
+ });
+ });
+
+ describe('CaptureImageOptions', function () {
+ it("capture.spec.7 CaptureImageOptions constructor should exist", function() {
+ var options = new CaptureImageOptions();
+ expect(options).toBeDefined();
+ expect(options.limit).toBeDefined();
+ });
+ });
+
+ describe('CaptureVideoOptions', function () {
+ it("capture.spec.8 CaptureVideoOptions constructor should exist", function() {
+ var options = new CaptureVideoOptions();
+ expect(options).toBeDefined();
+ expect(options.limit).toBeDefined();
+ expect(options.duration).toBeDefined();
+ });
+ });
+
+ describe('CaptureError interface', function () {
+ it("capture.spec.9 CaptureError constants should be defined", function() {
+ expect(CaptureError.CAPTURE_INTERNAL_ERR).toBe(0);
+ expect(CaptureError.CAPTURE_APPLICATION_BUSY).toBe(1);
+ expect(CaptureError.CAPTURE_INVALID_ARGUMENT).toBe(2);
+ expect(CaptureError.CAPTURE_NO_MEDIA_FILES).toBe(3);
+ });
+
+ it("capture.spec.10 CaptureError properties should exist", function() {
+ var error = new CaptureError();
+ expect(error).toBeDefined();
+ expect(error.code).toBeDefined();
+ });
+ });
+
+ describe('MediaFileData', function () {
+ it("capture.spec.11 MediaFileData constructor should exist", function() {
+ var fileData = new MediaFileData();
+ expect(fileData).toBeDefined();
+ expect(fileData.bitrate).toBeDefined();
+ expect(fileData.codecs).toBeDefined();
+ expect(fileData.duration).toBeDefined();
+ expect(fileData.height).toBeDefined();
+ expect(fileData.width).toBeDefined();
+ });
+ });
+
+ describe('MediaFile', function () {
+ it("capture.spec.12 MediaFile constructor should exist", function() {
+ var fileData = new MediaFile();
+ expect(fileData).toBeDefined();
+ expect(fileData.name).toBeDefined();
+ expect(fileData.type).toBeDefined();
+ expect(fileData.lastModifiedDate).toBeDefined();
+ expect(fileData.size).toBeDefined();
+ });
+ });
+ });
+};
[5/5] git commit: Merge branch 'CB-6959' of
https://github.com/stacic/cordova-plugin-media-capture
Posted by pu...@apache.org.
Merge branch 'CB-6959' of https://github.com/stacic/cordova-plugin-media-capture
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/commit/7fece155
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/tree/7fece155
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/diff/7fece155
Branch: refs/heads/master
Commit: 7fece155c02bfd1d6146262e8fbdae99a5519c68
Parents: 4c8b67e 11ad97c
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu Aug 7 13:31:57 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu Aug 7 13:31:57 2014 -0700
----------------------------------------------------------------------
tests/plugin.xml | 31 +++++++
tests/tests.js | 252 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 283 insertions(+)
----------------------------------------------------------------------
[3/5] git commit: CB-6959 Added manual tests
Posted by pu...@apache.org.
CB-6959 Added manual tests
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/commit/03129578
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/tree/03129578
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/diff/03129578
Branch: refs/heads/master
Commit: 0312957883b4baf8287365484becd80ba6fb4bfd
Parents: d6b23ee
Author: Staci Cooper <sm...@us.ibm.com>
Authored: Fri Jul 18 15:15:18 2014 -0400
Committer: Staci Cooper <sm...@us.ibm.com>
Committed: Fri Jul 18 15:15:18 2014 -0400
----------------------------------------------------------------------
test/tests.js | 164 ++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 151 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/03129578/test/tests.js
----------------------------------------------------------------------
diff --git a/test/tests.js b/test/tests.js
index a433aa5..3a9957b 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -19,36 +19,36 @@
*
*/
-exports.defineAutoTests = function() {
+exports.defineAutoTests = function () {
describe('Capture (navigator.device.capture)', function () {
- it("capture.spec.1 should exist", function() {
+ it("capture.spec.1 should exist", function () {
expect(navigator.device).toBeDefined();
expect(navigator.device.capture).toBeDefined();
});
- it("capture.spec.2 should have the correct properties ", function() {
+ it("capture.spec.2 should have the correct properties ", function () {
expect(navigator.device.capture.supportedAudioModes).toBeDefined();
expect(navigator.device.capture.supportedImageModes).toBeDefined();
expect(navigator.device.capture.supportedVideoModes).toBeDefined();
});
- it("capture.spec.3 should contain a captureAudio function", function() {
+ it("capture.spec.3 should contain a captureAudio function", function () {
expect(navigator.device.capture.captureAudio).toBeDefined();
expect(typeof navigator.device.capture.captureAudio == 'function').toBe(true);
});
- it("capture.spec.4 should contain a captureImage function", function() {
+ it("capture.spec.4 should contain a captureImage function", function () {
expect(navigator.device.capture.captureImage).toBeDefined();
expect(typeof navigator.device.capture.captureImage == 'function').toBe(true);
});
- it("capture.spec.5 should contain a captureVideo function", function() {
+ it("capture.spec.5 should contain a captureVideo function", function () {
expect(navigator.device.capture.captureVideo).toBeDefined();
expect(typeof navigator.device.capture.captureVideo == 'function').toBe(true);
});
describe('CaptureAudioOptions', function () {
- it("capture.spec.6 CaptureAudioOptions constructor should exist", function() {
+ it("capture.spec.6 CaptureAudioOptions constructor should exist", function () {
var options = new CaptureAudioOptions();
expect(options).toBeDefined();
expect(options.limit).toBeDefined();
@@ -57,7 +57,7 @@ exports.defineAutoTests = function() {
});
describe('CaptureImageOptions', function () {
- it("capture.spec.7 CaptureImageOptions constructor should exist", function() {
+ it("capture.spec.7 CaptureImageOptions constructor should exist", function () {
var options = new CaptureImageOptions();
expect(options).toBeDefined();
expect(options.limit).toBeDefined();
@@ -65,7 +65,7 @@ exports.defineAutoTests = function() {
});
describe('CaptureVideoOptions', function () {
- it("capture.spec.8 CaptureVideoOptions constructor should exist", function() {
+ it("capture.spec.8 CaptureVideoOptions constructor should exist", function () {
var options = new CaptureVideoOptions();
expect(options).toBeDefined();
expect(options.limit).toBeDefined();
@@ -74,14 +74,14 @@ exports.defineAutoTests = function() {
});
describe('CaptureError interface', function () {
- it("capture.spec.9 CaptureError constants should be defined", function() {
+ it("capture.spec.9 CaptureError constants should be defined", function () {
expect(CaptureError.CAPTURE_INTERNAL_ERR).toBe(0);
expect(CaptureError.CAPTURE_APPLICATION_BUSY).toBe(1);
expect(CaptureError.CAPTURE_INVALID_ARGUMENT).toBe(2);
expect(CaptureError.CAPTURE_NO_MEDIA_FILES).toBe(3);
});
- it("capture.spec.10 CaptureError properties should exist", function() {
+ it("capture.spec.10 CaptureError properties should exist", function () {
var error = new CaptureError();
expect(error).toBeDefined();
expect(error.code).toBeDefined();
@@ -89,7 +89,7 @@ exports.defineAutoTests = function() {
});
describe('MediaFileData', function () {
- it("capture.spec.11 MediaFileData constructor should exist", function() {
+ it("capture.spec.11 MediaFileData constructor should exist", function () {
var fileData = new MediaFileData();
expect(fileData).toBeDefined();
expect(fileData.bitrate).toBeDefined();
@@ -101,7 +101,7 @@ exports.defineAutoTests = function() {
});
describe('MediaFile', function () {
- it("capture.spec.12 MediaFile constructor should exist", function() {
+ it("capture.spec.12 MediaFile constructor should exist", function () {
var fileData = new MediaFile();
expect(fileData).toBeDefined();
expect(fileData.name).toBeDefined();
@@ -112,3 +112,141 @@ exports.defineAutoTests = function() {
});
});
};
+
+/******************************************************************************/
+/******************************************************************************/
+/******************************************************************************/
+
+exports.defineManualTests = function (contentEl, createActionButton) {
+ var platformId = cordova.require('cordova/platform').id;
+ var pageStartTime = +new Date();
+
+ function log(value) {
+ document.getElementById('camera_status').textContent += (new Date() - pageStartTime) / 1000 + ': ' + value + '\n';
+ console.log(value);
+ }
+
+ function captureAudioWin(mediaFiles) {
+ var path = mediaFiles[0].fullPath;
+ log('Audio captured: ' + path);
+ var m = new Media(path);
+ m.play();
+ }
+
+ function captureAudioFail(e) {
+ log('Error getting audio: ' + e.code);
+ }
+
+ function getAudio() {
+ clearStatus();
+ var options = { limit: 1, duration: 10 };
+ navigator.device.capture.captureAudio(captureAudioWin, captureAudioFail, options);
+ }
+
+ function captureImageWin(mediaFiles) {
+ var path = mediaFiles[0].fullPath;
+ log('Image captured: ' + path);
+ document.getElementById('camera_image').src = path;
+ }
+
+ function captureImageFail(e) {
+ log('Error getting image: ' + e.code);
+ }
+
+ function getImage() {
+ clearStatus();
+ var options = { limit: 1 };
+ navigator.device.capture.captureImage(captureImageWin, captureImageFail, options);
+ }
+
+ function captureVideoWin(mediaFiles) {
+ var path = mediaFiles[0].fullPath;
+ log('Video captured: ' + path);
+
+ // need to inject the video element into the html
+ // doesn't seem to work if you have a pre-existing video element and
+ // add in a source tag
+ var vid = document.createElement('video');
+ vid.id = "theVideo";
+ vid.width = "320";
+ vid.height = "240";
+ vid.controls = "true";
+ var source_vid = document.createElement('source');
+ source_vid.id = "theSource";
+ source_vid.src = path;
+ vid.appendChild(source_vid);
+ document.getElementById('video_container').appendChild(vid);
+ }
+
+ function captureVideoFail(e) {
+ log('Error getting video: ' + e.code);
+ }
+
+ function getVideo() {
+ clearStatus();
+ var options = { limit: 1, duration: 10 };
+ navigator.device.capture.captureVideo(captureVideoWin, captureVideoFail, options);
+ }
+
+ function resolveMediaFileURL(mediaFile, callback) {
+ resolveLocalFileSystemURL(mediaFile.localURL, function (entry) {
+ log("Resolved by URL: " + mediaFile.localURL);
+ if (callback) callback();
+ }, function (err) {
+ log("Failed to resolve by URL: " + mediaFile.localURL);
+ log("Error: " + JSON.stringify(err));
+ if (callback) callback();
+ });
+ }
+
+ function resolveMediaFile(mediaFile, callback) {
+ resolveLocalFileSystemURL(mediaFile.fullPath, function (entry) {
+ log("Resolved by path: " + mediaFile.fullPath);
+ if (callback) callback();
+ }, function (err) {
+ log("Failed to resolve by path: " + mediaFile.fullPath);
+ log("Error: " + JSON.stringify(err));
+ if (callback) callback();
+ });
+ }
+
+ function resolveVideo() {
+ clearStatus();
+ var options = { limit: 1, duration: 5 };
+ navigator.device.capture.captureVideo(function (mediaFiles) {
+ captureVideoWin(mediaFiles);
+ resolveMediaFile(mediaFiles[0], function () {
+ resolveMediaFileURL(mediaFiles[0]);
+ });
+ }, captureVideoFail, options);
+ }
+
+ function clearStatus() {
+ document.getElementById('camera_status').innerHTML = '';
+ document.getElementById('camera_image').src = 'about:blank';
+ }
+
+ /******************************************************************************/
+
+ contentEl.innerHTML = '<div id="info" style="white-space: pre-wrap">' +
+ '<b>Status:</b> <div id="camera_status"></div>' +
+ 'img: <img width="100" id="camera_image">' +
+ 'video: <div id="video_container"></div>' +
+ '</div><div id="actions"></div>';
+
+ createActionButton('Capture 10 sec of audio and play', function () {
+ getAudio();
+ }, 'actions');
+
+ createActionButton('Capture 1 image', function () {
+ getImage();
+ }, 'actions');
+
+ createActionButton('Capture 10 sec of video', function () {
+ getVideo();
+ }, 'actions');
+
+ createActionButton('Capture 5 sec of video and resolve', function () {
+ resolveVideo();
+ }, 'actions');
+};
[4/5] git commit: Renamed test dir, added nested plugin.xml
Posted by pu...@apache.org.
Renamed test dir, added nested plugin.xml
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/commit/11ad97cd
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/tree/11ad97cd
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/diff/11ad97cd
Branch: refs/heads/master
Commit: 11ad97cd4ddbe6a202128477e6af2efd64d81c42
Parents: 0312957
Author: Staci Cooper <sm...@us.ibm.com>
Authored: Thu Jul 31 15:31:51 2014 -0400
Committer: Staci Cooper <sm...@us.ibm.com>
Committed: Thu Jul 31 15:31:51 2014 -0400
----------------------------------------------------------------------
test/tests.js | 252 --------------------------------------------------
tests/plugin.xml | 31 +++++++
tests/tests.js | 252 ++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 283 insertions(+), 252 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/11ad97cd/test/tests.js
----------------------------------------------------------------------
diff --git a/test/tests.js b/test/tests.js
deleted file mode 100644
index 3a9957b..0000000
--- a/test/tests.js
+++ /dev/null
@@ -1,252 +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.
- *
-*/
-
-exports.defineAutoTests = function () {
- describe('Capture (navigator.device.capture)', function () {
- it("capture.spec.1 should exist", function () {
- expect(navigator.device).toBeDefined();
- expect(navigator.device.capture).toBeDefined();
- });
-
- it("capture.spec.2 should have the correct properties ", function () {
- expect(navigator.device.capture.supportedAudioModes).toBeDefined();
- expect(navigator.device.capture.supportedImageModes).toBeDefined();
- expect(navigator.device.capture.supportedVideoModes).toBeDefined();
- });
-
- it("capture.spec.3 should contain a captureAudio function", function () {
- expect(navigator.device.capture.captureAudio).toBeDefined();
- expect(typeof navigator.device.capture.captureAudio == 'function').toBe(true);
- });
-
- it("capture.spec.4 should contain a captureImage function", function () {
- expect(navigator.device.capture.captureImage).toBeDefined();
- expect(typeof navigator.device.capture.captureImage == 'function').toBe(true);
- });
-
- it("capture.spec.5 should contain a captureVideo function", function () {
- expect(navigator.device.capture.captureVideo).toBeDefined();
- expect(typeof navigator.device.capture.captureVideo == 'function').toBe(true);
- });
-
- describe('CaptureAudioOptions', function () {
- it("capture.spec.6 CaptureAudioOptions constructor should exist", function () {
- var options = new CaptureAudioOptions();
- expect(options).toBeDefined();
- expect(options.limit).toBeDefined();
- expect(options.duration).toBeDefined();
- });
- });
-
- describe('CaptureImageOptions', function () {
- it("capture.spec.7 CaptureImageOptions constructor should exist", function () {
- var options = new CaptureImageOptions();
- expect(options).toBeDefined();
- expect(options.limit).toBeDefined();
- });
- });
-
- describe('CaptureVideoOptions', function () {
- it("capture.spec.8 CaptureVideoOptions constructor should exist", function () {
- var options = new CaptureVideoOptions();
- expect(options).toBeDefined();
- expect(options.limit).toBeDefined();
- expect(options.duration).toBeDefined();
- });
- });
-
- describe('CaptureError interface', function () {
- it("capture.spec.9 CaptureError constants should be defined", function () {
- expect(CaptureError.CAPTURE_INTERNAL_ERR).toBe(0);
- expect(CaptureError.CAPTURE_APPLICATION_BUSY).toBe(1);
- expect(CaptureError.CAPTURE_INVALID_ARGUMENT).toBe(2);
- expect(CaptureError.CAPTURE_NO_MEDIA_FILES).toBe(3);
- });
-
- it("capture.spec.10 CaptureError properties should exist", function () {
- var error = new CaptureError();
- expect(error).toBeDefined();
- expect(error.code).toBeDefined();
- });
- });
-
- describe('MediaFileData', function () {
- it("capture.spec.11 MediaFileData constructor should exist", function () {
- var fileData = new MediaFileData();
- expect(fileData).toBeDefined();
- expect(fileData.bitrate).toBeDefined();
- expect(fileData.codecs).toBeDefined();
- expect(fileData.duration).toBeDefined();
- expect(fileData.height).toBeDefined();
- expect(fileData.width).toBeDefined();
- });
- });
-
- describe('MediaFile', function () {
- it("capture.spec.12 MediaFile constructor should exist", function () {
- var fileData = new MediaFile();
- expect(fileData).toBeDefined();
- expect(fileData.name).toBeDefined();
- expect(fileData.type).toBeDefined();
- expect(fileData.lastModifiedDate).toBeDefined();
- expect(fileData.size).toBeDefined();
- });
- });
- });
-};
-
-/******************************************************************************/
-/******************************************************************************/
-/******************************************************************************/
-
-exports.defineManualTests = function (contentEl, createActionButton) {
- var platformId = cordova.require('cordova/platform').id;
- var pageStartTime = +new Date();
-
- function log(value) {
- document.getElementById('camera_status').textContent += (new Date() - pageStartTime) / 1000 + ': ' + value + '\n';
- console.log(value);
- }
-
- function captureAudioWin(mediaFiles) {
- var path = mediaFiles[0].fullPath;
- log('Audio captured: ' + path);
- var m = new Media(path);
- m.play();
- }
-
- function captureAudioFail(e) {
- log('Error getting audio: ' + e.code);
- }
-
- function getAudio() {
- clearStatus();
- var options = { limit: 1, duration: 10 };
- navigator.device.capture.captureAudio(captureAudioWin, captureAudioFail, options);
- }
-
- function captureImageWin(mediaFiles) {
- var path = mediaFiles[0].fullPath;
- log('Image captured: ' + path);
- document.getElementById('camera_image').src = path;
- }
-
- function captureImageFail(e) {
- log('Error getting image: ' + e.code);
- }
-
- function getImage() {
- clearStatus();
- var options = { limit: 1 };
- navigator.device.capture.captureImage(captureImageWin, captureImageFail, options);
- }
-
- function captureVideoWin(mediaFiles) {
- var path = mediaFiles[0].fullPath;
- log('Video captured: ' + path);
-
- // need to inject the video element into the html
- // doesn't seem to work if you have a pre-existing video element and
- // add in a source tag
- var vid = document.createElement('video');
- vid.id = "theVideo";
- vid.width = "320";
- vid.height = "240";
- vid.controls = "true";
- var source_vid = document.createElement('source');
- source_vid.id = "theSource";
- source_vid.src = path;
- vid.appendChild(source_vid);
- document.getElementById('video_container').appendChild(vid);
- }
-
- function captureVideoFail(e) {
- log('Error getting video: ' + e.code);
- }
-
- function getVideo() {
- clearStatus();
- var options = { limit: 1, duration: 10 };
- navigator.device.capture.captureVideo(captureVideoWin, captureVideoFail, options);
- }
-
- function resolveMediaFileURL(mediaFile, callback) {
- resolveLocalFileSystemURL(mediaFile.localURL, function (entry) {
- log("Resolved by URL: " + mediaFile.localURL);
- if (callback) callback();
- }, function (err) {
- log("Failed to resolve by URL: " + mediaFile.localURL);
- log("Error: " + JSON.stringify(err));
- if (callback) callback();
- });
- }
-
- function resolveMediaFile(mediaFile, callback) {
- resolveLocalFileSystemURL(mediaFile.fullPath, function (entry) {
- log("Resolved by path: " + mediaFile.fullPath);
- if (callback) callback();
- }, function (err) {
- log("Failed to resolve by path: " + mediaFile.fullPath);
- log("Error: " + JSON.stringify(err));
- if (callback) callback();
- });
- }
-
- function resolveVideo() {
- clearStatus();
- var options = { limit: 1, duration: 5 };
- navigator.device.capture.captureVideo(function (mediaFiles) {
- captureVideoWin(mediaFiles);
- resolveMediaFile(mediaFiles[0], function () {
- resolveMediaFileURL(mediaFiles[0]);
- });
- }, captureVideoFail, options);
- }
-
- function clearStatus() {
- document.getElementById('camera_status').innerHTML = '';
- document.getElementById('camera_image').src = 'about:blank';
- }
-
- /******************************************************************************/
-
- contentEl.innerHTML = '<div id="info" style="white-space: pre-wrap">' +
- '<b>Status:</b> <div id="camera_status"></div>' +
- 'img: <img width="100" id="camera_image">' +
- 'video: <div id="video_container"></div>' +
- '</div><div id="actions"></div>';
-
- createActionButton('Capture 10 sec of audio and play', function () {
- getAudio();
- }, 'actions');
-
- createActionButton('Capture 1 image', function () {
- getImage();
- }, 'actions');
-
- createActionButton('Capture 10 sec of video', function () {
- getVideo();
- }, 'actions');
-
- createActionButton('Capture 5 sec of video and resolve', function () {
- resolveVideo();
- }, 'actions');
-};
http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/11ad97cd/tests/plugin.xml
----------------------------------------------------------------------
diff --git a/tests/plugin.xml b/tests/plugin.xml
new file mode 100644
index 0000000..1cf7f19
--- /dev/null
+++ b/tests/plugin.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:rim="http://www.blackberry.com/ns/widgets"
+ id="org.apache.cordova.media-capture.tests"
+ version="0.3.2-dev">
+ <name>Cordova Media Capture Plugin Tests</name>
+ <license>Apache 2.0</license>
+
+ <js-module src="tests.js" name="tests">
+ </js-module>
+</plugin>
http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/11ad97cd/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
new file mode 100644
index 0000000..3a9957b
--- /dev/null
+++ b/tests/tests.js
@@ -0,0 +1,252 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+exports.defineAutoTests = function () {
+ describe('Capture (navigator.device.capture)', function () {
+ it("capture.spec.1 should exist", function () {
+ expect(navigator.device).toBeDefined();
+ expect(navigator.device.capture).toBeDefined();
+ });
+
+ it("capture.spec.2 should have the correct properties ", function () {
+ expect(navigator.device.capture.supportedAudioModes).toBeDefined();
+ expect(navigator.device.capture.supportedImageModes).toBeDefined();
+ expect(navigator.device.capture.supportedVideoModes).toBeDefined();
+ });
+
+ it("capture.spec.3 should contain a captureAudio function", function () {
+ expect(navigator.device.capture.captureAudio).toBeDefined();
+ expect(typeof navigator.device.capture.captureAudio == 'function').toBe(true);
+ });
+
+ it("capture.spec.4 should contain a captureImage function", function () {
+ expect(navigator.device.capture.captureImage).toBeDefined();
+ expect(typeof navigator.device.capture.captureImage == 'function').toBe(true);
+ });
+
+ it("capture.spec.5 should contain a captureVideo function", function () {
+ expect(navigator.device.capture.captureVideo).toBeDefined();
+ expect(typeof navigator.device.capture.captureVideo == 'function').toBe(true);
+ });
+
+ describe('CaptureAudioOptions', function () {
+ it("capture.spec.6 CaptureAudioOptions constructor should exist", function () {
+ var options = new CaptureAudioOptions();
+ expect(options).toBeDefined();
+ expect(options.limit).toBeDefined();
+ expect(options.duration).toBeDefined();
+ });
+ });
+
+ describe('CaptureImageOptions', function () {
+ it("capture.spec.7 CaptureImageOptions constructor should exist", function () {
+ var options = new CaptureImageOptions();
+ expect(options).toBeDefined();
+ expect(options.limit).toBeDefined();
+ });
+ });
+
+ describe('CaptureVideoOptions', function () {
+ it("capture.spec.8 CaptureVideoOptions constructor should exist", function () {
+ var options = new CaptureVideoOptions();
+ expect(options).toBeDefined();
+ expect(options.limit).toBeDefined();
+ expect(options.duration).toBeDefined();
+ });
+ });
+
+ describe('CaptureError interface', function () {
+ it("capture.spec.9 CaptureError constants should be defined", function () {
+ expect(CaptureError.CAPTURE_INTERNAL_ERR).toBe(0);
+ expect(CaptureError.CAPTURE_APPLICATION_BUSY).toBe(1);
+ expect(CaptureError.CAPTURE_INVALID_ARGUMENT).toBe(2);
+ expect(CaptureError.CAPTURE_NO_MEDIA_FILES).toBe(3);
+ });
+
+ it("capture.spec.10 CaptureError properties should exist", function () {
+ var error = new CaptureError();
+ expect(error).toBeDefined();
+ expect(error.code).toBeDefined();
+ });
+ });
+
+ describe('MediaFileData', function () {
+ it("capture.spec.11 MediaFileData constructor should exist", function () {
+ var fileData = new MediaFileData();
+ expect(fileData).toBeDefined();
+ expect(fileData.bitrate).toBeDefined();
+ expect(fileData.codecs).toBeDefined();
+ expect(fileData.duration).toBeDefined();
+ expect(fileData.height).toBeDefined();
+ expect(fileData.width).toBeDefined();
+ });
+ });
+
+ describe('MediaFile', function () {
+ it("capture.spec.12 MediaFile constructor should exist", function () {
+ var fileData = new MediaFile();
+ expect(fileData).toBeDefined();
+ expect(fileData.name).toBeDefined();
+ expect(fileData.type).toBeDefined();
+ expect(fileData.lastModifiedDate).toBeDefined();
+ expect(fileData.size).toBeDefined();
+ });
+ });
+ });
+};
+
+/******************************************************************************/
+/******************************************************************************/
+/******************************************************************************/
+
+exports.defineManualTests = function (contentEl, createActionButton) {
+ var platformId = cordova.require('cordova/platform').id;
+ var pageStartTime = +new Date();
+
+ function log(value) {
+ document.getElementById('camera_status').textContent += (new Date() - pageStartTime) / 1000 + ': ' + value + '\n';
+ console.log(value);
+ }
+
+ function captureAudioWin(mediaFiles) {
+ var path = mediaFiles[0].fullPath;
+ log('Audio captured: ' + path);
+ var m = new Media(path);
+ m.play();
+ }
+
+ function captureAudioFail(e) {
+ log('Error getting audio: ' + e.code);
+ }
+
+ function getAudio() {
+ clearStatus();
+ var options = { limit: 1, duration: 10 };
+ navigator.device.capture.captureAudio(captureAudioWin, captureAudioFail, options);
+ }
+
+ function captureImageWin(mediaFiles) {
+ var path = mediaFiles[0].fullPath;
+ log('Image captured: ' + path);
+ document.getElementById('camera_image').src = path;
+ }
+
+ function captureImageFail(e) {
+ log('Error getting image: ' + e.code);
+ }
+
+ function getImage() {
+ clearStatus();
+ var options = { limit: 1 };
+ navigator.device.capture.captureImage(captureImageWin, captureImageFail, options);
+ }
+
+ function captureVideoWin(mediaFiles) {
+ var path = mediaFiles[0].fullPath;
+ log('Video captured: ' + path);
+
+ // need to inject the video element into the html
+ // doesn't seem to work if you have a pre-existing video element and
+ // add in a source tag
+ var vid = document.createElement('video');
+ vid.id = "theVideo";
+ vid.width = "320";
+ vid.height = "240";
+ vid.controls = "true";
+ var source_vid = document.createElement('source');
+ source_vid.id = "theSource";
+ source_vid.src = path;
+ vid.appendChild(source_vid);
+ document.getElementById('video_container').appendChild(vid);
+ }
+
+ function captureVideoFail(e) {
+ log('Error getting video: ' + e.code);
+ }
+
+ function getVideo() {
+ clearStatus();
+ var options = { limit: 1, duration: 10 };
+ navigator.device.capture.captureVideo(captureVideoWin, captureVideoFail, options);
+ }
+
+ function resolveMediaFileURL(mediaFile, callback) {
+ resolveLocalFileSystemURL(mediaFile.localURL, function (entry) {
+ log("Resolved by URL: " + mediaFile.localURL);
+ if (callback) callback();
+ }, function (err) {
+ log("Failed to resolve by URL: " + mediaFile.localURL);
+ log("Error: " + JSON.stringify(err));
+ if (callback) callback();
+ });
+ }
+
+ function resolveMediaFile(mediaFile, callback) {
+ resolveLocalFileSystemURL(mediaFile.fullPath, function (entry) {
+ log("Resolved by path: " + mediaFile.fullPath);
+ if (callback) callback();
+ }, function (err) {
+ log("Failed to resolve by path: " + mediaFile.fullPath);
+ log("Error: " + JSON.stringify(err));
+ if (callback) callback();
+ });
+ }
+
+ function resolveVideo() {
+ clearStatus();
+ var options = { limit: 1, duration: 5 };
+ navigator.device.capture.captureVideo(function (mediaFiles) {
+ captureVideoWin(mediaFiles);
+ resolveMediaFile(mediaFiles[0], function () {
+ resolveMediaFileURL(mediaFiles[0]);
+ });
+ }, captureVideoFail, options);
+ }
+
+ function clearStatus() {
+ document.getElementById('camera_status').innerHTML = '';
+ document.getElementById('camera_image').src = 'about:blank';
+ }
+
+ /******************************************************************************/
+
+ contentEl.innerHTML = '<div id="info" style="white-space: pre-wrap">' +
+ '<b>Status:</b> <div id="camera_status"></div>' +
+ 'img: <img width="100" id="camera_image">' +
+ 'video: <div id="video_container"></div>' +
+ '</div><div id="actions"></div>';
+
+ createActionButton('Capture 10 sec of audio and play', function () {
+ getAudio();
+ }, 'actions');
+
+ createActionButton('Capture 1 image', function () {
+ getImage();
+ }, 'actions');
+
+ createActionButton('Capture 10 sec of video', function () {
+ getVideo();
+ }, 'actions');
+
+ createActionButton('Capture 5 sec of video and resolve', function () {
+ resolveVideo();
+ }, 'actions');
+};
[2/5] git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture into
HEAD
Posted by pu...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture into HEAD
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/commit/d6b23eee
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/tree/d6b23eee
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/diff/d6b23eee
Branch: refs/heads/master
Commit: d6b23eee66a81d6685f312316be353c2c6d29604
Parents: 19f625a a6810a9
Author: Staci Cooper <sm...@us.ibm.com>
Authored: Fri Jul 18 15:13:56 2014 -0400
Committer: Staci Cooper <sm...@us.ibm.com>
Committed: Fri Jul 18 15:13:56 2014 -0400
----------------------------------------------------------------------
doc/ru/index.md | 541 ++++++++++++++++++++++++++++++++++++++++++
src/android/Capture.java | 14 +-
2 files changed, 554 insertions(+), 1 deletion(-)
----------------------------------------------------------------------