]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#572] fixed addtrackevent typo... and tests for it
authorScottDowne <sdowne@learn.senecac.on.ca>
Mon, 13 Jun 2011 22:52:29 +0000 (18:52 -0400)
committerScottDowne <sdowne@learn.senecac.on.ca>
Mon, 13 Jun 2011 22:52:29 +0000 (18:52 -0400)
popcorn.js
test/popcorn.unit.js

index d5adf76528ff9b1ab18f0472db07bf9f8410db5e..3d4fefae8371e42eb4985c843afb98ef11447ec4 100644 (file)
 
     for ( idx = byEnd.length-1; idx >= 0; idx-- ) {
 
-      if ( track.start >= byEnd[idx].start ) {
+      if ( track.end > byEnd[idx].end ) {
         byEnd.splice( idx + 1, 0, track );
         break;
       }
index 099a1986368738518df6ac926ee4dec18cfdefe1..fe26dc11446ecf2b494f3c3d4c4a36f64364b012 100644 (file)
@@ -1008,27 +1008,30 @@ test("Update Timer", function () {
   QUnit.reset();
 
   var p2 = Popcorn("#video"),
-      expects = 4,
+      expects = 12,
       count   = 0,
       // These make sure events are only fired once
       // any second call will produce a failed test
       forwardStart  = false,
       forwardEnd    = false,
       backwardStart = false,
-      backwardEnd   = false;
+      backwardEnd   = false,
+      wrapperRunning = { one: false, two: false, };
 
   function plus() {
     if ( ++count === expects ) {
-      start();
       // clean up added events after tests
-      Popcorn.removePlugin("forwards");
-      Popcorn.removePlugin("backwards");
+      Popcorn.removePlugin( "forwards" );
+      Popcorn.removePlugin( "backwards" );
+      Popcorn.removePlugin( "wrapper" );
+      p2.removePlugin( "exec" );
+      start();
     }
   }
 
-  stop(10000);
+  stop( 10000 );
 
-  Popcorn.plugin("forwards", function () {
+  Popcorn.plugin( "forwards", function () {
     return {
       start: function () {
         forwardStart = !forwardStart;
@@ -1049,7 +1052,7 @@ test("Update Timer", function () {
     end: 4
   });
 
-  Popcorn.plugin("backwards", function () {
+  Popcorn.plugin( "backwards", function () {
     return {
       start: function () {
         backwardStart = !backwardStart;
@@ -1061,6 +1064,7 @@ test("Update Timer", function () {
         backwardEnd = !backwardEnd;
         ok( backwardEnd, "backward's end fired");
         plus();
+        p2.currentTime(5).play();
       }
     };
   });
@@ -1070,6 +1074,59 @@ test("Update Timer", function () {
     end: 2
   });
 
+  Popcorn.plugin( "wrapper", {
+    start: function ( event, options ) {
+
+      wrapperRunning[ options.wrapper ] = true;
+    },
+    end: function ( event, options ) {
+
+      wrapperRunning[ options.wrapper ] = false;
+    }
+  });
+
+  p2.wrapper({
+    start: 6,
+    end: 7,
+    wrapper: "one"
+  })
+  .wrapper({
+    start: 5,
+    end: 8,
+    wrapper: "two"
+  })
+  .exec( 5, function() {
+
+    ok( wrapperRunning.two, "wrapper two is running" );
+    plus();
+    ok( !wrapperRunning.one, "wrapper one is stopped" );
+    plus();
+  })
+  // checking wrapper 1's start
+  .exec( 6, function() {
+
+    ok( wrapperRunning.two, "wrapper two is running" );
+    plus();
+    ok( wrapperRunning.one, "wrapper one is running" );
+    plus();
+  })
+  // checking wrapper 1's end
+  .exec( 7, function() {
+
+    ok( wrapperRunning.two, "wrapper two is running" );
+    plus();
+    ok( !wrapperRunning.one, "wrapper one is stopped" );
+    plus();
+  })
+  // checking wrapper 2's end
+  .exec( 9, function() {
+
+    ok( !wrapperRunning.two, "wrapper two is stopped" );
+    plus();
+    ok( !wrapperRunning.one, "wrapper one is stopped" );
+    plus();
+  });
+
   p2.currentTime(3).play();
 
 });