Changeset 6242


Ignore:
Timestamp:
05/05/10 17:18:04 (10 years ago)
Author:
curtis
Message:

Specify a pixel type for the importer tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/loci-plugins/test/loci/plugins/in/ImporterTest.java

    r6240 r6242  
    99 
    1010import loci.formats.FormatException; 
     11import loci.formats.FormatTools; 
    1112import loci.plugins.util.BF; 
    1213 
     
    1920  @Test 
    2021  public void testBasic() { 
     22    final int sizeX = 477, sizeY = 393; 
     23    final int pixelType = FormatTools.UINT8; 
     24    final String path = constructFakeFilename("basic", sizeX, sizeY, pixelType); 
     25    ImagePlus[] imps = null; 
     26     
    2127    try { 
    22       final int sizeX = 477, sizeY = 393; 
    23       final String path = constructFakeFilename("basic", sizeX, sizeY); 
    24       final ImagePlus[] imps = BF.openImagePlus(path); 
    25       assertNotNull(imps); 
    26       assertTrue(imps.length == 1); 
    27       assertNotNull(imps[0]); 
    28       assertTrue(imps[0].getWidth() == sizeX); 
    29       assertTrue(imps[0].getHeight() == sizeY); 
     28      imps = BF.openImagePlus(path); 
    3029    } 
    3130    catch (IOException e) { 
     
    3534      fail(e.getMessage()); 
    3635    } 
     36     
     37    assertNotNull(imps); 
     38    assertTrue(imps.length == 1); 
     39    assertNotNull(imps[0]); 
     40    assertTrue(imps[0].getWidth() == sizeX); 
     41    assertTrue(imps[0].getHeight() == sizeY); 
    3742    System.out.println("It worked!");//TEMP 
    3843  } 
     
    4045  @Test 
    4146  public void testCrop() { 
     47    final int sizeX = 253, sizeY = 511; 
     48    final int cropSizeX = 112, cropSizeY = 457; 
     49    final int pixelType = FormatTools.UINT8; 
     50    final String path = constructFakeFilename("crop", sizeX, sizeY, pixelType); 
     51    ImagePlus[] imps = null; 
    4252    try { 
    43       final ImporterOptions options = new ImporterOptions(); 
    44       final int sizeX = 253, sizeY = 511; 
    45       final int cropSizeX = 112, cropSizeY = 457; 
    46       final String path = constructFakeFilename("crop", sizeX, sizeY); 
     53            final ImporterOptions options = new ImporterOptions(); 
    4754      options.setId(path); 
    4855      options.setCrop(true); 
    4956      // TODO: pass crop parameters to options somehow 
    50       final ImagePlus[] imps = BF.openImagePlus(options); 
    51       assertNotNull(imps); 
    52       assertTrue(imps.length == 0); 
    53       assertNotNull(imps[0]); 
    54       assertTrue(imps[0].getWidth() == cropSizeX); 
    55       assertTrue(imps[0].getHeight() == cropSizeY); 
     57      imps = BF.openImagePlus(options); 
    5658    } 
    5759    catch (IOException e) { 
     
    6163      fail(e.getMessage()); 
    6264    } 
     65 
     66    assertNotNull(imps); 
     67    assertTrue(imps.length == 0); 
     68    assertNotNull(imps[0]); 
     69    assertTrue(imps[0].getWidth() == cropSizeX); 
     70    assertTrue(imps[0].getHeight() == cropSizeY); 
    6371  } 
    6472   
    6573  // -- Helper methods -- 
    6674 
    67   private String constructFakeFilename(String title, int sizeX, int sizeY) { 
    68     return title + "&sizeX=" + sizeX + "&sizeY=" + sizeY + ".fake"; 
     75  private String constructFakeFilename(String title, 
     76    int sizeX, int sizeY, int pixelType) 
     77  { 
     78    return title + 
     79      "&pixelType=" + FormatTools.getPixelTypeString(pixelType) + 
     80      "&sizeX=" + sizeX + "&sizeY=" + sizeY + ".fake"; 
    6981  } 
    7082 
     
    7587    test.testBasic(); 
    7688    //test.testCrop(); 
     89    System.exit(0); 
    7790  } 
    7891 
Note: See TracChangeset for help on using the changeset viewer.