From d5560a8a6ef6e8d8a272451661605f0e58380423 Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Thu, 5 May 2011 00:43:11 +0200 Subject: Check displaying of table in RoundControl tests git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@137 72836036-5685-4462-b002-a69064685172 --- test/jrummikub/control/RoundControlTest.java | 38 +++++++++++++++++++++++----- test/jrummikub/view/MockTablePanel.java | 2 ++ 2 files changed, 34 insertions(+), 6 deletions(-) (limited to 'test/jrummikub') diff --git a/test/jrummikub/control/RoundControlTest.java b/test/jrummikub/control/RoundControlTest.java index 7d13ff0..5b95ab2 100644 --- a/test/jrummikub/control/RoundControlTest.java +++ b/test/jrummikub/control/RoundControlTest.java @@ -6,11 +6,16 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; + +import java.util.Iterator; + +import jrummikub.model.GameState; import jrummikub.model.MockGameState; import jrummikub.model.MockTable; import jrummikub.model.Position; import jrummikub.model.Stone; import jrummikub.model.StoneSet; +import jrummikub.util.Pair; import jrummikub.view.MockView; import org.junit.Before; @@ -20,16 +25,22 @@ public class RoundControlTest { private MockView view; private MockGameState testGameState; private RoundControl testRound; + private MockTable newTable; @Before public void setup() { view = new MockView(); testGameState = new MockGameState(); testRound = new RoundControl(testGameState, view); + Stone stone = testGameState.getGameHeap().drawStone(); + testGameState.table.drop(new StoneSet(stone), new Position(5, 0)); + newTable = new MockTable(); + newTable.drop(new StoneSet(stone), new Position(5, 0)); + } private void checkCorrectlyDealed() { - assertEquals(106 - testGameState.getPlayerCount() * 14, testGameState + assertEquals(106 - testGameState.getPlayerCount() * 14 - testGameState.table.getSize(), testGameState .getGameHeap().getSize()); for (int i = 0; i < testGameState.getPlayerCount(); i++) { assertEquals(14, testGameState.getPlayer(i).getHand().getSize()); @@ -43,6 +54,18 @@ public class RoundControlTest { assertNotNull(view.getTablePanel().rightPlayerName); assertTrue(view.displayStartTurnPanel); assertFalse(view.startTurnEvent.listeners.isEmpty()); + checkTableDisplay(); + } + + private void checkTableDisplay() { + Iterator> stoneSetsView = view.tablePanel.stoneSets.iterator(); + Iterator> stoneSetsModel = testGameState.table.sets.iterator(); + + while(stoneSetsView.hasNext()) { + assertTrue(stoneSetsModel.hasNext()); + assertSame(stoneSetsView.next(), stoneSetsModel.next()); + } + assertFalse(stoneSetsModel.hasNext()); } private void resetTurnStart() { @@ -66,12 +89,19 @@ public class RoundControlTest { checkTurnStartSetUp(); } + + @Test + public void testStartRoundDisplayOnly() { + testRound.startRound(); + checkCorrectlyDealed(); + + checkTableDisplay(); + } @Test public void testTableValidHandChanged() { testRound.startRound(); MockTable oldTable = testGameState.table; - MockTable newTable = new MockTable(); newTable.valid = true; oldTable.clonedTable = newTable; @@ -92,7 +122,6 @@ public class RoundControlTest { public void testTableInvalidHandChanged() { testRound.startRound(); MockTable oldTable = testGameState.table; - MockTable newTable = new MockTable(); newTable.valid = false; oldTable.clonedTable = newTable; @@ -114,7 +143,6 @@ public class RoundControlTest { public void testTableValidHandUnchanged() { testRound.startRound(); MockTable oldTable = testGameState.table; - MockTable newTable = new MockTable(); newTable.valid = true; oldTable.clonedTable = newTable; @@ -135,7 +163,6 @@ public class RoundControlTest { public void testTableInvalidHandUnchanged() { testRound.startRound(); MockTable oldTable = testGameState.table; - MockTable newTable = new MockTable(); newTable.valid = false; oldTable.clonedTable = newTable; @@ -156,7 +183,6 @@ public class RoundControlTest { public void testWinning() { testRound.startRound(); MockTable oldTable = testGameState.table; - MockTable newTable = new MockTable(); newTable.valid = true; oldTable.clonedTable = newTable; diff --git a/test/jrummikub/view/MockTablePanel.java b/test/jrummikub/view/MockTablePanel.java index 65842c2..151cc7e 100644 --- a/test/jrummikub/view/MockTablePanel.java +++ b/test/jrummikub/view/MockTablePanel.java @@ -21,6 +21,8 @@ public class MockTablePanel implements ITablePanel { public String leftPlayerName; public String topPlayerName; public String rightPlayerName; + + public Iterable> stoneSets; @Override public IEvent2 getStoneClickEvent() { -- cgit v1.2.3