]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#494] Adds a test for frame function
authorRick Waldron <waldron.rick@gmail.com>
Thu, 8 Sep 2011 17:44:40 +0000 (13:44 -0400)
committerRick Waldron <waldron.rick@gmail.com>
Thu, 8 Sep 2011 17:44:40 +0000 (13:44 -0400)
test/popcorn.unit.js

index a1b1f01ffd05f54ebcc65cd22a5a6ee6ea7a8c28..89855e7d552a777251893403ca4a636faa6ce166 100644 (file)
@@ -1452,7 +1452,9 @@ test("Start Zero Immediately", function() {
 
   var $pop = Popcorn("#video"),
       expects = 1,
-      count   = 0;
+      count = 0;
+
+  expect(expects);
 
   function plus() {
     if ( ++count === expects ) {
@@ -1479,6 +1481,47 @@ test("Start Zero Immediately", function() {
     end: 2
   });
 });
+
+test("frame function (frameAnimation)", function() {
+
+  var $pop = Popcorn("#video", { frameAnimation: true }),
+      fired = 0,
+      expects = 1,
+      count = 0;
+
+  expect(expects);
+
+  function plus() {
+    if ( ++count === expects ) {
+      // clean up added events after tests
+      Popcorn.removePlugin("frameFn");
+      start();
+    }
+  }
+
+  stop();
+
+  $pop.pause().currentTime( 1 );
+
+  Popcorn.plugin( "frameFn", {
+    start: function() {
+    },
+    frame: function() {
+      fired++;
+    },
+    end: function() {
+      // if `frame` fired, then it will have value > 0
+      ok( fired, "frame fired. (actual: " + fired + ")" );
+      plus();
+    }
+  });
+
+  $pop.frameFn({
+    start: 1,
+    end: 3
+  }).play();
+});
+
 test("Update Timer (timeupdate)", function() {
 
   QUnit.reset();