mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-04-25 16:44:43 +00:00
moved directories to a seperate php file the emits json
This commit is contained in:
parent
b016b028f6
commit
4409782b00
3 changed files with 70 additions and 62 deletions
|
|
@ -17,22 +17,6 @@
|
|||
<link rel="stylesheet" href="../../external/qunit.css"></link>
|
||||
<script src="../../js/jquery.js"></script>
|
||||
<script src="../../external/qunit.js"></script>
|
||||
<script type="text/javascript">
|
||||
window.testDirectories = [
|
||||
<?php
|
||||
// TODO move to php which produces json or data attrs. This is just dirty.
|
||||
if ($handle = opendir(getcwd())) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if (is_dir($file) && $file[0] !== "." ) {
|
||||
echo "'$file',\n";
|
||||
}
|
||||
}
|
||||
|
||||
closedir($handle);
|
||||
}
|
||||
?>
|
||||
];
|
||||
</script>
|
||||
<script src="runner.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
17
tests/unit/ls.php
Normal file
17
tests/unit/ls.php
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
header("Content-Type: application/json");
|
||||
|
||||
$response = array( 'directories' => array());
|
||||
|
||||
if ($handle = opendir(getcwd())) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if (is_dir($file) && $file[0] !== "." ) {
|
||||
array_push($response['directories'], $file);
|
||||
}
|
||||
}
|
||||
|
||||
closedir($handle);
|
||||
}
|
||||
|
||||
echo json_encode($response)
|
||||
?>
|
||||
|
|
@ -1,55 +1,62 @@
|
|||
(function(){
|
||||
var $frameElem = $("#testFrame"),
|
||||
template = $frameElem.attr("data-src"),
|
||||
updateFrame = function(dir){
|
||||
return $frameElem.attr("src", template.replace("{{testdir}}", dir));
|
||||
};
|
||||
var test = function(data){
|
||||
var $frameElem = $("#testFrame"),
|
||||
template = $frameElem.attr("data-src"),
|
||||
updateFrame = function(dir){
|
||||
return $frameElem.attr("src", template.replace("{{testdir}}", dir));
|
||||
};
|
||||
|
||||
$.each(testDirectories, function(i, dir){
|
||||
asyncTest( dir, function(){
|
||||
var nextCheck = null;
|
||||
$.each(data.directories, function(i, dir){
|
||||
asyncTest( dir, function(){
|
||||
var nextCheck = null;
|
||||
|
||||
// establish a timeout for a given suite in case of async tests hanging
|
||||
var testTimeout = setTimeout( function(){
|
||||
// prevent any schedule checks for completion
|
||||
clearTimeout(nextCheck);
|
||||
start();
|
||||
}, 2 * 60 * 1000 ),
|
||||
|
||||
// setup the next state check and record the timer id for removal
|
||||
scheduleCheck = function(){
|
||||
nextCheck = setTimeout( check, 2000 );
|
||||
},
|
||||
|
||||
// check the iframe for success or failure and respond accordingly
|
||||
check = function(){
|
||||
|
||||
// check for the frames jquery object each time
|
||||
var framejQuery = window.frames["testFrame"].jQuery;
|
||||
|
||||
// if the iframe hasn't loaded (ie loaded jQuery) check back again shortly
|
||||
if( !framejQuery ){
|
||||
scheduleCheck();
|
||||
return;
|
||||
}
|
||||
|
||||
// grab the result of the iframe test suite
|
||||
var result = framejQuery("#qunit-banner").attr('class');
|
||||
|
||||
// if we have a result check it, otherwise check back shortly
|
||||
if( result ){
|
||||
ok( result == "qunit-pass" );
|
||||
clearTimeout(testTimeout);
|
||||
// establish a timeout for a given suite in case of async tests hanging
|
||||
var testTimeout = setTimeout( function(){
|
||||
// prevent any schedule checks for completion
|
||||
clearTimeout(nextCheck);
|
||||
start();
|
||||
} else {
|
||||
scheduleCheck();
|
||||
}
|
||||
};
|
||||
}, 2 * 60 * 1000 ),
|
||||
|
||||
// setup the next state check and record the timer id for removal
|
||||
scheduleCheck = function(){
|
||||
nextCheck = setTimeout( check, 2000 );
|
||||
},
|
||||
|
||||
expect( 1 );
|
||||
updateFrame( dir );
|
||||
scheduleCheck();
|
||||
// check the iframe for success or failure and respond accordingly
|
||||
check = function(){
|
||||
|
||||
// check for the frames jquery object each time
|
||||
var framejQuery = window.frames["testFrame"].jQuery;
|
||||
|
||||
// if the iframe hasn't loaded (ie loaded jQuery) check back again shortly
|
||||
if( !framejQuery ){
|
||||
scheduleCheck();
|
||||
return;
|
||||
}
|
||||
|
||||
// grab the result of the iframe test suite
|
||||
var result = framejQuery("#qunit-banner").attr('class');
|
||||
|
||||
// if we have a result check it, otherwise check back shortly
|
||||
if( result ){
|
||||
ok( result == "qunit-pass" );
|
||||
clearTimeout(testTimeout);
|
||||
start();
|
||||
} else {
|
||||
scheduleCheck();
|
||||
}
|
||||
};
|
||||
|
||||
expect( 1 );
|
||||
updateFrame( dir );
|
||||
scheduleCheck();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// get the test directories
|
||||
$.ajax({
|
||||
url: "ls.php",
|
||||
success: test
|
||||
});
|
||||
})();
|
||||
|
|
|
|||
Loading…
Reference in a new issue