RegressionTests__ImageReaderTest.st
branchjv
changeset 1484 e5af485c693d
parent 699 3316cd60b7c2
child 1485 5a1aadddbc7f
equal deleted inserted replaced
1483:8e5a0f125106 1484:e5af485c693d
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "{ Package: 'exept:regression' }"
     3 "{ Package: 'exept:regression' }"
     2 
     4 
     3 "{ NameSpace: RegressionTests }"
     5 "{ NameSpace: RegressionTests }"
     4 
     6 
     5 TestCase subclass:#ImageReaderTest
     7 TestCase subclass:#ImageReaderTest
    27 "
    29 "
    28 ! !
    30 ! !
    29 
    31 
    30 !ImageReaderTest methodsFor:'tests'!
    32 !ImageReaderTest methodsFor:'tests'!
    31 
    33 
    32 test001
    34 test001_bmp
    33     |img|
    35     |img|
    34 
    36 
    35     img := Image 
    37     img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test1.bmp').
    36                 fromFile:(self class packageDirectory construct:'testData/test1.bmp').
    38     self assert:(img notNil).
    37     self assert:(img notNil).
    39     self assert:(img depth == 1).
    38     
    40     
    39     "/ img inspect.
    41     "/ img inspect.
    40     
    42     
    41     self assert:((img colorAtX:0 y:0) rgbValue = 16r4040FF).
    43     self assert:((img colorAtX:0 y:0) rgbValue = 16r4040FF).
    42     self assert:((img colorAtX:0 y:63) rgbValue = 16r4040FF).
    44     self assert:((img colorAtX:0 y:63) rgbValue = 16r4040FF).
    43     self assert:((img colorAtX:0 y:18) rgbValue = 16r40FF40).
    45     self assert:((img colorAtX:0 y:18) rgbValue = 16r40FF40).
    44 
    46 
    45     "
    47     "
    46      self run:#test01
    48      self run:#test001_bmp
    47      self new test01"
    49      self new test001_bmp"
    48 !
    50 !
    49 
    51 
    50 test002
    52 test002_bmp
    51     |img|
    53     |img|
    52 
    54 
    53     img := Image 
    55     img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test4.bmp').
    54                 fromFile:(self class packageDirectory construct:'testData/test4.bmp').
    56     self assert:(img notNil).
    55     self assert:(img notNil).
    57     self assert:(img depth == 4).
    56 
    58 
    57     "/ img inspect.
    59     self assert:((img colorAtX:0 y:15) rgbValue = 16rFF0000).
    58     "
    60     self assert:((img colorAtX:35 y:15) rgbValue = 16r004000).
    59      self run:#test02
    61     self assert:((img colorAtX:35 y:30) rgbValue = 16r008000).
    60      self new test02"
    62     self assert:((img colorAtX:35 y:45) rgbValue = 16r00C000).
    61 !
    63     self assert:((img colorAtX:35 y:60) rgbValue = 16r00FF00).
    62 
    64     self assert:((img colorAtX:70 y:15) rgbValue = 16r0000FF).
    63 test003
    65 
    64     |img|
    66     "/ img inspect.
    65 
    67     "
    66     img := Image 
    68      self run:#test002_bmp
    67                 fromFile:(self class packageDirectory construct:'testData/test8.bmp').
    69      self new test002_bmp"
    68     self assert:(img notNil).
    70 !
       
    71 
       
    72 test003_bmp
       
    73     |img|
       
    74 
       
    75     img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test8.bmp').
       
    76     self assert:(img notNil).
       
    77     self assert:(img depth == 8).
       
    78     self assert:((img colorAtX:30 y:0) rgbValue = 16rFF0000).
    69 
    79 
    70     "/ img inspect
    80     "/ img inspect
    71     "
    81     "
    72      self run:#test03
    82      self run:#test003_bmp
    73      self new test03"
    83      self new test003_bmp"
    74 !
    84 !
    75 
    85 
    76 test004
    86 test004_bmp
    77     |img|
    87     |img|
    78 
    88 
    79     img := Image fromFile:(self class packageDirectory 
    89     img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/testcompress4.bmp').
    80                         construct:'testData/testcompress4.bmp').
    90     self assert:(img notNil).
    81     self assert:(img notNil).
    91     self assert:(img depth == 4).
    82 
    92     self assert:((img colorAtX:0 y:15) rgbValue = 16rFF0000).
    83     "/ img inspect.
    93     self assert:((img colorAtX:35 y:15) rgbValue = 16r004000).
    84     "
    94     self assert:((img colorAtX:35 y:30) rgbValue = 16r008000).
    85      self run:#test04
    95     self assert:((img colorAtX:35 y:45) rgbValue = 16r00C000).
    86      self new test04"
    96     self assert:((img colorAtX:35 y:60) rgbValue = 16r00FF00).
    87 !
    97     self assert:((img colorAtX:70 y:15) rgbValue = 16r0000FF).
    88 
    98 
    89 test005
    99     "/ img inspect.
    90     |img|
   100     "
    91 
   101      self run:#test004_bmp
    92     img := Image fromFile:(self class packageDirectory 
   102      self new test004_bmp"
    93                         construct:'testData/testcompress8.bmp').
   103 !
    94     self assert:(img notNil).
   104 
    95 
   105 test005_bmp
    96     "/ img inspect.
   106     |img|
    97     "
   107 
    98      self run:#test05
   108     img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/testcompress8.bmp').
    99      self new test05"
   109     self assert:(img notNil).
   100 !
   110     self assert:(img depth == 8).
   101 
   111     self assert:((img colorAtX:30 y:0) rgbValue = 16rFF0000).
   102 test006
   112 
   103     |img|
   113     "/ img inspect.
   104 
   114     "
   105     img := Image 
   115      self run:#test005_bmp
   106                 fromFile:(self class packageDirectory construct:'testData/test8os2.bmp').
   116      self new test005_bmp"
   107     self assert:(img notNil).
   117 !
   108 
   118 
   109     "/ img inspect.
   119 test006_bmp
   110     "
   120     |img|
   111      self run:#test06
   121 
   112      self new test06"
   122     img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test8os2.bmp').
   113 !
   123     self assert:(img notNil).
   114 
   124 
   115 test007
   125     "/ img inspect.
   116     |img|
   126     "
   117 
   127      self run:#test006_bmp
   118     img := Image 
   128      self new test006_bmp"
   119                 fromFile:(self class packageDirectory construct:'testData/test4os2v2.bmp').
   129 !
   120     self assert:(img notNil).
   130 
   121 
   131 test007_bmp
   122     "/ img inspect.
   132     |img|
   123     "
   133 
   124      self run:#test07
   134     img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test4os2v2.bmp').
   125      self new test07"
   135     self assert:(img notNil).
   126 !
   136 
   127 
   137     "/ img inspect.
   128 test008
   138     "
   129     |img|
   139      self run:#test007_bmp
   130 
   140      self new test007_bmp"
   131     img := Image 
   141 !
   132                 fromFile:(self class packageDirectory construct:'testData/test16.bmp').
   142 
   133     self assert:(img notNil).
   143 test008_bmp
   134 
   144     |img|
   135     "/ img inspect.
   145 
   136     "
   146     img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test16.bmp').
   137      self run:#test08
   147     self assert:(img notNil).
   138      self new test08"
   148 
   139 !
   149     "/ img inspect.
   140 
   150     "
   141 test009
   151      self run:#test008_bmp
   142     |img|
   152      self new test008_bmp"
   143 
   153 !
   144     img := Image 
   154 
   145                 fromFile:(self class packageDirectory construct:'testData/test24.bmp').
   155 test009_bmp
   146     self assert:(img notNil).
   156     |img|
   147 
   157 
   148     "/ img inspect.
   158     img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test24.bmp').
   149     "
   159     self assert:(img notNil).
   150      self run:#test09
   160 
   151      self new test09"
   161     "/ img inspect.
   152 !
   162     "
   153 
   163      self run:#test009_bmp
   154 test010
   164      self new test009_bmp"
   155     |img|
   165 !
   156 
   166 
   157     img := Image 
   167 test010_bmp
   158                 fromFile:(self class packageDirectory construct:'testData/test32.bmp').
   168     |img|
   159     self assert:(img notNil).
   169 
   160 
   170     img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test32.bmp').
   161     "/ img inspect.
   171     self assert:(img notNil).
   162     "
   172 
   163      self run:#test10
   173     "/ img inspect.
   164      self new test10"
   174     "
       
   175      self run:#test010_bmp
       
   176      self new test010_bmp"
   165 !
   177 !
   166 
   178 
   167 test101
   179 test101
   168     |alpha s bits img|
   180     |alpha s bits img|
   169 
   181 
   231 
   243 
   232     img := Image fromFile:(self class packageDirectory construct:'testData/pngImages/basn0g02.png').
   244     img := Image fromFile:(self class packageDirectory construct:'testData/pngImages/basn0g02.png').
   233     self assert:(img notNil).
   245     self assert:(img notNil).
   234     self assert:(img depth == 2).
   246     self assert:(img depth == 2).
   235     self assert:(img extent = (32@32)).
   247     self assert:(img extent = (32@32)).
   236     self assert:(img colorAt:(0@0)) = Color black.
   248     self assert:(img colorAt:(0@0)) rgbValue = 0.
   237     self assert:(img colorAt:(31@31)) = (Color rgbValue:16rAAAAAA).
   249     self assert:(img colorAt:(31@31)) rgbValue = 16rAAAAAA.
   238 
   250 
   239     "/ img inspect.
   251     "/ img inspect.
   240     "
   252     "
   241      self run:#testPNG_002_basn0g02
   253      self run:#testPNG_002_basn0g02
   242      self new testPNG_002_basn0g02
   254      self new testPNG_002_basn0g02
   243     "
   255     "
   244 
   256 
   245     "Created: / 05-02-2011 / 10:33:24 / cg"
   257     "Created: / 05-02-2011 / 10:33:24 / cg"
   246 !
   258 !
   247 
   259 
       
   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.
       
   269 
       
   270     "/ img inspect.
       
   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 
       
   279 test_bmp_01
       
   280     |img allOK|
       
   281 
       
   282     allOK := true.
       
   283     (self class packageDirectory construct:'testData/bmpImages') directoryContentsAsFilenamesDo:[:f |
       
   284         (f isRegularFile and:[f hasSuffix:'bmp']) ifTrue:[
       
   285             Error handle:[:ex |
       
   286                 img := nil.
       
   287             ] do:[
       
   288                 img := Image fromFile:f.
       
   289             ].
       
   290             img isNil ifTrue:[ 
       
   291                 Transcript printf:'failed: %s\n' with:f baseName.
       
   292                 allOK := false
       
   293             ].                
       
   294         ].
       
   295     ].
       
   296     self assert:allOK.
       
   297 
       
   298     "
       
   299      self run:#test_bmp_01
       
   300      self new test_bmp_01
       
   301     "
       
   302 !
       
   303 
       
   304 test_bmp_02
       
   305     |img allOK|
       
   306 
       
   307     allOK := true.
       
   308     (self class packageDirectory construct:'testData/bmpImages/bmpsuite-2.4') directoryContentsAsFilenamesDo:[:f |
       
   309         (f isRegularFile and:[f hasSuffix:'bmp']) ifTrue:[
       
   310             Error handle:[:ex |
       
   311                 img := nil.
       
   312             ] do:[
       
   313                 img := Image fromFile:f.
       
   314             ].
       
   315             img isNil ifTrue:[ 
       
   316                 Transcript printf:'failed: %s\n' with:f baseName.
       
   317                 allOK := false
       
   318             ].                
       
   319         ].
       
   320     ].
       
   321     self assert:allOK.
       
   322 
       
   323     "
       
   324      self run:#test_bmp_02
       
   325      self new test_bmp_02
       
   326     "
       
   327 !
       
   328 
   248 test_png_01
   329 test_png_01
   249     |img|
   330     |img allOK|
   250 
   331 
       
   332     allOK := true.
   251     (self class packageDirectory construct:'testData/pngImages') directoryContentsAsFilenamesDo:[:f |
   333     (self class packageDirectory construct:'testData/pngImages') directoryContentsAsFilenamesDo:[:f |
   252         img := Image fromFile:f.
   334         (f isRegularFile and:[f hasSuffix:'png']) ifTrue:[
   253         self assert:(img notNil).
   335             Error handle:[:ex |
       
   336                 img := nil.
       
   337             ] do:[
       
   338                 img := Image fromFile:f.
       
   339             ].    
       
   340             img isNil ifTrue:[ 
       
   341                 Transcript printf:'failed: %s\n' with:f baseName.
       
   342                 allOK := false 
       
   343             ].
       
   344         ].
   254     ].
   345     ].
       
   346     self assert:allOK.
   255 
   347 
   256     "
   348     "
   257      self run:#test_png_01
   349      self run:#test_png_01
   258      self new test_png_01
   350      self new test_png_01
   259     "
   351     "
   290 !
   382 !
   291 
   383 
   292 version_CVS
   384 version_CVS
   293     ^ '$Header$'
   385     ^ '$Header$'
   294 ! !
   386 ! !
       
   387