]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
added unit tests for mediafragment plugin
authorKarim Hamidou <khamidou@gmail.com>
Tue, 8 Nov 2011 10:27:22 +0000 (11:27 +0100)
committerKarim Hamidou <khamidou@gmail.com>
Tue, 8 Nov 2011 10:27:22 +0000 (11:27 +0100)
plugins/mediafragment/popcorn.mediafragment.unit.html [new file with mode: 0644]
plugins/mediafragment/popcorn.mediafragment.unit.js [new file with mode: 0644]

diff --git a/plugins/mediafragment/popcorn.mediafragment.unit.html b/plugins/mediafragment/popcorn.mediafragment.unit.html
new file mode 100644 (file)
index 0000000..ff07abb
--- /dev/null
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>Popcorn API</title>
+  <link rel="stylesheet" href="../../test/qunit/qunit.css" type="text/css" media="screen">
+  <script src="../../test/qunit/qunit.js"></script>
+  <!--
+    do not move - this must be called immediately prior to
+    popcorn-api-draft.js
+  -->
+
+  <script src="../../popcorn.js"></script>
+  <script src="popcorn.mediafragment.js"></script>
+
+  <script src="popcorn.mediafragment.unit.js"></script>
+</head>
+<body>
+  <h1 id="qunit-header">Popcorn Mediafragment Plugin</h1>
+  <h2 id="qunit-banner"></h2>
+  <div id="qunit-testrunner-toolbar"></div>
+  <h2 id="qunit-userAgent"></h2>
+  <ol id="qunit-tests"></ol>
+  <div id="qunit-fixture">  </div>
+
+  <video id="video"
+    controls preload="none"
+    width="250px"
+    poster="../../test/poster.png">
+
+    <source id="mp4"
+      src="../../test/trailer.mp4"
+      type='video/mp4; codecs="avc1, mp4a"'>
+
+    <source id="ogv"
+      src="../../test/trailer.ogv"
+      type='video/ogg; codecs="theora, vorbis"'>
+      
+    <source id='webm'
+      src="../../test/trailer.webm"
+      type='video/webm; codecs="vp8, vorbis"'>
+
+    <p>Your user agent does not support the HTML5 Video element.</p>
+
+  </video>
+  <div id="footnotediv"></div>
+  <div id="textdiv"></div>
+</body>
+</html>
diff --git a/plugins/mediafragment/popcorn.mediafragment.unit.js b/plugins/mediafragment/popcorn.mediafragment.unit.js
new file mode 100644 (file)
index 0000000..0fff2b3
--- /dev/null
@@ -0,0 +1,53 @@
+test( "Popcorn Footnote Plugin", function() {
+
+  var popped = Popcorn( "#video" ),
+      expects = 3,
+      count = 0;     
+
+  expect( expects );
+
+  function plus() {
+    if ( ++count===expects ) {
+      start();
+    }
+  }
+
+  stop();
+
+  ok( "mediafragment" in popped, "mediafragment is a method of the popped instance" );
+  plus();
+
+  var currstate = window.location.href.split("#t=");
+  equals( currstate[1], undefined, "initially, there is no # in the url" );
+  plus();
+
+  popped.mediafragment({
+    start: 0,   
+  });
+
+  popped.exec( 2, function() {
+    popped.pause();
+    popped.play();
+    
+    
+  });
+
+  popped.exec( 3, function() {
+    var currstate = window.location.href.split("#t=");
+    console.log(currstate);
+    var time = + currstate[1];
+    
+    // popcorn's precision is limited to the second.
+    ok(time >= 2 && time <= 3, "correct time is set" );
+    plus();
+    popped.play();
+  
+  });
+  
+  popped.exec( 4, function() {
+    // clear the address bar
+    window.location.href = window.location.href.split("#t=")[0];
+  });
+  
+  popped.play();
+});
\ No newline at end of file