[wip] draw_images(): w, h, spos -> box screen_img; img_box -> pixel_box
[elinks/images.git] / src / dom / test / test-dom-configuration-basic
blobdd118f406264737f09dd0d91218eff7e9698fa61
1 #!/bin/sh
3 # Copyright (c) 2005 Jonas Fonseca
6 test_description='Test the DOM configuration module
8 This test checks that the normalization performed by the DOM configuration
9 is done correctly.
12 . "$TEST_LIB"
14 test_normalize_output_equals () {
15 desc="$1"; shift
16 config="$1"; shift
17 src="$1"; shift
18 out="$1"; shift
20 URI="test:$(normalize "$desc")"
22 sgml-parser --src "$src" --normalize "$config" --uri "$URI" --src "$src" > output
23 echo "#document: $URI" > expected
24 echo "$out" | sed -n '2,$p' | sed 's/^/ /' >> expected
26 test_expect_success "$desc" 'cmp output expected'
30 ## Config strings ###########################################################
32 NOOP='cdata-sections,comments,element-content-whitespace,entities'
33 NOCOMMENTS='cdata-sections,element-content-whitespace,entities'
34 CDATA2TEXT='comments,element-content-whitespace,entities'
35 ENTITIES='cdata-section,comments,element-content-whitespace'
36 NOWSTEXT='cdata-section,comments,entities'
37 NORM1=''
40 ## No-ops ###################################################################
42 test_normalize_output_equals \
43 'Normalization no-op.' \
44 "$NOOP" \
45 '<roswell> <![CDATA[| that |]]><!-- ends --> well</roswell>' \
47 element: roswell
48 #text:
49 #cdata-section: | that |
50 #comment: ends
51 #text: well'
53 test_normalize_output_equals \
54 'Keep comments.' \
55 "$NOOP" \
56 'and<!-- comment:1 -->or<!-- comment:2 -->' \
58 #text: and
59 #comment: comment:1
60 #text: or
61 #comment: comment:2 '
63 test_normalize_output_equals \
64 'Keep CDATA sections ' \
65 "$NOOP" \
66 '<![CDATA[and]]>or<![CDATA[maybe]]>' \
68 #cdata-section: and
69 #text: or
70 #cdata-section: maybe'
73 ## Comments #################################################################
75 test_normalize_output_equals \
76 'Remove comments. (I)' \
77 "$NOCOMMENTS" \
78 "<no><!-- comment -->?</no>" \
80 element: no
81 #text: ?'
83 test_normalize_output_equals \
84 'Remove comments. (II)' \
85 "$NOCOMMENTS" \
86 '<!-- comment:1 -->and<!-- comment:2 -->' \
88 #text: and'
90 test_normalize_output_equals \
91 'Remove comments. (III)' \
92 "$NOCOMMENTS" \
93 'nothing to see <!-- comment -->here' \
95 #text: nothing to see here'
98 ## Entities #################################################################
100 # Entities should be shown 'verbatim' here after expansion.
102 test_normalize_output_equals \
103 'Expand entities. (I)' \
104 "$ENTITIES" \
105 'a&lt;b&gt;c' \
107 #text: a&lt;b&gt;c'
109 test_normalize_output_equals \
110 'Expand entities. (II)' \
111 "$ENTITIES" \
112 '&bad-entity&good-entity;' \
114 #text: &bad-entity;&good-entity;'
116 test_normalize_output_equals \
117 'Expand entities. (III)' \
118 "$ENTITIES" \
119 '<a>&b;</a>' \
121 element: a
122 #text: &b;'
125 ## CDATA Sections ###########################################################
127 test_normalize_output_equals \
128 'Replace CDATA section with text. (I)' \
129 "$CDATA2TEXT" \
130 '<![CDATA[a small text snippet]]>' \
132 #text: a small text snippet'
134 test_normalize_output_equals \
135 'Replace CDATA section with text. (II)' \
136 "$CDATA2TEXT" \
137 '<![CDATA[a small]]> <![CDATA[text snippet]]>' \
139 #text: a small text snippet'
141 test_normalize_output_equals \
142 'Replace CDATA section with text. (III)' \
143 "$CDATA2TEXT" \
144 'before <![CDATA[and]]> after' \
146 #text: before and after'
149 ## Element Content Whitespace ###############################################
151 test_normalize_output_equals \
152 'Remove element content whitespace. (I)' \
153 "$NOWSTEXT" \
154 '<a>
155 <b>some text</b>
156 </a>' \
158 element: a
159 element: b
160 #text: some text' \
162 # I haven't read the specs about this thing, for now it just blasts all
163 # space-only text nodes. Probably not the wanted behaviour all of the time.
164 # --jonas
165 test_normalize_output_equals \
166 'Remove element content whitespace. (II)' \
167 "$NOWSTEXT" \
168 '<e>space between &this; &that; gets removed</e>' \
170 element: e
171 #text: space between
172 entity-reference: this
173 entity-reference: that
174 #text: gets removed'
177 ## Mixes ####################################################################
179 test_normalize_output_equals \
180 'Normalization mix #1. (I)' \
181 "$NORM1" \
182 'before <![CDATA[and]]> after &some;<!--comments--> remain' \
184 #text: before and after &some; remain'
186 test_normalize_output_equals \
187 'Normalization mix #1. (II)' \
188 "$NORM1" \
189 '<!--a-->b&c; <![CDATA[d]]>' \
191 #text: b&c;d'
194 ## Special ELinks Extensions ################################################
196 test_normalize_output_equals \
197 'Remove unknown (HTML) elements and attributes. (I)' \
198 "$NOOP,unknown" \
199 '<html wack="..."><title w00t="...">where?<doit>here!</doit></title></html>' \
201 element: html
202 element: title
203 #text: where?' \
205 test_normalize_output_equals \
206 'Remove unknown (HTML) elements and attributes. (II)' \
207 "$NOOP,unknown" \
208 '<x y=""><z></z></x> aint no HTML' \
210 #text: aint no HTML' \
212 test_normalize_output_equals \
213 'Normalize whitespace. (I)' \
214 "$NOOP,normalize-whitespace" \
215 'Here is a
219 lot of useless space.' \
221 #text: Here is a lot of useless space.' \
223 test_normalize_output_equals \
224 'Normalize whitespace. (II)' \
225 "$CDATA2TEXT,normalize-whitespace" \
226 'Could we <![CDATA[ please ]]> read that again?' \
228 #text: Could we please read that again?' \
230 test_done