summaryrefslogtreecommitdiff
path: root/docs/TestSuite
blob: 789134a7d1c442efc43a4dd9ae4da8ca278666dc (plain)
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
Assertions
-------------------------------------------------------------------------------
fail
	assert(false);

assertTrue
assertFalse
	@actual is a variable name, of type boolean (or castable to boolean?)
	or evaluate nested condition to boolean

assertNull
assertNotNull
	@actual is a variable name
	or evaluate nested condition
	
assertEquals
assertNotEquals
	Test actual is equal (or not equal) to expected.
	
	<assertEquals actual="result" expected="expectedResult" ignoreCase="true/false/auto" context="attribute/element" bitmask="..."/>
	
	For Collections (or Lists), need to check neither list is null, then that both lists have the same size, then that all their elements are equal.
	
	@ignoreCase="auto"
		if contentType == "text/html":
			if context == "attribute", do case insensitive test
			if context == "element", do case sensitive test against expected.toUpperCase()
	@context used in combination with ignoreCase="auto"
	@bitmask used in DOM Level 3 only.  Tests: (actual & bitmask) equals (expectedResult & bitmask) where bitmask is an int

	Alternatively, can include nested statement (presumably as a substitute to @actual), but can't see this is used anywhere.

assertSame
	Tests two objects for identity.
	If not, call assertEquals()
	Don't really understand the point of this assert
	
(note about assertNull, assertNotNull, assertEquals, assertNotEquals, assertSame)
	Alternatively, can include nested statement (presumably as a substitute to @actual), but can't see this is used anywhere.

assertInstanceOf
	Used in [hc_]namednodemapreturnattrnode.xml
	Can use Node.getNodeType() to get runtime type

assertSize
	Tests a Java Collection has the specified size. 
	
	<assertSize size="2" collection="notifications"/>

assertEventCount
	(not used)
	
assertURIEquals
	Compare pieces of the URI in @actual

	@actual
	@scheme
	@path
	@host
	@file
	@name
	@query
	@fragment 
	@isAbsolute boolean

assertImplementationException
	DOM Level 2 Events dispatchEvent01.xml

assertDOMException
	Tests that a DOMException is thrown with a specified code.  Try/catching not nested.
	
	<assertDOMException id="setValue_throws_NO_MODIFICATION_ERR">
	    <NO_MODIFICATION_ALLOWED_ERR>
	        <removeChild obj="attrNode" oldChild="textNode" var="removedNode"/>
	    </NO_MODIFICATION_ALLOWED_ERR>
	</assertDOMException>
	
	boolean success = false;
	try {
    	removedNode = attrNode.removeChild(textNode);
    } catch (DOMException ex) {
    	success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR);
    }
    assertTrue(success);
    
assertLowerSeverity
	DOM Level 3 Core only

Conditions
-------------------------------------------------------------------------------
same
	(not used)

equals
notEquals
less

lessOrEquals
	(not used)
	
greater

greaterOrEquals
	(not used)
	
isNull
	(not used)

notNull
and
or

xor
	(not used)
	
not

instanceOf
	(not used)

isTrue
isFalse

hasSize
	(not used)
	
contentType

contains
	DOM Level 3 Core and LS only
	
hasFeature
	calls DOMImplementation.hasFeature()
	
	@feature quoted string e.g. "XML"
	@version quoted string e.g. "1.0"
	@value boolean
	@var variable to assign the result to
	@obj name of var holding the DOMImplementation
	
implementationAttribute
	pass param to the test suite's DOMTestDocumentBuilderFactory (e.g. validating)


Statements
-------------------------------------------------------------------------------
var
	Can contain nested <member> elements when the var has @type Collection
	
	Can contain <handleError> element when the var type @type DOMErrorHandler.
	This then creates an class implementing DOMErrorHandler, overriding the handleError() method.
	This is only used in DOM Level 3 Core.
	
	@name variable name
	@type type of variable
	@value initially assigned value
	@isNull boolean assign initial value of NULL (essentially mutually exclusive with @value ?)

