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) { ...@@ -45,9 +45,6 @@ module.exports = function(grunt) {
45 dest: 'dist/videojs.hls.min.js' 45 dest: 'dist/videojs.hls.min.js'
46 } 46 }
47 }, 47 },
48 qunit: {
49 files: ['test/**/*.html', '!test/perf.html', '!test/muxer/**']
50 },
51 jshint: { 48 jshint: {
52 gruntfile: { 49 gruntfile: {
53 options: { 50 options: {
...@@ -93,11 +90,11 @@ module.exports = function(grunt) { ...@@ -93,11 +90,11 @@ module.exports = function(grunt) {
93 }, 90 },
94 src: { 91 src: {
95 files: '<%= jshint.src.src %>', 92 files: '<%= jshint.src.src %>',
96 tasks: ['jshint:src', 'qunit'] 93 tasks: ['jshint:src', 'test']
97 }, 94 },
98 test: { 95 test: {
99 files: '<%= jshint.test.src %>', 96 files: '<%= jshint.test.src %>',
100 tasks: ['jshint:test', 'qunit'] 97 tasks: ['jshint:test', 'test']
101 } 98 }
102 }, 99 },
103 concurrent: { 100 concurrent: {
...@@ -194,7 +191,6 @@ module.exports = function(grunt) { ...@@ -194,7 +191,6 @@ module.exports = function(grunt) {
194 grunt.loadNpmTasks('grunt-contrib-clean'); 191 grunt.loadNpmTasks('grunt-contrib-clean');
195 grunt.loadNpmTasks('grunt-contrib-concat'); 192 grunt.loadNpmTasks('grunt-contrib-concat');
196 grunt.loadNpmTasks('grunt-contrib-uglify'); 193 grunt.loadNpmTasks('grunt-contrib-uglify');
197 grunt.loadNpmTasks('grunt-contrib-qunit');
198 grunt.loadNpmTasks('grunt-contrib-jshint'); 194 grunt.loadNpmTasks('grunt-contrib-jshint');
199 grunt.loadNpmTasks('grunt-contrib-watch'); 195 grunt.loadNpmTasks('grunt-contrib-watch');
200 grunt.loadNpmTasks('grunt-contrib-connect'); 196 grunt.loadNpmTasks('grunt-contrib-connect');
...@@ -255,7 +251,7 @@ module.exports = function(grunt) { ...@@ -255,7 +251,7 @@ module.exports = function(grunt) {
255 ['clean', 251 ['clean',
256 'jshint', 252 'jshint',
257 'manifests-to-js', 253 'manifests-to-js',
258 'qunit', 254 'test',
259 'concat', 255 'concat',
260 'uglify']); 256 'uglify']);
261 257
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
19 "grunt-contrib-concat": "~0.3.0", 19 "grunt-contrib-concat": "~0.3.0",
20 "grunt-contrib-connect": "~0.6.0", 20 "grunt-contrib-connect": "~0.6.0",
21 "grunt-contrib-jshint": "~0.6.0", 21 "grunt-contrib-jshint": "~0.6.0",
22 "grunt-contrib-qunit": "~0.2.0",
23 "grunt-contrib-uglify": "~0.2.0", 22 "grunt-contrib-uglify": "~0.2.0",
24 "grunt-contrib-watch": "~0.4.0", 23 "grunt-contrib-watch": "~0.4.0",
25 "grunt-karma": "~0.6.2", 24 "grunt-karma": "~0.6.2",
......
...@@ -378,4 +378,31 @@ ...@@ -378,4 +378,31 @@
378 loader.media('unrecognized.m3u8'); 378 loader.media('unrecognized.m3u8');
379 }, 'throws an error'); 379 }, 'throws an error');
380 }); 380 });
381
382 test('dispose cancels the refresh timeout', function() {
383 var loader = new videojs.Hls.PlaylistLoader('live.m3u8');
384 requests.pop().respond(200, null,
385 '#EXTM3U\n' +
386 '#EXT-X-MEDIA-SEQUENCE:0\n' +
387 '#EXTINF:10,\n' +
388 '0.ts\n');
389 loader.dispose();
390 // a lot of time passes...
391 clock.tick(15 * 1000);
392
393 strictEqual(requests.length, 0, 'no refresh request was made');
394 });
395
396 test('dispose aborts pending refresh requests', function() {
397 var loader = new videojs.Hls.PlaylistLoader('live.m3u8');
398 requests.pop().respond(200, null,
399 '#EXTM3U\n' +
400 '#EXT-X-MEDIA-SEQUENCE:0\n' +
401 '#EXTINF:10,\n' +
402 '0.ts\n');
403 clock.tick(10 * 1000);
404
405 loader.dispose();
406 ok(requests[0].aborted, 'refresh request aborted');
407 });
381 })(window); 408 })(window);
......
...@@ -1140,4 +1140,22 @@ test('does not break if the playlist has no segments', function() { ...@@ -1140,4 +1140,22 @@ test('does not break if the playlist has no segments', function() {
1140 strictEqual(requests.length, 1, 'no requests for non-existent segments were queued'); 1140 strictEqual(requests.length, 1, 'no requests for non-existent segments were queued');
1141 }); 1141 });
1142 1142
1143 test('disposes the playlist loader', function() {
1144 var disposes = 0, player;
1145 player = createPlayer();
1146 player.src({
1147 src: 'manifest/master.m3u8',
1148 type: 'application/vnd.apple.mpegurl'
1149 });
1150 player.hls.mediaSource.trigger({
1151 type: 'sourceopen'
1152 });
1153 player.hls.playlists.dispose = function() {
1154 disposes++;
1155 };
1156
1157 player.dispose();
1158 strictEqual(disposes, 1, 'disposed playlist loader');
1159 });
1160
1143 })(window, window.videojs); 1161 })(window, window.videojs);
......