summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJannis Harder <harder@informatik.uni-luebeck.de>2011-05-24 01:51:47 +0200
committerJannis Harder <harder@informatik.uni-luebeck.de>2011-05-24 01:51:47 +0200
commit102299d0ffc15a08167f6eab8b9813c2f7dcda3b (patch)
treeb7a82e10dff01742fd68b0ede985e0fa4bc44be8 /test
parent9290db240a10d107801a568e57d742a36052ccc0 (diff)
downloadJRummikub-102299d0ffc15a08167f6eab8b9813c2f7dcda3b.tar
JRummikub-102299d0ffc15a08167f6eab8b9813c2f7dcda3b.zip
Fixed invalid moves without laying out stones and cleaned up rule
checks git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@259 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test')
-rw-r--r--test/jrummikub/control/RoundControlTest.java72
1 files changed, 71 insertions, 1 deletions
diff --git a/test/jrummikub/control/RoundControlTest.java b/test/jrummikub/control/RoundControlTest.java
index 86847e0..550c2cb 100644
--- a/test/jrummikub/control/RoundControlTest.java
+++ b/test/jrummikub/control/RoundControlTest.java
@@ -131,6 +131,7 @@ public class RoundControlTest {
assertFalse(roundState
.getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut());
assertEquals(0, roundState.getTable().getSize());
+ assertEquals(14 + 6, hand.getSize());
}
/** Threshold=30 */
@@ -177,6 +178,7 @@ public class RoundControlTest {
assertFalse(roundState
.getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut());
assertEquals(0, roundState.getTable().getSize());
+ assertEquals(14 + 9, hand.getSize());
}
/** Threshold=30 */
@@ -246,6 +248,7 @@ public class RoundControlTest {
assertFalse(roundState
.getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut());
assertEquals(2, roundState.getTable().getSize());
+ assertEquals(14 + 6, hand.getSize());
}
/** Threshold=30 */
@@ -318,6 +321,69 @@ public class RoundControlTest {
assertFalse(roundState
.getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut());
assertEquals(2, roundState.getTable().getSize());
+ assertEquals(14 + 7, hand.getSize());
+ }
+
+ @Test
+ public void laidOutJustChangedTable() {
+ MockGameSettings gameSettings = new MockGameSettings();
+ RoundState roundState = new RoundState(gameSettings);
+ RoundControl roundControl = new RoundControl(roundState, view);
+ roundControl.startRound();
+ view.startTurnEvent.emit();
+ // Fake Turn to put stones on the table
+ Stone blueFour = new Stone(4, BLUE);
+ Stone blackFour = new Stone(4, BLACK);
+ Stone redFour = new Stone(4, RED);
+ Stone orangeFour = new Stone(4, ORANGE);
+
+ Stone blueFive = new Stone(5, BLUE);
+ Stone blueSix = new Stone(6, BLUE);
+ Stone blueSeven = new Stone(7, BLUE);
+
+ IHand hand = roundState.getActivePlayer().getHand();
+ hand.drop(blueFive, new Position(0, 0));
+ hand.drop(blueSix, new Position(0, 0));
+ hand.drop(blueSeven, new Position(0, 0));
+
+ hand.drop(redFour, new Position(0, 0));
+ hand.drop(blueFour, new Position(0, 0));
+ hand.drop(blackFour, new Position(0, 0));
+ hand.drop(orangeFour, new Position(0, 0));
+
+ view.handPanel.stoneClickEvent.emit(redFour, false);
+ view.handPanel.stoneClickEvent.emit(blueFour, true);
+ view.handPanel.stoneClickEvent.emit(blackFour, true);
+ view.handPanel.stoneClickEvent.emit(orangeFour, true);
+
+ view.tablePanel.clickEvent.emit(new Position(0, 0));
+
+ view.handPanel.stoneClickEvent.emit(blueFive, false);
+ view.handPanel.stoneClickEvent.emit(blueSix, true);
+ view.handPanel.stoneClickEvent.emit(blueSeven, true);
+
+ view.tablePanel.clickEvent.emit(new Position(0, 0));
+
+ view.playerPanel.endTurnEvent.emit();
+ assertEquals(2, roundState.getTable().getSize());
+ view.startTurnEvent.emit();
+
+ hand = roundState.getActivePlayer().getHand();
+
+ view.tablePanel.stoneClickEvent.emit(blueFour, false);
+ view.tablePanel.stoneClickEvent.emit(blueFive, true);
+ view.tablePanel.stoneClickEvent.emit(blueSix, true);
+ view.tablePanel.stoneClickEvent.emit(blueSeven, true);
+
+ assertFalse(roundState.getActivePlayer().getLaidOut());
+
+ view.tablePanel.clickEvent.emit(new Position(0, 0));
+
+ view.playerPanel.endTurnEvent.emit();
+ assertFalse(roundState
+ .getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut());
+ assertEquals(2, roundState.getTable().getSize());
+ assertEquals(14 + 3, hand.getSize());
}
/** Threshold=30 */
@@ -365,6 +431,7 @@ public class RoundControlTest {
assertTrue(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1)
.getLaidOut());
assertEquals(2, roundState.getTable().getSize());
+ assertEquals(14, hand.getSize());
}
/** */
@@ -408,6 +475,7 @@ public class RoundControlTest {
/** */
@Test
public void testTableValidHandChanged() {
+ testRoundState.players.get(0).setLaidOut(true);
testRound.startRound();
MockTable oldTable = testRoundState.table;
testTable.valid = true;
@@ -453,6 +521,7 @@ public class RoundControlTest {
/** */
@Test
public void testTableValidHandUnchanged() {
+ testRoundState.players.get(0).setLaidOut(true);
testRound.startRound();
MockTable oldTable = testRoundState.table;
testTable.valid = true;
@@ -473,6 +542,7 @@ public class RoundControlTest {
/** */
@Test
public void testTableInvalidHandUnchanged() {
+ testRoundState.players.get(1).setLaidOut(true);
testRound.startRound();
MockTable oldTable = testRoundState.table;
testTable.valid = false;
@@ -484,7 +554,7 @@ public class RoundControlTest {
view.getPlayerPanel().endTurnEvent.emit();
assertNull(testRoundState.setTable);
- assertEquals(14 + 1, testRoundState.players.get(0).hand.getSize());
+ assertEquals(14 + 3, testRoundState.players.get(0).hand.getSize());
assertEquals(1, testRoundState.activePlayer);
checkTurnStartSetUp();