From: rwldrn Date: Sun, 5 Dec 2010 01:20:49 +0000 (-0500) Subject: [#173] X-Git-Tag: v0.2~68^2~5 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=2f5c45373be78d8cd03481d784cb62c48b4d2c26;p=popcorn-js.git [#173] --- diff --git a/popcorn.js b/popcorn.js index 853838b..429d114 100644 --- a/popcorn.js +++ b/popcorn.js @@ -279,7 +279,7 @@ } - this.video.addEventListener( "timeupdate", function( event ) { + this.listen( "timeupdate", function( event ) { if ( ~~self.currentTime() === options.start || diff --git a/test/demo.js b/test/demo.js index 281b497..c4a5a9b 100644 --- a/test/demo.js +++ b/test/demo.js @@ -155,7 +155,8 @@ $(function () { p.complicator({ start: 1, - end: 10 + end: 10, + wtf: "throws exception?" }); diff --git a/test/popcorn-api-draft-unit.js b/test/popcorn-api-draft-unit.js index b2f7776..d13c5ac 100644 --- a/test/popcorn-api-draft-unit.js +++ b/test/popcorn-api-draft-unit.js @@ -71,102 +71,6 @@ test("Popcorn Object", function () { }); -test("Popcorn Plugin", function () { - - QUnit.reset(); - - // needs expectation - - var popped = Popcorn("#video"), - methods = "load play pause currentTime mute volume"; - - - stop(); - - - Popcorn.plugin("subtitles", function () { - - var self = this; - - // These ensure that a popcorn instance is the value of `this` inside a plugin definition - - methods.split(/\s+/g).forEach(function (k,v) { - ok( k in self, "instance has method: " + k ); - }); - - ok( "video" in this, "instance has `video` property" ); - ok( Object.prototype.toString.call(popped.video) === "[object HTMLVideoElement]", "video property is a HTMLVideoElement" ); - - ok( "data" in this, "instance has `data` property" ); - ok( Object.prototype.toString.call(popped.data) === "[object Object]", "data property is an object" ); - - ok( "tracks" in this.data, "instance has `tracks` property" ); - ok( Object.prototype.toString.call(popped.data.tracks) === "[object Array]", "tracks property is an array" ) - }); - - - // Call plugin to test scope within - popped.subtitles(); - - - - ok( "subtitles" in popped, "subtitles plugin is now available to instance" ); - ok( Popcorn.registry.length === 1, "One item in the registry"); - - - - - - Popcorn.plugin("complicator", { - - start: function ( event ) { - - - equals( ~~this.currentTime(), 1, "~~this.currentTime() === 1"); - - var self = this; - - // These ensure that a popcorn instance is the value of `this` inside a plugin definition - - methods.split(/\s+/g).forEach(function (k,v) { - ok( k in self, "instance has method: " + k ); - }); - - ok( "video" in this, "instance has `video` property" ); - ok( Object.prototype.toString.call(popped.video) === "[object HTMLVideoElement]", "video property is a HTMLVideoElement" ); - - ok( "data" in this, "instance has `data` property" ); - ok( Object.prototype.toString.call(popped.data) === "[object Object]", "data property is an object" ); - - ok( "tracks" in this.data, "instance has `tracks` property" ); - ok( Object.prototype.toString.call(popped.data.tracks) === "[object Array]", "tracks property is an array" ) - - }, - end: function () { - - start(); - - }, - timeupdate: function () { - } - }); - - - ok( "complicator" in popped, "complicator plugin is now available to instance" ); - ok( Popcorn.registry.length === 2, "Two items in the registry"); - - - - popped.currentTime(0); - - popped.complicator({ - start: 1, - end: 2 - }); - - -}); - test("Popcorn Events Stored By Type", function () { QUnit.reset(); @@ -226,6 +130,8 @@ test("Popcorn Events Stored By Type", function () { p.trigger("play"); + p.unlisten("play"); + }); @@ -276,7 +182,8 @@ test("Popcorn Events Simulated", function () { test("Popcorn Events Real", function () { - + + QUnit.reset(); var p = Popcorn("#video"), completed = [], @@ -286,7 +193,7 @@ test("Popcorn Events Real", function () { events = eventtest.split(/\s+/g); - var expects = events.length, + var expects = 11, count = 0; //expect(expects); @@ -326,16 +233,100 @@ test("Popcorn Events Real", function () { +}); + +test("Popcorn Plugin", function () { + + QUnit.reset(); + + // needs expectation + + var popped = Popcorn("#video"), + methods = "load play pause currentTime mute volume"; + - setTimeout(function() { + stop(); - //console.log(completed); - start(); + Popcorn.plugin("subtitles", function () { + + var self = this; - }, 5000); + // These ensure that a popcorn instance is the value of `this` inside a plugin definition + + methods.split(/\s+/g).forEach(function (k,v) { + ok( k in self, "instance has method: " + k ); + }); + + ok( "video" in this, "instance has `video` property" ); + ok( Object.prototype.toString.call(popped.video) === "[object HTMLVideoElement]", "video property is a HTMLVideoElement" ); + + ok( "data" in this, "instance has `data` property" ); + ok( Object.prototype.toString.call(popped.data) === "[object Object]", "data property is an object" ); + + ok( "tracks" in this.data, "instance has `tracks` property" ); + ok( Object.prototype.toString.call(popped.data.tracks) === "[object Array]", "tracks property is an array" ) + }); + // Call plugin to test scope within + popped.subtitles(); -}); + + + ok( "subtitles" in popped, "subtitles plugin is now available to instance" ); + ok( Popcorn.registry.length === 1, "One item in the registry"); + + + + + + Popcorn.plugin("complicator", { + + start: function ( event ) { + + + equals( ~~this.currentTime(), 1, "~~this.currentTime() === 1"); + + var self = this; + + // These ensure that a popcorn instance is the value of `this` inside a plugin definition + + methods.split(/\s+/g).forEach(function (k,v) { + ok( k in self, "instance has method: " + k ); + }); + + ok( "video" in this, "instance has `video` property" ); + ok( Object.prototype.toString.call(popped.video) === "[object HTMLVideoElement]", "video property is a HTMLVideoElement" ); + + ok( "data" in this, "instance has `data` property" ); + ok( Object.prototype.toString.call(popped.data) === "[object Object]", "data property is an object" ); + ok( "tracks" in this.data, "instance has `tracks` property" ); + ok( Object.prototype.toString.call(popped.data.tracks) === "[object Array]", "tracks property is an array" ) + + }, + end: function () { + + start(); + + }, + timeupdate: function () { + } + }); + + + ok( "complicator" in popped, "complicator plugin is now available to instance" ); + ok( Popcorn.registry.length === 2, "Two items in the registry"); + + + + popped.currentTime(0); + + popped.complicator({ + start: 1, + end: 2 + }); + + +}); \ No newline at end of file