This repository has been archived by the owner on Nov 19, 2020. It is now read-only.
forked from mlingos/cordova-background-video
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
tests.js
61 lines (50 loc) · 2.4 KB
/
tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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); });
};