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;
}
Aggregations