mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-05-19 20:01:52 +00:00
moved check to interval, made the directories an ajax call instead of a templated js array, and reorged some bits to clean things up
This commit is contained in:
parent
a7045d3bb4
commit
97feeaffc0
3 changed files with 23 additions and 31 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
|
<link rel="stylesheet" href="../../external/qunit.css"></link>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div style="float: left; width: 500px;">
|
<div style="float: left; width: 500px;">
|
||||||
|
|
@ -14,7 +15,6 @@
|
||||||
I think an entire link and stylesheet is a waste -->
|
I think an entire link and stylesheet is a waste -->
|
||||||
<iframe data-src="../../tests/unit/{{testdir}}" name="testFrame" id="testFrame" width="800px" height="100%" style="float: left; border: 0px; height: 100%;" scrolling="no">
|
<iframe data-src="../../tests/unit/{{testdir}}" name="testFrame" id="testFrame" width="800px" height="100%" style="float: left; border: 0px; height: 100%;" scrolling="no">
|
||||||
</iframe>
|
</iframe>
|
||||||
<link rel="stylesheet" href="../../external/qunit.css"></link>
|
|
||||||
<script src="../../js/jquery.js"></script>
|
<script src="../../js/jquery.js"></script>
|
||||||
<script src="../../external/qunit.js"></script>
|
<script src="../../external/qunit.js"></script>
|
||||||
<script src="runner.js"></script>
|
<script src="runner.js"></script>
|
||||||
|
|
|
||||||
|
|
@ -13,5 +13,5 @@
|
||||||
closedir($handle);
|
closedir($handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo json_encode($response)
|
echo json_encode($response)
|
||||||
?>
|
?>
|
||||||
|
|
@ -1,63 +1,55 @@
|
||||||
(function(){
|
(function(){
|
||||||
var test = function(data){
|
var test = function(data){
|
||||||
var $frameElem = $("#testFrame"),
|
var $frameElem = $("#testFrame"),
|
||||||
template = $frameElem.attr("data-src"),
|
template = $frameElem.attr("data-src"),
|
||||||
updateFrame = function(dir){
|
updateFrame = function(dir){
|
||||||
return $frameElem.attr("src", template.replace("{{testdir}}", dir));
|
return $frameElem.attr("src", template.replace("{{testdir}}", dir));
|
||||||
};
|
};
|
||||||
|
|
||||||
$.each(data.directories, function(i, dir){
|
$.each(data.directories, function(i, dir){
|
||||||
asyncTest( dir, function(){
|
asyncTest( dir, function(){
|
||||||
var nextCheck = null;
|
var testTimeout = 2 * 60 * 1000, checkInterval = 2000;
|
||||||
|
|
||||||
// establish a timeout for a given suite in case of async tests hanging
|
// establish a timeout for a given suite in case of async tests hanging
|
||||||
var testTimeout = setTimeout( function(){
|
var testTimer = setTimeout( function(){
|
||||||
// prevent any schedule checks for completion
|
// prevent any schedule checks for completion
|
||||||
clearTimeout(nextCheck);
|
clearTimeout( checkTimer );
|
||||||
start();
|
start();
|
||||||
}, 2 * 60 * 1000 ),
|
}, testTimeout ),
|
||||||
|
|
||||||
// setup the next state check and record the timer id for removal
|
checkTimer = setInterval( check, checkInterval );
|
||||||
scheduleCheck = function(){
|
|
||||||
nextCheck = setTimeout( check, 2000 );
|
|
||||||
},
|
|
||||||
|
|
||||||
// check the iframe for success or failure and respond accordingly
|
// check the iframe for success or failure and respond accordingly
|
||||||
check = function(){
|
function check(){
|
||||||
|
|
||||||
// check for the frames jquery object each time
|
// check for the frames jquery object each time
|
||||||
var framejQuery = window.frames["testFrame"].jQuery;
|
var framejQuery = window.frames["testFrame"].jQuery;
|
||||||
|
|
||||||
// if the iframe hasn't loaded (ie loaded jQuery) check back again shortly
|
// if the iframe hasn't loaded (ie loaded jQuery) check back again shortly
|
||||||
if( !framejQuery ){
|
if( !framejQuery ) return;
|
||||||
scheduleCheck();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// grab the result of the iframe test suite
|
// grab the result of the iframe test suite
|
||||||
// TODO strip extra white space
|
// TODO strip extra white space
|
||||||
var result = framejQuery("#qunit-banner").attr('class');
|
var result = framejQuery( "#qunit-banner" ).attr( "class" );
|
||||||
|
|
||||||
// if we have a result check it, otherwise check back shortly
|
// if we have a result check it, otherwise check back shortly
|
||||||
if( result ){
|
if( result ){
|
||||||
ok( result == "qunit-pass" );
|
ok( result == "qunit-pass" );
|
||||||
clearTimeout(testTimeout);
|
|
||||||
|
// prevent the next interval of the check function and the test timeout
|
||||||
|
clearTimeout( checkTimer );
|
||||||
|
clearTimeout( testTimer );
|
||||||
start();
|
start();
|
||||||
} else {
|
|
||||||
scheduleCheck();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect( 1 );
|
expect( 1 );
|
||||||
|
|
||||||
|
// set the test suite page on the iframe
|
||||||
updateFrame( dir );
|
updateFrame( dir );
|
||||||
scheduleCheck();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// get the test directories
|
// get the test directories
|
||||||
$.ajax({
|
$.get("ls.php", test);
|
||||||
url: "ls.php",
|
|
||||||
success: test
|
|
||||||
});
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue