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());
}
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()));
}
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();
}
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);
}
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()));
}
Aggregations