Package org.zanata.webtrans.client.keys

Examples of org.zanata.webtrans.client.keys.KeyShortcut


    @Test
    public void testNextStateKeyHandler() {
        keyShortcuts.registerNavigationKeys(targetContentsPresenter);
        verify(keyShortcutPresenter, times(4)).register(
                keyShortcutCaptor.capture());
        KeyShortcut nextState = keyShortcutCaptor.getAllValues().get(2);
        ArgumentCaptor<NavTransUnitEvent> eventCaptor =
                ArgumentCaptor.forClass(NavTransUnitEvent.class);

        nextState.getHandler().onKeyShortcut(null);

        verify(targetContentsPresenter).savePendingChangesIfApplicable();
        verify(eventBus).fireEvent(eventCaptor.capture());
        assertThat(eventCaptor.getValue().getRowType(),
                Matchers.equalTo(NavTransUnitEvent.NavigationType.NextState));
View Full Code Here


    @Test
    public void testPreviousStateKeyHandler() {
        keyShortcuts.registerNavigationKeys(targetContentsPresenter);
        verify(keyShortcutPresenter, times(4)).register(
                keyShortcutCaptor.capture());
        KeyShortcut prevState = keyShortcutCaptor.getAllValues().get(3);
        ArgumentCaptor<NavTransUnitEvent> eventCaptor =
                ArgumentCaptor.forClass(NavTransUnitEvent.class);

        prevState.getHandler().onKeyShortcut(null);

        verify(targetContentsPresenter).savePendingChangesIfApplicable();
        verify(eventBus).fireEvent(eventCaptor.capture());
        assertThat(eventCaptor.getValue().getRowType(),
                Matchers.equalTo(NavTransUnitEvent.NavigationType.PrevState));
View Full Code Here

    @Test
    public void testSaveFuzzyKeyHandler() {
        keyShortcuts.registerEditorActionKeys(targetContentsPresenter);
        verify(keyShortcutPresenter, atLeastOnce()).register(
                keyShortcutCaptor.capture());
        KeyShortcut keys = keyShortcutCaptor.getAllValues().get(0);

        keys.getHandler().onKeyShortcut(null);

        verify(targetContentsPresenter).saveAsFuzzy(
                targetContentsPresenter.getCurrentTransUnitIdOrNull());
    }
View Full Code Here

    @Test
    public void testSaveApprovedKeyHandler() {
        keyShortcuts.registerEditorActionKeys(targetContentsPresenter);
        verify(keyShortcutPresenter, atLeastOnce()).register(
                keyShortcutCaptor.capture());
        KeyShortcut keys = keyShortcutCaptor.getAllValues().get(1);

        keys.getHandler().onKeyShortcut(null);

        verify(targetContentsPresenter).checkConfirmationBeforeSave();
    }
View Full Code Here

    @Test
    public void testCopySourceKeyHandler() {
        keyShortcuts.registerEditorActionKeys(targetContentsPresenter);
        verify(keyShortcutPresenter, atLeastOnce()).register(
                keyShortcutCaptor.capture());
        KeyShortcut keys = keyShortcutCaptor.getAllValues().get(2);

        keys.getHandler().onKeyShortcut(null);

        verify(targetContentsPresenter).copySourceForActiveRow();
    }
View Full Code Here

    public void testEnterSaveKeyHandler() {
        configHolder.setEnterSavesApproved(true);
        keyShortcuts.registerEditorActionKeys(targetContentsPresenter);
        verify(keyShortcutPresenter, atLeastOnce()).register(
                keyShortcutCaptor.capture());
        KeyShortcut keys = keyShortcutCaptor.getAllValues().get(2);

        keys.getHandler().onKeyShortcut(null);

        verify(targetContentsPresenter).checkConfirmationBeforeSave();
    }
View Full Code Here

        // Then:
        verify(keyShortcutPresenter, atLeastOnce()).register(
                keyShortcutCaptor.capture());
        List<KeyShortcut> allKeys = keyShortcutCaptor.getAllValues();
        KeyShortcut shortcut = allKeys.get(allKeys.size() - 1); // last key

        assertKeys(shortcut, "enter save as approved", true, true, new Keys(
                Keys.NO_MODIFIER, KeyCodes.KEY_ENTER));
    }
View Full Code Here

        // Then:
        verify(keyShortcutPresenter, atLeastOnce()).register(
                keyShortcutCaptor.capture());
        List<KeyShortcut> allKeys = keyShortcutCaptor.getAllValues();
        KeyShortcut nextState = allKeys.get(2);
        KeyShortcut prevState = allKeys.get(3);

        assertThat(nextState.getDescription(), Matchers.equalTo("next fuzzy"));
        assertThat(prevState.getDescription(), Matchers.equalTo("prev fuzzy"));
    }
