diff options
author | Ida Massow <massow@informatik.uni-luebeck.de> | 2011-06-19 22:27:24 +0200 |
---|---|---|
committer | Ida Massow <massow@informatik.uni-luebeck.de> | 2011-06-19 22:27:24 +0200 |
commit | 10153f76a14a7b66e3c936b3249bec0c76835984 (patch) | |
tree | 5a0472a849b227704f25ee314f5a3f3bfdf097ec | |
parent | fc6d3d46db69c639557462a49ccb16463df91617 (diff) | |
download | JRummikub-10153f76a14a7b66e3c936b3249bec0c76835984.tar JRummikub-10153f76a14a7b66e3c936b3249bec0c76835984.zip |
Fix mock and tests
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@493 72836036-5685-4462-b002-a69064685172
-rw-r--r-- | mock/jrummikub/view/MockView.java | 30 | ||||
-rw-r--r-- | src/jrummikub/control/ApplicationControl.java | 1 | ||||
-rw-r--r-- | src/jrummikub/control/SaveControl.java | 17 | ||||
-rw-r--r-- | src/jrummikub/util/Event.java | 2 | ||||
-rw-r--r-- | src/jrummikub/view/IQuitWarningPanel.java | 7 | ||||
-rw-r--r-- | src/jrummikub/view/impl/QuitWarningPanel.java | 9 | ||||
-rw-r--r-- | test/jrummikub/control/SaveControlTest.java | 2 |
7 files changed, 40 insertions, 28 deletions
diff --git a/mock/jrummikub/view/MockView.java b/mock/jrummikub/view/MockView.java index 7c9b18e..f283ebd 100644 --- a/mock/jrummikub/view/MockView.java +++ b/mock/jrummikub/view/MockView.java @@ -30,6 +30,8 @@ public class MockView implements IView { /** */ public MockGameListPanel gameListPanel = new MockGameListPanel(); /** */ + public MockQuitWarningPanel quitWarningPanel = new MockQuitWarningPanel(); + /** */ public boolean isSettingsPanelVisible = false; /** */ public boolean isScorePanelVisible = false; @@ -59,7 +61,7 @@ public class MockView implements IView { /** */ public MockEvent menuQuitEvent = new MockEvent(); /** */ - public MockEvent1<File> loadEvent = new MockEvent1<File>(); + public MockEvent loadEvent = new MockEvent(); /** */ public MockEvent1<File> saveEvent = new MockEvent1<File>(); /** */ @@ -70,6 +72,8 @@ public class MockView implements IView { public MockEvent networkGameEvent = new MockEvent(); /** */ public MockEvent acknowledgeInvalidEvent = new MockEvent(); + /** */ + public MockEvent1<File> loadFileEvent = new MockEvent1<File>(); @Override public MockTablePanel getTablePanel() { @@ -167,7 +171,7 @@ public class MockView implements IView { } @Override - public IEvent1<File> getLoadEvent() { + public IEvent getLoadEvent() { return loadEvent; } @@ -247,13 +251,13 @@ public class MockView implements IView { @Override public void showLoadingError() { // TODO Auto-generated method stub - + } @Override public void enableSave(boolean enable) { // TODO Auto-generated method stub - + } @Override @@ -264,23 +268,31 @@ public class MockView implements IView { @Override public void showSidePanel(boolean show) { // TODO Auto-generated method stub - + } public void showQuitWarningPanel(boolean show) { // TODO Auto-generated method stub - + } @Override public IEvent getQuitEvent() { - // TODO Auto-generated method stub - return null; + return quitEvent; } @Override public IQuitWarningPanel getQuitWarningPanel() { + return quitWarningPanel; + } + + @Override + public IEvent1<File> getLoadFileEvent() { + return loadFileEvent; + } + + @Override + public void load() { // TODO Auto-generated method stub - return null; } } diff --git a/src/jrummikub/control/ApplicationControl.java b/src/jrummikub/control/ApplicationControl.java index 87516c0..7a629af 100644 --- a/src/jrummikub/control/ApplicationControl.java +++ b/src/jrummikub/control/ApplicationControl.java @@ -109,7 +109,6 @@ public class ApplicationControl { view); addGameControlListeners(gameControl); gameControl.continueGame(gameState, roundState); - } }); saveControl.getLoadErrorEvent().add(new IListener() { diff --git a/src/jrummikub/control/SaveControl.java b/src/jrummikub/control/SaveControl.java index 31e7a12..4134aec 100644 --- a/src/jrummikub/control/SaveControl.java +++ b/src/jrummikub/control/SaveControl.java @@ -49,14 +49,15 @@ public class SaveControl { view.getQuitWarningPanel().setMode(QuitMode.QUIT_GAME); view.showQuitWarningPanel(true); - tempConnection=view.getQuitWarningPanel().getQuitEvent().add(new IListener() { - @Override - public void handle() { - view.showQuitWarningPanel(false); - view.load(); - tempConnection.remove(); - } - }); + tempConnection = view.getQuitWarningPanel().getQuitEvent() + .add(new IListener() { + @Override + public void handle() { + view.showQuitWarningPanel(false); + view.load(); + tempConnection.remove(); + } + }); } }); view.getLoadFileEvent().add(new IListener1<File>() { diff --git a/src/jrummikub/util/Event.java b/src/jrummikub/util/Event.java index aa491da..6d9522b 100644 --- a/src/jrummikub/util/Event.java +++ b/src/jrummikub/util/Event.java @@ -25,7 +25,7 @@ public class Event implements IEvent { /** Generate a single event */ public void emit() { - for (IListener listener : listeners) { + for (IListener listener : new HashSet<IListener>(listeners)) { listener.handle(); } } diff --git a/src/jrummikub/view/IQuitWarningPanel.java b/src/jrummikub/view/IQuitWarningPanel.java index eddf6b1..b1f4123 100644 --- a/src/jrummikub/view/IQuitWarningPanel.java +++ b/src/jrummikub/view/IQuitWarningPanel.java @@ -1,7 +1,6 @@ package jrummikub.view; -import jrummikub.util.Event; -import jrummikub.view.IQuitWarningPanel.QuitMode; +import jrummikub.util.IEvent; public interface IQuitWarningPanel { @@ -14,9 +13,9 @@ public interface IQuitWarningPanel { QUIT_GAME } - Event getQuitEvent(); + public IEvent getQuitEvent(); - Event getCancelEvent(); + public IEvent getCancelEvent(); public void setMode(QuitMode mode); diff --git a/src/jrummikub/view/impl/QuitWarningPanel.java b/src/jrummikub/view/impl/QuitWarningPanel.java index d7a304a..b7992b0 100644 --- a/src/jrummikub/view/impl/QuitWarningPanel.java +++ b/src/jrummikub/view/impl/QuitWarningPanel.java @@ -15,6 +15,7 @@ import javax.swing.border.EmptyBorder; import javax.swing.border.LineBorder; import jrummikub.util.Event; +import jrummikub.util.IEvent; import jrummikub.view.IQuitWarningPanel; public class QuitWarningPanel extends JPanel implements IQuitWarningPanel { @@ -77,19 +78,19 @@ public class QuitWarningPanel extends JPanel implements IQuitWarningPanel { messageLabel.setText("Der aktuelle Spielstand geht verloren"); } } - + @Override - public QuitMode getQuitMode(){ + public QuitMode getQuitMode() { return quitMode; } @Override - public Event getQuitEvent() { + public IEvent getQuitEvent() { return quitEvent; } @Override - public Event getCancelEvent() { + public IEvent getCancelEvent() { return cancelEvent; } } diff --git a/test/jrummikub/control/SaveControlTest.java b/test/jrummikub/control/SaveControlTest.java index 3ff5f42..72dba75 100644 --- a/test/jrummikub/control/SaveControlTest.java +++ b/test/jrummikub/control/SaveControlTest.java @@ -66,7 +66,7 @@ public class SaveControlTest { } }); - view.loadEvent.emit(file); + view.loadEvent.emit(); file.delete(); } |