7caf2561 by David LaPalomento

Verify buffer checks occur on init

Add a test case to show that buffer checks begin immediately on setting a new source.
1 parent b0f95038
...@@ -250,7 +250,6 @@ test('re-initializes the playlist loader when switching sources', function() { ...@@ -250,7 +250,6 @@ test('re-initializes the playlist loader when switching sources', function() {
250 ok(requests[0].url.indexOf('master.m3u8') >= 0, 'requested only the new playlist'); 250 ok(requests[0].url.indexOf('master.m3u8') >= 0, 'requested only the new playlist');
251 }); 251 });
252 252
253
254 test('sets the duration if one is available on the playlist', function() { 253 test('sets the duration if one is available on the playlist', function() {
255 var calls = 0; 254 var calls = 0;
256 player.duration = function(value) { 255 player.duration = function(value) {
...@@ -463,6 +462,34 @@ test('dont downshift if bandwidth is low', function() { ...@@ -463,6 +462,34 @@ test('dont downshift if bandwidth is low', function() {
463 'first segment requested'); 462 'first segment requested');
464 }); 463 });
465 464
465 test('starts checking the buffer on init', function() {
466 var player, i, length, callbacks = [], fills = 0, drains = 0;
467 // capture timeouts
468 window.setTimeout = function(callback) {
469 callbacks.push(callback);
470 };
471
472 player = createPlayer();
473 player.hls.fillBuffer = function() {
474 fills++;
475 };
476 player.hls.drainBuffer = function() {
477 drains++;
478 };
479 player.src({
480 src: 'manifest/master.m3u8',
481 type: 'application/vnd.apple.mpegurl'
482 });
483 ok(callbacks.length > 0, 'set timeouts');
484
485 for (i = 0, length = callbacks.length; i < length; i++) {
486 callbacks[i]();
487 }
488 equal(fills, 1, 'called fillBuffer');
489 equal(drains, 1, 'called drainBuffer');
490 player.dispose();
491 });
492
466 test('buffer checks are noops until a media playlist is ready', function() { 493 test('buffer checks are noops until a media playlist is ready', function() {
467 player.src({ 494 player.src({
468 src: 'manifest/media.m3u8', 495 src: 'manifest/media.m3u8',
......