--- a/RegressionTests__ImageReaderTest.st Fri Oct 13 14:07:04 2017 +0200
+++ b/RegressionTests__ImageReaderTest.st Fri Oct 13 15:02:08 2017 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"{ Package: 'stx:goodies/regression' }"
"{ NameSpace: RegressionTests }"
@@ -27,12 +29,31 @@
"
! !
+!ImageReaderTest methodsFor:'misc'!
+
+packageDirectory
+ |packageDirectory pathOfSTXExecutable|
+
+ packageDirectory := self class packageDirectory.
+ packageDirectory notNil ifTrue:[
+ ^ packageDirectory
+ ].
+
+ pathOfSTXExecutable := OperatingSystem pathOfSTXExecutable.
+ (pathOfSTXExecutable includesSubString:'quickSelfTest') ifTrue:[
+ "started from stx/goodies/builder/quickSelfTest"
+ ^ pathOfSTXExecutable asFilename directory directory directory / 'regression'
+ ].
+
+ self error:'no package path'.
+! !
+
!ImageReaderTest methodsFor:'tests'!
test001_bmp
|img|
- img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test1.bmp').
+ img := Image fromFile:(self packageDirectory construct:'testData/bmpImages/test1.bmp').
self assert:(img notNil).
self assert:(img depth == 1).
@@ -50,7 +71,7 @@
test002_bmp
|img|
- img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test4.bmp').
+ img := Image fromFile:(self packageDirectory construct:'testData/bmpImages/test4.bmp').
self assert:(img notNil).
self assert:(img depth == 4).
@@ -70,7 +91,7 @@
test003_bmp
|img|
- img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test8.bmp').
+ img := Image fromFile:(self packageDirectory construct:'testData/bmpImages/test8.bmp').
self assert:(img notNil).
self assert:(img depth == 8).
self assert:((img colorAtX:30 y:0) rgbValue = 16rFF0000).
@@ -84,7 +105,7 @@
test004_bmp
|img|
- img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/testcompress4.bmp').
+ img := Image fromFile:(self packageDirectory construct:'testData/bmpImages/testcompress4.bmp').
self assert:(img notNil).
self assert:(img depth == 4).
self assert:((img colorAtX:0 y:15) rgbValue = 16rFF0000).
@@ -103,7 +124,7 @@
test005_bmp
|img|
- img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/testcompress8.bmp').
+ img := Image fromFile:(self packageDirectory construct:'testData/bmpImages/testcompress8.bmp').
self assert:(img notNil).
self assert:(img depth == 8).
self assert:((img colorAtX:30 y:0) rgbValue = 16rFF0000).
@@ -117,7 +138,7 @@
test006_bmp
|img|
- img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test8os2.bmp').
+ img := Image fromFile:(self packageDirectory construct:'testData/bmpImages/test8os2.bmp').
self assert:(img notNil).
"/ img inspect.
@@ -129,7 +150,7 @@
test007_bmp
|img|
- img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test4os2v2.bmp').
+ img := Image fromFile:(self packageDirectory construct:'testData/bmpImages/test4os2v2.bmp').
self assert:(img notNil).
"/ img inspect.
@@ -141,7 +162,7 @@
test008_bmp
|img|
- img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test16.bmp').
+ img := Image fromFile:(self packageDirectory construct:'testData/bmpImages/test16.bmp').
self assert:(img notNil).
"/ img inspect.
@@ -153,7 +174,7 @@
test009_bmp
|img|
- img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test24.bmp').
+ img := Image fromFile:(self packageDirectory construct:'testData/bmpImages/test24.bmp').
self assert:(img notNil).
"/ img inspect.
@@ -165,7 +186,7 @@
test010_bmp
|img|
- img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test32.bmp').
+ img := Image fromFile:(self packageDirectory construct:'testData/bmpImages/test32.bmp').
self assert:(img notNil).
"/ img inspect.
@@ -220,7 +241,7 @@
testPNG_001_basn0g01
|img|
- img := Image fromFile:(self class packageDirectory construct:'testData/pngImages/basn0g01.png').
+ img := Image fromFile:(self packageDirectory construct:'testData/pngImages/basn0g01.png').
self assert:(img notNil).
self assert:(img depth == 1).
self assert:(img extent = (32@32)).
@@ -239,7 +260,7 @@
testPNG_002_basn0g02
|img|
- img := Image fromFile:(self class packageDirectory construct:'testData/pngImages/basn0g02.png').
+ img := Image fromFile:(self packageDirectory construct:'testData/pngImages/basn0g02.png').
self assert:(img notNil).
self assert:(img depth == 2).
self assert:(img extent = (32@32)).
@@ -258,7 +279,7 @@
testPNG_003_basi0g01
|img|
- img := Image fromFile:(self class packageDirectory construct:'testData/pngImages/basi0g01.png').
+ img := Image fromFile:(self packageDirectory construct:'testData/pngImages/basi0g01.png').
self assert:(img notNil).
self assert:(img depth == 1).
self assert:(img extent = (32@32)).
@@ -279,7 +300,7 @@
|img|
- img := Image fromFile:(self class packageDirectory construct:'testData/pngImages/tbbn0g04.png').
+ img := Image fromFile:(self packageDirectory construct:'testData/pngImages/tbbn0g04.png').
self assert:(img notNil).
self assert:(img depth == 4).
self assert:(img extent = (32@32)).
@@ -298,7 +319,7 @@
testPNG_004_tbbn3p03
|img|
- img := Image fromFile:(self class packageDirectory construct:'testData/pngImages/tbbn0g04.png').
+ img := Image fromFile:(self packageDirectory construct:'testData/pngImages/tbbn0g04.png').
self assert:(img notNil).
self assert:(img depth == 4).
self assert:(img extent = (32@32)).
@@ -319,7 +340,7 @@
|img|
- img := Image fromFile:(self class packageDirectory construct:'testData/pngImages/tbbn3p08.png').
+ img := Image fromFile:(self packageDirectory construct:'testData/pngImages/tbbn3p08.png').
self assert:(img notNil).
self assert:(img depth == 8).
self assert:(img extent = (32@32)).
@@ -340,19 +361,19 @@
failed := OrderedCollection new.
allOK := true.
- (self class packageDirectory construct:'testData/bmpImages') directoryContentsAsFilenamesDo:[:f |
- (f isRegularFile and:[f hasSuffix:'bmp']) ifTrue:[
- Error handle:[:ex |
- img := nil.
- ] do:[
- img := Image fromFile:f.
- ].
- img isNil ifTrue:[
- Transcript printf:'failed: %s\n' with:f baseName.
- allOK := false.
- failed add:f baseName.
- ].
- ].
+ (self packageDirectory construct:'testData/bmpImages') directoryContentsAsFilenamesDo:[:f |
+ (f isRegularFile and:[f hasSuffix:'bmp']) ifTrue:[
+ Error handle:[:ex |
+ img := nil.
+ ] do:[
+ img := Image fromFile:f.
+ ].
+ img isNil ifTrue:[
+ Transcript printf:'failed: %s\n' with:f baseName.
+ allOK := false.
+ failed add:f baseName.
+ ].
+ ].
].
self assert:allOK description:('failed to read: %s' printfWith:(failed asStringWith:', ')).
@@ -367,19 +388,19 @@
failed := OrderedCollection new.
allOK := true.
- (self class packageDirectory construct:'testData/bmpImages/bmpsuite-2.4') directoryContentsAsFilenamesDo:[:f |
- (f isRegularFile and:[f hasSuffix:'bmp']) ifTrue:[
- Error handle:[:ex |
- img := nil.
- ] do:[
- img := Image fromFile:f.
- ].
- img isNil ifTrue:[
- Transcript printf:'failed: %s\n' with:f baseName.
- allOK := false.
- failed add:f baseName.
- ].
- ].
+ (self packageDirectory construct:'testData/bmpImages/bmpsuite-2.4') directoryContentsAsFilenamesDo:[:f |
+ (f isRegularFile and:[f hasSuffix:'bmp']) ifTrue:[
+ Error handle:[:ex |
+ img := nil.
+ ] do:[
+ img := Image fromFile:f.
+ ].
+ img isNil ifTrue:[
+ Transcript printf:'failed: %s\n' with:f baseName.
+ allOK := false.
+ failed add:f baseName.
+ ].
+ ].
].
self assert:allOK description:('failed to read: %s' printfWith:(failed asStringWith:', ')).
@@ -397,7 +418,7 @@
failed := OrderedCollection new.
allOK := true.
- (self class packageDirectory construct:'testData/pngImages') directoryContentsAsFilenamesDo:[:f |
+ (self packageDirectory construct:'testData/pngImages') directoryContentsAsFilenamesDo:[:f |
(f isRegularFile and:[f hasSuffix:'png']) ifTrue:[
img := nil.
(f baseName startsWith:'x') ifTrue:[
@@ -436,18 +457,18 @@
test_png_02
|referenceImg img|
- img := Image fromFile:(self class packageDirectory construct:'testData/pngImages/basn0g01.png').
+ img := Image fromFile:(self packageDirectory construct:'testData/pngImages/basn0g01.png').
self assert:(img notNil).
referenceImg := (Depth1Image new) width: 32; height: 32;
- photometric:(#palette);
- bitsPerSample:(#[1]);
- samplesPerPixel:(1);
- bits:(ByteArray fromPackedString:'
+ photometric:(#palette);
+ bitsPerSample:(#[1]);
+ samplesPerPixel:(1);
+ bits:(ByteArray fromPackedString:'
?????/????3????8????<OO3?>C3<??@<?O? OL3?0C3L?8@<3O<@O G>@C8A?@@?L? @O3O0@C??8@@??<@@O?>@@C??@@@?? O8O?0C>C?8@00?<@LLO>@
C>C?@@? ? @LLO0@CCC8@@? <@@O8N@@@@C@@@@@ @@@@@@@@@@b') ;
- colorMapFromArray:#[0 0 0 255 255 255];
- yourself.
+ colorMapFromArray:#[0 0 0 255 255 255];
+ yourself.
self assert:(img bits = referenceImg bits).
self assert:(img width = referenceImg width).