diff options
author | Ida Massow <massow@informatik.uni-luebeck.de> | 2011-06-22 11:08:17 +0200 |
---|---|---|
committer | Ida Massow <massow@informatik.uni-luebeck.de> | 2011-06-22 11:08:17 +0200 |
commit | 65e08c508cd608ea73058bbc5c79407d00bb261c (patch) | |
tree | 32a79dd5f22cee2d80884bef1a5f889e926d224e | |
parent | e9b2de87bca4e0ba34236455e2c25c9f17be26d3 (diff) | |
download | JRummikub-65e08c508cd608ea73058bbc5c79407d00bb261c.tar JRummikub-65e08c508cd608ea73058bbc5c79407d00bb261c.zip |
Tests und Kommentare
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@594 72836036-5685-4462-b002-a69064685172
-rw-r--r-- | mock/jrummikub/view/MockView.java | 4 | ||||
-rw-r--r-- | test/jrummikub/control/RoundControlTest.java | 104 |
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); + } } |