Various enhancements to the testsuite:

- split resources of the suite (CSS, HTML, !JavaScript)
  - dedicated files for our changes to the suite
  - CSS enhancements (e.g. hover colors)
  - a simple quicksearch/filter for the list of testfiles (Only for browsers that support querySelectorAll)
  - links to the testfiles to easily bypass browser cache
  - running time info panel
  - detailed total number of testcases that failed/were ok

Non-functional change (closes #3507)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@12378 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Marc Jansen
2011-09-17 17:36:14 +00:00
parent 6cf0dbfc13
commit 57c16b7345
6 changed files with 3073 additions and 2421 deletions

View File

@@ -0,0 +1,177 @@
// total counters
Test.AnotherWay._openlayers_sum_total_detail_ok=0;
Test.AnotherWay._openlayers_sum_total_detail_fail=0;
Test.AnotherWay._startTime = null;
// method overwrites
//
// behaviour (timing)
Test.AnotherWay._old_run_all_onclick = Test.AnotherWay._run_all_onclick;
Test.AnotherWay._run_all_onclick = function(){
Test.AnotherWay._startTime = (new Date()).getTime();
Test.AnotherWay.reset_running_time();
Test.AnotherWay._old_run_all_onclick.apply(this, arguments);
};
Test.AnotherWay._old_run_selected_onclick = Test.AnotherWay._run_selected_onclick;
Test.AnotherWay._run_selected_onclick = function(){
Test.AnotherWay._startTime = (new Date()).getTime();
Test.AnotherWay.reset_running_time();
Test.AnotherWay._old_run_selected_onclick.apply(this, arguments);
};
Test.AnotherWay._old_run_one_onclick = Test.AnotherWay._run_one_onclick;
Test.AnotherWay._run_one_onclick = function(){
Test.AnotherWay._startTime = (new Date()).getTime();
Test.AnotherWay.reset_running_time();
Test.AnotherWay._old_run_one_onclick.apply(this, arguments);
};
// test page loading
Test.AnotherWay.old_load_next_page = Test.AnotherWay._load_next_page;
Test.AnotherWay._load_next_page = function(){
Test.AnotherWay.update_running_time();
Test.AnotherWay.old_load_next_page.apply(this, arguments);
};
Test.AnotherWay._add_test_page_url = function(test_url, convention){
var table = document.getElementById("testtable");
var record_select = document.getElementById("record_select");
var index = Test.AnotherWay._g_test_page_urls.length;
// trim spaces.
if (test_url.match("^(\\s*)(.*\\S)(\\s*)$")) {
test_url = RegExp.$2;
}
Test.AnotherWay._g_test_page_urls[index] = {
url: test_url,
convention: convention
};
var row = table.insertRow(-1);
var cell;
var cell_child;
var link;
cell = row.insertCell(-1);
cell_child = document.createElement("input");
cell_child.type = "checkbox";
cell_child.id = "checkbox" + index;
cell_child.checked = 'checked';
cell_child.defaultChecked = 'checked';
cell.appendChild(cell_child);
cell = row.insertCell(-1);
cell.setAttribute("width", "75%");
// make the URL a clickable link that opens in a new window
// start changes
link = document.createElement("a");
link.href=test_url;
link.target='_blank';
link.title='Opens testfile in a new window.';
link.appendChild(document.createTextNode(test_url));
cell.appendChild(link);
// end changes
cell = row.insertCell(-1);
cell_child = document.createElement("input");
cell_child.type = "button";
cell_child.id = "test" + index;
cell_child.value = " run ";
cell_child.onclick = Test.AnotherWay._run_one_onclick;
cell.appendChild(cell_child);
cell = row.insertCell(-1);
cell.setAttribute("width", "8em");
cell_child = document.createElement("span");
cell.appendChild(cell_child);
var option = document.createElement("option");
option.appendChild(document.createTextNode(test_url));
record_select.appendChild(option);
};
// new methods
Test.AnotherWay.update_running_time = function() {
var now = (new Date()).getTime();
var floor = Math.floor;
var elapsed = now - Test.AnotherWay._startTime;
var zeroPad = function(num, length){
var len = -1 * (length || 2);
return ('00000' + num).slice(len);
};
var ms = zeroPad(elapsed%1000, 3);
var seconds=zeroPad(floor((elapsed/1000)%60));
var minutes=zeroPad(floor((elapsed/60000)%60));
document.getElementById('running-time').innerHTML = 'Elapsed time ' + minutes + ':' + seconds + ':' + ms +' (m:s:ms).';
};
Test.AnotherWay.reset_running_time = function(){
document.getElementById('running-time').innerHTML = '';
};
// quickfilter
Test.AnotherWay.bindQuicksearchListener = function(){
var input = document.getElementById('quickfilter');
if (input.addEventListener) {
input.addEventListener('keyup', Test.AnotherWay.quicksearch);
} else if (input.attachEvent) {
input.attachEvent('onkeyup', Test.AnotherWay.quicksearch);
} else {
// remove the input field
input.parentNode.removeChild(input);
}
};
Test.AnotherWay.quicksearchThrottleTimeOut = null;
Test.AnotherWay.quicksearch = function(){
if (Test.AnotherWay.quicksearchThrottleTimeOut) {
window.clearTimeout(Test.AnotherWay.quicksearchThrottleTimeOut);
}
Test.AnotherWay.quicksearchThrottleTimeOut = window.setTimeout(function(){
var input = document.getElementById('quickfilter');
Test.AnotherWay.filterTestList(input.value);
}, 300);
};
Test.AnotherWay.filterTestList = function(str){
Test.AnotherWay.unfilterTestList();
var re = new RegExp(str, 'i');
var candidates = document.querySelectorAll('#testtable tr td:nth-child(2) a');
for (var idx = 0, len = candidates.length; idx<len; idx++) {
var tr = candidates[idx].parentNode.parentNode;
var html = candidates[idx].innerHTML;
if (re.test(html)) {
tr.className = 'isShown';
} else {
tr.className = 'isHidden';
}
}
};
Test.AnotherWay.unfilterTestList = function() {
if ( document.querySelectorAll ) {
var hidden = document.querySelectorAll('.isHidden');
for (var idx = 0, len = hidden.length; idx < len; idx++) {
hidden[idx].className = 'isShown';
}
}
};
// bind our quicksearch init method to body onload.
(function(win){
if (win.addEventListener) {
win.addEventListener('load', Test.AnotherWay.bindQuicksearchListener);
} else if (input.attachEvent) {
win.attachEvent('onload', Test.AnotherWay.bindQuicksearchListener);
} else {
win.onload = function(){
Test.AnotherWay.bindQuicksearchListener();
};
}
})(window);

243
tests/Test.AnotherWay.css Normal file
View File

@@ -0,0 +1,243 @@
/**
* Test.AnotherWay version 0.5
*
* Copyright (c) 2005 Artem Khodush, http://straytree.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
* {
padding: 0;
margin: 0;
}
html {
height: 99%;
}
body {
height: 98%;
font: normal normal 10pt sans-serif
}
#col1 {
float: left;
width: 27em;
margin: 0 0 0 1em;
overflow: visible;
}
#col2 {
position: relative;
height: 98%;
margin: 0 0.5em 0 28em;
}
#col1_header {
margin-top: 0.5em;
}
#scroller {
height: 400px;
overflow: auto;
}
#testtable {
margin: 0 0 2em 0;
width: 97%;
font-size: 1em;
border-collapse: collapse;
}
#testtable input {
cursor: pointer;
}
#testtable td {
line-height: 2em;
padding: 0;
margin: 0;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
}
#testtable tr:hover td {
background-color: #ededed;
}
#testtable tr.isHidden {
display: none;
}
#testtable tr.isShown {
display: table-row;
}
#run_buttons, #running-time {
margin-bottom: 1em;
}
#right_header {
padding-top: 0.8em;
}
#results_count {
float: left;
}
#results > p:hover {
background-color: #ededed;
}
.active_tab {
float: right;
padding: 0 1em 0.2em 1em;
background: #0af;
border: 1px solid #048;
border-bottom: none;
cursor: pointer;
cursor: hand;
position: relative;
top: -0.2em;
}
.inactive_tab {
float: right;
padding: 0 1em 0 1em;
background: #9bb;
color: #444;
border: 1px solid #9bb;
border-bottom: none;
cursor: pointer;
cursor: hand;
}
.inactive_mouseover_tab {
float: right;
padding: 0 1em 0 1em;
background: #9bb;
color: #062;
border: 1px solid #062;
border-bottom: none;
cursor: pointer;
cursor: hand;
}
#right_frame {
overflow: auto;
position: relative;
top: -0.2em;
clear: right;
height: 95%;
border: 1px solid #048;
}
#debug {
display: none;
}
#debug p {
margin: 2px 0 0 5em;
text-indent: -4.8em;
}
#error {
display: none;
color: #c22;
}
#results p {
margin: 0 0 2px 0;
}
/* cursor indicating that detailed results may be expanded/contracted */
#results p.badtest {
cursor: text;
}
#results p.ok, #results p.fail {
cursor: pointer;
cursor: hand;
}
/* colored squares in the results window at the left of test page names */
#results p.ok .bullet {
background: #6d6;
}
#results p.fail .bullet {
background: #d46;
}
#results p.badtest .bullet {
background: #ea3;
}
#results p.loading .bullet {
background: #48f;
}
#results p.running .bullet {
background: #26e;
}
#results p.waiting .bullet {
background: #04d;
}
/* highlight in the results line */
#results p .warning {
background: #ffc;
}
/* layout of the detailed results */
.result_detail {
padding-left: 3em;
}
.result_exception_detail {
padding-left: 4em;
}
.result_exception_stack_detail {
padding-left: 5em;
}
.result_micro_detail {
padding-left: 6em;
}
/* colouring in the detailed results */
.result_detail .fail, .result_exception_detail .fail, .result_micro_detail .fail {
background: #ffd8d8;
}
/* "start recording" controls*/
#record_div {
margin-top: 3em;
}
#record_div p {
margin-bottom: 0.5em;
}
#record_select {
width: 88%;
}
#record_input {
width: 53%;
}

View File

@@ -1,6 +1,6 @@
/**
* File: xml_eq.js
* Adds a xml_eq method to AnotherWay test objects.
* File: Test.AnotherWay.geom_eq.js
* Adds a geom_eq method to AnotherWay test objects.
*
*/

2498
tests/Test.AnotherWay.js Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
/**
* File: xml_eq.js
* File: Test.AnotherWay.xml_eq.js
* Adds a xml_eq method to AnotherWay test objects.
*
*/

File diff suppressed because it is too large Load Diff