]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#700] Popcorn dummies; Includes test suite w/ 59 tests
authorrwldrn <waldron.rick@gmail.com>
Wed, 31 Aug 2011 17:54:23 +0000 (13:54 -0400)
committerrwldrn <waldron.rick@gmail.com>
Wed, 31 Aug 2011 17:54:23 +0000 (13:54 -0400)
popcorn.js
test/archaic.html [new file with mode: 0644]
test/index.html
test/popcorn.unit.archaic.js [new file with mode: 0644]
test/popcorn.unit.archaic.setup.js [new file with mode: 0644]
test/popcorn.unit.setup.js
test/ready.html

index 51659a728ad55b8cdf113942933a744e4ea5f5d4..2b5ad22303b816615a612ebe331bac8b4badeeae 100644 (file)
@@ -1,6 +1,19 @@
 (function(global, document) {
 
-  //  Cache refs to speed up calls to native utils
+  // Popcorn.js does not support archaic browsers
+  if ( !document.addEventListener ) {
+    global.Popcorn = {};
+
+    var methods = ( "removeInstance addInstance getInstanceById removeInstanceById " + 
+          "forEach extend effects error guid sizeOf isArray nop position disable enable " + 
+          "addTrackEvent removeTrackEvent getTrackEvents getTrackEvent getLastTrackEventId " + 
+          "timeUpdate plugin removePlugin compose effect parser xhr getJSONP getScript" ).split(/\s+/);
+
+    while( methods.length ) {
+      global.Popcorn[ methods.shift() ] = function(){};
+    }
+    return;
+  }
 
   var
 
diff --git a/test/archaic.html b/test/archaic.html
new file mode 100644 (file)
index 0000000..c72a4b2
--- /dev/null
@@ -0,0 +1,110 @@
+<!DOCTYPE html>\r
+<html>\r
+<head>\r
+  <title>Simulate Archaic Browser</title>\r
+  <link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen">\r
+\r
+  <style>\r
+    body {\r
+      margin: 3px;\r
+      padding: 0px;\r
+    }\r
+    h3 {\r
+      margin: 3px;\r
+      padding: 0px;\r
+    }\r
+    h2 {\r
+      display: inline;\r
+      margin: 3px;\r
+      padding: 0px;\r
+    }    \r
+    .pass {\r
+      color: #33FF00;\r
+    }\r
+    .expect {\r
+      color: #2d2d2d;\r
+    }    \r
+    .fail {\r
+      color: #FF0000;\r
+    }\r
+  </style>\r
+  <script src="jquery.js"></script>\r
+\r
+\r
+  <script src="qunit/qunit.js"></script>\r
+\r
+  <!--\r
+    do not move - this must be called immediately prior to\r
+    popcorn-api-draft.js\r
+  -->\r
+  <script src="popcorn.unit.setup.js"></script>\r
+  <script src="popcorn.unit.archaic.setup.js"></script>\r
+\r
+  <script src="../popcorn.js"></script>\r
+  <script src="popcorn.unit.archaic.js"></script>\r
+  <script>\r
+  (function( Popcorn, $ ) {\r
+\r
+    var results = {\r
+          pass: 0, \r
+          fail: 0,\r
+          expect: 40\r
+        };\r
+\r
+    $(function() {\r
+\r
+      function isComplete( callback ) {\r
+\r
+        if ( !QUnit.config.queue.length ) {\r
+          // is complete\r
+\r
+          callback && callback( QUnit.config.stats );\r
+\r
+        } else {\r
+          setTimeout(function() {\r
+            isComplete( callback );\r
+          }, 10 );\r
+        }\r
+      }\r
+\r
+      isComplete(function( qResults ) {\r
+\r
+        //  Hack together the results as used in ready.html\r
+        results.pass = qResults.all - qResults.bad;\r
+        results.fail = qResults.bad;\r
+        results.expect = qResults.all;\r
+\r
+        $.each( results, function( name, value ) {\r
+          $("#qunit-header").before( \r
+            $("<h2>", {\r
+              className: name, \r
+              html: name + ": " + value  \r
+            }) \r
+          );\r
+        });\r
+      \r
+      });\r
+    });\r
+  })( Popcorn, jQuery );\r
+\r
+  </script>\r
+</head>\r
+<body>\r
+  <h3>Archaic<h3>\r
+\r
+  <h1 id="qunit-header">\r
+    Popcorn.js: Simulate Archaic Browser\r
+  </h1>\r
+  <h2 id="qunit-banner"></h2>\r
+  <div id="qunit-testrunner-toolbar"></div>\r
+  <h2 id="qunit-userAgent"></h2>\r
+  <ol id="qunit-tests"></ol>\r
+  <div id="qunit-fixture">\r
+\r
+\r
+\r
+\r
+\r
+  </div>\r
+</body>\r
+</html>\r
index dd813c18aa5b0a0f00058d3c4c9adb87b4745f55..b54d7e7ab08734de9a02c8cbdcedbc95b259543e 100644 (file)
@@ -20,6 +20,8 @@
 <body>
   <h1 id="qunit-header">
     Popcorn.js API
+    <iframe id="archaic-tests" data-src="archaic.html" style="width:325px;height:60px;float:right;border:0px;margin:-10px 20px 0 -10px;background:#fff" ></iframe>
+    
     <iframe id="butter-tests" data-src="butter_test.html" style="width:325px;height:60px;float:right;border:0px;margin:-10px 20px 0 -10px;background:#fff" ></iframe>
 
     <iframe id="ready-tests" data-src="ready.html" style="width:325px;height:60px;float:right;border:0px;margin:-10px 20px 0 -10px;background:#fff" ></iframe>
diff --git a/test/popcorn.unit.archaic.js b/test/popcorn.unit.archaic.js
new file mode 100644 (file)
index 0000000..e1df25c
--- /dev/null
@@ -0,0 +1,56 @@
+module("Core");
+test("Dummy", function () {
+
+  expect(1);
+
+  ok( Popcorn, "Popcorn dummy exists");
+});
+
+module("Static Methods");
+(function() {
+
+  var method, 
+      methods = ( "removeInstance addInstance getInstanceById removeInstanceById " +
+          "forEach extend effects error guid sizeOf isArray nop position disable enable " +
+          "addTrackEvent removeTrackEvent getTrackEvents getTrackEvent getLastTrackEventId " +
+          "timeUpdate plugin removePlugin compose effect parser xhr getJSONP getScript" ).split(/\s+/);
+
+  while( methods.length ) {
+
+    method = methods.shift();
+
+    test( method, function () {
+
+      expect(1);
+
+      ok( Popcorn[ method ], "Popcorn." + method + " exists");
+    });
+  }
+
+})( Popcorn );
+
+
+module("Attempt");
+(function() {
+
+  var method, 
+      methods = ( "removeInstance addInstance getInstanceById removeInstanceById " +
+          "forEach extend effects error guid sizeOf isArray nop position disable enable " +
+          "addTrackEvent removeTrackEvent getTrackEvents getTrackEvent getLastTrackEventId " +
+          "timeUpdate plugin removePlugin compose effect parser xhr getJSONP getScript" ).split(/\s+/);
+
+  while( methods.length ) {
+
+    method = methods.shift();
+
+    test( method, function () {
+
+      expect(1);
+
+      equal( Popcorn[ method ](), undefined, "Popcorn." + method + "() dummy returns undefined without throwing exception");
+
+    });
+  }
+
+})( Popcorn );
+
diff --git a/test/popcorn.unit.archaic.setup.js b/test/popcorn.unit.archaic.setup.js
new file mode 100644 (file)
index 0000000..16cff7b
--- /dev/null
@@ -0,0 +1,3 @@
+\r
+\r
+document.addEventListener = null;\r
index ebfa253eeb65633eb95da8576cae4e133b916bc7..4f2394846680c6458fcaad88eaab9a3787bf6500 100644 (file)
@@ -1,13 +1,15 @@
 //  suppress console log errors
 if ( !window['console'] ) {
-  var console = {}, 
-      methods = 'log debug info warn error exception assert dir dirxml trace group groupEnd groupCollapsed time timeEnd profile profileEnd count clear notifyFirebug getFirebugElement firebug element'.split(' ');
-  
-  for ( var m in methods ) {
-    console[ methods[m] ] = function () {
-      //Array.prototype.slice.call(arguments)
-    };
-  }  
+//  var console = {}, 
+//      methods = 'log debug info warn error exception assert dir dirxml trace group groupEnd groupCollapsed time timeEnd profile profileEnd count clear notifyFirebug getFirebugElement firebug element'.split(' ');
+//  
+//  for ( var m in methods ) {
+//    console[ methods[m] ] = function () {
+//      //Array.prototype.slice.call(arguments)
+//    };
+//  }
+
+  jQuery.getScript("https://getfirebug.com/firebug-lite-debug.js");
 }
 
 
index 8bf78d18e4643cd703ba23dc45486d6a5c6154a6..deccc2b172cabf5f2a595a687559a32122ce3608 100644 (file)
@@ -4,89 +4,89 @@
   <title>Popcorn API</title>
   <link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen">
 
-       <style>
-               body {
-                       margin: 3px;
-                       padding: 0px;
-               }
-               h3 {
-                       margin: 3px;
-                       padding: 0px;
-               }
-               h2 {
-                       display: inline;
-                       margin: 3px;
-                       padding: 0px;
-               }               
-               .pass {
-                       color: #33FF00;
-               }
-               .expect {
-                       color: #2d2d2d;
-               }               
-               .fail {
-                       color: #FF0000;
-               }
-       </style>
-       <script src="jquery.js"></script>
+  <style>
+    body {
+      margin: 3px;
+      padding: 0px;
+    }
+    h3 {
+      margin: 3px;
+      padding: 0px;
+    }
+    h2 {
+      display: inline;
+      margin: 3px;
+      padding: 0px;
+    }    
+    .pass {
+      color: #33FF00;
+    }
+    .expect {
+      color: #2d2d2d;
+    }    
+    .fail {
+      color: #FF0000;
+    }
+  </style>
+  <script src="jquery.js"></script>
   <script src="../popcorn.js"></script>
   <script>
-       (function( Popcorn, $ ) {
-
-               var readyCalled = 0, 
-                               readyOrder = [], 
-                               readyComposed = "Ready Callback 1,Ready Callback 2", 
-                               results = {
-                                       pass: 0, 
-                                       fail: 0,
-                                       expect: 2
-                               };
-
-               $(function() {
-                 readyCalled++;
-               });
-
-               Popcorn(function (e) {
-
-                 readyCalled++;
-                 readyOrder.push("Ready Callback 1");
-                 
-                 Popcorn("#video").exec( 1, function () {
-
-                               results[ 
-                                       ( readyCalled === 3 ? "pass" : "fail" ) 
-                               ]++;
-
-                               if ( readyOrder.join(",") === readyComposed ) {
-                                       results.pass++;
-                               }
-
-                               $.each( results, function( name, value ) {
-                                       $("video").before( 
-                                               $("<h2>", {
-                                                       className: name, 
-                                                       html: name + ": " + value  
-                                               }) 
-                                       );
-                               });
-
-                 }).play().volume(0);
-                 
-               });
-
-               Popcorn(function () {
-                 
-                 readyCalled++;
-                 readyOrder.push("Ready Callback 2");
-
-               });     
-       })( Popcorn, jQuery );
+  (function( Popcorn, $ ) {
+
+    var readyCalled = 0, 
+        readyOrder = [], 
+        readyComposed = "Ready Callback 1,Ready Callback 2", 
+        results = {
+          pass: 0, 
+          fail: 0,
+          expect: 2
+        };
+
+    $(function() {
+      readyCalled++;
+    });
+
+    Popcorn(function (e) {
+
+      readyCalled++;
+      readyOrder.push("Ready Callback 1");
+      
+      Popcorn("#video").exec( 1, function () {
+
+        results[ 
+          ( readyCalled === 3 ? "pass" : "fail" ) 
+        ]++;
+
+        if ( readyOrder.join(",") === readyComposed ) {
+          results.pass++;
+        }
+
+        $.each( results, function( name, value ) {
+          $("video").before( 
+            $("<h2>", {
+              className: name, 
+              html: name + ": " + value  
+            }) 
+          );
+        });
+
+      }).play().volume(0);
+      
+    });
+
+    Popcorn(function () {
+      
+      readyCalled++;
+      readyOrder.push("Ready Callback 2");
+
+    });    
+  })( Popcorn, jQuery );
 
   </script>
   
 </head>
 <body>
-       <h3>Popcorn(/* DOM Ready */)<h3>
+  <h3>Popcorn(/* DOM Ready */)<h3>
 
   <video id='video'style="display:none" 
     controls