use of com.faforever.client.player.Player in project downlords-faf-client by FAForever.
the class ChannelTabControllerTest method testOnUserJoinsChannel.
@Test
@SuppressWarnings("unchecked")
public void testOnUserJoinsChannel() throws Exception {
Channel channel = new Channel(CHANNEL_NAME);
instance.setChannel(channel);
ArgumentCaptor<MapChangeListener<String, ChatUser>> captor = ArgumentCaptor.forClass(MapChangeListener.class);
verify(chatService).addUsersListener(anyString(), captor.capture());
ChatUser chatUser = new ChatUser("junit", null);
ObservableMap<String, ChatUser> userMap = FXCollections.observableHashMap();
userMap.put("junit", chatUser);
Change<String, ChatUser> change = mock(Change.class);
when(change.wasAdded()).thenReturn(true);
when(change.getValueAdded()).thenReturn(chatUser);
when(change.getMap()).thenReturn(userMap);
Player player = PlayerBuilder.create("Hans").defaultValues().get();
when(playerService.createAndGetPlayerForUsername("junit")).thenReturn(player);
when(i18n.get("chat.userCount", 1)).thenReturn("1 Players");
when(chatUserItemController.getPlayer()).thenReturn(player);
// Actual test execution
captor.getValue().onChanged(change);
WaitForAsyncUtils.waitForFxEvents();
assertThat(player.usernameProperty().isBound(), is(true));
assertThat(player.getUsername(), is("junit"));
assertThat(instance.userSearchTextField.getPromptText(), is("1 Players"));
}
use of com.faforever.client.player.Player in project downlords-faf-client by FAForever.
the class ChannelTabControllerTest method testGetMessageCssClassModerator.
@Test
public void testGetMessageCssClassModerator() throws Exception {
Channel channel = new Channel(CHANNEL_NAME);
String playerName = "junit";
Player player = new Player(playerName);
player.moderatorForChannelsProperty().set(FXCollections.observableSet(CHANNEL_NAME));
instance.setChannel(channel);
when(playerService.getPlayerForUsername(playerName)).thenReturn(player);
assertEquals(instance.getMessageCssClass(playerName), ChannelTabController.CSS_CLASS_MODERATOR);
}
use of com.faforever.client.player.Player in project downlords-faf-client by FAForever.
the class ChatUserContextMenuControllerTest method testHideUserInfoOnIdBeingNull.
@Test
public void testHideUserInfoOnIdBeingNull() {
Player player = PlayerBuilder.create("xyz").get();
instance.setPlayer(player);
assertThat(instance.showUserInfo.isVisible(), is(false));
}
use of com.faforever.client.player.Player in project downlords-faf-client by FAForever.
the class PrivateChatTabControllerTest method setUp.
@Before
public void setUp() throws IOException {
Vault vault = new Vault();
vault.setReplayDownloadUrlFormat("test.de");
when(clientProperties.getVault()).thenReturn(vault);
PreferencesService preferencesService = new PreferencesService();
preferencesService.postConstruct();
preferencesService.getPreferences().getMainWindow().setLastView(NavigationItem.CHAT.name());
instance = new PrivateChatTabController(clanService, userService, platformService, preferencesService, playerService, timeService, i18n, imageUploadService, urlPreviewResolver, notificationService, reportingService, uiService, autoCompletionHelper, eventBus, audioService, chatService, mapService, webViewConfigurer, countryFlagService, replayService, clientProperties, externalReplayInfoGenerator);
playerName = "testUser";
Player player = new Player(playerName);
when(playerService.getPlayerForUsername(playerName)).thenReturn(player);
when(userService.getUsername()).thenReturn(playerName);
when(uiService.getThemeFileUrl(CHAT_CONTAINER)).then(invocation -> getThemeFileUrl(invocation.getArgument(0)));
TabPane tabPane = new TabPane();
tabPane.setSkin(new TabPaneSkin(tabPane));
loadFxml("theme/chat/private_chat_tab.fxml", clazz -> {
if (clazz == PrivateUserInfoController.class) {
return privateUserInfoController;
}
if (clazz == GameDetailController.class) {
return gameDetailController;
}
if (clazz == WatchButtonController.class) {
return watchButtonController;
}
return instance;
});
instance.setReceiver(playerName);
WaitForAsyncUtils.asyncFx(() -> {
getRoot().getChildren().setAll(tabPane);
tabPane.getTabs().add(instance.getRoot());
});
WaitForAsyncUtils.waitForFxEvents();
verify(webViewConfigurer).configureWebView(instance.messagesWebView);
}
use of com.faforever.client.player.Player in project downlords-faf-client by FAForever.
the class PircBotXChatServiceTest method testSuppressFoeMessage.
@Test
public void testSuppressFoeMessage() throws Exception {
String message = "private message";
preferences.getChat().setHideFoeMessages(true);
User user = mock(User.class);
when(user.getNick()).thenReturn(chatUser1.getUsername());
Player playerMock = mock(Player.class);
when(playerService.getPlayerForUsername(chatUser1.getUsername())).thenReturn(playerMock);
when(playerMock.getSocialStatus()).thenReturn(SocialStatus.FOE);
connect();
firePircBotXEvent(createPrivateMessageEvent(user, message));
verify(eventBus, never()).post(any(Object.class));
}
Aggregations