d1695461 by David LaPalomento

Use karma for all tests. Add a tests for dispose()

Get rid of grunt-contrib-qunit because it was inexplicably failing in phantomjs. It's still possible to test in phantom through karma and the tests all pass there. Add test cases for object disposal on the tech and the playlist loader.
1 parent 7429ce71
......@@ -45,9 +45,6 @@ module.exports = function(grunt) {
dest: 'dist/videojs.hls.min.js'
}
},
qunit: {
files: ['test/**/*.html', '!test/perf.html', '!test/muxer/**']
},
jshint: {
gruntfile: {
options: {
......@@ -93,11 +90,11 @@ module.exports = function(grunt) {
},
src: {
files: '<%= jshint.src.src %>',
tasks: ['jshint:src', 'qunit']
tasks: ['jshint:src', 'test']
},
test: {
files: '<%= jshint.test.src %>',
tasks: ['jshint:test', 'qunit']
tasks: ['jshint:test', 'test']
}
},
concurrent: {
......@@ -194,7 +191,6 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
......@@ -255,7 +251,7 @@ module.exports = function(grunt) {
['clean',
'jshint',
'manifests-to-js',
'qunit',
'test',
'concat',
'uglify']);
......
......@@ -19,7 +19,6 @@
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-connect": "~0.6.0",
"grunt-contrib-jshint": "~0.6.0",
"grunt-contrib-qunit": "~0.2.0",
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-watch": "~0.4.0",
"grunt-karma": "~0.6.2",
......
......@@ -378,4 +378,31 @@
loader.media('unrecognized.m3u8');
}, 'throws an error');
});
test('dispose cancels the refresh timeout', function() {
var loader = new videojs.Hls.PlaylistLoader('live.m3u8');
requests.pop().respond(200, null,
'#EXTM3U\n' +
'#EXT-X-MEDIA-SEQUENCE:0\n' +
'#EXTINF:10,\n' +
'0.ts\n');
loader.dispose();
// a lot of time passes...
clock.tick(15 * 1000);
strictEqual(requests.length, 0, 'no refresh request was made');
});
test('dispose aborts pending refresh requests', function() {
var loader = new videojs.Hls.PlaylistLoader('live.m3u8');
requests.pop().respond(200, null,
'#EXTM3U\n' +
'#EXT-X-MEDIA-SEQUENCE:0\n' +
'#EXTINF:10,\n' +
'0.ts\n');
clock.tick(10 * 1000);
loader.dispose();
ok(requests[0].aborted, 'refresh request aborted');
});
})(window);
......
......@@ -1140,4 +1140,22 @@ test('does not break if the playlist has no segments', function() {
strictEqual(requests.length, 1, 'no requests for non-existent segments were queued');
});
test('disposes the playlist loader', function() {
var disposes = 0, player;
player = createPlayer();
player.src({
src: 'manifest/master.m3u8',
type: 'application/vnd.apple.mpegurl'
});
player.hls.mediaSource.trigger({
type: 'sourceopen'
});
player.hls.playlists.dispose = function() {
disposes++;
};
player.dispose();
strictEqual(disposes, 1, 'disposed playlist loader');
});
})(window, window.videojs);
......