summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJannis Harder <harder@informatik.uni-luebeck.de>2011-06-22 11:38:04 +0200
committerJannis Harder <harder@informatik.uni-luebeck.de>2011-06-22 11:38:04 +0200
commit12e48f3d29c15a2f6aa333205fedce1dfa41f04b (patch)
treed40fd247498222e1b8001ce1560a2c1880628241 /test
parent65e08c508cd608ea73058bbc5c79407d00bb261c (diff)
downloadJRummikub-12e48f3d29c15a2f6aa333205fedce1dfa41f04b.tar
JRummikub-12e48f3d29c15a2f6aa333205fedce1dfa41f04b.zip
NetworkGameControlTests
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@595 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test')
-rw-r--r--test/jrummikub/control/network/NetworkGameControlTest.java78
1 files changed, 78 insertions, 0 deletions
diff --git a/test/jrummikub/control/network/NetworkGameControlTest.java b/test/jrummikub/control/network/NetworkGameControlTest.java
new file mode 100644
index 0000000..ea0dabe
--- /dev/null
+++ b/test/jrummikub/control/network/NetworkGameControlTest.java
@@ -0,0 +1,78 @@
+package jrummikub.control.network;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.awt.Color;
+
+import jrummikub.control.SaveControl;
+import jrummikub.model.GameSettings;
+import jrummikub.model.PlayerSettings;
+import jrummikub.util.IListener;
+import jrummikub.view.IView.BottomPanelType;
+import jrummikub.view.MockView;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests for the network game control
+ */
+public class NetworkGameControlTest {
+
+ public NetworkGameControl hostControl, clientControl;
+ public GameSettings settings;
+ public MockView view;
+ public MockConnectionControl connection;
+ public boolean fired;
+
+ /** */
+ @Before
+ public void setUp() {
+ settings = new GameSettings();
+ settings.getPlayerList().add(new PlayerSettings("Foobar", Color.BLACK));
+ PlayerSettings player = new PlayerSettings("Fooblubb", Color.BLACK);
+ player.setType(PlayerSettings.Type.NETWORK);
+ settings.getPlayerList().add(player);
+ view = new MockView();
+ connection = new MockConnectionControl();
+ hostControl = new NetworkGameControl(settings, new SaveControl(view),
+ view, connection, true);
+ clientControl = new NetworkGameControl(settings, new SaveControl(view),
+ view, connection, false);
+ fired = false;
+ }
+
+ /** */
+ @Test
+ public void testStart() {
+ clientControl.startGame();
+ assertFalse(connection.startRoundCalled);
+ hostControl.startGame();
+ assertTrue(connection.startRoundCalled);
+ }
+
+ /** */
+ @Test
+ public void testParticipantLeft() {
+
+ connection.participantLeftEvent.emit("Horst");
+ assertTrue(BottomPanelType.NETWORK_CONNECTION_LOST_PANEL != view.bottomPanelType);
+ connection.participantLeftEvent.emit("Fooblubb");
+ assertEquals(BottomPanelType.NETWORK_CONNECTION_LOST_PANEL,
+ view.bottomPanelType);
+
+ hostControl.getBackEvent().add(new IListener() {
+ @Override
+ public void handle() {
+ fired = true;
+ }
+ });
+
+ view.newGameEvent.emit();
+ assertTrue(fired);
+
+ }
+
+}