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));
}
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)));
}
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());
}
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());
}
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));
}
Aggregations