From: Rick Waldron Date: Thu, 8 Sep 2011 17:44:40 +0000 (-0400) Subject: [#494] Adds a test for frame function X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=155ac81b257b6a6c89325849f266b55c1068f2bc;p=popcorn-js.git [#494] Adds a test for frame function --- diff --git a/test/popcorn.unit.js b/test/popcorn.unit.js index a1b1f01..89855e7 100644 --- a/test/popcorn.unit.js +++ b/test/popcorn.unit.js @@ -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();