Implement settings control
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@291 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
5029ff206a
commit
5aa79ea898
4 changed files with 268 additions and 55 deletions
|
@ -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<GameSettings>() {
|
||||
|
@ -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 = "";
|
||||
|
|
Reference in a new issue