]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#729] Adds in cadecairos' tests from #t705
authorRick Waldron <waldron.rick@gmail.com>
Wed, 21 Sep 2011 20:11:10 +0000 (16:11 -0400)
committerRick Waldron <waldron.rick@gmail.com>
Wed, 21 Sep 2011 20:14:03 +0000 (16:14 -0400)
popcorn.js
test/popcorn.unit.js

index b0e9e0a6aebcda86a9722c781689d9031871310c..2e4e9ea8fdc6211443571afeb5a11c46ea5a0cdc 100644 (file)
             // Support for shorthanded play(n)/pause(n) jump to currentTime
             // If arg is not null or undefined and called by one of the
             // allowed shorthandable methods, then set the currentTime
-                                               // Supports time as seconds or SMPTE
+            // Supports time as seconds or SMPTE
             if ( arg != null && /play|pause/.test( name ) ) {
               this.media.currentTime = Popcorn.util.toSeconds( arg );
             }
index 61b9a86d54f7d89287cb93e3f5cb24b91f889ff7..55a5e9a4f7cb638b58125942160e68b53f517dec 100644 (file)
@@ -601,7 +601,7 @@ test("mute", function() {
 
 });
 
-test("play(n) as shorthand to currentTime(n).play()", function() {
+test( "play(n)/pause(n) as shorthand to currentTime(n).play()/pause()", function() {
 
   var $pop = Popcorn( "#video" ),
     expects = 2,
@@ -641,6 +641,58 @@ test("play(n) as shorthand to currentTime(n).play()", function() {
   poll();
 });
 
+// Originally written for #705 by chris de cairos
+test( "play(n)/pause(n) custom stop()", function() {
+
+  // Implement custom stop() method
+  Popcorn.p.stop = function() {
+    return this.pause( 0 );
+  };
+
+  var outerHTML = document.getElementById("video").outerHTML,
+      count = 0,
+      expects = 2,
+      $pop;
+
+  document.getElementById("qunit-fixture").innerHTML = outerHTML.replace('id="video"', 'id="video-fixture"');
+
+  $pop = Popcorn( "#video-fixture" );
+
+  expect( expects );
+
+  function plus() {
+    if ( ++count === expects ) {
+      // Remove custom stop() method
+      delete Popcorn.p.stop;
+      start();
+    }
+  }
+
+  stop( 8000 );
+
+  $pop.listen( "canplayall", function() {
+
+    this.exec( 4, function() {
+
+      this.listen( "seeked", function() {
+
+        this.unlisten( "seeked" );
+
+        equal( this.currentTime(), 0, "currentTime is 0" );
+        plus();
+
+        equal( this.media.paused, true, "The media is paused" );
+        plus();
+
+      // Call custom "stop()"
+      }).stop();
+    });
+
+    // Play from 3s
+    this.play( 3 );
+  });
+});
+
 
 module("Popcorn Static Methods");
 
@@ -1591,7 +1643,7 @@ test("Update Timer (timeupdate)", function() {
       Popcorn.removePlugin( "forwards" );
       Popcorn.removePlugin( "backwards" );
       Popcorn.removePlugin( "wrapper" );
-      p2.removePlugin( "exec" );
+      p2.removePlugin( "exec" ); // TODO: David, remove this during test suite cleanup ^RW
       start();
     }
   }
@@ -1759,7 +1811,7 @@ test("Update Timer (frameAnimation)", function() {
       Popcorn.removePlugin( "forwards" );
       Popcorn.removePlugin( "backwards" );
       Popcorn.removePlugin( "wrapper" );
-      p2.removePlugin( "exec" );
+      p2.removePlugin( "exec" ); // TODO: David, remove this during test suite cleanup ^RW
       start();
     }
   }