]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#357] lowerthird plugin tests
authorScottDowne <sdowne@learn.senecac.on.ca>
Sun, 10 Apr 2011 00:45:06 +0000 (20:45 -0400)
committerScottDowne <sdowne@learn.senecac.on.ca>
Sun, 10 Apr 2011 00:45:06 +0000 (20:45 -0400)
plugins/lowerthird/popcorn.lowerthird.unit.html [new file with mode: 0644]
plugins/lowerthird/popcorn.lowerthird.unit.js [new file with mode: 0644]

diff --git a/plugins/lowerthird/popcorn.lowerthird.unit.html b/plugins/lowerthird/popcorn.lowerthird.unit.html
new file mode 100644 (file)
index 0000000..c409b2b
--- /dev/null
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>Popcorn Lower Third Plug-in Test</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.lowerthird.js"></script>
+  <script src="popcorn.lowerthird.unit.js"></script>
+</head>
+<body>
+  <h1 id="qunit-header">Popcorn Lower Third 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"'> 
+
+    <p>Your user agent does not support the HTML5 Video element.</p> 
+
+  </video>
+  <div id="lowerthirddiv"></div>
+</body>
+</html>
diff --git a/plugins/lowerthird/popcorn.lowerthird.unit.js b/plugins/lowerthird/popcorn.lowerthird.unit.js
new file mode 100644 (file)
index 0000000..50d3bf3
--- /dev/null
@@ -0,0 +1,64 @@
+test( "Popcorn lower third Plugin", function () {
+  
+  var popped = Popcorn( "#video" ),
+      expects = 7, 
+      count = 0,
+      lowerthirddiv = document.getElementById( "lowerthirddiv" );
+
+  expect(expects);
+  
+  function plus() {
+    if ( ++count===expects ) {
+      start();
+    }
+  }
+  
+  stop();
+   
+  ok ( "lowerthird" in popped, "lowerthird is a method of the popped instance" );
+  plus();
+  
+  equals ( lowerthirddiv.innerHTML, "", "initially, there is nothing inside the lowerthirddiv" );
+  plus();
+
+  ok( !popped.container, "initially, there is no default div" );
+  plus();
+  
+  
+  popped.lowerthird({
+      start: 0, // seconds
+      end: 5, // seconds
+      salutation: "Mr",
+      name: "Hyde",
+      role: "Monster"
+    } )
+    .lowerthird({
+      start: 3, // seconds
+      end: 10, // seconds
+      target: "lowerthirddiv",
+      salutation: "Dr",
+      name: "Jekyll",
+      role: "Person"
+    } )
+    .volume(0);
+    
+  popped.exec( 1, function() {
+    equals ( popped.container.innerHTML, "Mr Hyde<br>Monster", "first lowerthird is visible" );
+    plus();
+  });
+  
+  popped.exec( 4, function() {
+    equals ( lowerthirddiv.innerHTML, "Dr Jekyll<br>Person", "second lowerthird is visible" );
+    plus();
+  });
+  
+  popped.exec( 11, function() {
+    equals ( popped.container.innerHTML, "", "first lowerthird is empty" );
+    plus();
+    equals ( lowerthirddiv.innerHTML, "", "second lowerthird is empty" );
+    plus();
+  });
+  
+  popped.play();
+
+});
\ No newline at end of file