From c708a0b648cb0b2df6d11b722f76c055e3586c01 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 21 Jun 2011 03:54:43 +0200 Subject: Fixed tests git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@537 72836036-5685-4462-b002-a69064685172 --- test/jrummikub/control/turn/AIControlTest.java | 10 +- test/jrummikub/control/turn/TurnControlTest.java | 112 ++++++++++------------- 2 files changed, 52 insertions(+), 70 deletions(-) (limited to 'test') diff --git a/test/jrummikub/control/turn/AIControlTest.java b/test/jrummikub/control/turn/AIControlTest.java index 722e464..dca6466 100644 --- a/test/jrummikub/control/turn/AIControlTest.java +++ b/test/jrummikub/control/turn/AIControlTest.java @@ -1,8 +1,6 @@ package jrummikub.control.turn; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import java.awt.Color; @@ -82,7 +80,7 @@ public class AIControlTest { @Test(timeout = 10000) public void testTurnZeroNoRedealing() throws InterruptedException { aiControl.setup(new ITurnControl.TurnInfo(roundState, - TurnMode.MAY_REDEAL), gameSettings, view); + TurnMode.MAY_REDEAL, false), gameSettings, view); aiControl.startTurn(); assertTrue(turnEnded); assertFalse(redealt); @@ -96,7 +94,7 @@ public class AIControlTest { @Test(timeout = 10000) public void testTurnZeroNotMelding() throws InterruptedException { aiControl.setup(new ITurnControl.TurnInfo(roundState, - TurnMode.INSPECT_ONLY), gameSettings, view); + TurnMode.INSPECT_ONLY, false), gameSettings, view); aiControl.startTurn(); assertTrue(turnEnded); assertFalse(redealt); @@ -110,7 +108,7 @@ public class AIControlTest { @Test public void testNormalTurnMelding() throws InterruptedException { aiControl.setup(new ITurnControl.TurnInfo(roundState, - TurnMode.NORMAL_TURN), gameSettings, view); + TurnMode.NORMAL_TURN, false), gameSettings, view); aiControl.startTurn(); assertTrue(turnEnded); assertFalse(redealt); diff --git a/test/jrummikub/control/turn/TurnControlTest.java b/test/jrummikub/control/turn/TurnControlTest.java index dd1176f..ecd76ac 100644 --- a/test/jrummikub/control/turn/TurnControlTest.java +++ b/test/jrummikub/control/turn/TurnControlTest.java @@ -1,13 +1,7 @@ package jrummikub.control.turn; -import static jrummikub.model.StoneColor.BLACK; -import static jrummikub.model.StoneColor.BLUE; -import static jrummikub.model.StoneColor.ORANGE; -import static jrummikub.model.StoneColor.RED; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import static jrummikub.model.StoneColor.*; +import static org.junit.Assert.*; import java.util.ArrayList; import java.util.Arrays; @@ -37,7 +31,6 @@ import jrummikub.model.Table; import jrummikub.util.Event; import jrummikub.util.IEvent; import jrummikub.util.IListener2; -import jrummikub.util.IListener3; import jrummikub.util.Pair; import jrummikub.view.IView.BottomPanelType; import jrummikub.view.MockView; @@ -151,7 +144,7 @@ public class TurnControlTest { mockPlayer.hand = mockHand; testControl = new HumanTurnControl(mockTimer); testControl.setup(new ITurnControl.TurnInfo(mockRoundState, - TurnMode.NORMAL_TURN), new GameSettings(), mockView); + TurnMode.NORMAL_TURN, false), new GameSettings(), mockView); } /** */ @@ -178,7 +171,7 @@ public class TurnControlTest { testControl = new HumanTurnControl(mockTimer); testControl.setup(new ITurnControl.TurnInfo(mockRoundState, - TurnMode.INSPECT_ONLY), new GameSettings(), mockView); + TurnMode.INSPECT_ONLY, false), new GameSettings(), mockView); testControl.startTurn(); mockView.startTurnEvent.emit(); @@ -227,8 +220,7 @@ public class TurnControlTest { testControl.getEndOfTurnEvent().add( new IListener2() { @Override - public void handle(IRoundState value1, - InvalidTurnInfo value2) { + public void handle(IRoundState value1, InvalidTurnInfo value2) { eventFired = true; } }); @@ -312,8 +304,8 @@ public class TurnControlTest { mockView.handPanel.stoneClickEvent.emit(redJoker, true); mockView.handPanel.stoneClickEvent.emit(blackJoker, true); - mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit( - blackJoker, true); + mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(blackJoker, + true); assertCollection(Arrays.asList(redJoker, blackJoker)); } @@ -329,8 +321,7 @@ public class TurnControlTest { mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(redJoker, true); - mockView.tablePanel.stoneCollectionPanel.setClickEvent.emit(redJoker, - true); + mockView.tablePanel.stoneCollectionPanel.setClickEvent.emit(redJoker, true); assertCollection(new ArrayList()); } @@ -428,8 +419,8 @@ public class TurnControlTest { testControl.startTurn(); Stone stone4 = new Stone(4, StoneColor.RED); - StoneSet set1 = new StoneSet(Arrays.asList(redOne, redTwo, redThree, - stone4)); + StoneSet set1 = new StoneSet( + Arrays.asList(redOne, redTwo, redThree, stone4)); mockTable.findStoneSet.put(redOne, set1); mockTable.findStoneSet.put(redThree, set1); @@ -600,15 +591,15 @@ public class TurnControlTest { mockHand.drop(blueThree, new Position(0, 0)); mockHand.drop(blueFour, new Position(0, 0)); - StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, - blackOne, redTwo, redThree, redFour, blackTwo, blackThree)); - StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blackFour, - blackFive)); + StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne, + redTwo, redThree, redFour, blackTwo, blackThree)); + StoneSet oldSet2 = new StoneSet( + Arrays.asList(blueTwo, blackFour, blackFive)); table.drop(oldSet1, new Position(0, 0)); table.drop(oldSet2, new Position(0, 0)); turnControl.setup(new ITurnControl.TurnInfo(mockRoundState, - TurnMode.NORMAL_TURN), new GameSettings(), mockView); + TurnMode.NORMAL_TURN, false), new GameSettings(), mockView); turnControl.startTurn(); mockView.handPanel.stoneClickEvent.emit(blueThree, false); @@ -707,16 +698,17 @@ public class TurnControlTest { mockTable.clonedTable = table; HumanTurnControl turnControl = new HumanTurnControl(mockTimer); - StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, - blackOne, redTwo, redThree, redFour, blackTwo, blackThree)); - StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blackFour, - blackFive)); + StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne, + redTwo, redThree, redFour, blackTwo, blackThree)); + StoneSet oldSet2 = new StoneSet( + Arrays.asList(blueTwo, blackFour, blackFive)); table.drop(oldSet1, new Position(0, 0)); table.drop(oldSet2, new Position(0, 0)); mockHand.drop(blueThree, new Position(0, 0)); mockHand.drop(blueFour, new Position(0, 0)); - turnControl.setup(new TurnInfo(mockRoundState, TurnMode.NORMAL_TURN), + turnControl.setup( + new TurnInfo(mockRoundState, TurnMode.NORMAL_TURN, false), new GameSettings(), mockView); turnControl.startTurn(); @@ -814,17 +806,18 @@ public class TurnControlTest { public void testAddNewSet() { AccessibleTable table = new AccessibleTable(); mockTable.clonedTable = table; - StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, - blackOne, redTwo, redThree, redFour, blackTwo, blackThree)); - StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blackFour, - blackFive)); + StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne, + redTwo, redThree, redFour, blackTwo, blackThree)); + StoneSet oldSet2 = new StoneSet( + Arrays.asList(blueTwo, blackFour, blackFive)); table.drop(oldSet1, new Position(0, 0)); table.drop(oldSet2, new Position(0, 0)); mockHand.drop(blueThree, new Position(0, 0)); mockHand.drop(blueFour, new Position(0, 0)); HumanTurnControl turnControl = new HumanTurnControl(mockTimer); - turnControl.setup(new TurnInfo(mockRoundState, TurnMode.NORMAL_TURN), + turnControl.setup( + new TurnInfo(mockRoundState, TurnMode.NORMAL_TURN, false), new GameSettings(), mockView); turnControl.startTurn(); mockView.handPanel.stoneClickEvent.emit(blueThree, false); @@ -914,8 +907,8 @@ public class TurnControlTest { List> stones = new ArrayList>( mockHand.stones); - Collections.sort(stones, - new HumanTurnControl.HandStonePositionComparator()); + Collections + .sort(stones, new HumanTurnControl.HandStonePositionComparator()); assertEquals(stones.size(), 13); @@ -963,8 +956,8 @@ public class TurnControlTest { List> stones = new ArrayList>( mockHand.stones); - Collections.sort(stones, - new HumanTurnControl.HandStonePositionComparator()); + Collections + .sort(stones, new HumanTurnControl.HandStonePositionComparator()); assertEquals(stones.size(), 13); @@ -1004,8 +997,8 @@ public class TurnControlTest { assertCollection(new ArrayList()); - Set expected = new HashSet(Arrays.asList(redJoker, - blackJoker)); + Set expected = new HashSet( + Arrays.asList(redJoker, blackJoker)); assertEquals(expected, mockHand.pickups); Set handStones = new HashSet(); @@ -1032,8 +1025,7 @@ public class TurnControlTest { assertCollection(Arrays.asList(blackJoker)); - Set expected = new HashSet(Arrays.asList(redJoker, - black13)); + Set expected = new HashSet(Arrays.asList(redJoker, black13)); assertEquals(expected, mockHand.pickups); Set handStones = new HashSet(); @@ -1049,15 +1041,12 @@ public class TurnControlTest { public void testTableDifference() { MockTable oldTable = new MockTable(); MockTable newTable = new MockTable(); - 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)); @@ -1065,8 +1054,7 @@ public class TurnControlTest { expectedStones.add(blueThree); expectedStones.add(blueFour); - Set stones = AbstractTurnControl.tableDifference(oldTable, - newTable); + Set stones = AbstractTurnControl.tableDifference(oldTable, newTable); assertTrue(expectedStones.containsAll(stones)); assertTrue(stones.containsAll(expectedStones)); @@ -1083,15 +1071,14 @@ public class TurnControlTest { 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 newSets = AbstractTurnControl.tableSetDifference( - oldTable, newTable); + List newSets = AbstractTurnControl.tableSetDifference(oldTable, + newTable); List vanishedSets = AbstractTurnControl.tableSetDifference( newTable, oldTable); @@ -1099,11 +1086,10 @@ public class TurnControlTest { 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 = AbstractTurnControl.tableSetDifference(oldTable, newTable); - vanishedSets = AbstractTurnControl.tableSetDifference(newTable, - oldTable); + vanishedSets = AbstractTurnControl.tableSetDifference(newTable, oldTable); assertFalse(newSets.isEmpty()); assertFalse(vanishedSets.isEmpty()); @@ -1113,13 +1099,11 @@ public class TurnControlTest { 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 = AbstractTurnControl.tableSetDifference(oldTable, newTable2); - vanishedSets = AbstractTurnControl.tableSetDifference(newTable2, - oldTable); + vanishedSets = AbstractTurnControl.tableSetDifference(newTable2, oldTable); assertFalse(newSets.isEmpty()); assertTrue(vanishedSets.isEmpty()); -- cgit v1.2.3