From 5aa79ea898e16cee1265ba9457c1af11616584cc Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 28 May 2011 20:13:35 +0200 Subject: Implement settings control git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@291 72836036-5685-4462-b002-a69064685172 --- test/jrummikub/control/SettingsControlTest.java | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'test/jrummikub/control') diff --git a/test/jrummikub/control/SettingsControlTest.java b/test/jrummikub/control/SettingsControlTest.java index f0e4ae0..8dc286c 100644 --- a/test/jrummikub/control/SettingsControlTest.java +++ b/test/jrummikub/control/SettingsControlTest.java @@ -12,11 +12,13 @@ import jrummikub.view.MockView; import org.junit.Before; import org.junit.Test; +/** */ public class SettingsControlTest { MockView view = new MockView(); SettingsControl settingsControl = new SettingsControl(view); GameSettings gameSettings = null; + /** */ @Before public void setup() { settingsControl.getStartGameEvent().add(new IListener1() { @@ -24,21 +26,23 @@ public class SettingsControlTest { @Override public void handle(GameSettings value) { gameSettings = value; - } }); + + settingsControl.startSettings(); } + /** */ @Test public void initialStateTest() { - assertSame(ISettingsPanel.SettingsError.NO_ERROR, - view.settingsPanel.error); + assertSame(ISettingsPanel.SettingsError.NO_ERROR, view.settingsPanel.error); view.settingsPanel.startGameEvent.emit(); assertNotNull(gameSettings); assertEquals(2, gameSettings.getPlayerList().size()); assertFalse(view.settingsPanel.removePlayerButtonsEnabled); } + /** */ @Test public void addPlayerTest() { view.settingsPanel.addPlayerEvent.emit(); @@ -48,6 +52,7 @@ public class SettingsControlTest { assertTrue(view.settingsPanel.removePlayerButtonsEnabled); } + /** */ @Test public void add14PlayerTest() { for (int i = 0; i < 14; i++) { @@ -60,6 +65,7 @@ public class SettingsControlTest { assertFalse(view.settingsPanel.addPlayerButtonEnabled); } + /** */ @Test public void add14RemovePlayerTest() { for (int i = 0; i < 14; i++) { @@ -73,6 +79,7 @@ public class SettingsControlTest { assertTrue(view.settingsPanel.addPlayerButtonEnabled); } + /** */ @Test public void removePlayerTest() { view.settingsPanel.addPlayerEvent.emit(); @@ -83,6 +90,7 @@ public class SettingsControlTest { assertFalse(view.settingsPanel.removePlayerButtonsEnabled); } + /** */ @Test public void takenColorTest() { Color color1 = Color.RED; @@ -97,6 +105,7 @@ public class SettingsControlTest { assertSame(color1, gameSettings.getPlayerList().get(1).getColor()); } + /** */ @Test public void unusedColorTest() { Color color1 = Color.RED; @@ -112,6 +121,7 @@ public class SettingsControlTest { assertSame(color3, gameSettings.getPlayerList().get(1).getColor()); } + /** */ @Test public void takenNameTest() { String name1 = "Julia"; @@ -126,6 +136,7 @@ public class SettingsControlTest { assertNull(gameSettings); } + /** */ @Test public void fixTakenNameTest() { String name1 = "Julia"; @@ -143,13 +154,13 @@ public class SettingsControlTest { view.settingsPanel.changePlayerNameEvent.emit(1, name2); assertTrue(view.settingsPanel.startButtonEnabled); - assertSame(ISettingsPanel.SettingsError.NO_ERROR, - view.settingsPanel.error); + assertSame(ISettingsPanel.SettingsError.NO_ERROR, view.settingsPanel.error); view.settingsPanel.startGameEvent.emit(); assertNotNull(gameSettings); } + /** */ @Test public void emptyNameTest() { String name1 = ""; -- cgit v1.2.3