1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
|
// jsreporter.js
// Script to support JsReporter class
// Relies heavily on the X library in x.js
// X v3.14.1, Cross-Browser DHTML Library from Cross-Browser.com
// Copyright (c) 2004 Jason E. Sweat (jsweat_php@yahoo.com)
//
// SimpleTest - http://simpletest.sf.net/
// Copyright (c) 2003,2004 Marcus Baker (marcus@lastcraft.com)
// $Id: webunit.js,v 1.10 2004/02/14 18:24:13 jsweat Exp $
// Variables:
min_x=500;
min_y=400;
groups = new Array();
cases = new Array();
methods = new Array();
current_group=0;
current_case=0;
current_method=0;
Hash = {
Set : function(foo,bar) {this[foo] = bar;},
Get : function(foo) {return this[foo];}
}
// Functions:
function wait_start() {
var wait_x;
var wait_y;
wait_x = xWidth('wait');
wait_y = xHeight('wait');
xMoveTo('wait', (xClientWidth()-wait_x)/2, (xClientHeight()-wait_y)/2);
xShow('wait');
}
function layout() {
xResizeTo('webunit', max(xClientWidth()-30,min_x), max(xClientHeight()-20,min_y));
xMoveTo('webunit', 5, 5);
xResizeTo('tabs', xWidth('webunit')-10, xHeight('webunit')/3);
xLeft('tabs', 5);
xShow('webunit');
xShow('tabs');
activate_tab('fail');
xShow('visible_tab');
xZIndex('visible_tab', 2)
xResizeTo('msg', xWidth('webunit')-17, xHeight('webunit')/3-20);
xLeft('msg', 2);
xTop('msg',2*xHeight('webunit')/3);
xShow('msg');
}
function set_div_content(div, content) {
xGetElementById(div).innerHTML = content;
}
function copy_div_content(divsrc, divtrgt) {
xGetElementById(divtrgt).innerHTML = xGetElementById(divsrc).innerHTML;
}
function activate_tab(tab) {
if (tab == 'fail') {
copy_div_content('fail', 'visible_tab');
xGetElementById('failtab').className = 'activetab';
xZIndex('failtab', 3)
xGetElementById('treetab').className = 'inactivetab';
xZIndex('treetab', 1)
}
if (tab == 'tree') {
copy_div_content('tree', 'visible_tab');
xGetElementById('failtab').className = 'inactivetab';
xZIndex('failtab', 1)
xGetElementById('treetab').className = 'activetab';
xZIndex('treetab', 3)
}
}
function add_group(group_name) {
var add;
add = {
Set : function(foo,bar) {this[foo] = bar;},
Get : function(foo) {return this[foo];}
}
add.Set('desc', group_name);
add.Set('pass', true);
groups[groups.length] = add;
current_group = groups.length - 1;
cases[current_group] = new Array();
methods[current_group] = new Array();
}
function add_case(case_name) {
var curgroup;
var add;
add = {
Set : function(foo,bar) {this[foo] = bar;},
Get : function(foo) {return this[foo];}
}
add.Set('desc', case_name);
add.Set('pass', true);
curgroup = cases[current_group];
cases[current_group][curgroup.length] = add;
current_case = curgroup.length - 1;
methods[current_group][current_case] = new Array();
}
function add_method(method_name) {
var curcase;
var add;
add = {
Set : function(foo,bar) {this[foo] = bar;},
Get : function(foo) {return this[foo];}
}
add.Set('desc', method_name);
add.Set('pass', true);
add.Set('msg','');
curcase = methods[current_group][current_case];
methods[current_group][current_case][curcase.length] = add;
current_method = curcase.length - 1;
}
function add_fail(msg) {
var oldmsg;
add_log(msg);
groups[current_group].Set('pass', false);
cases[current_group][current_case].Set('pass', false);
methods[current_group][current_case][current_method].Set('pass', false);
oldmsg = methods[current_group][current_case][current_method].Get('msg');
methods[current_group][current_case][current_method].Set('msg', oldmsg+msg);
}
function add_log(msg) {
var faildiv;
faildiv = xGetElementById('fail');
faildiv.innerHTML = faildiv.innerHTML + msg;
}
function set_msg(gid, cid, mid) {
var passfail;
var msg=methods[gid][cid][mid].Get('msg');
if ('' == msg) {
passfail = (methods[gid][cid][mid].Get('pass')) ? 'pass' : 'fail';
msg = 'No output for <span class="' + passfail + '">'
+ groups[gid].Get('desc') + '->'
+ cases[gid][cid].Get('desc') + '->'
+ methods[gid][cid][mid].Get('desc') + '</span><br />';
}
xGetElementById('msg').innerHTML = msg;
}
function make_tree() {
var content;
var passfail;
content = '<ul>';
for (x in groups) {
passfail = (groups[x].Get('pass')) ? 'pass' : 'fail';
content += '<li class="'+passfail+'">'+groups[x].Get('desc')+'<ul>';
for (y in cases[x]) {
passfail = (cases[x][y].Get('pass')) ? 'pass' : 'fail';
content += '<li class="'+passfail+'">'+cases[x][y].Get('desc')+'<ul>';
for (z in methods[x][y]) {
passfail = (methods[x][y][z].Get('pass')) ? 'pass' : 'fail';
content += '<li class="'+passfail+'"><a href="javascript:set_msg('+x+','+y+','+z+')">'+methods[x][y][z].Get('desc')+'</a></li>';
}
content += '</ul></li>';
}
content += '</ul></li>';
}
content += '</ul>';
xGetElementById('tree').innerHTML = content;
if (xGetElementById('treetab').className == 'activetab') {
activate_tab('tree');
} else {
activate_tab('fail');
}
}
function make_output(data) {
}
function make_fail_msg(id, msg) {
}
function max(n1, n2) {
if (n1 > n2) {
return n1;
} else {
return n2;
}
}
|