HardwareKeyboardController implements KeyboardController { @Override public PeekingIterator<KeyEvent> getEvents() { return new KeyEventIterator(hardwareKeyboard); } HardwareKeyboardController(HardwareKeyboard hardwareKeyboard); @Override PeekingIterator<KeyEvent> getEvents();  }
@Test public void keyDownEvent() throws Exception { stubReturn(true).on(hardwareKeyboard).next(); stubReturn('A').on(hardwareKeyboard).eventCharacter(); stubReturn(30).on(hardwareKeyboard).eventKey(); stubReturn(true).on(hardwareKeyboard).eventKeyState(); final PeekingIterator<KeyEvent> events = hardwareKeyboardController.getEvents(); assertTrue(events.hasNext()); final KeyEvent keyEvent = events.next(); assertEquals(Key.A, keyEvent.key()); assertEquals('A', keyEvent.keyChar()); assertEquals(KeyState.DOWN, keyEvent.keyState()); }