Search in sources :

Example 6 with Factory

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());
}
Also used : Medias(com.b3dgs.lionengine.Medias) BeforeEach(org.junit.jupiter.api.BeforeEach) UtilAssert.assertFalse(com.b3dgs.lionengine.UtilAssert.assertFalse) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) Setup(com.b3dgs.lionengine.game.feature.Setup) UtilAssert.assertTimeout(com.b3dgs.lionengine.UtilAssert.assertTimeout) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AtomicReference(java.util.concurrent.atomic.AtomicReference) UtilSetup(com.b3dgs.lionengine.game.feature.UtilSetup) UtilAssert.assertThrowsTimeout(com.b3dgs.lionengine.UtilAssert.assertThrowsTimeout) AfterAll(org.junit.jupiter.api.AfterAll) UtilAssert.assertNull(com.b3dgs.lionengine.UtilAssert.assertNull) Resolution(com.b3dgs.lionengine.Resolution) Services(com.b3dgs.lionengine.game.feature.Services) UtilAssert.assertNotNull(com.b3dgs.lionengine.UtilAssert.assertNotNull) BeforeAll(org.junit.jupiter.api.BeforeAll) Force(com.b3dgs.lionengine.game.Force) Handler(com.b3dgs.lionengine.game.feature.Handler) SourceResolutionDelegate(com.b3dgs.lionengine.graphic.engine.SourceResolutionDelegate) Transformable(com.b3dgs.lionengine.game.feature.Transformable) UtilAssert.assertEquals(com.b3dgs.lionengine.UtilAssert.assertEquals) TransformableModel(com.b3dgs.lionengine.game.feature.TransformableModel) Test(org.junit.jupiter.api.Test) AfterEach(org.junit.jupiter.api.AfterEach) UtilAssert.assertTrue(com.b3dgs.lionengine.UtilAssert.assertTrue) Media(com.b3dgs.lionengine.Media) Factory(com.b3dgs.lionengine.game.feature.Factory) Localizable(com.b3dgs.lionengine.Localizable) Featurable(com.b3dgs.lionengine.game.feature.Featurable) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Media(com.b3dgs.lionengine.Media) Factory(com.b3dgs.lionengine.game.feature.Factory) Handler(com.b3dgs.lionengine.game.feature.Handler) Setup(com.b3dgs.lionengine.game.feature.Setup) UtilSetup(com.b3dgs.lionengine.game.feature.UtilSetup) Test(org.junit.jupiter.api.Test)

Aggregations

Factory (com.b3dgs.lionengine.game.feature.Factory)6 Handler (com.b3dgs.lionengine.game.feature.Handler)4 Transformable (com.b3dgs.lionengine.game.feature.Transformable)4 Media (com.b3dgs.lionengine.Media)2 Featurable (com.b3dgs.lionengine.game.feature.Featurable)2 Services (com.b3dgs.lionengine.game.feature.Services)2 TransformableModel (com.b3dgs.lionengine.game.feature.TransformableModel)2 MapTileGame (com.b3dgs.lionengine.game.feature.tile.map.MapTileGame)2 MapTileGroup (com.b3dgs.lionengine.game.feature.tile.map.MapTileGroup)2 MapTileGroupModel (com.b3dgs.lionengine.game.feature.tile.map.MapTileGroupModel)2 MapTileViewerModel (com.b3dgs.lionengine.game.feature.tile.map.viewer.MapTileViewerModel)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 ContextMock (com.b3dgs.lionengine.ContextMock)1 Localizable (com.b3dgs.lionengine.Localizable)1 Medias (com.b3dgs.lionengine.Medias)1 Resolution (com.b3dgs.lionengine.Resolution)1 UtilAssert.assertEquals (com.b3dgs.lionengine.UtilAssert.assertEquals)1 UtilAssert.assertFalse (com.b3dgs.lionengine.UtilAssert.assertFalse)1 UtilAssert.assertNotNull (com.b3dgs.lionengine.UtilAssert.assertNotNull)1 UtilAssert.assertNull (com.b3dgs.lionengine.UtilAssert.assertNull)1