public abstract class AbstractRendererTestCase extends AbstractTestCase {
public List<String> render(final LineReader renderer, final int width) {
ArrayList<String> result = new ArrayList<String>();
while (renderer.hasLine()) {
final ScreenBuffer buffer = new ScreenBuffer();
renderer.renderLine(new RenderAppendable(new ScreenContext() {
public int getWidth() {
return width;
}
public int getHeight() {
return 40;
}
public Screenable append(CharSequence s) throws IOException {
buffer.append(s);
return this;
}
public Appendable append(char c) throws IOException {
buffer.append(c);
return this;
}
public Appendable append(CharSequence csq, int start, int end) throws IOException {
buffer.append(csq, start, end);
return this;
}
public Screenable append(Style style) throws IOException {
buffer.append(style);
return this;
}
public Screenable cls() throws IOException {
buffer.cls();
return this;
}
public void flush() throws IOException {
buffer.flush();
}
}));
StringBuilder sb = new StringBuilder();
try {
buffer.format(Format.ANSI, sb);
}
catch (IOException e) {
throw failure(e);
}
result.add(sb.toString());