]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
Demo, unit test done [#289]
authorstevenaw <sweerdenburg@gmail.com>
Tue, 25 Jan 2011 20:58:24 +0000 (15:58 -0500)
committerstevenaw <sweerdenburg@gmail.com>
Tue, 25 Jan 2011 20:58:24 +0000 (15:58 -0500)
parsers/parserTTXT/popcorn.parseTTXT.html
parsers/parserTTXT/popcorn.parseTTXT.unit.html [new file with mode: 0644]
parsers/parserTTXT/popcorn.parseTTXT.unit.js [new file with mode: 0644]

index e65d66948ba6957bb302c58a3cf0cd64636b5469..53a7faad5be23585b59c173173d5f4650fe6afc0 100644 (file)
@@ -1,17 +1,16 @@
 <!DOCTYPE html>
 <html>
 <head>
-  <title>Popcorn 0.1 parser Plug-in Demo</title>
+  <title>Popcorn 0.3 TTXT parser Plug-in Demo</title>
   
   <script src="../../popcorn.js"></script>
-  <script src="../../test/jquery.js"></script>
   <script src="../../plugins/subtitle/popcorn.subtitle.js"></script>
   <script src="popcorn.parseTTXT.js"></script>
 
 </head>
 <body>
-  <h1 id="qunit-header">Popcorn 0.1 parser Plug-in Demo</h1>
-  <p></p>
+  <h1 id="qunit-header">Popcorn 0.3 TTXT parser Plug-in Demo</h1>
+  <p>Subtitles are processed from <a href="data/data.TTXT">here</a></p>
   <div>
     <video id='video' data-timeline-sources="data/data.TTXT"
       controls
@@ -30,8 +29,6 @@
 
     </video> 
   </div>
-  
-  <div id="flickrdiv"></div>
 
 </body>
 </html>
diff --git a/parsers/parserTTXT/popcorn.parseTTXT.unit.html b/parsers/parserTTXT/popcorn.parseTTXT.unit.html
new file mode 100644 (file)
index 0000000..f2eb31c
--- /dev/null
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>Popcorn 0.3 TTXT parser 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.parseTTXT.js"></script>
+  <script src="../../plugins/subtitle/popcorn.subtitle.js"></script>
+  <script src="popcorn.parseTTXT.unit.js"></script>
+</head>
+<body>
+  <h1 id="qunit-header">Popcorn 0.3 TTXT parser Plug-in Test</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
+    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>
+</body>
+</html>
diff --git a/parsers/parserTTXT/popcorn.parseTTXT.unit.js b/parsers/parserTTXT/popcorn.parseTTXT.unit.js
new file mode 100644 (file)
index 0000000..2beb5ae
--- /dev/null
@@ -0,0 +1,47 @@
+test("Popcorn 0.3 TTXT Parser Plugin", function () {
+  
+  var expects = 8,
+      count = 0,
+      key,
+      numSubs = 0,
+      poppercorn = Popcorn( "#video" ),
+      subs = { // Expected values
+        "0": "",
+        "3": "[Background Music Playing]",
+        "6": "",
+        "16": "Heay!!",
+        "18": "",
+        "26": "[Bird noises]",
+        "31": ""
+        }
+      };
+      
+  function plus() {
+    if ( ++count === expects ) {
+      start();
+    }
+  }
+  
+  poppercorn.parseTTXT("data/data.ttxt");
+  
+  expect(expects);
+  
+  stop( 10000 );
+
+  // Allow load time
+  setTimeout(function () {
+    Popcorn.forEach(poppercorn.getTrackEvents(), function(evt) {
+      if(evt._natives.type === "subtitle") {
+        numSubs++;
+        key = Math.ceil(evt.start).toString();
+        equals(subs[key],  evt.text , "Correct amounts" );
+        plus();
+      }
+    });
+    
+    equals(7, numSubs , "Correctly parsed all subs" );
+    plus();
+
+  }, 1500);
+  
+});