From a4f5beb00598f577598a0e39e4e1099d9ea6e1e6 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 16 May 2011 22:09:56 +0200 Subject: Move getHandPanel from IPlayerPanel to IView git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@245 72836036-5685-4462-b002-a69064685172 --- test/jrummikub/control/TurnControlTest.java | 100 +++++++++++++++------------- 1 file changed, 52 insertions(+), 48 deletions(-) (limited to 'test') diff --git a/test/jrummikub/control/TurnControlTest.java b/test/jrummikub/control/TurnControlTest.java index 15b6937..edace0a 100644 --- a/test/jrummikub/control/TurnControlTest.java +++ b/test/jrummikub/control/TurnControlTest.java @@ -85,7 +85,7 @@ public class TurnControlTest { } private void checkHandDisplay(IHand hand) { - Iterator> stoneSetsView = mockView.playerPanel.handPanel.stones + Iterator> stoneSetsView = mockView.handPanel.stones .iterator(); Iterator> stoneSetsModel = hand.iterator(); @@ -131,7 +131,7 @@ public class TurnControlTest { testControl.startTurn(); int i = 0; - for (Pair pair : mockView.playerPanel.handPanel.stones) { + for (Pair pair : mockView.handPanel.stones) { assertSame(stones.get(i), pair); i++; } @@ -193,7 +193,7 @@ public class TurnControlTest { Stone firstStone = new Stone(StoneColor.RED); // Select first stone - mockView.playerPanel.handPanel.stoneClickEvent.emit(firstStone, false); + mockView.handPanel.stoneClickEvent.emit(firstStone, false); mockTimer.timeRunOutEvent.emit(); assertCollection(new ArrayList()); @@ -207,13 +207,13 @@ public class TurnControlTest { Stone firstStone = new Stone(StoneColor.RED); // Select first stone - mockView.playerPanel.handPanel.stoneClickEvent.emit(firstStone, false); + mockView.handPanel.stoneClickEvent.emit(firstStone, false); assertCollection(Arrays.asList(firstStone)); // Select second stone Stone secondStone = new Stone(StoneColor.BLACK); - mockView.playerPanel.handPanel.stoneClickEvent.emit(secondStone, false); + mockView.handPanel.stoneClickEvent.emit(secondStone, false); assertCollection(Arrays.asList(secondStone)); @@ -227,18 +227,18 @@ public class TurnControlTest { Stone firstStone = new Stone(StoneColor.RED); // Select first stone - mockView.playerPanel.handPanel.stoneClickEvent.emit(firstStone, true); + mockView.handPanel.stoneClickEvent.emit(firstStone, true); assertCollection(Arrays.asList(firstStone)); // Select second stone Stone secondStone = new Stone(StoneColor.BLACK); - mockView.playerPanel.handPanel.stoneClickEvent.emit(secondStone, true); + mockView.handPanel.stoneClickEvent.emit(secondStone, true); assertCollection(Arrays.asList(firstStone, secondStone)); // De-select first stone - mockView.playerPanel.handPanel.stoneClickEvent.emit(firstStone, true); + mockView.handPanel.stoneClickEvent.emit(firstStone, true); assertCollection(Arrays.asList(secondStone)); } @@ -251,8 +251,8 @@ public class TurnControlTest { Stone firstStone = new Stone(StoneColor.RED); Stone secondStone = new Stone(StoneColor.BLACK); - mockView.playerPanel.handPanel.stoneClickEvent.emit(firstStone, true); - mockView.playerPanel.handPanel.stoneClickEvent.emit(secondStone, true); + mockView.handPanel.stoneClickEvent.emit(firstStone, true); + mockView.handPanel.stoneClickEvent.emit(secondStone, true); mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(firstStone, false); @@ -268,8 +268,8 @@ public class TurnControlTest { Stone firstStone = new Stone(StoneColor.RED); Stone secondStone = new Stone(StoneColor.BLACK); - mockView.playerPanel.handPanel.stoneClickEvent.emit(firstStone, true); - mockView.playerPanel.handPanel.stoneClickEvent.emit(secondStone, true); + mockView.handPanel.stoneClickEvent.emit(firstStone, true); + mockView.handPanel.stoneClickEvent.emit(secondStone, true); mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(firstStone, true); @@ -285,8 +285,8 @@ public class TurnControlTest { Stone firstStone = new Stone(StoneColor.RED); Stone secondStone = new Stone(StoneColor.BLACK); - mockView.playerPanel.handPanel.stoneClickEvent.emit(firstStone, true); - mockView.playerPanel.handPanel.stoneClickEvent.emit(secondStone, true); + mockView.handPanel.stoneClickEvent.emit(firstStone, true); + mockView.handPanel.stoneClickEvent.emit(secondStone, true); mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(firstStone, true); @@ -516,8 +516,8 @@ public class TurnControlTest { mockHand.drop(stone3, new Position(0, 1)); mockHand.drop(stone4, new Position(1, 1)); - mockView.playerPanel.handPanel.stoneClickEvent.emit(stone3, false); - mockView.playerPanel.handPanel.rangeClickEvent.emit(stone1, true); + mockView.handPanel.stoneClickEvent.emit(stone3, false); + mockView.handPanel.rangeClickEvent.emit(stone1, true); assertCollection(Arrays.asList(stone1, stone2, stone3)); } @@ -536,8 +536,8 @@ public class TurnControlTest { mockHand.drop(stone3, new Position(0, 1)); mockHand.drop(stone4, new Position(1, 1)); - mockView.playerPanel.handPanel.stoneClickEvent.emit(stone1, false); - mockView.playerPanel.handPanel.rangeClickEvent.emit(stone3, true); + mockView.handPanel.stoneClickEvent.emit(stone1, false); + mockView.handPanel.rangeClickEvent.emit(stone3, true); assertCollection(Arrays.asList(stone1, stone2, stone3)); } @@ -558,10 +558,10 @@ public class TurnControlTest { mockHand.drop(stone3, new Position(0, 1)); mockHand.drop(stone4, new Position(1, 1)); - mockView.playerPanel.handPanel.stoneClickEvent.emit(extraStone, false); + mockView.handPanel.stoneClickEvent.emit(extraStone, false); - mockView.playerPanel.handPanel.stoneClickEvent.emit(stone1, true); - mockView.playerPanel.handPanel.rangeClickEvent.emit(stone3, false); + mockView.handPanel.stoneClickEvent.emit(stone1, true); + mockView.handPanel.rangeClickEvent.emit(stone3, false); assertCollection(Arrays.asList(extraStone, stone1, stone2, stone3)); } @@ -581,7 +581,7 @@ public class TurnControlTest { assertCollection(Arrays.asList(stone1)); // Select second stone - mockView.playerPanel.handPanel.rangeClickEvent.emit(stone2, false); + mockView.handPanel.rangeClickEvent.emit(stone2, false); assertCollection(Arrays.asList(stone1, stone2)); @@ -603,7 +603,7 @@ public class TurnControlTest { assertCollection(Arrays.asList(stone1)); // Select second stone - mockView.playerPanel.handPanel.rangeClickEvent.emit(stone2, true); + mockView.handPanel.rangeClickEvent.emit(stone2, true); assertCollection(Arrays.asList(stone1, stone2)); } @@ -643,7 +643,7 @@ public class TurnControlTest { table.drop(oldSet2, new Position(0, 0)); mockHand.drop(blueThree, new Position(0, 0)); mockHand.drop(blueFour, new Position(0, 0)); - mockView.playerPanel.handPanel.stoneClickEvent.emit(blueThree, false); + mockView.handPanel.stoneClickEvent.emit(blueThree, false); mockView.tablePanel.stoneClickEvent.emit(redOne, true); mockView.tablePanel.stoneClickEvent.emit(redThree, true); mockView.tablePanel.leftConnectorClickEvent.emit(oldSet1); @@ -705,7 +705,7 @@ public class TurnControlTest { assertSame(newSet2.get(3), blackFour); assertSame(newSet2.get(4), blackFive); // versuche, links was wegzunehmen und wieder anzuhängen - mockView.playerPanel.handPanel.stoneClickEvent.emit(blueFour, false); + mockView.handPanel.stoneClickEvent.emit(blueFour, false); mockView.tablePanel.stoneClickEvent.emit(redOne, true); mockView.tablePanel.leftConnectorClickEvent.emit(newSet2); @@ -760,7 +760,7 @@ public class TurnControlTest { table.drop(oldSet2, new Position(0, 0)); mockHand.drop(blueThree, new Position(0, 0)); mockHand.drop(blueFour, new Position(0, 0)); - mockView.playerPanel.handPanel.stoneClickEvent.emit(blueThree, false); + mockView.handPanel.stoneClickEvent.emit(blueThree, false); mockView.tablePanel.stoneClickEvent.emit(redOne, true); mockView.tablePanel.stoneClickEvent.emit(redThree, true); mockView.tablePanel.rightConnectorClickEvent.emit(oldSet1); @@ -822,7 +822,7 @@ public class TurnControlTest { assertSame(newSet2.get(3), redOne); assertSame(newSet2.get(4), redThree); // versuche, rechts was wegzunehmen und wieder anzuhängen - mockView.playerPanel.handPanel.stoneClickEvent.emit(blueFour, false); + mockView.handPanel.stoneClickEvent.emit(blueFour, false); mockView.tablePanel.stoneClickEvent.emit(redThree, true); mockView.tablePanel.rightConnectorClickEvent.emit(newSet2); @@ -877,7 +877,7 @@ public class TurnControlTest { table.drop(oldSet2, new Position(0, 0)); mockHand.drop(blueThree, new Position(0, 0)); mockHand.drop(blueFour, new Position(0, 0)); - mockView.playerPanel.handPanel.stoneClickEvent.emit(blueThree, false); + mockView.handPanel.stoneClickEvent.emit(blueThree, false); mockView.tablePanel.stoneClickEvent.emit(redOne, true); mockView.tablePanel.stoneClickEvent.emit(redThree, true); mockView.tablePanel.stoneClickEvent.emit(blueTwo, true); @@ -939,6 +939,7 @@ public class TurnControlTest { checkTableDisplay(table); checkHandDisplay(mockHand); } + /** */ @Test public void testSortByGroups() { @@ -1060,7 +1061,7 @@ public class TurnControlTest { checkHandDisplay(mockHand); } - + /** */ @Test public void testDropHandValid() { @@ -1068,20 +1069,21 @@ public class TurnControlTest { Stone firstStone = new Stone(StoneColor.RED); Stone secondStone = new Stone(StoneColor.BLACK); - - mockHand.drop(firstStone, new Position(0,0)); - mockHand.drop(secondStone, new Position(1,0)); - mockView.playerPanel.handPanel.stoneClickEvent.emit(firstStone, true); - mockView.playerPanel.handPanel.stoneClickEvent.emit(secondStone, true); + mockHand.drop(firstStone, new Position(0, 0)); + mockHand.drop(secondStone, new Position(1, 0)); + + mockView.handPanel.stoneClickEvent.emit(firstStone, true); + mockView.handPanel.stoneClickEvent.emit(secondStone, true); - mockView.playerPanel.handPanel.clickEvent.emit(new Position(2,0.25f)); + mockView.handPanel.clickEvent.emit(new Position(2, 0.25f)); assertCollection(new ArrayList()); - - Set expected = new HashSet(Arrays.asList(firstStone, secondStone)); + + Set expected = new HashSet(Arrays.asList(firstStone, + secondStone)); assertEquals(expected, mockHand.pickups); - + Set handStones = new HashSet(); for (Pair stone : mockHand.stones) { assertEquals(stone.getSecond().getY(), 0, 0.0001); @@ -1089,6 +1091,7 @@ public class TurnControlTest { } assertEquals(expected, handStones); } + /** */ @Test public void testDropHandInvalid() { @@ -1097,21 +1100,22 @@ public class TurnControlTest { Stone firstStone = new Stone(StoneColor.RED); Stone secondStone = new Stone(StoneColor.BLACK); Stone thirdStone = new Stone(13, StoneColor.BLACK); - - mockHand.drop(firstStone, new Position(0,0)); - mockHand.drop(thirdStone, new Position(1,0)); - mockView.playerPanel.handPanel.stoneClickEvent.emit(firstStone, true); + mockHand.drop(firstStone, new Position(0, 0)); + mockHand.drop(thirdStone, new Position(1, 0)); + + mockView.handPanel.stoneClickEvent.emit(firstStone, true); mockView.tablePanel.stoneClickEvent.emit(secondStone, true); - mockView.playerPanel.handPanel.stoneClickEvent.emit(thirdStone, true); + mockView.handPanel.stoneClickEvent.emit(thirdStone, true); - mockView.playerPanel.handPanel.clickEvent.emit(new Position(2,0.25f)); + mockView.handPanel.clickEvent.emit(new Position(2, 0.25f)); assertCollection(Arrays.asList(secondStone)); - - Set expected = new HashSet(Arrays.asList(firstStone, thirdStone)); + + Set expected = new HashSet(Arrays.asList(firstStone, + thirdStone)); assertEquals(expected, mockHand.pickups); - + Set handStones = new HashSet(); for (Pair stone : mockHand.stones) { assertEquals(stone.getSecond().getY(), 0, 0.0001); @@ -1119,5 +1123,5 @@ public class TurnControlTest { } assertEquals(expected, handStones); } - + } -- cgit v1.2.3