Changeset 4832


Ignore:
Timestamp:
02/20/09 14:03:28 (11 years ago)
Author:
melissa
Message:

For each writer, test all possible compression types (instead of assuming uncompressed).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/test-suite/src/loci/tests/testng/FormatWriterTest.java

    r4821 r4832  
    8787    createLogFile(); 
    8888    IFormatWriter[] writers = new ImageWriter().getWriters(); 
    89     IFormatWriter[][] writersToUse = new IFormatWriter[writers.length][1]; 
     89    Vector tmp = new Vector(); 
    9090    for (int i=0; i<writers.length; i++) { 
    91       writersToUse[i][0] = writers[i]; 
     91      String[] compressionTypes = writers[i].getCompressionTypes(); 
     92      if (compressionTypes == null) { 
     93        try { 
     94          IFormatWriter w = (IFormatWriter) writers[i].getClass().newInstance(); 
     95          tmp.add(w); 
     96        } 
     97        catch (InstantiationException ie) { } 
     98        catch (IllegalAccessException iae) { } 
     99        continue; 
     100      } 
     101      for (int q=0; q<compressionTypes.length; q++) { 
     102        try { 
     103          IFormatWriter w = (IFormatWriter) writers[i].getClass().newInstance(); 
     104          w.setCompression(compressionTypes[q]); 
     105          tmp.add(w); 
     106        } 
     107        catch (FormatException fe) { } 
     108        catch (InstantiationException ie) { } 
     109        catch (IllegalAccessException iae) { } 
     110      } 
     111    } 
     112    IFormatWriter[][] writersToUse = new IFormatWriter[tmp.size()][1]; 
     113    for (int i=0; i<tmp.size(); i++) { 
     114      writersToUse[i][0] = (IFormatWriter) tmp.get(i); 
    92115    } 
    93116    return writersToUse; 
     
    296319 
    297320  private static boolean isLosslessWriter(IFormatWriter writer) { 
    298     return !(writer instanceof JPEGWriter) && 
    299       !(writer instanceof JPEG2000Writer); 
     321    if ((writer instanceof JPEGWriter) || (writer instanceof JPEG2000Writer)) { 
     322      return false; 
     323    } 
     324    String compression = writer.getCompression(); 
     325    if (compression != null) compression = compression.toLowerCase(); 
     326    if (compression == null || compression.equals("lzw") || 
     327      compression.equals("zlib") || compression.equals("uncompressed")) 
     328    { 
     329      return true; 
     330    } 
     331    return false; 
    300332  } 
    301333 
Note: See TracChangeset for help on using the changeset viewer.