From 3cf18e1eca6cbfdf3fd4073f3502930ebdb00acd Mon Sep 17 00:00:00 2001 From: ScottDowne Date: Mon, 13 Jun 2011 18:52:29 -0400 Subject: [PATCH] [#572] fixed addtrackevent typo... and tests for it --- popcorn.js | 2 +- test/popcorn.unit.js | 73 +++++++++++++++++++++++++++++++++++++++----- 2 files changed, 66 insertions(+), 9 deletions(-) diff --git a/popcorn.js b/popcorn.js index d5adf76..3d4fefa 100644 --- a/popcorn.js +++ b/popcorn.js @@ -677,7 +677,7 @@ for ( idx = byEnd.length-1; idx >= 0; idx-- ) { - if ( track.start >= byEnd[idx].start ) { + if ( track.end > byEnd[idx].end ) { byEnd.splice( idx + 1, 0, track ); break; } diff --git a/test/popcorn.unit.js b/test/popcorn.unit.js index 099a198..fe26dc1 100644 --- a/test/popcorn.unit.js +++ b/test/popcorn.unit.js @@ -1008,27 +1008,30 @@ test("Update Timer", function () { QUnit.reset(); var p2 = Popcorn("#video"), - expects = 4, + expects = 12, count = 0, // These make sure events are only fired once // any second call will produce a failed test forwardStart = false, forwardEnd = false, backwardStart = false, - backwardEnd = false; + backwardEnd = false, + wrapperRunning = { one: false, two: false, }; function plus() { if ( ++count === expects ) { - start(); // clean up added events after tests - Popcorn.removePlugin("forwards"); - Popcorn.removePlugin("backwards"); + Popcorn.removePlugin( "forwards" ); + Popcorn.removePlugin( "backwards" ); + Popcorn.removePlugin( "wrapper" ); + p2.removePlugin( "exec" ); + start(); } } - stop(10000); + stop( 10000 ); - Popcorn.plugin("forwards", function () { + Popcorn.plugin( "forwards", function () { return { start: function () { forwardStart = !forwardStart; @@ -1049,7 +1052,7 @@ test("Update Timer", function () { end: 4 }); - Popcorn.plugin("backwards", function () { + Popcorn.plugin( "backwards", function () { return { start: function () { backwardStart = !backwardStart; @@ -1061,6 +1064,7 @@ test("Update Timer", function () { backwardEnd = !backwardEnd; ok( backwardEnd, "backward's end fired"); plus(); + p2.currentTime(5).play(); } }; }); @@ -1070,6 +1074,59 @@ test("Update Timer", function () { end: 2 }); + Popcorn.plugin( "wrapper", { + start: function ( event, options ) { + + wrapperRunning[ options.wrapper ] = true; + }, + end: function ( event, options ) { + + wrapperRunning[ options.wrapper ] = false; + } + }); + + p2.wrapper({ + start: 6, + end: 7, + wrapper: "one" + }) + .wrapper({ + start: 5, + end: 8, + wrapper: "two" + }) + .exec( 5, function() { + + ok( wrapperRunning.two, "wrapper two is running" ); + plus(); + ok( !wrapperRunning.one, "wrapper one is stopped" ); + plus(); + }) + // checking wrapper 1's start + .exec( 6, function() { + + ok( wrapperRunning.two, "wrapper two is running" ); + plus(); + ok( wrapperRunning.one, "wrapper one is running" ); + plus(); + }) + // checking wrapper 1's end + .exec( 7, function() { + + ok( wrapperRunning.two, "wrapper two is running" ); + plus(); + ok( !wrapperRunning.one, "wrapper one is stopped" ); + plus(); + }) + // checking wrapper 2's end + .exec( 9, function() { + + ok( !wrapperRunning.two, "wrapper two is stopped" ); + plus(); + ok( !wrapperRunning.one, "wrapper one is stopped" ); + plus(); + }); + p2.currentTime(3).play(); }); -- 2.43.0