コード例 #1
0
  @Test
  public void testRegisterEditorActionKeys() {
    // by default user config settings
    when(messages.saveAsFuzzy()).thenReturn("save fuzzy");
    when(messages.saveAsTranslated()).thenReturn("save approved");
    when(messages.copyFromSource()).thenReturn("copy from source");
    when(messages.switchBetweenEditor()).thenReturn("switch editor");

    keyShortcuts.registerEditorActionKeys(targetContentsPresenter);

    verify(keyShortcutPresenter, times(4)).register(keyShortcutCaptor.capture());
    List<KeyShortcut> keys = keyShortcutCaptor.getAllValues();
    assertKeys(keys.get(0), "save fuzzy", true, true, new Keys(Keys.CTRL_KEY, 'S'));
    assertKeys(
        keys.get(1), "save approved", true, true, new Keys(Keys.CTRL_KEY, KeyCodes.KEY_ENTER));
    assertKeys(keys.get(2), "copy from source", true, true, new Keys(Keys.ALT_KEY, 'G'));
    assertAttentionKeys(keys.get(2), new Keys('G'));
    assertKeys(keys.get(3), "switch editor", true, true, new Keys(Keys.CTRL_ALT_KEYS, 'H'));
  }
コード例 #2
0
  @Test
  public void registerEditorActionKeysAfterChangeUserConfig() {
    // enter and esc now active
    when(messages.saveAsFuzzy()).thenReturn("save fuzzy");
    when(messages.saveAsTranslated()).thenReturn("save approved");
    when(messages.copyFromSource()).thenReturn("copy from source");
    when(messages.switchBetweenEditor()).thenReturn("switch editor");

    configHolder.setEnterSavesApproved(true);

    keyShortcuts.registerEditorActionKeys(targetContentsPresenter);

    verify(keyShortcutPresenter, times(5)).register(keyShortcutCaptor.capture());
    List<KeyShortcut> keys = keyShortcutCaptor.getAllValues();
    assertKeys(keys.get(0), "save fuzzy", true, true, new Keys(Keys.CTRL_KEY, 'S'));
    assertKeys(
        keys.get(1), "save approved", true, true, new Keys(Keys.CTRL_KEY, KeyCodes.KEY_ENTER));
    assertKeys(
        keys.get(2), "save approved", true, true, new Keys(Keys.NO_MODIFIER, KeyCodes.KEY_ENTER));
    assertKeys(keys.get(3), "copy from source", true, true, new Keys(Keys.ALT_KEY, 'G'));
    assertAttentionKeys(keys.get(3), new Keys('G'));
    assertKeys(keys.get(4), "switch editor", true, true, new Keys(Keys.CTRL_ALT_KEYS, 'H'));
  }