Merge pull request #50 from cadecairos/t1045

New Popcorn.js Test runner
This commit is contained in:
Christopher De Cairos 2012-07-06 08:20:41 -07:00
Родитель 94d758d8c9 78dc050439
Коммит bb8bf2cbe8
48 изменённых файлов: 511 добавлений и 201 удалений

Просмотреть файл

@ -9,6 +9,7 @@
<script src="popcorn.locale.js"></script>
<script src="popcorn.locale.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn Module: Locale</h1>

Просмотреть файл

@ -9,6 +9,7 @@
<script src="popcorn.parser.js"></script>
<script src="popcorn.parser.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn Module: player</h1>

Просмотреть файл

@ -9,6 +9,7 @@
<script src="popcorn.player.js"></script>
<script src="popcorn.player.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn Module: player</h1>

Просмотреть файл

@ -11,6 +11,7 @@
<script src="popcorn.timeline-sources.unit.js"></script>
<script src="../../parsers/parserJSON/popcorn.parserJSON.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn Module: timeline-sources</h1>

Просмотреть файл

@ -19,6 +19,7 @@
<script src="../../parsers/parserJSON/popcorn.parserJSON.js"></script>
<script src="../../parsers/parserJSON/popcorn.parserJSON.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn 0.3 JSON parser Plug-in Test</h1>

Просмотреть файл

@ -16,6 +16,7 @@
<script src="popcorn.parserSBV.js"></script>
<script src="popcorn.parserSBV.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn 0.3 SBV parser Plug-in Test</h1>

Просмотреть файл

@ -16,6 +16,7 @@ popcorn-api-draft.js
<script src="../../plugins/subtitle/popcorn.subtitle.js"></script>
<script src="popcorn.parserSRT.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn 0.3 SRT parser Plug-in Test</h1>

Просмотреть файл

@ -16,6 +16,7 @@
<script src="popcorn.parserSSA.js"></script>
<script src="popcorn.parserSSA.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn 0.3 SSA parser Plug-in Test</h1>

Просмотреть файл

@ -15,6 +15,7 @@
<script src="popcorn.parserTTML.js"></script>
<script src="popcorn.parserTTML.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn 1.0 TTML parser Plug-in Test</h1>

Просмотреть файл

@ -16,6 +16,7 @@
<script src="../../plugins/subtitle/popcorn.subtitle.js"></script>
<script src="popcorn.parserTTXT.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn 0.3 TTXT parser Plug-in Test</h1>

Просмотреть файл

@ -16,6 +16,7 @@ popcorn-api-draft.js
<script src="../../plugins/subtitle/popcorn.subtitle.js"></script>
<script src="popcorn.parserVTT.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn 1.0 WebSRT/VTT parser Plug-in Test</h1>

Просмотреть файл

@ -15,6 +15,7 @@
<script src="popcorn.parserXML.js"></script>
<script src="popcorn.parserXML.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn 0.1 parser Plug-in Test</h1>

Просмотреть файл

