use of com.ichi2.anki.cardviewer.ViewerCommand in project Anki-Android by ankidroid.
the class PeripheralKeymapTest method flagAndAnswerDoNotConflict.
@Test
public void flagAndAnswerDoNotConflict() {
List<ViewerCommand> processed = new ArrayList<>();
PeripheralKeymap peripheralKeymap = new PeripheralKeymap(new MockReviewerUi(), processed::add);
peripheralKeymap.setup(mock(SharedPreferences.class));
KeyEvent event = mock(KeyEvent.class);
when(event.getUnicodeChar()).thenReturn(0);
when(event.isCtrlPressed()).thenReturn(true);
when(event.getUnicodeChar(0)).thenReturn(49);
when(event.getKeyCode()).thenReturn(KeyEvent.KEYCODE_1);
assertThat((char) event.getUnicodeChar(), is('\0'));
assertThat((char) event.getUnicodeChar(0), is('1'));
peripheralKeymap.onKeyDown(KeyEvent.KEYCODE_1, event);
assertThat(processed, hasSize(1));
assertThat(processed.get(0), is(ViewerCommand.COMMAND_TOGGLE_FLAG_RED));
}
Aggregations