diff options
Diffstat (limited to 'test/jrummikub')
-rw-r--r-- | test/jrummikub/control/network/NetworkControlTest.java | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/test/jrummikub/control/network/NetworkControlTest.java b/test/jrummikub/control/network/NetworkControlTest.java index 2be4da0..6d772ff 100644 --- a/test/jrummikub/control/network/NetworkControlTest.java +++ b/test/jrummikub/control/network/NetworkControlTest.java @@ -5,6 +5,7 @@ import static org.junit.Assert.*; import java.awt.Color; import java.util.UUID; +import jrummikub.control.SaveControl; import jrummikub.model.GameSettings; import jrummikub.model.PlayerSettings; import jrummikub.model.PlayerSettings.Type; @@ -35,7 +36,7 @@ public class NetworkControlTest { mockConnection.nickname = "Karl"; view = new MockView(); loginData = new LoginData("Karl", "server", "password", "channel"); - networkControl = new NetworkControl(loginData, mockConnection, null, view); + networkControl = new NetworkControl(loginData, mockConnection, new SaveControl(view), view); networkControl.startNetwork(); } @@ -77,6 +78,7 @@ public class NetworkControlTest { assertTrue(view.isSettingsPanelVisible); assertEquals(SettingsMode.NETWORK_OFFER, view.settingsPanel.settingsMode); + assertNotNull(mockConnection.offeredGame); } /** */ @@ -117,6 +119,30 @@ public class NetworkControlTest { /** */ @Test + public void disconnectedGameTest() { + mockConnection.connectedEvent.emit(); + offerTestGame(id1, "Berta"); + + offerTestGame(id2, "Horst"); + + assertEquals(2, view.gameListPanel.gameList.size()); + assertEquals(2, view.gameListPanel.gameList.get(0).getGameSettings() + .getPlayerList().size()); + assertEquals(id1, view.gameListPanel.gameList.get(0).getGameID()); + assertEquals("Berta", view.gameListPanel.gameList.get(0).getHost()); + assertEquals(2, view.gameListPanel.gameList.get(1).getGameSettings() + .getPlayerList().size()); + assertEquals(id2, view.gameListPanel.gameList.get(1).getGameID()); + assertEquals("Horst", view.gameListPanel.gameList.get(1).getHost()); + + mockConnection.participantLeftEvent.emit("Berta"); + assertEquals(1, view.gameListPanel.gameList.size()); + assertEquals(id2, view.gameListPanel.gameList.get(0).getGameID()); + assertEquals("Horst", view.gameListPanel.gameList.get(0).getHost()); + } + + /** */ + @Test public void testCancel() { mockConnection.connectedEvent.emit(); @@ -138,4 +164,23 @@ public class NetworkControlTest { return gameData; } + /** */ + @Test + public void testStartGame() { + mockConnection.connectedEvent.emit(); + + view.gameListPanel.openNewGameEvent.emit(); + + assertTrue(view.isSettingsPanelVisible); + assertEquals(SettingsMode.NETWORK_SETUP, + view.settingsPanel.settingsMode); + + view.settingsPanel.offerGameEvent.emit(); + + mockConnection.gameJoinEvent.emit("Blubb"); + + view.settingsPanel.startGameEvent.emit(); + + assertTrue(mockConnection.startRoundCalled); + } } |