mirror of
https://github.com/videojs/video.js.git
synced 2024-12-25 02:42:10 +02:00
Updated qUnit tests.
This commit is contained in:
parent
0f45812b71
commit
2751be7e0f
33
Rakefile
33
Rakefile
@ -135,6 +135,39 @@ namespace :build do
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
desc "Build list of source files for easy inclusion in projects"
|
||||
task :source_html do
|
||||
|
||||
File.open("dev/source-list.html", "w+") do |file|
|
||||
file.puts "<!-- Video.js Source Files -->"
|
||||
|
||||
src_array = ["src/core", "src/lib"]
|
||||
last = ["src/setup"] # "flash/swfobject",
|
||||
exclude = [".", "..", ".DS_Store", "_end.js", "_begin.js"]
|
||||
|
||||
Dir.foreach('src') do |item|
|
||||
next if exclude.include? item
|
||||
|
||||
item_name = "src/" << item.sub(".js", "")
|
||||
|
||||
next if (src_array + last).include? item_name
|
||||
|
||||
src_array << item_name
|
||||
end
|
||||
|
||||
src_array = src_array + last
|
||||
|
||||
src_array.each do |item|
|
||||
file.puts "<script src='#{item}.js'></script>"
|
||||
end
|
||||
# file.puts "vjsSourceList.push('src/#{item.sub(".js", "")}')"
|
||||
# file.puts "vjsSourceList.push('flash/swfobject.js')"
|
||||
|
||||
file.puts "<!-- END Video.js Source Files -->"
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
13
dev/source-list.html
Normal file
13
dev/source-list.html
Normal file
@ -0,0 +1,13 @@
|
||||
<!-- Video.js Source Files -->
|
||||
<script src='src/core.js'></script>
|
||||
<script src='src/lib.js'></script>
|
||||
<script src='src/component.js'></script>
|
||||
<script src='src/controls.js'></script>
|
||||
<script src='src/ecma.js'></script>
|
||||
<script src='src/events.js'></script>
|
||||
<script src='src/json.js'></script>
|
||||
<script src='src/player.js'></script>
|
||||
<script src='src/tech.js'></script>
|
||||
<script src='src/tracks.js'></script>
|
||||
<script src='src/setup.js'></script>
|
||||
<!-- END Video.js Source Files -->
|
@ -5,41 +5,31 @@
|
||||
<title>QUnit Test Suite</title>
|
||||
|
||||
<link rel="stylesheet" href="../design/video-js.css" type="text/css">
|
||||
<!--[if lt IE 9]>
|
||||
<script>
|
||||
document.createElement("video"); // HTML5 Shiv. Must be in <head>.
|
||||
</script>
|
||||
<![endif]-->
|
||||
|
||||
<!--[if IE]>
|
||||
<script src="https://getfirebug.com/firebug-lite.js" type="text/javascript" charset="utf-8"></script>
|
||||
<![endif]-->
|
||||
|
||||
<script src="../src/core.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="../src/lib.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="../src/ecma.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="../src/json.js" type="text/javascript" charset="utf-8"></script>
|
||||
<!-- Video.js Source Files -->
|
||||
<script src='../src/core.js'></script>
|
||||
<script src='../src/lib.js'></script>
|
||||
<script src='../src/component.js'></script>
|
||||
<script src='../src/controls.js'></script>
|
||||
<script src='../src/ecma.js'></script>
|
||||
<script src='../src/events.js'></script>
|
||||
<script src='../src/json.js'></script>
|
||||
<script src='../src/player.js'></script>
|
||||
<script src='../src/tech.js'></script>
|
||||
<script src='../src/tracks.js'></script>
|
||||
<script src='../src/setup.js'></script>
|
||||
<!-- END Video.js Source Files -->
|
||||
|
||||
<script src="../src/api.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="../src/events.js" type="text/javascript" charset="utf-8"></script>
|
||||
|
||||
<script src="../src/tracks.js" type="text/javascript" charset="utf-8"></script>
|
||||
|
||||
<script src="../src/behaviors/behaviors.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="../src/behaviors/seekBar.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="../src/behaviors/volume.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="../src/behaviors/texttrackdisplays.js" type="text/javascript" charset="utf-8"></script>
|
||||
|
||||
<script src="../src/controls/bigPlay.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="../src/controls/bar.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="../src/controls/subtitlesBox.js" type="text/javascript" charset="utf-8"></script>
|
||||
|
||||
<script src="../src/tech/html5.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="../src/tech/flowplayer.js" type="text/javascript" charset="utf-8"></script>
|
||||
|
||||
<script src="../src/autoload.js" type="text/javascript" charset="utf-8"></script>
|
||||
|
||||
<script src="../src/log.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
// Easy access to test Flash over HTML5. Add ?flash to URL
|
||||
if (window.location.href.indexOf("?flash") !== -1) {
|
||||
_V_.options.techOrder = ["flash"]
|
||||
}
|
||||
</script>
|
||||
|
||||
<link rel="stylesheet" href="qunit/qunit/qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="qunit/qunit/qunit.js"></script>
|
||||
|
189
test/test.js
189
test/test.js
@ -1,8 +1,13 @@
|
||||
var tagCode = '<video id="vid1" class="video-js vjs-default-skin" preload="none" width="640" height="264" data-setup=\'{}\' poster="http://video-js.zencoder.com/oceans-clip.png">';
|
||||
|
||||
// Potential Future automation
|
||||
// https://github.com/mcrmfc/qunit_sauce_runner
|
||||
// http://saucelabs.com/blog/index.php/2011/06/javascript-unit-testing-with-jellyfish-and-ondemand/
|
||||
// https://github.com/admc/jellyfish/blob/master/test/fun/jfqunit.js
|
||||
|
||||
var tagCode = '<video id="vid1" controls class="video-js vjs-default-skin" preload="none" width="640" height="264" data-setup=\'{}\' poster="http://video-js.zencoder.com/oceans-clip.png">';
|
||||
tagCode+= '<source src="http://video-js.zencoder.com/oceans-clip.mp4" type="video/mp4">';
|
||||
tagCode+= '<source src="http://video-js.zencoder.com/oceans-clip.webm" type="video/webm">';
|
||||
tagCode+= '<source src="http://video-js.zencoder.com/oceans-clip.ogv" type="video/ogg; codecs=\'theora, vorbis\'">';
|
||||
tagCode+= '<track kind="subtitles" src="http://videojs.com/subtitles/demo-subtitles.srt" srclang="en-US" label="English"></track>';
|
||||
tagCode+= '</video>';
|
||||
|
||||
function playerSetup(){
|
||||
@ -17,11 +22,11 @@ function playerSetup(){
|
||||
}
|
||||
|
||||
function playerTeardown(){
|
||||
_V_("vid1").destroy();
|
||||
document.body.removeChild(document.getElementById("vid1"));
|
||||
ok(!document.getElementById("vid1"), "torndown");
|
||||
}
|
||||
|
||||
module("video.js setup", {
|
||||
module("Video.js setup", {
|
||||
setup: playerSetup,
|
||||
teardown: playerTeardown
|
||||
});
|
||||
@ -37,45 +42,59 @@ module("API Events", {
|
||||
teardown: playerTeardown
|
||||
});
|
||||
|
||||
// Play Event
|
||||
test("play", function() {
|
||||
this.player.addEvent("play", _V_.proxy(this, function(){
|
||||
start();
|
||||
ok(true);
|
||||
}));
|
||||
this.player.play();
|
||||
});
|
||||
var playEventList = []
|
||||
|
||||
// Playing Event
|
||||
test("playing", function() {
|
||||
this.player.addEvent("playing", _V_.proxy(this, function(){
|
||||
start();
|
||||
ok(true, "playing");
|
||||
}));
|
||||
this.player.play();
|
||||
});
|
||||
// Test all playback events
|
||||
test("Initial Events", 11, function() {
|
||||
stop(); // Give 30 seconds to run then fail.
|
||||
|
||||
// Pause Event
|
||||
test("pause", function() {
|
||||
this.player.addEvent("pause", _V_.proxy(this, function(){
|
||||
start();
|
||||
ok(true);
|
||||
}));
|
||||
this.player.addEvent("playing", _V_.proxy(this, function(){
|
||||
this.player.pause();
|
||||
}));
|
||||
this.player.play();
|
||||
});
|
||||
var events = [
|
||||
// "loadstart" // Called during setup
|
||||
"play",
|
||||
"playing",
|
||||
|
||||
"durationchange",
|
||||
"loadedmetadata",
|
||||
"loadeddata",
|
||||
|
||||
"progress",
|
||||
"timeupdate",
|
||||
|
||||
"canplay",
|
||||
"canplaythrough",
|
||||
|
||||
"pause",
|
||||
"ended"
|
||||
];
|
||||
|
||||
// Add an event listener for each event type.
|
||||
for (var i=0, l=events.length; i<l; i++) {
|
||||
var evt = events[i];
|
||||
|
||||
// Bind player and event name to function so event name value doesn't get overwritten.
|
||||
this.player.one(evt, _V_.proxy({ player: this.player, evt: evt }, function(){
|
||||
ok(true, this.evt);
|
||||
|
||||
// Once we reach canplaythrough, pause the video and wait for 'paused'.
|
||||
if (this.evt == "canplaythrough") {
|
||||
this.player.pause();
|
||||
|
||||
// After we've paused, go to the end of the video and wait for 'ended'.
|
||||
} else if (this.evt == "pause") {
|
||||
this.player.currentTime(this.player.duration() - 1);
|
||||
|
||||
// Flash has an issue calling play too quickly after currentTime. Hopefully we'll fix this.
|
||||
setTimeout(this.player.proxy(function(){
|
||||
this.play();
|
||||
}), 250);
|
||||
|
||||
// When we reach ended, we're done. Continue with the test suite.
|
||||
} else if (this.evt == "ended") {
|
||||
start();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
// Pause Event
|
||||
test("timeupdate", function() {
|
||||
this.player.addEvent("timeupdate", _V_.proxy(this, function(){
|
||||
start();
|
||||
ok(true);
|
||||
}));
|
||||
this.player.addEvent("playing", _V_.proxy(this, function(){
|
||||
this.player.pause();
|
||||
}));
|
||||
this.player.play();
|
||||
});
|
||||
|
||||
@ -107,48 +126,48 @@ test("pause()", function() {
|
||||
this.player.play();
|
||||
});
|
||||
|
||||
test("currentTime()", function() {
|
||||
|
||||
// Need video loaded before we can call current time
|
||||
this.player.addEvent("loadstart", _V_.proxy(this, function(){
|
||||
start();
|
||||
ok(true, "vid loading");
|
||||
|
||||
// Watch for timeudpate
|
||||
this.player.addEvent("timeupdate", _V_.proxy(this, function(){
|
||||
start();
|
||||
equal(this.player.currentTime(), 0, "time is 0");
|
||||
this.player.removeEvent("timeupdate", arguments.callee);
|
||||
|
||||
// Test again for later time
|
||||
this.player.addEvent("timeupdate", _V_.proxy(this, function(){
|
||||
start();
|
||||
notEqual(this.player.currentTime(), 0, "time is not 0");
|
||||
this.player.removeEvent("timeupdate", arguments.callee);
|
||||
}));
|
||||
// Stop and trigger time
|
||||
stop();
|
||||
this.player.currentTime(10);
|
||||
|
||||
}));
|
||||
// Stop and trigger time
|
||||
stop();
|
||||
this.player.currentTime(0);
|
||||
|
||||
}));
|
||||
|
||||
stop();
|
||||
this.player.load();
|
||||
|
||||
|
||||
|
||||
// Watch for timeudpate
|
||||
this.player.addEvent("timeupdate", _V_.proxy(this, function(){
|
||||
start();
|
||||
notEqual(this.player.currentTime(), 0, "time is not 0");
|
||||
this.player.removeEvent("timeupdate", arguments.callee);
|
||||
}));
|
||||
// Stop and trigger time
|
||||
stop();
|
||||
this.player.load();
|
||||
});
|
||||
// test("currentTime()", function() {
|
||||
//
|
||||
// // Need video loaded before we can call current time
|
||||
// this.player.addEvent("loadstart", _V_.proxy(this, function(){
|
||||
// start();
|
||||
// ok(true, "vid loading");
|
||||
//
|
||||
// // Watch for timeudpate
|
||||
// this.player.addEvent("timeupdate", _V_.proxy(this, function(){
|
||||
// start();
|
||||
// equal(this.player.currentTime(), 0, "time is 0");
|
||||
// this.player.removeEvent("timeupdate", arguments.callee);
|
||||
//
|
||||
// // Test again for later time
|
||||
// this.player.addEvent("timeupdate", _V_.proxy(this, function(){
|
||||
// start();
|
||||
// notEqual(this.player.currentTime(), 0, "time is not 0");
|
||||
// this.player.removeEvent("timeupdate", arguments.callee);
|
||||
// }));
|
||||
// // Stop and trigger time
|
||||
// stop();
|
||||
// this.player.currentTime(10);
|
||||
//
|
||||
// }));
|
||||
// // Stop and trigger time
|
||||
// stop();
|
||||
// this.player.currentTime(0);
|
||||
//
|
||||
// }));
|
||||
//
|
||||
// stop();
|
||||
// this.player.load();
|
||||
//
|
||||
//
|
||||
//
|
||||
// // Watch for timeudpate
|
||||
// this.player.addEvent("timeupdate", _V_.proxy(this, function(){
|
||||
// start();
|
||||
// notEqual(this.player.currentTime(), 0, "time is not 0");
|
||||
// this.player.removeEvent("timeupdate", arguments.callee);
|
||||
// }));
|
||||
// // Stop and trigger time
|
||||
// stop();
|
||||
// this.player.load();
|
||||
// });
|
Loading…
Reference in New Issue
Block a user