Search in sources :

Example 6 with GameLaunchMessage

use of com.faforever.client.remote.domain.GameLaunchMessage in project downlords-faf-client by FAForever.

the class GameServiceImplTest method testAddOnGameStartedListener.

@Test
@SuppressWarnings("unchecked")
public void testAddOnGameStartedListener() throws Exception {
    Process process = mock(Process.class);
    NewGameInfo newGameInfo = NewGameInfoBuilder.create().defaultValues().get();
    GameLaunchMessage gameLaunchMessage = GameLaunchMessageBuilder.create().defaultValues().get();
    gameLaunchMessage.setArgs(asList("/foo bar", "/bar foo"));
    when(forgedAllianceService.startGame(gameLaunchMessage.getUid(), null, asList("/foo", "bar", "/bar", "foo"), GLOBAL, GPG_PORT, LOCAL_REPLAY_PORT, false, junitPlayer)).thenReturn(process);
    when(gameUpdater.update(any(), any(), any(), any())).thenReturn(completedFuture(null));
    when(fafService.requestHostGame(newGameInfo)).thenReturn(completedFuture(gameLaunchMessage));
    when(mapService.download(newGameInfo.getMap())).thenReturn(CompletableFuture.completedFuture(null));
    CountDownLatch gameStartedLatch = new CountDownLatch(1);
    CountDownLatch gameTerminatedLatch = new CountDownLatch(1);
    instance.gameRunningProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue) {
            gameStartedLatch.countDown();
        } else {
            gameTerminatedLatch.countDown();
        }
    });
    CountDownLatch processLatch = new CountDownLatch(1);
    instance.hostGame(newGameInfo).toCompletableFuture().get(TIMEOUT, TIME_UNIT);
    gameStartedLatch.await(TIMEOUT, TIME_UNIT);
    processLatch.countDown();
    gameTerminatedLatch.await(TIMEOUT, TIME_UNIT);
    verify(forgedAllianceService).startGame(gameLaunchMessage.getUid(), null, asList("/foo", "bar", "/bar", "foo"), GLOBAL, GPG_PORT, LOCAL_REPLAY_PORT, false, junitPlayer);
    verify(replayService).startReplayServer(gameLaunchMessage.getUid());
}
Also used : CountDownLatch(java.util.concurrent.CountDownLatch) GameLaunchMessage(com.faforever.client.remote.domain.GameLaunchMessage) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Example 7 with GameLaunchMessage

use of com.faforever.client.remote.domain.GameLaunchMessage in project downlords-faf-client by FAForever.

the class GameServiceImplTest method testStartSearchLadder1v1.

@Test
public void testStartSearchLadder1v1() throws Exception {
    GameLaunchMessage gameLaunchMessage = new GameLaunchMessage();
    gameLaunchMessage.setMod("ladder1v1");
    gameLaunchMessage.setUid(123);
    gameLaunchMessage.setArgs(emptyList());
    gameLaunchMessage.setMapname("scmp_037");
    FeaturedMod featuredMod = FeaturedModBeanBuilder.create().defaultValues().get();
    when(fafService.startSearchLadder1v1(CYBRAN, GAME_PORT)).thenReturn(CompletableFuture.completedFuture(gameLaunchMessage));
    when(gameUpdater.update(featuredMod, null, Collections.emptyMap(), Collections.emptySet())).thenReturn(CompletableFuture.completedFuture(null));
    when(mapService.isInstalled("scmp_037")).thenReturn(false);
    when(mapService.download("scmp_037")).thenReturn(CompletableFuture.completedFuture(null));
    when(modService.getFeaturedMod(LADDER_1V1.getTechnicalName())).thenReturn(CompletableFuture.completedFuture(featuredMod));
    CompletableFuture<Void> future = instance.startSearchLadder1v1(CYBRAN).toCompletableFuture();
    verify(fafService).startSearchLadder1v1(CYBRAN, GAME_PORT);
    verify(mapService).download("scmp_037");
    verify(replayService).startReplayServer(123);
    verify(forgedAllianceService, timeout(100)).startGame(eq(123), eq(CYBRAN), eq(asList("/team", "1", "/players", "2")), eq(RatingMode.LADDER_1V1), anyInt(), eq(LOCAL_REPLAY_PORT), eq(false), eq(junitPlayer));
    assertThat(future.get(TIMEOUT, TIME_UNIT), is(nullValue()));
}
Also used : FeaturedMod(com.faforever.client.mod.FeaturedMod) GameLaunchMessage(com.faforever.client.remote.domain.GameLaunchMessage) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Example 8 with GameLaunchMessage

use of com.faforever.client.remote.domain.GameLaunchMessage in project downlords-faf-client by FAForever.

