2 // Script to support JsReporter class
3 // Relies heavily on the X library in x.js
4 // X v3.14.1, Cross-Browser DHTML Library from Cross-Browser.com
5 // Copyright (c) 2004 Jason E. Sweat (jsweat_php@yahoo.com)
7 // SimpleTest - http://simpletest.sf.net/
8 // Copyright (c) 2003,2004 Marcus Baker (marcus@lastcraft.com)
17 methods
= new Array();
23 Set : function(foo
,bar
) {this[foo
] = bar
;},
24 Get : function(foo
) {return this[foo
];}
28 function wait_start() {
32 wait_x
= xWidth('wait');
33 wait_y
= xHeight('wait');
34 xMoveTo('wait', (xClientWidth()-wait_x
)/2, (xClientHeight()-wait_y)/2);
39 xResizeTo('webunit', max(xClientWidth()-30,min_x
), max(xClientHeight()-20,min_y
));
40 xMoveTo('webunit', 5, 5);
41 xResizeTo('tabs', xWidth('webunit')-10, xHeight('webunit')/3);
47 xZIndex('visible_tab', 2)
48 xResizeTo('msg', xWidth('webunit')-17, xHeight('webunit')/3-20);
50 xTop('msg',2*xHeight('webunit')/3);
54 function set_div_content(div
, content
) {
55 xGetElementById(div
).innerHTML
= content
;
58 function copy_div_content(divsrc
, divtrgt
) {
59 xGetElementById(divtrgt
).innerHTML
= xGetElementById(divsrc
).innerHTML
;
62 function activate_tab(tab
) {
64 copy_div_content('fail', 'visible_tab');
65 xGetElementById('failtab').className
= 'activetab';
67 xGetElementById('treetab').className
= 'inactivetab';
71 copy_div_content('tree', 'visible_tab');
72 xGetElementById('failtab').className
= 'inactivetab';
74 xGetElementById('treetab').className
= 'activetab';
79 function add_group(group_name
) {
83 Set : function(foo
,bar
) {this[foo
] = bar
;},
84 Get : function(foo
) {return this[foo
];}
86 add
.Set('desc', group_name
);
87 add
.Set('pass', true);
88 groups
[groups
.length
] = add
;
89 current_group
= groups
.length
- 1;
90 cases
[current_group
] = new Array();
91 methods
[current_group
] = new Array();
94 function add_case(case_name
) {
99 Set : function(foo
,bar
) {this[foo
] = bar
;},
100 Get : function(foo
) {return this[foo
];}
102 add
.Set('desc', case_name
);
103 add
.Set('pass', true);
104 curgroup
= cases
[current_group
];
105 cases
[current_group
][curgroup
.length
] = add
;
106 current_case
= curgroup
.length
- 1;
107 methods
[current_group
][current_case
] = new Array();
110 function add_method(method_name
) {
115 Set : function(foo
,bar
) {this[foo
] = bar
;},
116 Get : function(foo
) {return this[foo
];}
118 add
.Set('desc', method_name
);
119 add
.Set('pass', true);
121 curcase
= methods
[current_group
][current_case
];
122 methods
[current_group
][current_case
][curcase
.length
] = add
;
123 current_method
= curcase
.length
- 1;
126 function add_fail(msg
) {
129 groups
[current_group
].Set('pass', false);
130 cases
[current_group
][current_case
].Set('pass', false);
131 methods
[current_group
][current_case
][current_method
].Set('pass', false);
132 oldmsg
= methods
[current_group
][current_case
][current_method
].Get('msg');
133 methods
[current_group
][current_case
][current_method
].Set('msg', oldmsg
+msg
);
136 function add_log(msg
) {
138 faildiv
= xGetElementById('fail');
139 faildiv
.innerHTML
= faildiv
.innerHTML
+ msg
;
142 function set_msg(gid
, cid
, mid
) {
144 var msg
=methods
[gid
][cid
][mid
].Get('msg');
146 passfail
= (methods
[gid
][cid
][mid
].Get('pass')) ? 'pass' : 'fail';
147 msg
= 'No output for <span class="' + passfail
+ '">'
148 + groups
[gid
].Get('desc') + '->'
149 + cases
[gid
][cid
].Get('desc') + '->'
150 + methods
[gid
][cid
][mid
].Get('desc') + '</span><br />';
152 xGetElementById('msg').innerHTML
= msg
;
155 function make_tree() {
160 passfail
= (groups
[x
].Get('pass')) ? 'pass' : 'fail';
161 content
+= '<li class="'+passfail
+'">'+groups
[x
].Get('desc')+'<ul>';
162 for (y
in cases
[x
]) {
163 passfail
= (cases
[x
][y
].Get('pass')) ? 'pass' : 'fail';
164 content
+= '<li class="'+passfail
+'">'+cases
[x
][y
].Get('desc')+'<ul>';
165 for (z
in methods
[x
][y
]) {
166 passfail
= (methods
[x
][y
][z
].Get('pass')) ? 'pass' : 'fail';
167 content
+= '<li class="'+passfail
+'"><a href="javascript:set_msg('+x
+','+y
+','+z
+')">'+methods
[x
][y
][z
].Get('desc')+'</a></li>';
169 content
+= '</ul></li>';
171 content
+= '</ul></li>';
174 xGetElementById('tree').innerHTML
= content
;
175 if (xGetElementById('treetab').className
== 'activetab') {
176 activate_tab('tree');
178 activate_tab('fail');
182 function make_output(data
) {
185 function make_fail_msg(id
, msg
) {
188 function max(n1
, n2
) {