summaryrefslogtreecommitdiffstats
path: root/test/jrummikub
diff options
context:
space:
mode:
authorIda Massow <massow@informatik.uni-luebeck.de>2011-06-19 03:43:25 +0200
committerIda Massow <massow@informatik.uni-luebeck.de>2011-06-19 03:43:25 +0200
commitf0c5aa509293ec56b73b304f46921fd3994ead83 (patch)
tree0ed4e93865b54ede5a6b9eb4f0423c7f06e12c65 /test/jrummikub
parentfe7a2bc0ee0c04171cebffbfb0d0fdd98038938b (diff)
downloadJRummikub-f0c5aa509293ec56b73b304f46921fd3994ead83.tar
JRummikub-f0c5aa509293ec56b73b304f46921fd3994ead83.zip
Neue Tests fürs Netzwerk
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@481 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test/jrummikub')
-rw-r--r--test/jrummikub/control/network/GameOfferControlTest.java56
-rw-r--r--test/jrummikub/control/network/NetworkSettingsControlTest.java62
2 files changed, 118 insertions, 0 deletions
diff --git a/test/jrummikub/control/network/GameOfferControlTest.java b/test/jrummikub/control/network/GameOfferControlTest.java
index 4d1d5e6..105c435 100644
--- a/test/jrummikub/control/network/GameOfferControlTest.java
+++ b/test/jrummikub/control/network/GameOfferControlTest.java
@@ -1,6 +1,62 @@
package jrummikub.control.network;
+import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.awt.Color;
+import java.util.UUID;
+
+import jrummikub.model.GameSettings;
+import jrummikub.model.PlayerSettings;
+import jrummikub.model.PlayerSettings.Type;
+import jrummikub.util.GameData;
+import jrummikub.util.LoginData;
+import jrummikub.view.MockView;
+import jrummikub.view.ISettingsPanel.SettingsMode;
+
+import org.junit.Before;
+import org.junit.Test;
public class GameOfferControlTest {
+ LoginData loginData;
+ MockConnectionControl mockConnection;
+ NetworkControl networkControl;
+ GameJoinControl joinControl;
+ MockView view;
+ UUID id1 = UUID.randomUUID();
+ UUID id2 = UUID.randomUUID();
+ UUID id3 = UUID.randomUUID();
+
+ /** */
+ @Before
+ public void setup() {
+ mockConnection = new MockConnectionControl();
+ mockConnection.nickname = "Karl";
+ view = new MockView();
+ loginData = new LoginData("Karl", "server", "password", "channel");
+ networkControl = new NetworkControl(loginData, mockConnection, view);
+ networkControl.startNetwork();
+
+ mockConnection.connectedEvent.emit();
+ }
+
+ /** */
+ @Test
+ public void withdrawGameTest() {
+ view.gameListPanel.openNewGameEvent.emit();
+ assertFalse(view.isGameListPanelVisible);
+ assertTrue(view.isSettingsPanelVisible);
+ assertEquals(SettingsMode.NETWORK_SETUP,
+ view.settingsPanel.settingsMode);
+ view.settingsPanel.offerGameEvent.emit();
+ assertEquals(SettingsMode.NETWORK_OFFER,
+ view.settingsPanel.settingsMode);
+ view.settingsPanel.changePlayerColorEvent.emit(0, Color.PINK);
+ assertEquals(Color.PINK, mockConnection.playerColor);
+ view.settingsPanel.backEvent.emit();
+ assertFalse(view.isSettingsPanelVisible);
+ assertTrue(view.isGameListPanelVisible);
+ }
}
diff --git a/test/jrummikub/control/network/NetworkSettingsControlTest.java b/test/jrummikub/control/network/NetworkSettingsControlTest.java
index 799890d..ec11960 100644
--- a/test/jrummikub/control/network/NetworkSettingsControlTest.java
+++ b/test/jrummikub/control/network/NetworkSettingsControlTest.java
@@ -1,6 +1,68 @@
package jrummikub.control.network;
+import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.UUID;
+
+import jrummikub.model.PlayerSettings.Type;
+import jrummikub.util.LoginData;
+import jrummikub.view.MockView;
+import jrummikub.view.ISettingsPanel.SettingsMode;
+
+import org.junit.Before;
+import org.junit.Test;
+
public class NetworkSettingsControlTest {
+ LoginData loginData;
+ MockConnectionControl mockConnection;
+ NetworkControl networkControl;
+ GameJoinControl joinControl;
+ MockView view;
+ UUID id1 = UUID.randomUUID();
+ UUID id2 = UUID.randomUUID();
+ UUID id3 = UUID.randomUUID();
+
+ /** */
+ @Before
+ public void setup() {
+ mockConnection = new MockConnectionControl();
+ mockConnection.nickname = "Karl";
+ view = new MockView();
+ loginData = new LoginData("Karl", "server", "password", "channel");
+ networkControl = new NetworkControl(loginData, mockConnection, view);
+ networkControl.startNetwork();
+
+ mockConnection.connectedEvent.emit();
+ }
+
+ /** */
+ @Test
+ public void networkSettingsTest() {
+ view.gameListPanel.openNewGameEvent.emit();
+ assertFalse(view.isGameListPanelVisible);
+ assertTrue(view.isSettingsPanelVisible);
+ assertEquals(SettingsMode.NETWORK_SETUP, view.settingsPanel.settingsMode);
+ view.settingsPanel.addPlayerEvent.emit();
+ view.settingsPanel.addPlayerEvent.emit();
+ view.settingsPanel.changePlayerTypeEvent.emit(1, Type.VACANT);
+ view.settingsPanel.changePlayerTypeEvent.emit(2, Type.COMPUTER);
+ view.settingsPanel.changeJokerNumberEvent.emit(4);
+ view.settingsPanel.changeHighestValueEvent.emit(10);
+ view.settingsPanel.offerGameEvent.emit();
+
+ assertEquals(SettingsMode.NETWORK_OFFER, view.settingsPanel.settingsMode);
+
+ assertEquals(4, mockConnection.offeredGame.getGameSettings().getPlayerList().size());
+ assertSame(Type.VACANT, mockConnection.offeredGame.getGameSettings().getPlayerList().get(1).getType());
+ assertSame(Type.COMPUTER, mockConnection.offeredGame.getGameSettings().getPlayerList().get(2).getType());
+ assertSame(Type.VACANT, mockConnection.offeredGame.getGameSettings().getPlayerList().get(3).getType());
+ assertEquals(4, mockConnection.offeredGame.getGameSettings().getJokerNumber());
+ assertEquals(10, mockConnection.offeredGame.getGameSettings().getHighestValue());
+ }
+
}