Search in sources :

Example 1 with Localizable

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

the class GeomTest method testHashCodeLocalizable.

/**
 * Test localizable hash code.
 */
@Test
void testHashCodeLocalizable() {
    final Localizable localizable = Geom.createLocalizable(1.5, 2.5);
    assertHashNotEquals(localizable, new Object());
    assertHashNotEquals(localizable, Geom.createLocalizable(2.5, 2.5));
    assertHashNotEquals(localizable, Geom.createLocalizable(1.5, 1.5));
    assertHashEquals(localizable, Geom.createLocalizable(1.5, 2.5));
}
Also used : Localizable(com.b3dgs.lionengine.Localizable) Test(org.junit.jupiter.api.Test)

Example 2 with Localizable

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

the class GeomTest method testSameLocalizable.

/**
 * Test if localizable are same.
 */
@Test
void testSameLocalizable() {
    final Localizable localizable = Geom.createLocalizable(1.5, 2.5);
    assertTrue(Geom.same(localizable, localizable));
    assertTrue(Geom.same(localizable, Geom.createLocalizable(1.5, 2.5)));
    assertTrue(Geom.same(Geom.createLocalizable(1.5, 2.5), localizable));
    assertTrue(Geom.same(Geom.createLocalizable(1.5, 2.5), Geom.createLocalizable(1.5, 2.5)));
    final Coord coord = new Coord(1.5, 2.5);
    assertTrue(Geom.same(coord, coord));
    assertTrue(Geom.same(coord, localizable));
    assertTrue(Geom.same(coord, new Coord(1.5, 2.5)));
    assertTrue(Geom.same(new Coord(1.5, 2.5), coord));
    assertTrue(Geom.same(coord, Geom.createLocalizable(1.5, 2.5)));
}
Also used : Localizable(com.b3dgs.lionengine.Localizable) Test(org.junit.jupiter.api.Test)

Example 3 with Localizable

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

the class LauncherModelTest method testLauncher.

/**
 * Test the launcher.
 *
 * @throws InterruptedException If error.
 */
@Test
void testLauncher() throws InterruptedException {
    final AtomicBoolean fired = new AtomicBoolean();
    final AtomicReference<Launchable> firedLaunchable = new AtomicReference<>();
    launcher.addListener(UtilLaunchable.createListener(fired));
    launcher.addListener(UtilLaunchable.createListener(firedLaunchable));
    assertTimeout(1000L, () -> {
        while (!launcher.fire()) {
            launcher.update(1.0);
            continue;
        }
    });
    assertTrue(fired.get());
    assertNotNull(firedLaunchable.get());
    firedLaunchable.set(null);
    final Handler handler = services.get(Handler.class);
    handler.update(1.0);
    assertEquals(1, handler.size());
    final Transformable transformable = new TransformableModel(services, setup);
    assertTimeout(1000L, () -> {
        while (!launcher.fire(transformable)) {
            launcher.update(1.0);
            continue;
        }
    });
    assertNotNull(firedLaunchable.get());
    firedLaunchable.set(null);
    handler.update(1.0);
    assertEquals(2, handler.size());
    final Localizable localizable = UtilLaunchable.createLocalizable();
    assertTimeout(1000L, () -> {
        while (!launcher.fire(localizable)) {
            launcher.update(1.0);
            continue;
        }
    });
    assertNotNull(firedLaunchable.get());
    handler.update(1.0);
    assertEquals(3, handler.size());
    handler.removeAll();
    handler.update(1.0);
    assertEquals(0, handler.size());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TransformableModel(com.b3dgs.lionengine.game.feature.TransformableModel) Handler(com.b3dgs.lionengine.game.feature.Handler) Transformable(com.b3dgs.lionengine.game.feature.Transformable) AtomicReference(java.util.concurrent.atomic.AtomicReference) Localizable(com.b3dgs.lionengine.Localizable) Test(org.junit.jupiter.api.Test)

Example 4 with Localizable

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

the class GeomTest method testCreateLocalizable.

/**
 * Test create localizable.
 */
@Test
void testCreateLocalizable() {
    final Localizable localizable = Geom.createLocalizable(1.5, 2.5);
    assertEquals(1.5, localizable.getX());
    assertEquals(2.5, localizable.getY());
}
Also used : Localizable(com.b3dgs.lionengine.Localizable) Test(org.junit.jupiter.api.Test)

Example 5 with Localizable

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

the class GeomTest method testEqualsLocalizable.

/**
 * Test localizable equals.
 */
@Test
void testEqualsLocalizable() {
    final Localizable localizable = Geom.createLocalizable(1.5, 2.5);
    assertNotEquals(localizable, null);
    assertNotEquals(localizable, new Object());
    assertNotEquals(localizable, Geom.createLocalizable(2.5, 2.5));
    assertNotEquals(localizable, Geom.createLocalizable(1.5, 1.5));
    assertEquals(localizable, localizable);
    assertEquals(localizable, Geom.createLocalizable(1.5, 2.5));
    assertEquals(Geom.createLocalizable(1.5, 2.5), localizable);
    assertEquals(Geom.createLocalizable(1.5, 2.5), Geom.createLocalizable(1.5, 2.5));
}
Also used : Localizable(com.b3dgs.lionengine.Localizable) Test(org.junit.jupiter.api.Test)

Aggregations

Localizable (com.b3dgs.lionengine.Localizable)7 Test (org.junit.jupiter.api.Test)7 ContextMock (com.b3dgs.lionengine.ContextMock)1 Cursor (com.b3dgs.lionengine.game.Cursor)1 Handler (com.b3dgs.lionengine.game.feature.Handler)1 Transformable (com.b3dgs.lionengine.game.feature.Transformable)1 TransformableModel (com.b3dgs.lionengine.game.feature.TransformableModel)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1