forked from mozilla/popcorn-js
/
popcorn.parserSSA.unit.js
57 lines (48 loc) · 1.31 KB
/
popcorn.parserSSA.unit.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
test( "Popcorn 0.3 SSA/ASS Parser Plugin", function () {
var count = 0,
numSubs = 0,
sub,
poppercorn = Popcorn( "#video" ),
subs = [
{
text: "Senator, we're <br />making our final <br />approach into Coruscant.",
start: 2.4,
end: 7.2
},
{
text: "Very good, Lieutenant.",
start: 9.71,
end: 13.39
},
{
text: "It's <br />a <br />trap!",
start: 15.04,
end: 18.04
}
],
expects = subs.length*3 + 1;
function plus() {
if ( ++count === expects ) {
start();
}
}
poppercorn.parseSSA( "data/data.ssa" );
expect( expects );
stop( 5000 );
// Allow load time
setTimeout(function () {
Popcorn.forEach( poppercorn.getTrackEvents(), function(evt) {
if( evt._natives.type === "subtitle" ) {
sub = subs[numSubs++];
equals( evt.start, sub.start, "Correctly parsed start of " + evt.start );
plus();
equals( evt.text, sub.text, "Correctly parsed text of " + evt.start );
plus();
equals( evt.end, sub.end, "Correctly parsed end at " + evt.start );
plus();
}
});
equals( subs.length, numSubs, "Parsed all subtitles" );
plus();
}, 500);
});