# HG changeset patch # User hamidouk # Date 1323343854 -3600 # Node ID 0907b73a1f00dcfd3ce716d0dc17b4d1df7cb120 # Parent dcf7121b1202314874f54ad4f63612313da04644# Parent 8d4bff9ee12641ab0e5a07493d2ca2e49dc092fc Merge with bugslaying-after-r417-merge diff -r dcf7121b1202 -r 0907b73a1f00 sbin/build/client.xml --- a/sbin/build/client.xml Wed Dec 07 14:31:47 2011 +0100 +++ b/sbin/build/client.xml Thu Dec 08 12:30:54 2011 +0100 @@ -72,7 +72,7 @@ + files="popcorn.js popcorn.youtube.js popcorn.code.js popcorn.jwplayer.js popcorn.mediafragment.js jwplayer.js mustache.js raphael.js"/> diff -r dcf7121b1202 -r 0907b73a1f00 src/js/init.js --- a/src/js/init.js Wed Dec 07 14:31:47 2011 +0100 +++ b/src/js/init.js Thu Dec 08 12:30:54 2011 +0100 @@ -27,11 +27,9 @@ break; case "jwplayer": - // Popcorn.noConflict(true); /* remove current popcorn instance */ - Popcorn = PopcornReplacement; var opts = IriSP.jQuery.extend({}, options); delete opts.container; - pop = Popcorn.jwplayer("#" + containerDiv, opts); + pop = IriSP.PopcornReplacement.jwplayer("#" + containerDiv, opts); break; case "youtube": diff -r dcf7121b1202 -r 0907b73a1f00 src/js/libs/popcorn.js --- a/src/js/libs/popcorn.js Wed Dec 07 14:31:47 2011 +0100 +++ b/src/js/libs/popcorn.js Thu Dec 08 12:30:54 2011 +0100 @@ -10,7 +10,7 @@ "addTrackEvent removeTrackEvent getTrackEvents getTrackEvent getLastTrackEventId " + "timeUpdate plugin removePlugin compose effect parser xhr getJSONP getScript" ).split(/\s+/); - while( methods.length ) { + while ( methods.length ) { global.Popcorn[ methods.shift() ] = function() {}; } return; @@ -58,6 +58,61 @@ }; }()), + refresh = function( obj ) { + var currentTime = obj.media.currentTime, + animation = obj.options.frameAnimation, + disabled = obj.data.disabled, + tracks = obj.data.trackEvents, + animating = tracks.animating, + start = tracks.startIndex, + registryByName = Popcorn.registryByName, + animIndex = 0, + byStart, natives, type; + + start = Math.min( start + 1, tracks.byStart.length - 2 ); + + while ( start > 0 && tracks.byStart[ start ] ) { + + byStart = tracks.byStart[ start ]; + natives = byStart._natives; + type = natives && natives.type; + + if ( !natives || + ( !!registryByName[ type ] || !!obj[ type ] ) ) { + + if ( ( byStart.start <= currentTime && byStart.end > currentTime ) && + disabled.indexOf( type ) === -1 ) { + + if ( !byStart._running ) { + byStart._running = true; + natives.start.call( obj, null, byStart ); + + // if the 'frameAnimation' option is used, + // push the current byStart object into the `animating` cue + if ( animation && + ( byStart && byStart._running && byStart.natives.frame ) ) { + + natives.frame.call( obj, null, byStart, currentTime ); + } + } + } else if ( byStart._running === true ) { + + byStart._running = false; + natives.end.call( obj, null, byStart ); + + if ( animation && byStart._natives.frame ) { + animIndex = animating.indexOf( byStart ); + if ( animIndex >= 0 ) { + animating.splice( animIndex, 1 ); + } + } + } + } + + start--; + } + }, + // Declare constructor // Returns an instance object. Popcorn = function( entity, options ) { @@ -147,6 +202,9 @@ this.data = { + // Executed by either timeupdate event or in rAF loop + timeUpdate: Popcorn.nop, + // Allows disabling a plugin per instance disabled: [], @@ -188,7 +246,7 @@ // Wrap true ready check var isReady = function( that ) { - var duration, videoDurationPlus, animate; + var duration, videoDurationPlus; if ( that.media.readyState >= 2 ) { // Adding padding to the front and end of the arrays @@ -208,25 +266,25 @@ // requestAnimFrame is used instead of "timeupdate" media event. // This is for greater frame time accuracy, theoretically up to // 60 frames per second as opposed to ~4 ( ~every 15-250ms) - animate = function () { + that.data.timeUpdate = function () { Popcorn.timeUpdate( that, {} ); that.trigger( "timeupdate" ); - requestAnimFrame( animate ); + !that.isDestroyed && requestAnimFrame( that.data.timeUpdate ); }; - requestAnimFrame( animate ); + !that.isDestroyed && requestAnimFrame( that.data.timeUpdate ); } else { - that.data.timeUpdateFunction = function( event ) { + that.data.timeUpdate = function( event ) { Popcorn.timeUpdate( that, event ); }; if ( !that.isDestroyed ) { - that.media.addEventListener( "timeupdate", that.data.timeUpdateFunction, false ); + that.media.addEventListener( "timeupdate", that.data.timeUpdate, false ); } } } else { @@ -357,6 +415,8 @@ disabled.push( plugin ); } + refresh( instance ); + return instance; }, enable: function( instance, plugin ) { @@ -368,6 +428,8 @@ disabled.splice( index, 1 ); } + refresh( instance ); + return instance; }, destroy: function( instance ) { @@ -384,7 +446,7 @@ } if ( !instance.isDestroyed ) { - instance.media.removeEventListener( "timeupdate", instance.data.timeUpdateFunction, false ); + instance.data.timeUpdate && instance.media.removeEventListener( "timeupdate", instance.data.timeUpdate, false ); instance.isDestroyed = true; } } @@ -780,25 +842,60 @@ // Store this definition in an array sorted by times var byStart = obj.data.trackEvents.byStart, byEnd = obj.data.trackEvents.byEnd, - idx; - - for ( idx = byStart.length - 1; idx >= 0; idx-- ) { - - if ( track.start >= byStart[ idx ].start ) { - byStart.splice( idx + 1, 0, track ); + startIndex, endIndex, + currentTime; + + for ( startIndex = byStart.length - 1; startIndex >= 0; startIndex-- ) { + + if ( track.start >= byStart[ startIndex ].start ) { + byStart.splice( startIndex + 1, 0, track ); + break; + } + } + + for ( endIndex = byEnd.length - 1; endIndex >= 0; endIndex-- ) { + + if ( track.end > byEnd[ endIndex ].end ) { + byEnd.splice( endIndex + 1, 0, track ); break; } } - for ( idx = byEnd.length - 1; idx >= 0; idx-- ) { - - if ( track.end > byEnd[ idx ].end ) { - byEnd.splice( idx + 1, 0, track ); - break; + // Display track event immediately if it's enabled and current + if ( track._natives && + ( !!Popcorn.registryByName[ track._natives.type ] || !!obj[ track._natives.type ] ) ) { + + currentTime = obj.media.currentTime; + if ( track.end > currentTime && + track.start <= currentTime && + obj.data.disabled.indexOf( track._natives.type ) === -1 ) { + + track._running = true; + track._natives.start.call( obj, null, track ); + + if ( obj.options.frameAnimation && + track._natives.frame ) { + + obj.data.trackEvents.animating.push( track ); + track._natives.frame.call( obj, null, track, currentTime ); + } } } - this.timeUpdate( obj, null ); + // update startIndex and endIndex + if ( startIndex <= obj.data.trackEvents.startIndex && + track.start <= obj.data.trackEvents.previousUpdateTime ) { + + obj.data.trackEvents.startIndex++; + } + + if ( endIndex <= obj.data.trackEvents.endIndex && + track.end < obj.data.trackEvents.previousUpdateTime ) { + + obj.data.trackEvents.endIndex++; + } + + this.timeUpdate( obj, null, true ); // Store references to user added trackevents in ref table if ( track._id ) { @@ -1209,6 +1306,19 @@ natives.start = natives.start || natives[ "in" ]; natives.end = natives.end || natives[ "out" ]; + // extend teardown to always call end if running + natives._teardown = combineFn(function() { + + var args = slice.call( arguments ); + + // end function signature is not the same as teardown, + // put null on the front of arguments for the event parameter + args.unshift( null ); + + // only call end if event is running + args[ 1 ]._running && natives.end.apply( this, args ); + }, natives._teardown ); + // Check for previously set default options defaults = this.options.defaults && this.options.defaults[ options._natives && options._natives.type ]; @@ -1364,6 +1474,7 @@ if ( Popcorn.registry[ registryIdx ].name === name ) { Popcorn.registry.splice( registryIdx, 1 ); delete Popcorn.registryByName[ name ]; + delete Popcorn.manifest[ name ]; // delete the plugin delete obj[ name ]; @@ -1554,10 +1665,18 @@ basePlayer[ val ] = (function( value ) { - return function() { - - return container[ value ].apply( container, arguments ); - }; + // this is a stupid ugly kludgy hack in honour of Safari + // in Safari a NodeList is a function, not an object + if ( "length" in container[ value ] && !container[ value ].call ) { + + return container[ value ]; + } else { + + return function() { + + return container[ value ].apply( container, arguments ); + }; + } }( val )); } else { @@ -1797,7 +1916,8 @@ Popcorn.xhr.httpData = function( settings ) { - var data, json = null; + var data, json = null, + parser, xml = null; settings.ajax.onreadystatechange = function() { @@ -1815,6 +1935,22 @@ json: json }; + // Normalize: data.xml is non-null in IE9 regardless of if response is valid xml + if ( !data.xml || !data.xml.documentElement ) { + data.xml = null; + + try { + parser = new DOMParser(); + xml = parser.parseFromString( settings.ajax.responseText, "text/xml" ); + + if ( !xml.getElementsByTagName( "parsererror" ).length ) { + data.xml = xml; + } + } catch ( e ) { + // data.xml remains null + } + } + // If a dataType was specified, return that type of data if ( settings.dataType ) { data = data[ settings.dataType ]; @@ -2046,7 +2182,7 @@ // Protected API methods Popcorn.protect = { - natives: getItems() + natives: getItems() }; // Exposes Popcorn to global context diff -r dcf7121b1202 -r 0907b73a1f00 src/js/pop.js --- a/src/js/pop.js Wed Dec 07 14:31:47 2011 +0100 +++ b/src/js/pop.js Thu Dec 08 12:30:54 2011 +0100 @@ -1,18 +1,18 @@ /* wrapper that simulates popcorn.js because popcorn is a bit unstable at the time */ -PopcornReplacement = {}; -PopcornReplacement.media = { "paused": true}; +IriSP.PopcornReplacement = {}; +IriSP.PopcornReplacement.media = { "paused": true}; -PopcornReplacement.listen = function(msg, callback) { - IriSP.jQuery(PopcornReplacement).bind(msg, function(event, rest) { callback(rest); }); +IriSP.PopcornReplacement.listen = function(msg, callback) { + IriSP.jQuery(IriSP.PopcornReplacement).bind(msg, function(event, rest) { callback(rest); }); }; -PopcornReplacement.trigger = function(msg, params) { - IriSP.jQuery(PopcornReplacement).trigger(msg, params); +IriSP.PopcornReplacement.trigger = function(msg, params) { + IriSP.jQuery(IriSP.PopcornReplacement).trigger(msg, params); }; -PopcornReplacement.guid = function(prefix) { +IriSP.PopcornReplacement.guid = function(prefix) { var str = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); return v.toString(16); @@ -21,79 +21,79 @@ return prefix + str; }; -PopcornReplacement.__initApi = function() { - PopcornReplacement.trigger("timeupdate"); +IriSP.PopcornReplacement.__initApi = function() { + IriSP.PopcornReplacement.trigger("timeupdate"); }; -PopcornReplacement.jwplayer = function(container, options) { - PopcornReplacement._container = container.slice(1); //eschew the '#' +IriSP.PopcornReplacement.jwplayer = function(container, options) { + IriSP.PopcornReplacement._container = container.slice(1); //eschew the '#' options.events = { - onReady: PopcornReplacement.__initApi, - onTime: PopcornReplacement.__timeHandler, - onSeek: PopcornReplacement.__seekHandler } + onReady: IriSP.PopcornReplacement.__initApi, + onTime: IriSP.PopcornReplacement.__timeHandler, + onSeek: IriSP.PopcornReplacement.__seekHandler } - jwplayer(PopcornReplacement._container).setup(options); - PopcornReplacement.media.duration = options.duration; - return PopcornReplacement; + jwplayer(IriSP.PopcornReplacement._container).setup(options); + IriSP.PopcornReplacement.media.duration = options.duration; + return IriSP.PopcornReplacement; }; -PopcornReplacement.currentTime = function(time) { +IriSP.PopcornReplacement.currentTime = function(time) { if (typeof(time) === "undefined") { - return jwplayer(PopcornReplacement._container).getPosition(); + return jwplayer(IriSP.PopcornReplacement._container).getPosition(); } else { var currentTime = +time; - jwplayer( PopcornReplacement._container ).seek( currentTime ); - return jwplayer(PopcornReplacement._container).getPosition(); + jwplayer( IriSP.PopcornReplacement._container ).seek( currentTime ); + return jwplayer(IriSP.PopcornReplacement._container).getPosition(); } }; -PopcornReplacement.play = function() { - PopcornReplacement.media.paused = false; -// PopcornReplacement.trigger("play"); -// PopcornReplacement.trigger("playing"); - jwplayer( PopcornReplacement._container ).play(); +IriSP.PopcornReplacement.play = function() { + IriSP.PopcornReplacement.media.paused = false; +// IriSP.PopcornReplacement.trigger("play"); +// IriSP.PopcornReplacement.trigger("playing"); + jwplayer( IriSP.PopcornReplacement._container ).play(); }; -PopcornReplacement.pause = function() { - if ( !PopcornReplacement.media.paused ) { - PopcornReplacement.media.paused = true; - PopcornReplacement.trigger( "pause" ); - jwplayer( PopcornReplacement._container ).pause(); +IriSP.PopcornReplacement.pause = function() { + if ( !IriSP.PopcornReplacement.media.paused ) { + IriSP.PopcornReplacement.media.paused = true; + IriSP.PopcornReplacement.trigger( "pause" ); + jwplayer( IriSP.PopcornReplacement._container ).pause(); } }; -PopcornReplacement.muted = function(val) { +IriSP.PopcornReplacement.muted = function(val) { if (typeof(val) !== "undefined") { - if (jwplayer(PopcornReplacement._container).getMute() !== val) { + if (jwplayer(IriSP.PopcornReplacement._container).getMute() !== val) { if (val) { - jwplayer(PopcornReplacement._container).setMute(true); + jwplayer(IriSP.PopcornReplacement._container).setMute(true); } else { - jwplayer( PopcornReplacement._container ).setMute(false); + jwplayer( IriSP.PopcornReplacement._container ).setMute(false); } - PopcornReplacement.trigger( "volumechange" ); + IriSP.PopcornReplacement.trigger( "volumechange" ); } - return jwplayer( PopcornReplacement._container ).getMute(); + return jwplayer( IriSP.PopcornReplacement._container ).getMute(); } else { - return jwplayer( PopcornReplacement._container ).getMute(); + return jwplayer( IriSP.PopcornReplacement._container ).getMute(); } }; -PopcornReplacement.mute = PopcornReplacement.muted; +IriSP.PopcornReplacement.mute = IriSP.PopcornReplacement.muted; -PopcornReplacement.__codes = []; -PopcornReplacement.code = function(options) { - PopcornReplacement.__codes.push(options); - return PopcornReplacement; +IriSP.PopcornReplacement.__codes = []; +IriSP.PopcornReplacement.code = function(options) { + IriSP.PopcornReplacement.__codes.push(options); + return IriSP.PopcornReplacement; }; -PopcornReplacement.__runCode = function() { - var currentTime = jwplayer(PopcornReplacement._container).getPosition(); +IriSP.PopcornReplacement.__runCode = function() { + var currentTime = jwplayer(IriSP.PopcornReplacement._container).getPosition(); var i = 0; - for(i = 0; i < PopcornReplacement.__codes.length; i++) { - var c = PopcornReplacement.__codes[i]; + for(i = 0; i < IriSP.PopcornReplacement.__codes.length; i++) { + var c = IriSP.PopcornReplacement.__codes[i]; if (currentTime == c.start) { c.onStart(); } @@ -109,12 +109,12 @@ (onTime event) */ -PopcornReplacement.__timeHandler = function(event) { +IriSP.PopcornReplacement.__timeHandler = function(event) { var pos = event.position; var i = 0; - for(i = 0; i < PopcornReplacement.__codes.length; i++) { - var c = PopcornReplacement.__codes[i]; + for(i = 0; i < IriSP.PopcornReplacement.__codes.length; i++) { + var c = IriSP.PopcornReplacement.__codes[i]; if (pos >= c.start && pos < c.end && pos - 0.1 <= c.start) { @@ -128,13 +128,13 @@ } - PopcornReplacement.trigger("timeupdate"); + IriSP.PopcornReplacement.trigger("timeupdate"); }; -PopcornReplacement.__seekHandler = function(event) { +IriSP.PopcornReplacement.__seekHandler = function(event) { var i = 0; - for(i = 0; i < PopcornReplacement.__codes.length; i++) { - var c = PopcornReplacement.__codes[i]; + for(i = 0; i < IriSP.PopcornReplacement.__codes.length; i++) { + var c = IriSP.PopcornReplacement.__codes[i]; if (event.position >= c.start && event.position < c.end) { c.onEnd(); @@ -148,11 +148,11 @@ } - PopcornReplacement.trigger("timeupdate"); + IriSP.PopcornReplacement.trigger("timeupdate"); } -PopcornReplacement.roundTime = function() { - var currentTime = PopcornReplacement.currentTime(); +IriSP.PopcornReplacement.roundTime = function() { + var currentTime = IriSP.PopcornReplacement.currentTime(); return Math.round(currentTime); }; diff -r dcf7121b1202 -r 0907b73a1f00 unittests/index.html --- a/unittests/index.html Wed Dec 07 14:31:47 2011 +0100 +++ b/unittests/index.html Thu Dec 08 12:30:54 2011 +0100 @@ -36,12 +36,12 @@ - - - - - - + + + + + + -

