summaryrefslogtreecommitdiffstats
path: root/test/jrummikub/control/ApplicationControlTest.java
diff options
context:
space:
mode:
authorIda Massow <massow@informatik.uni-luebeck.de>2011-07-02 12:21:10 +0200
committerIda Massow <massow@informatik.uni-luebeck.de>2011-07-02 12:21:10 +0200
commitaca4b2521072561e3dfb3ce0e5034f5c5d76c8b3 (patch)
treedecb7fcd36bc363b4ebb56522ca4fdb7e784029a /test/jrummikub/control/ApplicationControlTest.java
parent8facde1b30e8bd478409a6752eaeceebe6ba3e98 (diff)
downloadJRummikub-aca4b2521072561e3dfb3ce0e5034f5c5d76c8b3.tar
JRummikub-aca4b2521072561e3dfb3ce0e5034f5c5d76c8b3.zip
Tests für die Control Klasse, jetzt zu 91.9 Prozent abgedeckt
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@601 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test/jrummikub/control/ApplicationControlTest.java')
-rw-r--r--test/jrummikub/control/ApplicationControlTest.java136
1 files changed, 136 insertions, 0 deletions
diff --git a/test/jrummikub/control/ApplicationControlTest.java b/test/jrummikub/control/ApplicationControlTest.java
new file mode 100644
index 0000000..88f365a
--- /dev/null
+++ b/test/jrummikub/control/ApplicationControlTest.java
@@ -0,0 +1,136 @@
+package jrummikub.control;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import jrummikub.util.LoginData;
+import jrummikub.view.IQuitWarningPanel.QuitMode;
+import jrummikub.view.MockView;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests for the testable parts of the application control
+ */
+public class ApplicationControlTest {
+ ApplicationControl testAppControl;
+ MockView view;
+
+ /** */
+ @Before
+ public void setup() {
+ view = new MockView();
+ }
+
+ /** */
+ @Test
+ public void enableSaving() {
+ assertFalse(view.savingEnabled);
+ testAppControl = new ApplicationControl(view);
+ testAppControl.startApplication();
+ assertTrue(view.isSettingsPanelVisible);
+ view.settingsPanel.startGameEvent.emit();
+ assertFalse(view.isSettingsPanelVisible);
+ assertTrue(view.savingEnabled);
+ }
+
+ /** */
+ @Test
+ public void pauseTest() {
+ testAppControl = new ApplicationControl(view);
+ testAppControl.startApplication();
+ view.settingsPanel.startGameEvent.emit();
+ view.getPlayerPanel().pauseEvent.emit();
+ // assertTrue(view.isPaused);
+ }
+
+ /** */
+ @Test
+ public void networkTest() {
+ testAppControl = new ApplicationControl(view);
+ testAppControl.startApplication();
+
+ view.networkGameEvent.emit();
+ assertTrue(view.isLoginPanelVisible);
+ }
+
+ /** */
+ @Test
+ public void networkFromRunningGameTest() {
+ testAppControl = new ApplicationControl(view);
+ testAppControl.startApplication();
+ view.settingsPanel.startGameEvent.emit();
+
+ view.networkGameEvent.emit();
+ assertTrue(view.isQuitWarningPanelVisible);
+ assertSame(QuitMode.QUIT_GAME, view.getQuitWarningPanel().getQuitMode());
+ view.getQuitWarningPanel().quitEvent.emit();
+ assertTrue(view.isLoginPanelVisible);
+ }
+
+ /** */
+ @Test
+ public void newGameFromNetworkTest() {
+ testAppControl = new ApplicationControl(view);
+ testAppControl.startApplication();
+
+ view.networkGameEvent.emit();
+ assertTrue(view.isLoginPanelVisible);
+
+ LoginData data = new LoginData("Horst", "server", "horstspw", "channel");
+ view.loginPanel.loginEvent.emit(data);
+ assertTrue(view.isConnectPanelVisible);
+ view.menuNewGameEvent.emit();
+ assertTrue(view.isQuitWarningPanelVisible);
+ assertSame(QuitMode.QUIT_GAME, view.getQuitWarningPanel().getQuitMode());
+ view.getQuitWarningPanel().quitEvent.emit();
+
+ assertFalse(view.isConnectPanelVisible);
+ assertTrue(view.isSettingsPanelVisible);
+ }
+
+ /** */
+ @Test
+ public void loadTest() {
+ testAppControl = new ApplicationControl(view);
+ testAppControl.startApplication();
+
+ view.loadEvent.emit();
+ assertFalse(view.isQuitWarningPanelVisible);
+ }
+
+ /** */
+ @Test
+ public void loadFromRunningGameTest() {
+ testAppControl = new ApplicationControl(view);
+ testAppControl.startApplication();
+ view.settingsPanel.startGameEvent.emit();
+
+ view.loadEvent.emit();
+ assertTrue(view.isQuitWarningPanelVisible);
+ assertSame(QuitMode.QUIT_GAME, view.getQuitWarningPanel().getQuitMode());
+ view.getQuitWarningPanel().quitEvent.emit();
+ // TODO asserte was
+ }
+
+ /** */
+ @Test
+ public void newGameFromRunningGameTest() {
+ testAppControl = new ApplicationControl(view);
+ testAppControl.startApplication();
+ view.settingsPanel.startGameEvent.emit();
+
+ view.menuNewGameEvent.emit();
+ assertTrue(view.isQuitWarningPanelVisible);
+ assertSame(QuitMode.QUIT_GAME, view.getQuitWarningPanel().getQuitMode());
+ view.getQuitWarningPanel().cancelEvent.emit();
+ assertFalse(view.isQuitWarningPanelVisible);
+
+ view.menuNewGameEvent.emit();
+ assertTrue(view.isQuitWarningPanelVisible);
+ assertSame(QuitMode.QUIT_GAME, view.getQuitWarningPanel().getQuitMode());
+ view.getQuitWarningPanel().quitEvent.emit();
+ assertTrue(view.isSettingsPanelVisible);
+ }
+}