1341
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
356
|
3 |
"{ Package: 'exept:regression' }"
|
|
4 |
|
|
5 |
"{ NameSpace: RegressionTests }"
|
|
6 |
|
|
7 |
TestCase subclass:#ImageReaderTest
|
|
8 |
instanceVariableNames:''
|
|
9 |
classVariableNames:''
|
|
10 |
poolDictionaries:''
|
|
11 |
category:'tests-Regression'
|
|
12 |
!
|
|
13 |
|
|
14 |
!ImageReaderTest class methodsFor:'documentation'!
|
|
15 |
|
|
16 |
documentation
|
|
17 |
"
|
|
18 |
documentation to be added.
|
|
19 |
|
|
20 |
[author:]
|
|
21 |
cg (cg@AQUA-DUO)
|
|
22 |
|
|
23 |
[instance variables:]
|
|
24 |
|
|
25 |
[class variables:]
|
|
26 |
|
|
27 |
[see also:]
|
|
28 |
|
|
29 |
"
|
|
30 |
! !
|
|
31 |
|
|
32 |
!ImageReaderTest methodsFor:'tests'!
|
|
33 |
|
1326
|
34 |
test001_bmp
|
356
|
35 |
|img|
|
|
36 |
|
1326
|
37 |
img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test1.bmp').
|
357
|
38 |
self assert:(img notNil).
|
1326
|
39 |
self assert:(img depth == 1).
|
526
|
40 |
|
357
|
41 |
"/ img inspect.
|
526
|
42 |
|
357
|
43 |
self assert:((img colorAtX:0 y:0) rgbValue = 16r4040FF).
|
|
44 |
self assert:((img colorAtX:0 y:63) rgbValue = 16r4040FF).
|
|
45 |
self assert:((img colorAtX:0 y:18) rgbValue = 16r40FF40).
|
356
|
46 |
|
|
47 |
"
|
1326
|
48 |
self run:#test001_bmp
|
|
49 |
self new test001_bmp"
|
357
|
50 |
!
|
|
51 |
|
1326
|
52 |
test002_bmp
|
357
|
53 |
|img|
|
|
54 |
|
1326
|
55 |
img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test4.bmp').
|
357
|
56 |
self assert:(img notNil).
|
1326
|
57 |
self assert:(img depth == 4).
|
|
58 |
|
|
59 |
self assert:((img colorAtX:0 y:15) rgbValue = 16rFF0000).
|
|
60 |
self assert:((img colorAtX:35 y:15) rgbValue = 16r004000).
|
|
61 |
self assert:((img colorAtX:35 y:30) rgbValue = 16r008000).
|
|
62 |
self assert:((img colorAtX:35 y:45) rgbValue = 16r00C000).
|
|
63 |
self assert:((img colorAtX:35 y:60) rgbValue = 16r00FF00).
|
|
64 |
self assert:((img colorAtX:70 y:15) rgbValue = 16r0000FF).
|
526
|
65 |
|
357
|
66 |
"/ img inspect.
|
|
67 |
"
|
1326
|
68 |
self run:#test002_bmp
|
|
69 |
self new test002_bmp"
|
357
|
70 |
!
|
|
71 |
|
1326
|
72 |
test003_bmp
|
357
|
73 |
|img|
|
|
74 |
|
1326
|
75 |
img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test8.bmp').
|
357
|
76 |
self assert:(img notNil).
|
1326
|
77 |
self assert:(img depth == 8).
|
|
78 |
self assert:((img colorAtX:30 y:0) rgbValue = 16rFF0000).
|
526
|
79 |
|
357
|
80 |
"/ img inspect
|
|
81 |
"
|
1326
|
82 |
self run:#test003_bmp
|
|
83 |
self new test003_bmp"
|
357
|
84 |
!
|
|
85 |
|
1326
|
86 |
test004_bmp
|
357
|
87 |
|img|
|
|
88 |
|
1326
|
89 |
img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/testcompress4.bmp').
|
357
|
90 |
self assert:(img notNil).
|
1326
|
91 |
self assert:(img depth == 4).
|
|
92 |
self assert:((img colorAtX:0 y:15) rgbValue = 16rFF0000).
|
|
93 |
self assert:((img colorAtX:35 y:15) rgbValue = 16r004000).
|
|
94 |
self assert:((img colorAtX:35 y:30) rgbValue = 16r008000).
|
|
95 |
self assert:((img colorAtX:35 y:45) rgbValue = 16r00C000).
|
|
96 |
self assert:((img colorAtX:35 y:60) rgbValue = 16r00FF00).
|
|
97 |
self assert:((img colorAtX:70 y:15) rgbValue = 16r0000FF).
|
526
|
98 |
|
357
|
99 |
"/ img inspect.
|
|
100 |
"
|
1326
|
101 |
self run:#test004_bmp
|
|
102 |
self new test004_bmp"
|
357
|
103 |
!
|
|
104 |
|
1326
|
105 |
test005_bmp
|
357
|
106 |
|img|
|
|
107 |
|
1326
|
108 |
img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/testcompress8.bmp').
|
|
109 |
self assert:(img notNil).
|
|
110 |
self assert:(img depth == 8).
|
|
111 |
self assert:((img colorAtX:30 y:0) rgbValue = 16rFF0000).
|
|
112 |
|
|
113 |
"/ img inspect.
|
|
114 |
"
|
|
115 |
self run:#test005_bmp
|
|
116 |
self new test005_bmp"
|
|
117 |
!
|
|
118 |
|
|
119 |
test006_bmp
|
|
120 |
|img|
|
|
121 |
|
|
122 |
img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test8os2.bmp').
|
357
|
123 |
self assert:(img notNil).
|
526
|
124 |
|
357
|
125 |
"/ img inspect.
|
|
126 |
"
|
1326
|
127 |
self run:#test006_bmp
|
|
128 |
self new test006_bmp"
|
357
|
129 |
!
|
|
130 |
|
1326
|
131 |
test007_bmp
|
526
|
132 |
|img|
|
|
133 |
|
1326
|
134 |
img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test4os2v2.bmp').
|
526
|
135 |
self assert:(img notNil).
|
|
136 |
|
|
137 |
"/ img inspect.
|
|
138 |
"
|
1326
|
139 |
self run:#test007_bmp
|
|
140 |
self new test007_bmp"
|
526
|
141 |
!
|
|
142 |
|
1326
|
143 |
test008_bmp
|
357
|
144 |
|img|
|
|
145 |
|
1326
|
146 |
img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test16.bmp').
|
357
|
147 |
self assert:(img notNil).
|
|
148 |
|
526
|
149 |
"/ img inspect.
|
357
|
150 |
"
|
1326
|
151 |
self run:#test008_bmp
|
|
152 |
self new test008_bmp"
|
357
|
153 |
!
|
|
154 |
|
1326
|
155 |
test009_bmp
|
357
|
156 |
|img|
|
|
157 |
|
1326
|
158 |
img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test24.bmp').
|
357
|
159 |
self assert:(img notNil).
|
|
160 |
|
526
|
161 |
"/ img inspect.
|
357
|
162 |
"
|
1326
|
163 |
self run:#test009_bmp
|
|
164 |
self new test009_bmp"
|
357
|
165 |
!
|
|
166 |
|
1326
|
167 |
test010_bmp
|
526
|
168 |
|img|
|
|
169 |
|
1326
|
170 |
img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test32.bmp').
|
526
|
171 |
self assert:(img notNil).
|
|
172 |
|
|
173 |
"/ img inspect.
|
|
174 |
"
|
1326
|
175 |
self run:#test010_bmp
|
|
176 |
self new test010_bmp"
|
357
|
177 |
!
|
|
178 |
|
526
|
179 |
test101
|
|
180 |
|alpha s bits img|
|
|
181 |
|
|
182 |
img := Depth32Image width:16 height:16.
|
|
183 |
alpha := #[
|
|
184 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
185 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
186 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
187 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
188 |
|
|
189 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
190 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
191 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
192 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
357
|
193 |
|
526
|
194 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
195 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
196 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
197 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
198 |
|
|
199 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
200 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
201 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
202 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
203 |
].
|
|
204 |
s := WriteStream on:#[].
|
|
205 |
alpha do:[:a |
|
|
206 |
s nextPut:127. "/ r
|
|
207 |
s nextPut:127. "/ g
|
|
208 |
s nextPut:127. "/ b
|
|
209 |
s nextPut:a.
|
|
210 |
].
|
|
211 |
|
|
212 |
bits := (s contents).
|
|
213 |
img bits:bits.
|
699
|
214 |
"/ img inspect.
|
357
|
215 |
|
|
216 |
"
|
526
|
217 |
self run:#test101
|
|
218 |
self new test101
|
357
|
219 |
"
|
382
|
220 |
!
|
|
221 |
|
576
|
222 |
testPNG_001_basn0g01
|
|
223 |
|img|
|
|
224 |
|
|
225 |
img := Image fromFile:(self class packageDirectory construct:'testData/pngImages/basn0g01.png').
|
|
226 |
self assert:(img notNil).
|
|
227 |
self assert:(img depth == 1).
|
|
228 |
self assert:(img extent = (32@32)).
|
|
229 |
self assert:(img colorAt:(0@0)) = Color white.
|
|
230 |
self assert:(img colorAt:(31@31)) = Color black.
|
|
231 |
|
|
232 |
"/ img inspect.
|
|
233 |
"
|
|
234 |
self run:#testPNG_001_basn0g01
|
|
235 |
self new testPNG_001_basn0g01
|
|
236 |
"
|
|
237 |
|
|
238 |
"Created: / 05-02-2011 / 10:32:32 / cg"
|
|
239 |
!
|
|
240 |
|
|
241 |
testPNG_002_basn0g02
|
|
242 |
|img|
|
|
243 |
|
|
244 |
img := Image fromFile:(self class packageDirectory construct:'testData/pngImages/basn0g02.png').
|
|
245 |
self assert:(img notNil).
|
|
246 |
self assert:(img depth == 2).
|
|
247 |
self assert:(img extent = (32@32)).
|
1326
|
248 |
self assert:(img colorAt:(0@0)) rgbValue = 0.
|
|
249 |
self assert:(img colorAt:(31@31)) rgbValue = 16rAAAAAA.
|
576
|
250 |
|
|
251 |
"/ img inspect.
|
|
252 |
"
|
|
253 |
self run:#testPNG_002_basn0g02
|
|
254 |
self new testPNG_002_basn0g02
|
|
255 |
"
|
|
256 |
|
|
257 |
"Created: / 05-02-2011 / 10:33:24 / cg"
|
|
258 |
!
|
|
259 |
|
1339
|
260 |
testPNG_003_basi0g01
|
|
261 |
|img|
|
|
262 |
|
|
263 |
img := Image fromFile:(self class packageDirectory construct:'testData/pngImages/basi0g01.png').
|
|
264 |
self assert:(img notNil).
|
|
265 |
self assert:(img depth == 1).
|
|
266 |
self assert:(img extent = (32@32)).
|
|
267 |
self assert:(img colorAt:(0@0)) = Color white.
|
|
268 |
self assert:(img colorAt:(31@31)) = Color black.
|
1340
|
269 |
"/ img inspect.
|
1339
|
270 |
|
|
271 |
"
|
|
272 |
self run:#testPNG_003_basi0g01
|
|
273 |
self new testPNG_003_basi0g01
|
|
274 |
"
|
|
275 |
|
|
276 |
"Created: / 05-02-2011 / 10:32:32 / cg"
|
|
277 |
!
|
|
278 |
|
1326
|
279 |
test_bmp_01
|
1340
|
280 |
|img allOK failed|
|
1326
|
281 |
|
1340
|
282 |
failed := OrderedCollection new.
|
1326
|
283 |
allOK := true.
|
|
284 |
(self class packageDirectory construct:'testData/bmpImages') directoryContentsAsFilenamesDo:[:f |
|
1334
|
285 |
(f isRegularFile and:[f hasSuffix:'bmp']) ifTrue:[
|
1326
|
286 |
Error handle:[:ex |
|
|
287 |
img := nil.
|
|
288 |
] do:[
|
|
289 |
img := Image fromFile:f.
|
|
290 |
].
|
1334
|
291 |
img isNil ifTrue:[
|
|
292 |
Transcript printf:'failed: %s\n' with:f baseName.
|
1340
|
293 |
allOK := false.
|
|
294 |
failed add:f baseName.
|
1334
|
295 |
].
|
1326
|
296 |
].
|
|
297 |
].
|
1340
|
298 |
self assert:allOK description:('failed to read: %s' printfWith:(failed asStringWith:', ')).
|
1326
|
299 |
|
|
300 |
"
|
|
301 |
self run:#test_bmp_01
|
|
302 |
self new test_bmp_01
|
|
303 |
"
|
|
304 |
!
|
|
305 |
|
1338
|
306 |
test_bmp_02
|
1340
|
307 |
|img allOK failed|
|
1338
|
308 |
|
1340
|
309 |
failed := OrderedCollection new.
|
1338
|
310 |
allOK := true.
|
|
311 |
(self class packageDirectory construct:'testData/bmpImages/bmpsuite-2.4') directoryContentsAsFilenamesDo:[:f |
|
|
312 |
(f isRegularFile and:[f hasSuffix:'bmp']) ifTrue:[
|
|
313 |
Error handle:[:ex |
|
|
314 |
img := nil.
|
|
315 |
] do:[
|
|
316 |
img := Image fromFile:f.
|
|
317 |
].
|
|
318 |
img isNil ifTrue:[
|
|
319 |
Transcript printf:'failed: %s\n' with:f baseName.
|
1340
|
320 |
allOK := false.
|
|
321 |
failed add:f baseName.
|
1338
|
322 |
].
|
|
323 |
].
|
|
324 |
].
|
1340
|
325 |
self assert:allOK description:('failed to read: %s' printfWith:(failed asStringWith:', ')).
|
1338
|
326 |
|
|
327 |
"
|
|
328 |
self run:#test_bmp_02
|
|
329 |
self new test_bmp_02
|
|
330 |
"
|
|
331 |
!
|
|
332 |
|
382
|
333 |
test_png_01
|
1341
|
334 |
"/ currently, 4 files fail;
|
|
335 |
"/ these are greyscale+alpha images
|
|
336 |
|
1340
|
337 |
|img allOK failed|
|
382
|
338 |
|
1340
|
339 |
failed := OrderedCollection new.
|
1326
|
340 |
allOK := true.
|
382
|
341 |
(self class packageDirectory construct:'testData/pngImages') directoryContentsAsFilenamesDo:[:f |
|
1334
|
342 |
(f isRegularFile and:[f hasSuffix:'png']) ifTrue:[
|
1340
|
343 |
img := nil.
|
|
344 |
(f baseName startsWith:'x') ifTrue:[
|
|
345 |
"/ should fail
|
|
346 |
self should:[ img := Image fromFile:f ] raise:(Image badImageFormatQuerySignal).
|
|
347 |
self assert:img == nil.
|
|
348 |
] ifFalse:[
|
|
349 |
Error handle:[:ex |
|
|
350 |
img := nil.
|
|
351 |
] do:[
|
|
352 |
img := Image fromFile:f.
|
|
353 |
].
|
|
354 |
img isNil ifTrue:[
|
|
355 |
Transcript printf:'failed: %s\n' with:f baseName.
|
|
356 |
allOK := false.
|
|
357 |
failed add:f baseName.
|
|
358 |
].
|
1334
|
359 |
].
|
1326
|
360 |
].
|
382
|
361 |
].
|
1340
|
362 |
self assert:allOK description:('failed to read: %s' printfWith:(failed asStringWith:', ')).
|
382
|
363 |
|
|
364 |
"
|
|
365 |
self run:#test_png_01
|
|
366 |
self new test_png_01
|
|
367 |
"
|
1341
|
368 |
|
|
369 |
"Modified (comment): / 08-03-2016 / 18:21:01 / cg"
|
382
|
370 |
!
|
|
371 |
|
|
372 |
test_png_02
|
|
373 |
|referenceImg img|
|
|
374 |
|
|
375 |
img := Image fromFile:(self class packageDirectory construct:'testData/pngImages/basn0g01.png').
|
|
376 |
self assert:(img notNil).
|
|
377 |
|
|
378 |
referenceImg := (Depth1Image new) width: 32; height: 32;
|
|
379 |
photometric:(#palette);
|
|
380 |
bitsPerSample:(#[1]);
|
|
381 |
samplesPerPixel:(1);
|
|
382 |
bits:(ByteArray fromPackedString:'
|
|
383 |
?????/????3????8????<OO3?>C3<??@<?O? OL3?0C3L?8@<3O<@O G>@C8A?@@?L? @O3O0@C??8@@??<@@O?>@@C??@@@?? O8O?0C>C?8@00?<@LLO>@
|
|
384 |
C>C?@@? ? @LLO0@CCC8@@? <@@O8N@@@@C@@@@@ @@@@@@@@@@b') ;
|
|
385 |
colorMapFromArray:#[0 0 0 255 255 255];
|
|
386 |
yourself.
|
|
387 |
|
1340
|
388 |
self assert:(img bits = referenceImg bits).
|
|
389 |
self assert:(img width = referenceImg width).
|
|
390 |
self assert:(img height = referenceImg height).
|
|
391 |
self assert:(img depth = referenceImg depth).
|
|
392 |
self assert:(img bitsPerSample asArray = referenceImg bitsPerSample asArray).
|
|
393 |
self assert:(img samplesPerPixel = referenceImg samplesPerPixel).
|
|
394 |
self assert:(img colorFromValue:0) = (referenceImg colorFromValue:0).
|
|
395 |
self assert:(img colorFromValue:1) = (referenceImg colorFromValue:1).
|
382
|
396 |
|
|
397 |
"
|
|
398 |
self run:#test_png_02
|
|
399 |
self new test_png_02
|
|
400 |
"
|
356
|
401 |
! !
|
|
402 |
|
|
403 |
!ImageReaderTest class methodsFor:'documentation'!
|
|
404 |
|
|
405 |
version
|
|
406 |
^ '$Header$'
|
576
|
407 |
!
|
|
408 |
|
|
409 |
version_CVS
|
|
410 |
^ '$Header$'
|
356
|
411 |
! !
|
1326
|
412 |
|