Search in sources :

Example 6 with Timing

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

the class ScreenAbstract method awaitReady.

@Override
public final void awaitReady() {
    final Timing timeout = new Timing();
    timeout.start();
    while (!isReady()) {
        if (timeout.elapsed(getReadyTimeOut())) {
            throw new LionEngineException(ERROR_SCREEN_READY);
        }
        try {
            Thread.sleep(Constant.DECADE);
        } catch (final InterruptedException exception) {
            Thread.currentThread().interrupt();
            throw new LionEngineException(exception, ERROR_SCREEN_READY);
        }
    }
}
Also used : LionEngineException(com.b3dgs.lionengine.LionEngineException) Timing(com.b3dgs.lionengine.Timing)

Example 7 with Timing

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

the class UtilSequenceTest method testPauseInterrupted.

/**
 * Test pause interrupted.
 */
@Test
public void testPauseInterrupted() {
    final Timing timing = new Timing();
    timing.start();
    final Thread thread = new Thread() {

        @Override
        public void run() {
            UtilSequence.pause(Constant.THOUSAND);
        }
    };
    thread.start();
    thread.interrupt();
    Assert.assertTrue(String.valueOf(timing.elapsed()), timing.elapsed() < Constant.THOUSAND);
}
Also used : Timing(com.b3dgs.lionengine.Timing) Test(org.junit.Test)

Aggregations

Timing (com.b3dgs.lionengine.Timing)7 Test (org.junit.Test)2 Test (org.junit.jupiter.api.Test)2 LionEngineException (com.b3dgs.lionengine.LionEngineException)1