Search in sources :

Example 36 with Config

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

the class LoopHybridTest method testNoSync.

/**
 * Test without sync.
 */
@Test
void testNoSync() {
    ScreenMock.setScreenWait(false);
    final Screen screen = new ScreenMock(new Config(new Resolution(320, 240, 0), 16, true));
    final Thread thread = getTask(screen);
    thread.start();
    assertTimeout(1000L, thread::join);
    assertEquals(maxTick.get(), tick.get());
    assertTrue(rendered.get() <= tick.get(), rendered.get() + " " + tick.get());
    assertTrue(extrapolation.get().doubleValue() < 1.0, String.valueOf(extrapolation.get()));
    final int expectedRate = screen.getConfig().getOutput().getRate();
    assertTrue(computed.get() > expectedRate, String.valueOf(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.jupiter.api.Test)

Example 37 with Config

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

the class LoopHybridTest method testNoSyncFullscreen.

/**
 * Test without sync full screen.
 */
@Test
void testNoSyncFullscreen() {
    ScreenMock.setScreenWait(false);
    final Screen screen = new ScreenMock(new Config(new Resolution(320, 240, 0), 16, false));
    loop.notifyRateChanged(50);
    final Thread thread = getTask(screen);
    thread.start();
    assertTimeout(1000L, thread::join);
    assertEquals(maxTick.get(), tick.get());
    assertTrue(rendered.get() <= tick.get(), rendered.get() + " " + tick.get());
    assertTrue(extrapolation.get().doubleValue() > 0, String.valueOf(extrapolation.get()));
    final int expectedRate = screen.getConfig().getOutput().getRate();
    assertTrue(computed.get() > expectedRate, String.valueOf(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.jupiter.api.Test)

Example 38 with Config

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

the class LoopUnlockedTest method testUnready.

/**
 * Test with not ready screen.
 */
@Test
void testUnready() {
    ScreenMock.setScreenWait(true);
    try {
        final Screen screen = new ScreenMock(new Config(new Resolution(320, 240, 50), 16, true));
        final Thread thread = getTask(screen);
        thread.start();
        assertTimeout(1000L, latch::await);
        loop.stop();
        assertTimeout(1000L, thread::join);
        assertEquals(0, rendered.get());
        assertEquals(0, tick.get());
        assertEquals(-1, computed.get());
    } finally {
        ScreenMock.setScreenWait(false);
    }
}
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.jupiter.api.Test)

Example 39 with Config

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

the class LoopLockedTest method testNoSyncFullscreen.

/**
 * Test without sync.
 */
@Test
void testNoSyncFullscreen() {
    ScreenMock.setScreenWait(false);
    final Screen screen = new ScreenMock(new Config(new Resolution(320, 240, 0), 16, false));
    loop.notifyRateChanged(0);
    final Thread thread = getTask(screen);
    thread.start();
    assertTimeout(1000L, thread::join);
    assertEquals(maxTick.get(), tick.get());
    assertEquals(tick.get(), rendered.get());
    final int expectedRate = screen.getConfig().getOutput().getRate();
    assertTrue(computed.get() > expectedRate, String.valueOf(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.jupiter.api.Test)

Example 40 with Config

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

the class WorldTest method prepare.

/**
 * Prepare test.
 */
@BeforeEach
public void prepare() {
    services.add(new Context() {

        @Override
        public int getX() {
            return 0;
        }

        @Override
        public int getY() {
            return 0;
        }

        @Override
        public int getWidth() {
            return 0;
        }

        @Override
        public int getHeight() {
            return 0;
        }

        @Override
        public <T extends InputDevice> T getInputDevice(Class<T> type) {
            return null;
        }

        @Override
        public Config getConfig() {
            return config;
        }
    });
    services.add(new SourceResolutionProvider() {

        @Override
        public int getWidth() {
            return output.getWidth();
        }

        @Override
        public int getHeight() {
            return output.getHeight();
        }

        @Override
        public int getRate() {
            return output.getRate();
        }
    });
    services.add(new Sequencer() {

        @Override
        public void end(Class<? extends Sequencable> nextSequenceClass, Object... arguments) {
        // Mock
        }

        @Override
        public void end() {
        // Mock
        }

        @Override
        public void load(Class<? extends Sequencable> nextSequenceClass, Object... arguments) {
        // Mock
        }

        @Override
        public void setSystemCursorVisible(boolean visible) {
        // Mock
        }
    });
    services.add(new Rasterbar() {

        @Override
        public void setRasterbarY(int y1, int y2) {
        // Mock
        }

        @Override
        public void setRasterbarOffset(int offsetY, int factorY) {
        // Mock
        }

        @Override
        public void renderRasterbar() {
        // Mock
        }

        @Override
        public void clearRasterbarColor() {
        // Mock
        }

        @Override
        public void addRasterbarColor(ImageBuffer buffer) {
        // Mock
        }
    });
}
Also used : Context(com.b3dgs.lionengine.Context) Sequencer(com.b3dgs.lionengine.graphic.engine.Sequencer) ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) Config(com.b3dgs.lionengine.Config) SourceResolutionProvider(com.b3dgs.lionengine.graphic.engine.SourceResolutionProvider) Rasterbar(com.b3dgs.lionengine.graphic.engine.Rasterbar) BeforeEach(org.junit.jupiter.api.BeforeEach)

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