Search in sources :

Example 16 with ViewerMock

use of com.b3dgs.lionengine.ViewerMock in project lionengine by b3dgs.

the class SpriteFontTest method testSetLocationViewer.

/**
 * Test set location with viewer.
 */
@Test
void testSetLocationViewer() {
    final SpriteFontImpl sprite = new SpriteFontImpl(media, font, 6, 7);
    sprite.load();
    final ViewerMock viewer = new ViewerMock();
    sprite.setLocation(viewer, Geom.createLocalizable(1.5, 2.5));
    assertEquals(0.0, sprite.getX());
    assertEquals(0.0, sprite.getY());
    viewer.set(10, 20);
    sprite.setLocation(viewer, Geom.createLocalizable(1.5, 2.5));
    assertEquals(0.0, sprite.getX());
    assertEquals(0.0, sprite.getY());
    sprite.dispose();
}
Also used : ViewerMock(com.b3dgs.lionengine.ViewerMock) Test(org.junit.jupiter.api.Test)

Example 17 with ViewerMock

use of com.b3dgs.lionengine.ViewerMock in project lionengine by b3dgs.

the class SpriteTest method testSetLocationViewer.

/**
 * Test set location with viewer.
 */
@Test
void testSetLocationViewer() {
    final SpriteImpl sprite = new SpriteImpl(Graphics.createImageBuffer(64, 32));
    final ViewerMock viewer = new ViewerMock();
    sprite.setLocation(viewer, Geom.createLocalizable(1.5, 2.5));
    assertEquals(1.5, sprite.getX());
    assertEquals(237.5, sprite.getY());
    assertEquals(2, sprite.getRenderX());
    assertEquals(238, sprite.getRenderY());
    viewer.set(10, 20);
    sprite.setLocation(viewer, Geom.createLocalizable(1.5, 2.5));
    assertEquals(-8.5, sprite.getX());
    assertEquals(257.5, sprite.getY());
    assertEquals(-8, sprite.getRenderX());
    assertEquals(258, sprite.getRenderY());
}
Also used : ViewerMock(com.b3dgs.lionengine.ViewerMock) Test(org.junit.jupiter.api.Test)

Example 18 with ViewerMock

use of com.b3dgs.lionengine.ViewerMock in project lionengine by b3dgs.

the class ImageTest method testSetLocationViewer.

/**
 * Test set location with viewer.
 */
@Test
void testSetLocationViewer() {
    final ImageImpl image = new ImageImpl(Graphics.createImageBuffer(64, 32));
    final ViewerMock viewer = new ViewerMock();
    image.setLocation(viewer, Geom.createLocalizable(1.5, 2.5));
    assertEquals(1.5, image.getX());
    assertEquals(237.5, image.getY());
    assertEquals(2, image.getRenderX());
    assertEquals(238, image.getRenderY());
    viewer.set(10, 20);
    image.setLocation(viewer, Geom.createLocalizable(1.5, 2.5));
    assertEquals(-8.5, image.getX());
    assertEquals(257.5, image.getY());
    assertEquals(-8, image.getRenderX());
    assertEquals(258, image.getRenderY());
    image.dispose();
}
Also used : ViewerMock(com.b3dgs.lionengine.ViewerMock) Test(org.junit.jupiter.api.Test)

Example 19 with ViewerMock

use of com.b3dgs.lionengine.ViewerMock in project lionengine by b3dgs.

the class CursorTest method testSetViewer.

/**
 * Test set viewer.
 */
@Test
void testSetViewer() {
    final Cursor cursor = new Cursor(services);
    final MouseMock mouse = new MouseMock();
    mouse.move(1, 2);
    cursor.setSync(mouse);
    final ViewerMock viewer = new ViewerMock();
    cursor.setViewer(viewer);
    viewer.set(100, 200);
    cursor.update(1.0);
    assertEquals(101.0, cursor.getX());
    assertEquals(438.0, cursor.getY());
    assertEquals(1.0, cursor.getScreenX());
    assertEquals(2.0, cursor.getScreenY());
}
Also used : ViewerMock(com.b3dgs.lionengine.ViewerMock) Test(org.junit.jupiter.api.Test)

Example 20 with ViewerMock

use of com.b3dgs.lionengine.ViewerMock in project lionengine by b3dgs.

the class TextGameTest method testLocation.

/**
 * Test location.
 */
@Test
void testLocation() {
    final TextGame text = new TextGame(Constant.FONT_DIALOG, 8, TextStyle.NORMAL);
    assertEquals(0, text.getLocationX());
    assertEquals(0, text.getLocationY());
    final ViewerMock viewer = new ViewerMock();
    viewer.set(1, 2);
    text.update(viewer);
    assertEquals(0, text.getLocationX());
    assertEquals(0, text.getLocationY());
    text.setLocation(3, 4);
    assertEquals(3, text.getLocationX());
    assertEquals(4, text.getLocationY());
}
Also used : ViewerMock(com.b3dgs.lionengine.ViewerMock) Test(org.junit.jupiter.api.Test)

Aggregations

ViewerMock (com.b3dgs.lionengine.ViewerMock)22 Test (org.junit.jupiter.api.Test)13 Test (org.junit.Test)5 BeforeEach (org.junit.jupiter.api.BeforeEach)4 Media (com.b3dgs.lionengine.Media)3 Camera (com.b3dgs.lionengine.game.feature.Camera)3 ContextMock (com.b3dgs.lionengine.ContextMock)2 Xml (com.b3dgs.lionengine.Xml)2 Configurer (com.b3dgs.lionengine.game.Configurer)2 Cursor (com.b3dgs.lionengine.game.Cursor)2 Featurable (com.b3dgs.lionengine.game.feature.Featurable)2 FeaturableModel (com.b3dgs.lionengine.game.feature.FeaturableModel)2 Services (com.b3dgs.lionengine.game.feature.Services)2 Setup (com.b3dgs.lionengine.game.feature.Setup)2 TransformableModel (com.b3dgs.lionengine.game.feature.TransformableModel)2 MapTileGame (com.b3dgs.lionengine.game.feature.tile.map.MapTileGame)2 Animation (com.b3dgs.lionengine.Animation)1 Animatable (com.b3dgs.lionengine.game.feature.Animatable)1 AnimatableModel (com.b3dgs.lionengine.game.feature.AnimatableModel)1 Factory (com.b3dgs.lionengine.game.feature.Factory)1