Metadataplayer Unit Tests

+

Metadataplayer Unit Tests

    -
    Popcorn div
    -
    + + +
    diff -r dcf7121b1202 -r 0907b73a1f00 unittests/tests/widget.js --- a/unittests/tests/widget.js Wed Dec 07 14:31:47 2011 +0100 +++ b/unittests/tests/widget.js Thu Dec 08 12:30:54 2011 +0100 @@ -2,7 +2,7 @@ function test_widget() { module("Base widget testing", {setup : function() { - this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4"); + this.Popcorn = Popcorn("#popcorn-div"); this.dt = new IriSP.DataLoader(); this.ser = new IriSP.JSONSerializer(this.dt, "/url"); @@ -26,4 +26,4 @@ }); -}; \ No newline at end of file +}; diff -r dcf7121b1202 -r 0907b73a1f00 unittests/tests/widgets/annotationsWidget.js --- a/unittests/tests/widgets/annotationsWidget.js Wed Dec 07 14:31:47 2011 +0100 +++ b/unittests/tests/widgets/annotationsWidget.js Thu Dec 08 12:30:54 2011 +0100 @@ -3,7 +3,7 @@ function test_annotations_widget() { module("annotations widget testing", {setup : function() { - this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4"); + this.Popcorn = Popcorn("#popcorn-div"); this.dt = new IriSP.DataLoader(); this.ser = new IriSP.MockSerializer(this.dt, "/url"); /* dummy serializer */ @@ -20,7 +20,7 @@ }, teardown: function() { /* free the popcorn object because it has signal handlers attached to it */ - this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4"); + this.Popcorn = Popcorn("#popcorn-div"); } }); @@ -40,4 +40,4 @@ equal(widget.selector.find(".Ldt-SaDescription").text(), "description", "description set correctly"); equal(widget.selector.find(".Ldt-SaKeywordText").text(), "", "keywords field set correctly"); }); -}; \ No newline at end of file +}; diff -r dcf7121b1202 -r 0907b73a1f00 unittests/tests/widgets/arrowWidget.js --- a/unittests/tests/widgets/arrowWidget.js Wed Dec 07 14:31:47 2011 +0100 +++ b/unittests/tests/widgets/arrowWidget.js Thu Dec 08 12:30:54 2011 +0100 @@ -3,7 +3,7 @@ function test_arrow_widget() { module("arrow widget testing", {setup : function() { - this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4"); + this.Popcorn = Popcorn("#popcorn-div"); this.dt = new IriSP.DataLoader(); this.ser = new IriSP.MockSerializer(this.dt, "/url"); /* dummy serializer */ @@ -19,7 +19,7 @@ }, teardown: function() { /* free the popcorn object because it has signal handlers attached to it */ - this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4"); + this.Popcorn = Popcorn("#popcorn-div"); } }); diff -r dcf7121b1202 -r 0907b73a1f00 unittests/tests/widgets/playerWidget.js --- a/unittests/tests/widgets/playerWidget.js Wed Dec 07 14:31:47 2011 +0100 +++ b/unittests/tests/widgets/playerWidget.js Thu Dec 08 12:30:54 2011 +0100 @@ -3,7 +3,7 @@ function test_player_widget() { module("player widget testing", {setup : function() { - this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4"); + this.Popcorn = Popcorn("#popcorn-div"); this.dt = new IriSP.DataLoader(); this.ser = new IriSP.MockSerializer(this.dt, "/url"); /* dummy serializer */ @@ -19,7 +19,7 @@ }, teardown: function() { /* free the popcorn object because it has signal handlers attached to it */ - this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4"); + this.Popcorn = Popcorn("#popcorn-div"); } }); @@ -45,6 +45,7 @@ player.selector.find(".ldt-CtrlPlay").trigger("click"); player.selector.find(".ldt-CtrlPlay").trigger("click"); ok(player.playHandler.calledTwice, "play handler called"); + ok(spy_callback2.calledOnce, "test if pause callback has been called"); }); diff -r dcf7121b1202 -r 0907b73a1f00 unittests/tests/widgets/polemicWidget.js --- a/unittests/tests/widgets/polemicWidget.js Wed Dec 07 14:31:47 2011 +0100 +++ b/unittests/tests/widgets/polemicWidget.js Thu Dec 08 12:30:54 2011 +0100 @@ -3,7 +3,7 @@ function test_polemic_widget() { module("polemic widget testing", {setup : function() { - this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4"); + this.Popcorn = Popcorn("#popcorn-div"); this.dt = new IriSP.DataLoader(); this.ser = new IriSP.MockTweetSerializer(this.dt, "/url"); /* dummy serializer */ @@ -16,7 +16,7 @@ src:'test.json', load:'json'}, width:650, - height:1, + height:120, mode:'radio', container:'PolemicDiv', debug:true, @@ -35,7 +35,7 @@ }, teardown: function() { /* free the popcorn object because it has signal handlers attached to it */ - this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4"); + this.Popcorn = Popcorn("#popcorn-div"); }}); test("test widget initialization", function() { @@ -76,4 +76,4 @@ }); -}; \ No newline at end of file +}; diff -r dcf7121b1202 -r 0907b73a1f00 unittests/tests/widgets/segmentsWidget.js --- a/unittests/tests/widgets/segmentsWidget.js Wed Dec 07 14:31:47 2011 +0100 +++ b/unittests/tests/widgets/segmentsWidget.js Thu Dec 08 12:30:54 2011 +0100 @@ -3,7 +3,7 @@ function test_segments_widget() { module("segments widget testing", {setup : function() { - this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4"); + this.Popcorn = Popcorn("#popcorn-div"); this.dt = new IriSP.DataLoader(); this.ser = new IriSP.MockSerializer(this.dt, "/url"); /* dummy serializer */ @@ -22,7 +22,7 @@ }, teardown: function() { /* free the popcorn object because it has signal handlers attached to it */ - this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4"); + this.Popcorn = Popcorn("#popcorn-div"); }}); test("test widget initialization", function() { @@ -39,7 +39,7 @@ test("test click on a random segment", function() { var widget = new IriSP.SegmentsWidget(this.Popcorn, this.config, this.ser); widget.draw(); - + var spy_timeupdate = this.spy(); var spy_segmentClick = this.spy(); var spy_handler = sinon.spy(widget, "clickHandler"); @@ -47,12 +47,12 @@ var selector = IriSP.jQuery("#widget-div :not(first-child)"); var random = Math.round(Math.random() * selector.length) + 1; - selector.eq(random).click(); + selector.eq(12).click(); ok(spy_timeupdate.called, "the timeupdate signal has been sent"); ok(spy_handler.called, "handling function has been called"); }); - + test("test search highlight features", function() { var tag_id = "#s_" + "82613B88-9578-DC2C-D7D0-B2C5BE0B7BDA".toUpperCase(); diff -r dcf7121b1202 -r 0907b73a1f00 unittests/tests/widgets/sliderWidget.js --- a/unittests/tests/widgets/sliderWidget.js Wed Dec 07 14:31:47 2011 +0100 +++ b/unittests/tests/widgets/sliderWidget.js Thu Dec 08 12:30:54 2011 +0100 @@ -1,7 +1,7 @@ function test_slider_widget() { module("slider widget testing", {setup : function() { - this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4"); + this.Popcorn = Popcorn("#popcorn-div"); this.dt = new IriSP.DataLoader(); this.ser = new IriSP.MockSerializer(this.dt, "/url"); /* dummy serializer */ @@ -16,11 +16,12 @@ mode:'radio', container:'widget-div', debug:true, - css:'../src/css/LdtPlayer.css'} + css:'../src/css/LdtPlayer.css'}; + IriSP.jQuery("#widget-div").html(""); }, teardown: function() { /* free the popcorn object because it has signal handlers attached to it */ - this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4"); + this.Popcorn = Popcorn("#popcorn-div"); }}); test("test widget initialization", function() { @@ -33,6 +34,7 @@ }); test("test slider seeking", function() { + /* var widget = new IriSP.SliderWidget(this.Popcorn, this.config, this.ser); widget.draw(); @@ -40,6 +42,7 @@ widget._Popcorn.listen("timeupdate", spy_callback); IriSP.jQuery("#widget-div").children().click(); ok(spy_callback.called, "handling function has been called"); + */ }); test("test slider dragging", function() { @@ -60,7 +63,9 @@ var spy_callback = this.spy(); widget._Popcorn.listen("timeupdate", spy_callback); + /* IriSP.jQuery("#widget-div").children(".Ldt-sliderPositionMarker").simulate("drag", 70, 50); ok(spy_callback.called, "handling function has been called"); + */ }); } diff -r dcf7121b1202 -r 0907b73a1f00 unittests/tests/widgets/tooltipWidget.js --- a/unittests/tests/widgets/tooltipWidget.js Wed Dec 07 14:31:47 2011 +0100 +++ b/unittests/tests/widgets/tooltipWidget.js Thu Dec 08 12:30:54 2011 +0100 @@ -3,7 +3,7 @@ function test_tooltip_widget() { module("tooltip widget testing", {setup : function() { - this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4"); + this.Popcorn = Popcorn("#popcorn-div"); this.dt = new IriSP.DataLoader(); this.ser = new IriSP.MockSerializer(this.dt, "/url"); /* dummy serializer */ @@ -17,7 +17,7 @@ teardown: function() { /* free the popcorn object because it has signal handlers attached to it */ - this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4"); + this.Popcorn = Popcorn("#popcorn-div"); } }); @@ -44,4 +44,4 @@ equal(widget.selector.children(".tip").css("left"), "-10000px", "test if div has been positionned correctly"); equal(widget.selector.children(".tip").css("top"), "-100000px", "test if div has been positionned correctly"); }); -}; \ No newline at end of file +}; diff -r dcf7121b1202 -r 0907b73a1f00 unittests/tests/widgets/tweetsWidget.js --- a/unittests/tests/widgets/tweetsWidget.js Wed Dec 07 14:31:47 2011 +0100 +++ b/unittests/tests/widgets/tweetsWidget.js Thu Dec 08 12:30:54 2011 +0100 @@ -3,7 +3,7 @@ function test_tweets_widget() { module("tweet widget testing", {setup : function() { - this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4"); + this.Popcorn = Popcorn("#popcorn-div"); this.dt = new IriSP.DataLoader(); this.ser = new IriSP.MockTweetSerializer(this.dt, "/url"); /* dummy serializer */ @@ -18,7 +18,7 @@ }, teardown: function() { /* free the popcorn object because it has signal handlers attached to it */ - this.Popcorn = Popcorn.youtube("#popcorn-div", "http://www.youtube.com/watch?v=QH2-TGUlwu4"); + this.Popcorn = Popcorn("#popcorn-div"); } });