Litmus tab improvements, including "select tests" dialog and the subgroup

overview box. p=ben_h, r=zach.
This commit is contained in:
zach@zachlipton.com 2007-07-25 15:51:02 -07:00
Родитель ba69ba85c9
Коммит 41988a4176
10 изменённых файлов: 248 добавлений и 56 удалений

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

@ -88,4 +88,26 @@ var qaTools = {
}
}
},
arrayify : function(obj) {
if (obj instanceof Array) {
return obj;
}
var newArray = new Array();
newArray[0] = obj;
return newArray;
},
writeSafeHTML : function(elementID, htmlstr) {
document.getElementById(elementID).innerHTML = ""; //clear it.
var gUnescapeHTML = Components.classes["@mozilla.org/feed-unescapehtml;1"].getService(Components.interfaces.nsIScriptableUnescapeHTML);
var context = document.getElementById(elementID);
var fragment = gUnescapeHTML.parseFragment(htmlstr, false, null, context);
context.appendChild(fragment);
},
linkTargetsToBlank : function(node) {
var children = node.getElementsByTagName('a');
for (var i = 0; i < children.length; i++)
children[i].setAttribute("target", "_blank");
}
};

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

@ -1,26 +1,29 @@
const FIREFOX_ID = "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
var litmus = {
baseURL : qaPref.getPref(qaPref.prefBase+".litmus.url", "char"),
getTestcase : function(testcase_id, callback) {
var url = litmus.baseURL+'json.cgi?testcase_id='+testcase_id;
var d = loadJSONDoc(url);
d.addBoth(function (res) {
d.deferred = null;
return res;
});
d.addCallback(callback);
d.addErrback(function (err) {
if (err instanceof CancelledError) {
return;
}
alert(err);
});
litmus.getLitmusJson(testcase_id, callback, "testcase_id=");
},
getSubgroup : function(subgroupID, callback) {
var url = litmus.baseURL+'json.cgi?subgroup_id='+subgroupID;
litmus.getLitmusJson(subgroupID, callback, "subgroup_id=");
},
getTestgroup : function(testgroupID, callback) {
litmus.getLitmusJson(testgroupID, callback, "testgroup_id=");
},
getTestrun : function(testrunID, callback) {
litmus.getLitmusJson(testrunID, callback, "test_run_id=");
},
getTestruns : function(callback) {
var s = new Sysconfig(); // TODO: actually detect settings
var branch = encodeURIComponent(s.branch);
litmus.getLitmusJson("&product_name=Firefox&branch_name=" + branch,
callback, "test_runs_by_branch_product_name=1");
},
getLitmusJson : function(ID, callback, prefix) {
var url = litmus.baseURL+'json.cgi?' + prefix + ID;
var d = loadJSONDoc(url);
d.addBoth(function (res) {
d.deferred = null;
@ -31,15 +34,19 @@
if (err instanceof CancelledError) {
return;
}
alert(err);
});
},
alert(err);
});
},
handleDialog : function() {
var newWindow = window.openDialog('chrome://qa/content/tabs/selecttests.xul', '_blank', 'chrome,all,dialog=yes', litmus.readStateFromPref);
},
validateLogin : function(uname, passwd, callback) {
var req = doSimpleXMLHttpRequest(litmus.baseURL+'json.cgi', {
validate_login: 1,
username: uname,
password: passwd,
password: passwd
});
req.addErrback(callback);
req.addCallback(callback);
@ -62,14 +69,22 @@
});
},
currentTestCaseIndex: 0, // position in array
currentSubgroupID: 21,
currentSubgroupID: null,
cachedTests: null,
writeStateToPref : function(subgroupID, index) {
qaPref.setPref(qaPref.prefBase + ".currentTestcase.subgroupId", subgroupID, "int");
qaPref.setPref(qaPref.prefBase + ".currentTestcase.testcaseIndex", index, "int");
},
readStateFromPref : function() {
litmus.currentSubgroupID = qaPref.getPref(qaPref.prefBase + ".currentTestcase.subgroupId", "int");
litmus.getSubgroup(litmus.currentSubgroupID,litmus.statePopulateFields);
},
checkRadioButtons : function() {
var menu = document.getElementById('testlist');
if (menu.selectedIndex == -1) return;
var disable = menu.selectedItem.firstChild.getAttribute("checked");
document.getElementById("qa-testcase-result").disabled = disable;
},
@ -87,18 +102,19 @@
litmus.selectCurrentTestCase();
},
handleSelect : function() {
litmus.currentTestCaseIndex = document.getElementById('testlist').selectedIndex;
var menu = document.getElementById('testlist');
if (menu.selectedIndex == litmus.currentTestCaseIndex || menu.selectedIndex == -1)
return; // prevent recursion or triggering by removal of elements
litmus.currentTestCaseIndex = menu.selectedIndex;
litmus.selectCurrentTestCase();
},
selectCurrentTestCase : function() {
var menu = document.getElementById('testlist');
menu.selectedIndex = litmus.currentTestCaseIndex;
litmus.populateTestcase(litmus.cachedTests[litmus.currentTestCaseIndex]);
litmus.checkRadioButtons();
litmus.getTestcase(menu.selectedItem.value, litmus.populateTestcase);
},
populatePreviewBox : function() {
//document.getElementById("prev1").innerHTML = "hi!"; This doesn't even work, I guess I'll rewrite table in XUL
var menu = document.getElementById('testlist');
if (!menu) return;
@ -108,37 +124,48 @@
};
for (var i = 0; i < litmus.cachedTests.length; i++) {
var row = menu.appendItem("");
var row = menu.appendItem("", litmus.cachedTests[i].testcase_id);
var checkbox = document.createElement("listcell");
checkbox.setAttribute("label", "");
checkbox.setAttribute("type", "checkbox");
checkbox.setAttribute("disabled", "true");
//checkbox.setAttribute("checked", "true");
var name = document.createElement("listcell");
name.setAttribute("label", "#" + litmus.cachedTests[i].testcase_id + " -- " + litmus.cachedTests[i].summary);
name.setAttribute("crop", "end");
name.setAttribute("maxwidth", "175");
row.appendChild(checkbox);
row.appendChild(name);
}
},
},
populateTestcase : function(testcase) {
if (testcase == undefined) {
return;
}
document.getElementById('qa-testcase-id').value =
qaMain.bundle.getString("qa.extension.testcase.head")+testcase.testcase_id;
document.getElementById('qa-testcase-summary').value = testcase.summary;
document.getElementById('qa-testcase-steps').innerHTML = testcase.steps;
document.getElementById('qa-testcase-expected').innerHTML = testcase.expected_results;
},
qaTools.writeSafeHTML('qa-testcase-steps', testcase.steps_formatted);
qaTools.writeSafeHTML('qa-testcase-expected', testcase.expected_results_formatted);
qaTools.linkTargetsToBlank($('qa-testcase-steps'));
qaTools.linkTargetsToBlank($('qa-testcase-expected'));
litmus.checkRadioButtons();
},
populateFields : function(subgroup) {
litmus.cachedTests = subgroup.testcases;
//litmus.currentTestCaseIndex = 0;
litmus.populatePreviewBox();
litmus.currentTestCaseIndex = 0;
litmus.selectCurrentTestCase();
},
statePopulateFields : function(subgroup) { //TODO: there's gotta be a better way to do this...
litmus.cachedTests = subgroup.testcases;
litmus.populatePreviewBox();
litmus.currentTestCaseIndex = qaPref.getPref(qaPref.prefBase + ".currentTestcase.testcaseIndex", "int");
litmus.selectCurrentTestCase();
},
submitResult : function() {
var rs;
var item = $('qa-testcase-result').selectedItem;

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

@ -10,8 +10,6 @@ var qaMain = {
}
},
};
qaMain.__defineGetter__("bundle", function(){return $("bundle_qa");});
qaMain.__defineGetter__("urlbundle", function(){return $("bundle_urls");});
@ -30,4 +28,4 @@ function $() {
}
return elements;
}
}

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

