f91ca616 by Gary Katsevman

Add upshift and downshift tests

1 parent 91a1a861
...@@ -368,7 +368,7 @@ test('downloads media playlists after loading the master', function() { ...@@ -368,7 +368,7 @@ test('downloads media playlists after loading the master', function() {
368 'first segment requested'); 368 'first segment requested');
369 }); 369 });
370 370
371 test('downloads a second media playlist before playback, if bandwidth is high', function() { 371 test('upshift if initial bandwidth is high', function() {
372 player.src({ 372 player.src({
373 src: 'manifest/master.m3u8', 373 src: 'manifest/master.m3u8',
374 type: 'application/vnd.apple.mpegurl' 374 type: 'application/vnd.apple.mpegurl'
...@@ -378,11 +378,12 @@ test('downloads a second media playlist before playback, if bandwidth is high', ...@@ -378,11 +378,12 @@ test('downloads a second media playlist before playback, if bandwidth is high',
378 standardXHRResponse(requests[0]); 378 standardXHRResponse(requests[0]);
379 379
380 player.hls.playlists.setBandwidth = function() { 380 player.hls.playlists.setBandwidth = function() {
381 player.hls.playlists.bandwidth = 100000; 381 player.hls.playlists.bandwidth = 1000000000;
382 }; 382 };
383 383
384 standardXHRResponse(requests[1]); 384 standardXHRResponse(requests[1]);
385 standardXHRResponse(requests[2]); 385 standardXHRResponse(requests[2]);
386
386 standardXHRResponse(requests[3]); 387 standardXHRResponse(requests[3]);
387 388
388 strictEqual(requests[0].url, 'manifest/master.m3u8', 'master playlist requested'); 389 strictEqual(requests[0].url, 'manifest/master.m3u8', 'master playlist requested');
...@@ -394,13 +395,49 @@ test('downloads a second media playlist before playback, if bandwidth is high', ...@@ -394,13 +395,49 @@ test('downloads a second media playlist before playback, if bandwidth is high',
394 strictEqual(requests[2].url, 395 strictEqual(requests[2].url,
395 window.location.origin + 396 window.location.origin +
396 window.location.pathname.split('/').slice(0, -1).join('/') + 397 window.location.pathname.split('/').slice(0, -1).join('/') +
397 '/manifest/media1.m3u8', 398 '/manifest/media3.m3u8',
398 'media playlist requested'); 399 'media playlist requested');
399 strictEqual(requests[3].url, 400 strictEqual(requests[3].url,
400 window.location.origin + 401 window.location.origin +
401 window.location.pathname.split('/').slice(0, -1).join('/') + 402 window.location.pathname.split('/').slice(0, -1).join('/') +
402 '/manifest/media1-00001.ts', 403 '/manifest/media3-00001.ts',
404 'first segment requested');
405 });
406
407 test('dont downshift if bandwidth is low', function() {
408 player.src({
409 src: 'manifest/master.m3u8',
410 type: 'application/vnd.apple.mpegurl'
411 });
412 openMediaSource(player);
413
414 standardXHRResponse(requests[0]);
415
416 player.hls.playlists.setBandwidth = function() {
417 player.hls.playlists.bandwidth = 100;
418 };
419
420 standardXHRResponse(requests[1]);
421 standardXHRResponse(requests[2]);
422
423 standardXHRResponse(requests[3]);
424
425 strictEqual(requests[0].url, 'manifest/master.m3u8', 'master playlist requested');
426 strictEqual(requests[1].url,
427 window.location.origin +
428 window.location.pathname.split('/').slice(0, -1).join('/') +
429 '/manifest/media.m3u8',
430 'media playlist requested');
431 strictEqual(requests[2].url,
432 window.location.origin +
433 window.location.pathname.split('/').slice(0, -1).join('/') +
434 '/manifest/media-00001.ts',
403 'first segment requested'); 435 'first segment requested');
436 strictEqual(requests[3].url,
437 window.location.origin +
438 window.location.pathname.split('/').slice(0, -1).join('/') +
439 '/manifest/media1.m3u8',
440 'media playlist requested');
404 }); 441 });
405 442
406 test('timeupdates do not check to fill the buffer until a media playlist is ready', function() { 443 test('timeupdates do not check to fill the buffer until a media playlist is ready', function() {
......