From 223f6d7e858021d9d08e8d074c06bf9804518ee4 Mon Sep 17 00:00:00 2001 From: Ida Massow Date: Mon, 9 May 2011 21:19:04 +0200 Subject: =?UTF-8?q?Testfall=20f=C3=BCr=20rangeclick=20auf=20der=20Hand?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@196 72836036-5685-4462-b002-a69064685172 --- test/jrummikub/control/TurnControlTest.java | 159 +++++++++++++++++++++++----- 1 file changed, 132 insertions(+), 27 deletions(-) (limited to 'test/jrummikub') diff --git a/test/jrummikub/control/TurnControlTest.java b/test/jrummikub/control/TurnControlTest.java index 6178ec4..fdc43fc 100644 --- a/test/jrummikub/control/TurnControlTest.java +++ b/test/jrummikub/control/TurnControlTest.java @@ -111,9 +111,10 @@ public class TurnControlTest { public void showInitialHand() { mockView.displayStartTurnPanel = true; - List> stones = Arrays.asList( - new Pair(new Stone(RED), new Position(0, 0)), - new Pair(new Stone(BLACK), new Position(1, 0))); + List> stones = Arrays + .asList(new Pair(new Stone(RED), new Position( + 0, 0)), new Pair(new Stone(BLACK), + new Position(1, 0))); mockHand.iterable = stones; @@ -239,8 +240,8 @@ public class TurnControlTest { mockView.playerPanel.handPanel.stoneClickEvent.emit(firstStone, true); mockView.playerPanel.handPanel.stoneClickEvent.emit(secondStone, true); - mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(firstStone, - false); + mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit( + firstStone, false); assertCollection(Arrays.asList(secondStone)); } @@ -255,8 +256,8 @@ public class TurnControlTest { mockView.playerPanel.handPanel.stoneClickEvent.emit(firstStone, true); mockView.playerPanel.handPanel.stoneClickEvent.emit(secondStone, true); - mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(firstStone, - true); + mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit( + firstStone, true); assertCollection(Arrays.asList(secondStone, firstStone)); } @@ -271,8 +272,8 @@ public class TurnControlTest { mockView.playerPanel.handPanel.stoneClickEvent.emit(firstStone, true); mockView.playerPanel.handPanel.stoneClickEvent.emit(secondStone, true); - mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(firstStone, - true); + mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit( + firstStone, true); mockView.tablePanel.stoneCollectionPanel.setClickEvent.emit(firstStone, true); @@ -374,7 +375,8 @@ public class TurnControlTest { Stone stone2 = new Stone(2, StoneColor.RED); Stone stone3 = new Stone(3, StoneColor.RED); Stone stone4 = new Stone(4, StoneColor.RED); - StoneSet set1 = new StoneSet(Arrays.asList(stone1, stone2, stone3, stone4)); + StoneSet set1 = new StoneSet(Arrays.asList(stone1, stone2, stone3, + stone4)); mockTable.findStoneSet.put(stone1, set1); mockTable.findStoneSet.put(stone3, set1); @@ -385,7 +387,7 @@ public class TurnControlTest { assertCollection(Arrays.asList(stone1, stone2, stone3)); } - + @Test public void rangeSelectOnTable() { testControl.startTurn(); @@ -394,7 +396,8 @@ public class TurnControlTest { Stone stone2 = new Stone(2, StoneColor.RED); Stone stone3 = new Stone(3, StoneColor.RED); Stone stone4 = new Stone(4, StoneColor.RED); - StoneSet set1 = new StoneSet(Arrays.asList(stone1, stone2, stone3, stone4)); + StoneSet set1 = new StoneSet(Arrays.asList(stone1, stone2, stone3, + stone4)); mockTable.findStoneSet.put(stone1, set1); mockTable.findStoneSet.put(stone3, set1); @@ -416,7 +419,8 @@ public class TurnControlTest { Stone stone2 = new Stone(2, StoneColor.RED); Stone stone3 = new Stone(3, StoneColor.RED); Stone stone4 = new Stone(4, StoneColor.RED); - StoneSet set1 = new StoneSet(Arrays.asList(stone1, stone2, stone3, stone4)); + StoneSet set1 = new StoneSet(Arrays.asList(stone1, stone2, stone3, + stone4)); mockTable.findStoneSet.put(stone1, set1); mockTable.findStoneSet.put(stone3, set1); @@ -476,6 +480,107 @@ public class TurnControlTest { assertCollection(Arrays.asList(stone1, stone2)); } + @Test + public void rangeSelectOnHandReverse() { + testControl.startTurn(); + + Stone stone1 = new Stone(1, StoneColor.RED); + Stone stone2 = new Stone(2, StoneColor.RED); + Stone stone3 = new Stone(3, StoneColor.RED); + Stone stone4 = new Stone(4, StoneColor.RED); + mockHand.drop(stone1, new Position(0, 0)); + mockHand.drop(stone2, new Position(1.5f, 0)); + 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); + + assertCollection(Arrays.asList(stone1, stone2, stone3)); + } + + @Test + public void rangeSelectOnHand() { + testControl.startTurn(); + + Stone stone1 = new Stone(1, StoneColor.RED); + Stone stone2 = new Stone(2, StoneColor.RED); + Stone stone3 = new Stone(3, StoneColor.RED); + Stone stone4 = new Stone(4, StoneColor.RED); + mockHand.drop(stone1, new Position(0, 0)); + mockHand.drop(stone2, new Position(1.5f, 0)); + 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); + + assertCollection(Arrays.asList(stone1, stone2, stone3)); + } + + @Test + public void rangeCollectOnHand() { + testControl.startTurn(); + + Stone extraStone = new Stone(StoneColor.RED); + + Stone stone1 = new Stone(1, StoneColor.RED); + Stone stone2 = new Stone(2, StoneColor.RED); + Stone stone3 = new Stone(3, StoneColor.RED); + Stone stone4 = new Stone(4, StoneColor.RED); + mockHand.drop(stone1, new Position(0, 0)); + mockHand.drop(stone2, new Position(1.5f, 0)); + mockHand.drop(stone3, new Position(0, 1)); + mockHand.drop(stone4, new Position(1, 1)); + + mockView.playerPanel.handPanel.stoneClickEvent.emit(extraStone, false); + + mockView.playerPanel.handPanel.stoneClickEvent.emit(stone1, true); + mockView.playerPanel.handPanel.rangeClickEvent.emit(stone3, false); + assertCollection(Arrays.asList(extraStone, stone1, stone2, stone3)); + } + + @Test + public void rangeFailSelectHand() { + testControl.startTurn(); + + Stone stone1 = new Stone(1, StoneColor.RED); + Stone stone2 = new Stone(2, StoneColor.RED); + StoneSet set1 = new StoneSet(Arrays.asList(stone1)); + mockTable.findStoneSet.put(stone1, set1); + mockHand.drop(stone2, new Position(0, 0)); + // Select first stone + mockView.tablePanel.stoneClickEvent.emit(stone1, false); + + assertCollection(Arrays.asList(stone1)); + + // Select second stone + mockView.playerPanel.handPanel.rangeClickEvent.emit(stone2, false); + + assertCollection(Arrays.asList(stone2)); + + } + + @Test + public void rangeFailCollectHand() { + testControl.startTurn(); + + Stone stone1 = new Stone(1, StoneColor.RED); + Stone stone2 = new Stone(2, StoneColor.RED); + StoneSet set1 = new StoneSet(Arrays.asList(stone1)); + mockTable.findStoneSet.put(stone1, set1); + mockHand.drop(stone2, new Position(0, 0)); + // Select first stone + mockView.tablePanel.stoneClickEvent.emit(stone1, false); + + assertCollection(Arrays.asList(stone1)); + + // Select second stone + mockView.playerPanel.handPanel.rangeClickEvent.emit(stone2, true); + + assertCollection(Arrays.asList(stone1, stone2)); + } + private void assertCollection(List expected) { ArrayList selectedStones = new ArrayList( mockView.selectedStones); @@ -502,10 +607,10 @@ public class TurnControlTest { Stone blackThree = new Stone(3, BLACK); Stone blackFour = new Stone(4, BLACK); Stone blackFive = new Stone(5, BLACK); - 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)); @@ -575,7 +680,7 @@ public class TurnControlTest { mockView.playerPanel.handPanel.stoneClickEvent.emit(blueFour, false); mockView.tablePanel.stoneClickEvent.emit(redOne, true); mockView.tablePanel.leftConnectorClickEvent.emit(newSet2); - + // handcheck assertEquals(0, mockHand.getSize()); // tablecheck @@ -618,10 +723,10 @@ public class TurnControlTest { Stone blackThree = new Stone(3, BLACK); Stone blackFour = new Stone(4, BLACK); Stone blackFive = new Stone(5, BLACK); - 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)); @@ -691,7 +796,7 @@ public class TurnControlTest { mockView.playerPanel.handPanel.stoneClickEvent.emit(blueFour, false); mockView.tablePanel.stoneClickEvent.emit(redThree, true); mockView.tablePanel.rightConnectorClickEvent.emit(newSet2); - + // handcheck assertEquals(0, mockHand.getSize()); // tablecheck @@ -734,10 +839,10 @@ public class TurnControlTest { Stone blackThree = new Stone(3, BLACK); Stone blackFour = new Stone(4, BLACK); Stone blackFive = new Stone(5, BLACK); - 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)); -- cgit v1.2.3