Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion test/functional/testSuites.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ const seekPeriods = require('./tests/seekPeriods');
const audioSwitch = require('./tests/audioSwitch');
const textSwitch = require('./tests/textSwitch');
const initialAudio = require('./tests/initialAudio');
const initialText = require('./tests/initialText');
const ended = require('./tests/ended');

var registerSuites = function (stream) {
var suites = intern.config.testSuites || ['playFromTime', 'pause', 'seek', 'seekPeriods', 'audioSwitch', 'textSwitch','initialAudio' , 'ended'];
var suites = intern.config.testSuites || ['playFromTime', 'pause', 'seek', 'seekPeriods', 'audioSwitch', 'textSwitch','initialAudio' , 'initialText','ended'];

setup.register(stream);
play.register(stream);
Expand All @@ -26,6 +27,7 @@ var registerSuites = function (stream) {
if (suites.indexOf('audioSwitch') !== -1) audioSwitch.register(stream);
if (suites.indexOf('textSwitch') !== -1) textSwitch.register(stream);
if (suites.indexOf('initialAudio') !== -1) initialAudio.register(stream);
if (suites.indexOf('initialText') !== -1) initialText.register(stream);
if (suites.indexOf('ended') !== -1) ended.register(stream);
};

Expand Down
70 changes: 70 additions & 0 deletions test/functional/tests/initialText.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
INITIAL_Text:
- for each text track:
- load test page
- load elements
- set initial text track
- load stream
- play stream
- check new current text track
- check if playback progressing
**/
const intern = require('intern').default;
const { suite, before, test} = intern.getPlugin('interface.tdd');
const { assert } = intern.getPlugin('chai');

const utils = require('./scripts/utils.js');
const player = require('./scripts/player.js');

// Suite name
const NAME = 'INITIAL_TEXT';

// test constants
const SWITCH_WAIT = 3;
const SWITCH_TIMEOUT = 60;

exports.register = function (stream) {

suite(utils.testName(NAME, stream), (suite) => {

before(() => {
if (!stream.available || stream.textTracks.text.length < 1 && stream.textTracks.fragmentedText.length < 1) suite.skip();
utils.log(NAME, 'Load stream');

});

test('switch text track', async (test) => {
// Set test timeout
test.timeout = SWITCH_TIMEOUT * 1000;

for(let textType in stream.textTracks){
for (let i = 0; i < stream.textTracks[textType].length ; i++) {
// reload page
command = test.remote.get(intern.config.testPage);
await command.execute(player.setAutoPlay, [false]);

//Load needed elements into doc for Captions to function
let ttml = await command.findById('ttml-rendering-div');
await command.execute(player.attachTTMLRenderingDiv, [ttml]);
await command.execute(player.setTextDefaultEnabled, [true]);

// set initial track
utils.log(NAME, 'set initial text track: ' + stream.textTracks[textType][i].lang);
await command.execute(player.setInitialMediaSettingsFor, [textType, {
lang: stream.textTracks[textType][i].lang
}]);
await command.execute(player.loadStream, [stream]);
await command.execute(player.play, []);

// Wait
await command.sleep(SWITCH_WAIT * 1000);

// Check if initial track is correct
const newTrack = await command.execute(player.getCurrentTrackFor, [textType]);
utils.log(NAME, 'current audio track: ' + newTrack.lang);
assert.deepEqual(newTrack.lang, stream.textTracks[textType][i].lang);
}
}
});
});
};
1 change: 0 additions & 1 deletion test/functional/tests/scripts/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ module.exports = {
setTextDefaultEnabled: function(bool){
player.setTextDefaultEnabled(bool);
},

attachTTMLRenderingDiv: function(ttmlDiv){
player.attachTTMLRenderingDiv(ttmlDiv);
}
Expand Down