Skip to content

Commit 3b7f2a5

Browse files
vrosenbergdsilhavy
andauthored
Feature initial text (#3500)
* initial Text prerequisites * feature initial text * set test timeout * Minor refactoring Co-authored-by: dsilhavy <[email protected]>
1 parent 4f25e04 commit 3b7f2a5

File tree

3 files changed

+73
-2
lines changed

3 files changed

+73
-2
lines changed

test/functional/testSuites.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ const seekPeriods = require('./tests/seekPeriods');
1111
const audioSwitch = require('./tests/audioSwitch');
1212
const textSwitch = require('./tests/textSwitch');
1313
const initialAudio = require('./tests/initialAudio');
14+
const initialText = require('./tests/initialText');
1415
const ended = require('./tests/ended');
1516

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

1920
setup.register(stream);
2021
play.register(stream);
@@ -26,6 +27,7 @@ var registerSuites = function (stream) {
2627
if (suites.indexOf('audioSwitch') !== -1) audioSwitch.register(stream);
2728
if (suites.indexOf('textSwitch') !== -1) textSwitch.register(stream);
2829
if (suites.indexOf('initialAudio') !== -1) initialAudio.register(stream);
30+
if (suites.indexOf('initialText') !== -1) initialText.register(stream);
2931
if (suites.indexOf('ended') !== -1) ended.register(stream);
3032
};
3133

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/**
2+
INITIAL_Text:
3+
- for each text track:
4+
- load test page
5+
- load elements
6+
- set initial text track
7+
- load stream
8+
- play stream
9+
- check new current text track
10+
- check if playback progressing
11+
**/
12+
const intern = require('intern').default;
13+
const { suite, before, test} = intern.getPlugin('interface.tdd');
14+
const { assert } = intern.getPlugin('chai');
15+
16+
const utils = require('./scripts/utils.js');
17+
const player = require('./scripts/player.js');
18+
19+
// Suite name
20+
const NAME = 'INITIAL_TEXT';
21+
22+
// test constants
23+
const SWITCH_WAIT = 3;
24+
const SWITCH_TIMEOUT = 60;
25+
26+
exports.register = function (stream) {
27+
28+
suite(utils.testName(NAME, stream), (suite) => {
29+
30+
before(() => {
31+
if (!stream.available || stream.textTracks.text.length < 1 && stream.textTracks.fragmentedText.length < 1) suite.skip();
32+
utils.log(NAME, 'Load stream');
33+
34+
});
35+
36+
test('switch text track', async (test) => {
37+
// Set test timeout
38+
test.timeout = SWITCH_TIMEOUT * 1000;
39+
40+
for(let textType in stream.textTracks){
41+
for (let i = 0; i < stream.textTracks[textType].length ; i++) {
42+
// reload page
43+
command = test.remote.get(intern.config.testPage);
44+
await command.execute(player.setAutoPlay, [false]);
45+
46+
//Load needed elements into doc for Captions to function
47+
let ttml = await command.findById('ttml-rendering-div');
48+
await command.execute(player.attachTTMLRenderingDiv, [ttml]);
49+
await command.execute(player.setTextDefaultEnabled, [true]);
50+
51+
// set initial track
52+
utils.log(NAME, 'set initial text track: ' + stream.textTracks[textType][i].lang);
53+
await command.execute(player.setInitialMediaSettingsFor, [textType, {
54+
lang: stream.textTracks[textType][i].lang
55+
}]);
56+
await command.execute(player.loadStream, [stream]);
57+
await command.execute(player.play, []);
58+
59+
// Wait
60+
await command.sleep(SWITCH_WAIT * 1000);
61+
62+
// Check if initial track is correct
63+
const newTrack = await command.execute(player.getCurrentTrackFor, [textType]);
64+
utils.log(NAME, 'current audio track: ' + newTrack.lang);
65+
assert.deepEqual(newTrack.lang, stream.textTracks[textType][i].lang);
66+
}
67+
}
68+
});
69+
});
70+
};

test/functional/tests/scripts/player.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ module.exports = {
157157
setTextDefaultEnabled: function(bool){
158158
player.setTextDefaultEnabled(bool);
159159
},
160-
161160
attachTTMLRenderingDiv: function(ttmlDiv){
162161
player.attachTTMLRenderingDiv(ttmlDiv);
163162
}

0 commit comments

Comments
 (0)