RegressionTests__ImageReaderTest.st
author Claus Gittinger <cg@exept.de>
Thu, 25 Oct 2012 15:17:11 +0200
changeset 699 3316cd60b7c2
parent 576 0cbc67ca4ab3
child 1326 3497aa4bf680
child 1484 e5af485c693d
permissions -rw-r--r--
changed: #test101

"{ Package: 'exept:regression' }"

"{ NameSpace: RegressionTests }"

TestCase subclass:#ImageReaderTest
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'tests-Regression'
!

!ImageReaderTest class methodsFor:'documentation'!

documentation
"
    documentation to be added.

    [author:]
        cg (cg@AQUA-DUO)

    [instance variables:]

    [class variables:]

    [see also:]

"
! !

!ImageReaderTest methodsFor:'tests'!

test001
    |img|

    img := Image 
                fromFile:(self class packageDirectory construct:'testData/test1.bmp').
    self assert:(img notNil).
    
    "/ img inspect.
    
    self assert:((img colorAtX:0 y:0) rgbValue = 16r4040FF).
    self assert:((img colorAtX:0 y:63) rgbValue = 16r4040FF).
    self assert:((img colorAtX:0 y:18) rgbValue = 16r40FF40).

    "
     self run:#test01
     self new test01"
!

test002
    |img|

    img := Image 
                fromFile:(self class packageDirectory construct:'testData/test4.bmp').
    self assert:(img notNil).

    "/ img inspect.
    "
     self run:#test02
     self new test02"
!

test003
    |img|

    img := Image 
                fromFile:(self class packageDirectory construct:'testData/test8.bmp').
    self assert:(img notNil).

    "/ img inspect
    "
     self run:#test03
     self new test03"
!

test004
    |img|

    img := Image fromFile:(self class packageDirectory 
                        construct:'testData/testcompress4.bmp').
    self assert:(img notNil).

    "/ img inspect.
    "
     self run:#test04
     self new test04"
!

test005
    |img|

    img := Image fromFile:(self class packageDirectory 
                        construct:'testData/testcompress8.bmp').
    self assert:(img notNil).

    "/ img inspect.
    "
     self run:#test05
     self new test05"
!

test006
    |img|

    img := Image 
                fromFile:(self class packageDirectory construct:'testData/test8os2.bmp').
    self assert:(img notNil).

    "/ img inspect.
    "
     self run:#test06
     self new test06"
!

test007
    |img|

    img := Image 
                fromFile:(self class packageDirectory construct:'testData/test4os2v2.bmp').
    self assert:(img notNil).

    "/ img inspect.
    "
     self run:#test07
     self new test07"
!

test008
    |img|

    img := Image 
                fromFile:(self class packageDirectory construct:'testData/test16.bmp').
    self assert:(img notNil).

    "/ img inspect.
    "
     self run:#test08
     self new test08"
!

test009
    |img|

    img := Image 
                fromFile:(self class packageDirectory construct:'testData/test24.bmp').
    self assert:(img notNil).

    "/ img inspect.
    "
     self run:#test09
     self new test09"
!

test010
    |img|

    img := Image 
                fromFile:(self class packageDirectory construct:'testData/test32.bmp').
    self assert:(img notNil).

    "/ img inspect.
    "
     self run:#test10
     self new test10"
!

test101
    |alpha s bits img|

    img := Depth32Image width:16 height:16.
    alpha := #[
                    0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
                    0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
                    0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
                    0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255

                    0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
                    0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
                    0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
                    0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255

                    0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
                    0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
                    0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
                    0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255

                    0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
                    0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
                    0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
                    0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
              ].
    s := WriteStream on:#[].
    alpha do:[:a |
        s nextPut:127.    "/ r
        s nextPut:127.    "/ g
        s nextPut:127.    "/ b
        s nextPut:a.    
    ].

    bits := (s contents).
    img bits:bits.
    "/ img inspect.

    "
     self run:#test101
     self new test101
    "
!

testPNG_001_basn0g01
    |img|

    img := Image fromFile:(self class packageDirectory construct:'testData/pngImages/basn0g01.png').
    self assert:(img notNil).
    self assert:(img depth == 1).
    self assert:(img extent = (32@32)).
    self assert:(img colorAt:(0@0)) = Color white.
    self assert:(img colorAt:(31@31)) = Color black.

    "/ img inspect.
    "
     self run:#testPNG_001_basn0g01
     self new testPNG_001_basn0g01
    "

    "Created: / 05-02-2011 / 10:32:32 / cg"
!

testPNG_002_basn0g02
    |img|

    img := Image fromFile:(self class packageDirectory construct:'testData/pngImages/basn0g02.png').
    self assert:(img notNil).
    self assert:(img depth == 2).
    self assert:(img extent = (32@32)).
    self assert:(img colorAt:(0@0)) = Color black.
    self assert:(img colorAt:(31@31)) = (Color rgbValue:16rAAAAAA).

    "/ img inspect.
    "
     self run:#testPNG_002_basn0g02
     self new testPNG_002_basn0g02
    "

    "Created: / 05-02-2011 / 10:33:24 / cg"
!

test_png_01
    |img|

    (self class packageDirectory construct:'testData/pngImages') directoryContentsAsFilenamesDo:[:f |
        img := Image fromFile:f.
        self assert:(img notNil).
    ].

    "
     self run:#test_png_01
     self new test_png_01
    "
!

test_png_02
    |referenceImg img|

    img := Image fromFile:(self class 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:'
?????/????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.

    self assert:(img asImageWithDepth:1) = (referenceImg asImageWithDepth:1).

    "
     self run:#test_png_02
     self new test_png_02
    "
! !

!ImageReaderTest class methodsFor:'documentation'!

version
    ^ '$Header$'
!

version_CVS
    ^ '$Header$'
! !