summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mock/jrummikub/view/MockView.java4
-rw-r--r--test/jrummikub/control/RoundControlTest.java104
2 files changed, 64 insertions, 44 deletions
diff --git a/mock/jrummikub/view/MockView.java b/mock/jrummikub/view/MockView.java
index 1472742..8dc261b 100644
--- a/mock/jrummikub/view/MockView.java
+++ b/mock/jrummikub/view/MockView.java
@@ -47,6 +47,8 @@ public class MockView implements IView {
public boolean isSidePanelVisible = false;
/** */
public boolean isConnectPanelVisible = false;
+ /** */
+ public boolean pauseModeEnabled = false;
/** */
public Collection<Stone> selectedStones;
@@ -244,7 +246,7 @@ public class MockView implements IView {
@Override
public void enablePauseMode(boolean enable) {
- // TODO Auto-generated method stub
+ pauseModeEnabled = enable;
}
@Override
diff --git a/test/jrummikub/control/RoundControlTest.java b/test/jrummikub/control/RoundControlTest.java
index a6e1bbb..50219c7 100644
--- a/test/jrummikub/control/RoundControlTest.java
+++ b/test/jrummikub/control/RoundControlTest.java
@@ -100,21 +100,24 @@ 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, new GameState());
roundControl = new RoundControl(roundState, view);
}
private void checkCorrectlyDealt() {
GameSettings settings = testRoundState.getGameSettings();
- int totalStones = settings.getHighestValue() * settings.getStoneSetNumber()
+ int totalStones = settings.getHighestValue()
+ * settings.getStoneSetNumber()
* settings.getStoneColors().size() + settings.getJokerNumber();
assertEquals(
totalStones - testRoundState.getPlayerCount()
* settings.getNumberOfStonesDealt()
- - testRoundState.table.getSize(), testRoundState.getStoneHeap()
- .getSize());
+ - testRoundState.table.getSize(), testRoundState
+ .getStoneHeap().getSize());
for (int i = 0; i < testRoundState.getPlayerCount(); i++) {
assertEquals(settings.getNumberOfStonesDealt(), testRoundState
.getNthNextPlayer(i).getHand().getSize());
@@ -185,8 +188,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, roundState.getActivePlayer().getHand().getSize());
}
@@ -208,7 +211,8 @@ public class RoundControlTest {
assertFalse(roundState.getNthNextPlayer(-1).getLaidOut());
assertEquals(0, roundState.getTable().getSize());
- assertEquals(14 + 1, roundState.getNthNextPlayer(-1).getHand().getSize());
+ assertEquals(14 + 1, roundState.getNthNextPlayer(-1).getHand()
+ .getSize());
}
/** Threshold=30 */
@@ -245,7 +249,8 @@ public class RoundControlTest {
assertFalse(roundState.getNthNextPlayer(-1).getLaidOut());
assertEquals(0, roundState.getTable().getSize());
- assertEquals(14 + 9, roundState.getNthNextPlayer(-1).getHand().getSize());
+ assertEquals(14 + 9, roundState.getNthNextPlayer(-1).getHand()
+ .getSize());
}
private void dropStonesOnHand(IHand hand, List<Stone> stones) {
@@ -304,7 +309,8 @@ public class RoundControlTest {
view.acknowledgeInvalidEvent.emit();
assertFalse(roundState.getNthNextPlayer(-1).getLaidOut());
assertEquals(2, roundState.getTable().getSize());
- assertEquals(14 + 6, roundState.getNthNextPlayer(-1).getHand().getSize());
+ assertEquals(14 + 6, roundState.getNthNextPlayer(-1).getHand()
+ .getSize());
}
/** Threshold=30 */
@@ -356,7 +362,8 @@ public class RoundControlTest {
view.acknowledgeInvalidEvent.emit();
assertFalse(roundState.getNthNextPlayer(-1).getLaidOut());
assertEquals(2, roundState.getTable().getSize());
- assertEquals(14 + 7, roundState.getNthNextPlayer(-1).getHand().getSize());
+ assertEquals(14 + 7, roundState.getNthNextPlayer(-1).getHand()
+ .getSize());
}
/** */
@@ -409,7 +416,8 @@ public class RoundControlTest {
view.acknowledgeInvalidEvent.emit();
assertFalse(roundState.getNthNextPlayer(-1).getLaidOut());
assertEquals(2, roundState.getTable().getSize());
- assertEquals(14 + 3, roundState.getNthNextPlayer(-1).getHand().getSize());
+ assertEquals(14 + 3, roundState.getNthNextPlayer(-1).getHand()
+ .getSize());
}
/** Threshold=30 */
@@ -492,9 +500,8 @@ public class RoundControlTest {
testTable.valid = true;
testTable.sets.clear();
testTable.drop(
- new StoneSet(Arrays
- .asList(blueEight, blackEight, redEight, orangeEight)),
- new Position(0, 0));
+ new StoneSet(Arrays.asList(blueEight, blackEight, redEight,
+ orangeEight)), new Position(0, 0));
oldTable.clonedTable = testTable;
view.startTurnEvent.emit();
@@ -523,10 +530,9 @@ public class RoundControlTest {
testTable.valid = false;
testTable.sets.clear();
- testTable
- .drop(
- new StoneSet(Arrays.asList(blueEight, blackEight, redEight,
- blackFour)), new Position(0, 0));
+ testTable.drop(
+ new StoneSet(Arrays.asList(blueEight, blackEight, redEight,
+ blackFour)), new Position(0, 0));
oldTable.clonedTable = testTable;
view.startTurnEvent.emit();
@@ -582,9 +588,8 @@ public class RoundControlTest {
MockTable oldTable = testRoundState.table;
oldTable.sets.clear();
oldTable.drop(
- new StoneSet(Arrays
- .asList(blueEight, blackEight, redEight, orangeEight)),
- new Position(0, 0));
+ new StoneSet(Arrays.asList(blueEight, blackEight, redEight,
+ orangeEight)), new Position(0, 0));
testTable.valid = false;
testTable.sets.clear();
@@ -709,19 +714,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();
@@ -755,19 +761,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);
@@ -852,4 +858,16 @@ public class RoundControlTest {
}
assertEquals(TurnMode.NORMAL_TURN, view.playerPanel.turnMode);
}
+
+ /** */
+ @Test
+ public void testPauseAndContinue() {
+ testRound.startRound();
+ testRound.startTurn();
+ view.startTurnEvent.emit();
+ view.pauseEvent.emit();
+ assertTrue(view.pauseModeEnabled);
+ view.endPauseEvent.emit();
+ assertFalse(view.pauseModeEnabled);
+ }
}