summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorIda Massow <massow@informatik.uni-luebeck.de>2011-06-21 02:19:48 +0200
committerIda Massow <massow@informatik.uni-luebeck.de>2011-06-21 02:19:48 +0200
commit2a31f0d9a6aa230ea499b09c49cdbccc7fc053b2 (patch)
tree6c99c3807f6bee7ce0fab4a4223345c849fa585b /test
parentec4faf57b16a857016374b6b34eb2c5cebf2bd2c (diff)
downloadJRummikub-2a31f0d9a6aa230ea499b09c49cdbccc7fc053b2.tar
JRummikub-2a31f0d9a6aa230ea499b09c49cdbccc7fc053b2.zip
Fix weitere tests
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@528 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test')
-rw-r--r--test/jrummikub/control/turn/AIControlTest.java71
1 files changed, 35 insertions, 36 deletions
diff --git a/test/jrummikub/control/turn/AIControlTest.java b/test/jrummikub/control/turn/AIControlTest.java
index f58796e..91d0b94 100644
--- a/test/jrummikub/control/turn/AIControlTest.java
+++ b/test/jrummikub/control/turn/AIControlTest.java
@@ -1,22 +1,24 @@
package jrummikub.control.turn;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import java.awt.Color;
+import jrummikub.control.RoundControl;
import jrummikub.model.GameSettings;
+import jrummikub.model.GameState;
import jrummikub.model.IHand;
-import jrummikub.model.IPlayer;
-import jrummikub.model.ITable;
-import jrummikub.model.Player;
+import jrummikub.model.IRoundState;
import jrummikub.model.PlayerSettings;
import jrummikub.model.PlayerSettings.Type;
import jrummikub.model.Position;
+import jrummikub.model.RoundState;
import jrummikub.model.Stone;
import jrummikub.model.StoneColor;
-import jrummikub.model.Table;
import jrummikub.util.IListener;
-import jrummikub.util.IListener3;
+import jrummikub.util.IListener2;
import jrummikub.view.MockView;
import org.junit.Before;
@@ -26,10 +28,9 @@ import org.junit.Test;
public class AIControlTest {
ITurnControl aiControl;
+ IRoundState roundState;
GameSettings gameSettings;
PlayerSettings playerSettings;
- IPlayer player;
- ITable table;
MockView view;
boolean turnEnded;
@@ -39,23 +40,24 @@ public class AIControlTest {
@Before
public void setUp() {
aiControl = TurnControlFactory.getFactory(Type.COMPUTER).create();
- ((AIControl) aiControl).useBackgroundThread = false;
+ AIControl.useBackgroundThread = false;
gameSettings = new GameSettings();
playerSettings = new PlayerSettings("ROBOT_01", Color.GRAY);
- player = new Player(playerSettings);
- table = new Table(gameSettings);
+ gameSettings.getPlayerList().add(playerSettings);
+ roundState = new RoundState(gameSettings, new GameState());
view = new MockView();
turnEnded = false;
redealt = false;
- aiControl.getEndOfTurnEvent().add(new IListener3<IHand, ITable, ITable>() {
- @Override
- public void handle(IHand oldHand, ITable oldTable, ITable newTable) {
- turnEnded = true;
- }
-
- });
-
+ aiControl.getEndOfTurnEvent().add(
+ new IListener2<IRoundState, RoundControl.InvalidTurnInfo>() {
+ @Override
+ public void handle(IRoundState state,
+ RoundControl.InvalidTurnInfo value2) {
+ turnEnded = true;
+ roundState = state;
+ }
+ });
aiControl.getRedealEvent().add(new IListener() {
@Override
@@ -65,7 +67,7 @@ public class AIControlTest {
});
- IHand hand = player.getHand();
+ IHand hand = roundState.getActivePlayer().getHand();
hand.drop(new Stone(11, StoneColor.RED), new Position(0, 0));
hand.drop(new Stone(12, StoneColor.RED), new Position(0, 0));
hand.drop(new Stone(13, StoneColor.RED), new Position(0, 0));
@@ -73,47 +75,44 @@ 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(roundState,
+ TurnMode.MAY_REDEAL), gameSettings, view);
aiControl.startTurn();
assertTrue(turnEnded);
assertFalse(redealt);
- assertEquals(table.getSize(), 0);
+ assertEquals(0, roundState.getTable().getSize());
}
/**
* @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(roundState,
+ TurnMode.INSPECT_ONLY), gameSettings, view);
aiControl.startTurn();
assertTrue(turnEnded);
assertFalse(redealt);
- assertEquals(table.getSize(), 0);
+ assertEquals(0, roundState.getTable().getSize());
}
/**
* @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(roundState,
+ TurnMode.NORMAL_TURN), gameSettings, view);
aiControl.startTurn();
assertTrue(turnEnded);
assertFalse(redealt);
- assertEquals(table.getSize(), 1);
- assertEquals(player.getHand().getSize(), 0);
+ assertEquals(1, roundState.getTable().getSize());
+ assertEquals(0, roundState.getActivePlayer().getHand().getSize());
}
}