diff options
author | Ida Massow <massow@informatik.uni-luebeck.de> | 2011-06-21 01:46:36 +0200 |
---|---|---|
committer | Ida Massow <massow@informatik.uni-luebeck.de> | 2011-06-21 01:46:36 +0200 |
commit | 72912be6008039ea81f875fe3be911cd4d66a8d4 (patch) | |
tree | f519e7666719e1ede5ac2ba084484b91bbcfa0d9 /test/jrummikub/control/RoundControlTest.java | |
parent | f304f20cbccca0fb959a4d2fabb31946e11580cb (diff) | |
download | JRummikub-72912be6008039ea81f875fe3be911cd4d66a8d4.tar JRummikub-72912be6008039ea81f875fe3be911cd4d66a8d4.zip |
Tests für RoundControl gefixt
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@524 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test/jrummikub/control/RoundControlTest.java')
-rw-r--r-- | test/jrummikub/control/RoundControlTest.java | 126 |
1 files changed, 77 insertions, 49 deletions
diff --git a/test/jrummikub/control/RoundControlTest.java b/test/jrummikub/control/RoundControlTest.java index 8785fba..80a91be 100644 --- a/test/jrummikub/control/RoundControlTest.java +++ b/test/jrummikub/control/RoundControlTest.java @@ -4,6 +4,7 @@ import static jrummikub.model.StoneColor.*; import static org.junit.Assert.*; import java.awt.Color; +import java.util.Arrays; import java.util.Iterator; import jrummikub.control.turn.TurnMode; @@ -97,21 +98,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, null); 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.getGameHeap() - .getSize()); + - testRoundState.table.getSize(), testRoundState + .getGameHeap().getSize()); for (int i = 0; i < testRoundState.getPlayerCount(); i++) { assertEquals(settings.getNumberOfStonesDealt(), testRoundState .getNthNextPlayer(i).getHand().getSize()); @@ -182,8 +186,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()); } @@ -205,7 +209,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 */ @@ -246,7 +251,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()); } /** Threshold=30 */ @@ -304,7 +310,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 */ @@ -364,7 +371,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()); } /** */ @@ -417,7 +425,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 */ @@ -487,8 +496,7 @@ public class RoundControlTest { /** */ @Test - public void testTableValidHandChanged() { - fail(); + public void testTableValidTableChanged() { testRoundState.players.get(0).setLaidOut(true); testRound.startRound(); for (int i = 0; i < 4; i++) { @@ -496,18 +504,23 @@ public class RoundControlTest { view.playerPanel.endTurnEvent.emit(); } MockTable oldTable = testRoundState.table; + oldTable.sets.clear(); + testTable.valid = true; + testTable.sets.clear(); + testTable.drop( + new StoneSet(Arrays.asList(blueEight, blackEight, redEight, + orangeEight)), new Position(0, 0)); oldTable.clonedTable = testTable; view.startTurnEvent.emit(); assertSame(BottomPanelType.HUMAN_HAND_PANEL, view.bottomPanelType); - IHand hand = testRoundState.players.get(0).hand; - hand.pickUp(hand.iterator().next().getFirst()); resetTurnStart(); view.getPlayerPanel().endTurnEvent.emit(); assertSame(testTable, testRoundState.setTable); + assertEquals(14, testRoundState.players.get(0).getHand().getSize()); assertEquals(1, testRoundState.activePlayer); checkTurnStartSetUp(); @@ -515,37 +528,38 @@ public class RoundControlTest { /** */ @Test - public void testTableInvalidHandChanged() { - fail(); + public void testTableInvalidTableChanged() { testRound.startRound(); for (int i = 0; i < 4; i++) { view.startTurnEvent.emit(); view.playerPanel.endTurnEvent.emit(); } MockTable oldTable = testRoundState.table; + oldTable.sets.clear(); + testTable.valid = false; + testTable.sets.clear(); + testTable.drop( + new StoneSet(Arrays.asList(blueEight, blackEight, redEight, + blackFour)), new Position(0, 0)); oldTable.clonedTable = testTable; - IHand hand = testRoundState.getActivePlayer().getHand(); view.startTurnEvent.emit(); assertSame(BottomPanelType.HUMAN_HAND_PANEL, view.bottomPanelType); - Stone stone = hand.iterator().next().getFirst(); - hand.pickUp(stone); - testTable.drop(new StoneSet(stone), new Position(0, 0)); + resetTurnStart(); view.getPlayerPanel().endTurnEvent.emit(); view.acknowledgeInvalidEvent.emit(); assertNull(testRoundState.setTable); assertEquals(1, testRoundState.activePlayer); - assertEquals(14 + 3, testRoundState.players.get(0).hand.getSize()); + assertEquals(14 + 4 + 3, testRoundState.players.get(0).hand.getSize()); checkTurnStartSetUp(); } /** */ @Test - public void testTableValidHandUnchanged() { - fail(); + public void testTableValidTabelUnchanged() { testRoundState.players.get(0).setLaidOut(true); testRound.startRound(); for (int i = 0; i < 4; i++) { @@ -553,7 +567,10 @@ public class RoundControlTest { view.playerPanel.endTurnEvent.emit(); } MockTable oldTable = testRoundState.table; + oldTable.sets.clear(); + testTable.valid = true; + testTable.sets.clear(); oldTable.clonedTable = testTable; view.startTurnEvent.emit(); @@ -570,8 +587,7 @@ public class RoundControlTest { /** */ @Test - public void testTableInvalidHandUnchanged() { - fail(); + public void testTableInvalidTabelReordered() { testRoundState.players.get(1).setLaidOut(true); testRound.startRound(); for (int i = 0; i < 4; i++) { @@ -579,11 +595,22 @@ public class RoundControlTest { view.playerPanel.endTurnEvent.emit(); } MockTable oldTable = testRoundState.table; + oldTable.sets.clear(); + oldTable.drop( + new StoneSet(Arrays.asList(blueEight, blackEight, redEight, + orangeEight)), new Position(0, 0)); + testTable.valid = false; - oldTable.clonedTable = testTable; + testTable.sets.clear(); + oldTable.clonedTable = testTable; + testTable.drop(new StoneSet(Arrays.asList(blueEight, blackEight)), + new Position(0, 0)); + testTable.drop(new StoneSet(Arrays.asList(redEight, orangeEight)), + new Position(0, 0)); view.startTurnEvent.emit(); assertSame(BottomPanelType.HUMAN_HAND_PANEL, view.bottomPanelType); + resetTurnStart(); view.getPlayerPanel().endTurnEvent.emit(); view.acknowledgeInvalidEvent.emit(); @@ -696,19 +723,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(); @@ -742,19 +770,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); |