use of com.b3dgs.lionengine.game.feature.Handler in project lionengine by b3dgs.
the class LauncherModelTest method testLauncherDelay.
/**
* Test the launcher with delay.
*
* @throws InterruptedException If error.
*/
@Test
void testLauncherDelay() throws InterruptedException {
final Media launcherMedia = UtilLaunchable.createLauncherMedia(launchableMedia, 100);
final Setup setup = new Setup(launcherMedia);
final Launcher launcher = UtilLaunchable.createLauncher(services, setup, featurable);
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);
}
});
final Handler handler = services.get(Handler.class);
launcher.update(1.0);
handler.update(1.0);
assertEquals(0, handler.size());
assertTrue(fired.get());
assertNull(firedLaunchable.get());
assertTimeout(1000L, () -> {
while (firedLaunchable.get() == null) {
launcher.update(1.0);
handler.update(1.0);
}
});
assertEquals(1, handler.size());
firedLaunchable.set(null);
handler.removeAll();
handler.update(1.0);
assertEquals(0, handler.size());
}
use of com.b3dgs.lionengine.game.feature.Handler in project lionengine by b3dgs.
the class LauncherModelTest method testLauncherInitial.
/**
* Test the launcher with initial speed.
*
* @throws InterruptedException If error.
*/
@Test
void testLauncherInitial() throws InterruptedException {
final AtomicBoolean fired = new AtomicBoolean();
final AtomicReference<Launchable> firedLaunchable = new AtomicReference<>();
launcher.addListener(UtilLaunchable.createListener(fired));
launcher.addListener(UtilLaunchable.createListener(firedLaunchable));
final Force force = new Force(1.0, 2.0);
assertTimeout(1000L, () -> {
while (!launcher.fire(force)) {
launcher.update(1.0);
continue;
}
});
assertTrue(fired.get());
assertNotNull(firedLaunchable.get());
final Transformable transformable = firedLaunchable.get().getFeature(Transformable.class);
assertEquals(2.0, transformable.getX());
assertEquals(4.0, transformable.getY());
final Handler handler = services.get(Handler.class);
handler.update(1.0);
assertEquals(1, handler.size());
handler.removeAll();
handler.update(1.0);
assertEquals(0, handler.size());
}
use of com.b3dgs.lionengine.game.feature.Handler in project lionengine by b3dgs.
the class ProducerModelTest method prepare.
/**
* Prepare test.
*/
@BeforeEach
public void prepare() {
services.add(new Handler(services));
services.add(new SourceResolutionProvider() {
@Override
public int getWidth() {
return 0;
}
@Override
public int getHeight() {
return 0;
}
@Override
public int getRate() {
return 50;
}
});
producer = new ProducerModel(services, setup);
producer.prepare(object);
}
Aggregations