Package org.zanata.webtrans.client.keys

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


        verify(display).setListener(presenter);
        verify(eventBus).addHandler(CommentBeforeSaveEvent.TYPE, presenter);
        verify(keyShortcutPresenter).register(shortcutCapture.capture());

        KeyShortcut keyShortcut = shortcutCapture.getValue();
        assertThat(keyShortcut.getContext(),
                Matchers.equalTo(ShortcutContext.RejectConfirmationPopup));
    }
View Full Code Here


        when(messages.publishChatContent()).thenReturn("publish chat");
        spyPresenter.onBind();
        verify(keyShortcutPresenter).register(keyShortcutCaptor.capture());

        // key is 'enter', context is Chat, description is publish chat
        KeyShortcut keyShortcut = keyShortcutCaptor.getValue();
        assertThat(keyShortcut.getAllKeys(), Matchers.hasSize(1));
        Keys keys = keyShortcut.getAllKeys().iterator().next();
        assertThat(keys.getModifiers(), Matchers.equalTo(Keys.NO_MODIFIER));
        assertThat(keys.getKeyCode(), Matchers.equalTo(KeyCodes.KEY_ENTER));
        assertThat(keyShortcut.getDescription(),
                Matchers.equalTo("publish chat"));
        assertThat(keyShortcut.getContext(),
                Matchers.equalTo(ShortcutContext.Chat));

        // key handler
        when(identity.getPerson()).thenReturn(person);
        when(display.getChatInputText()).thenReturn("hello");
        keyShortcut.getHandler().onKeyShortcut(new KeyShortcutEvent(keys));
        verify(spyPresenter).dispatchChatAction(person.getId().toString(),
                "hello", HasWorkspaceChatData.MESSAGE_TYPE.USER_MSG);
    }
View Full Code Here

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

        // test keys
        KeyShortcut prevKey = shortcuts.get(0);
        assertThat(prevKey.getAllKeys(), Matchers.equalTo(Keys.setOf(new Keys(
                Keys.ALT_KEY, KeyCodes.KEY_UP), new Keys(Keys.ALT_KEY, 'J'))));
        assertThat(prevKey.getDescription(), Matchers.equalTo("previous row"));
        assertThat(prevKey.getContext(),
                Matchers.equalTo(ShortcutContext.Navigation));
        assertThat(prevKey.getKeyEvent(),
                Matchers.equalTo(KeyShortcut.KeyEvent.KEY_DOWN));

        KeyShortcut nextKey = shortcuts.get(1);
        assertThat(nextKey.getAllKeys(), Matchers.equalTo(Keys.setOf(new Keys(
                Keys.ALT_KEY, KeyCodes.KEY_DOWN), new Keys(Keys.ALT_KEY, 'K'))));
        assertThat(nextKey.getDescription(), Matchers.equalTo("next row"));
        assertThat(nextKey.getContext(),
                Matchers.equalTo(ShortcutContext.Navigation));
        assertThat(nextKey.getKeyEvent(),
                Matchers.equalTo(KeyShortcut.KeyEvent.KEY_DOWN));

        KeyShortcut enterKey = shortcuts.get(2);
        assertThat(enterKey.getAllKeys(), Matchers.contains(new Keys(
                Keys.NO_MODIFIER, KeyCodes.KEY_ENTER)));
        assertThat(enterKey.getDescription(), Matchers.equalTo("open editor"));
        assertThat(enterKey.getContext(),
                Matchers.equalTo(ShortcutContext.Navigation));
        assertThat(enterKey.getKeyEvent(),
                Matchers.equalTo(KeyShortcut.KeyEvent.KEY_UP));

        // test key handlers
        prevKey.getHandler().onKeyShortcut(null);
        verify(targetContentsPresenter, atLeastOnce())
                .savePendingChangesIfApplicable();
        verify(eventBus).fireEvent(
                new NavTransUnitEvent(
                        NavTransUnitEvent.NavigationType.PrevEntry));

        nextKey.getHandler().onKeyShortcut(null);
        verify(targetContentsPresenter, atLeastOnce())
                .savePendingChangesIfApplicable();
        verify(eventBus).fireEvent(
                new NavTransUnitEvent(
                        NavTransUnitEvent.NavigationType.NextEntry));

        // by default all other presenters are not focused
        when(translationEditorPresenter.getDisplay()).thenReturn(
                translationEditorDisplay);
        enterKey.getHandler().onKeyShortcut(null);
        verify(targetContentsPresenter).setFocus();
        verify(targetContentsPresenter).revealDisplay();
    }
View Full Code Here

        doNothing().when(spyPresenter).fireSearchEvent();

        spyPresenter.onBind();

        verify(keyShortcutPresenter).register(keyShortcutCaptor.capture());
        KeyShortcut keyShortcut = keyShortcutCaptor.getValue();
        assertThat(keyShortcut.getAllKeys(),
                Matchers.containsInAnyOrder(new Keys(Keys.NO_MODIFIER,
                        KeyCodes.KEY_ENTER)));
        assertThat(keyShortcut.getContext(),
                Matchers.equalTo(ShortcutContext.Glossary));
        assertThat(keyShortcut.getDescription(),
                Matchers.equalTo("search glossary"));

        keyShortcut.getHandler().onKeyShortcut(null);
        verify(spyPresenter).fireSearchEvent();
    }
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.