Browse Source

test: speedup the playback integration tests using playbackRate (#565)

pull/571/head
Brandon Casey 6 years ago
committed by GitHub
parent
commit
2111bed695
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 88
      test/playback.test.js
  2. 7
      test/videojs-http-streaming.test.js
  3. 4
      test/vtt-segment-loader.test.js

88
test/playback.test.js

@ -3,48 +3,80 @@ import videojs from 'video.js';
import document from 'global/document';
import '../src/videojs-http-streaming';
let when = function(element, type, cb, condition) {
element.on(type, function func() {
if (condition()) {
element.off(type, func);
cb();
const playFor = function(player, time, cb) {
if (player.paused()) {
const playPromise = player.play();
// Catch/silence error when a pause interrupts a play request
// on browsers which return a promise
if (typeof playPromise !== 'undefined' && typeof playPromise.then === 'function') {
playPromise.then(null, (e) => {});
}
});
};
let playFor = function(player, time, cb) {
}
let targetTime = player.currentTime() + time;
when(player, 'timeupdate', cb, () => player.currentTime() >= targetTime);
const checkPlayerTime = function() {
window.setTimeout(() => {
if (player.currentTime() <= targetTime) {
return checkPlayerTime();
}
cb();
}, 10);
};
checkPlayerTime();
};
QUnit.module('Playback', {
before(assert) {
this.fixture = document.createElement('div');
document.body.appendChild(this.fixture);
},
beforeEach(assert) {
assert.timeout(50000);
this.fixture = document.getElementById('qunit-fixture');
let done = assert.async();
let video = document.createElement('video-js');
// uncomment these lines when deugging
// videojs.log.level('debug');
video.style = 'display: none;';
// this.fixture.style = 'position: inherit;';
video.setAttribute('controls', '');
video.setAttribute('muted', '');
video.width = 600;
video.height = 300;
video.defaultPlaybackRate = 16;
this.fixture.appendChild(video);
this.player = videojs(video, {
muted: true,
autoplay: 'muted'
});
this.player.ready(done);
this.player = videojs(video);
this.player.ready(done, true);
},
afterEach() {
this.player.dispose();
}
});
QUnit.test('Advanced Bip Bop default speed', function(assert) {
let done = assert.async();
this.player.defaultPlaybackRate(1);
assert.expect(2);
let player = this.player;
playFor(player, 2, function() {
assert.ok(true, 'played for at least two seconds');
assert.equal(player.error(), null, 'has no player errors');
done();
});
player.src({
src: 'https://s3.amazonaws.com/_bc_dml/example-content/bipbop-advanced/bipbop_16x9_variant.m3u8',
type: 'application/x-mpegURL'
});
});
QUnit.test('Advanced Bip Bop', function(assert) {
let done = assert.async();
@ -106,7 +138,7 @@ QUnit.test('playlist with fmp4 segments', function(assert) {
});
player.src({
src: 'https://storage.googleapis.com/shaka-demo-assets/angel-one-hls/hls.m3u8',
src: 'https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_adv_example_hevc/master.m3u8',
type: 'application/x-mpegURL'
});
});
@ -226,19 +258,11 @@ QUnit.test('DASH sidx with alt audio should end', function(assert) {
/* eslint-disable max-nested-callbacks */
playFor(player, 1, () => {
player.currentTime(18);
// switch audio playlist
player.audioTracks()[1].enabled = true;
playFor(player, 1, () => {
player.currentTime(25);
playFor(player, 1, () => {
// switch audio playlist
player.audioTracks()[1].enabled = true;
playFor(player, 1, () => {
player.currentTime(player.duration() - 5);
});
});
player.currentTime(player.duration() - 5);
});
});
/* eslint-enable max-nested-callbacks */

7
test/videojs-http-streaming.test.js

@ -4119,6 +4119,7 @@ QUnit.skip('detects fullscreen and triggers a smooth quality change', function(a
Events.trigger(document, 'fullscreenchange');
assert.equal(qualityChanges, 1, 'did not make another quality change');
hls.dispose();
});
QUnit.test('downloads additional playlists if required', function(assert) {
@ -4169,6 +4170,7 @@ QUnit.test('downloads additional playlists if required', function(assert) {
// verify stats
assert.equal(hls.stats.bandwidth, 3000000, 'updated bandwidth');
hls.dispose();
});
});
@ -4220,6 +4222,7 @@ QUnit.test('waits to download new segments until the media playlist is stable',
// verify stats
assert.equal(hls.stats.bandwidth, Infinity, 'bandwidth is set to infinity');
hls.dispose();
});
});
@ -4260,6 +4263,7 @@ QUnit.test('live playlist starts three target durations before live', function(a
hls.seekable().end(0),
'seeked to the seekable end');
assert.equal(this.requests.length, 1, 'begins buffering');
hls.dispose();
});
QUnit.test('uses user defined selectPlaylist from HlsHandler if specified',
@ -4284,6 +4288,8 @@ function(assert) {
HlsHandler.prototype.selectPlaylist = newSelectPlaylist;
hls.dispose();
hls = HlsSourceHandler.handleSource({
src: 'manifest/master.m3u8',
type: 'application/vnd.apple.mpegurl'
@ -4306,6 +4312,7 @@ function(assert) {
Hls.STANDARD_PLAYLIST_SELECTOR = origStandardPlaylistSelector;
delete HlsHandler.prototype.selectPlaylist;
hls.dispose();
});
QUnit.module('HLS - Encryption', {

4
test/vtt-segment-loader.test.js

@ -64,6 +64,10 @@ QUnit.module('VTTSegmentLoader', function(hooks) {
this.track = new MockTextTrack();
});
nestedHooks.afterEach(function(assert) {
loader.dispose();
});
QUnit.test('load waits until a playlist and track are specified to proceed',
function(assert) {
loader.load();

Loading…
Cancel
Save