summaryrefslogtreecommitdiffstats
path: root/test/jrummikub
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-05-04 21:37:29 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-05-04 21:37:29 +0200
commit4ae29c76c2703bb7f36aee70aaf09c6bb7590464 (patch)
tree6a0abd19388cbb858a7aa1c08ec3f6fdc2b4e0e0 /test/jrummikub
parent32f2f8030b07225fd6e4ebc0dc5ebdf09289eb40 (diff)
downloadJRummikub-4ae29c76c2703bb7f36aee70aaf09c6bb7590464.tar
JRummikub-4ae29c76c2703bb7f36aee70aaf09c6bb7590464.zip
Add mock events
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@121 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test/jrummikub')
-rw-r--r--test/jrummikub/util/MockEvent.java17
-rw-r--r--test/jrummikub/util/MockEvent1.java17
-rw-r--r--test/jrummikub/util/MockEvent2.java17
-rw-r--r--test/jrummikub/view/MockView.java31
4 files changed, 68 insertions, 14 deletions
diff --git a/test/jrummikub/util/MockEvent.java b/test/jrummikub/util/MockEvent.java
new file mode 100644
index 0000000..85f2c28
--- /dev/null
+++ b/test/jrummikub/util/MockEvent.java
@@ -0,0 +1,17 @@
+package jrummikub.util;
+
+import java.util.HashSet;
+
+public class MockEvent implements IEvent {
+ public HashSet<IListener> listeners = new HashSet<IListener>();
+
+ @Override
+ public void add(IListener listener) {
+ listeners.add(listener);
+ }
+
+ @Override
+ public void remove(IListener listener) {
+ listeners.remove(listener);
+ }
+}
diff --git a/test/jrummikub/util/MockEvent1.java b/test/jrummikub/util/MockEvent1.java
new file mode 100644
index 0000000..36af527
--- /dev/null
+++ b/test/jrummikub/util/MockEvent1.java
@@ -0,0 +1,17 @@
+package jrummikub.util;
+
+import java.util.HashSet;
+
+public class MockEvent1<T> implements IEvent1<T> {
+ public HashSet<IListener1<T>> listeners = new HashSet<IListener1<T>>();
+
+ @Override
+ public void add(IListener1<T> listener) {
+ listeners.add(listener);
+ }
+
+ @Override
+ public void remove(IListener1<T> listener) {
+ listeners.remove(listener);
+ }
+}
diff --git a/test/jrummikub/util/MockEvent2.java b/test/jrummikub/util/MockEvent2.java
new file mode 100644
index 0000000..4f01372
--- /dev/null
+++ b/test/jrummikub/util/MockEvent2.java
@@ -0,0 +1,17 @@
+package jrummikub.util;
+
+import java.util.HashSet;
+
+public class MockEvent2<T1, T2> implements IEvent2<T1, T2> {
+ public HashSet<IListener2<T1, T2>> listeners = new HashSet<IListener2<T1, T2>>();
+
+ @Override
+ public void add(IListener2<T1, T2> listener) {
+ listeners.add(listener);
+ }
+
+ @Override
+ public void remove(IListener2<T1, T2> listener) {
+ listeners.remove(listener);
+ }
+}
diff --git a/test/jrummikub/view/MockView.java b/test/jrummikub/view/MockView.java
index 3165478..e208375 100644
--- a/test/jrummikub/view/MockView.java
+++ b/test/jrummikub/view/MockView.java
@@ -4,6 +4,7 @@ import java.util.Collection;
import jrummikub.model.Stone;
import jrummikub.util.IEvent;
+import jrummikub.util.MockEvent;
public class MockView implements IView {
public MockPlayerPanel playerPanel = new MockPlayerPanel();
@@ -11,21 +12,28 @@ public class MockView implements IView {
public Collection<Stone> selectedStones;
+ public String currentPlayerName;
+ public boolean displayStartTurnPanel = false;
+ public boolean displayWinPanel = false;
+
+ public MockEvent startTurnEvent = new MockEvent();
+ public MockEvent quitEvent = new MockEvent();
+ public MockEvent newGameEvent = new MockEvent();
+
@Override
- public ITablePanel getTablePanel() {
+ public MockTablePanel getTablePanel() {
// TODO Auto-generated method stub
return null;
}
@Override
- public IPlayerPanel getPlayerPanel() {
+ public MockPlayerPanel getPlayerPanel() {
return playerPanel;
}
@Override
public void setCurrentPlayerName(String playerName) {
- // TODO Auto-generated method stub
-
+ currentPlayerName = playerName;
}
@Override
@@ -35,32 +43,27 @@ public class MockView implements IView {
@Override
public void enableStartTurnPanel(boolean enable) {
- // TODO Auto-generated method stub
-
+ displayStartTurnPanel = enable;
}
@Override
public IEvent getStartTurnEvent() {
- // TODO Auto-generated method stub
- return null;
+ return startTurnEvent;
}
@Override
public void enableWinPanel(boolean enable) {
- // TODO Auto-generated method stub
-
+ displayWinPanel = enable;
}
@Override
public IEvent getQuitEvent() {
- // TODO Auto-generated method stub
- return null;
+ return quitEvent;
}
@Override
public IEvent getNewGameEvent() {
- // TODO Auto-generated method stub
- return null;
+ return newGameEvent;
}
} \ No newline at end of file