module("Popcorn API");
-test("API", function () {
+test("API", function() {
var expects = 4,
count = 0;
});
-test("Popcorn.* Static Methods", function () {
+test("Popcorn.* Static Methods", function() {
var statics = [ "forEach", "extend", "error", "guid", "sizeOf", "nop",
"addTrackEvent", "removeTrackEvent", "getTrackEvents", "getTrackEvent", "position", "disable", "enable" ],
equal(count, Popcorn.sizeOf(object), Popcorn.sizeOf(object) + " properties in object");
});
-test("Popcorn.util.toSeconds" , function () {
+test("Popcorn.util.toSeconds" , function() {
var framerate = 24,
storedStartTime,
storedEndTime,
}
];
- var equivalentTimes = function ( testedTime, correctTime ) {
+ var equivalentTimes = function( testedTime, correctTime ) {
var tolerance = 0.0001;
return ( testedTime < ( correctTime + tolerance ) ) &&
( testedTime > ( correctTime - tolerance ) );
};
- var logMessage = function ( timeStr, correctTime, incorrectTime ) {
+ var logMessage = function( timeStr, correctTime, incorrectTime ) {
return "Time stored in seconds for '" + timeStr +
"' should be " + correctTime +
". Time stored was " + incorrectTime ;
plus();
});
-test("guid", function () {
+test("guid", function() {
expect(6);
});
-test("Protected", function () {
+test("Protected", function() {
expect(1);
// TODO: comprehensive tests for these utilities
});
-test("Protected from removal", function () {
+test("Protected from removal", function() {
expect( Popcorn.protect.natives.length * 2 );
-test( "Object", function () {
+test( "Object", function() {
var popped = Popcorn( "#video" ),
popObj = Popcorn( document.getElementById( "video" ) ),
popped.play();
- methods.split( /\s+/g ).forEach(function ( k,v ) {
+ methods.split( /\s+/g ).forEach(function( k,v ) {
ok( k in popped, "instance by id has method: " + k );
plus();
popObj.play();
- methods.split( /\s+/g ).forEach(function ( k,v ) {
+ methods.split( /\s+/g ).forEach(function( k,v ) {
ok( k in popObj, "instance by reference has method: " + k );
plus();
-test("roundTime", function () {
+test("roundTime", function() {
QUnit.reset();
});
-test("exec", function () {
+test("exec", function() {
QUnit.reset();
stop( 10000 );
- popped.exec( 4, function () {
+ popped.exec( 4, function() {
ok( loop < 2, "exec callback fired " + ++loop );
plus();
});
-test("mute", function () {
+test("mute", function() {
var video = Popcorn("#video"),
audio = Popcorn("#audio"),
module("Popcorn Static Methods");
-test( "Popcorn.extend", function () {
+test( "Popcorn.extend", function() {
QUnit.reset();
equals( typeof Popcorn.Events.Natives, "string", "Popcorn.Events.Natives is a string" );
equals( typeof Popcorn.events, "object", "Popcorn.events is an object" );
- Popcorn.forEach( eventsReturned, function ( e ) {
+ Popcorn.forEach( eventsReturned, function( e ) {
ok( Popcorn.events.isNative ( e ), e + " is a native event" );
});
module("Popcorn Position");
-test("position", function () {
+test("position", function() {
expect(25);
$("#position-tests").hide();
});
-test("position called from plugin", function () {
+test("position called from plugin", function() {
var $pop = Popcorn("#video"),
expects = 3,
});
});
-test("Stored By Type", function () {
+test("Stored By Type", function() {
QUnit.reset();
stop( 10000 );
- p.listen("play", function () {
+ p.listen("play", function() {
fired++;
ok(true, "Play fired " + fired);
plus();
});
- p.listen("play", function () {
+ p.listen("play", function() {
fired++;
ok(true, "Play fired " + fired);
plus();
});
- p.listen("play", function () {
+ p.listen("play", function() {
fired++;
ok(true, "Play fired " + fired);
plus();
});
- p.listen("play", function () {
+ p.listen("play", function() {
fired++;
ok(true, "Play fired " + fired);
});
-test("Simulated", function () {
+test("Simulated", function() {
QUnit.reset();
stop( 10000 );
- Setup.events.forEach(function ( name ) {
- p.listen( name, function (event) {
+ Setup.events.forEach(function( name ) {
+ p.listen( name, function(event) {
if ( completed.indexOf(name) === -1 ) {
ok( true, name + " fired" );
});
});
- Setup.events.forEach(function ( name ) {
+ Setup.events.forEach(function( name ) {
p.trigger( name );
});
});
-test("Real", function () {
+test("Real", function() {
QUnit.reset();
stop( 10000 );
- [ "play", "pause", "volumechange", "seeking", "seeked" ].forEach(function ( name ) {
+ [ "play", "pause", "volumechange", "seeking", "seeked" ].forEach(function( name ) {
- p.listen( name, function (event) {
+ p.listen( name, function(event) {
if ( completed.indexOf(name) === -1 ) {
ok( true, name + " fired" );
});
-test("Custom", function () {
+test("Custom", function() {
var expects = 1,
count = 0;
var p = Popcorn("#video");
- p.listen("eventz0rz", function ( event ) {
+ p.listen("eventz0rz", function( event ) {
ok( true, "Custom event fired" );
plus();
});
-test("UI/Mouse", function () {
+test("UI/Mouse", function() {
var expects = 1,
count = 0;
var p = Popcorn("#video");
- p.listen("click", function ( event ) {
+ p.listen("click", function( event ) {
ok( true, "click event fired" );
plus();
});
module("Popcorn Plugin")
-test("Manifest", function () {
+test("Manifest", function() {
});
-test("Configurable Defaults", function () {
+test("Configurable Defaults", function() {
var expects = 13,
count = 0;
stop();
- Popcorn.plugin( "configurable", function () {
+ Popcorn.plugin( "configurable", function() {
return {
_setup: function( options ) {
}
});
- Popcorn.plugin( "multiconfig", function () {
+ Popcorn.plugin( "multiconfig", function() {
return {
start: function( event, options ) {
equal( options.target, "quux", 'options.target, "quux" in multiconfig start');
};
});
- Popcorn.plugin( "overridden", function () {
+ Popcorn.plugin( "overridden", function() {
return {
_setup: function( options ) {
equal( options.text, "hello!", 'options.text, overriden with "hello!" in overridden _setup');
});
-test("Start Zero Immediately", function () {
+test("Start Zero Immediately", function() {
var $pop = Popcorn("#video"),
expects = 1,
end: 2
});
});
-test("Update Timer (timeupdate)", function () {
+test("Update Timer (timeupdate)", function() {
QUnit.reset();
// These tests come close to 10 seconds on chrome, increasing to 15
stop( 15000 );
- Popcorn.plugin( "forwards", function () {
+ Popcorn.plugin( "forwards", function() {
return {
- start: function ( event, options ) {
+ start: function( event, options ) {
if ( !options.startFired ) {
plus();
}
},
- end: function ( event, options ) {
+ end: function( event, options ) {
if ( !options.endFired ) {
end: 4
});
- Popcorn.plugin( "backwards", function () {
+ Popcorn.plugin( "backwards", function() {
return {
- start: function ( event, options ) {
+ start: function( event, options ) {
if ( !options.startFired ) {
plus();
}
},
- end: function ( event, options ) {
+ end: function( event, options ) {
if ( !options.endFired ) {
});
Popcorn.plugin( "wrapper", {
- start: function ( event, options ) {
+ start: function( event, options ) {
wrapperRunning[ options.wrapper ] = true;
},
- end: function ( event, options ) {
+ end: function( event, options ) {
wrapperRunning[ options.wrapper ] = false;
}
});
-test("Update Timer (frameAnimation)", function () {
+test("Update Timer (frameAnimation)", function() {
QUnit.reset();
// These tests come close to 10 seconds on chrome, increasing to 15
stop( 15000 );
- Popcorn.plugin( "forwards", function () {
+ Popcorn.plugin( "forwards", function() {
return {
- start: function ( event, options ) {
+ start: function( event, options ) {
if ( !options.startFired ) {
plus();
}
},
- end: function ( event, options ) {
+ end: function( event, options ) {
if ( !options.endFired ) {
end: 4
});
- Popcorn.plugin( "backwards", function () {
+ Popcorn.plugin( "backwards", function() {
return {
- start: function ( event, options ) {
+ start: function( event, options ) {
if ( !options.startFired ) {
plus();
}
},
- end: function ( event, options ) {
+ end: function( event, options ) {
if ( !options.endFired ) {
});
Popcorn.plugin( "wrapper", {
- start: function ( event, options ) {
+ start: function( event, options ) {
wrapperRunning[ options.wrapper ] = true;
},
- end: function ( event, options ) {
+ end: function( event, options ) {
wrapperRunning[ options.wrapper ] = false;
}
});
-test("Plugin Factory", function () {
+test("Plugin Factory", function() {
QUnit.reset();
expect( expects );
stop( 15000 );
- Popcorn.plugin("executor", function () {
+ Popcorn.plugin("executor", function() {
return {
- start: function () {
+ start: function() {
var self = this;
// These ensure that a popcorn instance is the value of `this` inside a plugin definition
- methods.split(/\s+/g).forEach(function (k,v) {
+ methods.split(/\s+/g).forEach(function(k,v) {
ok( k in self, "executor instance has method: " + k );
plus();
ok( Object.prototype.toString.call(popped.data.trackEvents) === "[object Object]", "executor trackEvents property is an object" )
plus();
},
- end: function () {
+ end: function() {
}
};
Popcorn.plugin("complicator", {
- start: function ( event ) {
+ start: function( event ) {
var self = this;
// These ensure that a popcorn instance is the value of `this` inside a plugin definition
- methods.split(/\s+/g).forEach(function (k,v) {
+ methods.split(/\s+/g).forEach(function(k,v) {
ok( k in self, "complicator instance has method: " + k );
plus();
ok( Object.prototype.toString.call(popped.data.trackEvents) === "[object Object]", "complicator trackEvents property is an object" )
plus();
},
- end: function () {
+ end: function() {
//start();
},
- timeupdate: function () {
+ timeupdate: function() {
}
});
});
-test( "Popcorn Compose", function () {
+test( "Popcorn Compose", function() {
QUnit.reset();
popped.currentTime( 0 ).play();
});
-test("Plugin Breaker", function () {
+test("Plugin Breaker", function() {
QUnit.reset();
Popcorn.plugin("breaker", {
- start: function () {
+ start: function() {
breaker.start++;
ok(true, "breaker started");
plus();
},
- end: function () {
+ end: function() {
breaker.end++;
});
-test("Plugin Empty", function () {
+test("Plugin Empty", function() {
QUnit.reset();
});
-test("Plugin Closure", function () {
+test("Plugin Closure", function() {
QUnit.reset();
options.startCount = 0;
options.endCount = 0;
},
- start: function ( event, options ) {
+ start: function( event, options ) {
// called once for each instance; the test will fail if startCount is not actually unique per instance
equals( startCount++, options.startCount++, options.nick + " has correct start counts" );
plus();
},
- end: function ( event, options ) {
+ end: function( event, options ) {
// likewise for endCount
equals( endCount++, options.endCount++, options.nick + " has correct end counts" );
plus();
});
-test("Remove Plugin", function () {
+test("Remove Plugin", function() {
var p = Popcorn("#video"),
p2 = Popcorn("#video"),
Popcorn.plugin("removeme", {
- start: function () {
+ start: function() {
},
- end: function () {
+ end: function() {
},
_teardown: function( options ) {
-test("Protected Names", function () {
+test("Protected Names", function() {
//QUnit.reset();
expect(8);
var popped = Popcorn("#video");
- $.each( "load play pause currentTime playbackRate mute volume duration".split(/\s+/), function (k, name) {
+ $.each( "load play pause currentTime playbackRate mute volume duration".split(/\s+/), function(k, name) {
try {
Popcorn.plugin( name, {});
});
module("Popcorn TrackEvents");
-test("Functions", function () {
+test("Functions", function() {
// TODO: break this into sep. units per function
expect(19);
var popped = Popcorn("#video"), ffTrackId, rwTrackId, rw2TrackId, rw3TrackId, historyRef, trackEvents;
- Popcorn.plugin("ff", function () {
+ Popcorn.plugin("ff", function() {
return {
- start: function () {},
- end: function () {}
+ start: function() {},
+ end: function() {}
};
});
- Popcorn.plugin("rw", function () {
+ Popcorn.plugin("rw", function() {
return {
- start: function () {},
- end: function () {}
+ start: function() {},
+ end: function() {}
};
});
});
-test("getTrackEvent", function () {
+test("getTrackEvent", function() {
// TODO: break this into sep. units per function
expect(5);
var popped = Popcorn("#video"),
trackIds = [], obj, oldId;
- Popcorn.plugin("ff", function () {
+ Popcorn.plugin("ff", function() {
return {
- start: function () {},
- end: function () {}
+ start: function() {},
+ end: function() {}
};
});
trackIds.push( popped.getLastTrackEventId() );
- Popcorn.plugin("rw", function () {
+ Popcorn.plugin("rw", function() {
return {
- start: function () {},
- end: function () {}
+ start: function() {},
+ end: function() {}
};
});
});
-test("Index Integrity", function () {
+test("Index Integrity (timeupdate)", function() {
+ var trackLen,
+ hasrun = false,
+ lastrun = false;
-
- var trackLen, hasrun = false, lastrun = false;
-
-
- Popcorn.plugin("ff", function () {
+ Popcorn.plugin("ff", function() {
return {
- start: function () {
- var div = document.createElement('div');
+ start: function() {
+ var div = document.createElement("div");
div.id = "index-test";
div.innerHTML = "foo";
document.body.appendChild(div);
},
- end: function () {
- document.getElementById('index-test').parentNode.removeChild(document.getElementById('index-test'));
+ end: function() {
+ document.getElementById("index-test").parentNode.removeChild(document.getElementById("index-test"));
}
};
});
-
var p = Popcorn("#video");
p.ff({
equals(p.data.trackEvents.startIndex, 0, "p.data.trackEvents.startIndex is 0");
equals(p.data.trackEvents.byStart.length, 3, "p.data.trackEvents.byStart.length is 3 - before play" );
-
-
-
- p.listen("timeupdate", function () {
-
- if ( p.roundTime() > 40 && p.roundTime() < 42 && !hasrun ) {
- }
+ p.listen("timeupdate", function() {
if ( p.roundTime() > 40 && p.roundTime() < 42 && hasrun && !lastrun ) {
lastrun = true;
- equals( document.getElementById('index-test'), null, "document.getElementById('index-test') is null on second run - after removeTrackEvent" );
+ equals( document.getElementById("index-test"), null, "document.getElementById('index-test') is null on second run - after removeTrackEvent" );
start();
}
equals(p.data.trackEvents.startIndex, 2, "p.data.trackEvents.startIndex is 2 - after play, before removeTrackEvent");
equals(p.data.trackEvents.endIndex, 2, "p.data.trackEvents.endIndex is 2 - after play, before removeTrackEvent");
-
-
p.removeTrackEvent("removeable-track-event");
equals(p.data.trackEvents.byStart.length, 2, "p.data.trackEvents.byStart.length is 2 - after removeTrackEvent" );
equals(p.data.trackEvents.startIndex, 1, "p.data.trackEvents.startIndex is 1 - after removeTrackEvent");
equals(p.data.trackEvents.endIndex, 1, "p.data.trackEvents.endIndex is 1 - after removeTrackEvent");
-
-
p.currentTime(40).play();
-
-
}
});
p.play();
-
-
});
-test("Index Integrity (frameAnimation)", function () {
-
+test("Index Integrity (frameAnimation)", function() {
+ var trackLen,
+ hasrun = false,
+ lastrun = false;
- var trackLen, hasrun = false, lastrun = false;
-
-
- Popcorn.plugin("ff", function () {
+ Popcorn.plugin("ff", function() {
return {
- start: function () {
- var div = document.createElement('div');
+ start: function() {
+ var div = document.createElement("div");
div.id = "index-test";
div.innerHTML = "foo";
document.body.appendChild(div);
},
- end: function () {
- document.getElementById('index-test').parentNode.removeChild(document.getElementById('index-test'));
+ end: function() {
+ document.getElementById("index-test").parentNode.removeChild(document.getElementById("index-test"));
}
};
});
-
var p = Popcorn("#video", { frameAnimation: true });
p.ff({
equals(p.data.trackEvents.startIndex, 0, "p.data.trackEvents.startIndex is 0");
equals(p.data.trackEvents.byStart.length, 3, "p.data.trackEvents.byStart.length is 3 - before play" );
-
-
-
- p.listen("timeupdate", function () {
-
- if ( p.roundTime() > 40 && p.roundTime() < 42 && !hasrun ) {
- }
+ p.listen("timeupdate", function() {
if ( p.roundTime() > 40 && p.roundTime() < 42 && hasrun && !lastrun ) {
lastrun = true;
- equals( document.getElementById('index-test'), null, "document.getElementById('index-test') is null on second run - after removeTrackEvent" );
+ equals( document.getElementById("index-test"), null, "document.getElementById('index-test') is null on second run - after removeTrackEvent" );
start();
}
equals(p.data.trackEvents.startIndex, 2, "p.data.trackEvents.startIndex is 2 - after play, before removeTrackEvent");
equals(p.data.trackEvents.endIndex, 2, "p.data.trackEvents.endIndex is 2 - after play, before removeTrackEvent");
-
-
p.removeTrackEvent("removeable-track-event");
equals(p.data.trackEvents.byStart.length, 2, "p.data.trackEvents.byStart.length is 2 - after removeTrackEvent" );
equals(p.data.trackEvents.startIndex, 1, "p.data.trackEvents.startIndex is 1 - after removeTrackEvent");
equals(p.data.trackEvents.endIndex, 1, "p.data.trackEvents.endIndex is 1 - after removeTrackEvent");
-
-
p.currentTime(40).play();
-
-
-
}
});
p.play();
-
-
});
test("Popcorn.disable/enable/toggle (timeupdate)", function() {
-
var $pop = Popcorn( "#video" ),
count = 0,
expects = 5;
start();
Popcorn.removeInstance( $pop );
- Popcorn.removePlugin( "toggler" );
+ Popcorn.removePlugin( "toggler" );
}
}
- Popcorn.plugin("toggler", function () {
+ Popcorn.plugin("toggler", function() {
return {
- start: function () {
+ start: function() {
var div = document.createElement("div");
div.id = "toggler-test";
div.innerHTML = "foo";
document.body.appendChild(div);
},
- end: function () {
+ end: function() {
document.getElementById("toggler-test").parentNode.removeChild(document.getElementById("toggler-test"));
}
};
});
module("Popcorn XHR");
-test("Basic", function () {
+test("Basic", function() {
expect(2);
});
-test("Text Response", function () {
+test("Text Response", function() {
var expects = 2,
count = 0;
});
});
-test("dataType: Text Response", function () {
+test("dataType: Text Response", function() {
var expects = 2,
count = 0;
});
-test("JSON Response", function () {
+test("JSON Response", function() {
var expects = 2,
count = 0;
});
-test("dataType: JSON Response", function () {
+test("dataType: JSON Response", function() {
var expects = 2,
count = 0;
if ( !/file/.test( location.protocol ) ) {
- test("JSONP Response", function () {
+ test("JSONP Response", function() {
var expects = 8,
count = 0;
});
} else {
- test("JSONP Response", function () {
+ test("JSONP Response", function() {
expect(1);
});
}
-test("Popcorn.getScript()", function () {
+test("Popcorn.getScript()", function() {
var expects = 8,
count = 0;
});
-test("XML Response", function () {
+test("XML Response", function() {
var expects = 2,
count = 0;
});
-test("dataType: XML Response", function () {
+test("dataType: XML Response", function() {
var expects = 2,
count = 0;
module("Popcorn Parser");
-test("Parsing Functions", function () {
+test("Parsing Functions", function() {
var expects = 3,
count = 0,
});
-test("Parsing Integrity", function () {
+test("Parsing Integrity", function() {
var expects = 6,
count = 0,
Popcorn.plugin("parserTest", {
- start: function () {
+ start: function() {
ok(true, "parserTest started");
plus();
},
- end: function () {
+ end: function() {
ok(true, "parserTest ended");
plus();
}
});
-test("Parsing Handler - References unavailable plugin", function () {
+test("Parsing Handler - References unavailable plugin", function() {
var expects = 1,
count = 0,
});
module("Audio");
-test( "Basic Audio Support (timeupdate)", function () {
+test( "Basic Audio Support (timeupdate)", function() {
var popped = Popcorn( "#audio" ),
popObj = Popcorn( document.getElementById( "audio" ) ),
popped.play();
- methods.split( /\s+/g ).forEach(function ( k,v ) {
+ methods.split( /\s+/g ).forEach(function( k,v ) {
ok( k in popped, "instance by id has method: " + k );
plus();
popObj.play();
- methods.split( /\s+/g ).forEach(function ( k,v ) {
+ methods.split( /\s+/g ).forEach(function( k,v ) {
ok( k in popObj, "instance by reference has method: " + k );
plus();
});
});
-test( "Basic Audio Support (frameAnimation)", function () {
+test( "Basic Audio Support (frameAnimation)", function() {
var popped = Popcorn( "#audio", { frameAnimation: true }),
popObj = Popcorn( document.getElementById( "audio" ), { frameAnimation: true }),
popped.play();
- methods.split( /\s+/g ).forEach(function ( k,v ) {
+ methods.split( /\s+/g ).forEach(function( k,v ) {
ok( k in popped, "instance by id has method: " + k );
plus();
popObj.play();
- methods.split( /\s+/g ).forEach(function ( k,v ) {
+ methods.split( /\s+/g ).forEach(function( k,v ) {
ok( k in popObj, "instance by reference has method: " + k );
plus();
});
});
-test("Parser Support", function () {
+test("Parser Support", function() {
var expects = 3,
count = 0,
module("Popcorn Test Runner End");
-test("Last Check", function () {
+test("Last Check", function() {
// ALWAYS RUN LAST
try {