Move manifest parsing tests into their own test file.
Showing
3 changed files
with
109 additions
and
95 deletions
test/m3u8_test.js
0 → 100644
1 | (function(window) { | ||
2 | var | ||
3 | m3u8parser; | ||
4 | |||
5 | module('environment'); | ||
6 | |||
7 | test('is sane', function() { | ||
8 | expect(1); | ||
9 | ok(true); | ||
10 | }); | ||
11 | |||
12 | /* | ||
13 | Manfiest controller | ||
14 | */ | ||
15 | |||
16 | module('manifest controller', { | ||
17 | setup: function() { | ||
18 | manifestController = new window.videojs.hls.ManifestController(); | ||
19 | this.vjsget = window.videojs.get; | ||
20 | window.videojs.get = function(url, success) { | ||
21 | success(window.brightcove_playlist_data); | ||
22 | }; | ||
23 | }, | ||
24 | teardown: function() { | ||
25 | window.videojs.get = this.vjsget; | ||
26 | } | ||
27 | }); | ||
28 | |||
29 | test('should create', function() { | ||
30 | ok(manifestController); | ||
31 | }); | ||
32 | |||
33 | test('should return a parsed object', function() { | ||
34 | var data = manifestController.parseManifest(window.brightcove_playlist_data); | ||
35 | |||
36 | ok(data); | ||
37 | equal(data.playlistItems.length, 4, 'Has correct rendition count'); | ||
38 | equal(data.playlistItems[0].bandwidth, 240000, 'First rendition index bandwidth is correct'); | ||
39 | equal(data.playlistItems[0]["program-id"], 1, 'First rendition index program-id is correct'); | ||
40 | equal(data.playlistItems[0].resolution.width, 396, 'First rendition index resolution width is correct'); | ||
41 | equal(data.playlistItems[0].resolution.height, 224, 'First rendition index resolution height is correct'); | ||
42 | }); | ||
43 | |||
44 | test('should get a manifest from hermes', function() { | ||
45 | manifestController.loadManifest('http://example.com/16x9-master.m3u8', | ||
46 | function(responseData) { | ||
47 | ok(responseData); | ||
48 | }, | ||
49 | function() { | ||
50 | ok(false, 'does not error'); | ||
51 | }, | ||
52 | function() {}); | ||
53 | }); | ||
54 | |||
55 | /* | ||
56 | M3U8 Test Suite | ||
57 | */ | ||
58 | |||
59 | module('m3u8 parser', { | ||
60 | setup: function() { | ||
61 | m3u8parser = new window.videojs.hls.M3U8Parser(); | ||
62 | } | ||
63 | }); | ||
64 | |||
65 | test('should create my parser', function() { | ||
66 | ok(m3u8parser !== undefined); | ||
67 | }); | ||
68 | |||
69 | test('should successfully parse manifest data', function() { | ||
70 | var parsedData = m3u8parser.parse(window.playlistData); | ||
71 | ok(parsedData); | ||
72 | }); | ||
73 | |||
74 | test('should populate the manifest data object', function() { | ||
75 | var data = m3u8parser.parse(window.playlistData); | ||
76 | |||
77 | notEqual(data, null, 'data is not NULL'); | ||
78 | equal(data.invalidReasons.length, 0, 'data has 0 invalid reasons'); | ||
79 | equal(data.hasValidM3UTag, true, 'data has valid EXTM3U'); | ||
80 | equal(data.targetDuration, 10, 'data has correct TARGET DURATION'); | ||
81 | equal(data.allowCache, "NO", 'acceptable ALLOW CACHE'); | ||
82 | equal(data.isPlaylist, false, 'data is parsed as a PLAYLIST as expected'); | ||
83 | equal(data.playlistType, "VOD", 'acceptable PLAYLIST TYPE'); | ||
84 | equal(data.mediaItems.length, 16, 'acceptable mediaItem count'); | ||
85 | equal(data.mediaSequence, 0, 'MEDIA SEQUENCE is correct'); | ||
86 | equal(data.totalDuration, -1, "ZEN TOTAL DURATION is unknown as expected"); | ||
87 | equal(data.hasEndTag, true, 'should have ENDLIST tag'); | ||
88 | }); | ||
89 | |||
90 | module('brightcove playlist', { | ||
91 | setup: function() { | ||
92 | m3u8parser = new window.videojs.hls.M3U8Parser(); | ||
93 | } | ||
94 | }); | ||
95 | |||
96 | test('should parse a brightcove manifest data', function() { | ||
97 | var data = m3u8parser.parse(window.brightcove_playlist_data); | ||
98 | |||
99 | ok(data); | ||
100 | equal(data.playlistItems.length, 4, 'Has correct rendition count'); | ||
101 | equal(data.isPlaylist, true, 'data is parsed as a PLAYLIST as expected'); | ||
102 | equal(data.playlistItems[0].bandwidth, 240000, 'First rendition index bandwidth is correct'); | ||
103 | equal(data.playlistItems[0]["program-id"], 1, 'First rendition index program-id is correct'); | ||
104 | equal(data.playlistItems[0].resolution.width, 396, 'First rendition index resolution width is correct'); | ||
105 | equal(data.playlistItems[0].resolution.height, 224, 'First rendition index resolution height is correct'); | ||
106 | |||
107 | }); | ||
108 | })(this); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -36,6 +36,7 @@ | ... | @@ -36,6 +36,7 @@ |
36 | <script src="video-js-hls_test.js"></script> | 36 | <script src="video-js-hls_test.js"></script> |
37 | <script src="exp-golomb_test.js"></script> | 37 | <script src="exp-golomb_test.js"></script> |
38 | <script src="flv-tag_test.js"></script> | 38 | <script src="flv-tag_test.js"></script> |
39 | <script src="m3u8_test.js"></script> | ||
39 | </head> | 40 | </head> |
40 | <body> | 41 | <body> |
41 | <div id="qunit"></div> | 42 | <div id="qunit"></div> | ... | ... |
... | @@ -22,7 +22,6 @@ | ... | @@ -22,7 +22,6 @@ |
22 | var | 22 | var |
23 | manifestController, | 23 | manifestController, |
24 | segmentController, | 24 | segmentController, |
25 | m3u8parser, | ||
26 | parser, | 25 | parser, |
27 | 26 | ||
28 | expectedHeader = [ | 27 | expectedHeader = [ |
... | @@ -231,100 +230,6 @@ | ... | @@ -231,100 +230,6 @@ |
231 | } | 230 | } |
232 | }); | 231 | }); |
233 | 232 | ||
234 | /* | ||
235 | M3U8 Test Suite | ||
236 | */ | ||
237 | |||
238 | module('m3u8 parser', { | ||
239 | setup: function() { | ||
240 | m3u8parser = new window.videojs.hls.M3U8Parser(); | ||
241 | } | ||
242 | }); | ||
243 | |||
244 | test('should create my parser', function() { | ||
245 | ok(m3u8parser !== undefined); | ||
246 | }); | ||
247 | |||
248 | test('should successfully parse manifest data', function() { | ||
249 | var parsedData = m3u8parser.parse(window.playlistData); | ||
250 | ok(parsedData); | ||
251 | }); | ||
252 | |||
253 | test('test for expected results', function() { | ||
254 | var data = m3u8parser.parse(window.playlistData); | ||
255 | |||
256 | notEqual(data, null, 'data is not NULL'); | ||
257 | equal(data.invalidReasons.length, 0, 'data has 0 invalid reasons'); | ||
258 | equal(data.hasValidM3UTag, true, 'data has valid EXTM3U'); | ||
259 | equal(data.targetDuration, 10, 'data has correct TARGET DURATION'); | ||
260 | equal(data.allowCache, "NO", 'acceptable ALLOW CACHE'); | ||
261 | equal(data.isPlaylist, false, 'data is parsed as a PLAYLIST as expected'); | ||
262 | equal(data.playlistType, "VOD", 'acceptable PLAYLIST TYPE'); | ||
263 | equal(data.mediaItems.length, 16, 'acceptable mediaItem count'); | ||
264 | equal(data.mediaSequence, 0, 'MEDIA SEQUENCE is correct'); | ||
265 | equal(data.totalDuration, -1, "ZEN TOTAL DURATION is unknown as expected"); | ||
266 | equal(data.hasEndTag, true, 'should have ENDLIST tag'); | ||
267 | }); | ||
268 | |||
269 | module('brightcove playlist', { | ||
270 | setup: function() { | ||
271 | m3u8parser = new window.videojs.hls.M3U8Parser(); | ||
272 | } | ||
273 | }); | ||
274 | |||
275 | test('should parse a brightcove manifest data', function() { | ||
276 | var data = m3u8parser.parse(window.brightcove_playlist_data); | ||
277 | |||
278 | ok(data); | ||
279 | equal(data.playlistItems.length, 4, 'Has correct rendition count'); | ||
280 | equal(data.isPlaylist, true, 'data is parsed as a PLAYLIST as expected'); | ||
281 | equal(data.playlistItems[0].bandwidth, 240000, 'First rendition index bandwidth is correct'); | ||
282 | equal(data.playlistItems[0]["program-id"], 1, 'First rendition index program-id is correct'); | ||
283 | equal(data.playlistItems[0].resolution.width, 396, 'First rendition index resolution width is correct'); | ||
284 | equal(data.playlistItems[0].resolution.height, 224, 'First rendition index resolution height is correct'); | ||
285 | |||
286 | } | ||
287 | ); | ||
288 | |||
289 | module('manifest controller', { | ||
290 | setup: function() { | ||
291 | manifestController = new window.videojs.hls.ManifestController(); | ||
292 | this.vjsget = window.videojs.get; | ||
293 | window.videojs.get = function(url, success) { | ||
294 | success(window.brightcove_playlist_data); | ||
295 | }; | ||
296 | }, | ||
297 | teardown: function() { | ||
298 | window.videojs.get = this.vjsget; | ||
299 | } | ||
300 | }); | ||
301 | |||
302 | test('should create', function() { | ||
303 | ok(manifestController); | ||
304 | }); | ||
305 | |||
306 | test('should return a parsed object', function() { | ||
307 | var data = manifestController.parseManifest(window.brightcove_playlist_data); | ||
308 | |||
309 | ok(data); | ||
310 | equal(data.playlistItems.length, 4, 'Has correct rendition count'); | ||
311 | equal(data.playlistItems[0].bandwidth, 240000, 'First rendition index bandwidth is correct'); | ||
312 | equal(data.playlistItems[0]["program-id"], 1, 'First rendition index program-id is correct'); | ||
313 | equal(data.playlistItems[0].resolution.width, 396, 'First rendition index resolution width is correct'); | ||
314 | equal(data.playlistItems[0].resolution.height, 224, 'First rendition index resolution height is correct'); | ||
315 | }); | ||
316 | |||
317 | test('should get a manifest from hermes', function() { | ||
318 | manifestController.loadManifest('http://example.com/16x9-master.m3u8', | ||
319 | function(responseData) { | ||
320 | ok(responseData); | ||
321 | }, | ||
322 | function() { | ||
323 | ok(false, 'does not error'); | ||
324 | }, | ||
325 | function() {}); | ||
326 | }); | ||
327 | |||
328 | module('segment controller', { | 233 | module('segment controller', { |
329 | setup: function() { | 234 | setup: function() { |
330 | segmentController = new window.videojs.hls.SegmentController(); | 235 | segmentController = new window.videojs.hls.SegmentController(); | ... | ... |
-
Please register or sign in to post a comment