From 080c03ac7f3ce2a9cf6ca7e97dc1f3bbfff9016f Mon Sep 17 00:00:00 2001 From: ScottDowne Date: Tue, 8 Mar 2011 11:17:43 -0500 Subject: [PATCH] [#374] removing setinterval from plugin tests, had problems with wiki, so not included yet --- plugins/flickr/popcorn.flickr.unit.js | 32 ++--- plugins/footnote/popcorn.footnote.unit.js | 77 +++++------- plugins/googlemap/popcorn.googlemap.unit.js | 99 +++++++-------- plugins/image/popcorn.image.unit.js | 33 ++--- plugins/lastfm/popcorn.lastfm.unit.js | 96 +++++++-------- .../popcorn.tagthisperson.unit.js | 116 ++++++++---------- plugins/twitter/popcorn.twitter.unit.js | 32 ++--- plugins/webpage/popcorn.webpage.unit.js | 98 +++++++-------- 8 files changed, 248 insertions(+), 335 deletions(-) diff --git a/plugins/flickr/popcorn.flickr.unit.js b/plugins/flickr/popcorn.flickr.unit.js index f539515..d41d8b5 100644 --- a/plugins/flickr/popcorn.flickr.unit.js +++ b/plugins/flickr/popcorn.flickr.unit.js @@ -3,8 +3,6 @@ test("Popcorn Flickr Plugin", function () { var popped = Popcorn("#video"), expects = 5, count = 0, - interval, - interval2, flickrdiv = document.getElementById('flickrdiv'); expect( expects ); @@ -25,29 +23,23 @@ test("Popcorn Flickr Plugin", function () { popped.flickr({ start: 1, // seconds - end: 3, // seconds + end: 3, // seconds userid: '35034346917@N01', numberofimages: '1', target: 'flickrdiv' } ); - interval = setInterval( function() { - if( popped.currentTime() > 1 && popped.currentTime() < 3 ) { - ok( /display: inline;/.test( flickrdiv.innerHTML ), "Div contents are displayed" ); - plus(); - ok( /img/.test( flickrdiv.innerHTML ), "An image exists" ); - plus(); - clearInterval( interval ); - } - }, 500); - - interval2 = setInterval( function() { - if( popped.currentTime() > 3 ) { - ok( /display: none;/.test( flickrdiv.innerHTML ), "Div contents are hidden again" ); - plus(); - clearInterval( interval2 ); - } - }, 500); + popped.exec( 2, function() { + ok( /display: inline;/.test( flickrdiv.innerHTML ), "Div contents are displayed" ); + plus(); + ok( /img/.test( flickrdiv.innerHTML ), "An image exists" ); + plus(); + }); + + popped.exec( 4, function() { + ok( /display: none;/.test( flickrdiv.innerHTML ), "Div contents are hidden again" ); + plus(); + }); popped.volume(0); popped.play(); diff --git a/plugins/footnote/popcorn.footnote.unit.js b/plugins/footnote/popcorn.footnote.unit.js index 6c44e00..7693bec 100644 --- a/plugins/footnote/popcorn.footnote.unit.js +++ b/plugins/footnote/popcorn.footnote.unit.js @@ -3,9 +3,6 @@ test("Popcorn Footnote Plugin", function () { var popped = Popcorn("#video"), expects = 7, count = 0, - interval, - interval2, - interval3, footnotediv = document.getElementById('footnotediv'); expect(expects); @@ -25,47 +22,37 @@ test("Popcorn Footnote Plugin", function () { plus(); popped.footnote({ - start: 0, // seconds - end: 5, // seconds - text: 'This video made exclusively for drumbeat.org', - target: 'footnotediv' - } ) - .footnote({ - start: 7, // seconds - end: 14, // seconds - text: 'Visit webmademovies.org for more details', - target: 'footnotediv' - } ) - .volume(0) - .play(); - - - interval = setInterval( function() { - if( popped.currentTime() > 0 && popped.currentTime() <= 5 ) { - equals ( footnotediv.childElementCount, 2, "footnotediv now has two inner elements" ); - plus(); - equals (footnotediv.children[0].innerHTML , "This video made exclusively for drumbeat.org", "footnote displaing correct information" ); - plus(); - equals (footnotediv.children[0].style.display , "inline", "footnote is visible on the page" ); - plus(); - clearInterval( interval ); - } - }, 2000); - - interval2 = setInterval( function() { - if( popped.currentTime() > 7 && popped.currentTime() < 14 ) { - equals (footnotediv.children[1].style.display , "inline", "second footnote is visible on the page" ); - plus(); - clearInterval( interval2 ); - } - }, 3000); - - interval3 = setInterval( function() { - if( popped.currentTime() > 14) { - ok (footnotediv.children[1].style.display === 'none' && footnotediv.children[0].style.display === 'none', "footnote are no longer vidible on the page" ); - plus(); - clearInterval( interval3 ); - } - }, 15000); + start: 0, // seconds + end: 2, // seconds + text: 'This video made exclusively for drumbeat.org', + target: 'footnotediv' + } ) + .footnote({ + start: 2, // seconds + end: 4, // seconds + text: 'Visit webmademovies.org for more details', + target: 'footnotediv' + } ) + .volume(0); + + popped.exec( 1, function() { + equals ( footnotediv.childElementCount, 2, "footnotediv now has two inner elements" ); + plus(); + equals (footnotediv.children[0].innerHTML , "This video made exclusively for drumbeat.org", "footnote displaing correct information" ); + plus(); + equals (footnotediv.children[0].style.display , "inline", "footnote is visible on the page" ); + plus(); + }); + + popped.exec( 3, function() { + equals (footnotediv.children[1].style.display , "inline", "second footnote is visible on the page" ); + plus(); + }); + + popped.exec( 5, function() { + ok (footnotediv.children[1].style.display === 'none' && footnotediv.children[0].style.display === 'none', "footnote are no longer vidible on the page" ); + plus(); + }); + popped.play(); }); diff --git a/plugins/googlemap/popcorn.googlemap.unit.js b/plugins/googlemap/popcorn.googlemap.unit.js index 8962284..bb2bab3 100644 --- a/plugins/googlemap/popcorn.googlemap.unit.js +++ b/plugins/googlemap/popcorn.googlemap.unit.js @@ -2,11 +2,7 @@ test("Popcorn Google Map Plugin", function () { var popped = Popcorn("#video"), expects = 10, - count = 0, - mapInterval, - mapInterval2, - mapInterval3, - mapInterval4; + count = 0; expect(expects); @@ -28,55 +24,48 @@ test("Popcorn Google Map Plugin", function () { plus(); popped.googlemap({ - start: 0, // seconds - end: 5, // seconds - type: 'ROADMAP', - target: 'map', - lat: 43.665429, - lng: -79.403323, - zoom: 10 - } ) - .googlemap({ - start: 0, // seconds - end: 5, // seconds - type: 'SATELLITE', - target: 'map2', - location:'boston', - zoom: 15 - } ) - .volume(0) - .play(); - - - mapInterval = setInterval( function() { - if( popped.currentTime() > 3 && popped.currentTime() <= 5 ) { - ok(google.maps, "Google maps is available"); - plus(); - ok(google.maps.Geocoder, "Google maps Geocoder is available"); - plus(); - ok (document.getElementById('actualmap1'), "First map is on the page" ); - plus(); - equals (document.getElementById('actualmap1').offsetParent.id, "map", "First map is inside the 'map' div" ); - plus(); - clearInterval( mapInterval ); - } - }, 1000); - mapInterval2 = setInterval( function() { - if( popped.currentTime() > 3 && popped.currentTime() <= 5 ) { - ok (document.getElementById('actualmap2'), "Second map is on the page" ); - plus(); - equals (document.getElementById('actualmap2').offsetParent.id, "map2", "Second map is inside the 'map2' div" ); - plus(); - clearInterval( mapInterval2 ); - } - }, 1000); - mapInterval3 = setInterval( function() { - if( popped.currentTime() > 5 ) { - ok (document.getElementById('actualmap2').style.display === "none" && - document.getElementById('actualmap1').style.display === "none", "Both maps are no lnger visible" ); - plus(); - clearInterval( mapInterval3 ); - } - }, 1000); + start: 0, // seconds + end: 5, // seconds + type: 'ROADMAP', + target: 'map', + lat: 43.665429, + lng: -79.403323, + zoom: 10 + } ) + .googlemap({ + start: 0, // seconds + end: 5, // seconds + type: 'SATELLITE', + target: 'map2', + location:'boston', + zoom: 15 + } ) + .volume(0); + + popped.exec( 4, function() { + ok(google.maps, "Google maps is available"); + plus(); + ok(google.maps.Geocoder, "Google maps Geocoder is available"); + plus(); + ok (document.getElementById('actualmap1'), "First map is on the page" ); + plus(); + equals (document.getElementById('actualmap1').offsetParent.id, "map", "First map is inside the 'map' div" ); + plus(); + }); + + popped.exec( 4, function() { + ok (document.getElementById('actualmap2'), "Second map is on the page" ); + plus(); + equals (document.getElementById('actualmap2').offsetParent.id, "map2", "Second map is inside the 'map2' div" ); + plus(); + }); + + popped.exec( 6, function() { + ok (document.getElementById('actualmap2').style.display === "none" && + document.getElementById('actualmap1').style.display === "none", "Both maps are no lnger visible" ); + plus(); + }); + + popped.play(); }); diff --git a/plugins/image/popcorn.image.unit.js b/plugins/image/popcorn.image.unit.js index 00b1325..7bbf66d 100644 --- a/plugins/image/popcorn.image.unit.js +++ b/plugins/image/popcorn.image.unit.js @@ -3,8 +3,6 @@ test("Popcorn Image Plugin", function () { var popped = Popcorn("#video"), expects = 5, count = 0, - interval, - interval2, imagediv = document.getElementById('imagediv'); expect( expects ); @@ -31,24 +29,17 @@ test("Popcorn Image Plugin", function () { target: 'imagediv' } ); - interval = setInterval( function() { - if( popped.currentTime() > 1 && popped.currentTime() < 3 ) { - ok( /display: inline;/.test( imagediv.innerHTML ), "Div contents are displayed" ); - plus(); - ok( /img/.test( imagediv.innerHTML ), "An image exists" ); - plus(); - clearInterval( interval ); - } - }, 500); - - interval2 = setInterval( function() { - if( popped.currentTime() > 3 ) { - ok( /display: none;/.test( imagediv.innerHTML ), "Div contents are hidden again" ); - plus(); - clearInterval( interval2 ); - } - }, 500); - popped.volume(0); - popped.play(); + popped.exec( 2, function() { + ok( /display: inline;/.test( imagediv.innerHTML ), "Div contents are displayed" ); + plus(); + ok( /img/.test( imagediv.innerHTML ), "An image exists" ); + plus(); + }); + + popped.exec( 4, function() { + ok( /display: none;/.test( imagediv.innerHTML ), "Div contents are hidden again" ); + plus(); + }); + popped.volume(0).play(); }); diff --git a/plugins/lastfm/popcorn.lastfm.unit.js b/plugins/lastfm/popcorn.lastfm.unit.js index cba21cc..c66b009 100644 --- a/plugins/lastfm/popcorn.lastfm.unit.js +++ b/plugins/lastfm/popcorn.lastfm.unit.js @@ -8,9 +8,6 @@ test("Popcorn LastFM Plugin", function () { var popped = Popcorn("#video"), expects = 8, count = 0, - interval, - interval2, - interval3, lastfmdiv = document.getElementById('lastfmdiv'); expect( expects ); @@ -30,58 +27,47 @@ test("Popcorn LastFM Plugin", function () { plus(); popped.lastfm({ - start: 1, // seconds - end: 4, // seconds - artist: 'yacht', - target: 'lastfmdiv', - apikey: '30ac38340e8be75f9268727cb4526b3d' - } ) - .lastfm({ - start: 2.5, // seconds - end: 7, // seconds - artist: 'the beatles', - target: 'lastfmdiv', - apikey: '30ac38340e8be75f9268727cb4526b3d' - } ) - .lastfm({ - start: 4.5, // seconds - end: 7, // seconds - artist: '', - target: 'lastfmdiv', - apikey: '30ac38340e8be75f9268727cb4526b3d' - } ); + start: 1, // seconds + end: 4, // seconds + artist: 'yacht', + target: 'lastfmdiv', + apikey: '30ac38340e8be75f9268727cb4526b3d' + }) + .lastfm({ + start: 2, // seconds + end: 7, // seconds + artist: 'the beatles', + target: 'lastfmdiv', + apikey: '30ac38340e8be75f9268727cb4526b3d' + }) + .lastfm({ + start: 4, // seconds + end: 7, // seconds + artist: '', + target: 'lastfmdiv', + apikey: '30ac38340e8be75f9268727cb4526b3d' + }); - interval = setInterval( function() { - if( popped.currentTime() > 1 && popped.currentTime() < 4 ) { - - equals ( lastfmdiv.childElementCount, 3, "lastfmdiv now has three inner elements" ); - plus(); - equals (lastfmdiv.children[0].style.display , "inline", "yachtdiv is visible on the page" ); - plus(); - clearInterval( interval ); - } - }, 1000); - - interval2 = setInterval( function() { - if( popped.currentTime() > 2.5 && popped.currentTime() < 3 ) { - equals (lastfmdiv.children[0].style.display , "inline", "yachtdiv is visible on the page" ); - plus(); - equals (lastfmdiv.children[1].style.display , "inline", "beatlesdiv is visible on the page" ); - plus(); - equals (lastfmdiv.children[2].style.display , "none", "nulldiv is not visible on the page" ); - plus(); - clearInterval( interval2 ); - } - }, 1000); - - interval3 = setInterval( function() { - if( popped.currentTime() > 4.5 && popped.currentTime() < 7 ) { - equals (lastfmdiv.children[2].innerHTML , "Unknown Artist", "Artist information could not be found" ); - plus(); - clearInterval( interval3 ); - } - }, 1000); + popped.exec( 2, function() { + equals ( lastfmdiv.childElementCount, 3, "lastfmdiv now has three inner elements" ); + plus(); + equals (lastfmdiv.children[0].style.display , "inline", "yachtdiv is visible on the page" ); + plus(); + }); + + popped.exec( 3, function() { + equals (lastfmdiv.children[0].style.display , "inline", "yachtdiv is still visible on the page" ); + plus(); + equals (lastfmdiv.children[1].style.display , "inline", "beatlesdiv is visible on the page" ); + plus(); + equals (lastfmdiv.children[2].style.display , "none", "nulldiv is not visible on the page" ); + plus(); + }); + + popped.exec( 5, function() { + equals (lastfmdiv.children[2].innerHTML , "Unknown Artist", "Artist information could not be found" ); + plus(); + }); - popped.volume(0); - popped.play(); + popped.volume(0).play(); }); diff --git a/plugins/tagthisperson/popcorn.tagthisperson.unit.js b/plugins/tagthisperson/popcorn.tagthisperson.unit.js index ace4240..fad01cc 100644 --- a/plugins/tagthisperson/popcorn.tagthisperson.unit.js +++ b/plugins/tagthisperson/popcorn.tagthisperson.unit.js @@ -3,9 +3,6 @@ test("Popcorn tagthisperson Plugin", function () { var popped = Popcorn( "#video" ), expects = 8, count = 0, - interval, - interval2, - interval3, tagdiv = document.getElementById( 'tagdiv' ); tagdiv2 = document.getElementById( 'tagdiv2' ); @@ -19,71 +16,62 @@ test("Popcorn tagthisperson Plugin", function () { stop(); - ok ( 'tagthisperson' in popped, "tagthisperson is a method of the popped instance" ); + ok( 'tagthisperson' in popped, "tagthisperson is a method of the popped instance" ); plus(); - equals ( tagdiv.innerHTML, "", "initially, there is nothing inside the tagdiv" ); + equals( tagdiv.innerHTML, "", "initially, there is nothing inside the tagdiv" ); plus(); popped.tagthisperson({ - start: 0, // seconds - end: 5, // seconds - person: 'Anna Sob', - image: 'http://newshour.s3.amazonaws.com/photos%2Fspeeches%2Fguests%2FRichardNSmith_thumbnail.jpg', - href: 'http://annasob.wordpress.com', - target: 'tagdiv' - } ) - .tagthisperson({ - start: 3, // seconds - end: 10, // seconds - person: 'Scott', - href: 'http://scottdowne.wordpress.com/', - target: 'tagdiv' - } ) - .tagthisperson({ - start: 6, // seconds - end: 10, // seconds - person: 'Mike', - target: 'tagdiv2' - } ) - .tagthisperson({ - start: 7, // seconds - end: 12, // seconds - person: 'Daniel', - target: 'tagdiv2' - } ) - .volume(0) - .play(); - - - interval = setInterval( function() { - if( popped.currentTime() > 0 && popped.currentTime() <= 5 ) { - equals ( tagdiv.childElementCount, 2, "tagdiv now contains two child elements" ); - plus(); - equals ( tagdiv.textContent.trim() , "Anna Sob" ,"tagdiv shows the first tag" ); - plus(); - clearInterval( interval ); - } - }, 2000); - - interval2 = setInterval( function() { - if( popped.currentTime() > 5 ) { - equals ( tagdiv.innerHTML.search( " 12 ) { - equals ( tagdiv.innerHTML , "" ,"tagdiv is now cleared" ); - plus(); - equals ( tagdiv2.innerHTML , "" ,"tagdiv2 is now cleared" ); - plus(); - clearInterval( interval3 ); - } - }, 4000); + start: 0, // seconds + end: 1, // seconds + person: 'Anna Sob', + image: 'http://newshour.s3.amazonaws.com/photos%2Fspeeches%2Fguests%2FRichardNSmith_thumbnail.jpg', + href: 'http://annasob.wordpress.com', + target: 'tagdiv' + }) + .tagthisperson({ + start: 1, // seconds + end: 2, // seconds + person: 'Scott', + href: 'http://scottdowne.wordpress.com/', + target: 'tagdiv' + }) + .tagthisperson({ + start: 1, // seconds + end: 2, // seconds + person: 'Mike', + target: 'tagdiv2' + }) + .tagthisperson({ + start: 1, // seconds + end: 2, // seconds + person: 'Daniel', + target: 'tagdiv2' + }) + .volume(0); + + popped.exec( 0, function() { + equals( tagdiv.childElementCount, 2, "tagdiv now contains two child elements" ); + plus(); + equals( tagdiv.textContent.trim() , "Anna Sob" ,"tagdiv shows the first tag" ); + plus(); + }); + + popped.exec( 1, function() { + equals( tagdiv.innerHTML.search( " 1 && popped.currentTime() < 3 ) { - ok( /display: inline;/.test( twitterdiv.innerHTML ), "Div contents are displayed" ); - plus(); - ok( /twtr-widget/.test( twitterdiv.innerHTML ), "A Twitter widget exists" ); - plus(); - clearInterval( interval ); - } - }, 500); - - interval2 = setInterval( function() { - if( popped.currentTime() > 3 ) { - ok( /display: none;/.test( twitterdiv.innerHTML ), "Div contents are hidden again" ); - plus(); - clearInterval( interval2 ); - } - }, 500); + popped.exec( 1, function() { + ok( /display: inline;/.test( twitterdiv.innerHTML ), "Div contents are displayed" ); + plus(); + ok( /twtr-widget/.test( twitterdiv.innerHTML ), "A Twitter widget exists" ); + plus(); + }); + + popped.exec( 2, function() { + ok( /display: none;/.test( twitterdiv.innerHTML ), "Div contents are hidden again" ); + plus(); + }); popped.play(); diff --git a/plugins/webpage/popcorn.webpage.unit.js b/plugins/webpage/popcorn.webpage.unit.js index 7ba514b..91b4650 100644 --- a/plugins/webpage/popcorn.webpage.unit.js +++ b/plugins/webpage/popcorn.webpage.unit.js @@ -3,11 +3,8 @@ test("Popcorn Webpage Plugin", function () { var popped = Popcorn("#video"), expects = 10, count = 0, - iframeInterval, - iframeInterval2, - iframeInterval3, - iframeInterval4; theiFrame = document.getElementsByTagName('iframe'); + expect(expects); function plus() { @@ -25,55 +22,46 @@ test("Popcorn Webpage Plugin", function () { plus(); popped.webpage({ - id: "webpages-a", - start: 0, // seconds - end: 5, // seconds - src: 'http://webmademovies.org', - target: 'webpagediv' - }) - .webpage({ - id: "webpages-b", - start: 7, // seconds - end: 10, // seconds - src: 'http://zenit.senecac.on.ca/wiki/index.php/Processing.js', - target: 'webpagediv' - }) - .volume(0) - .play(); - - - iframeInterval = setInterval( function() { - if( popped.currentTime() > 1 && popped.currentTime() <= 5 ) { - ok (!!theiFrame[0], "iframe was created" ); - plus(); - equals (theiFrame.length, 2, "there is only two iframes on the page" ); - plus(); - equals (theiFrame[0].id, "webpages-a", "the first iframe has the id 'webpages-a'" ); - plus(); - equals (theiFrame[0].src, "http://webmademovies.org/", "iframe has the src 'http://webmademovies.org/'" ); - plus(); - clearInterval( iframeInterval ); - } - }, 5000); - - iframeInterval2 = setInterval( function() { - if( popped.currentTime() > 10 ) { - ok (theiFrame[0].style.display === 'none' && theiFrame[1].style.display === 'none', "both iframes are hidden" ); - plus(); - clearInterval( iframeInterval2 ); - } - }, 15000); - - iframeInterval3 = setInterval( function() { - if( popped.currentTime() > 8 && popped.currentTime() <= 10 ) { - ok (!!theiFrame[1], "iframe was created" ); - plus(); - equals (theiFrame[1].id, "webpages-b", "iframe second has the id 'webpages-b'" ); - plus(); - equals (theiFrame[1].src,"http://zenit.senecac.on.ca/wiki/index.php/Processing.js", "iframe has the src 'http://zenit.senecac.on.ca/wiki/index.php/Processing.js'" ); - plus(); - clearInterval( iframeInterval3 ); - } - }, 5000); - + id: "webpages-a", + start: 0, // seconds + end: 1, // seconds + src: 'http://webmademovies.org', + target: 'webpagediv' + }) + .webpage({ + id: "webpages-b", + start: 1, // seconds + end: 2, // seconds + src: 'http://zenit.senecac.on.ca/wiki/index.php/Processing.js', + target: 'webpagediv' + }) + .volume(0); + + popped.exec( 0, function() { + ok (!!theiFrame[0], "iframe was created" ); + plus(); + equals (theiFrame.length, 2, "there is only two iframes on the page" ); + plus(); + equals (theiFrame[0].id, "webpages-a", "the first iframe has the id 'webpages-a'" ); + plus(); + equals (theiFrame[0].src, "http://webmademovies.org/", "iframe has the src 'http://webmademovies.org/'" ); + plus(); + }); + + popped.exec( 2, function() { + ok (theiFrame[0].style.display === 'none' && theiFrame[1].style.display === 'none', "both iframes are hidden" ); + plus(); + }); + + popped.exec( 1, function() { + ok (!!theiFrame[1], "iframe was created" ); + plus(); + equals (theiFrame[1].id, "webpages-b", "iframe second has the id 'webpages-b'" ); + plus(); + equals (theiFrame[1].src,"http://zenit.senecac.on.ca/wiki/index.php/Processing.js", "iframe has the src 'http://zenit.senecac.on.ca/wiki/index.php/Processing.js'" ); + plus(); + }); + + popped.play(); + }); -- 2.43.0