Skip to content

Commit

Permalink
Merge b66d04f into 2389ec9
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheikah45 committed Nov 10, 2020
2 parents 2389ec9 + b66d04f commit b69aafd
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private String getSimModsLabelContent(ObservableMap<String, String> simMods) {
.collect(Collectors.toList());

if (simMods.size() > 2) {
return i18n.get("game.mods.twoAndMore", modNames.get(0), modNames.size());
return i18n.get("game.mods.twoAndMore", modNames.get(0), modNames.get(1), simMods.size() - 2);
}
return Joiner.on(i18n.get("textSeparator")).join(modNames);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ game.join.passwordWrong=Incorrect password
game.start.couldNotStart=The game could not be started. See error details below.
game.full=Game is full
game.full.action=Click to open game
game.mods.twoAndMore={0} and {1,number,#} more
game.mods.twoAndMore={0}, {1} and {2,number,#} more
game.gameStatus=Game status
game.gameStatus.playing=Playing
game.gameStatus.hosting=Hosting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@
import com.faforever.client.mod.ModService;
import com.faforever.client.player.PlayerService;
import com.faforever.client.test.AbstractPlainJavaFxTest;
import com.faforever.client.theme.UiService;
import javafx.collections.FXCollections;
import javafx.scene.input.MouseButton;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.testfx.util.WaitForAsyncUtils;

import java.util.HashMap;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.contains;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -54,20 +58,47 @@ public void setUp() throws Exception {
loadFxml("theme/play/game_card.fxml", clazz -> instance);

instance.setOnSelectedListener(onSelectedConsumer);
instance.setGame(game);
}

@Test
public void testOnLeftDoubleClick() {
instance.setGame(game);
instance.onClick(MouseEvents.generateClick(MouseButton.PRIMARY, 2));
verify(joinGameHelper).join(any());
verify(onSelectedConsumer).accept(game);
}

@Test
public void testOnLeftSingleClick() {
instance.setGame(game);
instance.onClick(MouseEvents.generateClick(MouseButton.PRIMARY, 1));
verify(joinGameHelper, never()).join(any());
verify(onSelectedConsumer).accept(game);
}

@Test
public void testSimModeLabel4Mods() {
HashMap<String, String> simMods = new HashMap<>();
simMods.put("test1", "test1");
simMods.put("test2", "test2");
simMods.put("test3", "test3");
simMods.put("test4", "test4");
game.setSimMods(FXCollections.observableMap(simMods));
instance.setGame(game);
WaitForAsyncUtils.waitForFxEvents();

verify(i18n).get(eq("game.mods.twoAndMore"), contains("test"), contains("test"), eq(2));
}

@Test
public void testSimModeLabel2Mods() {
HashMap<String, String> simMods = new HashMap<>();
simMods.put("test1", "test1");
simMods.put("test2", "test2");
game.setSimMods(FXCollections.observableMap(simMods));
instance.setGame(game);
WaitForAsyncUtils.waitForFxEvents();

verify(i18n).get("textSeparator");
}
}

0 comments on commit b69aafd

Please sign in to comment.