KeyboardFaceSource implements FaceReactionSource { public boolean onKeyDown(int keyCode) { if (sameKeyCodeIsTriggered(keyCode)) { return false; } FaceExpression faceExpression = mappings.getFaceFromKeyCode(keyCode); if (faceExpression != null) { currentExpression = faceExpression; faceListener.onNewFace(faceExpression); return true; } currentExpression = NEUTRAL_EXPRESSION; return false; } KeyboardFaceSource(FaceTracker.FaceListener faceListener, KeyToFaceMappings mappings); boolean onKeyDown(int keyCode); boolean onKeyUp(int keyCode); @Override void start(); @Override void release();  }
@Test public void whenKeySadIsPressed_thenSadExpressionIsTriggered() { source.onKeyDown(CODE_SAD); verify(mockListener).onNewFace(FaceExpression.SAD); }
@Test public void whenUnsupportedKeyIsPressed_thenNoCallbacksAreTriggered() { source.onKeyDown(1337); verify(mockListener, times(0)).onNewFace(any(FaceExpression.class)); }