diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-06-19 19:46:06 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-06-19 19:46:06 +0200 |
commit | 45656861ab2e618938764f0c46f830184099a71d (patch) | |
tree | 8e5cd9ab28d47f242408d6dcfc29317902048605 /test/jrummikub/control/turn | |
parent | 9b7aac51f58eb628978ed0e4d1a922a959917a3b (diff) | |
download | JRummikub-45656861ab2e618938764f0c46f830184099a71d.tar JRummikub-45656861ab2e618938764f0c46f830184099a71d.zip |
Added NetworkRoundControlTest and started NetworkRoundControl and NetworkTurnControl implementation
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@491 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test/jrummikub/control/turn')
-rw-r--r-- | test/jrummikub/control/turn/AIControlTest.java | 29 | ||||
-rw-r--r-- | test/jrummikub/control/turn/TurnControlTest.java | 88 |
2 files changed, 57 insertions, 60 deletions
diff --git a/test/jrummikub/control/turn/AIControlTest.java b/test/jrummikub/control/turn/AIControlTest.java index 6da4b00..a8974ea 100644 --- a/test/jrummikub/control/turn/AIControlTest.java +++ b/test/jrummikub/control/turn/AIControlTest.java @@ -16,6 +16,7 @@ import jrummikub.model.Stone; import jrummikub.model.StoneColor;
import jrummikub.model.Table;
import jrummikub.util.IListener;
+import jrummikub.util.IListener1;
import jrummikub.view.MockView;
import org.junit.Before;
@@ -47,10 +48,9 @@ public class AIControlTest { turnEnded = false;
redealt = false;
- aiControl.getEndOfTurnEvent().add(new IListener() {
-
+ aiControl.getEndOfTurnEvent().add(new IListener1<ITable>() {
@Override
- public void handle() {
+ public void handle(ITable newTable) {
turnEnded = true;
}
@@ -73,12 +73,13 @@ public class AIControlTest { /**
* @throws InterruptedException
- * if timeout
+ * if timeout
*/
@Test(timeout = 10000)
public void testTurnZeroNoRedealing() throws InterruptedException {
- aiControl.setup(new ITurnControl.TurnInfo(table, player.getHand(),
- player.getLaidOut(), TurnMode.MAY_REDEAL), gameSettings, view);
+ aiControl.setup(
+ new ITurnControl.TurnInfo(table, player.getHand(), player.getLaidOut(),
+ TurnMode.MAY_REDEAL), gameSettings, view);
aiControl.startTurn();
assertTrue(turnEnded);
assertFalse(redealt);
@@ -87,14 +88,13 @@ public class AIControlTest { /**
* @throws InterruptedException
- * if timeout
+ * if timeout
*/
@Test(timeout = 10000)
public void testTurnZeroNotMelding() throws InterruptedException {
- aiControl
- .setup(new ITurnControl.TurnInfo(table, player.getHand(),
- player.getLaidOut(), TurnMode.INSPECT_ONLY),
- gameSettings, view);
+ aiControl.setup(
+ new ITurnControl.TurnInfo(table, player.getHand(), player.getLaidOut(),
+ TurnMode.INSPECT_ONLY), gameSettings, view);
aiControl.startTurn();
assertTrue(turnEnded);
assertFalse(redealt);
@@ -103,12 +103,13 @@ public class AIControlTest { /**
* @throws InterruptedException
- * if timeout
+ * if timeout
*/
@Test(timeout = 10000)
public void testNormalTurnMelding() throws InterruptedException {
- aiControl.setup(new ITurnControl.TurnInfo(table, player.getHand(),
- player.getLaidOut(), TurnMode.NORMAL_TURN), gameSettings, view);
+ aiControl.setup(
+ new ITurnControl.TurnInfo(table, player.getHand(), player.getLaidOut(),
+ TurnMode.NORMAL_TURN), gameSettings, view);
aiControl.startTurn();
assertTrue(turnEnded);
assertFalse(redealt);
diff --git a/test/jrummikub/control/turn/TurnControlTest.java b/test/jrummikub/control/turn/TurnControlTest.java index f334b29..5e3e09c 100644 --- a/test/jrummikub/control/turn/TurnControlTest.java +++ b/test/jrummikub/control/turn/TurnControlTest.java @@ -25,7 +25,7 @@ import jrummikub.model.StoneSet; import jrummikub.model.Table; import jrummikub.util.Event; import jrummikub.util.IEvent; -import jrummikub.util.IListener; +import jrummikub.util.IListener1; import jrummikub.util.Pair; import jrummikub.view.IView.BottomPanelType; import jrummikub.view.MockView; @@ -133,8 +133,8 @@ public class TurnControlTest { mockPlayer = new MockPlayer(null, null); mockPlayer.hand = mockHand; testControl = new HumanTurnControl(mockTimer); - testControl.setup(new ITurnControl.TurnInfo(mockTable, mockPlayer - .getHand(), mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN), + testControl.setup(new ITurnControl.TurnInfo(mockTable, + mockPlayer.getHand(), mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN), new GameSettings(), mockView); } @@ -159,8 +159,8 @@ public class TurnControlTest { mockHand.iterable = stones; testControl = new HumanTurnControl(mockTimer); - testControl.setup(new ITurnControl.TurnInfo(mockTable, mockPlayer - .getHand(), mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN), + testControl.setup(new ITurnControl.TurnInfo(mockTable, + mockPlayer.getHand(), mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN), new GameSettings(), mockView); testControl.startTurn(); @@ -182,10 +182,9 @@ public class TurnControlTest { eventFired = false; mockTimer.timerRunning = true; - testControl.getEndOfTurnEvent().add(new IListener() { - + testControl.getEndOfTurnEvent().add(new IListener1<ITable>() { @Override - public void handle() { + public void handle(ITable newTable) { eventFired = true; } }); @@ -205,10 +204,9 @@ public class TurnControlTest { eventFired = false; mockTimer.timerRunning = true; - testControl.getEndOfTurnEvent().add(new IListener() { - + testControl.getEndOfTurnEvent().add(new IListener1<ITable>() { @Override - public void handle() { + public void handle(ITable newTable) { eventFired = true; } }); @@ -292,8 +290,8 @@ public class TurnControlTest { mockView.handPanel.stoneClickEvent.emit(redJoker, true); mockView.handPanel.stoneClickEvent.emit(blackJoker, true); - mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit( - blackJoker, true); + mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(blackJoker, + true); assertCollection(Arrays.asList(redJoker, blackJoker)); } @@ -309,8 +307,7 @@ public class TurnControlTest { mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(redJoker, true); - mockView.tablePanel.stoneCollectionPanel.setClickEvent.emit(redJoker, - true); + mockView.tablePanel.stoneCollectionPanel.setClickEvent.emit(redJoker, true); assertCollection(new ArrayList<Stone>()); } @@ -408,8 +405,8 @@ public class TurnControlTest { testControl.startTurn(); Stone stone4 = new Stone(4, StoneColor.RED); - StoneSet set1 = new StoneSet(Arrays.asList(redOne, redTwo, redThree, - stone4)); + StoneSet set1 = new StoneSet( + Arrays.asList(redOne, redTwo, redThree, stone4)); mockTable.findStoneSet.put(redOne, set1); mockTable.findStoneSet.put(redThree, set1); @@ -576,15 +573,15 @@ public class TurnControlTest { public void testAddLeft() { AccessibleTable table = new AccessibleTable(); HumanTurnControl turnControl = new HumanTurnControl(mockTimer); - turnControl.setup(new ITurnControl.TurnInfo(table, - mockPlayer.getHand(), mockPlayer.getLaidOut(), - TurnMode.NORMAL_TURN), new GameSettings(), mockView); + turnControl.setup(new ITurnControl.TurnInfo(table, mockPlayer.getHand(), + mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN), new GameSettings(), + mockView); turnControl.startTurn(); - StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, - blackOne, redTwo, redThree, redFour, blackTwo, blackThree)); - StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blackFour, - blackFive)); + StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne, + redTwo, redThree, redFour, blackTwo, blackThree)); + StoneSet oldSet2 = new StoneSet( + Arrays.asList(blueTwo, blackFour, blackFive)); table.drop(oldSet1, new Position(0, 0)); table.drop(oldSet2, new Position(0, 0)); mockHand.drop(blueThree, new Position(0, 0)); @@ -683,14 +680,14 @@ public class TurnControlTest { public void testAddRight() { AccessibleTable table = new AccessibleTable(); HumanTurnControl turnControl = new HumanTurnControl(mockTimer); - turnControl.setup(new ITurnControl.TurnInfo(table, - mockPlayer.getHand(), mockPlayer.getLaidOut(), - TurnMode.NORMAL_TURN), new GameSettings(), mockView); + turnControl.setup(new ITurnControl.TurnInfo(table, mockPlayer.getHand(), + mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN), new GameSettings(), + mockView); turnControl.startTurn(); - StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, - blackOne, redTwo, redThree, redFour, blackTwo, blackThree)); - StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blackFour, - blackFive)); + StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne, + redTwo, redThree, redFour, blackTwo, blackThree)); + StoneSet oldSet2 = new StoneSet( + Arrays.asList(blueTwo, blackFour, blackFive)); table.drop(oldSet1, new Position(0, 0)); table.drop(oldSet2, new Position(0, 0)); mockHand.drop(blueThree, new Position(0, 0)); @@ -789,14 +786,14 @@ public class TurnControlTest { public void testAddNewSet() { AccessibleTable table = new AccessibleTable(); HumanTurnControl turnControl = new HumanTurnControl(mockTimer); - turnControl.setup(new ITurnControl.TurnInfo(table, - mockPlayer.getHand(), mockPlayer.getLaidOut(), - TurnMode.NORMAL_TURN), new GameSettings(), mockView); + turnControl.setup(new ITurnControl.TurnInfo(table, mockPlayer.getHand(), + mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN), new GameSettings(), + mockView); turnControl.startTurn(); - StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, - blackOne, redTwo, redThree, redFour, blackTwo, blackThree)); - StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blackFour, - blackFive)); + StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne, + redTwo, redThree, redFour, blackTwo, blackThree)); + StoneSet oldSet2 = new StoneSet( + Arrays.asList(blueTwo, blackFour, blackFive)); table.drop(oldSet1, new Position(0, 0)); table.drop(oldSet2, new Position(0, 0)); mockHand.drop(blueThree, new Position(0, 0)); @@ -887,8 +884,8 @@ public class TurnControlTest { List<Pair<Stone, Position>> stones = new ArrayList<Pair<Stone, Position>>( mockHand.stones); - Collections.sort(stones, - new HumanTurnControl.HandStonePositionComparator()); + Collections + .sort(stones, new HumanTurnControl.HandStonePositionComparator()); assertEquals(stones.size(), 13); @@ -936,8 +933,8 @@ public class TurnControlTest { List<Pair<Stone, Position>> stones = new ArrayList<Pair<Stone, Position>>( mockHand.stones); - Collections.sort(stones, - new HumanTurnControl.HandStonePositionComparator()); + Collections + .sort(stones, new HumanTurnControl.HandStonePositionComparator()); assertEquals(stones.size(), 13); @@ -977,8 +974,8 @@ public class TurnControlTest { assertCollection(new ArrayList<Stone>()); - Set<Stone> expected = new HashSet<Stone>(Arrays.asList(redJoker, - blackJoker)); + Set<Stone> expected = new HashSet<Stone>( + Arrays.asList(redJoker, blackJoker)); assertEquals(expected, mockHand.pickups); Set<Stone> handStones = new HashSet<Stone>(); @@ -1005,8 +1002,7 @@ public class TurnControlTest { assertCollection(Arrays.asList(blackJoker)); - Set<Stone> expected = new HashSet<Stone>(Arrays.asList(redJoker, - black13)); + Set<Stone> expected = new HashSet<Stone>(Arrays.asList(redJoker, black13)); assertEquals(expected, mockHand.pickups); Set<Stone> handStones = new HashSet<Stone>(); |