Search in sources :

Example 11 with FactoryGraphicMock

use of com.b3dgs.lionengine.graphic.FactoryGraphicMock in project lionengine by b3dgs.

the class DrawableTest method setUp.

/**
 * Setup test.
 */
@BeforeClass
public static void setUp() {
    Medias.setLoadFromJar(DrawableTest.class);
    Graphics.setFactoryGraphic(new FactoryGraphicMock());
    media = Medias.create("image.png");
    font = Medias.create("fontdata.xml");
}
Also used : FactoryGraphicMock(com.b3dgs.lionengine.graphic.FactoryGraphicMock) BeforeClass(org.junit.BeforeClass)

Example 12 with FactoryGraphicMock

use of com.b3dgs.lionengine.graphic.FactoryGraphicMock in project lionengine by b3dgs.

the class SpriteFontTest method setUp.

/**
 * Prepare test.
 */
@BeforeClass
public static void setUp() {
    Graphics.setFactoryGraphic(new FactoryGraphicMock());
    Medias.setLoadFromJar(SpriteFontTest.class);
    media = Medias.create("image.png");
    font = Medias.create("fontdata.xml");
}
Also used : FactoryGraphicMock(com.b3dgs.lionengine.graphic.FactoryGraphicMock) BeforeClass(org.junit.BeforeClass)

Example 13 with FactoryGraphicMock

use of com.b3dgs.lionengine.graphic.FactoryGraphicMock in project lionengine by b3dgs.

the class SpriteTest method setUp.

/**
 * Prepare test.
 */
@BeforeClass
public static void setUp() {
    Graphics.setFactoryGraphic(new FactoryGraphicMock());
    Medias.setLoadFromJar(SpriteTest.class);
    media = Medias.create("image.png");
}
Also used : FactoryGraphicMock(com.b3dgs.lionengine.graphic.FactoryGraphicMock) BeforeClass(org.junit.BeforeClass)

Example 14 with FactoryGraphicMock

use of com.b3dgs.lionengine.graphic.FactoryGraphicMock in project lionengine by b3dgs.

the class SpriteDigitTest method beforeTests.

/**
 * Prepare tests.
 */
@BeforeAll
public static void beforeTests() {
    Graphics.setFactoryGraphic(new FactoryGraphicMock());
    Medias.setLoadFromJar(SpriteDigitTest.class);
}
Also used : FactoryGraphicMock(com.b3dgs.lionengine.graphic.FactoryGraphicMock) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 15 with FactoryGraphicMock

use of com.b3dgs.lionengine.graphic.FactoryGraphicMock in project lionengine by b3dgs.

the class LoaderTest method testInterruptedUnchecked.

/**
 * Test interrupted unchecked exception.
 */
@Test
void testInterruptedUnchecked() {
    Graphics.setFactoryGraphic(new FactoryGraphicMock() {

        @Override
        public Screen createScreen(Config config) {
            return null;
        }
    });
    final AtomicReference<Throwable> exception = new AtomicReference<>();
    final Semaphore semaphore = new Semaphore(0);
    final Thread thread = new Thread() {

        @Override
        public void run() {
            final TaskFuture future = Loader.start(CONFIG, SequenceInterruptMock.class);
            future.await();
        }
    };
    thread.setUncaughtExceptionHandler((t, throwable) -> {
        exception.set(throwable);
        semaphore.release();
    });
    Verbose.info("*********************************** EXPECTED VERBOSE ***********************************");
    thread.start();
    assertTimeout(SequenceInterruptMock.PAUSE_MILLI * 2L, semaphore::acquire);
    assertTrue(exception.get().getCause() instanceof NullPointerException);
    Verbose.info("****************************************************************************************");
    Graphics.setFactoryGraphic(new FactoryGraphicMock());
}
Also used : Config(com.b3dgs.lionengine.Config) Screen(com.b3dgs.lionengine.graphic.Screen) FactoryGraphicMock(com.b3dgs.lionengine.graphic.FactoryGraphicMock) AtomicReference(java.util.concurrent.atomic.AtomicReference) Semaphore(java.util.concurrent.Semaphore) Test(org.junit.jupiter.api.Test)

Aggregations

FactoryGraphicMock (com.b3dgs.lionengine.graphic.FactoryGraphicMock)61 BeforeAll (org.junit.jupiter.api.BeforeAll)35 BeforeClass (org.junit.BeforeClass)24 EngineMock (com.b3dgs.lionengine.EngineMock)11 FactoryMediaDefault (com.b3dgs.lionengine.FactoryMediaDefault)3 Config (com.b3dgs.lionengine.Config)2 Screen (com.b3dgs.lionengine.graphic.Screen)2 Semaphore (java.util.concurrent.Semaphore)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 Animation (com.b3dgs.lionengine.Animation)1 Xml (com.b3dgs.lionengine.Xml)1 Collision (com.b3dgs.lionengine.game.feature.collidable.Collision)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1 Test (org.junit.jupiter.api.Test)1