use of com.faforever.client.game.Game 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.game.Game in project downlords-faf-client by FAForever.
the class ReplayServiceImpl method runLiveReplay.
@Override
public void runLiveReplay(int gameId, int playerId) {
Game game = gameService.getByUid(gameId);
if (game == null) {
throw new RuntimeException("There's no game with ID: " + gameId);
}
URIBuilder uriBuilder = new URIBuilder();
uriBuilder.setScheme(FAF_LIFE_PROTOCOL);
// TODO check if this host is correct
uriBuilder.setHost(clientProperties.getReplay().getRemoteHost());
uriBuilder.setPath("/" + gameId + "/" + playerId + SUP_COM_REPLAY_FILE_ENDING);
uriBuilder.addParameter("map", UrlEscapers.urlFragmentEscaper().escape(game.getMapFolderName()));
uriBuilder.addParameter("mod", game.getFeaturedMod());
noCatch(() -> runLiveReplay(uriBuilder.build()));
}
use of com.faforever.client.game.Game in project downlords-faf-client by FAForever.
the class ChatUserContextMenuControllerTest method setUp.
@Before
public void setUp() throws Exception {
instance = new ChatUserContextMenuController(userService, chatService, preferencesService, playerService, gameService, replayService, notificationService, i18n, eventBus, joinGameHelper, avatarService, uiService);
Preferences preferences = mock(Preferences.class);
ChatPrefs chatPrefs = mock(ChatPrefs.class);
ObjectProperty<ChatColorMode> chatColorModeObjectProperty = new SimpleObjectProperty<>();
when(preferencesService.getPreferences()).thenReturn(preferences);
when(preferences.getChat()).thenReturn(chatPrefs);
when(chatPrefs.getUserToColor()).thenReturn(mock(ObservableMap.class));
when(chatPrefs.chatColorModeProperty()).thenReturn(chatColorModeObjectProperty);
when(avatarService.getAvailableAvatars()).thenReturn(CompletableFuture.completedFuture(Arrays.asList(new AvatarBean(new URL("http://www.example.com/avatar1.png"), "Avatar Number #1"), new AvatarBean(new URL("http://www.example.com/avatar2.png"), "Avatar Number #2"), new AvatarBean(new URL("http://www.example.com/avatar3.png"), "Avatar Number #3"))));
loadFxml("theme/chat/chat_user_context_menu.fxml", clazz -> instance);
player = PlayerBuilder.create(TEST_USER_NAME).socialStatus(SELF).avatar(null).game(new Game()).get();
instance.setPlayer(player);
}
use of com.faforever.client.game.Game in project downlords-faf-client by FAForever.
the class OnGameFullNotifierTest method testAlreadyFocusedDoesntTriggerNotification.
@Test
public void testAlreadyFocusedDoesntTriggerNotification() throws Exception {
Game game = GameBuilder.create().defaultValues().get();
when(gameService.getCurrentGame()).thenReturn(game);
when(platformService.isWindowFocused("Forged Alliance")).thenReturn(true);
instance.onGameFull(new GameFullEvent());
verifyZeroInteractions(notificationService);
}
use of com.faforever.client.game.Game in project downlords-faf-client by FAForever.
the class OnGameFullNotifierTest method testOnGameFull.
@Test
public void testOnGameFull() throws Exception {
Game game = GameBuilder.create().defaultValues().get();
when(gameService.getCurrentGame()).thenReturn(game);
when(platformService.isWindowFocused("Forged Alliance")).thenReturn(false);
CountDownLatch countDownLatch = new CountDownLatch(1);
doAnswer(invocation -> {
countDownLatch.countDown();
return null;
}).when(platformService).stopFlashingWindow("Forged Alliance");
instance.onGameFull(new GameFullEvent());
verify(notificationService).addNotification(any(TransientNotification.class));
verify(executor).execute(any(Runnable.class));
}
Aggregations