Skip to content

Commit

Permalink
[t1066] review changes
Browse files Browse the repository at this point in the history
1. Some more rigorous tests
2. Whitespace fixes
3. Used Popcorn.dom.find instead of doc.getEl()
  • Loading branch information
secretrobotron committed May 9, 2012
1 parent 947b831 commit 08e56cf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
4 changes: 2 additions & 2 deletions modules/player/popcorn.player.js
Expand Up @@ -404,13 +404,13 @@

if ( !targetType ) {

targetType = ( target.charAt( 0 ) === "#" ? document.getElementById( target.substring( 1 ) ) : document.getElementById( target ) ).nodeName;
targetType = Popcorn.dom.find( target ).nodeName;

}

// If src is an array, add <source>'s
if ( typeof( src ) !== "string" && src.length ) {

for ( var i = 0; i < src.length; ++i ) {

sourceNode = document.createElement( "source" );
Expand Down
23 changes: 19 additions & 4 deletions modules/player/popcorn.player.unit.js
Expand Up @@ -333,7 +333,7 @@ asyncTest( "Popcorn.smart - audio and video elements", function() {
});

asyncTest( "Popcorn.smart - multiple sources for HTML5 media", function() {
expect( 6 );
expect( 19 );

var instanceDiv,
count = 0,
Expand All @@ -345,13 +345,28 @@ asyncTest( "Popcorn.smart - multiple sources for HTML5 media", function() {

instanceDiv = document.getElementById( "multi-div" );
ok( instanceDiv.firstChild && instanceDiv.firstChild.childNodes.length === 3, "multi-div has 3 children" );
ok( instanceDiv.firstChild.childNodes[ 0 ].nodeName === "SOURCE", "multi-div has <source> children" );
ok( instanceDiv.firstChild.childNodes[ 0 ].nodeName === "SOURCE", "multi-div has <source> children [ 0 ]" );
ok( instanceDiv.firstChild.childNodes[ 1 ].nodeName === "SOURCE", "multi-div has <source> children [ 1 ]" );
ok( instanceDiv.firstChild.childNodes[ 2 ].nodeName === "SOURCE", "multi-div has <source> children [ 2 ]" );
ok( instanceDiv.firstChild.childNodes[ 0 ].getAttribute( "type" ) === "video/ogv", "source[ 0 ] is correct type" );
ok( instanceDiv.firstChild.childNodes[ 1 ].getAttribute( "type" ) === "video/webm", "source[ 1 ] is correct type" );
ok( instanceDiv.firstChild.childNodes[ 2 ].getAttribute( "type" ) === "video/mp4", "source[ 2 ] is correct type" );

instanceDiv = document.getElementById( "multi-video" );
ok( instanceDiv.childNodes.length === 3, "multi-video has 3 children" );
ok( instanceDiv.childNodes[ 0 ].nodeName === "SOURCE", "multi-video has <source> children" );
ok( instanceDiv.childNodes[ 0 ].nodeName === "SOURCE", "multi-video has <source> children [ 0 ]" );
ok( instanceDiv.childNodes[ 1 ].nodeName === "SOURCE", "multi-video has <source> children [ 1 ]" );
ok( instanceDiv.childNodes[ 2 ].nodeName === "SOURCE", "multi-video has <source> children [ 2 ]" );
ok( instanceDiv.childNodes[ 0 ].getAttribute( "type" ) === "video/ogv", "source[ 0 ] is correct type" );
ok( instanceDiv.childNodes[ 1 ].getAttribute( "type" ) === "video/webm", "source[ 1 ] is correct type" );
ok( instanceDiv.childNodes[ 2 ].getAttribute( "type" ) === "video/mp4", "source[ 2 ] is correct type" );

instanceDiv = document.getElementById( "multi-audio" );
ok( instanceDiv.childNodes.length === 2, "multi-audio has 2 children" );
ok( instanceDiv.childNodes[ 0 ].nodeName === "SOURCE", "multi-audio has <source> children" );
ok( instanceDiv.childNodes[ 0 ].nodeName === "SOURCE", "multi-audio has <source> children [ 0 ]" );
ok( instanceDiv.childNodes[ 1 ].nodeName === "SOURCE", "multi-audio has <source> children [ 1 ]" );
ok( instanceDiv.childNodes[ 0 ].getAttribute( "type" ) === "audio/ogg", "source[ 0 ] is correct type" );
ok( instanceDiv.childNodes[ 1 ].getAttribute( "type" ) === "audio/mp4", "source[ 1 ] is correct type" );

start();

Expand Down

0 comments on commit 08e56cf

Please sign in to comment.