@ -1,4 +1,5 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<?xml-stylesheet href="chome://qa/skin/" type="text/css"?>
<!DOCTYPE window [
@ -15,7 +16,7 @@
id="qa-mainwindow"
title="&qa.mainwindow.title;"
width="400"
height="750"
height="800"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
onload="qaMain.onToolOpen();">

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

@ -84,11 +84,6 @@ var qaPrefsWindow = {
},
};
// on load, set an event listener to deal with saving settings when
// changing tabs
window.addEventListener('load', function() {
$('qa_tabrow').addEventListener('select', qaPrefsWindow.onSwitchTab, false);
}, false);
var qaSetup = {
didSubmitForm : 0,

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

@ -5,46 +5,51 @@
<!ENTITY % qaDTD SYSTEM "chrome://qa/locale/qa.dtd"> %qaDTD;
]>
<overlay id="qa-litmus-overlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<overlay id="qa-litmus-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="chrome://qa/content/MochiKit/MochiKit.js" />
<script type="application/x-javascript" src="chrome://qa/content/tabs/qa.js" />
<script type="application/x-javascript" src="chrome://qa/content/tabs/prefs.js" />
<script type="application/x-javascript" src="chrome://qa/content/tabs/litmus.js" />
<tabpanel id="qa-tab-litmus" >
<vbox align="start" pack="start">
<hbox align="start" pack="start">
<vbox maxwidth="110">
<button maxwidth="110" label="&qa.litmus.selecttests;" oncommand="litmus.getSubgroup('1', litmus.populateFields)" style="margin-left: 4px;" />
<label value="Firefox 3.0 Catch-All Test Run" />
<label value="Firefox 3.0 Basic Functional Tests" />
<label value="Software Update" />
<button maxwidth="110" label="&qa.litmus.selecttests;"
oncommand="litmus.handleDialog()"
style="margin-left: 4px;" />
<label value="" id="qa-testrun-label"/>
<label value="" id="qa-testgroup-label"/>
<label value="" id="qa-subgroup-label"/>
</vbox>
<listbox rows="7" equalsize="always" onselect="litmus.handleSelect()" id="testlist">
<listcols>
<listcol />
<listcol />
</listcols>
<listitem label="&qa.litmus.testlist.initiallabel;" />
</listbox>
</hbox>
<hbox style="font-weight: bold;">
<label id="qa-testcase-id" value="Testcase 51" />
<label id="qa-testcase-id" width = "100px" value="&qa.litmus.testlist.initialdescription;" />
<label value=" --" />
<description id="qa-testcase-summary">Summary of testcase</description>
<description id="qa-testcase-summary" maxwidth="230px" crop="end"></description>
</hbox>
<vbox>
<groupbox height="160px">
<caption label="&qa.testcase.steps;" crop="end" maxwidth="200"/>
<div xmlns="http://www.w3.org/1999/xhtml" style="width: 300px" id="qa-testcase-steps" class="list"/>
<div xmlns="http://www.w3.org/1999/xhtml" style="width: 350px; height: 160px; overflow: auto;" id="qa-testcase-steps" class="list"/>
</groupbox>
<splitter id="qa-mainwindow-splitter" state="open" collapse="none">
<grippy/>
</splitter>
<groupbox height="130px">
<caption label="&qa.testcase.expected;" />
<div xmlns="http://www.w3.org/1999/xhtml" id="qa-testcase-expected" class="list"/>
<div xmlns="http://www.w3.org/1999/xhtml" style="width: 350px; height: 130px; overflow: auto;" id="qa-testcase-expected" class="list"/>
</groupbox>
</vbox>

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

