Fixes of different issues
Video_player_spec wouldn't run because of a syntax error. All test would fail when error() was called on an undefined JQuery object. Tidy up spy on onTouchBaseDevice. Fix dependecies between RequireJs modules
This commit is contained in:
committed by
Alexander Kryklia
parent
47dac695fa
commit
af0149e52a
@@ -1,7 +1,10 @@
|
||||
(function () {
|
||||
describe('VideoAlpha', function () {
|
||||
var oldOTBD;
|
||||
|
||||
beforeEach(function () {
|
||||
jasmine.stubRequests();
|
||||
oldOTBD = window.onTouchBasedDevice;
|
||||
window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false);
|
||||
this.videosDefinition = '0.75:slowerSpeedYoutubeId,1.0:normalSpeedYoutubeId';
|
||||
this.slowerSpeedYoutubeId = 'slowerSpeedYoutubeId';
|
||||
@@ -13,6 +16,7 @@
|
||||
window.onYouTubePlayerAPIReady = undefined;
|
||||
window.onHTML5PlayerAPIReady = undefined;
|
||||
$('source').remove();
|
||||
window.onTouchBasedDevice = oldOTBD;
|
||||
});
|
||||
|
||||
describe('constructor', function () {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(function () {
|
||||
describe('VideoAlpha HTML5Video', function () {
|
||||
var state, player, playbackRates = [0.75, 1.0, 1.25, 1.5];
|
||||
var state, player, oldOTBD, playbackRates = [0.75, 1.0, 1.25, 1.5];
|
||||
|
||||
function initialize() {
|
||||
loadFixtures('videoalpha_html5.html');
|
||||
@@ -9,6 +9,8 @@
|
||||
}
|
||||
|
||||
beforeEach(function () {
|
||||
oldOTBD = window.onTouchBasedDevice;
|
||||
window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false);
|
||||
initialize();
|
||||
player.config.events.onReady = jasmine.createSpy('onReady');
|
||||
});
|
||||
@@ -18,6 +20,7 @@
|
||||
$.fn.scrollTo.reset();
|
||||
$('.subtitles').remove();
|
||||
$('source').remove();
|
||||
window.onTouchBasedDevice = oldOTBD;
|
||||
});
|
||||
|
||||
describe('events:', function () {
|
||||
|
||||
@@ -1,28 +1,7 @@
|
||||
Jasmine JavaScript tests status
|
||||
-------------------------------
|
||||
|
||||
As of 18.07.2013, 12:55, each individual tests file in this directory passes. However,
|
||||
if you try to run all of them at the same time, weird things start to happen. In some
|
||||
cases the browser crashes, in other cases there are failing tests with extremely crazy
|
||||
failing messages.
|
||||
|
||||
I [Valera Rozuvan] believe that this is due to the fact that almost in every file there
|
||||
is present the function initialize() which is invoked many-many-many times throughout
|
||||
the file. With each invocation, initialize() instantiates a new VideoAlpha instance.
|
||||
It shouoldn't be necessary to instantiate a new VideoAlpha instance for each it() test.
|
||||
Many it() tests can be run in sequence on the same VideoAlpha instance - it is just a
|
||||
matter of correctly planning the order in which the it() tests are run.
|
||||
|
||||
So, you can do either:
|
||||
|
||||
a.) Run tests individually, changing in each file the top level "xdescribe(" to
|
||||
"describe(". Make sure that you change it back to "xdescribe(" once you are done.
|
||||
|
||||
b.) Refactor all the VideoAlpha tests so that they can be run all at once.
|
||||
|
||||
Good luck ^_^v (and thanks for all the fish!)
|
||||
|
||||
|
||||
As of 22.07.2013, all the tests in this directory pass. To disable each of them, change the top level "describe(" to "xdescribe(".
|
||||
|
||||
PS: When you are running the tests in chrome locally, make sure that chrome is started
|
||||
with the option "--allow-file-access-from-files".
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(function() {
|
||||
describe('VideoCaptionAlpha', function() {
|
||||
var state, videoPlayer, videoCaption, videoSpeedControl;
|
||||
var state, videoPlayer, videoCaption, videoSpeedControl, oldOTBD;
|
||||
|
||||
function initialize() {
|
||||
loadFixtures('videoalpha_all.html');
|
||||
@@ -11,6 +11,7 @@
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
oldOTBD = window.onTouchBasedDevice;
|
||||
window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false);
|
||||
initialize();
|
||||
});
|
||||
@@ -20,6 +21,7 @@
|
||||
$.fn.scrollTo.reset();
|
||||
$('.subtitles').remove();
|
||||
$('source').remove();
|
||||
window.onTouchBasedDevice = oldOTBD;
|
||||
});
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(function() {
|
||||
describe('VideoControlAlpha', function() {
|
||||
var state, videoControl;
|
||||
var state, videoControl, oldOTBD;
|
||||
|
||||
function initialize() {
|
||||
loadFixtures('videoalpha_all.html');
|
||||
@@ -8,13 +8,18 @@
|
||||
videoControl = state.videoControl;
|
||||
}
|
||||
|
||||
beforeEach(function(){
|
||||
oldOTBD = window.onTouchBasedDevice;
|
||||
window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
$('source').remove();
|
||||
window.onTouchBasedDevice = oldOTBD;
|
||||
});
|
||||
|
||||
describe('constructor', function() {
|
||||
beforeEach(function() {
|
||||
window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false);
|
||||
initialize();
|
||||
});
|
||||
|
||||
@@ -46,10 +51,6 @@
|
||||
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');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(function() {
|
||||
describe('VideoPlayerAlpha', function() {
|
||||
var state, videoPlayer, player, videoControl, videoCaption, videoProgressSlider, videoSpeedControl, videoVolumeControl;
|
||||
var state, videoPlayer, player, videoControl, videoCaption, videoProgressSlider, videoSpeedControl, videoVolumeControl, oldOTBD;
|
||||
|
||||
function initialize(fixture) {
|
||||
if (typeof fixture === 'undefined') {
|
||||
@@ -23,8 +23,14 @@
|
||||
initialize('videoalpha.html');
|
||||
}
|
||||
|
||||
beforeEach(function () {
|
||||
oldOTBD = window.onTouchBasedDevice;
|
||||
window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
$('source').remove();
|
||||
$('source').remove();
|
||||
window.onTouchBasedDevice = oldOTBD;
|
||||
});
|
||||
|
||||
describe('constructor', function() {
|
||||
@@ -68,7 +74,6 @@
|
||||
|
||||
it('create video progress slider', function() {
|
||||
expect(videoProgressSlider).toBeDefined();
|
||||
console.log('videoProgressSlider', videoProgressSlider, state, state.videoControl.sliderEl)
|
||||
expect(videoProgressSlider.el).toHaveClass('slider');
|
||||
});
|
||||
|
||||
@@ -160,22 +165,11 @@
|
||||
// });
|
||||
|
||||
describe('when not on a touch based device', function() {
|
||||
var oldOTBD;
|
||||
|
||||
beforeEach(function() {
|
||||
oldOTBD = window.onTouchBasedDevice;
|
||||
|
||||
window.onTouchBasedDevice = function () {
|
||||
return true;
|
||||
};
|
||||
|
||||
window.onTouchBasedDevice.andReturn(true);
|
||||
initialize();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
window.onTouchBasedDevice = oldOTBD;
|
||||
});
|
||||
|
||||
it('does not add the tooltip to fullscreen button', function() {
|
||||
expect($('.add-fullscreen')).not.toHaveData('qtip');
|
||||
});
|
||||
@@ -190,19 +184,9 @@
|
||||
var oldOTBD;
|
||||
|
||||
beforeEach(function() {
|
||||
oldOTBD = window.onTouchBasedDevice;
|
||||
|
||||
window.onTouchBasedDevice = function () {
|
||||
return false;
|
||||
};
|
||||
|
||||
initialize();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
window.onTouchBasedDevice = oldOTBD;
|
||||
});
|
||||
|
||||
it('add the tooltip to fullscreen button', function() {
|
||||
expect($('.add-fullscreen')).toHaveData('qtip');
|
||||
});
|
||||
@@ -759,7 +743,7 @@
|
||||
|
||||
it('set the player volume', function() {
|
||||
player.setVolume(60);
|
||||
expect(Number(player.getVolume().toFixed(1)).toEqual(0.6);
|
||||
expect(player.getVolume()).toEqual(0.6);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(function() {
|
||||
describe('VideoProgressSliderAlpha', function() {
|
||||
var state, videoPlayer, videoProgressSlider;
|
||||
var state, videoPlayer, videoProgressSlider, oldOTBD;
|
||||
|
||||
function initialize() {
|
||||
loadFixtures('videoalpha_all.html');
|
||||
@@ -10,12 +10,14 @@
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false);
|
||||
oldOTBD = window.onTouchBasedDevice;
|
||||
window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false);
|
||||
});
|
||||
|
||||
|
||||
afterEach(function() {
|
||||
$('source').remove();
|
||||
window.onTouchBasedDevice = oldOTBD;
|
||||
});
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(function() {
|
||||
describe('VideoQualityControlAlpha', function() {
|
||||
var state, videoControl, videoQualityControl;
|
||||
var state, videoControl, videoQualityControl, oldOTBD;
|
||||
|
||||
function initialize() {
|
||||
loadFixtures('videoalpha.html');
|
||||
@@ -9,9 +9,14 @@
|
||||
videoQualityControl = state.videoQualityControl;
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
oldOTBD = window.onTouchBasedDevice;
|
||||
window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
$('source').remove();
|
||||
$('source').remove();
|
||||
window.onTouchBasedDevice = oldOTBD;
|
||||
});
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
@@ -11,12 +11,14 @@
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
oldOTBD = window.onTouchBasedDevice;
|
||||
window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false);
|
||||
});
|
||||
|
||||
|
||||
afterEach(function() {
|
||||
$('source').remove();
|
||||
$('source').remove();
|
||||
window.onTouchBasedDevice = oldOTBD;
|
||||
});
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(function() {
|
||||
describe('VideoVolumeControlAlpha', function() {
|
||||
var state, videoControl, videoVolumeControl;
|
||||
var state, videoControl, videoVolumeControl, oldOTBD;
|
||||
|
||||
function initialize() {
|
||||
loadFixtures('videoalpha_all.html');
|
||||
@@ -9,10 +9,14 @@
|
||||
videoVolumeControl = state.videoVolumeControl;
|
||||
}
|
||||
|
||||
|
||||
beforeEach(function() {
|
||||
oldOTBD = window.onTouchBasedDevice;
|
||||
window.onTouchBasedDevice = jasmine.createSpy('onTouchBasedDevice').andReturn(false);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
$('source').remove();
|
||||
window.onTouchBasedDevice = oldOTBD;
|
||||
});
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
(function (requirejs, require, define) {
|
||||
|
||||
define(
|
||||
'videoalpha/display/initialize.js',
|
||||
['videoalpha/display/video_player.js'],
|
||||
'videoalpha/02_initialize.js',
|
||||
['videoalpha/04_video_player.js'],
|
||||
function (VideoPlayer) {
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
(function (requirejs, require, define) {
|
||||
|
||||
define(
|
||||
'videoalpha/display/html5_video.js',
|
||||
'videoalpha/03_html5_video.js',
|
||||
[],
|
||||
function () {
|
||||
var HTML5Video = {};
|
||||
@@ -67,7 +67,7 @@ function () {
|
||||
if (isNaN(this.video.duration)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return this.video.duration;
|
||||
};
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
// VideoPlayer module.
|
||||
define(
|
||||
'videoalpha/display/video_player.js',
|
||||
['videoalpha/display/html5_video.js'],
|
||||
'videoalpha/04_video_player.js',
|
||||
['videoalpha/03_html5_video.js'],
|
||||
function (HTML5Video) {
|
||||
|
||||
// VideoPlayer() function - what this module "exports".
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// VideoControl module.
|
||||
define(
|
||||
'videoalpha/display/video_control.js',
|
||||
'videoalpha/05_video_control.js',
|
||||
[],
|
||||
function () {
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// VideoQualityControl module.
|
||||
define(
|
||||
'videoalpha/display/video_quality_control.js',
|
||||
'videoalpha/06_video_quality_control.js',
|
||||
[],
|
||||
function () {
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ mind, or whether to act, and in acting, to live."
|
||||
|
||||
// VideoProgressSlider module.
|
||||
define(
|
||||
'videoalpha/display/video_progress_slider.js',
|
||||
'videoalpha/07_video_progress_slider.js',
|
||||
[],
|
||||
function () {
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// VideoVolumeControl module.
|
||||
define(
|
||||
'videoalpha/display/video_volume_control.js',
|
||||
'videoalpha/08_video_volume_control.js',
|
||||
[],
|
||||
function () {
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// VideoSpeedControl module.
|
||||
define(
|
||||
'videoalpha/display/video_speed_control.js',
|
||||
'videoalpha/09_video_speed_control.js',
|
||||
[],
|
||||
function () {
|
||||
|
||||
@@ -44,7 +44,7 @@ function () {
|
||||
state.videoControl.secondaryControlsEl.prepend(state.videoSpeedControl.el);
|
||||
|
||||
$.each(state.videoSpeedControl.speeds, function(index, speed) {
|
||||
|
||||
|
||||
//var link = $('<a href="#">' + speed + 'x</a>');
|
||||
var link = '<a href="#">' + speed + 'x</a>';
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// VideoCaption module.
|
||||
define(
|
||||
'videoalpha/display/video_caption.js',
|
||||
'videoalpha/10_video_caption.js',
|
||||
[],
|
||||
function () {
|
||||
|
||||
@@ -109,11 +109,11 @@ function () {
|
||||
}
|
||||
|
||||
function fetchCaption() {
|
||||
var _this = this;
|
||||
var _this = this, jQueryObject;
|
||||
|
||||
this.videoCaption.hideCaptions(this.hide_captions);
|
||||
|
||||
$.getWithPrefix(this.videoCaption.captionURL(), function(captions) {
|
||||
jQueryObject = $.getWithPrefix(this.videoCaption.captionURL(), function(captions) {
|
||||
_this.videoCaption.captions = captions.text;
|
||||
_this.videoCaption.start = captions.start;
|
||||
_this.videoCaption.loaded = true;
|
||||
@@ -125,8 +125,11 @@ function () {
|
||||
} else {
|
||||
_this.videoCaption.renderCaption();
|
||||
}
|
||||
})
|
||||
.error(function(){console.error('Subtitles not found. Upload subtitles to server!');});
|
||||
});
|
||||
|
||||
if (typeof jQueryObject === 'undefined') {
|
||||
console.error('Subtitles not found. Upload subtitles to server!');
|
||||
}
|
||||
}
|
||||
|
||||
function captionURL() {
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
// Main module.
|
||||
require(
|
||||
[
|
||||
'videoalpha/display/initialize.js',
|
||||
'videoalpha/display/video_control.js',
|
||||
'videoalpha/display/video_quality_control.js',
|
||||
'videoalpha/display/video_progress_slider.js',
|
||||
'videoalpha/display/video_volume_control.js',
|
||||
'videoalpha/display/video_speed_control.js',
|
||||
'videoalpha/display/video_caption.js'
|
||||
'videoalpha/02_initialize.js',
|
||||
'videoalpha/05_video_control.js',
|
||||
'videoalpha/06_video_quality_control.js',
|
||||
'videoalpha/07_video_progress_slider.js',
|
||||
'videoalpha/08_video_volume_control.js',
|
||||
'videoalpha/09_video_speed_control.js',
|
||||
'videoalpha/10_video_caption.js'
|
||||
],
|
||||
function (
|
||||
Initialize,
|
||||
|
||||
Reference in New Issue
Block a user