Search in sources :

Example 6 with Image

use of com.b3dgs.lionengine.graphic.Image in project lionengine by b3dgs.

the class ImageTest method testLoadMediaAlready.

/**
 * Test load with media already loaded.
 */
@Test(expected = LionEngineException.class)
public void testLoadMediaAlready() {
    final Image image = new ImageImpl(media);
    image.load();
    image.load();
}
Also used : Image(com.b3dgs.lionengine.graphic.Image) Test(org.junit.Test)

Example 7 with Image

use of com.b3dgs.lionengine.graphic.Image in project lionengine by b3dgs.

the class ImageTest method testHashCode.

/**
 * Test hash code.
 */
@Test
public void testHashCode() {
    final ImageBuffer surface = Graphics.createImageBuffer(64, 32);
    final int image = new ImageImpl(surface).hashCode();
    final Image imageMedia = new ImageImpl(media);
    imageMedia.load();
    Assert.assertEquals(image, new ImageImpl(surface).hashCode());
    Assert.assertNotEquals(image, new Object().hashCode());
    Assert.assertNotEquals(imageMedia.hashCode(), new ImageImpl(media).hashCode());
    Assert.assertNotEquals(image, new ImageImpl(Graphics.createImageBuffer(64, 32)).hashCode());
    Assert.assertNotEquals(image, new ImageImpl(Graphics.createImageBuffer(32, 32)).hashCode());
    Assert.assertNotEquals(image, new ImageImpl(Graphics.createImageBuffer(64, 64)).hashCode());
    Assert.assertNotEquals(image, new ImageImpl(Graphics.createImageBuffer(32, 64)).hashCode());
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) Image(com.b3dgs.lionengine.graphic.Image) Test(org.junit.Test)

Example 8 with Image

use of com.b3dgs.lionengine.graphic.Image in project lionengine by b3dgs.

the class ImageTest method testConstructorMedia.

/**
 * Test constructor with media.
 */
@Test
public void testConstructorMedia() {
    final Image image = new ImageImpl(media);
    Assert.assertFalse(image.isLoaded());
    Assert.assertNull(image.getSurface());
    Assert.assertEquals(64, image.getWidth());
    Assert.assertEquals(32, image.getHeight());
}
Also used : Image(com.b3dgs.lionengine.graphic.Image) Test(org.junit.Test)

Example 9 with Image

use of com.b3dgs.lionengine.graphic.Image in project lionengine by b3dgs.

the class ImageTest method testLoadMedia.

/**
 * Test load with media.
 */
@Test
public void testLoadMedia() {
    final Image image = new ImageImpl(media);
    image.load();
    Assert.assertNotNull(image.getSurface());
    image.prepare();
    image.dispose();
}
Also used : Image(com.b3dgs.lionengine.graphic.Image) Test(org.junit.Test)

Aggregations

Image (com.b3dgs.lionengine.graphic.Image)9 Test (org.junit.Test)9 ImageBuffer (com.b3dgs.lionengine.graphic.ImageBuffer)3 Graphic (com.b3dgs.lionengine.graphic.Graphic)1