summaryrefslogtreecommitdiffstats
path: root/test/jrummikub/control
diff options
context:
space:
mode:
Diffstat (limited to 'test/jrummikub/control')
-rw-r--r--test/jrummikub/control/RoundControlTest.java109
-rw-r--r--test/jrummikub/control/turn/TurnControlTest.java6
2 files changed, 64 insertions, 51 deletions
diff --git a/test/jrummikub/control/RoundControlTest.java b/test/jrummikub/control/RoundControlTest.java
index fd2d3fb..f5afeea 100644
--- a/test/jrummikub/control/RoundControlTest.java
+++ b/test/jrummikub/control/RoundControlTest.java
@@ -70,8 +70,10 @@ public class RoundControlTest {
gameSettings.getPlayerList().add(new PlayerSettings("Ida", Color.RED));
gameSettings.getPlayerList().add(
new PlayerSettings("Matthias", Color.YELLOW));
- gameSettings.getPlayerList().add(new PlayerSettings("Jannis", Color.GREEN));
- gameSettings.getPlayerList().add(new PlayerSettings("Bennet", Color.BLACK));
+ gameSettings.getPlayerList().add(
+ new PlayerSettings("Jannis", Color.GREEN));
+ gameSettings.getPlayerList().add(
+ new PlayerSettings("Bennet", Color.BLACK));
roundState = new RoundState(gameSettings);
roundControl = new RoundControl(roundState, view);
}
@@ -81,7 +83,8 @@ public class RoundControlTest {
- testRoundState.table.getSize(), testRoundState.getGameHeap()
.getSize());
for (int i = 0; i < testRoundState.getPlayerCount(); i++) {
- assertEquals(14, testRoundState.getNthNextPlayer(i).getHand().getSize());
+ assertEquals(14, testRoundState.getNthNextPlayer(i).getHand()
+ .getSize());
}
}
@@ -142,8 +145,8 @@ public class RoundControlTest {
view.tablePanel.clickEvent.emit(new Position(0, 0));
view.playerPanel.endTurnEvent.emit();
- assertFalse(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1)
- .getLaidOut());
+ assertFalse(roundState
+ .getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut());
assertEquals(0, roundState.getTable().getSize());
assertEquals(14 + 6, hand.getSize());
}
@@ -163,8 +166,8 @@ public class RoundControlTest {
assertFalse(roundState.getActivePlayer().getLaidOut());
view.playerPanel.endTurnEvent.emit();
- assertFalse(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1)
- .getLaidOut());
+ assertFalse(roundState
+ .getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut());
assertEquals(0, roundState.getTable().getSize());
assertEquals(14 + 1, hand.getSize());
}
@@ -211,8 +214,8 @@ public class RoundControlTest {
view.tablePanel.clickEvent.emit(new Position(0, 0));
view.playerPanel.endTurnEvent.emit();
- assertFalse(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1)
- .getLaidOut());
+ assertFalse(roundState
+ .getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut());
assertEquals(0, roundState.getTable().getSize());
assertEquals(14 + 9, hand.getSize());
}
@@ -282,8 +285,8 @@ public class RoundControlTest {
view.tablePanel.clickEvent.emit(new Position(0, 0));
view.playerPanel.endTurnEvent.emit();
- assertFalse(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1)
- .getLaidOut());
+ assertFalse(roundState
+ .getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut());
assertEquals(2, roundState.getTable().getSize());
assertEquals(14 + 6, hand.getSize());
}
@@ -356,8 +359,8 @@ public class RoundControlTest {
view.tablePanel.clickEvent.emit(new Position(0, 0));
view.playerPanel.endTurnEvent.emit();
- assertFalse(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1)
- .getLaidOut());
+ assertFalse(roundState
+ .getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut());
assertEquals(2, roundState.getTable().getSize());
assertEquals(14 + 7, hand.getSize());
}
@@ -420,8 +423,8 @@ public class RoundControlTest {
view.tablePanel.clickEvent.emit(new Position(0, 0));
view.playerPanel.endTurnEvent.emit();
- assertFalse(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1)
- .getLaidOut());
+ assertFalse(roundState
+ .getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut());
assertEquals(2, roundState.getTable().getSize());
assertEquals(14 + 3, hand.getSize());
}
@@ -679,12 +682,15 @@ public class RoundControlTest {
Stone blueTwo = new Stone(2, BLUE);
Stone blueThree = new Stone(3, BLUE);
Stone blueFour = new Stone(4, BLUE);
- StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne));
+ StoneSet oldSet1 = new StoneSet(
+ Arrays.asList(blueOne, redOne, blackOne));
StoneSet oldSet2 = new StoneSet(blueTwo);
oldTable.drop(oldSet1, new Position(0, 0));
oldTable.drop(oldSet2, new Position(0, 0));
- StoneSet newSet1 = new StoneSet(Arrays.asList(blueOne, blueTwo, blueFour));
- StoneSet newSet2 = new StoneSet(Arrays.asList(redOne, blackOne, blueThree));
+ StoneSet newSet1 = new StoneSet(Arrays.asList(blueOne, blueTwo,
+ blueFour));
+ StoneSet newSet2 = new StoneSet(Arrays.asList(redOne, blackOne,
+ blueThree));
newTable.drop(newSet1, new Position(0, 0));
newTable.drop(newSet2, new Position(0, 0));
@@ -701,7 +707,7 @@ public class RoundControlTest {
/** */
@Test
public void testTableSetDifference() {
- ITable oldTable = new Table();
+ ITable oldTable = new Table(gameSettings);
Stone blueOne = new Stone(1, BLUE);
Stone redOne = new Stone(1, RED);
Stone blackOne = new Stone(1, BLACK);
@@ -709,14 +715,15 @@ public class RoundControlTest {
Stone blueTwo = new Stone(2, BLUE);
Stone blueThree = new Stone(3, BLUE);
Stone blueFour = new Stone(4, BLUE);
- StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne,
- orangeOne));
- StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blueThree, blueFour));
+ StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne,
+ blackOne, orangeOne));
+ StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blueThree,
+ blueFour));
oldTable.drop(oldSet1, new Position(0, 0));
oldTable.drop(oldSet2, new Position(0, 0));
ITable newTable = (Table) oldTable.clone();
- List<StoneSet> newSets = RoundControl
- .tableSetDifference(oldTable, newTable);
+ List<StoneSet> newSets = RoundControl.tableSetDifference(oldTable,
+ newTable);
List<StoneSet> vanishedSets = RoundControl.tableSetDifference(newTable,
oldTable);
@@ -724,8 +731,8 @@ public class RoundControlTest {
assertTrue(vanishedSets.isEmpty());
newTable.pickUp(oldSet2);
- newTable.drop(oldSet2.join(new StoneSet(new Stone(5, BLUE))), new Position(
- 0, 0));
+ newTable.drop(oldSet2.join(new StoneSet(new Stone(5, BLUE))),
+ new Position(0, 0));
newSets = RoundControl.tableSetDifference(oldTable, newTable);
vanishedSets = RoundControl.tableSetDifference(newTable, oldTable);
@@ -737,7 +744,8 @@ public class RoundControlTest {
Stone redTwo = new Stone(2, RED);
Stone redThree = new Stone(3, RED);
Stone redFour = new Stone(4, RED);
- StoneSet oldSet3 = new StoneSet(Arrays.asList(redTwo, redThree, redFour));
+ StoneSet oldSet3 = new StoneSet(
+ Arrays.asList(redTwo, redThree, redFour));
ITable newTable2 = (Table) oldTable.clone();
newTable2.drop(oldSet3, new Position(0, 0));
newSets = RoundControl.tableSetDifference(oldTable, newTable2);
@@ -799,19 +807,20 @@ public class RoundControlTest {
}
testRoundState.players.get(0).laidOut = true;
- testRoundState.players.get(0).hand.drop(new Stone(1, RED), new Position(0,
- 0));
- testRoundState.players.get(0).hand.drop(new Stone(2, RED), new Position(0,
- 0));
+ testRoundState.players.get(0).hand.drop(new Stone(1, RED),
+ new Position(0, 0));
+ testRoundState.players.get(0).hand.drop(new Stone(2, RED),
+ new Position(0, 0));
testRoundState.players.get(1).laidOut = true;
- testRoundState.players.get(1).hand.drop(new Stone(RED), new Position(0, 0));
- testRoundState.players.get(2).laidOut = false;
- testRoundState.players.get(2).hand.drop(new Stone(9, RED), new Position(0,
- 0));
- testRoundState.players.get(2).hand.drop(new Stone(10, RED), new Position(0,
- 0));
- testRoundState.players.get(2).hand.drop(new Stone(11, RED), new Position(0,
+ testRoundState.players.get(1).hand.drop(new Stone(RED), new Position(0,
0));
+ testRoundState.players.get(2).laidOut = false;
+ testRoundState.players.get(2).hand.drop(new Stone(9, RED),
+ new Position(0, 0));
+ testRoundState.players.get(2).hand.drop(new Stone(10, RED),
+ new Position(0, 0));
+ testRoundState.players.get(2).hand.drop(new Stone(11, RED),
+ new Position(0, 0));
testRoundState.players.get(3).laidOut = true;
testRound.endOfRound();
@@ -845,19 +854,19 @@ public class RoundControlTest {
}
testRoundState.players.get(0).laidOut = true;
- testRoundState.players.get(0).hand.drop(new Stone(1, RED), new Position(0,
- 0));
- testRoundState.players.get(0).hand.drop(new Stone(2, RED), new Position(0,
- 0));
+ testRoundState.players.get(0).hand.drop(new Stone(1, RED),
+ new Position(0, 0));
+ testRoundState.players.get(0).hand.drop(new Stone(2, RED),
+ new Position(0, 0));
testRoundState.players.get(1).laidOut = true;
- testRoundState.players.get(1).hand.drop(new Stone(3, RED), new Position(0,
- 0));
+ testRoundState.players.get(1).hand.drop(new Stone(3, RED),
+ new Position(0, 0));
testRoundState.players.get(2).laidOut = true;
- testRoundState.players.get(2).hand.drop(new Stone(3, BLUE), new Position(0,
- 0));
+ testRoundState.players.get(2).hand.drop(new Stone(3, BLUE),
+ new Position(0, 0));
testRoundState.players.get(3).laidOut = false;
- testRoundState.players.get(3).hand.drop(new Stone(13, RED), new Position(0,
- 0));
+ testRoundState.players.get(3).hand.drop(new Stone(13, RED),
+ new Position(0, 0));
testRound.endOfRound();
assertTrue(roundEnded);
@@ -905,7 +914,7 @@ public class RoundControlTest {
view.playerPanel.redealEvent.emit();
assertTrue(roundRestarted);
}
-
+
/** */
@Test
public void testRedealDisallowed() {
@@ -924,7 +933,7 @@ public class RoundControlTest {
}
assertFalse(view.playerPanel.inspectOnly);
}
-
+
/** */
@Test
public void testRedealAllowed() {
diff --git a/test/jrummikub/control/turn/TurnControlTest.java b/test/jrummikub/control/turn/TurnControlTest.java
index 11c4c2b..db382ca 100644
--- a/test/jrummikub/control/turn/TurnControlTest.java
+++ b/test/jrummikub/control/turn/TurnControlTest.java
@@ -17,7 +17,7 @@ import java.util.List;
import java.util.Set;
import jrummikub.control.ITurnTimer;
-import jrummikub.control.turn.HumanTurnControl;
+import jrummikub.model.GameSettings;
import jrummikub.model.IHand;
import jrummikub.model.ITable;
import jrummikub.model.MockHand;
@@ -45,6 +45,10 @@ public class TurnControlTest {
StoneSet[] getSetArray() {
return objects.keySet().toArray(new StoneSet[0]);
}
+
+ AccessibleTable (){
+ super (new GameSettings());
+ }
}
class MockTimer implements ITurnTimer {