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 () {
xdescribe('VideoAlpha', function () {
describe('VideoAlpha', function () {
beforeEach(function () {
jasmine.stubRequests();
window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false);
......@@ -12,6 +12,7 @@
window.OldVideoPlayerAlpha = undefined;
window.onYouTubePlayerAPIReady = undefined;
window.onHTML5PlayerAPIReady = undefined;
$('source').remove();
});
describe('constructor', function () {
......
(function () {
xdescribe('VideoAlpha HTML5Video', function () {
describe('VideoAlpha HTML5Video', function () {
var state, player, playbackRates = [0.75, 1.0, 1.25, 1.5];
function initialize() {
......@@ -13,6 +13,13 @@
player.config.events.onReady = jasmine.createSpy('onReady');
});
afterEach(function() {
YT.Player = void 0;
$.fn.scrollTo.reset();
$('.subtitles').remove();
$('source').remove();
});
describe('events:', function () {
beforeEach(function () {
spyOn(player, 'callStateChangeCallback').andCallThrough();
......
(function() {
xdescribe('VideoCaptionAlpha', function() {
describe('VideoCaptionAlpha', function() {
var state, videoPlayer, videoCaption, videoSpeedControl;
function initialize() {
......@@ -11,14 +11,15 @@
}
beforeEach(function() {
initialize();
window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false);
initialize();
});
afterEach(function() {
YT.Player = void 0;
$.fn.scrollTo.reset();
$('.subtitles').remove();
$('source').remove();
});
describe('constructor', function() {
......@@ -117,7 +118,7 @@
describe('mouse movement', function() {
beforeEach(function() {
initialize();
//initialize();
window.setTimeout.andReturn(100);
spyOn(window, 'clearTimeout');
});
......@@ -209,7 +210,7 @@
describe('search', function() {
beforeEach(function() {
initialize();
//initialize();
});
it('return a correct caption index', function() {
......@@ -264,7 +265,7 @@
describe('pause', function() {
beforeEach(function() {
initialize();
//initialize();
videoCaption.playing = true;
videoCaption.pause();
});
......@@ -275,9 +276,9 @@
});
describe('updatePlayTime', function() {
beforeEach(function() {
/*beforeEach(function() {
initialize();
});
});*/
describe('when the video speed is 1.0x', function() {
beforeEach(function() {
......@@ -421,7 +422,7 @@
describe('seekPlayer', function() {
describe('when the video speed is 1.0x', function() {
beforeEach(function() {
initialize();
//initialize();
videoSpeedControl.currentSpeed = '1.0';
$('.subtitles li[data-start="14910"]').trigger('click');
});
......
(function() {
xdescribe('VideoControlAlpha', function() {
describe('VideoControlAlpha', function() {
var state, videoControl;
function initialize() {
......@@ -8,6 +8,10 @@
videoControl = state.videoControl;
}
afterEach(function() {
$('source').remove();
});
describe('constructor', function() {
beforeEach(function() {
window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false);
......@@ -42,6 +46,10 @@
initialize();
});
afterEach(function(){
window.onTouchBasedDevice.andReturn(false);
});
it('does not add the play class to video control', function() {
expect($('.video_control')).not.toHaveClass('play');
expect($('.video_control')).not.toHaveAttr('title', 'Play');
......
(function() {
xdescribe('VideoPlayerAlpha', function() {
describe('VideoPlayerAlpha', function() {
var state, videoPlayer, player, videoControl, videoCaption, videoProgressSlider, videoSpeedControl, videoVolumeControl;
function initialize(fixture) {
......@@ -23,6 +23,10 @@
initialize('videoalpha.html');
}
afterEach(function() {
$('source').remove();
});
describe('constructor', function() {
beforeEach(function() {
$.fn.qtip.andCallFake(function() {
......@@ -64,6 +68,7 @@
it('create video progress slider', function() {
expect(videoProgressSlider).toBeDefined();
console.log('videoProgressSlider', videoProgressSlider, state, state.videoControl.sliderEl)
expect(videoProgressSlider.el).toHaveClass('slider');
});
......@@ -754,7 +759,7 @@
it('set the player volume', function() {
player.setVolume(60);
expect(player.getVolume()).toEqual(0.6);
expect(Number(player.getVolume().toFixed(1)).toEqual(0.6);
});
});
});
......
(function() {
xdescribe('VideoProgressSliderAlpha', function() {
describe('VideoProgressSliderAlpha', function() {
var state, videoPlayer, videoProgressSlider;
function initialize() {
......@@ -13,6 +13,11 @@
window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false);
});
afterEach(function() {
$('source').remove();
});
describe('constructor', function() {
describe('on a non-touch based device', function() {
beforeEach(function() {
......
(function() {
xdescribe('VideoQualityControlAlpha', function() {
describe('VideoQualityControlAlpha', function() {
var state, videoControl, videoQualityControl;
function initialize() {
......@@ -9,6 +9,11 @@
videoQualityControl = state.videoQualityControl;
}
afterEach(function() {
$('source').remove();
});
describe('constructor', function() {
beforeEach(function() {
initialize();
......
(function() {
xdescribe('VideoSpeedControlAlpha', function() {
describe('VideoSpeedControlAlpha', function() {
var state, videoPlayer, videoControl, videoSpeedControl;
function initialize() {
......@@ -14,6 +14,11 @@
window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false);
});
afterEach(function() {
$('source').remove();
});
describe('constructor', function() {
describe('always', function() {
beforeEach(function() {
......
(function() {
xdescribe('VideoVolumeControlAlpha', function() {
describe('VideoVolumeControlAlpha', function() {
var state, videoControl, videoVolumeControl;
function initialize() {
......@@ -9,6 +9,12 @@
videoVolumeControl = state.videoVolumeControl;
}
afterEach(function() {
$('source').remove();
});
describe('constructor', function() {
beforeEach(function() {
spyOn($.fn, 'slider').andCallThrough();
......
......@@ -125,7 +125,8 @@ function () {
} else {
_this.videoCaption.renderCaption();
}
});
})
.error(function(){console.error('Subtitles not found. Upload subtitles to server!');});
}
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