Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Commit

Permalink
add cordova tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jhayward committed Jan 4, 2017
1 parent 2293726 commit 0bf4559
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/plugin.xml
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:rim="http://www.blackberry.com/ns/widgets"
xmlns:android="http://schemas.android.com/apk/res/android"
id="iclue-backgroundvideo-tests"
version="0.0.11">
<name>Iclue Background Video Cordova Plugin Tests</name>
<license>GPL3</license>

<dependency id="iclue-backgroundvideo" version=">=0.0.11" />

<js-module src="tests.js" name="tests">
</js-module>
</plugin>
61 changes: 61 additions & 0 deletions tests/tests.js
@@ -0,0 +1,61 @@
/* globals window, document, cordova, exports, console */
/* jshint jasmine: true */

'use strict';

exports.defineAutoTests = function() {
describe('Background video', function () {
it("should exist", function () {
expect(cordova.plugins.backgroundvideo).toBeDefined();
});

it("should contain a start function", function () {
expect(cordova.plugins.backgroundvideo.start).toBeDefined();
expect(typeof cordova.plugins.backgroundvideo.start == 'function').toBe(true);
});

it("should contain a stop function", function () {
expect(cordova.plugins.backgroundvideo.stop).toBeDefined();
expect(typeof cordova.plugins.backgroundvideo.stop == 'function').toBe(true);
});
});
};

/******************************************************************************/
/******************************************************************************/
/******************************************************************************/

exports.defineManualTests = function (contentEl, createActionButton) {
var recordAudio = false;
var camera = 'FRONT';
var filename = 'test-video';
var content = '<h1>Background Video</h1><div id="status"></div>';

function Log(tag, value) {
console.log(tag, value);
document.getElementById('status').textContent += '\r\n ' + tag + ': ' + value;
}
function successFn(a){Log('success', a);}
function errorFn(a){Log('error', a);}

// We need to wrap this code due to Windows security restrictions
// see http://msdn.microsoft.com/en-us/library/windows/apps/hh465380.aspx#differences for details
if (window.MSApp && window.MSApp.execUnsafeLocalFunction) {
MSApp.execUnsafeLocalFunction(function() {
contentEl.innerHTML = content;
});
} else {
contentEl.innerHTML = content;
}

createActionButton('Start video', function () {
cordova.plugins.backgroundvideo.start(filename, camera, recordAudio, successFn, errorFn);
});

createActionButton('Stop video', function () {
cordova.plugins.backgroundvideo.stop(successFn, errorFn);
});

createActionButton('Toggle audio', function () { recordAudio = !recordAudio; Log('Record audio set', recordAudio); });
createActionButton('Toggle camera', function () { camera = (camera === 'FRONT' ? 'BACK' : 'FRONT'); Log('Camera set', camera); });
};

0 comments on commit 0bf4559

Please sign in to comment.