Test initial meld threshold in settings control

git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@295 72836036-5685-4462-b002-a69064685172
This commit is contained in:
Jannis Harder 2011-05-29 15:32:00 +02:00
parent 7f89a1ce10
commit 09aa507e3b
3 changed files with 18 additions and 5 deletions

View file

@ -25,7 +25,7 @@ public class ApplicationControl {
* Starts the application by showing the game settings dialog panel * Starts the application by showing the game settings dialog panel
*/ */
public void startApplication() { public void startApplication() {
SettingsControl settingsControl = new SettingsControl(view); SettingsControl settingsControl = new SettingsControl(view, new GameSettings());
settingsControl.getStartGameEvent().add(new IListener1<GameSettings>() { settingsControl.getStartGameEvent().add(new IListener1<GameSettings>() {
@Override @Override

View file

@ -19,17 +19,19 @@ public class SettingsControl {
private IView view; private IView view;
private Event1<GameSettings> startGameEvent = new Event1<GameSettings>(); private Event1<GameSettings> startGameEvent = new Event1<GameSettings>();
private GameSettings settings = new GameSettings(); private GameSettings settings;
/** /**
* Create a new settings control * Create a new settings control
* *
* @param view * @param view
* the view to use * the view to use
* @param settings
* initial game settings
*/ */
public SettingsControl(IView view) { public SettingsControl(IView view, GameSettings settings) {
this.view = view; this.view = view;
this.settings = settings;
addPlayer(); addPlayer();
addPlayer(); addPlayer();
} }

View file

@ -15,7 +15,8 @@ import org.junit.Test;
/** */ /** */
public class SettingsControlTest { public class SettingsControlTest {
MockView view = new MockView(); MockView view = new MockView();
SettingsControl settingsControl = new SettingsControl(view); GameSettings initialSettings = new GameSettings();
SettingsControl settingsControl = new SettingsControl(view, initialSettings);
GameSettings gameSettings = null; GameSettings gameSettings = null;
/** */ /** */
@ -174,4 +175,14 @@ public class SettingsControlTest {
assertNull(gameSettings); assertNull(gameSettings);
} }
/** */
@Test
public void initialMeldThresholdTest() {
assertEquals(initialSettings.getInitialMeldThreshold(), view.settingsPanel.initialMeldThreshold);
view.settingsPanel.changeInitialMeldThresholdEvent.emit(25);
view.settingsPanel.startGameEvent.emit();
assertEquals(25, gameSettings.getInitialMeldThreshold());
}
} }