transcendental-lisp/test/terminal/FlushListener.java
Mike Cifelli 2de2e3947a Increase test coverage
Fixed an intermittent deadlock in MainTest:
FlushListener could receive more than the expected number of flushes
before the VirtualTerminalInteractor was given control. So by setting
the flush count to zero in waitForFlushes(), flushes could be lost. Now
it only reduces the number of flushes by the expected number.
2017-03-24 11:53:33 -04:00

38 lines
805 B
Java

package terminal;
import com.googlecode.lanterna.TerminalSize;
import com.googlecode.lanterna.terminal.Terminal;
import com.googlecode.lanterna.terminal.virtual.VirtualTerminalListener;
public class FlushListener implements VirtualTerminalListener {
private int flushCount;
public FlushListener() {
this.flushCount = 0;
}
public synchronized int getFlushCount() {
return flushCount;
}
public synchronized void reduceFlushCount(int reduction) {
flushCount -= reduction;
}
@Override
public void onResized(Terminal terminal, TerminalSize newSize) {}
@Override
public synchronized void onFlush() {
flushCount++;
notify();
}
@Override
public void onBell() {}
@Override
public void onClose() {}
}