assign
	<assign var="..." value="..."/>

increment
decrement
	<increment var="..." value="..."/>

append
	<append collection="..." item="..."/>
	Append an object to the end of a Collection.
	In Java, this is implemented with an ArrayList.

plus
subtract
mult
divide
load

if
while

try
	Fail if reach the end of the try without throwing an exception specified in <catch>
	<try>
		...
		<catch>
			<DOMException code="..."/>
			<DOMException code="..."/>
			...
		</catch>
	</try>
	
	No nesting in test cases, but sometimes more than one instance in a single test.

for-each
	<for-each collection="..." member="...">

comment
	Only used in DOM Level 3 XPath.

return
	Only used in DOM Level 2/3.  Returns immediately from method call with optional @value

userObj
	(not used)

atEvents
capturedEvents
bubbledEvents
allEvents
	DOM Level 2 Events only

createXPathEvaluator
	DOM Level 3 XPath only
	
getResourceURI
	DOM Level 3 LS only

substring
	<substringData var="..." obj="..." offset="..." count="..."/>
	Calls @obj.substringData() where obj is an instance of CharacterData

createTempURI
	DOMImplementationRegistry.newInstance

allErrors
	Only used in DOM Level 3
	Calls org.w3c.domts.DOMErrorMonitor.getAllErrors(), which is an instance of DOMErrorHandler

allNotifications
operation
key
dst
	DOM Level 3 Core only

Datatypes
-------------------------------------------------------------------------------
int
short
double
boolean
	Primitives

DOMString

List
	In Java, an ArrayList instance typed as a List

Collection
	In Java, an ArrayList instance typed as a Collection
	
	<var name="expectedResult" type="Collection">
		<member>"ent1"</member>
		<member>"ent2"</member>

EventMonitor
	DOM Level 2 Events only

DOMErrorMonitor
	DOM Level 3 only
	
UserDataMonitor
UserDataNotification
LSInputStream
	DOM Level 3 Core only


Attr
CDATASection
CharacterData
Comment
Document
DocumentFragment
DocumentType
DOMImplementation
Element
Entity
EntityReference
NamedNodeMap
Node
NodeList
Notation
ProcessingInstruction
Text
	DOM types
	
-------------------------------------------------------------------------------	
WHAT ABOUT RETURN VALUES?
for method calls and attribute getters (&result)

ASSERTIONS (other statements?)
[temp variables for assert params]
assertFoo(...)
for @expected, produce a var decl/ref
required-type is the type of @actual


CONDITIONS IN CONTROL STRUCTURES
[temp variables for condition params]
if (<condition>)
for every condition clause that requires it (e.g. <equals>), produce a var decl/ref
required-type is the type of @actual
	e.g. 
	<var name="myVar" type="DOMString"/>
	<equals actual="myVar" expected="&quot;beans&quot;"/>
	required-type is DOMString

METHOD CALL
[temp variables for method params]
[temp variable to hold method result]
getElementsByTagName(doc, param_a, param_b, param_c, &result)
[assign temp variable to real result var]

produce var decl/ref for each param: a, b, c
required-type is the method param's type in the domspec


ATTRIBUTE SET
[temp variables for setting attribute]
setFoo(node, param)

required-type is the attribute's type in the domspec


ATTRIBUTE GET
[temp variable to hold getter result]
getFoo(node, &result)
[assign temp variable to real result var]

call produce-var-reference in getFoo() call to generate &result
call produce-var-assignment after getFoo() to convert the temp result into the desired result 


PSEUDO TEMPLATES
template name="produce-var-declaration"
param name="var-or-literal"
param name="required-type"
if (needs temp variable)
	declare and assign new temporary variable $var_x$		
/if

template name="produce-var-reference"
choose
	when (needs temp variable)
		print temporary variable $var_x$ using generate-id()
	when (needs cast)
		call-template name="cast"
	otherwise
		$var-or-literal
/choose

template name="produce-var-assignment"
if (needs temp variable)
	$var-or-literal = conversion_function($var_x$);
/if