summaryrefslogtreecommitdiffstats
path: root/test/jrummikub/control
diff options
context:
space:
mode:
Diffstat (limited to 'test/jrummikub/control')
-rw-r--r--test/jrummikub/control/network/GameJoinControlTest.java7
-rw-r--r--test/jrummikub/control/network/GameOfferControlTest.java48
-rw-r--r--test/jrummikub/control/network/NetworkControlTest.java19
-rw-r--r--test/jrummikub/control/network/NetworkSettingsControlTest.java39
4 files changed, 68 insertions, 45 deletions
diff --git a/test/jrummikub/control/network/GameJoinControlTest.java b/test/jrummikub/control/network/GameJoinControlTest.java
index 31f76da..d2f3f9c 100644
--- a/test/jrummikub/control/network/GameJoinControlTest.java
+++ b/test/jrummikub/control/network/GameJoinControlTest.java
@@ -1,7 +1,7 @@
package jrummikub.control.network;
-import static org.junit.Assert.*;
-import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import java.awt.Color;
import java.util.UUID;
@@ -17,6 +17,9 @@ import jrummikub.view.MockView;
import org.junit.Before;
import org.junit.Test;
+/**
+ * Test class for game join control
+ */
public class GameJoinControlTest {
LoginData loginData;
MockConnectionControl mockConnection;
diff --git a/test/jrummikub/control/network/GameOfferControlTest.java b/test/jrummikub/control/network/GameOfferControlTest.java
index 57e68ac..a922967 100644
--- a/test/jrummikub/control/network/GameOfferControlTest.java
+++ b/test/jrummikub/control/network/GameOfferControlTest.java
@@ -1,23 +1,24 @@
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.assertSame;
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 jrummikub.view.MockView;
import org.junit.Before;
import org.junit.Test;
+/**
+ * Test class for game offer control
+ */
public class GameOfferControlTest {
LoginData loginData;
MockConnectionControl mockConnection;
@@ -53,31 +54,36 @@ public class GameOfferControlTest {
assertEquals(SettingsMode.NETWORK_OFFER,
view.settingsPanel.settingsMode);
view.settingsPanel.changePlayerColorEvent.emit(0, Color.PINK);
- assertEquals(Color.PINK, mockConnection.playerColor);
+ assertEquals(Color.PINK, mockConnection.playerColor);
view.settingsPanel.backEvent.emit();
assertFalse(view.isSettingsPanelVisible);
assertTrue(view.isGameListPanelVisible);
}
-
+
/** */
@Test
- public void getJoinLeaveTest(){
+ public void getJoinLeaveTest() {
view.gameListPanel.openNewGameEvent.emit();
view.settingsPanel.offerGameEvent.emit();
-
- mockConnection.gameJoinEvent.emit("Berta");
-
- assertEquals("Berta", mockConnection.offeredGame.getGameSettings().getPlayerList().get(1).getName());
- assertSame(Type.NETWORK, mockConnection.offeredGame.getGameSettings().getPlayerList().get(1).getType());
-
+
+ mockConnection.gameJoinEvent.emit("Berta");
+
+ assertEquals("Berta", mockConnection.offeredGame.getGameSettings()
+ .getPlayerList().get(1).getName());
+ assertSame(Type.NETWORK, mockConnection.offeredGame.getGameSettings()
+ .getPlayerList().get(1).getType());
+
mockConnection.changeColorEvent.emit("Berta", Color.BLUE);
-
- assertEquals(Color.BLUE, mockConnection.offeredGame.getGameSettings().getPlayerList().get(1).getColor());
-
+
+ assertEquals(Color.BLUE, mockConnection.offeredGame.getGameSettings()
+ .getPlayerList().get(1).getColor());
+
mockConnection.gameLeaveEvent.emit("Berta");
-
- assertEquals("Offen", mockConnection.offeredGame.getGameSettings().getPlayerList().get(1).getName());
- assertSame(Type.VACANT, mockConnection.offeredGame.getGameSettings().getPlayerList().get(1).getType());
- }
+
+ assertEquals("Offen", mockConnection.offeredGame.getGameSettings()
+ .getPlayerList().get(1).getName());
+ assertSame(Type.VACANT, mockConnection.offeredGame.getGameSettings()
+ .getPlayerList().get(1).getType());
+ }
}
diff --git a/test/jrummikub/control/network/NetworkControlTest.java b/test/jrummikub/control/network/NetworkControlTest.java
index 6cbd3d0..f805c73 100644
--- a/test/jrummikub/control/network/NetworkControlTest.java
+++ b/test/jrummikub/control/network/NetworkControlTest.java
@@ -1,7 +1,9 @@
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.assertSame;
+import static org.junit.Assert.assertTrue;
import java.awt.Color;
import java.util.UUID;
@@ -11,12 +13,15 @@ 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 jrummikub.view.MockView;
import org.junit.Before;
import org.junit.Test;
+/**
+ * Test class for network control
+ */
public class NetworkControlTest {
LoginData loginData;
MockConnectionControl mockConnection;
@@ -76,9 +81,9 @@ public class NetworkControlTest {
assertEquals(SettingsMode.NETWORK_OFFER,
view.settingsPanel.settingsMode);
}
-
+
/** */
- @Test
+ @Test
public void joinGameTest() {
mockConnection.connectedEvent.emit();
GameData data = offerTestGame(id1, "Berta");
@@ -112,12 +117,12 @@ public class NetworkControlTest {
assertEquals(id2, view.gameListPanel.gameList.get(0).getGameID());
assertEquals("Horst", view.gameListPanel.gameList.get(0).getHost());
}
-
+
/** */
@Test
- public void testCancel(){
+ public void testCancel() {
mockConnection.connectedEvent.emit();
-
+
view.gameListPanel.cancelEvent.emit();
assertFalse(view.isGameListPanelVisible);
assertFalse(mockConnection.connected);
diff --git a/test/jrummikub/control/network/NetworkSettingsControlTest.java b/test/jrummikub/control/network/NetworkSettingsControlTest.java
index ec11960..c8bb7af 100644
--- a/test/jrummikub/control/network/NetworkSettingsControlTest.java
+++ b/test/jrummikub/control/network/NetworkSettingsControlTest.java
@@ -1,21 +1,23 @@
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.assertSame;
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 jrummikub.view.MockView;
import org.junit.Before;
import org.junit.Test;
-
+/**
+ * Test class for network settings control
+ */
public class NetworkSettingsControlTest {
LoginData loginData;
MockConnectionControl mockConnection;
@@ -36,7 +38,7 @@ public class NetworkSettingsControlTest {
networkControl = new NetworkControl(loginData, mockConnection, view);
networkControl.startNetwork();
- mockConnection.connectedEvent.emit();
+ mockConnection.connectedEvent.emit();
}
/** */
@@ -45,7 +47,8 @@ public class NetworkSettingsControlTest {
view.gameListPanel.openNewGameEvent.emit();
assertFalse(view.isGameListPanelVisible);
assertTrue(view.isSettingsPanelVisible);
- assertEquals(SettingsMode.NETWORK_SETUP, view.settingsPanel.settingsMode);
+ assertEquals(SettingsMode.NETWORK_SETUP,
+ view.settingsPanel.settingsMode);
view.settingsPanel.addPlayerEvent.emit();
view.settingsPanel.addPlayerEvent.emit();
view.settingsPanel.changePlayerTypeEvent.emit(1, Type.VACANT);
@@ -53,16 +56,22 @@ public class NetworkSettingsControlTest {
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());
- }
+ 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());
+ }
}