From 667b8fd6ee6bcb7ac39d41652b2e29781564280a Mon Sep 17 00:00:00 2001 From: Christopher De Cairos Date: Thu, 15 Sep 2011 16:42:10 -0400 Subject: [PATCH] Added Popcorn.p.stop and unit tests [#705] --- popcorn.js | 5 +++++ test/popcorn.unit.js | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/popcorn.js b/popcorn.js index e2c7320..faaaf20 100644 --- a/popcorn.js +++ b/popcorn.js @@ -1143,6 +1143,11 @@ timeUpdate: function( event ) { Popcorn.timeUpdate.call( null, this, event ); return this; + }, + + stop: function() { + + return this.currentTime( 0 ).pause(); } }); diff --git a/test/popcorn.unit.js b/test/popcorn.unit.js index 6dfff8f..f547a85 100644 --- a/test/popcorn.unit.js +++ b/test/popcorn.unit.js @@ -601,6 +601,41 @@ test("mute", function() { }); +test( "Popcorn.stop", function() { + + var $pop = Popcorn( "#video" ), + count = 0, + expects = 4; + + expect( expects ); + + function plus() { + if ( ++count === expects ) { + start(); + $pop.removePlugin( "exec" ); + } + } + + stop( 8000 ); + + ok( $pop.stop, "stop is a method of the $pop instance" ); + plus(); + + equals( typeof $pop.stop, "function", "$pop.stop is a function" ); + plus(); + + $pop.exec( 4, function() { + $pop.stop(); + + equals( $pop.currentTime(), 0, "currentTime is 0" ); + plus(); + equals( $pop.media.paused, true, "The media is paused" ); + plus(); + }); + + $pop.currentTime( 3 ).play(); + +}); module("Popcorn Static Methods"); @@ -3470,7 +3505,7 @@ test("Parsing Handler - References unavailable plugin", function() { start(); // clean up added events after tests clearInterval( interval ); - poppercore.removePlugin( "parserTest" ); + poppercore.removePlugin( "parserTest" ).stop(); } } @@ -3648,6 +3683,7 @@ test("Parser Support", function() { start(); Popcorn.removePlugin( "testAudioParser" ); + audiocorn.stop(); } } -- 2.43.0