Search in sources :

Example 76 with ImageBuffer

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

the class ImageTest method testConstructorSurface.

/**
 * Test constructor with surface.
 */
@Test
public void testConstructorSurface() {
    final ImageBuffer surface = Graphics.createImageBuffer(64, 32);
    final Image image = new ImageImpl(surface);
    Assert.assertTrue(image.isLoaded());
    Assert.assertEquals(surface, image.getSurface());
    Assert.assertEquals(64, image.getWidth());
    Assert.assertEquals(32, image.getHeight());
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) Image(com.b3dgs.lionengine.graphic.Image) Test(org.junit.Test)

Example 77 with ImageBuffer

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

the class ImageTest method testEquals.

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

Example 78 with ImageBuffer

use of com.b3dgs.lionengine.graphic.ImageBuffer 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 79 with ImageBuffer

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

the class SpriteAnimatedTest method testConstructorSurface.

/**
 * Test constructor with surface.
 */
@Test
public void testConstructorSurface() {
    final ImageBuffer surface = Graphics.createImageBuffer(64, 32);
    final SpriteAnimated sprite = new SpriteAnimatedImpl(surface, 16, 8);
    Assert.assertTrue(sprite.isLoaded());
    Assert.assertEquals(surface, sprite.getSurface());
    Assert.assertEquals(64, sprite.getWidth());
    Assert.assertEquals(32, sprite.getHeight());
    Assert.assertEquals(4, sprite.getTileWidth());
    Assert.assertEquals(4, sprite.getTileHeight());
    Assert.assertEquals(16, sprite.getFramesHorizontal());
    Assert.assertEquals(8, sprite.getFramesVertical());
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) SpriteAnimated(com.b3dgs.lionengine.graphic.SpriteAnimated) Test(org.junit.Test)

Example 80 with ImageBuffer

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

the class SpriteAnimatedTest method testEquals.

/**
 * Test equals.
 */
@Test
public void testEquals() {
    final ImageBuffer surface = Graphics.createImageBuffer(64, 32);
    final SpriteAnimated sprite = new SpriteAnimatedImpl(surface, 16, 8);
    final SpriteAnimated spriteMedia = new SpriteAnimatedImpl(media, 16, 8);
    spriteMedia.load();
    Assert.assertEquals(sprite, sprite);
    Assert.assertEquals(sprite, new SpriteAnimatedImpl(surface, 16, 8));
    Assert.assertEquals(spriteMedia, spriteMedia);
    Assert.assertNotEquals(sprite, null);
    Assert.assertNotEquals(sprite, new Object());
    Assert.assertNotEquals(sprite, new SpriteAnimatedImpl(media, 16, 8));
    Assert.assertNotEquals(spriteMedia, new SpriteAnimatedImpl(media, 16, 8));
    Assert.assertNotEquals(sprite, new SpriteAnimatedImpl(surface, 16, 16));
    Assert.assertNotEquals(sprite, new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8));
    Assert.assertNotEquals(sprite, new SpriteAnimatedImpl(Graphics.createImageBuffer(32, 32), 16, 8));
    Assert.assertNotEquals(sprite, new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 64), 16, 8));
    Assert.assertNotEquals(sprite, new SpriteAnimatedImpl(Graphics.createImageBuffer(32, 64), 16, 8));
    Assert.assertNotEquals(sprite, new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 8, 8));
    Assert.assertNotEquals(sprite, new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 16));
    Assert.assertNotEquals(sprite, new SpriteAnimatedImpl(Graphics.createImageBuffer(32, 32), 8, 8));
    Assert.assertNotEquals(sprite, new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 64), 16, 16));
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) SpriteAnimated(com.b3dgs.lionengine.graphic.SpriteAnimated) Test(org.junit.Test)

Aggregations

ImageBuffer (com.b3dgs.lionengine.graphic.ImageBuffer)110 Test (org.junit.Test)34 Test (org.junit.jupiter.api.Test)28 Media (com.b3dgs.lionengine.Media)16 Graphic (com.b3dgs.lionengine.graphic.Graphic)12 GraphicTest (com.b3dgs.lionengine.graphic.GraphicTest)12 FactoryGraphic (com.b3dgs.lionengine.graphic.FactoryGraphic)9 BufferedImage (java.awt.image.BufferedImage)9 SpriteTiled (com.b3dgs.lionengine.graphic.SpriteTiled)6 SpriteTiled (com.b3dgs.lionengine.graphic.drawable.SpriteTiled)5 ColorRgba (com.b3dgs.lionengine.graphic.ColorRgba)3 FactoryGraphicTest (com.b3dgs.lionengine.graphic.FactoryGraphicTest)3 Image (com.b3dgs.lionengine.graphic.Image)3 Sprite (com.b3dgs.lionengine.graphic.Sprite)3 SpriteAnimated (com.b3dgs.lionengine.graphic.SpriteAnimated)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 TilesExtractor (com.b3dgs.lionengine.game.feature.tile.TilesExtractor)2 ArrayList (java.util.ArrayList)2 BeforeAll (org.junit.jupiter.api.BeforeAll)2 Config (com.b3dgs.lionengine.Config)1