org.hd.d.pg2k.test.dev
Class MediaHandlerTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.hd.d.pg2k.test.dev.MediaHandlerTest
All Implemented Interfaces:
junit.framework.Test

public final class MediaHandlerTest
extends junit.framework.TestCase

Tests of media-generation classes, eg for making thumbnails. This will test features such as transcoding, etc.

Also tests some relevant features of the ExhibitMIME class.


Field Summary
(package private) static int bigImageHeight
          Height of image big enough to make both thumbnails of; several times longest large thumbnail dimension.
(package private) static int bigImageWidth
          Width of image big enough to make both thumbnails of; several times longest large thumbnail dimension.
private static java.util.Random rnd
          Reasonable shared random-number generator.
 
Constructor Summary
MediaHandlerTest(java.lang.String name)
           
 
Method Summary
private static java.awt.image.BufferedImage makeTestRGBIndexedColourBufferedImage(int width, int height)
          Create a byte-indexed fully-opaque RGB test image in memory.
(package private) static java.awt.image.BufferedImage makeTestRGBTrueColourBufferedImage(int width, int height)
          Create a test RGB fully-opaque true-colour image in memory.
(package private) static byte[] makeTestRGBTrueColourJPEGImage()
          Make test JPEG encoded image of reasonably typical size; never null.
 void testColourReduction()
          Test colour reduction of RGB and indexed images using ImageUtils routine.
 void testDimensionExtraction()
          Test ability to accurately extract image dimensions from raw binaries.
 void testExhibitMIMEBasics()
          Test some basic features of ExhibitMIME.
 void testGIFBasics()
          Does some basic tests on the GIF handler.
 void testJP2Basics()
          Does some basic tests on the JP2 (JPEG 2000) handler.
 void testJPGBasics()
          Does some basic tests on the JPG (JPEG) handler.
 void testMetadataBasics()
          Simple tests of exhibit metadata.
 void testPNGBasics()
          Does some basic tests on the PNG handler.
 void testQuantizer()
          Test that we can do colour reduction with the ImageMagik-derived Quantizer.
 void testThumbnailGeneration()
          Test thumbnail generation of a given set of exhibit types.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

bigImageWidth

static final int bigImageWidth
Width of image big enough to make both thumbnails of; several times longest large thumbnail dimension. Package-visible to be available to other tests.

See Also:
Constant Field Values

bigImageHeight

static final int bigImageHeight
Height of image big enough to make both thumbnails of; several times longest large thumbnail dimension. Package-visible to be available to other tests.

See Also:
Constant Field Values

rnd

private static final java.util.Random rnd
Reasonable shared random-number generator.

Constructor Detail

MediaHandlerTest

public MediaHandlerTest(java.lang.String name)
Method Detail

testExhibitMIMEBasics

public void testExhibitMIMEBasics()
Test some basic features of ExhibitMIME. Including all exhibit type values being in range, in order, and unique.


testJPGBasics

public void testJPGBasics()
                   throws java.lang.Exception
Does some basic tests on the JPG (JPEG) handler. For example, make sure that it always exists.

Throws:
java.lang.Exception

testJP2Basics

public void testJP2Basics()
                   throws java.lang.Exception
Does some basic tests on the JP2 (JPEG 2000) handler. For example, make sure that it always exists.

Throws:
java.lang.Exception

testGIFBasics

public void testGIFBasics()
Does some basic tests on the GIF handler. Because of the Unisys LZW patent issues until 2004 this may not initially be prepared to make thumbnails.


testPNGBasics

public void testPNGBasics()
Does some basic tests on the PNG handler.


testThumbnailGeneration

public void testThumbnailGeneration()
                             throws java.lang.Exception
Test thumbnail generation of a given set of exhibit types. In passing, tests that images can be generated at all.

Throws:
java.lang.Exception

testDimensionExtraction

public void testDimensionExtraction()
                             throws java.io.IOException
Test ability to accurately extract image dimensions from raw binaries. In passing, we will make sure that the overhead for each format is no larger than the (presumed valid, and very small) test images.

Throws:
java.io.IOException

makeTestRGBTrueColourBufferedImage

static java.awt.image.BufferedImage makeTestRGBTrueColourBufferedImage(int width,
                                                                       int height)
Create a test RGB fully-opaque true-colour image in memory. This image will be suitable to make thumbnails from, for example, if large enough.

This is an RGB image with a mixture of slowly-varying colours and noise.

Package-visible to be available to other tests.


makeTestRGBIndexedColourBufferedImage

private static java.awt.image.BufferedImage makeTestRGBIndexedColourBufferedImage(int width,
                                                                                  int height)
Create a byte-indexed fully-opaque RGB test image in memory. This image will be suitable to make thumbnails from, for example, if large enough.

This is an RGB image some geometric patterns in a small number of colours (but more than one colour),# but that should be colour-reducable.

In passing this also tests a technique for generating indexed-colour images given RGB values.


makeTestRGBTrueColourJPEGImage

static byte[] makeTestRGBTrueColourJPEGImage()
                                      throws java.io.IOException
Make test JPEG encoded image of reasonably typical size; never null. The image is bigger than any thumbnail, and encoded at a typical quality.

Will throw a jUnit exception if something unexpected happens.

Package-visible to be available to other tests.

Throws:
java.io.IOException - if the JPEG encoder routines have difficulty

testColourReduction

public void testColourReduction()
Test colour reduction of RGB and indexed images using ImageUtils routine. This tests that we don't get back more colours than we start with, and that this works regardless of source image type.


testQuantizer

public void testQuantizer()
Test that we can do colour reduction with the ImageMagik-derived Quantizer.


testMetadataBasics

public void testMetadataBasics()
                        throws java.lang.Exception
Simple tests of exhibit metadata. For example, check that it is safe to attempt to extract metadata from all exhibits with a handler, even though there legitimately be no metadata to extract though we in fact expect to always extract some metadata from every object where we have a handler.

We check that we can extract EXIF data from at least one (JPEG) exhibit.

Throws:
java.lang.Exception

DHD Multimedia Gallery V1.57.21

Copyright (c) 1996-2011, Damon Hart-Davis. All rights reserved.