public TestDriver assertChars(String s) { for (int i = 0;i < s.length();i++) { char c = s.charAt(i); assertChar(c); } return this; }
public void testCompleteSingle2() { shell.setCompleter(new SyncCompleter() { @Override public CompletionMatch complete(String prefix) { Completion.Builder builder = Completion.builder(""); builder.add("foo", true); return new CompletionMatch(Delimiter.EMPTY, builder.build()); } }); console.init(); console.on(KeyStrokes.COMPLETE); driver.assertChars("foo").assertChar(' ').assertFlush().assertEmpty(); assertEquals("foo ", getCurrentLine()); }
public void testMultiline1() { console.init(); console.on(KeyStrokes.a); console.on(KeyStrokes.BACKSLASH); console.on(KeyStrokes.ENTER); console.on(KeyStrokes.b); assertEquals("b", getCurrentLine()); driver.assertChar('a').assertFlush(); driver.assertChar('\\').assertFlush(); driver.assertCRLF().assertChars("> ").assertFlush(); driver.assertChar('b').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); } }); console.on(KeyStrokes.ENTER); assertEquals(Arrays.asList("ab"), requests); }
private void doTest() { driver.assertChar('a').assertFlush().assertEmpty(); console.on(Operation.CLEAR_SCREEN); driver.assertCLS(); driver.assertChar('a').assertFlush().assertEmpty(); } }
public void testDeleteBeginning() { console.init(); console.on(KeyStrokes.DELETE_BEGINNING); driver.assertEmpty(); console.on(KeyStrokes.a); console.on(KeyStrokes.b); console.on(KeyStrokes.c); driver.assertChar('a').assertFlush(); driver.assertChar('b').assertFlush(); driver.assertChar('c').assertFlush().assertEmpty(); console.on(KeyStrokes.LEFT); driver.assertMoveLeft().assertFlush().assertEmpty(); console.on(KeyStrokes.DELETE_BEGINNING); assertEquals("c", getCurrentLine()); driver.assertMoveLeft().assertChars("c ").assertMoveLeft().assertMoveLeft().assertMoveLeft().assertChars("c ").assertMoveLeft().assertMoveLeft().assertFlush().assertEmpty(); }
public void testEditor() { console.init(); console.on(KeyStrokes.a); driver.assertChar('a').assertFlush().assertEmpty(); }
public void testDeletePrevWord() { console.init(); console.on(KeyStrokes.DELETE_PREV_WORD); driver.assertEmpty(); assertEquals("", getClipboard()); console.on(KeyStrokes.a); console.on(KeyStrokes.b); console.on(KeyStrokes.SPACE); console.on(KeyStrokes.c); console.on(KeyStrokes.d); driver.assertChar('a').assertFlush().assertChar('b').assertFlush().assertChar(' ').assertFlush().assertChar('c').assertFlush().assertChar('d').assertFlush().assertEmpty(); console.on(KeyStrokes.LEFT); driver.assertMoveLeft().assertFlush().assertEmpty(); console.on(KeyStrokes.DELETE_PREV_WORD); driver.assertMoveLeft().assertChars("d ").assertMoveLeft().assertMoveLeft().assertFlush().assertEmpty(); assertEquals("ab d", getCurrentLine()); assertEquals("c", getClipboard()); console.on(KeyStrokes.DELETE_PREV_WORD); driver.assertMoveLeft().assertChars("d ").assertMoveLeft(3).assertChars("d ").assertMoveLeft(3).assertChars("d ").assertMoveLeft(2).assertFlush().assertEmpty(); assertEquals("d", getCurrentLine()); assertEquals("ab ", getClipboard()); }
public void testPrompt() { driver.assertEmpty(); prompt = "% "; console.init(); driver.assertChar('%').assertChar(' ').assertFlush().assertEmpty(); final ArrayBlockingQueue<ShellProcessContext> contexts = new ArrayBlockingQueue<ShellProcessContext>(1); shell.addProcess(new SyncProcess() { @Override public void run(String request, ShellProcessContext context) throws Exception { contexts.add(context); } }); console.on(KeyStrokes.a); console.on(KeyStrokes.ENTER); driver.assertChar('a').assertFlush().assertCRLF().assertFlush().assertEmpty(); driver.assertEmpty(); ShellProcessContext context = contexts.poll(); assertNotNull(context); context.end(ShellResponse.ok()); driver.assertCRLF().assertFlush().assertChar('%').assertChar(' ').assertFlush().assertEmpty(); }
public void testInsert() { console.init(); console.on(KeyStrokes.a); driver.assertChar('a').assertFlush().assertEmpty(); console.on(KeyStrokes.LEFT); console.on(KeyStrokes.b); driver.assertMoveLeft().assertFlush().assertChars("ba").assertMoveLeft().assertFlush().assertEmpty(); console.on(KeyStrokes.LEFT); console.on(KeyStrokes.b); driver.assertMoveLeft().assertFlush().assertChars("bba").assertMoveLeft().assertMoveLeft().assertFlush().assertEmpty(); assertEquals("bba", getCurrentLine()); }
public void testMovePrevWord() { console.init(); console.on(KeyStrokes.MOVE_PREV_WORD); driver.assertEmpty(); console.on(KeyStrokes.SPACE); driver.assertChar(' ').assertFlush().assertEmpty(); console.on(KeyStrokes.a); driver.assertChar('a').assertFlush().assertEmpty(); console.on(KeyStrokes.b); driver.assertChar('b').assertFlush().assertEmpty(); console.on(KeyStrokes.MOVE_PREV_WORD); driver.assertMoveLeft().assertMoveLeft().assertFlush().assertEmpty(); }
public void testInterruptMultiline() throws Exception { final ArrayBlockingQueue<String> keys = new ArrayBlockingQueue<String>(1); shell.addProcess(new SyncProcess() { @Override public void run(String request, ShellProcessContext context) throws Exception { keys.add(request); } }); console.init(); console.on(KeyStrokes.QUOTE); console.on(KeyStrokes.ENTER); driver.assertChar('"').assertFlush(); driver.assertCRLF().assertChars("> ").assertFlush().assertEmpty(); console.on(KeyStrokes.INTERRUPT); driver.assertCRLF().assertFlush().assertEmpty(); console.on(KeyStrokes.ENTER); driver.assertCRLF().assertFlush().assertEmpty(); String request = keys.poll(1, TimeUnit.SECONDS); assertEquals("", request); }
public void testMoveBeginning() { console.init(); console.on(KeyStrokes.MOVE_BEGINNING); driver.assertEmpty(); console.on(KeyStrokes.a); driver.assertChar('a').assertFlush().assertEmpty(); console.on(KeyStrokes.SPACE); driver.assertChar(' ').assertFlush().assertEmpty(); console.on(KeyStrokes.b); driver.assertChar('b').assertFlush().assertEmpty(); console.on(KeyStrokes.MOVE_BEGINNING); driver.assertMoveLeft().assertMoveLeft().assertMoveLeft().assertFlush().assertEmpty(); }
public void testMovePrevChar() { console.init(); console.on(KeyStrokes.a); console.on(KeyStrokes.LEFT); driver.assertChar('a').assertFlush().assertMoveLeft().assertFlush().assertEmpty(); }
public void testDeletePrevChar() { console.init(); console.on(KeyStrokes.DELETE_PREV_CHAR); driver.assertEmpty(); console.on(KeyStrokes.a); driver.assertChar('a').assertFlush().assertEmpty(); console.on(KeyStrokes.DELETE_PREV_CHAR); driver.assertDel().assertFlush().assertEmpty(); }
public void testDeleteNextChar() { console.init(); console.on(KeyStrokes.DELETE_NEXT_CHAR); driver.assertEmpty(); console.on(KeyStrokes.a); console.on(KeyStrokes.b); driver.assertChar('a').assertFlush(); driver.assertChar('b').assertFlush().assertEmpty(); console.on(KeyStrokes.DELETE_NEXT_CHAR); driver.assertEmpty(); console.on(KeyStrokes.LEFT); driver.assertMoveLeft().assertFlush().assertEmpty(); console.on(KeyStrokes.LEFT); driver.assertMoveLeft().assertFlush().assertEmpty(); console.on(KeyStrokes.DELETE_NEXT_CHAR); driver.assertMoveRight().assertMoveLeft().assertChar('b').assertChar(' ').assertMoveLeft().assertMoveLeft().assertFlush().assertEmpty(); assertEquals("b", getCurrentLine()); console.on(KeyStrokes.DELETE_NEXT_CHAR); driver.assertMoveRight().assertDel().assertFlush().assertEmpty(); assertEquals("", getCurrentLine()); }
public void testMoveNextWord() { console.init(); console.on(KeyStrokes.MOVE_NEXT_WORD); driver.assertEmpty(); console.on(KeyStrokes.a); driver.assertChar('a').assertFlush().assertEmpty(); console.on(KeyStrokes.b); driver.assertChar('b').assertFlush().assertEmpty(); console.on(KeyStrokes.SPACE); driver.assertChar(' ').assertFlush().assertEmpty(); console.on(KeyStrokes.c); driver.assertChar('c').assertFlush().assertEmpty(); console.on(KeyStrokes.LEFT); driver.assertMoveLeft().assertFlush().assertEmpty(); console.on(KeyStrokes.LEFT); driver.assertMoveLeft().assertFlush().assertEmpty(); console.on(KeyStrokes.LEFT); driver.assertMoveLeft().assertFlush().assertEmpty(); console.on(KeyStrokes.LEFT); driver.assertMoveLeft().assertFlush().assertEmpty(); console.on(KeyStrokes.MOVE_NEXT_WORD); driver.assertMoveRight().assertMoveRight().assertFlush().assertEmpty(); }
public void testMoveEnd() { console.init(); console.on(KeyStrokes.MOVE_END); driver.assertEmpty(); console.on(KeyStrokes.a); driver.assertChar('a').assertFlush().assertEmpty(); console.on(KeyStrokes.SPACE); driver.assertChar(' ').assertFlush().assertEmpty(); console.on(KeyStrokes.b); driver.assertChar('b').assertFlush().assertEmpty(); console.on(KeyStrokes.LEFT); driver.assertMoveLeft().assertFlush().assertEmpty(); console.on(KeyStrokes.LEFT); driver.assertMoveLeft().assertFlush().assertEmpty(); console.on(KeyStrokes.LEFT); driver.assertMoveLeft().assertFlush().assertEmpty(); console.on(KeyStrokes.MOVE_END); driver.assertMoveRight().assertMoveRight().assertMoveRight().assertFlush().assertEmpty(); }
public void testMoveNextChar() { console.init(); console.on(KeyStrokes.RIGHT); driver.assertEmpty(); console.on(KeyStrokes.a); console.on(KeyStrokes.LEFT); driver.assertChar('a').assertFlush().assertMoveLeft().assertFlush().assertEmpty(); console.on(KeyStrokes.RIGHT); driver.assertMoveRight().assertFlush().assertEmpty(); }
public void testDeleteEnd() { console.init(); console.on(KeyStrokes.DELETE_END); driver.assertEmpty(); assertEquals("", getClipboard()); console.on(KeyStrokes.a); console.on(KeyStrokes.b); console.on(KeyStrokes.c); driver.assertChar('a').assertFlush(); driver.assertChar('b').assertFlush(); driver.assertChar('c').assertFlush().assertEmpty(); console.on(KeyStrokes.LEFT); driver.assertMoveLeft().assertFlush().assertEmpty(); console.on(KeyStrokes.LEFT); driver.assertMoveLeft().assertFlush().assertEmpty(); console.on(KeyStrokes.DELETE_END); driver.assertMoveRight().assertMoveRight().assertDel().assertDel().assertFlush().assertEmpty(); assertEquals("a", getCurrentLine()); assertEquals("bc", getClipboard()); }
public void testViMode() throws Exception { console.init(); console.on(KeyStrokes.a); assertEquals(Mode.EMACS, console.getMode()); console.on(Operation.VI_EDITING_MODE); driver.assertChar('a').assertFlush().assertEmpty(); assertEquals(Mode.VI_INSERT, console.getMode()); console.on(Operation.VI_MOVEMENT_MODE); driver.assertMoveLeft().assertFlush().assertEmpty(); assertEquals(Mode.VI_MOVE, console.getMode()); } }