Search in sources :

Example 61 with Config

use of com.b3dgs.lionengine.Config in project lionengine by b3dgs.

the class LoopUnlockedTest method testUnready.

/**
 * Test with not ready screen.
 *
 * @throws InterruptedException If error.
 */
@Test(timeout = 1000L)
public void testUnready() throws InterruptedException {
    ScreenMock.setScreenWait(true);
    final Screen screen = new ScreenMock(new Config(new Resolution(320, 240, 50), 16, true));
    screen.getConfig().setSource(new Resolution(320, 240, 50));
    final Thread thread = getTask(screen);
    thread.start();
    latch.await();
    loop.stop();
    thread.join();
    Assert.assertEquals(0, rendered.get());
    Assert.assertEquals(0, tick.get());
    Assert.assertEquals(-1, computed.get());
}
Also used : Screen(com.b3dgs.lionengine.graphic.Screen) Config(com.b3dgs.lionengine.Config) ScreenMock(com.b3dgs.lionengine.graphic.ScreenMock) Resolution(com.b3dgs.lionengine.Resolution) Test(org.junit.Test)

Example 62 with Config

use of com.b3dgs.lionengine.Config in project lionengine by b3dgs.

the class ScreenAwtTest method testEngineWindowed.

/**
 * Test with engine
 */
@Test
void testEngineWindowed() {
    Medias.setLoadFromJar(ScreenAwtTest.class);
    final Config config = new Config(UtilTests.RESOLUTION_320_240, 32, true, Medias.create("image.png"));
    EngineAwt.start(ScreenAwtTest.class.getSimpleName(), Version.DEFAULT, ScreenAwtTest.class);
    testScreen(config);
}
Also used : Config(com.b3dgs.lionengine.Config) Test(org.junit.jupiter.api.Test)

Example 63 with Config

use of com.b3dgs.lionengine.Config in project lionengine by b3dgs.

the class ScreenAwtTest method testFullscreenFail.

/**
 * Test full screen fail.
 *
 * @throws ReflectiveOperationException If error.
 */
@Test
void testFullscreenFail() throws ReflectiveOperationException {
    final Resolution resolution = new Resolution(Integer.MAX_VALUE, Integer.MAX_VALUE, 0);
    final Config config = new Config(resolution, 32, false);
    assertThrowsPrefix(() -> testScreen(config), ScreenFullAwt.ERROR_UNSUPPORTED_FULLSCREEN);
}
Also used : Config(com.b3dgs.lionengine.Config) Resolution(com.b3dgs.lionengine.Resolution) Test(org.junit.jupiter.api.Test)

Example 64 with Config

use of com.b3dgs.lionengine.Config in project lionengine by b3dgs.

the class ScreenAwtTest method testFullscreen.

/**
 * Test full screen.
 */
@Test
void testFullscreen() {
    Medias.setLoadFromJar(ScreenAwtTest.class);
    final DisplayMode res = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayModes()[0];
    final Config config = new Config(new Resolution(res.getWidth(), res.getHeight(), res.getRefreshRate()), res.getBitDepth(), false, Medias.create("image.png"));
    try {
        testScreen(config);
    } catch (final LionEngineException exception) {
        // Skip test
        if (!ScreenFullAwt.ERROR_SWITCH.equals(exception.getMessage())) {
            throw exception;
        }
    }
}
Also used : DisplayMode(java.awt.DisplayMode) LionEngineException(com.b3dgs.lionengine.LionEngineException) Config(com.b3dgs.lionengine.Config) Resolution(com.b3dgs.lionengine.Resolution) Test(org.junit.jupiter.api.Test)

Example 65 with Config

use of com.b3dgs.lionengine.Config in project lionengine by b3dgs.

the class ScreenHeadlessTest method testFullscreen.

/**
 * Test full screen.
 *
 * @throws Exception If error.
 */
@Test
void testFullscreen() throws Exception {
    final Resolution resolution = com.b3dgs.lionengine.UtilTests.RESOLUTION_320_240;
    final Config config = new Config(resolution, 32, false, Medias.create(IMAGE));
    assertTimeout(1000L, () -> testScreen(config));
}
Also used : Config(com.b3dgs.lionengine.Config) Resolution(com.b3dgs.lionengine.Resolution) Test(org.junit.jupiter.api.Test)

Aggregations

Config (com.b3dgs.lionengine.Config)89 Resolution (com.b3dgs.lionengine.Resolution)75 Screen (com.b3dgs.lionengine.graphic.Screen)47 ScreenMock (com.b3dgs.lionengine.graphic.ScreenMock)45 Test (org.junit.jupiter.api.Test)42 Test (org.junit.Test)38 FactoryGraphicMock (com.b3dgs.lionengine.graphic.FactoryGraphicMock)2 Semaphore (java.util.concurrent.Semaphore)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 Context (com.b3dgs.lionengine.Context)1 LionEngineException (com.b3dgs.lionengine.LionEngineException)1 FilterBilinear (com.b3dgs.lionengine.core.filter.FilterBilinear)1 FilterBlur (com.b3dgs.lionengine.core.filter.FilterBlur)1 FilterHq2x (com.b3dgs.lionengine.core.filter.FilterHq2x)1 FilterHq3x (com.b3dgs.lionengine.core.filter.FilterHq3x)1 ImageBuffer (com.b3dgs.lionengine.graphic.ImageBuffer)1 Rasterbar (com.b3dgs.lionengine.graphic.engine.Rasterbar)1 Sequencer (com.b3dgs.lionengine.graphic.engine.Sequencer)1 SourceResolutionProvider (com.b3dgs.lionengine.graphic.engine.SourceResolutionProvider)1 FilterBilinear (com.b3dgs.lionengine.graphic.filter.FilterBilinear)1