-
Notifications
You must be signed in to change notification settings - Fork 792
Remove extraneous methods from PlaylistLoader #1286
Changes from 1 commit
0fcca13
cc9ddfc
165bea9
9ae5af6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,8 @@ import { | |
updateMaster, | ||
setupMediaPlaylists, | ||
resolveMediaGroupUris, | ||
refreshDelay | ||
refreshDelay, | ||
isLowestEnabledRendition | ||
} from '../src/playlist-loader'; | ||
import xhrFactory from '../src/xhr'; | ||
import { useFakeEnvironment } from './test-helpers'; | ||
|
@@ -791,6 +792,43 @@ QUnit.test('uses last segment duration for refresh delay', function(assert) { | |
'used half targetDuration when update is false'); | ||
}); | ||
|
||
QUnit.test('isLowestEnabledRendition detects if we are on lowest rendition', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think putting these tests in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. master-playlist-controller.test.js also already has integration tests for isLowestEnabledRendition, so even more reason to convert these to unit tests |
||
function(assert) { | ||
let loader = new PlaylistLoader('master.m3u8', this.fakeHls); | ||
|
||
loader.load(); | ||
this.requests.shift().respond(200, null, | ||
'#EXTM3U\n' + | ||
'#EXT-X-STREAM-INF:BANDWIDTH=1\n' + | ||
'video1/media.m3u8\n' + | ||
'#EXT-X-STREAM-INF:BANDWIDTH=1\n' + | ||
'video2/media.m3u8\n'); | ||
loader.media = function() { | ||
return {attributes: {BANDWIDTH: 10}}; | ||
}; | ||
|
||
loader.master.playlists = [{attributes: {BANDWIDTH: 10}}, | ||
{attributes: {BANDWIDTH: 20}}]; | ||
assert.ok(isLowestEnabledRendition(loader.master, loader.media()), | ||
'Detected on lowest rendition'); | ||
|
||
loader.master.playlists = [{attributes: {BANDWIDTH: 10}}, | ||
{attributes: {BANDWIDTH: 10}}, | ||
{attributes: {BANDWIDTH: 10}}, | ||
{attributes: {BANDWIDTH: 20}}]; | ||
assert.ok(isLowestEnabledRendition(loader.master, loader.media()), | ||
'Detected on lowest rendition'); | ||
|
||
loader.media = function() { | ||
return {attributes: {BANDWIDTH: 20}}; | ||
}; | ||
|
||
loader.master.playlists = [{attributes: {BANDWIDTH: 10}}, | ||
{attributes: {BANDWIDTH: 20}}]; | ||
assert.ok(!isLowestEnabledRendition(loader.master, loader.media()), | ||
'Detected not on lowest rendition'); | ||
}); | ||
|
||
QUnit.test('throws if the playlist url is empty or undefined', function(assert) { | ||
assert.throws(function() { | ||
PlaylistLoader(); | ||
|
@@ -895,57 +933,6 @@ QUnit.test('resolves relative media playlist URIs', function(assert) { | |
'resolved media URI'); | ||
}); | ||
|
||
QUnit.test('playlist loader returns the correct amount of enabled playlists', | ||
function(assert) { | ||
let loader = new PlaylistLoader('master.m3u8', this.fakeHls); | ||
|
||
loader.load(); | ||
|
||
this.requests.shift().respond(200, null, | ||
'#EXTM3U\n' + | ||
'#EXT-X-STREAM-INF:BANDWIDTH=1\n' + | ||
'video1/media.m3u8\n' + | ||
'#EXT-X-STREAM-INF:BANDWIDTH=1\n' + | ||
'video2/media.m3u8\n'); | ||
assert.equal(loader.enabledPlaylists_(), 2, 'Returned initial amount of playlists'); | ||
loader.master.playlists[0].excludeUntil = Date.now() + 100000; | ||
this.clock.tick(1000); | ||
assert.equal(loader.enabledPlaylists_(), 1, 'Returned one less playlist'); | ||
}); | ||
|
||
QUnit.test('playlist loader detects if we are on lowest rendition', function(assert) { | ||
let loader = new PlaylistLoader('master.m3u8', this.fakeHls); | ||
|
||
loader.load(); | ||
this.requests.shift().respond(200, null, | ||
'#EXTM3U\n' + | ||
'#EXT-X-STREAM-INF:BANDWIDTH=1\n' + | ||
'video1/media.m3u8\n' + | ||
'#EXT-X-STREAM-INF:BANDWIDTH=1\n' + | ||
'video2/media.m3u8\n'); | ||
loader.media = function() { | ||
return {attributes: {BANDWIDTH: 10}}; | ||
}; | ||
|
||
loader.master.playlists = [{attributes: {BANDWIDTH: 10}}, | ||
{attributes: {BANDWIDTH: 20}}]; | ||
assert.ok(loader.isLowestEnabledRendition_(), 'Detected on lowest rendition'); | ||
|
||
loader.master.playlists = [{attributes: {BANDWIDTH: 10}}, | ||
{attributes: {BANDWIDTH: 10}}, | ||
{attributes: {BANDWIDTH: 10}}, | ||
{attributes: {BANDWIDTH: 20}}]; | ||
assert.ok(loader.isLowestEnabledRendition_(), 'Detected on lowest rendition'); | ||
|
||
loader.media = function() { | ||
return {attributes: {BANDWIDTH: 20}}; | ||
}; | ||
|
||
loader.master.playlists = [{attributes: {BANDWIDTH: 10}}, | ||
{attributes: {BANDWIDTH: 20}}]; | ||
assert.ok(!loader.isLowestEnabledRendition_(), 'Detected not on lowest rendition'); | ||
}); | ||
|
||
QUnit.test('resolves media initialization segment URIs', function(assert) { | ||
let loader = new PlaylistLoader('video/fmp4.m3u8', this.fakeHls); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,64 @@ import QUnit from 'qunit'; | |
import xhrFactory from '../src/xhr'; | ||
import { useFakeEnvironment } from './test-helpers'; | ||
|
||
QUnit.module('Playlist Status'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is already an entire module of tests for blacklisting and enabled states near the bottom of this file... |
||
|
||
QUnit.test('isBlacklisted returns if a playlist is blacklisted', function(assert) { | ||
assert.ok(!Playlist.isBlacklisted({}), 'not blacklisted if empty object'); | ||
assert.ok(!Playlist.isBlacklisted({ | ||
disabled: true, | ||
enabled: false | ||
}), 'not blacklisted if no excludeUntil'); | ||
assert.ok(!Playlist.isBlacklisted({ | ||
disabled: true, | ||
enabled: false, | ||
uri: 'test-uri', | ||
duration: 4 | ||
}), 'not blacklisted if no excludeUntil'); | ||
assert.ok(!Playlist.isBlacklisted({ | ||
disabled: true, | ||
enabled: false, | ||
uri: 'test-uri', | ||
duration: 4 | ||
}), 'not blacklisted if no excludeUntil'); | ||
assert.ok(!Playlist.isBlacklisted({ | ||
disabled: true, | ||
enabled: false, | ||
uri: 'test-uri', | ||
duration: 4, | ||
excludeUntil: Date.now() | ||
}), 'not blacklisted if excludeUntil is not in future'); | ||
assert.ok(Playlist.isBlacklisted({ | ||
disabled: true, | ||
enabled: false, | ||
uri: 'test-uri', | ||
duration: 4, | ||
excludeUntil: Date.now() + 1 | ||
}), 'blacklisted if excludeUntil is in future'); | ||
}); | ||
|
||
QUnit.test('isEnabled returns if a playlist is enabled', function(assert) { | ||
assert.ok(Playlist.isEnabled({}), 'is enabled if empty object'); | ||
assert.ok(Playlist.isEnabled({ | ||
disabled: false | ||
}), 'is enabled if disabled is false'); | ||
assert.ok(!Playlist.isEnabled({ | ||
disabled: true | ||
}), 'is not enabled if disabled is true'); | ||
assert.ok(Playlist.isEnabled({ | ||
disabled: false, | ||
excludeUntil: Date.now() | ||
}), 'is enabled if not currently blacklisted'); | ||
assert.ok(!Playlist.isEnabled({ | ||
disabled: false, | ||
excludeUntil: Date.now() + 1 | ||
}), 'is not enabled if excludeUntil is in future'); | ||
assert.ok(!Playlist.isEnabled({ | ||
disabled: true, | ||
excludeUntil: Date.now() + 1 | ||
}), 'is not enabled if excludeUntil is in future and disabled'); | ||
}); | ||
|
||
QUnit.module('Playlist Duration'); | ||
|
||
QUnit.test('total duration for live playlists is Infinity', function(assert) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this would make more sense being in the playlist.js file now that its not tied to the playlist-loader instance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. Looks much nicer there 👍