Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated qUnit tests.

  • Loading branch information...
commit 2751be7e0fc3d70c36d5d2d808bb3a2e2bd3b416 1 parent 0f45812
@heff heff authored
Showing with 172 additions and 117 deletions.
  1. +33 −0 Rakefile
  2. +13 −0 dev/source-list.html
  3. +20 −30 test/test.html
  4. +106 −87 test/test.js
View
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
View
13 dev/source-list.html
@@ -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 -->
View
50 test/test.html
@@ -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>
-
- <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>
+ <!-- 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 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>
View
193 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();
-});
-
-// Playing Event
-test("playing", function() {
- this.player.addEvent("playing", _V_.proxy(this, function(){
- start();
- ok(true, "playing");
- }));
- this.player.play();
-});
-
-// 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 playEventList = []
+
+// Test all playback events
+test("Initial Events", 11, function() {
+ stop(); // Give 30 seconds to run then fail.
+
+ 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();
+// });
Please sign in to comment.
Something went wrong with that request. Please try again.