summaryrefslogtreecommitdiffstats
path: root/test/jrummikub/control
diff options
context:
space:
mode:
authorIda Massow <massow@informatik.uni-luebeck.de>2011-05-09 21:19:04 +0200
committerIda Massow <massow@informatik.uni-luebeck.de>2011-05-09 21:19:04 +0200
commit223f6d7e858021d9d08e8d074c06bf9804518ee4 (patch)
treedb51ba129a83789c6a384e3fb1740ea92bda6add /test/jrummikub/control
parenta6a5388560692b59a20a82a4b22a231d6705d9d0 (diff)
downloadJRummikub-223f6d7e858021d9d08e8d074c06bf9804518ee4.tar
JRummikub-223f6d7e858021d9d08e8d074c06bf9804518ee4.zip
Testfall für rangeclick auf der Hand
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@196 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test/jrummikub/control')
-rw-r--r--test/jrummikub/control/TurnControlTest.java159
1 files changed, 132 insertions, 27 deletions
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<Pair<Stone, Position>> stones = Arrays.asList(
- new Pair<Stone, Position>(new Stone(RED), new Position(0, 0)),
- new Pair<Stone, Position>(new Stone(BLACK), new Position(1, 0)));
+ List<Pair<Stone, Position>> stones = Arrays
+ .asList(new Pair<Stone, Position>(new Stone(RED), new Position(
+ 0, 0)), new Pair<Stone, Position>(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<Stone> expected) {
ArrayList<Stone> selectedStones = new ArrayList<Stone>(
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));