From: David Seifried Date: Thu, 22 Sep 2011 15:15:29 +0000 (-0400) Subject: Fixed merge conflict X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=e7dc9aaccf4df329ed3b4dd024a4eb636a423ef5;p=popcorn-js.git Fixed merge conflict --- e7dc9aaccf4df329ed3b4dd024a4eb636a423ef5 diff --cc popcorn.js index d50a864,16f3e75..2baf6a9 --- a/popcorn.js +++ b/popcorn.js @@@ -885,10 -901,10 +903,10 @@@ registryByName = Popcorn.registryByName, - byEnd, byStart, natives, type; + byEnd, byStart, byAnimate, natives, type; // Playbar advancing - if ( previousTime < currentTime ) { + if ( previousTime <= currentTime ) { while ( tracks.byEnd[ end ] && tracks.byEnd[ end ].end <= currentTime ) { diff --cc test/popcorn.unit.js index f5928ca,1981ea5..b41398a --- a/test/popcorn.unit.js +++ b/test/popcorn.unit.js @@@ -49,10 -41,10 +41,10 @@@ test("API", function() }); - test("Popcorn.* Static Methods", function () { + test("Popcorn.* Static Methods", function() { var statics = [ "forEach", "extend", "error", "guid", "sizeOf", "nop", - "addTrackEvent", "removeTrackEvent", "getTrackEvents", "getTrackEvent", "position", "disable", "enable" ], + "addTrackEvent", "removeTrackEvent", "getTrackEvents", "getTrackEvent", "position", "disable", "enable", "timeUpdate" ], substatics = [ "addTrackEvent", "removeTrackEvent", "getTrackEvents", "getTrackEvent"]; expect(statics.length + substatics.length); @@@ -1647,58 -1626,176 +1626,227 @@@ test("Update Timer (timeupdate)", funct }); + test("Update Timer (frameAnimation)", function() { + QUnit.reset(); + + var p2 = Popcorn("#video", { frameAnimation: true }), + expects = 12, + count = 0, + execCount = 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, + wrapperRunning = { one: false, two: false, }; + + function plus() { + if ( ++count === expects ) { + // clean up added events after tests + Popcorn.removePlugin( "forwards" ); + Popcorn.removePlugin( "backwards" ); + Popcorn.removePlugin( "wrapper" ); + p2.removePlugin( "exec" ); + start(); + } + } + + // These tests come close to 10 seconds on chrome, increasing to 15 + stop( 15000 ); + + Popcorn.plugin( "forwards", function() { + return { + start: function( event, options ) { + + if ( !options.startFired ) { + + options.startFired = true; + forwardStart = !forwardStart; + ok( forwardStart, "forward's start fired" ); + plus(); + } + }, + end: function( event, options ) { + + if ( !options.endFired ) { + + options.endFired = true; + forwardEnd = !forwardEnd; + p2.currentTime(1).play(); + ok( forwardEnd, "forward's end fired" ); + plus(); + } + } + }; + }); + + p2.forwards({ + start: 3, + end: 4 + }); + + Popcorn.plugin( "backwards", function() { + return { + start: function( event, options ) { + + if ( !options.startFired ) { + + options.startFired = true; + backwardStart = !backwardStart; + p2.currentTime(0).play(); + ok( true, "backward's start fired" ); + plus(); + } + }, + end: function( event, options ) { + + if ( !options.endFired ) { + + options.endFired = true; + backwardEnd = !backwardEnd; + ok( backwardEnd, "backward's end fired" ); + plus(); + p2.currentTime( 5 ).play(); + } + } + }; + }); + + p2.backwards({ + start: 1, + end: 2 + }); + + Popcorn.plugin( "wrapper", { + start: function( event, options ) { + + wrapperRunning[ options.wrapper ] = true; + }, + end: function( event, options ) { + + wrapperRunning[ options.wrapper ] = false; + } + }); + + // second instance of wrapper is wrapping the first + p2.wrapper({ + start: 6, + end: 7, + wrapper: "one" + }) + .wrapper({ + start: 5, + end: 8, + wrapper: "two" + }) + // checking wrapper 2's start + .exec( 5, function() { + + if ( execCount === 0 ) { + + execCount++; + ok( wrapperRunning.two, "wrapper two is running at second 5" ); + plus(); + ok( !wrapperRunning.one, "wrapper one is stopped at second 5" ); + plus(); + } + }) + // checking wrapper 1's start + .exec( 6, function() { + + if ( execCount === 1 ) { + + execCount++; + ok( wrapperRunning.two, "wrapper two is running at second 6" ); + plus(); + ok( wrapperRunning.one, "wrapper one is running at second 6" ); + plus(); + } + }) + // checking wrapper 1's end + .exec( 7, function() { + + if ( execCount === 2 ) { + + execCount++; + ok( wrapperRunning.two, "wrapper two is running at second 7" ); + plus(); + ok( !wrapperRunning.one, "wrapper one is stopped at second 7" ); + plus(); + } + }) + // checking wrapper 2's end + .exec( 8, function() { + + if ( execCount === 3 ) { + + execCount++; + ok( !wrapperRunning.two, "wrapper two is stopped at second 9" ); + plus(); + ok( !wrapperRunning.one, "wrapper one is stopped at second 9" ); + plus(); + } + }); + + p2.currentTime(3).play(); + + }); + + -test("Plugin Factory", function() { ++<<<<<<< HEAD +test("timeUpdate add track event while paused", function() { + + var $pop = Popcorn( "#video" ), + count = 0, + expects = 3; + + expect( expects ); + + function plus() { + if ( ++count === expects ) { + Popcorn.removePlugin( "timeUpdateTester" ); + Popcorn.removeInstance( $pop ); + } + } + + 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")); + } + }; + }); + + $pop.currentTime(40).pause(); + + equals( $pop.getTrackEvents().length, 0, "Initially no trackEvents" ); + plus(); + + $pop.timeUpdateTester({ + id:"timeUpdateID", + start:40, + end: 41 + }); + + equals( $pop.getTrackEvents().length, 1, "trackEvent successfully added" ); + plus(); + + ok( document.getElementById( "timeUpdate-test" ), "trackEvent successfully added, content was displayed while video was paused" ); + plus(); + + $pop.removeTrackEvent( "timeUpdateID" ); + +}); + +test("Plugin Factory", function () { QUnit.reset(); @@@ -2626,17 -2719,82 +2772,82 @@@ test("Index Integrity (timeupdate)", fu stop( 10000 ); - equals(p.data.trackEvents.endIndex, 0, "p.data.trackEvents.endIndex is 0"); - equals(p.data.trackEvents.startIndex, 0, "p.data.trackEvents.startIndex is 0"); + equals(p.data.trackEvents.endIndex, 1, "p.data.trackEvents.endIndex is 1"); + equals(p.data.trackEvents.startIndex, 1, "p.data.trackEvents.startIndex is 1"); equals(p.data.trackEvents.byStart.length, 3, "p.data.trackEvents.byStart.length is 3 - before play" ); + p.listen("timeupdate", function() { + + if ( p.roundTime() > 40 && p.roundTime() < 42 && hasrun && !lastrun ) { + + lastrun = true; + + equals( document.getElementById("index-test"), null, "document.getElementById('index-test') is null on second run - after removeTrackEvent" ); + start(); + } + + if ( p.roundTime() >= 42 && !hasrun ) { + + hasrun = true; + p.pause(); + equals(p.data.trackEvents.byStart.length, 3, "p.data.trackEvents.byStart.length is 3 - after play, before removeTrackEvent" ); + equals(p.data.trackEvents.startIndex, 2, "p.data.trackEvents.startIndex is 2 - after play, before removeTrackEvent"); + equals(p.data.trackEvents.endIndex, 2, "p.data.trackEvents.endIndex is 2 - after play, before removeTrackEvent"); + + p.removeTrackEvent("removeable-track-event"); + + equals(p.data.trackEvents.byStart.length, 2, "p.data.trackEvents.byStart.length is 2 - after removeTrackEvent" ); + equals(p.data.trackEvents.startIndex, 1, "p.data.trackEvents.startIndex is 1 - after removeTrackEvent"); + equals(p.data.trackEvents.endIndex, 1, "p.data.trackEvents.endIndex is 1 - after removeTrackEvent"); - p.listen("timeupdate", function () { + p.currentTime(40).play(); - if ( p.roundTime() > 40 && p.roundTime() < 42 && !hasrun ) { } + }); + + p.play(); + }); + + test("Index Integrity (frameAnimation)", function() { + + var trackLen, + hasrun = false, + lastrun = false; + + Popcorn.plugin("ff", function() { + return { + start: function() { + var div = document.createElement("div"); + div.id = "index-test"; + div.innerHTML = "foo"; + + document.body.appendChild(div); + }, + end: function() { + document.getElementById("index-test").parentNode.removeChild(document.getElementById("index-test")); + } + }; + }); + + var p = Popcorn("#video", { frameAnimation: true }); + + p.ff({ + id: "removeable-track-event", + start: 40, + end: 41 + }); + + p.currentTime(40).pause(); + + stop( 10000 ); + + equals(p.data.trackEvents.endIndex, 0, "p.data.trackEvents.endIndex is 0"); + equals(p.data.trackEvents.startIndex, 0, "p.data.trackEvents.startIndex is 0"); + equals(p.data.trackEvents.byStart.length, 3, "p.data.trackEvents.byStart.length is 3 - before play" ); + + p.listen("timeupdate", function() { if ( p.roundTime() > 40 && p.roundTime() < 42 && hasrun && !lastrun ) {