add progress to mochitest, let 'run tests' button switch to 'stop tests' when tests are running. r=jwalden

--HG--
extra : rebase_source : a3140848cc101fae96f355f4a44892b4e23c9850
This commit is contained in:
Ted Mielczarek 2009-10-30 13:00:19 -04:00
Родитель 34015a77aa
Коммит 9dcdb9fc2e
4 изменённых файлов: 25 добавлений и 6 удалений

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

@ -514,6 +514,10 @@ function testListing(metadata, response)
true);
dumpn("count: " + count);
var tests = jsonArrayOfTestFiles(links);
var runtests = "Run Tests";
if (metadata.queryString.indexOf("autorun=1") != -1) {
runtests = "Stop Tests";
}
response.write(
HTML(
HEAD(
@ -536,7 +540,7 @@ function testListing(metadata, response)
),
BODY(
DIV({class: "container"},
H2("--> ", A({href: "#", id: "runtests"}, "Run Tests"), " <--"),
H2("--> ", A({href: "#", id: "runtests"}, runtests), " <--"),
P({style: "float: right;"},
SMALL(
"Based on the ",
@ -546,6 +550,8 @@ function testListing(metadata, response)
),
DIV({class: "status"},
H1({id: "indicator"}, "Status"),
H2({id: "file"}, "File: ",
SPAN({id: "progress"}, "0 / " + count + " (0%)")),
H2({id: "pass"}, "Passed: ", SPAN({id: "pass-count"},"0")),
H2({id: "fail"}, "Failed: ", SPAN({id: "fail-count"},"0")),
H2({id: "fail"}, "Todo: ", SPAN({id: "todo-count"},"0"))

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

@ -91,7 +91,7 @@ div#current-test {
margin: 0;
}
#pass, #fail {
#pass, #fail, #file {
margin: 0;
padding: .5em;
}

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

@ -11,6 +11,7 @@ TestRunner.logEnabled = false;
TestRunner._currentTest = 0;
TestRunner.currentTestURL = "";
TestRunner._urls = [];
TestRunner._title = "";
TestRunner.timeout = 5 * 60 * 1000; // 5 minutes.
TestRunner.maxTimeouts = 4; // halt testing after too many timeouts
@ -95,7 +96,7 @@ TestRunner._makeIframe = function (url, retry) {
TestRunner.logger.log("Error: Unable to restore focus, expect failures and timeouts.");
}
}
window.scrollTo(0, $('indicator').offsetTop);
window.scrollTo(0, 0);
iframe.src = url;
iframe.name = url;
iframe.width = "500";
@ -112,6 +113,7 @@ TestRunner.runTests = function (/*url...*/) {
if (TestRunner.logEnabled)
TestRunner.logger.log("SimpleTest START");
TestRunner._title = document.title;
TestRunner._urls = flattenArguments(arguments);
$('testframe').src="";
TestRunner._checkForHangs();
@ -169,6 +171,12 @@ TestRunner.runNextTest = function() {
if (TestRunner.onComplete)
TestRunner.onComplete();
}
var cur = TestRunner._currentTest;
var total = TestRunner._urls.length;
var progress = cur + " / " + total + " (" +
Math.floor(100 * (cur / total)) + "%)";
document.title = progress + " - " + TestRunner._title;
$("progress").innerHTML = progress;
};
/**

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

@ -138,11 +138,16 @@ RunSet.runall = function(e) {
}
RunSet.reloadAndRunAll = function(e) {
e.preventDefault();
//window.location.hash = "";
var addParam = "";
if (params.autorun) {
window.location.search += "";
window.location.href = window.location.href;
if (!TestRunner._haltTests) {
TestRunner._haltTests = true;
$('runtests').innerHTML = "Restart Tests";
}
else {
// already clicked stop, so just reload
window.location.href = window.location.href;
}
} else if (window.location.search) {
window.location.href += "&autorun=1";
} else {