]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
Added tests for timeUpdate function and fixed other unit tests because of timing...
authorDavid Seifried <david.c.seifried@gmail.com>
Wed, 7 Sep 2011 16:58:27 +0000 (12:58 -0400)
committerDavid Seifried <david.c.seifried@gmail.com>
Wed, 7 Sep 2011 16:58:27 +0000 (12:58 -0400)
popcorn.js
test/popcorn.unit.js

index 9f6b0913db0b4e57fc2257aaf57ed2b5b3a214fc..87aeeb321f7b9ba2dfcbe14722efe9779cb83613 100644 (file)
 
       //  Creating a one second track event with an empty end
       Popcorn.addTrackEvent( this, {
-        start: time,
+        start: time + 0.25,
         end: time + 1,
         _running: false,
         _natives: {
index e618179ca021ffa448294f16dd262178e2812712..a6ca9487470510231aaf21aa2191f401e00aa092 100644 (file)
@@ -2538,30 +2538,6 @@ test("getTrackEvent", function () {
 
 });
 
-test("timeUpdate functionality", function() {
-
-  var $pop = Popcorn( "#video" ),
-    count = 0,
-    expects = 5;
-
-  expect( expects );
-
-  function plus() {
-    if ( ++count === expects ) {
-      start();
-
-      Popcorn.removeInstance( $pop );
-    }
-  }
-
-  Popcorn.plugin("timeUpdateTester", function() {
-    return {
-      start: function(){},
-      end: function(){}
-    };
-  });
-});
-
 test("Index Integrity", function () {
 
 
@@ -2649,6 +2625,49 @@ test("Index Integrity", function () {
 
 });
 
+test("timeUpdate functionality", function() {
+
+  var $pop = Popcorn( "#video" ),
+    count = 0,
+    expects = 4;
+
+  expect( expects );
+
+  Popcorn.plugin("timeUpdateTester", function() {
+    return {
+      start: function () {
+        var div = document.createElement("div");
+        div.id = "timeUpdate-test";
+
+        document.body.appendChild(div);
+      },
+      end: function () {
+        document.getElementById("timeUpdate-test").parentNode.removeChild(document.getElementById("timeUpdate-test"));
+      }
+    };
+  });
+
+  equals( typeof Popcorn.timeUpdate, "function", "timeUpdate is a function of Popcorn" );
+
+  $pop.currentTime(40).pause();
+
+  equals( $pop.getTrackEvents().length, 0, "Initially no trackEvents" );
+  
+  $pop.timeUpdateTester({
+    id:"timeUpdateID",
+    start:40,
+    end: 41
+  });
+
+  equals( $pop.getTrackEvents().length, 1, "trackEvent successfully added" );
+
+  ok( document.getElementById( "timeUpdate-test" ), "trackEvent successfully added, content was displayed while video was paused" );
+
+  $pop.removeTrackEvent( "timeUpdateID" );
+  Popcorn.removeInstance( $pop );
+
+});
+
 test("Popcorn.disable/enable/toggle", function() {