fix 'selects a playlist after segment downloads'
Showing
1 changed file
with
31 additions
and
3 deletions
... | @@ -316,18 +316,47 @@ test('calculates the bandwidth after downloading a segment', function() { | ... | @@ -316,18 +316,47 @@ test('calculates the bandwidth after downloading a segment', function() { |
316 | 'saves segment request time: ' + player.hls.segmentXhrTime + 's'); | 316 | 'saves segment request time: ' + player.hls.segmentXhrTime + 's'); |
317 | }); | 317 | }); |
318 | 318 | ||
319 | test('selects a playlist after segment downloads', function() { | 319 | asyncTest('selects a playlist after segment downloads', function() { |
320 | window.XMLHttpRequest = function() { | ||
321 | this.open = function(method, url) { | ||
322 | xhrUrls.push(url); | ||
323 | }; | ||
324 | this.send = function() { | ||
325 | var self = this; | ||
326 | setTimeout(function() { | ||
327 | var manifestName = (/(?:.*\/)?(.*)\.m3u8/).exec(xhrUrls.slice(-1)[0]); | ||
328 | if (manifestName) { | ||
329 | manifestName = manifestName[1]; | ||
330 | } | ||
331 | self.responseText = window.manifests[manifestName || xhrUrls.slice(-1)[0]]; | ||
332 | self.response = new Uint8Array([1]).buffer; | ||
333 | |||
334 | self.readyState = 4; | ||
335 | self.onreadystatechange(); | ||
336 | }, 0); | ||
337 | }; | ||
338 | this.abort = function() {}; | ||
339 | }; | ||
340 | |||
320 | var calls = 0; | 341 | var calls = 0; |
321 | player.hls('manifest/master.m3u8'); | 342 | player.hls('manifest/master.m3u8'); |
322 | player.hls.selectPlaylist = function() { | 343 | player.hls.selectPlaylist = function() { |
323 | calls++; | 344 | calls++; |
345 | strictEqual(calls, 1, 'selects after the initial segment'); | ||
346 | |||
347 | player.hls.selectPlaylist = function() { | ||
348 | calls++; | ||
349 | strictEqual(calls, 2, 'selects after additional segments'); | ||
350 | start(); | ||
351 | return player.hls.master.playlists[0]; | ||
352 | }; | ||
353 | |||
324 | return player.hls.master.playlists[0]; | 354 | return player.hls.master.playlists[0]; |
325 | }; | 355 | }; |
326 | videojs.mediaSources[player.currentSrc()].trigger({ | 356 | videojs.mediaSources[player.currentSrc()].trigger({ |
327 | type: 'sourceopen' | 357 | type: 'sourceopen' |
328 | }); | 358 | }); |
329 | 359 | ||
330 | strictEqual(calls, 1, 'selects after the initial segment'); | ||
331 | player.currentTime = function() { | 360 | player.currentTime = function() { |
332 | return 1; | 361 | return 1; |
333 | }; | 362 | }; |
... | @@ -335,7 +364,6 @@ test('selects a playlist after segment downloads', function() { | ... | @@ -335,7 +364,6 @@ test('selects a playlist after segment downloads', function() { |
335 | return videojs.createTimeRange(0, 2); | 364 | return videojs.createTimeRange(0, 2); |
336 | }; | 365 | }; |
337 | player.trigger('timeupdate'); | 366 | player.trigger('timeupdate'); |
338 | strictEqual(calls, 2, 'selects after additional segments'); | ||
339 | }); | 367 | }); |
340 | 368 | ||
341 | test('moves to the next segment if there is a network error', function() { | 369 | test('moves to the next segment if there is a network error', function() { | ... | ... |
-
Please register or sign in to post a comment