]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#221] 0.1 XML parser unit test
authorScottDowne <sdowne@learn.senecac.on.ca>
Wed, 5 Jan 2011 16:50:53 +0000 (11:50 -0500)
committerScottDowne <sdowne@learn.senecac.on.ca>
Wed, 5 Jan 2011 16:50:53 +0000 (11:50 -0500)
parsers/parserXML/popcorn.parseXML.unit.html [new file with mode: 0644]
parsers/parserXML/popcorn.parseXML.unit.js [new file with mode: 0644]
parsers/parserXML/unit.XML [new file with mode: 0644]

diff --git a/parsers/parserXML/popcorn.parseXML.unit.html b/parsers/parserXML/popcorn.parseXML.unit.html
new file mode 100644 (file)
index 0000000..05a3383
--- /dev/null
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>Popcorn 0.1 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.parseXML.js"></script>
+  <script src="popcorn.parseXML.unit.js"></script>
+</head>
+<body>
+  <h1 id="qunit-header">Popcorn 0.1 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> 
+  <div id="footnotediv"></div>  
+</body>
+</html>
diff --git a/parsers/parserXML/popcorn.parseXML.unit.js b/parsers/parserXML/popcorn.parseXML.unit.js
new file mode 100644 (file)
index 0000000..e0f47ae
--- /dev/null
@@ -0,0 +1,63 @@
+test("Popcorn 0.1 XML Parser Plugin", function () {
+  
+  var expects = 7,
+      count = 0,
+      timeOut = 0,
+      interval,
+      poppercorn = Popcorn( "#video" );
+      
+  function plus() {
+    if ( ++count === expects ) {
+      start();
+      // clean up added events after tests
+      clearInterval( interval );
+    }
+  }
+  
+  expect(expects);
+  
+  stop( 10000 );
+
+  Popcorn.plugin("parserTest1", {
+    
+    start: function ( event, options ) {
+      ok( options.item2 === "item2", "parserTest1 has data directly from manifest" );
+      plus();
+      ok( options.item3 === "item3", "parserTest1 has cascading data from manifest" );
+      plus();
+    },
+    end: function ( event, options ) {}
+  });
+
+  Popcorn.plugin("parserTest2", {
+    
+    start: function ( event, options ) {
+      ok( options.text === "item4", "parserTest2 has text data" );
+      plus();
+      ok( options.item1 === "item1", "parserTest2 has cascading data from parent" );
+      plus();
+    },
+    end: function ( event, options ) {}
+  });
+
+  Popcorn.plugin("parserTest3", {
+    
+    start: function ( event, options ) {
+      ok( options.item1 === "item1", "parserTest3 has cascading data from parent" );
+      plus();
+      ok( options.item2 === "item2", "parserTest3 has data directly from manifest" );
+      plus();
+      ok( options.item3 === "item3", "parserTest3 has cascading data from manifest" );
+      plus();
+    },
+    end: function ( event, options ) {}
+  });
+
+  poppercorn.parseXML("unit.XML");
+
+  // interval used to wait for data to be parsed
+  interval = setInterval( function() {
+    poppercorn.currentTime(5).play().currentTime(6);
+  }, 2000);
+  
+});
diff --git a/parsers/parserXML/unit.XML b/parsers/parserXML/unit.XML
new file mode 100644 (file)
index 0000000..c7efe8c
--- /dev/null
@@ -0,0 +1,21 @@
+<popcorn>
+
+  <manifest>
+
+    <container item3="item3">
+      <somedata id="somedata" item2="item2"/>
+    </container>
+
+  </manifest>
+
+  <timeline>
+    <parserTest1 in="5" out="6" resourceid="somedata"/>
+
+    <container item1="item1">
+      <parserTest2 in="5" out="6">item4</parserTest2>
+      <parserTest3 in="5" out="6" resourceid="somedata"/>
+    </container>
+
+  </timeline>
+
+</popcorn>