@ -9,6 +9,7 @@
<script src="popcorn.soundcloud.js"></script>
<script src="popcorn.soundcloud.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
<style>
.soundcloudPlayer {
left: 20px;

Просмотреть файл

@ -16,6 +16,7 @@
<script src="popcorn.vimeo.unit.js"></script>
<script src="popcorn.vimeo.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>

Просмотреть файл

@ -15,6 +15,7 @@
<script src="popcorn.youtube.js"></script>
<script src="popcorn.youtube.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn YouTube Player Plugin</h1>

Просмотреть файл

@ -14,6 +14,8 @@
<script src="popcorn.attribution.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn Attribution Plugin</h1>

Просмотреть файл

@ -15,6 +15,7 @@
<script src="popcorn.code.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
@ -39,7 +40,7 @@
<source id="ogv"
src="../../test/trailer.ogv"
type='video/ogg; codecs="theora, vorbis"'>
<source id='webm'
src="../../test/trailer.webm"
type='video/webm; codecs="vp8, vorbis"'>

Просмотреть файл

@ -14,6 +14,8 @@
<script src="popcorn.documentcloud.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn DocumentCloud Plugin</h1>

Просмотреть файл

@ -12,6 +12,7 @@
<script src="popcorn.facebook.js"></script>
<script src="popcorn.facebook.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn Facebook Plugin</h1>
@ -27,7 +28,7 @@
<div id="activitydiv"></div>
</div>
<video id="video"
controls
controls
width="250px"
poster="../../test/poster.png">

Просмотреть файл

@ -15,6 +15,7 @@
<script src="popcorn.flickr.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>

Просмотреть файл

@ -8,6 +8,7 @@
<script src="popcorn.footnote.js"></script>
<script src="popcorn.footnote.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn Footnote Plugin</h1>

Просмотреть файл

@ -12,6 +12,7 @@
<script src="popcorn.gml.js"></script>
<script src="popcorn.gml.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn GML Plugin</h1>
@ -22,7 +23,7 @@
<div id="qunit-fixture"> </div>
<video id="video"
controls
controls
width="250px"
poster="../../test/poster.png">

Просмотреть файл

@ -13,6 +13,7 @@
<script src="popcorn.googlefeed.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn Google Feed Plugin</h1>
@ -23,7 +24,7 @@
<div id="qunit-fixture"> </div>
<video id="video"
controls
controls
width="250px"
poster="../../test/poster.png">

Просмотреть файл

@ -14,6 +14,7 @@
<script src="popcorn.googlemap.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn Google Map Plugin</h1>
@ -24,7 +25,7 @@
<div id="qunit-fixture"> </div>
<video id="video"
controls
controls
width="250px"
poster="../../test/poster.png">

Просмотреть файл

@ -12,6 +12,7 @@
<script src="popcorn.image.js"></script>
<script src="popcorn.image.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn Image Plug-in Test</h1>
@ -42,7 +43,7 @@
</video>
<div id="imagediv"></div>
<div id="zerostart"></div>
<div id="zerostart"></div>
<div style="width:400px; height:400px" id="withsize"></div>
<div style="width:400px; height:400px">
<div id="withoutsizeinsize"></div>

Просмотреть файл

@ -1,79 +0,0 @@
<!DOCTYPE>
<html>
<head>
<title>Popcorn Plug-in Unit Tests</title>
</head>
<body onload="runAllTests();">
<div style="position:absolute;top:0px;left:0px;width:150px;height:100%">
<h1>Popcorn Plug-in Unit Tests</h1>
<button type="button" onclick="runAllTests();">Run all Tests</button>
<ul id="menuItems">
<li><a onclick="clearEvents();" target="out" href="attribution/popcorn.attribution.unit.html">attribution</a></li>
<li><a onclick="clearEvents();" target="out" href="code/popcorn.code.unit.html">code</a></li>
<li><a onclick="clearEvents();" target="out" href="facebook/popcorn.facebook.unit.html">facebook</a></li>
<li><a onclick="clearEvents();" target="out" href="flickr/popcorn.flickr.unit.html">flickr</a></li>
<li><a onclick="clearEvents();" target="out" href="footnote/popcorn.footnote.unit.html">footnote</a></li>
<li><a onclick="clearEvents();" target="out" href="gml/popcorn.gml.unit.html">gml</a></li>
<li><a onclick="clearEvents();" target="out" href="googlemap/popcorn.googlemap.unit.html">googlemap</a></li>
<li><a onclick="clearEvents();" target="out" href="googlefeed/popcorn.googlefeed.unit.html">googlefeed</a></li>
<li><a onclick="clearEvents();" target="out" href="image/popcorn.image.unit.html">image</a></li>
<li><a onclick="clearEvents();" target="out" href="lastfm/popcorn.lastfm.unit.html">lastfm</a></li>
<li><a onclick="clearEvents();" target="out" href="linkedin/popcorn.linkedin.unit.html">linkedin</a></li>
<li><a onclick="clearEvents();" target="out" href="lowerthird/popcorn.lowerthird.unit.html">lowerthird</a></li>
<li><a onclick="clearEvents();" target="out" href="mustache/popcorn.mustache.unit.html">mustache</a></li>
<li><a onclick="clearEvents();" target="out" href="openmap/popcorn.openmap.unit.html">openmap</a></li>
<li><a onclick="clearEvents();" target="out" href="pause/popcorn.pause.unit.html">pause</a></li>
<li><a onclick="clearEvents();" target="out" href="processing/popcorn.processing.unit.html">processing</a></li>
<li><a onclick="clearEvents();" target="out" href="subtitle/popcorn.subtitle.unit.html">subtitle</a></li>
<li><a onclick="clearEvents();" target="out" href="tagthisperson/popcorn.tagthisperson.unit.html">tagthisperson</a></li>
<li><a onclick="clearEvents();" target="out" href="timeline/popcorn.timeline.unit.html">timeline</a></li>
<li><a onclick="clearEvents();" target="out" href="twitter/popcorn.twitter.unit.html">twitter</a></li>
<li><a onclick="clearEvents();" target="out" href="webpage/popcorn.webpage.unit.html">webpage</a></li>
<li><a onclick="clearEvents();" target="out" href="wikipedia/popcorn.wikipedia.unit.html">wikipedia</a></li>
<li><a onclick="clearEvents();" target="out" href="wordriver/popcorn.wordriver.unit.html">wordriver</a></li>
</ul>
</div>
<iframe id="out" name="out" style="position:absolute;top:0px;left:150px;height:100%;width:100%"></iframe>
<script>
var eventList = [];
function runAllTests(){
var testUrl = [ "attribution", "code", "facebook", "flickr", "footnote", "gml",
"googlemap", "googlefeed", "image", "lastfm", "linkedin", "lowerthird",
"mustache", "openmap", "pause", "processing", "subtitle", "tagthisperson",
"timeline", "twitter", "webpage", "wikipedia", "wordriver" ];
var testDur = [ 7000, 9000, 7000, 12000, 9000, 8000,
9000, 5000, 8000, 7000, 6000, 7000,
6000, 7000, 7000, 6000, 12000, 3500,
5500 ,3500, 4000, 8000, 6000 ];
var setTest = function( index ) {
var url = function( str ) {
return str + "/popcorn." + str + ".unit.html";
};
document.getElementById('out').src = url( testUrl[ index ] );
};
for ( var i = 0, delay = 0; i < testUrl.length; delay += testDur[i], i++ ) {
(function ( j ) {
var event = setTimeout(function() {
setTest( j );
}, delay);
eventList.push(event);
})( i );
}
}
function clearEvents(){
var len = eventList.length;
for( var i = 0; i < len; i++ ) {
clearTimeout( eventList[i] );
}
for( var i = 0; i < len; i++ ) {
eventList.pop();
}
}
</script>
</body>
</html>

Просмотреть файл

@ -15,6 +15,7 @@
<script src="popcorn.lastfm.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>

Просмотреть файл

@ -12,6 +12,7 @@
<script src="popcorn.linkedin.js"></script>
<script src="popcorn.linkedin.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn LinkedIn Plugin Test</h1>

Просмотреть файл

@ -14,6 +14,7 @@
<script src="popcorn.lowerthird.js"></script>
<script src="popcorn.lowerthird.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn Lower Third Plugin</h1>
@ -24,7 +25,7 @@
<div id="qunit-fixture"> </div>
<video id="video"
controls
controls
width="250px"
poster="../../test/poster.png">

Просмотреть файл

@ -14,6 +14,7 @@
<script src="popcorn.mustache.js"></script>
<script src="popcorn.mustache.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
@ -38,7 +39,7 @@
<source id="ogv"
src="../../test/trailer.ogv"
type='video/ogg; codecs="theora, vorbis"'>
<source id='webm'
src="../../test/trailer.webm"
type='video/webm; codecs="vp8, vorbis"'>

Просмотреть файл

@ -12,6 +12,7 @@
<script src="popcorn.openmap.js"></script>
<script src="popcorn.openmap.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn Open Map Plugin</h1>
@ -22,7 +23,7 @@
<div id="qunit-fixture"> </div>
<video id="video"
controls
controls
width="250px"
poster="../../test/poster.png">

Просмотреть файл

@ -14,6 +14,7 @@
<script src="popcorn.pause.js"></script>
<script src="popcorn.pause.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
@ -38,7 +39,7 @@
<source id="ogv"
src="../../test/trailer.ogv"
type='video/ogg; codecs="theora, vorbis"' />
<source id='webm'
src="../../test/trailer.webm"
type='video/webm; codecs="vp8, vorbis"'>

Просмотреть файл

@ -9,6 +9,7 @@
<script src="popcorn.processing.js"></script>
<script src="popcorn.processing.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn processing Plug-in Demo</h1>
@ -19,7 +20,7 @@
<div id="qunit-fixture"> </div>
<div>
<video id="video"
controls
controls
width="250px"
poster="../../test/poster.png">
@ -30,7 +31,7 @@
<source id="ogv"
src="../../test/trailer.ogv"
type='video/ogg; codecs="theora, vorbis"'>
<source id='webm'
src="../../test/trailer.webm"
type='video/webm; codecs="vp8, vorbis"'>

Просмотреть файл

@ -9,6 +9,7 @@
<script src="popcorn.rdio.js"></script>
<script src="popcorn.rdio.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>

Просмотреть файл

@ -12,6 +12,7 @@
<script src="popcorn.subtitle.js"></script>
<script src="popcorn.subtitle.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn Subtitle Plugin</h1>
@ -22,7 +23,7 @@
<div id="qunit-fixture"> </div>
<video id="video"
controls
controls
width="250px"
poster="../../test/poster.png">
@ -42,7 +43,7 @@
</video>
<video id="video2"
controls
controls
width="250px"
poster="../../test/poster.png">

Просмотреть файл

@ -13,6 +13,7 @@
<script src="popcorn.tagthisperson.js"></script>
<script src="popcorn.tagthisperson.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn tagthisperson Plugin</h1>
@ -23,7 +24,7 @@
<div id="qunit-fixture"> </div>
<video id="video"
controls
controls
width= "250px"
poster="../../test/poster.png">

Просмотреть файл

@ -14,6 +14,7 @@
<script src="popcorn.timeline.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn Timeline Plugin</h1>
@ -24,7 +25,7 @@
<div id="qunit-fixture"> </div>
<video id="video"
controls
controls
width="250px"
poster="../../test/poster.png"
style="float: left;">

Просмотреть файл

@ -12,6 +12,7 @@
<script src="popcorn.tumblr.js"></script>
<script src="popcorn.tumblr.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn Tumblr Plugin</h1>
@ -27,7 +28,7 @@
<div id="testsdiv"></div>
</div>
<video id="video"
controls
controls
width="250px"
poster="../../test/poster.png">

Просмотреть файл

@ -13,6 +13,7 @@
<script src="popcorn.twitter.js"></script>
<script src="popcorn.twitter.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>

Просмотреть файл

@ -14,6 +14,7 @@
<script src="popcorn.webpage.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn Webpage UI</h1>
@ -24,7 +25,7 @@
<div id="qunit-fixture"> </div>
<video id="video"
controls
controls
width="250px"
poster="../../test/poster.png">

Просмотреть файл

@ -14,6 +14,7 @@
<script src="popcorn.wikipedia.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn wikipedia UI</h1>

Просмотреть файл

@ -12,6 +12,7 @@
<script src="popcorn.wordriver.js"></script>
<script src="popcorn.wordriver.unit.js"></script>
<script src="../../test/inject.js"></script>
<script src="../../test/popcorn.inject.js"></script>
</head>
<body>
<h1 id="qunit-header">Popcorn Word River Plugin</h1>
@ -22,7 +23,7 @@
<div id="qunit-fixture"> </div>
<video id="video"
controls
controls
width="250px"
poster="../../test/poster.png">

116
test/core.html Normal file
Просмотреть файл

@ -0,0 +1,116 @@
<!DOCTYPE html>
<html>
<head>
<title>Popcorn API</title>
<link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen">
<script src="jquery.js"></script>
<script src="qunit/qunit.js"></script>
<script src="popcorn.unit.setup.js"></script>
<script src="../popcorn.js"></script>
<script src="popcorn.unit.js"></script>
<script src="inject.js"></script>
<script src="popcorn.inject.js"></script>
</head>
<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>
</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">
<div class="contextual" data-contextual="true">This should break the tests</div>
<div id="popcorn-dom-find-context">
<div id="inside-context" class="contextual" data-contextual="true">This element will be found when its parent is used as a context</div>
</div>
</div>
<video id="video" class="dom-tests" data-custom="foo"
style="display:;width:300px"
controls
preload="auto">
<source id="mp4"
src="trailer.mp4"
type='video/mp4; codecs="avc1, mp4a"'>
<source id="ogv"
src="trailer.ogv"
type='video/ogg; codecs="theora, vorbis"'>
<source id="webm"
src="trailer.webm"
type='video/webm; codecs="vp8, vorbis"'>
<p>Your user agent does not support the HTML5 Video element.</p>
</video>
<audio id="audio" data-timeline-sources="data/parserData.json" controls>
<source src="italia.mp4" type='audio/mp4; codecs="mp4a.40.2"'>
<source src="italia.ogg" type='audio/ogg; codecs="vorbis"'>
</audio>
<!-- Position Tests Adapted From jQuery offsets/dimensions Tests -->
<style type="text/css" media="screen">
#position-tests { display:none;margin:0; position: fixed;top:0px;left:0px; }
div.absolute { position: absolute; margin: 0px; width: 100px; height: 100px; background: #fff; }
#absolute-1 { top: 0; left: 0; }
#absolute-1-1 { top: 1px; left: 1px; }
#absolute-1-1-1 { top: 1px; left: 1px; }
#absolute-2 { top: 19px; left: 19px; }
div.relative { position: relative; top: 0; left: 0; width: 100px; height: 100px; background: #fff; overflow: hidden; }
#relative-2 { top: 20px; left: 20px; }
div.fixed { position: fixed; width: 100px; height: 100px; background: #fff; overflow: hidden; }
#fixed-1 { top: 0; left: 0; }
#fixed-2 { top: 20px; left: 20px; }
div.static { position: static; top: 0; left: 0; width: 100px; height: 100px; background: #fff; overflow: hidden; }
#static-2 { top: 20px; left: 20px; }
</style>
<div id="position-tests">
<div id="absolute-1" class="absolute"><video id="vid-absolute-1" src="trailer.ogv" style="visibility:hidden"></video>
<div id="absolute-1-1" class="absolute"><video id="vid-absolute-1-1"" src="trailer.ogv" style="visibility:hidden"></video>
<div id="absolute-1-1-1" class="absolute"><video id="vid-absolute-1-1-1" src="trailer.ogv" style="visibility:hidden"></video></div>
</div>
</div>
<div id="absolute-2" class="absolute"><video id="vid-absolute-2" src="trailer.ogv" style="visibility:hidden"></video></div>
<div id="relative-1" class="relative"><video id="vid-relative-1" src="trailer.ogv" style="visibility:hidden"></video>
<div id="relative-1-1" class="relative"><video id="vid-relative-1-1" src="trailer.ogv" style="visibility:hidden"></video>
<div id="relative-1-1-1" class="relative"><video id="vid-relative-1-1-1" src="trailer.ogv" style="visibility:hidden"></video></div>
</div>
</div>
<div id="relative-2" class="relative"><video id="vid-relative-2" src="trailer.ogv" style="visibility:hidden"></video></div>
<div id="fixed-1" class="fixed"><video id="vid-fixed-1" src="trailer.ogv" style="visibility:hidden"></video></div>
<div id="fixed-2" class="fixed"><video id="vid-fixed-2" src="trailer.ogv" style="visibility:hidden"></video></div>
<div id="static-1" class="static"><video id="vid-static-1" src="trailer.ogv" style="visibility:hidden">
<div id="static-1-1" class="static"><video id="vid-static-1-1" src="trailer.ogv" style="visibility:hidden">
<div id="static-1-1-1" class="static"><video id="vid-static-1-1-1" src="trailer.ogv" style="visibility:hidden"></div>
</div>
</div>
<div id="static-2" class="static"><video id="vid-static-2" src="trailer.ogv" style="visibility:hidden"></div>
</div>
</body>
</html>

Просмотреть файл

@ -1,115 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<title>Popcorn API</title>
<title>Popcorn Test Suite Runner</title>
<link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen">
<link rel="stylesheet" href="popcorn.testrunner.css" type="text/css" >
<script src="jquery.js"></script>
<script src="qunit/qunit.js"></script>
<script src="popcorn.unit.setup.js"></script>
<script src="../popcorn.js"></script>
<script src="popcorn.unit.js"></script>
<script src="inject.js"></script>
<script src="popcorn.testrunner.js"></script>
</head>
<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>
Popcorn.js Test Suite
<span style="" id="test-links">
<label for="core-tests">Core Tests</label><input id="core-tests" type="checkbox" value="core" checked="true" tabindex="1"/> |
<label for="plugin-tests">Plugin Tests</label><input id="plugin-tests" type="checkbox" value="plugins" checked tabindex="2"/> |
<label for="player-tests">Player Tests</label><input id="player-tests" type="checkbox" value="players" checked tabindex="3"/> |
<label for="parser-tests">Parser Tests</label><input id="parser-tests" type="checkbox" value="parsers" checked tabindex="4"/> |
<label for="module-tests">Module Tests</label><input id="module-tests" type="checkbox" value="modules" checked tabindex="5"/> |
<input id="run-selected" type="button" value="Run Selected" checked tabindex="6" />
</span>
</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">
<div class="contextual" data-contextual="true">This should break the tests</div>
<div id="popcorn-dom-find-context">
<div id="inside-context" class="contextual" data-contextual="true">This element will be found when its parent is used as a context</div>
</div>
</div>
<video id="video" class="dom-tests" data-custom="foo"
style="display:;width:300px"
controls
preload="auto">
<source id="mp4"
src="trailer.mp4"
type='video/mp4; codecs="avc1, mp4a"'>
<source id="ogv"
src="trailer.ogv"
type='video/ogg; codecs="theora, vorbis"'>
<source id="webm"
src="trailer.webm"
type='video/webm; codecs="vp8, vorbis"'>
<p>Your user agent does not support the HTML5 Video element.</p>
</video>
<audio id="audio" data-timeline-sources="data/parserData.json" controls>
<source src="italia.mp4" type='audio/mp4; codecs="mp4a.40.2"'>
<source src="italia.ogg" type='audio/ogg; codecs="vorbis"'>
</audio>
<!-- Position Tests Adapted From jQuery offsets/dimensions Tests -->
<style type="text/css" media="screen">
#position-tests { display:none;margin:0; position: fixed;top:0px;left:0px; }
div.absolute { position: absolute; margin: 0px; width: 100px; height: 100px; background: #fff; }
#absolute-1 { top: 0; left: 0; }
#absolute-1-1 { top: 1px; left: 1px; }
#absolute-1-1-1 { top: 1px; left: 1px; }
#absolute-2 { top: 19px; left: 19px; }
div.relative { position: relative; top: 0; left: 0; width: 100px; height: 100px; background: #fff; overflow: hidden; }
#relative-2 { top: 20px; left: 20px; }
div.fixed { position: fixed; width: 100px; height: 100px; background: #fff; overflow: hidden; }
#fixed-1 { top: 0; left: 0; }
#fixed-2 { top: 20px; left: 20px; }
div.static { position: static; top: 0; left: 0; width: 100px; height: 100px; background: #fff; overflow: hidden; }
#static-2 { top: 20px; left: 20px; }
</style>
<div id="position-tests">
<div id="absolute-1" class="absolute"><video id="vid-absolute-1" src="trailer.ogv" style="visibility:hidden"></video>
<div id="absolute-1-1" class="absolute"><video id="vid-absolute-1-1"" src="trailer.ogv" style="visibility:hidden"></video>
<div id="absolute-1-1-1" class="absolute"><video id="vid-absolute-1-1-1" src="trailer.ogv" style="visibility:hidden"></video></div>
</div>
</div>
<div id="absolute-2" class="absolute"><video id="vid-absolute-2" src="trailer.ogv" style="visibility:hidden"></video></div>
<div id="relative-1" class="relative"><video id="vid-relative-1" src="trailer.ogv" style="visibility:hidden"></video>
<div id="relative-1-1" class="relative"><video id="vid-relative-1-1" src="trailer.ogv" style="visibility:hidden"></video>
<div id="relative-1-1-1" class="relative"><video id="vid-relative-1-1-1" src="trailer.ogv" style="visibility:hidden"></video></div>
</div>
</div>
<div id="relative-2" class="relative"><video id="vid-relative-2" src="trailer.ogv" style="visibility:hidden"></video></div>
<div id="fixed-1" class="fixed"><video id="vid-fixed-1" src="trailer.ogv" style="visibility:hidden"></video></div>
<div id="fixed-2" class="fixed"><video id="vid-fixed-2" src="trailer.ogv" style="visibility:hidden"></video></div>
<div id="static-1" class="static"><video id="vid-static-1" src="trailer.ogv" style="visibility:hidden">
<div id="static-1-1" class="static"><video id="vid-static-1-1" src="trailer.ogv" style="visibility:hidden">
<div id="static-1-1-1" class="static"><video id="vid-static-1-1-1" src="trailer.ogv" style="visibility:hidden"></div>
</div>
</div>
<div id="static-2" class="static"><video id="vid-static-2" src="trailer.ogv" style="visibility:hidden"></div>
</div>
<iframe id="test-frame" style="height: 600px; width: 100%; overflow: scroll;"></iframe>
</body>
</html>
</html>

31
test/popcorn.inject.js Normal file
Просмотреть файл

@ -0,0 +1,31 @@
(function( global ) {
var combineFn = function( first, second ) {
first = first || function() {};
second = second || function() {};
return function( message ) {
first.call( this, message );
second.call( this, message );
};
};
if ( QUnit && global.parent ) {
QUnit.done = combineFn( QUnit.done, function( message ) {
global.parent.postMessage( JSON.stringify( message ), "*" );
});
QUnit.testDone = combineFn( QUnit.testDone, function( message ) {
global.parent.postMessage( JSON.stringify( message ), "*" );
});
// Fail tests that don't complete in 60s
QUnit.config.testTimeout = 60000;
window.addEventListener( "message", function( e ) {
if ( e.data === "getFocus" ) {
window.focus();
}
}, false );
}
})( window );

Просмотреть файл

@ -0,0 +1,17 @@
span#test-links {
float: right;
padding-right: 15px;
}
span#test-links > a {
font-size: 0.8em;
}
input[type=checkbox], input#run-selected {
position: relative;
bottom: 3px;
}
input#run-selected {
font-size: 16px;
}

269
test/popcorn.testrunner.js Normal file
Просмотреть файл

@ -0,0 +1,269 @@
(function() {
var TestRunner = window.TestRunner = function() {
var index = 0,
testFrame = id( "test-frame" ),
results = id( "qunit-tests" ),
totalPass = 0,
totalFail = 0,
totalRun = 0,
totalTime = 0,
main_li = create( "li" ),
main_b = create( "b" ),
allTests,
currentTest,
testList = [],
results_arr = [],
userAgent = id( "qunit-userAgent" ),
checkboxes = [],
testTypes = [ "core-tests", "plugin-tests", "player-tests", "parser-tests", "module-tests" ],
queryString = "",
runSelected = document.getElementById( "run-selected" );
function id( name ) {
return document.getElementById( name );
}
function create( type ){
return document.createElement( type );
}
function sendGetFocus( event ) {
event.target &&
event.target.contentWindow &&
event.target.contentWindow.postMessage( "getFocus", "*" );
}
function parseQueryString() {
var queryVars = {},
pairs = window.location.search.substring( 1 ).split( "&" ),
onePair;
for ( var i = 0, len = pairs.length; i < len; i++ ) {
onePair = pairs[ i ].split( "=" );
queryVars[ onePair[0] ] = onePair[ 1 ];
}
// run all tests if there's no query string
if( pairs.length === 1 ) {
queryVars = {
"core-tests": "1",
"plugin-tests": "1",
"player-tests": "1",
"parser-tests": "1",
"module-tests": "1",
};
}
return queryVars;
}
function buildQueryString() {
queryString = "?";
checkboxes.forEach(function( cb ) {
if ( cb.checked ) {
queryString += cb.id + "=1&";
}
});
}
function receiveResults( data ) {
var message = JSON.parse( data ),
li,
b,
ol,
a,
oneTest,
time,
title,
type,
fail = 0,
pass = 0,
total = 0;
// If name is present, we know this is a testDone post, so push results into array.
if ( message.name ) {
results_arr.push( message )
} else {
// this message is a Done post, so tally up everything and build the list item
ol = create( "ol" );
ol.style.display = "none";
// build inner list of results
while( oneTest = results_arr.pop() ) {
li = create( "li" );
li.className = oneTest.failed ? "fail" : "pass";
li.innerHTML = oneTest.name + " <b class='counts'>(<b class='failed'>" +
oneTest.failed + "</b>, <b class='passed'>" +
oneTest.passed + "</b>, " +
oneTest.total + ")</b>";
ol.appendChild( li );
// set to displayed if tests failed
if ( oneTest.failed ) {
ol.style.display = "block";
}
}
var a = create( "a" );
a.innerHTML = "Run test in new window";
a.href = currentTest.path;
a.target = "_blank";
fail = message.failed;
pass = message.passed;
total = message.total;
time = message.runtime;
title = currentTest.name;
type = currentTest.type;
main_b = create( "b" );
main_b.innerHTML = '<span class="module-name">' + type +
':&nbsp;</span><span class="test-name">' +
title + ":</span> Tests completed in " +
time + " milliseconds " + " <b class='counts'>(<b class='failed'>" +
fail + "</b>, <b class='passed'>" +
pass + "</b>, " + total + ")</b>";
// set up click listener for expanding inner test list
main_b.addEventListener( "click", function( e ) {
var next = e.target.nextSibling.nextSibling,
display = next.style.display;
next.style.display = display === "none" ? "block" : "none";
}, false );
// build main_li, append all children and then append to result list
main_li.className = fail ? "fail" : "pass";
main_li.removeChild( main_li.firstChild );
main_li.appendChild( main_b );
main_li.appendChild( a );
main_li.appendChild( ol );
// update running totals
totalRun += total;
totalFail += fail;
totalPass += pass;
totalTime += time;
advance();
}
}
function advance() {
if ( ++index < testList.length ) {
currentTest = testList[ index ];
main_li = create( "li" );
main_b = create ( "b" );
main_b.innerHTML = "Running " + currentTest.name;
main_li.appendChild( main_b );
main_li.className = "running";
results.appendChild( main_li );
testFrame.src = currentTest.path;
testFrame.contentWindow.focus();
} else {
// Finish test suite; display totals
$( testFrame ).remove();
id( "qunit-banner" ).className = totalFail ? "qunit-fail" : "qunit-pass";
var banner = create( "p" ),
html = [
'Tests completed in ',
totalTime,
' milliseconds.<br/>',
'<span class="passed">',
totalPass,
'</span> tests of <span class="total">',
totalRun,
'</span> passed, <span class="failed">',
totalFail,
'</span> failed.'
].join('');
banner.id = "qunit-testresult";
banner.className = "result";
banner.innerHTML = html;
results.parentNode.insertBefore( banner, results );
}
}
function addTests ( type ) {
var testTypeList = allTests[ type ];
for ( var test in testTypeList ) {
if ( testTypeList.hasOwnProperty( test ) ) {
testList.unshift({
"name": test,
"path": "../" + testTypeList[ test ],
"type": type
});
}
}
}
function parseTests() {
var qVars = parseQueryString(),
cb;
for ( var i = 0, len = testTypes.length; i < len; i++ ) {
cb = checkboxes[ i ];
cb.checked = !!( qVars[ cb.id ] === "1" );
if ( cb.checked ) {
addTests( cb.value );
}
}
}
this.getTests = function( loadedCallback ) {
$.getJSON( "../tests.conf", function( data ) {
if ( data ) {
allTests = data;
parseTests();
loadedCallback && typeof loadedCallback === "function" && loadedCallback();
}
});
}
this.runTests = function() {
if ( testList.length ) {
currentTest = testList[ index ];
main_b.innerHTML = "Running " + currentTest.name;
main_li.appendChild( main_b );
main_li.className = "running";
results.appendChild( main_li );
testFrame.src = currentTest.path;
}
};
// Get references to the checkboxes
testTypes.forEach(function( checkBoxId ) {
checkboxes.unshift( id( checkBoxId ) );
});
// Tells the tests within the iframe to take focus
testFrame.addEventListener( "load", sendGetFocus, false );
// Populate the userAgent h2 with information, if available
if ( userAgent ) {
userAgent.innerHTML = navigator.userAgent;
};
// Triggers tallying of results, and advances the tests.
window.addEventListener( "message", function( e ) {
receiveResults( e.data );
});
runSelected.addEventListener( "click", function() {
var location = window.location;
buildQueryString();
if ( queryString.length > 1 ) {
window.location = location.href.split( "?" )[ 0 ] + queryString;
}
});
};
document.addEventListener( "DOMContentLoaded", function() {
var runner = new TestRunner();
runner.getTests(function() {
runner.runTests();
});
});
}());

Просмотреть файл

@ -1,6 +1,6 @@
{
{
"core": {
"core": "test/index.html"
"core": "test/core.html"
},
"modules": {
"ie8": "ie8/popcorn.ie8.unit.html",