use of com.b3dgs.lionengine.game.feature.Factory in project lionengine by b3dgs.
the class LauncherModelTest method testCheckListener.
/**
* Test check listener conditions.
*/
@Test
void testCheckListener() {
final Media launchableMedia = UtilSetup.createMedia(LaunchableObjectException.class);
final Media launcherMedia = UtilLaunchable.createLauncherMedia(launchableMedia);
final Setup setup = new Setup(launcherMedia);
services.add(new Factory(services));
services.add(new Handler(services));
final AtomicBoolean launchableListener = new AtomicBoolean();
final AtomicBoolean launcherListener = new AtomicBoolean();
final Launcher launcher = new LauncherModel(services, setup) {
@Override
public void addListener(LaunchableListener listener) {
launchableListener.set(true);
}
@Override
public void addListener(LauncherListener listener) {
launcherListener.set(true);
}
};
assertFalse(launchableListener.get());
assertFalse(launcherListener.get());
launcher.checkListener(launcher);
assertFalse(launchableListener.get());
assertFalse(launcherListener.get());
launcher.checkListener((LaunchableListener) l -> l.update(1.0));
assertTrue(launchableListener.get());
assertFalse(launcherListener.get());
launcher.checkListener((LauncherListener) () -> launcher.update(1.0));
launchableListener.set(false);
assertFalse(launchableListener.get());
assertTrue(launcherListener.get());
assertTrue(launchableMedia.getFile().delete());
}
Aggregations