From 73c1072ba68b152aeb85aa71ae751f5d8afb3a68 Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Wed, 22 Jun 2011 10:38:11 +0200 Subject: Continued NetworkControlTest git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@592 72836036-5685-4462-b002-a69064685172 --- .../control/network/NetworkControlTest.java | 47 +++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'test') 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); } /** */ @@ -115,6 +117,30 @@ public class NetworkControlTest { assertEquals("Horst", view.gameListPanel.gameList.get(0).getHost()); } + /** */ + @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() { @@ -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); + } } -- cgit v1.2.3