Search in sources :

Example 1 with MPlayerDumpBuilder

use of org.fagu.fmv.soft.mplayer.MPlayerDump.MPlayerDumpBuilder in project fmv by f-agu.

the class RipperTestCase method mockMPlayerDumpBuilder.

// ************************************
/**
 * @return
 * @throws IOException
 */
private MPlayerDumpBuilder mockMPlayerDumpBuilder() throws IOException {
    MPlayerDump dump = mock(MPlayerDump.class);
    MPlayerDumpBuilder builder = mock(MPlayerDumpBuilder.class);
    AtomicReference<IntConsumer> progress = new AtomicReference<>();
    doAnswer(invocation -> {
        progress.set((IntConsumer) invocation.getArguments()[0]);
        return builder;
    }).when(builder).progress(any(IntConsumer.class));
    doAnswer(invocation -> {
        for (int i = 0; i < 100; ++i) {
            Thread.sleep(30);
            progress.get().accept(i);
        }
        return dump;
    }).when(builder).dump(anyInt(), any(File.class));
    return builder;
}
Also used : MPlayerDumpBuilder(org.fagu.fmv.soft.mplayer.MPlayerDump.MPlayerDumpBuilder) MPlayerDump(org.fagu.fmv.soft.mplayer.MPlayerDump) AtomicReference(java.util.concurrent.atomic.AtomicReference) File(java.io.File) IntConsumer(java.util.function.IntConsumer)

Aggregations

File (java.io.File)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 IntConsumer (java.util.function.IntConsumer)1 MPlayerDump (org.fagu.fmv.soft.mplayer.MPlayerDump)1 MPlayerDumpBuilder (org.fagu.fmv.soft.mplayer.MPlayerDump.MPlayerDumpBuilder)1