@ -0,0 +1,79 @@
var updateFunction;
var sTestrunsWrapper; // an array of things that are kind of like testruns, but w/o important fields.
//returned by "test_runs_by_branch_product_name="
var sTestrun; // actual testrun
function handleLoad() {
if (window.arguments.length > 0)
updateFunction = window.arguments[0]; // parent window passes in a function to update itself with data
litmus.getTestruns(populateTestRuns);
}
function handleRunSelect() {
var id = document.getElementById("qa-st-testrun").selectedItem.getAttribute("value");
litmus.getTestrun(id, populateTestGroups);
}
function handleTestgroupSelect() {
var id = document.getElementById("qa-st-testgroup").selectedItem.value;
litmus.getTestgroup(id, populateSubgroups);
}
function handleSubgroupSelect() {
var id = document.getElementById("qa-st-subgroup").selectedItem.value;
updateCaller(id, 0);
}
function populateTestRuns(testrunsWrapper) {
var menu = document.getElementById("qa-st-testrun");
testrunsWrapper = qaTools.arrayify(testrunsWrapper);
sTestrunsWrapper = testrunsWrapper;
while (menu.firstChild) { // clear menu
menu.removeChild(menu.firstChild);
}
for (var i = 0; i < testrunsWrapper.length; i++) {
if (testrunsWrapper[i].enabled == 0) continue;
var item = menu.appendItem(testrunsWrapper[i].name, testrunsWrapper[i].test_run_id);
}
menu.selectedIndex = 0;
handleRunSelect();
}
function populateTestGroups(testrun) {
var menu = document.getElementById("qa-st-testgroup");
while (menu.firstChild) { // clear menu
menu.removeChild(menu.firstChild);
}
var testgroups = qaTools.arrayify(testrun.testgroups);
for (var i = 0; i < testgroups.length; i++) {
if (testgroups[i].enabled == 0) continue;
menu.appendItem(testgroups[i].name, testgroups[i].testgroup_id);
}
menu.selectedIndex = 0;
}
function populateSubgroups(testgroup) {
var menu = document.getElementById("qa-st-subgroup");
while (menu.firstChild) { // clear menu
menu.removeChild(menu.firstChild);
}
var subgroups = qaTools.arrayify(testgroup.subgroups);
for (var i = 0; i < subgroups.length; i++) {
if (subgroups[i].enabled == 0) continue;
menu.appendItem(subgroups[i].name, subgroups[i].subgroup_id);
}
menu.selectedIndex = 0;
}
function OK() {
return true;
}
function updateCaller(subgroupID, index) {
litmus.writeStateToPref(subgroupID, index);
updateFunction();
}
function Cancel() {
return true;
}

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