View Full Code Here

        verify(keyShortcutPresenter, times(3)).register(
                keyShortcutCaptor.capture());
        List<KeyShortcut> shortcuts = keyShortcutCaptor.getAllValues();

        // testing keys
        KeyShortcut docListKey = shortcuts.get(0);
        assertThat(docListKey.getAllKeys(),
                Matchers.contains(new Keys(Keys.ALT_KEY, 'L')));
        assertThat(docListKey.getDescription(), Matchers.equalTo("doc list"));
        assertThat(docListKey.getContext(),
                Matchers.equalTo(ShortcutContext.Application));

        KeyShortcut editorKey = shortcuts.get(1);
        assertThat(editorKey.getAllKeys(),
                Matchers.contains(new Keys(Keys.ALT_KEY, 'O')));
        assertThat(editorKey.getDescription(), Matchers.equalTo("editor"));
        assertThat(editorKey.getContext(),
                Matchers.equalTo(ShortcutContext.Application));

        KeyShortcut searchKey = shortcuts.get(2);
        assertThat(searchKey.getAllKeys(),
                Matchers.contains(new Keys(Keys.ALT_KEY, 'P')));
        assertThat(searchKey.getDescription(),
                Matchers.equalTo("project wide search"));
        assertThat(searchKey.getContext(),
                Matchers.equalTo(ShortcutContext.Application));
    }
View Full Code Here

        verify(keyShortcutPresenter, times(3)).register(
                keyShortcutCaptor.capture());
        List<KeyShortcut> shortcuts = keyShortcutCaptor.getAllValues();

        // testing keys
        KeyShortcut docListKey = shortcuts.get(0);
        KeyShortcut editorKey = shortcuts.get(1);
        KeyShortcut searchKey = shortcuts.get(2);

        // testing handlers
        // doc key handler
        HistoryToken docToken = new HistoryToken();
        when(history.getHistoryToken()).thenReturn(docToken);
        docListKey.getHandler().onKeyShortcut(null);
        assertThat(docToken.getView(), Matchers.is(MainView.Documents));
        verify(history).newItem(docToken.toTokenString());

        // editor key handler on selected doc is null
        when(messages.noDocumentSelected()).thenReturn("no doc selected");
        editorKey.getHandler().onKeyShortcut(null);
        verify(eventBus).fireEvent(isA(NotificationEvent.class));

        // editor key handler on selected doc is NOT null
        HistoryToken editorToken = new HistoryToken();
        when(history.getHistoryToken()).thenReturn(editorToken);
        DocumentInfo selectedDocument = mock(DocumentInfo.class);
        presenter.setStatesForTest(null, null, MainView.Documents,
                selectedDocument);
        editorKey.getHandler().onKeyShortcut(null);
        assertThat(editorToken.getView(), Matchers.is(MainView.Editor));
        verify(history).newItem(editorToken.toTokenString());

        // search key handler
        HistoryToken searchToken = new HistoryToken();
        when(history.getHistoryToken()).thenReturn(searchToken);
        searchKey.getHandler().onKeyShortcut(null);
        assertThat(searchToken.getView(), Matchers.is(MainView.Search));
        verify(history).newItem(searchToken.toTokenString());
    }
View Full Code Here

TOP

Related Classes of org.zanata.webtrans.client.keys.KeyShortcut

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.