the class MockFafServerAccessor method requestJoinGame.

@Override
public CompletableFuture<GameLaunchMessage> requestJoinGame(int gameId, String password) {
    return taskService.submitTask(new CompletableTask<GameLaunchMessage>(HIGH) {

        @Override
        protected GameLaunchMessage call() throws Exception {
            updateTitle("Joining game");
            GameLaunchMessage gameLaunchMessage = new GameLaunchMessage();
            gameLaunchMessage.setArgs(Arrays.asList("/ratingcolor d8d8d8d8", "/numgames 1234"));
            gameLaunchMessage.setMod("faf");
            gameLaunchMessage.setUid(1234);
            return gameLaunchMessage;
        }
    }).getFuture();
}
Also used : CompletableTask(com.faforever.client.task.CompletableTask) GameLaunchMessage(com.faforever.client.remote.domain.GameLaunchMessage)

Example 9 with GameLaunchMessage

use of com.faforever.client.remote.domain.GameLaunchMessage in project downlords-faf-client by FAForever.

the class MockFafServerAccessor method startSearchLadder1v1.

@Override
public CompletableFuture<GameLaunchMessage> startSearchLadder1v1(Faction faction) {
    logger.debug("Searching 1v1 match with faction: {}", faction);
    GameLaunchMessage gameLaunchMessage = new GameLaunchMessage();
    gameLaunchMessage.setUid(123);
    gameLaunchMessage.setMod(KnownFeaturedMod.DEFAULT.getTechnicalName());
    return CompletableFuture.completedFuture(gameLaunchMessage);
}
Also used : GameLaunchMessage(com.faforever.client.remote.domain.GameLaunchMessage)

Example 10 with GameLaunchMessage

use of com.faforever.client.remote.domain.GameLaunchMessage in project downlords-faf-client by FAForever.

the class ServerAccessorImplTest method startSearchLadder1v1WithAeon.

@Test
public void startSearchLadder1v1WithAeon() throws Exception {
    connectAndLogIn();
    CompletableFuture<GameLaunchMessage> future = instance.startSearchLadder1v1(Faction.AEON).toCompletableFuture();
    String clientMessage = messagesReceivedByFafServer.poll(TIMEOUT, TIMEOUT_UNIT);
    SearchLadder1v1ClientMessage searchRanked1v1Message = gson.fromJson(clientMessage, SearchLadder1v1ClientMessage.class);
    assertThat(searchRanked1v1Message, instanceOf(SearchLadder1v1ClientMessage.class));
    assertThat(searchRanked1v1Message.getFaction(), is(Faction.AEON));
    GameLaunchMessage gameLaunchMessage = new GameLaunchMessage();
    gameLaunchMessage.setUid(1234);
    sendFromServer(gameLaunchMessage);
    assertThat(future.get(TIMEOUT, TIMEOUT_UNIT).getUid(), is(gameLaunchMessage.getUid()));
}
Also used : SearchLadder1v1ClientMessage(com.faforever.client.rankedmatch.SearchLadder1v1ClientMessage) StopSearchLadder1v1ClientMessage(com.faforever.client.rankedmatch.StopSearchLadder1v1ClientMessage) GameLaunchMessage(com.faforever.client.remote.domain.GameLaunchMessage) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Aggregations

GameLaunchMessage (com.faforever.client.remote.domain.GameLaunchMessage)10 AbstractPlainJavaFxTest (com.faforever.client.test.AbstractPlainJavaFxTest)6 Test (org.junit.Test)6 FeaturedMod (com.faforever.client.mod.FeaturedMod)2 CompletableTask (com.faforever.client.task.CompletableTask)2 ClientProperties (com.faforever.client.config.ClientProperties)1 ForgedAllianceService (com.faforever.client.fa.ForgedAllianceService)1 RatingMode (com.faforever.client.fa.RatingMode)1 NONE (com.faforever.client.fa.RatingMode.NONE)1 RehostRequestEvent (com.faforever.client.fa.relay.event.RehostRequestEvent)1 IceAdapter (com.faforever.client.fa.relay.ice.IceAdapter)1 JavaFxUtil (com.faforever.client.fx.JavaFxUtil)1 PlatformService (com.faforever.client.fx.PlatformService)1 LADDER_1V1 (com.faforever.client.game.KnownFeaturedMod.LADDER_1V1)1 I18n (com.faforever.client.i18n.I18n)1 MapService (com.faforever.client.map.MapService)1 ModService (com.faforever.client.mod.ModService)1 ConnectionState (com.faforever.client.net.ConnectionState)1 Action (com.faforever.client.notification.Action)1 DismissAction (com.faforever.client.notification.DismissAction)1