diff --git a/test/functional/testSuites.js b/test/functional/testSuites.js index 24f37b6da6..b352400a17 100644 --- a/test/functional/testSuites.js +++ b/test/functional/testSuites.js @@ -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); @@ -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); }; diff --git a/test/functional/tests/initialText.js b/test/functional/tests/initialText.js new file mode 100644 index 0000000000..169268f17b --- /dev/null +++ b/test/functional/tests/initialText.js @@ -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); + } + } + }); + }); +}; diff --git a/test/functional/tests/scripts/player.js b/test/functional/tests/scripts/player.js index b2dc70fe39..51bbc6a59d 100644 --- a/test/functional/tests/scripts/player.js +++ b/test/functional/tests/scripts/player.js @@ -157,7 +157,6 @@ module.exports = { setTextDefaultEnabled: function(bool){ player.setTextDefaultEnabled(bool); }, - attachTTMLRenderingDiv: function(ttmlDiv){ player.attachTTMLRenderingDiv(ttmlDiv); }