@ -0,0 +1,55 @@
<?xml version="1.0"?>
<!DOCTYPE dialog PUBLIC "-//MOZILLA//DTD XUL V1.0//EN" "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
[<!ENTITY % qaDTD SYSTEM "chrome://qa/locale/qa.dtd"> %qaDTD;
]>
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<?xml-stylesheet href="chome://qa/skin/" type="text/css"?>
<dialog id="dialog-name"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
persist="screenX screenY width height"
buttons="accept,cancel"
ondialogaccept="return OK();"
ondialogcancel="return Cancel();"
onload="handleLoad();">
<script type="application/x-javascript" src="chrome://qa/content/MochiKit/MochiKit.js" />
<script type="application/x-javascript" src="chrome://qa/content/prefs.js" />
<script type="application/x-javascript" src="chrome://qa/content/litmus.js" />
<script type="application/x-javascript" src="chrome://qa/content/qa.js" />
<script type="application/x-javascript" src="chrome://qa/content/settings.js" />
<script type="application/x-javascript" src="chrome://qa/content/common.js" />
<script type="application/x-javascript" src="chrome://qa/content/selecttests.js" />
<dialogheader title="Select test group" />
<spacer height="20" />
<vbox>
<hbox>
<description value="Test Run:" />
<menulist label=" " id="qa-st-testrun" onselect="handleRunSelect()">
<menupopup >
<menuitem label="&qa.selecttests.load;" selected="true" />
</menupopup>
</menulist>
</hbox>
<spacer height="20" />
<hbox>
<vbox>
<description value="Test Group:" />
<listbox id="qa-st-testgroup" rows = "5" onselect="handleTestgroupSelect()">
<listitem label="&qa.selecttests.load;" />
</listbox>
</vbox>
<vbox>
<description value="Subgroup" />
<listbox id="qa-st-subgroup" rows = "5" onselect="handleSubgroupSelect()">
<listitem label="&qa.selecttests.load;" />
</listbox>
</vbox>
</hbox>
</vbox>
</dialog>

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

@ -9,7 +9,14 @@
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="chrome://qa/content/settings.js" />
<script type="application/x-javascript">
// on load, set an event listener to deal with saving settings when
// changing tabs
window.addEventListener('load', function() {
$('qa_tabrow').addEventListener('select', qaPrefsWindow.onSwitchTab, false);
}, false);
</script>
<stringbundleset id="stringbundleset">
<stringbundle id="bundle_qa" src="chrome://qa/locale/qa.properties" />
</stringbundleset>

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

@ -1,6 +1,7 @@
<!ENTITY qa.litmus.title "Litmus">
<!ENTITY qa.litmus.selecttests "Select Tests">
<!ENTITY qa.litmus.testlist.initiallabel "No tests loaded, select some tests!">
<!ENTITY qa.litmus.testlist.initialdescription "No testcase">
<!ENTITY qa.statusbar.label "QA">
<!ENTITY qa.mainwindow.prefs "Preferences">
<!ENTITY qa.mainwindow.title "Mozilla QA">
@ -11,6 +12,8 @@
<!ENTITY qa.testcase.result.unclearbroken "Test is unclear or broken">
<!ENTITY qa.testcase.comment "Comment (optional):">
<!ENTITY qa.selecttests.load "Loading...">
<!ENTITY qa.preferences.title "Settings">
<!ENTITY qa.preferences.litmus.title "Litmus Settings">
<!ENTITY qa.preferences.litmus.username "Email:">