use of com.faforever.client.player.event.FriendJoinedGameEvent in project downlords-faf-client by FAForever.
the class FriendJoinedGameNotifierTest method onFriendJoinedGame.
@Test
public void onFriendJoinedGame() throws Exception {
Game game = GameBuilder.create().defaultValues().title("My Game").get();
Player player = PlayerBuilder.create("junit").id(1).game(game).get();
when(notification.isFriendJoinsGameToastEnabled()).thenReturn(true);
when(i18n.get("friend.joinedGameNotification.title", "junit", "My Game")).thenReturn("junit joined My Game");
when(i18n.get("friend.joinedGameNotification.action")).thenReturn("Click to join");
instance.onFriendJoinedGame(new FriendJoinedGameEvent(player, game));
ArgumentCaptor<TransientNotification> captor = ArgumentCaptor.forClass(TransientNotification.class);
verify(notificationService).addNotification(captor.capture());
TransientNotification notification = captor.getValue();
assertThat(notification.getTitle(), is("junit joined My Game"));
assertThat(notification.getText(), is("Click to join"));
assertThat(notification.getImage(), notNullValue());
}
use of com.faforever.client.player.event.FriendJoinedGameEvent in project downlords-faf-client by FAForever.
the class FriendJoinedGameNotifier method onFriendJoinedGame.
@Subscribe
public void onFriendJoinedGame(FriendJoinedGameEvent event) {
Player player = event.getPlayer();
Game game = event.getGame();
audioService.playFriendJoinsGameSound();
if (preferencesService.getPreferences().getNotification().isFriendJoinsGameToastEnabled()) {
notificationService.addNotification(new TransientNotification(i18n.get("friend.joinedGameNotification.title", player.getUsername(), game.getTitle()), i18n.get("friend.joinedGameNotification.action"), IdenticonUtil.createIdenticon(player.getId()), event1 -> joinGameHelper.join(player.getGame())));
}
}
use of com.faforever.client.player.event.FriendJoinedGameEvent in project downlords-faf-client by FAForever.
the class FriendJoinedGameNotifierTest method testNoNotificationIfDisabledInPreferences.
@Test
public void testNoNotificationIfDisabledInPreferences() throws Exception {
when(notification.isFriendJoinsGameToastEnabled()).thenReturn(false);
instance.onFriendJoinedGame(new FriendJoinedGameEvent(PlayerBuilder.create("junit").get(), GameBuilder.create().get()));
verify(notificationService, never()).addNotification(any(TransientNotification.class));
}
Aggregations