Commit 4778c535 by Valera Rozuvan Committed by Vasyl Nakvasiuk

Restructuring Video Alpha Jasmine tests.

Fixing more tests.
Turned on all Video Alpha tests.
More tests fixing.
Turned on all tests.
Fixing more tests.
Worked on tests at the beginning of video_player_spec.js. Not finished
All Video Alpha tests completed and can be run individually. When run individually - they all pass.
Added jasmine_test_runner.html to gitignore.
parent 8c3f4388
test.mp4
test.ogv
test.webm
jasmine_test_runner.html
...@@ -8,7 +8,9 @@ ...@@ -8,7 +8,9 @@
data-show-captions="true" data-show-captions="true"
data-start="" data-start=""
data-end="" data-end=""
data-caption-asset-path="/static/subs/"> data-caption-asset-path="/static/subs/"
data-autoplay="False"
>
<div class="tc-wrapper"> <div class="tc-wrapper">
<article class="video-wrapper"> <article class="video-wrapper">
<div class="video-player-pre"></div> <div class="video-player-pre"></div>
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
data-mp4-source="test.mp4" data-mp4-source="test.mp4"
data-webm-source="test.webm" data-webm-source="test.webm"
data-ogg-source="test.ogv" data-ogg-source="test.ogv"
data-autoplay="False"
> >
<div class="tc-wrapper"> <div class="tc-wrapper">
<article class="video-wrapper"> <article class="video-wrapper">
......
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
data-mp4-source="test.mp4" data-mp4-source="test.mp4"
data-webm-source="test.webm" data-webm-source="test.webm"
data-ogg-source="test.ogv" data-ogg-source="test.ogv"
> data-autoplay="False"
>
<div class="tc-wrapper"> <div class="tc-wrapper">
<article class="video-wrapper"> <article class="video-wrapper">
<section class="video-player"> <section class="video-player">
......
...@@ -8,7 +8,9 @@ ...@@ -8,7 +8,9 @@
data-show-captions="false" data-show-captions="false"
data-start="" data-start=""
data-end="" data-end=""
data-caption-asset-path="/static/subs/"> data-caption-asset-path="/static/subs/"
data-autoplay="False"
>
<div class="tc-wrapper"> <div class="tc-wrapper">
<article class="video-wrapper"> <article class="video-wrapper">
<section class="video-player"> <section class="video-player">
......
...@@ -198,7 +198,7 @@ ...@@ -198,7 +198,7 @@
expect(player.callStateChangeCallback).toHaveBeenCalled(); expect(player.callStateChangeCallback).toHaveBeenCalled();
}); });
}); });
}); // End-of: describe('events:', function () { });
describe('methods', function () { describe('methods', function () {
var volume, seek, duration, playbackRate; var volume, seek, duration, playbackRate;
...@@ -318,6 +318,6 @@ ...@@ -318,6 +318,6 @@
it('getAvailablePlaybackRates', function () { it('getAvailablePlaybackRates', function () {
expect(player.getAvailablePlaybackRates()).toEqual(playbackRates); expect(player.getAvailablePlaybackRates()).toEqual(playbackRates);
}); });
}); // End-of: describe('methods', function () { });
}); });
}).call(this); }).call(this);
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!)
PS: When you are running the tests in chrome locally, make sure that chrome is started
with the option "--allow-file-access-from-files".
PPS: Don't forget to place test video files (test.mp4, test.ogv, test.webm) into the
folder "common/lib/xmodule". You can get these from http://www.quirksmode.org/html5/tests/video.html
or from some other site that demonstrates HTML5 video playback. Just open up the site's
source, and save the video files (make sure to rname them to "test.*").
...@@ -346,13 +346,13 @@ ...@@ -346,13 +346,13 @@
}); });
it('set the height of caption container', function() { it('set the height of caption container', function() {
expect(parseInt($('.subtitles').css('maxHeight'))).toBeCloseTo($('.video-wrapper').height(), 2); expect(parseInt($('.subtitles').css('maxHeight'), 10)).toBeCloseTo($('.video-wrapper').height(), 2);
}); });
it('set the height of caption spacing', function() { it('set the height of caption spacing', function() {
var firstSpacing, lastSpacing; var firstSpacing, lastSpacing;
firstSpacing = Math.abs(parseInt($('.subtitles .spacing:first').css('height'))); firstSpacing = Math.abs(parseInt($('.subtitles .spacing:first').css('height'), 10));
lastSpacing = Math.abs(parseInt($('.subtitles .spacing:last').css('height'))); lastSpacing = Math.abs(parseInt($('.subtitles .spacing:last').css('height'), 10));
expect(firstSpacing - videoCaption.topSpacingHeight()).toBeLessThan(1); expect(firstSpacing - videoCaption.topSpacingHeight()).toBeLessThan(1);
expect(lastSpacing - videoCaption.bottomSpacingHeight()).toBeLessThan(1); expect(lastSpacing - videoCaption.bottomSpacingHeight()).toBeLessThan(1);
}); });
...@@ -404,7 +404,7 @@ ...@@ -404,7 +404,7 @@
// Check for calledWith(parameters) for some reason fails... // Check for calledWith(parameters) for some reason fails...
// //
// var offset = -0.5 * ($('.video-wrapper').height() - $('.subtitles .current:first').height()); // var offset = -0.5 * ($('.video-wrapper').height() - $('.subtitles .current:first').height());
// //
// expect($.fn.scrollTo).toHaveBeenCalledWith( // expect($.fn.scrollTo).toHaveBeenCalledWith(
// $('.subtitles .current:first', videoCaption.el), // $('.subtitles .current:first', videoCaption.el),
// { // {
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
it('render the video controls', function() { it('render the video controls', function() {
expect($('.video-controls')).toContain( expect($('.video-controls')).toContain(
['.slider', 'ul.vcr', 'a.play', '.vidtime', '.add-fullscreen'].join(',') ['.slider', 'ul.vcr', 'a.play', '.vidtime', '.add-fullscreen'].join(',')
); //Should we add '.quality_control' and '.hide-subtitles'? );
expect($('.video-controls').find('.vidtime')).toHaveText('0:00 / 0:00'); expect($('.video-controls').find('.vidtime')).toHaveText('0:00 / 0:00');
}); });
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
}); });
describe('when the slider was already built', function() { describe('when the slider was already built', function() {
var spy; var spy;
beforeEach(function() { beforeEach(function() {
spy = spyOn(videoProgressSlider, 'buildSlider'); spy = spyOn(videoProgressSlider, 'buildSlider');
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
// videoProgressSlider.slider = null; // videoProgressSlider.slider = null;
// videoPlayer.play(); // videoPlayer.play();
// }); // });
//
// it('build the slider', function() { // it('build the slider', function() {
// expect(videoProgressSlider.slider).toBe('.slider'); // expect(videoProgressSlider.slider).toBe('.slider');
// expect($.fn.slider).toHaveBeenCalledWith({ // expect($.fn.slider).toHaveBeenCalledWith({
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
// stop: videoProgressSlider.onStop // stop: videoProgressSlider.onStop
// }); // });
// }); // });
//
// it('build the seek handle', function() { // it('build the seek handle', function() {
// expect(videoProgressSlider.handle).toBe('.ui-slider-handle'); // expect(videoProgressSlider.handle).toBe('.ui-slider-handle');
// expect($.fn.qtip).toHaveBeenCalledWith({ // expect($.fn.qtip).toHaveBeenCalledWith({
...@@ -142,7 +142,7 @@ ...@@ -142,7 +142,7 @@
expect($.fn.slider).not.toHaveBeenCalled(); expect($.fn.slider).not.toHaveBeenCalled();
}); });
}); });
describe('when not frozen', function() { describe('when not frozen', function() {
beforeEach(function() { beforeEach(function() {
spyOn($.fn, 'slider').andCallThrough(); spyOn($.fn, 'slider').andCallThrough();
...@@ -160,7 +160,6 @@ ...@@ -160,7 +160,6 @@
}); });
}); });
//TODO Fails: Problem with data-sub
describe('onSlide', function() { describe('onSlide', function() {
beforeEach(function() { beforeEach(function() {
initialize(); initialize();
...@@ -184,7 +183,6 @@ ...@@ -184,7 +183,6 @@
expect(videoPlayer.currentTime).toEqual(20); expect(videoPlayer.currentTime).toEqual(20);
}); });
}); });
//End Fails
describe('onChange', function() { describe('onChange', function() {
beforeEach(function() { beforeEach(function() {
...@@ -199,7 +197,6 @@ ...@@ -199,7 +197,6 @@
}); });
}); });
//TODO Fails: Problem with data-sub
describe('onStop', function() { describe('onStop', function() {
beforeEach(function() { beforeEach(function() {
initialize(); initialize();
...@@ -224,15 +221,14 @@ ...@@ -224,15 +221,14 @@
expect(videoProgressSlider.frozen).toBeFalsy(); expect(videoProgressSlider.frozen).toBeFalsy();
}); });
}); });
//End Fails
describe('updateTooltip', function() { describe('updateTooltip', function() {
beforeEach(function() { beforeEach(function() {
initialize(); initialize();
spyOn($.fn, 'slider').andCallThrough(); spyOn($.fn, 'slider').andCallThrough();
videoProgressSlider.updateTooltip(90); videoProgressSlider.updateTooltip(90);
}); });
it('set the tooltip value', function() { it('set the tooltip value', function() {
expect($.fn.qtip).toHaveBeenCalledWith('option', 'content.text', '1:30'); expect($.fn.qtip).toHaveBeenCalledWith('option', 'content.text', '1:30');
}); });
......
(function() {
xdescribe('VideoQualityControlAlpha', function() {
var state, videoControl, videoQualityControl;
function initialize() {
loadFixtures('videoalpha.html');
state = new VideoAlpha('#example');
videoControl = state.videoControl;
videoQualityControl = state.videoQualityControl;
}
describe('constructor', function() {
beforeEach(function() {
initialize();
});
it('render the quality control', function() {
expect(videoControl.secondaryControlsEl.html()).toContain("<a href=\"#\" class=\"quality_control\" title=\"HD\">");
});
it('bind the quality control', function() {
expect($('.quality_control')).toHandleWith('click', videoQualityControl.toggleQuality);
});
});
});
}).call(this);
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
expect($('.speeds')).not.toHaveClass('open'); expect($('.speeds')).not.toHaveClass('open');
}); });
}); });
describe('when running on non-touch based device', function() { describe('when running on non-touch based device', function() {
beforeEach(function() { beforeEach(function() {
initialize(); initialize();
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
// expect(videoPlayer.onSpeedChange).not.toHaveBeenCalled(); // expect(videoPlayer.onSpeedChange).not.toHaveBeenCalled();
// }); // });
// }); // });
describe('when new speed is not the same', function() { describe('when new speed is not the same', function() {
beforeEach(function() { beforeEach(function() {
initialize(); initialize();
...@@ -112,14 +112,14 @@ ...@@ -112,14 +112,14 @@
}); });
}); });
}); });
describe('onSpeedChange', function() { describe('onSpeedChange', function() {
beforeEach(function() { beforeEach(function() {
initialize(); initialize();
$('li[data-speed="1.0"] a').addClass('active'); $('li[data-speed="1.0"] a').addClass('active');
videoSpeedControl.setSpeed(0.75); videoSpeedControl.setSpeed(0.75);
}); });
it('set the new speed as active', function() { it('set the new speed as active', function() {
expect($('.video_speeds li[data-speed="1.0"]')).not.toHaveClass('active'); expect($('.video_speeds li[data-speed="1.0"]')).not.toHaveClass('active');
expect($('.video_speeds li[data-speed="0.75"]')).toHaveClass('active'); expect($('.video_speeds li[data-speed="0.75"]')).toHaveClass('active');
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
}); });
it('render the volume control', function() { it('render the volume control', function() {
expect(videoControl.secondaryControlsEl.html()).toContain("<div class=\"volume\">\n"); //toContain("<div class=\"volume\">\n <a href=\"#\"></a>\n <div class=\"volume-slider-container\">\n <div class=\"volume-slider\"></div>\n </div>\n</div>"); expect(videoControl.secondaryControlsEl.html()).toContain("<div class=\"volume\">\n");
}); });
it('create the slider', function() { it('create the slider', function() {
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
range: "min", range: "min",
min: 0, min: 0,
max: 100, max: 100,
value: 100, /* value: 100, */
value: videoVolumeControl.currentVolume, value: videoVolumeControl.currentVolume,
change: videoVolumeControl.onChange, change: videoVolumeControl.onChange,
slide: videoVolumeControl.onChange slide: videoVolumeControl.onChange
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
}); });
}); });
}); });
describe('toggleMute', function() { describe('toggleMute', function() {
beforeEach(function() { beforeEach(function() {
initialize(); initialize();
...@@ -103,14 +103,14 @@ ...@@ -103,14 +103,14 @@
expect(videoVolumeControl.currentVolume).toEqual(0); expect(videoVolumeControl.currentVolume).toEqual(0);
}); });
}); });
describe('when the current volume is 0', function() { describe('when the current volume is 0', function() {
beforeEach(function() { beforeEach(function() {
videoVolumeControl.currentVolume = 0; videoVolumeControl.currentVolume = 0;
videoVolumeControl.previousVolume = 60; videoVolumeControl.previousVolume = 60;
videoVolumeControl.buttonEl.trigger('click'); videoVolumeControl.buttonEl.trigger('click');
}); });
it('set the player volume to previous volume', function() { it('set the player volume to previous volume', function() {
expect(videoVolumeControl.currentVolume).toEqual(60); expect(videoVolumeControl.currentVolume).toEqual(60);
}); });
......
...@@ -72,3 +72,9 @@ if (!Array.prototype.indexOf) { ...@@ -72,3 +72,9 @@ if (!Array.prototype.indexOf) {
return -1; return -1;
} }
} }
if (!window.onTouchBasedDevice) {
window.onTouchBasedDevice = function() {
return navigator.userAgent.match(/iPhone|iPod|iPad/i);
};
}
...@@ -253,6 +253,10 @@ function (HTML5Video) { ...@@ -253,6 +253,10 @@ function (HTML5Video) {
function onEnded() { function onEnded() {
this.trigger(['videoControl','pause'], null); this.trigger(['videoControl','pause'], null);
if (this.config.show_captions) {
this.trigger(['videoCaption','pause'], null);
}
} }
function onPause() { function onPause() {
...@@ -267,6 +271,10 @@ function (HTML5Video) { ...@@ -267,6 +271,10 @@ function (HTML5Video) {
delete this.videoPlayer.updateInterval; delete this.videoPlayer.updateInterval;
this.trigger(['videoControl','pause'], null); this.trigger(['videoControl','pause'], null);
if (this.config.show_captions) {
this.trigger(['videoCaption','pause'], null);
}
} }
function onPlay() { function onPlay() {
...@@ -282,6 +290,10 @@ function (HTML5Video) { ...@@ -282,6 +290,10 @@ function (HTML5Video) {
} }
this.trigger(['videoControl','play'], null); this.trigger(['videoControl','play'], null);
if (this.config.show_captions) {
this.trigger(['videoCaption','play'], null);
}
} }
function onUnstarted() { } function onUnstarted() { }
...@@ -334,7 +346,7 @@ function (HTML5Video) { ...@@ -334,7 +346,7 @@ function (HTML5Video) {
this.videoPlayer.player.setPlaybackRate(this.speed); this.videoPlayer.player.setPlaybackRate(this.speed);
} }
if (!onTouchBasedDevice() && $('.video:first').data('autoplay') === 'True') { if (!onTouchBasedDevice() && $('.videoalpha:first').data('autoplay') === 'True') {
this.videoPlayer.play(); this.videoPlayer.play();
} }
} }
......
...@@ -13,7 +13,8 @@ the course, section, subsection, unit, etc. ...@@ -13,7 +13,8 @@ the course, section, subsection, unit, etc.
""" """
from xmodule.videoalpha_module import VideoAlphaDescriptor from xmodule.videoalpha_module import VideoAlphaDescriptor
from . import LogicTest, etree from . import LogicTest
from lxml import etree
class VideoAlphaModuleTest(LogicTest): class VideoAlphaModuleTest(LogicTest):
......
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