Changeset 3826


Ignore:
Timestamp:
03/14/08 18:48:55 (12 years ago)
Author:
curtis
Message:
  • Run some tests only on the first few image planes, for speed.
  • Improve logging output a little.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/tests/testng/FormatReaderTest.java

    r3808 r3826  
    104104    if (!initFile()) return; 
    105105    String file = reader.getCurrentFile(); 
    106     String testName = "\ttestBufferedImageDimensions"; 
     106    String testName = "testBufferedImageDimensions"; 
    107107    boolean success = true; 
    108108    String msg = null; 
     
    117117        int type = reader.getPixelType(); 
    118118 
    119         for (int j=0; j<reader.getImageCount() && success; j++) { 
     119        int num = reader.getImageCount(); 
     120        if (num > 3) num = 3; // test first three image planes only, for speed 
     121        for (int j=0; j<num && success; j++) { 
    120122          b = reader.openImage(j); 
    121123 
     
    153155    if (!initFile()) return; 
    154156    String file = reader.getCurrentFile(); 
    155     String testName = "\ttestByteArrayDimensions"; 
     157    String testName = "testByteArrayDimensions"; 
    156158    boolean success = true; 
    157159    String msg = null; 
     
    167169        int expected = x * y * c * bytes; 
    168170 
    169         for (int j=0; j<reader.getImageCount() && success; j++) { 
     171        int num = reader.getImageCount(); 
     172        if (num > 3) num = 3; // test first three planes only, for speed 
     173        for (int j=0; j<num && success; j++) { 
    170174          b = reader.openBytes(j); 
    171175          success = b.length == expected; 
     
    190194    if (!initFile()) return; 
    191195    String file = reader.getCurrentFile(); 
    192     String testName = "\ttestThumbnailImageDimensions"; 
    193     boolean success = true; 
    194     String msg = null; 
    195     try { 
    196       BufferedImage b = null; 
     196    String testName = "testThumbnailImageDimensions"; 
     197    boolean success = true; 
     198    String msg = null; 
     199    try { 
    197200      for (int i=0; i<reader.getSeriesCount() && success; i++) { 
    198201        reader.setSeries(i); 
     
    203206        int type = reader.getPixelType(); 
    204207 
    205         for (int j=0; j<reader.getImageCount() && success; j++) { 
    206           b = reader.openThumbImage(j); 
    207  
    208           int actualX = b.getWidth(); 
    209           boolean passX = x == actualX; 
    210           if (!passX) msg = "X: was " + actualX + ", expected " + x; 
    211  
    212           int actualY = b.getHeight(); 
    213           boolean passY = y == actualY; 
    214           if (!passY) msg = "Y: was " + actualY + ", expected " + y; 
    215  
    216           int actualC = b.getRaster().getNumBands(); 
    217           boolean passC = c == actualC; 
    218           if (!passC) msg = "C: was " + actualC + ", expected < " + c; 
    219  
    220           int actualType = ImageTools.getPixelType(b); 
    221           boolean passType = type == actualType; 
    222           if (!passType) msg = "type: was " + actualType + ", expected " + type; 
    223  
    224           success = passX && passY && passC && passType; 
    225         } 
     208        BufferedImage b = reader.openThumbImage(0); 
     209 
     210        int actualX = b.getWidth(); 
     211        boolean passX = x == actualX; 
     212        if (!passX) { 
     213          msg = "series #" + i + ": X: was " + actualX + ", expected " + x; 
     214        } 
     215 
     216        int actualY = b.getHeight(); 
     217        boolean passY = y == actualY; 
     218        if (!passY) { 
     219          msg = "series #" + i + ": Y: was " + actualY + ", expected " + y; 
     220        } 
     221 
     222        int actualC = b.getRaster().getNumBands(); 
     223        boolean passC = c == actualC; 
     224        if (!passC) { 
     225          msg = "series #" + i + ": C: was " + actualC + ", expected < " + c; 
     226        } 
     227 
     228        int actualType = ImageTools.getPixelType(b); 
     229        boolean passType = type == actualType; 
     230        if (!passType) { 
     231          msg = "series #" + i + ": type: was " + 
     232            actualType + ", expected " + type; 
     233        } 
     234 
     235        success = passX && passY && passC && passType; 
    226236      } 
    227237    } 
     
    239249    if (!initFile()) return; 
    240250    String file = reader.getCurrentFile(); 
    241     String testName = "\ttestThumbnailByteArrayDimensions"; 
    242     boolean success = true; 
    243     String msg = null; 
    244     try { 
    245       byte[] b = null; 
     251    String testName = "testThumbnailByteArrayDimensions"; 
     252    boolean success = true; 
     253    String msg = null; 
     254    try { 
    246255      for (int i=0; i<reader.getSeriesCount() && success; i++) { 
    247256        reader.setSeries(i); 
     
    253262        int expected = x * y * c * bytes; 
    254263 
    255         for (int j=0; j<reader.getImageCount() && success; j++) { 
    256           b = reader.openThumbBytes(j); 
    257           success = b.length == expected; 
    258           if (!success) { 
    259             msg = "series #" + i + ", image #" + j + 
    260               ": was " + b.length + ", expected " + expected; 
    261           } 
     264        byte[] b = reader.openThumbBytes(0); 
     265        success = b.length == expected; 
     266        if (!success) { 
     267          msg = "series #" + i + ": was " + b.length + ", expected " + expected; 
    262268        } 
    263269      } 
     
    276282    if (!initFile()) return; 
    277283    String file = reader.getCurrentFile(); 
    278     String testName = "\ttestImageCount"; 
     284    String testName = "testImageCount"; 
    279285    boolean success = true; 
    280286    String msg = null; 
     
    304310    if (!initFile()) return; 
    305311    String file = reader.getCurrentFile(); 
    306     String testName = "\ttestOMEXML"; 
     312    String testName = "testOMEXML"; 
    307313    boolean success = true; 
    308314    String msg = null; 
     
    359365    if (!initFile()) return; 
    360366    String file = reader.getCurrentFile(); 
    361     String testName = "\ttestConsistent"; 
     367    String testName = "testConsistent"; 
    362368    boolean success = true; 
    363369    String msg = null; 
     
    474480    if (!initFile()) return; 
    475481    String file = reader.getCurrentFile(); 
    476     String testName = "\ttestPerformance"; 
     482    String testName = "testPerformance"; 
    477483    boolean success = true; 
    478484    String msg = null; 
     
    502508        int actualMem = (int) ((m2 - m1) >> 20); 
    503509 
    504         // check time elapsed  
     510        // check time elapsed 
    505511        if (actualTime - timeMultiplier * properTime > 20.0) { 
    506512          success = false; 
     
    528534    if (!initFile()) return; 
    529535    String file = reader.getCurrentFile(); 
    530     String testName = "\ttestSaneUsedFiles"; 
     536    String testName = "testSaneUsedFiles"; 
    531537    boolean success = true; 
    532538    String msg = null; 
     
    565571    if (!initFile()) return; 
    566572    String file = reader.getCurrentFile(); 
    567     String testName = "\ttestValidXML"; 
     573    String testName = "testValidXML"; 
    568574    boolean success = true; 
    569575    try { 
     
    587593    if (!initFile()) return; 
    588594    String file = reader.getCurrentFile(); 
    589     String testName = "\ttestPixelsHashes"; 
     595    String testName = "testPixelsHashes"; 
    590596    boolean success = true; 
    591597    String msg = null; 
     
    618624    if (!initFile()) return; 
    619625    String file = reader.getCurrentFile(); 
    620     String testName = "\ttestIsThisType"; 
     626    String testName = "testIsThisType"; 
    621627    boolean success = true; 
    622628    String msg = null; 
     
    839845   */ 
    840846  private static void result(String testName, boolean success, String msg) { 
    841     LogTools.println(timestamp() + ": " + testName + ": " + 
     847    LogTools.println("\t" + timestamp() + ": " + testName + ": " + 
    842848      (success ? "PASSED" : "FAILED") + (msg == null ? "" : " (" + msg + ")")); 
    843849    if (msg == null) assert success; 
Note: See TracChangeset for help on using the changeset viewer.