Search in sources :

Example 1 with Game

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());
}
Also used : TransientNotification(com.faforever.client.notification.TransientNotification) Game(com.faforever.client.game.Game) FriendJoinedGameEvent(com.faforever.client.player.event.FriendJoinedGameEvent) Test(org.junit.Test)

Example 2 with Game

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()));
}
Also used : Game(com.faforever.client.game.Game) URIBuilder(org.apache.http.client.utils.URIBuilder)

Example 3 with Game

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);
}
Also used : SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Game(com.faforever.client.game.Game) ChatPrefs(com.faforever.client.preferences.ChatPrefs) AvatarBean(com.faforever.client.chat.avatar.AvatarBean) ObservableMap(javafx.collections.ObservableMap) Preferences(com.faforever.client.preferences.Preferences) URL(java.net.URL) Before(org.junit.Before)

Example 4 with Game

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);
}
Also used : Game(com.faforever.client.game.Game) GameFullEvent(com.faforever.client.fa.relay.event.GameFullEvent) Test(org.junit.Test)

Example 5 with Game

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));
}
Also used : TransientNotification(com.faforever.client.notification.TransientNotification) Game(com.faforever.client.game.Game) GameFullEvent(com.faforever.client.fa.relay.event.GameFullEvent) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Aggregations

Game (com.faforever.client.game.Game)10 I18n (com.faforever.client.i18n.I18n)4 TransientNotification (com.faforever.client.notification.TransientNotification)4 Inject (javax.inject.Inject)4 Component (org.springframework.stereotype.Component)4 GameFullEvent (com.faforever.client.fa.relay.event.GameFullEvent)3 GameService (com.faforever.client.game.GameService)3 MapService (com.faforever.client.map.MapService)3 PreviewSize (com.faforever.client.map.MapServiceImpl.PreviewSize)3 NotificationService (com.faforever.client.notification.NotificationService)3 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)3 Test (org.junit.Test)3 AbstractViewController (com.faforever.client.fx.AbstractViewController)2 NodeTableCell (com.faforever.client.fx.NodeTableCell)2 StringCell (com.faforever.client.fx.StringCell)2 PreferencesService (com.faforever.client.preferences.PreferencesService)2 GameStatus (com.faforever.client.remote.domain.GameStatus)2 UiService (com.faforever.client.theme.UiService)2 EventBus (com.google.common.eventbus.EventBus)2 Subscribe (com.google.common.eventbus.Subscribe)2