--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Popcorn Subtitle 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="http://google.com/jsapi"></script>
+ <script>google.load("language", "1");</script>
+ <script src="popcorn.subtitle.js"></script>
+
+ <script src="popcorn.subtitle.unit.js"></script>
+</head>
+<body>
+ <h1 id="qunit-header">Popcorn Subtitle 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>
+ <h2>Choose your language</h2>
+ <select id="language">
+ <option value="en" selected="selected">English</option>
+ </select>
+ <div>
+ with help from <a href="http://google.com/translate">Google Translate</a><br />
+ <input type="checkbox" id="accessibility" checked="checked" />All subtitles (accessibility)
+ </div>
+</body>
+</html>
--- /dev/null
+test("Popcorn Subtitle Plugin", function () {
+
+ var popped = Popcorn("#video"),
+ expects = 5,
+ count = 0,
+ interval,
+ interval2,
+ interval3,
+ interval4,
+ subtitlediv;
+
+ expect(expects);
+
+ function plus() {
+ if ( ++count===expects) {
+ start();
+ }
+ }
+
+ stop();
+
+ ok ('subtitle' in popped, "subtitle is a method of the popped instance");
+ plus();
+
+ popped.subtitle({
+ start: 3,
+ text: 'this is the first subtitle of 2011',
+ language: "en",
+ languagesrc: "language",
+ accessibilitysrc: "accessibility"
+ } )
+ .subtitle({
+ start: 10,
+ end: 15,
+ text: 'this is the second subtitle of 2011',
+ language: "en",
+ languagesrc: "language",
+ accessibilitysrc: "accessibility"
+ } )
+ .subtitle({
+ start: 20,
+ text: 'this is the third subtitle of 2011',
+ language: "en",
+ languagesrc: "language",
+ accessibilitysrc: "accessibility"
+ } )
+ .volume(0)
+ .play();
+
+ interval = setInterval( function() {
+ if( popped.currentTime() >= 3 && popped.currentTime() < 10 ) {
+ subtitlediv = document.getElementById('subtitlediv'); // this div has only now been created
+ equals (subtitlediv.innerHTML, "this is the first subtitle of 2011", "subtitle displaying correct information" );
+ plus();
+ clearInterval( interval );
+ }
+ }, 500);
+
+ interval2 = setInterval( function() {
+ if( popped.currentTime() >= 10 && popped.currentTime() < 15 ) {
+ equals (subtitlediv.innerHTML, "this is the second subtitle of 2011", "subtitle displaying correct information" );
+ plus();
+ clearInterval( interval2 );
+ }
+ }, 500);
+
+ interval3 = setInterval( function() {
+ if( popped.currentTime() >= 15 && popped.currentTime() < 20 ) {
+ equals (subtitlediv.innerHTML, "" );
+ plus();
+ clearInterval( interval3 );
+ }
+ }, 500);
+
+ interval4 = setInterval( function() {
+ if( popped.currentTime() > 20) {
+ equals (subtitlediv.innerHTML, "this is the third subtitle of 2011", "subtitle displaying correct information" );
+ plus();
+ clearInterval( interval4 );
+ }
+ }, 500);
+
+});
\ No newline at end of file