HasWorkspaceChatData.MESSAGE_TYPE.SYSTEM_WARNING);
}
@Test
public void testKeyShortcut() {
Person person = TestFixture.person();
WorkspaceUsersPresenter spyPresenter = Mockito.spy(presenter);
doNothing().when(spyPresenter).dispatchChatAction(
person.getId().toString(), "hello",
HasWorkspaceChatData.MESSAGE_TYPE.USER_MSG);
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);
}