Skip to content

Commit

Permalink
Merge branch 'main' into feat/append-stats
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey authored May 27, 2021
2 parents 44cda65 + 82b6781 commit 36dfe49
Showing 1 changed file with 34 additions and 30 deletions.
64 changes: 34 additions & 30 deletions test/segment-loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2959,49 +2959,53 @@ QUnit.module('SegmentLoader', function(hooks) {
const logs = [];

return setupMediaSource(loader.mediaSource_, loader.sourceUpdater_, {isVideoOnly: true}).then(() => {
const origAppendToSourceBuffer = loader.appendToSourceBuffer_.bind(loader);

// set the mediaSource duration as it is usually set by
// master playlist controller, which is not present here
loader.mediaSource_.duration = Infinity;

loader.appendToSourceBuffer_ = (config) => {
appends.push(config);
origAppendToSourceBuffer(config);
};

loader.playlist(playlistWithDuration(20));
loader.load();
this.clock.tick(1);
standardXHRResponse(this.requests.shift(), videoSegment());

return new Promise((resolve, reject) => {
loader.one('appended', resolve);
loader.one('error', reject);
});
}).then(() => {
this.clock.tick(1);

assert.equal(appends.length, 1, 'one append');
assert.equal(appends[0].type, 'video', 'appended to video buffer');
assert.ok(appends[0].initSegment, 'appended video init segment');
const origAppendToSourceBuffer = loader.appendToSourceBuffer_.bind(loader);

loader.playlist(playlistWithDuration(20, { uri: 'new-playlist.m3u8' }));
// remove old aborted request
this.requests.shift();
// get the new request
this.clock.tick(1);
loader.chooseNextRequest_ = () => ({partIndex: null, mediaIndex: 1});
loader.logger_ = (line) => {
logs.push(line);
};
standardXHRResponse(this.requests.shift(), videoSegment());
loader.appendToSourceBuffer_ = (config) => {
appends.push(config);
origAppendToSourceBuffer(config);
};

// since it's a sync request, wait for the syncinfoupdate event (we won't get the
// appended event)
loader.playlist(playlistWithDuration(20));
loader.load();
this.clock.tick(1);
standardXHRResponse(this.requests.shift(), videoSegment());

});
}).then(() => {
return new Promise((resolve, reject) => {
loader.one('syncinfoupdate', resolve);
// since it's a sync request, wait for the syncinfoupdate event (we won't get the
// appended event)
this.clock.tick(1);

assert.equal(appends.length, 1, 'one append');
assert.equal(appends[0].type, 'video', 'appended to video buffer');
assert.ok(appends[0].initSegment, 'appended video init segment');

loader.playlist(playlistWithDuration(20, { uri: 'new-playlist.m3u8' }));
// remove old aborted request
this.requests.shift();
// get the new request
this.clock.tick(1);
loader.chooseNextRequest_ = () => ({partIndex: null, mediaIndex: 1});
loader.logger_ = (line) => {
logs.push(line);
};
loader.one('syncinfoupdate', function() {
resolve();
});
loader.one('error', reject);
standardXHRResponse(this.requests.shift(), videoSegment());

});
}).then(() => {
this.clock.tick(1);
Expand Down

0 comments on commit 36dfe49

Please sign in to comment.