diff options
author | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-06-22 10:38:11 +0200 |
---|---|---|
committer | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-06-22 10:38:11 +0200 |
commit | 73c1072ba68b152aeb85aa71ae751f5d8afb3a68 (patch) | |
tree | 4af4993084fbb33fedac67202adb25003d4f1380 /test/jrummikub/control | |
parent | f5aa073827980bdae3e530b6ea9d8c17807ad764 (diff) | |
download | JRummikub-73c1072ba68b152aeb85aa71ae751f5d8afb3a68.tar JRummikub-73c1072ba68b152aeb85aa71ae751f5d8afb3a68.zip |
Continued NetworkControlTest
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@592 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test/jrummikub/control')
-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); + } } |