]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
Added Popcorn.p.stop and unit tests [#705]
authorChristopher De Cairos <chris.decairos@gmail.com>
Thu, 15 Sep 2011 20:42:10 +0000 (16:42 -0400)
committerChristopher De Cairos <chris.decairos@gmail.com>
Thu, 15 Sep 2011 20:42:10 +0000 (16:42 -0400)
popcorn.js
test/popcorn.unit.js

index e2c7320a73229cfaa39255e2c7fe59c740cf6e82..faaaf201c4ceb900978500dfe4c69e575044b030 100644 (file)
     timeUpdate: function( event ) {
       Popcorn.timeUpdate.call( null, this, event );
       return this;
+    },
+
+    stop: function() {
+
+      return this.currentTime( 0 ).pause();
     }
   });
 
index 6dfff8f4996c8d8ecd5150f130ac1e8564ec6b5d..f547a857e5f84298d2aefd912617eb57acfa1db1 100644 (file)
@@ -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();
     }
   }