console.init();
console.on(KeyStrokes.UP);
driver.assertEmpty();
console.on(KeyStrokes.DOWN);
driver.assertEmpty();
shell.addProcess(new SyncProcess() {
@Override
public void run(String request, ShellProcessContext context) throws Exception {
context.end(ShellResponse.ok());
}
});
console.on(KeyStrokes.a);
console.on(KeyStrokes.ENTER);
driver.assertChar('a').assertFlush().assertCRLF().assertFlush().assertCRLF().assertFlush().assertEmpty();
shell.addProcess(new SyncProcess() {
@Override
public void run(String request, ShellProcessContext context) throws Exception {
context.end(ShellResponse.ok());
}
});
console.on(KeyStrokes.b);
console.on(KeyStrokes.ENTER);
driver.assertChar('b').assertFlush().assertCRLF().assertFlush().assertCRLF().assertFlush().assertEmpty();
console.on(KeyStrokes.c);
driver.assertChar('c').assertFlush().assertEmpty();
console.on(KeyStrokes.UP);
driver.assertDel().assertChar('b').assertFlush().assertEmpty();
console.on(KeyStrokes.UNDERSCORE);
driver.assertChar('_').assertFlush().assertEmpty();
console.on(KeyStrokes.UP);
driver.assertDel().assertDel().assertChar('a').assertFlush().assertEmpty();
console.on(KeyStrokes.UP);
driver.assertEmpty();
console.on(KeyStrokes.DOWN);
driver.assertDel().assertChar('b').assertChar('_').assertFlush().assertEmpty();
console.on(KeyStrokes.DOWN);
driver.assertDel().assertDel().assertChar('c').assertFlush().assertEmpty();
console.on(KeyStrokes.DOWN);
driver.assertEmpty();
console.on(KeyStrokes.UP);
driver.assertDel().assertChar('b').assertChar('_').assertFlush().assertEmpty();
console.on(KeyStrokes.ONE);
driver.assertChar('1').assertFlush().assertEmpty();
final ArrayList<String> requests = new ArrayList<String>();
shell.addProcess(new SyncProcess() {
@Override
public void run(String request, ShellProcessContext context) throws Exception {
requests.add(request);
context.end(ShellResponse.ok());
}