Commit 47dac695 by jmclaus Committed by Alexander Kryklia

Reduces the number of calls to initialize() in video_caption_spec.

All the tests run and pass when enabled.
Only video_player has issues left
Adds error logging to console if captions not found
Fix problems with memory leaks
parent 4778c535
(function () { (function () {
xdescribe('VideoAlpha', function () { describe('VideoAlpha', function () {
beforeEach(function () { beforeEach(function () {
jasmine.stubRequests(); jasmine.stubRequests();
window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false); window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false);
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
window.OldVideoPlayerAlpha = undefined; window.OldVideoPlayerAlpha = undefined;
window.onYouTubePlayerAPIReady = undefined; window.onYouTubePlayerAPIReady = undefined;
window.onHTML5PlayerAPIReady = undefined; window.onHTML5PlayerAPIReady = undefined;
$('source').remove();
}); });
describe('constructor', function () { describe('constructor', function () {
......
(function () { (function () {
xdescribe('VideoAlpha HTML5Video', function () { describe('VideoAlpha HTML5Video', function () {
var state, player, playbackRates = [0.75, 1.0, 1.25, 1.5]; var state, player, playbackRates = [0.75, 1.0, 1.25, 1.5];
function initialize() { function initialize() {
...@@ -13,6 +13,13 @@ ...@@ -13,6 +13,13 @@
player.config.events.onReady = jasmine.createSpy('onReady'); player.config.events.onReady = jasmine.createSpy('onReady');
}); });
afterEach(function() {
YT.Player = void 0;
$.fn.scrollTo.reset();
$('.subtitles').remove();
$('source').remove();
});
describe('events:', function () { describe('events:', function () {
beforeEach(function () { beforeEach(function () {
spyOn(player, 'callStateChangeCallback').andCallThrough(); spyOn(player, 'callStateChangeCallback').andCallThrough();
......
(function() { (function() {
xdescribe('VideoCaptionAlpha', function() { describe('VideoCaptionAlpha', function() {
var state, videoPlayer, videoCaption, videoSpeedControl; var state, videoPlayer, videoCaption, videoSpeedControl;
function initialize() { function initialize() {
...@@ -11,14 +11,15 @@ ...@@ -11,14 +11,15 @@
} }
beforeEach(function() { beforeEach(function() {
initialize();
window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false); window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false);
initialize();
}); });
afterEach(function() { afterEach(function() {
YT.Player = void 0; YT.Player = void 0;
$.fn.scrollTo.reset(); $.fn.scrollTo.reset();
$('.subtitles').remove(); $('.subtitles').remove();
$('source').remove();
}); });
describe('constructor', function() { describe('constructor', function() {
...@@ -117,7 +118,7 @@ ...@@ -117,7 +118,7 @@
describe('mouse movement', function() { describe('mouse movement', function() {
beforeEach(function() { beforeEach(function() {
initialize(); //initialize();
window.setTimeout.andReturn(100); window.setTimeout.andReturn(100);
spyOn(window, 'clearTimeout'); spyOn(window, 'clearTimeout');
}); });
...@@ -209,7 +210,7 @@ ...@@ -209,7 +210,7 @@
describe('search', function() { describe('search', function() {
beforeEach(function() { beforeEach(function() {
initialize(); //initialize();
}); });
it('return a correct caption index', function() { it('return a correct caption index', function() {
...@@ -264,7 +265,7 @@ ...@@ -264,7 +265,7 @@
describe('pause', function() { describe('pause', function() {
beforeEach(function() { beforeEach(function() {
initialize(); //initialize();
videoCaption.playing = true; videoCaption.playing = true;
videoCaption.pause(); videoCaption.pause();
}); });
...@@ -275,9 +276,9 @@ ...@@ -275,9 +276,9 @@
}); });
describe('updatePlayTime', function() { describe('updatePlayTime', function() {
beforeEach(function() { /*beforeEach(function() {
initialize(); initialize();
}); });*/
describe('when the video speed is 1.0x', function() { describe('when the video speed is 1.0x', function() {
beforeEach(function() { beforeEach(function() {
...@@ -421,7 +422,7 @@ ...@@ -421,7 +422,7 @@
describe('seekPlayer', function() { describe('seekPlayer', function() {
describe('when the video speed is 1.0x', function() { describe('when the video speed is 1.0x', function() {
beforeEach(function() { beforeEach(function() {
initialize(); //initialize();
videoSpeedControl.currentSpeed = '1.0'; videoSpeedControl.currentSpeed = '1.0';
$('.subtitles li[data-start="14910"]').trigger('click'); $('.subtitles li[data-start="14910"]').trigger('click');
}); });
......
(function() { (function() {
xdescribe('VideoControlAlpha', function() { describe('VideoControlAlpha', function() {
var state, videoControl; var state, videoControl;
function initialize() { function initialize() {
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
videoControl = state.videoControl; videoControl = state.videoControl;
} }
afterEach(function() {
$('source').remove();
});
describe('constructor', function() { describe('constructor', function() {
beforeEach(function() { beforeEach(function() {
window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false); window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false);
...@@ -42,6 +46,10 @@ ...@@ -42,6 +46,10 @@
initialize(); initialize();
}); });
afterEach(function(){
window.onTouchBasedDevice.andReturn(false);
});
it('does not add the play class to video control', function() { it('does not add the play class to video control', function() {
expect($('.video_control')).not.toHaveClass('play'); expect($('.video_control')).not.toHaveClass('play');
expect($('.video_control')).not.toHaveAttr('title', 'Play'); expect($('.video_control')).not.toHaveAttr('title', 'Play');
......
(function() { (function() {
xdescribe('VideoPlayerAlpha', function() { describe('VideoPlayerAlpha', function() {
var state, videoPlayer, player, videoControl, videoCaption, videoProgressSlider, videoSpeedControl, videoVolumeControl; var state, videoPlayer, player, videoControl, videoCaption, videoProgressSlider, videoSpeedControl, videoVolumeControl;
function initialize(fixture) { function initialize(fixture) {
...@@ -23,6 +23,10 @@ ...@@ -23,6 +23,10 @@
initialize('videoalpha.html'); initialize('videoalpha.html');
} }
afterEach(function() {
$('source').remove();
});
describe('constructor', function() { describe('constructor', function() {
beforeEach(function() { beforeEach(function() {
$.fn.qtip.andCallFake(function() { $.fn.qtip.andCallFake(function() {
...@@ -64,6 +68,7 @@ ...@@ -64,6 +68,7 @@
it('create video progress slider', function() { it('create video progress slider', function() {
expect(videoProgressSlider).toBeDefined(); expect(videoProgressSlider).toBeDefined();
console.log('videoProgressSlider', videoProgressSlider, state, state.videoControl.sliderEl)
expect(videoProgressSlider.el).toHaveClass('slider'); expect(videoProgressSlider.el).toHaveClass('slider');
}); });
...@@ -754,7 +759,7 @@ ...@@ -754,7 +759,7 @@
it('set the player volume', function() { it('set the player volume', function() {
player.setVolume(60); player.setVolume(60);
expect(player.getVolume()).toEqual(0.6); expect(Number(player.getVolume().toFixed(1)).toEqual(0.6);
}); });
}); });
}); });
......
(function() { (function() {
xdescribe('VideoProgressSliderAlpha', function() { describe('VideoProgressSliderAlpha', function() {
var state, videoPlayer, videoProgressSlider; var state, videoPlayer, videoProgressSlider;
function initialize() { function initialize() {
...@@ -13,6 +13,11 @@ ...@@ -13,6 +13,11 @@
window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false); window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false);
}); });
afterEach(function() {
$('source').remove();
});
describe('constructor', function() { describe('constructor', function() {
describe('on a non-touch based device', function() { describe('on a non-touch based device', function() {
beforeEach(function() { beforeEach(function() {
......
(function() { (function() {
xdescribe('VideoQualityControlAlpha', function() { describe('VideoQualityControlAlpha', function() {
var state, videoControl, videoQualityControl; var state, videoControl, videoQualityControl;
function initialize() { function initialize() {
...@@ -9,6 +9,11 @@ ...@@ -9,6 +9,11 @@
videoQualityControl = state.videoQualityControl; videoQualityControl = state.videoQualityControl;
} }
afterEach(function() {
$('source').remove();
});
describe('constructor', function() { describe('constructor', function() {
beforeEach(function() { beforeEach(function() {
initialize(); initialize();
......
(function() { (function() {
xdescribe('VideoSpeedControlAlpha', function() { describe('VideoSpeedControlAlpha', function() {
var state, videoPlayer, videoControl, videoSpeedControl; var state, videoPlayer, videoControl, videoSpeedControl;
function initialize() { function initialize() {
...@@ -14,6 +14,11 @@ ...@@ -14,6 +14,11 @@
window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false); window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false);
}); });
afterEach(function() {
$('source').remove();
});
describe('constructor', function() { describe('constructor', function() {
describe('always', function() { describe('always', function() {
beforeEach(function() { beforeEach(function() {
......
(function() { (function() {
xdescribe('VideoVolumeControlAlpha', function() { describe('VideoVolumeControlAlpha', function() {
var state, videoControl, videoVolumeControl; var state, videoControl, videoVolumeControl;
function initialize() { function initialize() {
...@@ -9,6 +9,12 @@ ...@@ -9,6 +9,12 @@
videoVolumeControl = state.videoVolumeControl; videoVolumeControl = state.videoVolumeControl;
} }
afterEach(function() {
$('source').remove();
});
describe('constructor', function() { describe('constructor', function() {
beforeEach(function() { beforeEach(function() {
spyOn($.fn, 'slider').andCallThrough(); spyOn($.fn, 'slider').andCallThrough();
......
...@@ -125,7 +125,8 @@ function () { ...@@ -125,7 +125,8 @@ function () {
} else { } else {
_this.videoCaption.renderCaption(); _this.videoCaption.renderCaption();
} }
}); })
.error(function(){console.error('Subtitles not found. Upload subtitles to server!');});
} }
function captionURL() { function captionURL() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment