summaryrefslogtreecommitdiffstats
path: root/test/jrummikub/control
diff options
context:
space:
mode:
authorIda Massow <massow@informatik.uni-luebeck.de>2011-06-18 16:19:20 +0200
committerIda Massow <massow@informatik.uni-luebeck.de>2011-06-18 16:19:20 +0200
commitac3c13c50b87abfc6e4959fabd5107990d1eb417 (patch)
tree6457f708d25e751dea1da503df77c0f74d4d30fa /test/jrummikub/control
parentbc835d499f2fe3c8b9c5b6bc9cfca9d9666854e9 (diff)
downloadJRummikub-ac3c13c50b87abfc6e4959fabd5107990d1eb417.tar
JRummikub-ac3c13c50b87abfc6e4959fabd5107990d1eb417.zip
Ca. 150 Zeilen überflüssigen Code entfernt
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@463 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test/jrummikub/control')
-rw-r--r--test/jrummikub/control/turn/AIControlTest.java5
-rw-r--r--test/jrummikub/control/turn/TurnControlTest.java586
2 files changed, 234 insertions, 357 deletions
diff --git a/test/jrummikub/control/turn/AIControlTest.java b/test/jrummikub/control/turn/AIControlTest.java
index 6f7bf6f..6da4b00 100644
--- a/test/jrummikub/control/turn/AIControlTest.java
+++ b/test/jrummikub/control/turn/AIControlTest.java
@@ -38,7 +38,7 @@ public class AIControlTest {
@Before
public void setUp() {
aiControl = TurnControlFactory.getFactory(Type.COMPUTER).create();
- ((AIControl)aiControl).useBackgroundThread = false;
+ ((AIControl) aiControl).useBackgroundThread = false;
gameSettings = new GameSettings();
playerSettings = new PlayerSettings("ROBOT_01", Color.GRAY);
player = new Player(playerSettings);
@@ -73,6 +73,7 @@ public class AIControlTest {
/**
* @throws InterruptedException
+ * if timeout
*/
@Test(timeout = 10000)
public void testTurnZeroNoRedealing() throws InterruptedException {
@@ -86,6 +87,7 @@ public class AIControlTest {
/**
* @throws InterruptedException
+ * if timeout
*/
@Test(timeout = 10000)
public void testTurnZeroNotMelding() throws InterruptedException {
@@ -101,6 +103,7 @@ public class AIControlTest {
/**
* @throws InterruptedException
+ * if timeout
*/
@Test(timeout = 10000)
public void testNormalTurnMelding() throws InterruptedException {
diff --git a/test/jrummikub/control/turn/TurnControlTest.java b/test/jrummikub/control/turn/TurnControlTest.java
index e4fc187..f334b29 100644
--- a/test/jrummikub/control/turn/TurnControlTest.java
+++ b/test/jrummikub/control/turn/TurnControlTest.java
@@ -37,6 +37,7 @@ import org.junit.Test;
* Tests for {@link HumanTurnControl}
*/
public class TurnControlTest {
+ @SuppressWarnings("serial")
static class AccessibleTable extends Table {
StoneSet[] getSetArray() {
return objects.keySet().toArray(new StoneSet[0]);
@@ -75,6 +76,28 @@ public class TurnControlTest {
MockTable mockTable;
MockHand mockHand;
boolean eventFired;
+ Stone blueOne = new Stone(1, BLUE);
+ Stone redOne = new Stone(1, RED);
+ Stone blackOne = new Stone(1, BLACK);
+ Stone blueTwo = new Stone(2, BLUE);
+ Stone blueThree = new Stone(3, BLUE);
+ Stone blueFour = new Stone(4, BLUE);
+ Stone redTwo = new Stone(2, RED);
+ Stone redThree = new Stone(3, RED);
+ Stone redFour = new Stone(4, RED);
+ Stone blackTwo = new Stone(2, BLACK);
+ Stone blackThree = new Stone(3, BLACK);
+ Stone blackFour = new Stone(4, BLACK);
+ Stone blackFive = new Stone(5, BLACK);
+ Stone redJoker = new Stone(RED);
+ Stone blackJoker = new Stone(BLACK);
+ Stone orange10 = new Stone(10, StoneColor.ORANGE);
+ Stone blue4a = new Stone(4, StoneColor.BLUE);
+ Stone black5 = new Stone(5, StoneColor.BLACK);
+ Stone orange13 = new Stone(13, StoneColor.ORANGE);
+ Stone red11 = new Stone(11, StoneColor.RED);
+ Stone black10 = new Stone(10, StoneColor.BLACK);
+ Stone black13 = new Stone(13, StoneColor.BLACK);
private void checkTableDisplay(ITable table) {
Iterator<Pair<StoneSet, Position>> stoneSetsView = mockView.tablePanel.stoneSets
@@ -110,8 +133,8 @@ public class TurnControlTest {
mockPlayer = new MockPlayer(null, null);
mockPlayer.hand = mockHand;
testControl = new HumanTurnControl(mockTimer);
- testControl.setup(new ITurnControl.TurnInfo(mockTable,
- mockPlayer.getHand(), mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN),
+ testControl.setup(new ITurnControl.TurnInfo(mockTable, mockPlayer
+ .getHand(), mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN),
new GameSettings(), mockView);
}
@@ -130,14 +153,14 @@ public class TurnControlTest {
mockView.bottomPanelType = BottomPanelType.START_TURN_PANEL;
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)));
+ new Pair<Stone, Position>(redJoker, new Position(0, 0)),
+ new Pair<Stone, Position>(blackJoker, new Position(1, 0)));
mockHand.iterable = stones;
testControl = new HumanTurnControl(mockTimer);
- testControl.setup(new ITurnControl.TurnInfo(mockTable,
- mockPlayer.getHand(), mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN),
+ testControl.setup(new ITurnControl.TurnInfo(mockTable, mockPlayer
+ .getHand(), mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN),
new GameSettings(), mockView);
testControl.startTurn();
@@ -215,19 +238,15 @@ public class TurnControlTest {
public void selectStoneInHand() {
testControl.startTurn();
- Stone firstStone = new Stone(StoneColor.RED);
-
// Select first stone
- mockView.handPanel.stoneClickEvent.emit(firstStone, false);
+ mockView.handPanel.stoneClickEvent.emit(redJoker, false);
- assertCollection(Arrays.asList(firstStone));
+ assertCollection(Arrays.asList(redJoker));
// Select second stone
- Stone secondStone = new Stone(StoneColor.BLACK);
- mockView.handPanel.stoneClickEvent.emit(secondStone, false);
-
- assertCollection(Arrays.asList(secondStone));
+ mockView.handPanel.stoneClickEvent.emit(blackJoker, false);
+ assertCollection(Arrays.asList(blackJoker));
}
/** */
@@ -235,23 +254,20 @@ public class TurnControlTest {
public void collectStoneInHand() {
testControl.startTurn();
- Stone firstStone = new Stone(StoneColor.RED);
-
// Select first stone
- mockView.handPanel.stoneClickEvent.emit(firstStone, true);
+ mockView.handPanel.stoneClickEvent.emit(redJoker, true);
- assertCollection(Arrays.asList(firstStone));
+ assertCollection(Arrays.asList(redJoker));
// Select second stone
- Stone secondStone = new Stone(StoneColor.BLACK);
- mockView.handPanel.stoneClickEvent.emit(secondStone, true);
+ mockView.handPanel.stoneClickEvent.emit(blackJoker, true);
- assertCollection(Arrays.asList(firstStone, secondStone));
+ assertCollection(Arrays.asList(redJoker, blackJoker));
// De-select first stone
- mockView.handPanel.stoneClickEvent.emit(firstStone, true);
+ mockView.handPanel.stoneClickEvent.emit(redJoker, true);
- assertCollection(Arrays.asList(secondStone));
+ assertCollection(Arrays.asList(blackJoker));
}
/** */
@@ -259,16 +275,13 @@ public class TurnControlTest {
public void deselectStoneInCollection() {
testControl.startTurn();
- Stone firstStone = new Stone(StoneColor.RED);
- Stone secondStone = new Stone(StoneColor.BLACK);
-
- mockView.handPanel.stoneClickEvent.emit(firstStone, true);
- mockView.handPanel.stoneClickEvent.emit(secondStone, true);
+ mockView.handPanel.stoneClickEvent.emit(redJoker, true);
+ mockView.handPanel.stoneClickEvent.emit(blackJoker, true);
- mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(firstStone,
+ mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(redJoker,
false);
- assertCollection(Arrays.asList(secondStone));
+ assertCollection(Arrays.asList(blackJoker));
}
/** */
@@ -276,16 +289,13 @@ public class TurnControlTest {
public void reorderCollection() {
testControl.startTurn();
- Stone firstStone = new Stone(StoneColor.RED);
- Stone secondStone = new Stone(StoneColor.BLACK);
-
- mockView.handPanel.stoneClickEvent.emit(firstStone, true);
- mockView.handPanel.stoneClickEvent.emit(secondStone, true);
+ mockView.handPanel.stoneClickEvent.emit(redJoker, true);
+ mockView.handPanel.stoneClickEvent.emit(blackJoker, true);
- mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(firstStone,
- true);
+ mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(
+ blackJoker, true);
- assertCollection(Arrays.asList(secondStone, firstStone));
+ assertCollection(Arrays.asList(redJoker, blackJoker));
}
/** */
@@ -293,16 +303,13 @@ public class TurnControlTest {
public void deselectWholeCollection() {
testControl.startTurn();
- Stone firstStone = new Stone(StoneColor.RED);
- Stone secondStone = new Stone(StoneColor.BLACK);
-
- mockView.handPanel.stoneClickEvent.emit(firstStone, true);
- mockView.handPanel.stoneClickEvent.emit(secondStone, true);
+ mockView.handPanel.stoneClickEvent.emit(redJoker, true);
+ mockView.handPanel.stoneClickEvent.emit(blackJoker, true);
- mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(firstStone,
+ mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(redJoker,
true);
- mockView.tablePanel.stoneCollectionPanel.setClickEvent.emit(firstStone,
+ mockView.tablePanel.stoneCollectionPanel.setClickEvent.emit(redJoker,
true);
assertCollection(new ArrayList<Stone>());
@@ -313,19 +320,13 @@ public class TurnControlTest {
public void selectStoneOnTable() {
testControl.startTurn();
- Stone firstStone = new Stone(StoneColor.RED);
-
// Select first stone
- mockView.tablePanel.stoneClickEvent.emit(firstStone, false);
-
- assertCollection(Arrays.asList(firstStone));
+ mockView.tablePanel.stoneClickEvent.emit(redJoker, false);
+ assertCollection(Arrays.asList(redJoker));
// Select second stone
- Stone secondStone = new Stone(StoneColor.BLACK);
- mockView.tablePanel.stoneClickEvent.emit(secondStone, false);
-
- assertCollection(Arrays.asList(secondStone));
-
+ mockView.tablePanel.stoneClickEvent.emit(blackJoker, false);
+ assertCollection(Arrays.asList(blackJoker));
}
/** */
@@ -333,23 +334,17 @@ public class TurnControlTest {
public void collectStoneOnTable() {
testControl.startTurn();
- Stone firstStone = new Stone(StoneColor.RED);
-
// Select first stone
- mockView.tablePanel.stoneClickEvent.emit(firstStone, true);
-
- assertCollection(Arrays.asList(firstStone));
+ mockView.tablePanel.stoneClickEvent.emit(redJoker, true);
+ assertCollection(Arrays.asList(redJoker));
// Select second stone
- Stone secondStone = new Stone(StoneColor.BLACK);
- mockView.tablePanel.stoneClickEvent.emit(secondStone, true);
-
- assertCollection(Arrays.asList(firstStone, secondStone));
+ mockView.tablePanel.stoneClickEvent.emit(blackJoker, true);
+ assertCollection(Arrays.asList(redJoker, blackJoker));
// De-select first stone
- mockView.tablePanel.stoneClickEvent.emit(firstStone, true);
-
- assertCollection(Arrays.asList(secondStone));
+ mockView.tablePanel.stoneClickEvent.emit(redJoker, true);
+ assertCollection(Arrays.asList(blackJoker));
}
/** */
@@ -357,22 +352,18 @@ public class TurnControlTest {
public void selectSetOnTable() {
testControl.startTurn();
- Stone stone1 = new Stone(StoneColor.RED);
- Stone stone2 = new Stone(StoneColor.BLACK);
- StoneSet set1 = new StoneSet(Arrays.asList(stone1, stone2));
- Stone stone3 = new Stone(1, StoneColor.RED);
- Stone stone4 = new Stone(1, StoneColor.BLACK);
- StoneSet set2 = new StoneSet(Arrays.asList(stone3, stone4));
-
- mockTable.findStoneSet.put(stone1, set1);
- mockTable.findStoneSet.put(stone4, set2);
-
- mockView.tablePanel.stoneClickEvent.emit(stone1, false);
- mockView.tablePanel.setClickEvent.emit(stone1, false);
- assertCollection(Arrays.asList(stone1, stone2));
- mockView.tablePanel.stoneClickEvent.emit(stone4, false);
- mockView.tablePanel.setClickEvent.emit(stone4, false);
- assertCollection(Arrays.asList(stone3, stone4));
+ StoneSet set1 = new StoneSet(Arrays.asList(redJoker, blackJoker));
+ StoneSet set2 = new StoneSet(Arrays.asList(redOne, blackOne));
+
+ mockTable.findStoneSet.put(redJoker, set1);
+ mockTable.findStoneSet.put(blackOne, set2);
+
+ mockView.tablePanel.stoneClickEvent.emit(redJoker, false);
+ mockView.tablePanel.setClickEvent.emit(redJoker, false);
+ assertCollection(Arrays.asList(redJoker, blackJoker));
+ mockView.tablePanel.stoneClickEvent.emit(blackOne, false);
+ mockView.tablePanel.setClickEvent.emit(blackOne, false);
+ assertCollection(Arrays.asList(redOne, blackOne));
}
/** */
@@ -380,22 +371,18 @@ public class TurnControlTest {
public void collectSetOnTable() {
testControl.startTurn();
- Stone stone1 = new Stone(StoneColor.RED);
- Stone stone2 = new Stone(StoneColor.BLACK);
- StoneSet set1 = new StoneSet(Arrays.asList(stone1, stone2));
- Stone stone3 = new Stone(1, StoneColor.RED);
- Stone stone4 = new Stone(1, StoneColor.BLACK);
- StoneSet set2 = new StoneSet(Arrays.asList(stone3, stone4));
-
- mockTable.findStoneSet.put(stone1, set1);
- mockTable.findStoneSet.put(stone4, set2);
-
- mockView.tablePanel.stoneClickEvent.emit(stone1, true);
- mockView.tablePanel.setClickEvent.emit(stone1, true);
- assertCollection(Arrays.asList(stone1, stone2));
- mockView.tablePanel.stoneClickEvent.emit(stone4, true);
- mockView.tablePanel.setClickEvent.emit(stone4, true);
- assertCollection(Arrays.asList(stone1, stone2, stone3, stone4));
+ StoneSet set1 = new StoneSet(Arrays.asList(redJoker, blackJoker));
+ StoneSet set2 = new StoneSet(Arrays.asList(redOne, blackOne));
+
+ mockTable.findStoneSet.put(redJoker, set1);
+ mockTable.findStoneSet.put(blackOne, set2);
+
+ mockView.tablePanel.stoneClickEvent.emit(redJoker, true);
+ mockView.tablePanel.setClickEvent.emit(redJoker, true);
+ assertCollection(Arrays.asList(redJoker, blackJoker));
+ mockView.tablePanel.stoneClickEvent.emit(blackOne, true);
+ mockView.tablePanel.setClickEvent.emit(blackOne, true);
+ assertCollection(Arrays.asList(redJoker, blackJoker, redOne, blackOne));
}
/** */
@@ -403,20 +390,16 @@ public class TurnControlTest {
public void rangeSelectOnTableReverse() {
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);
- StoneSet set1 = new StoneSet(Arrays.asList(stone1, stone2, stone3, stone4));
-
- mockTable.findStoneSet.put(stone1, set1);
- mockTable.findStoneSet.put(stone3, set1);
+ StoneSet set1 = new StoneSet(Arrays.asList(redOne, redTwo, redThree,
+ redFour));
- mockView.tablePanel.stoneClickEvent.emit(stone3, false);
- mockView.tablePanel.rangeClickEvent.emit(stone1, true);
+ mockTable.findStoneSet.put(redOne, set1);
+ mockTable.findStoneSet.put(redThree, set1);
- assertCollection(Arrays.asList(stone1, stone2, stone3));
+ mockView.tablePanel.stoneClickEvent.emit(redThree, false);
+ mockView.tablePanel.rangeClickEvent.emit(redOne, true);
+ assertCollection(Arrays.asList(redOne, redTwo, redThree));
}
/** */
@@ -424,20 +407,17 @@ public class TurnControlTest {
public void rangeSelectOnTable() {
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);
- StoneSet set1 = new StoneSet(Arrays.asList(stone1, stone2, stone3, stone4));
+ StoneSet set1 = new StoneSet(Arrays.asList(redOne, redTwo, redThree,
+ stone4));
- mockTable.findStoneSet.put(stone1, set1);
- mockTable.findStoneSet.put(stone3, set1);
+ mockTable.findStoneSet.put(redOne, set1);
+ mockTable.findStoneSet.put(redThree, set1);
- mockView.tablePanel.stoneClickEvent.emit(stone1, false);
- mockView.tablePanel.rangeClickEvent.emit(stone3, true);
-
- assertCollection(Arrays.asList(stone1, stone2, stone3));
+ mockView.tablePanel.stoneClickEvent.emit(redOne, false);
+ mockView.tablePanel.rangeClickEvent.emit(redThree, true);
+ assertCollection(Arrays.asList(redOne, redTwo, redThree));
}
/** */
@@ -445,23 +425,18 @@ public class TurnControlTest {
public void rangeCollectOnTable() {
testControl.startTurn();
- Stone extraStone = new Stone(StoneColor.RED);
+ StoneSet set1 = new StoneSet(Arrays.asList(redOne, redTwo, redThree,
+ redFour));
- 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);
- StoneSet set1 = new StoneSet(Arrays.asList(stone1, stone2, stone3, stone4));
+ mockTable.findStoneSet.put(redOne, set1);
+ mockTable.findStoneSet.put(redThree, set1);
- mockTable.findStoneSet.put(stone1, set1);
- mockTable.findStoneSet.put(stone3, set1);
+ mockView.tablePanel.stoneClickEvent.emit(redJoker, false);
- mockView.tablePanel.stoneClickEvent.emit(extraStone, false);
-
- mockView.tablePanel.stoneClickEvent.emit(stone1, true);
- mockView.tablePanel.rangeClickEvent.emit(stone3, false);
+ mockView.tablePanel.stoneClickEvent.emit(redOne, true);
+ mockView.tablePanel.rangeClickEvent.emit(redThree, false);
- assertCollection(Arrays.asList(extraStone, stone1, stone2, stone3));
+ assertCollection(Arrays.asList(redJoker, redOne, redTwo, redThree));
}
/** */
@@ -469,24 +444,19 @@ public class TurnControlTest {
public void rangeFailSelect() {
testControl.startTurn();
- Stone stone1 = new Stone(1, StoneColor.RED);
- Stone stone2 = new Stone(2, StoneColor.RED);
- StoneSet set1 = new StoneSet(Arrays.asList(stone1));
- StoneSet set2 = new StoneSet(Arrays.asList(stone2));
+ StoneSet set1 = new StoneSet(Arrays.asList(redOne));
+ StoneSet set2 = new StoneSet(Arrays.asList(redTwo));
- mockTable.findStoneSet.put(stone1, set1);
- mockTable.findStoneSet.put(stone2, set2);
+ mockTable.findStoneSet.put(redOne, set1);
+ mockTable.findStoneSet.put(redTwo, set2);
// Select first stone
- mockView.tablePanel.stoneClickEvent.emit(stone1, false);
-
- assertCollection(Arrays.asList(stone1));
+ mockView.tablePanel.stoneClickEvent.emit(redOne, false);
+ assertCollection(Arrays.asList(redOne));
// Select second stone
- mockView.tablePanel.rangeClickEvent.emit(stone2, false);
-
- assertCollection(Arrays.asList(stone1, stone2));
-
+ mockView.tablePanel.rangeClickEvent.emit(redTwo, false);
+ assertCollection(Arrays.asList(redOne, redTwo));
}
/** */
@@ -494,23 +464,19 @@ public class TurnControlTest {
public void rangeFailCollect() {
testControl.startTurn();
- Stone stone1 = new Stone(1, StoneColor.RED);
- Stone stone2 = new Stone(2, StoneColor.RED);
- StoneSet set1 = new StoneSet(Arrays.asList(stone1));
- StoneSet set2 = new StoneSet(Arrays.asList(stone2));
+ StoneSet set1 = new StoneSet(Arrays.asList(redOne));
+ StoneSet set2 = new StoneSet(Arrays.asList(redTwo));
- mockTable.findStoneSet.put(stone1, set1);
- mockTable.findStoneSet.put(stone2, set2);
+ mockTable.findStoneSet.put(redOne, set1);
+ mockTable.findStoneSet.put(redTwo, set2);
// Select first stone
- mockView.tablePanel.stoneClickEvent.emit(stone1, true);
-
- assertCollection(Arrays.asList(stone1));
+ mockView.tablePanel.stoneClickEvent.emit(redOne, true);
+ assertCollection(Arrays.asList(redOne));
// Select second stone
- mockView.tablePanel.rangeClickEvent.emit(stone2, true);
-
- assertCollection(Arrays.asList(stone1, stone2));
+ mockView.tablePanel.rangeClickEvent.emit(redTwo, true);
+ assertCollection(Arrays.asList(redOne, redTwo));
}
/** */
@@ -518,19 +484,15 @@ public class TurnControlTest {
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));
+ mockHand.drop(redOne, new Position(0, 0));
+ mockHand.drop(redTwo, new Position(1.5f, 0));
+ mockHand.drop(redThree, new Position(0, 1));
+ mockHand.drop(redFour, new Position(1, 1));
- mockView.handPanel.stoneClickEvent.emit(stone3, false);
- mockView.handPanel.rangeClickEvent.emit(stone1, true);
+ mockView.handPanel.stoneClickEvent.emit(redThree, false);
+ mockView.handPanel.rangeClickEvent.emit(redOne, true);
- assertCollection(Arrays.asList(stone1, stone2, stone3));
+ assertCollection(Arrays.asList(redOne, redTwo, redThree));
}
/** */
@@ -538,19 +500,15 @@ public class TurnControlTest {
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));
+ mockHand.drop(redOne, new Position(0, 0));
+ mockHand.drop(redTwo, new Position(1.5f, 0));
+ mockHand.drop(redThree, new Position(0, 1));
+ mockHand.drop(redFour, new Position(1, 1));
- mockView.handPanel.stoneClickEvent.emit(stone1, false);
- mockView.handPanel.rangeClickEvent.emit(stone3, true);
+ mockView.handPanel.stoneClickEvent.emit(redOne, false);
+ mockView.handPanel.rangeClickEvent.emit(redThree, true);
- assertCollection(Arrays.asList(stone1, stone2, stone3));
+ assertCollection(Arrays.asList(redOne, redTwo, redThree));
}
/** */
@@ -558,22 +516,16 @@ public class TurnControlTest {
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));
+ mockHand.drop(redOne, new Position(0, 0));
+ mockHand.drop(redTwo, new Position(1.5f, 0));
+ mockHand.drop(redThree, new Position(0, 1));
+ mockHand.drop(redFour, new Position(1, 1));
- mockView.handPanel.stoneClickEvent.emit(extraStone, false);
+ mockView.handPanel.stoneClickEvent.emit(redJoker, false);
- mockView.handPanel.stoneClickEvent.emit(stone1, true);
- mockView.handPanel.rangeClickEvent.emit(stone3, false);
- assertCollection(Arrays.asList(extraStone, stone1, stone2, stone3));
+ mockView.handPanel.stoneClickEvent.emit(redOne, true);
+ mockView.handPanel.rangeClickEvent.emit(redThree, false);
+ assertCollection(Arrays.asList(redJoker, redOne, redTwo, redThree));
}
/** */
@@ -581,21 +533,18 @@ public class TurnControlTest {
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));
+ StoneSet set1 = new StoneSet(Arrays.asList(redOne));
+ mockTable.findStoneSet.put(redOne, set1);
+ mockHand.drop(redTwo, new Position(0, 0));
// Select first stone
- mockView.tablePanel.stoneClickEvent.emit(stone1, false);
+ mockView.tablePanel.stoneClickEvent.emit(redOne, false);
- assertCollection(Arrays.asList(stone1));
+ assertCollection(Arrays.asList(redOne));
// Select second stone
- mockView.handPanel.rangeClickEvent.emit(stone2, false);
-
- assertCollection(Arrays.asList(stone1, stone2));
+ mockView.handPanel.rangeClickEvent.emit(redTwo, false);
+ assertCollection(Arrays.asList(redOne, redTwo));
}
/** */
@@ -603,20 +552,16 @@ public class TurnControlTest {
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));
+ StoneSet set1 = new StoneSet(Arrays.asList(redOne));
+ mockTable.findStoneSet.put(redOne, set1);
+ mockHand.drop(redTwo, new Position(0, 0));
// Select first stone
- mockView.tablePanel.stoneClickEvent.emit(stone1, false);
-
- assertCollection(Arrays.asList(stone1));
+ mockView.tablePanel.stoneClickEvent.emit(redOne, false);
+ assertCollection(Arrays.asList(redOne));
// Select second stone
- mockView.handPanel.rangeClickEvent.emit(stone2, true);
-
- assertCollection(Arrays.asList(stone1, stone2));
+ mockView.handPanel.rangeClickEvent.emit(redTwo, true);
+ assertCollection(Arrays.asList(redOne, redTwo));
}
private void assertCollection(List<Stone> expected) {
@@ -631,27 +576,15 @@ public class TurnControlTest {
public void testAddLeft() {
AccessibleTable table = new AccessibleTable();
HumanTurnControl turnControl = new HumanTurnControl(mockTimer);
- turnControl.setup(new ITurnControl.TurnInfo(table, mockPlayer.getHand(),
- mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN), new GameSettings(),
- mockView);
+ turnControl.setup(new ITurnControl.TurnInfo(table,
+ mockPlayer.getHand(), mockPlayer.getLaidOut(),
+ TurnMode.NORMAL_TURN), new GameSettings(), mockView);
turnControl.startTurn();
- Stone blueOne = new Stone(1, BLUE);
- Stone redOne = new Stone(1, RED);
- Stone blackOne = new Stone(1, BLACK);
- Stone blueTwo = new Stone(2, BLUE);
- Stone blueThree = new Stone(3, BLUE);
- Stone blueFour = new Stone(4, BLUE);
- Stone redTwo = new Stone(2, RED);
- Stone redThree = new Stone(3, RED);
- Stone redFour = new Stone(4, RED);
- Stone blackTwo = new Stone(2, BLACK);
- 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));
@@ -750,27 +683,14 @@ public class TurnControlTest {
public void testAddRight() {
AccessibleTable table = new AccessibleTable();
HumanTurnControl turnControl = new HumanTurnControl(mockTimer);
- turnControl.setup(new ITurnControl.TurnInfo(table, mockPlayer.getHand(),
- mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN), new GameSettings(),
- mockView);
+ turnControl.setup(new ITurnControl.TurnInfo(table,
+ mockPlayer.getHand(), mockPlayer.getLaidOut(),
+ TurnMode.NORMAL_TURN), new GameSettings(), mockView);
turnControl.startTurn();
- Stone blueOne = new Stone(1, BLUE);
- Stone redOne = new Stone(1, RED);
- Stone blackOne = new Stone(1, BLACK);
- Stone blueTwo = new Stone(2, BLUE);
- Stone blueThree = new Stone(3, BLUE);
- Stone blueFour = new Stone(4, BLUE);
- Stone redTwo = new Stone(2, RED);
- Stone redThree = new Stone(3, RED);
- Stone redFour = new Stone(4, RED);
- Stone blackTwo = new Stone(2, BLACK);
- 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));
@@ -869,27 +789,14 @@ public class TurnControlTest {
public void testAddNewSet() {
AccessibleTable table = new AccessibleTable();
HumanTurnControl turnControl = new HumanTurnControl(mockTimer);
- turnControl.setup(new ITurnControl.TurnInfo(table, mockPlayer.getHand(),
- mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN), new GameSettings(),
- mockView);
+ turnControl.setup(new ITurnControl.TurnInfo(table,
+ mockPlayer.getHand(), mockPlayer.getLaidOut(),
+ TurnMode.NORMAL_TURN), new GameSettings(), mockView);
turnControl.startTurn();
- Stone blueOne = new Stone(1, BLUE);
- Stone redOne = new Stone(1, RED);
- Stone blackOne = new Stone(1, BLACK);
- Stone blueTwo = new Stone(2, BLUE);
- Stone blueThree = new Stone(3, BLUE);
- Stone blueFour = new Stone(4, BLUE);
- Stone redTwo = new Stone(2, RED);
- Stone redThree = new Stone(3, RED);
- Stone redFour = new Stone(4, RED);
- Stone blackTwo = new Stone(2, BLACK);
- 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));
@@ -962,28 +869,15 @@ public class TurnControlTest {
public void testSortByGroups() {
testControl.startTurn();
- Stone red1 = new Stone(1, StoneColor.RED);
- Stone blue2 = new Stone(2, StoneColor.BLUE);
- Stone red4 = new Stone(4, StoneColor.RED);
- Stone red3 = new Stone(3, StoneColor.RED);
- Stone orange10 = new Stone(10, StoneColor.ORANGE);
- Stone blue1 = new Stone(1, StoneColor.BLUE);
- Stone blue4 = new Stone(4, StoneColor.BLUE);
- Stone blue4a = new Stone(4, StoneColor.BLUE);
- Stone joker = new Stone(StoneColor.BLACK);
- Stone black5 = new Stone(5, StoneColor.BLACK);
- Stone orange13 = new Stone(13, StoneColor.ORANGE);
- Stone red11 = new Stone(11, StoneColor.RED);
- Stone black10 = new Stone(10, StoneColor.BLACK);
- mockHand.drop(red1, new Position(0, 0));
- mockHand.drop(blue2, new Position(0, 0));
- mockHand.drop(red4, new Position(0, 0));
- mockHand.drop(red3, new Position(0, 0));
+ mockHand.drop(redOne, new Position(0, 0));
+ mockHand.drop(blueTwo, new Position(0, 0));
+ mockHand.drop(redFour, new Position(0, 0));
+ mockHand.drop(redThree, new Position(0, 0));
mockHand.drop(orange10, new Position(0, 0));
- mockHand.drop(blue1, new Position(0, 0));
- mockHand.drop(blue4, new Position(0, 0));
+ mockHand.drop(blueOne, new Position(0, 0));
+ mockHand.drop(blueFour, new Position(0, 0));
mockHand.drop(blue4a, new Position(0, 0));
- mockHand.drop(joker, new Position(0, 0));
+ mockHand.drop(blackJoker, new Position(0, 0));
mockHand.drop(black5, new Position(0, 0));
mockHand.drop(orange13, new Position(0, 0));
mockHand.drop(red11, new Position(0, 0));
@@ -993,28 +887,28 @@ public class TurnControlTest {
List<Pair<Stone, Position>> stones = new ArrayList<Pair<Stone, Position>>(
mockHand.stones);
- Collections
- .sort(stones, new HumanTurnControl.HandStonePositionComparator());
+ Collections.sort(stones,
+ new HumanTurnControl.HandStonePositionComparator());
assertEquals(stones.size(), 13);
- assertSame(stones.get(0).getFirst(), blue1);
- assertSame(stones.get(1).getFirst(), red1);
- assertSame(stones.get(2).getFirst(), blue2);
- assertSame(stones.get(3).getFirst(), red3);
+ assertSame(stones.get(0).getFirst(), blueOne);
+ assertSame(stones.get(1).getFirst(), redOne);
+ assertSame(stones.get(2).getFirst(), blueTwo);
+ assertSame(stones.get(3).getFirst(), redThree);
- assertTrue(stones.get(4).getFirst() == blue4
+ assertTrue(stones.get(4).getFirst() == blueFour
|| stones.get(4).getFirst() == blue4a);
- assertTrue(stones.get(5).getFirst() == blue4
+ assertTrue(stones.get(5).getFirst() == blueFour
|| stones.get(5).getFirst() == blue4a);
- assertSame(stones.get(6).getFirst(), red4);
+ assertSame(stones.get(6).getFirst(), redFour);
assertSame(stones.get(7).getFirst(), black5);
assertSame(stones.get(8).getFirst(), black10);
assertSame(stones.get(9).getFirst(), orange10);
assertSame(stones.get(10).getFirst(), red11);
assertSame(stones.get(11).getFirst(), orange13);
- assertSame(stones.get(12).getFirst(), joker);
+ assertSame(stones.get(12).getFirst(), blackJoker);
checkHandDisplay(mockHand);
}
@@ -1024,28 +918,15 @@ public class TurnControlTest {
public void testSortByRuns() {
testControl.startTurn();
- Stone red1 = new Stone(1, StoneColor.RED);
- Stone blue2 = new Stone(2, StoneColor.BLUE);
- Stone red4 = new Stone(4, StoneColor.RED);
- Stone red3 = new Stone(3, StoneColor.RED);
- Stone orange10 = new Stone(10, StoneColor.ORANGE);
- Stone blue1 = new Stone(1, StoneColor.BLUE);
- Stone blue4 = new Stone(4, StoneColor.BLUE);
- Stone blue4a = new Stone(4, StoneColor.BLUE);
- Stone joker = new Stone(StoneColor.BLACK);
- Stone black5 = new Stone(5, StoneColor.BLACK);
- Stone orange13 = new Stone(13, StoneColor.ORANGE);
- Stone red11 = new Stone(11, StoneColor.RED);
- Stone black10 = new Stone(10, StoneColor.BLACK);
- mockHand.drop(red1, new Position(0, 0));
- mockHand.drop(blue2, new Position(0, 0));
- mockHand.drop(red4, new Position(0, 0));
- mockHand.drop(red3, new Position(0, 0));
+ mockHand.drop(redOne, new Position(0, 0));
+ mockHand.drop(blueTwo, new Position(0, 0));
+ mockHand.drop(redFour, new Position(0, 0));
+ mockHand.drop(redThree, new Position(0, 0));
mockHand.drop(orange10, new Position(0, 0));
- mockHand.drop(blue1, new Position(0, 0));
- mockHand.drop(blue4, new Position(0, 0));
+ mockHand.drop(blueOne, new Position(0, 0));
+ mockHand.drop(blueFour, new Position(0, 0));
mockHand.drop(blue4a, new Position(0, 0));
- mockHand.drop(joker, new Position(0, 0));
+ mockHand.drop(blackJoker, new Position(0, 0));
mockHand.drop(black5, new Position(0, 0));
mockHand.drop(orange13, new Position(0, 0));
mockHand.drop(red11, new Position(0, 0));
@@ -1055,8 +936,8 @@ public class TurnControlTest {
List<Pair<Stone, Position>> stones = new ArrayList<Pair<Stone, Position>>(
mockHand.stones);
- Collections
- .sort(stones, new HumanTurnControl.HandStonePositionComparator());
+ Collections.sort(stones,
+ new HumanTurnControl.HandStonePositionComparator());
assertEquals(stones.size(), 13);
@@ -1064,19 +945,19 @@ public class TurnControlTest {
assertSame(stones.get(1).getFirst(), black10);
assertSame(stones.get(2).getFirst(), orange10);
assertSame(stones.get(3).getFirst(), orange13);
- assertSame(stones.get(4).getFirst(), blue1);
- assertSame(stones.get(5).getFirst(), blue2);
+ assertSame(stones.get(4).getFirst(), blueOne);
+ assertSame(stones.get(5).getFirst(), blueTwo);
- assertTrue(stones.get(6).getFirst() == blue4
+ assertTrue(stones.get(6).getFirst() == blueFour
|| stones.get(6).getFirst() == blue4a);
- assertTrue(stones.get(7).getFirst() == blue4
+ assertTrue(stones.get(7).getFirst() == blueFour
|| stones.get(7).getFirst() == blue4a);
- assertSame(stones.get(8).getFirst(), red1);
- assertSame(stones.get(9).getFirst(), red3);
- assertSame(stones.get(10).getFirst(), red4);
+ assertSame(stones.get(8).getFirst(), redOne);
+ assertSame(stones.get(9).getFirst(), redThree);
+ assertSame(stones.get(10).getFirst(), redFour);
assertSame(stones.get(11).getFirst(), red11);
- assertSame(stones.get(12).getFirst(), joker);
+ assertSame(stones.get(12).getFirst(), blackJoker);
checkHandDisplay(mockHand);
}
@@ -1086,21 +967,18 @@ public class TurnControlTest {
public void testDropHandValid() {
testControl.startTurn();
- 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));
+ mockHand.drop(redJoker, new Position(0, 0));
+ mockHand.drop(blackJoker, new Position(1, 0));
- mockView.handPanel.stoneClickEvent.emit(firstStone, true);
- mockView.handPanel.stoneClickEvent.emit(secondStone, true);
+ mockView.handPanel.stoneClickEvent.emit(redJoker, true);
+ mockView.handPanel.stoneClickEvent.emit(blackJoker, true);
mockView.handPanel.clickEvent.emit(new Position(2, 0.25f));
assertCollection(new ArrayList<Stone>());
- Set<Stone> expected = new HashSet<Stone>(Arrays.asList(firstStone,
- secondStone));
+ Set<Stone> expected = new HashSet<Stone>(Arrays.asList(redJoker,
+ blackJoker));
assertEquals(expected, mockHand.pickups);
Set<Stone> handStones = new HashSet<Stone>();
@@ -1116,23 +994,19 @@ public class TurnControlTest {
public void testDropHandInvalid() {
testControl.startTurn();
- 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));
+ mockHand.drop(redJoker, new Position(0, 0));
+ mockHand.drop(black13, new Position(1, 0));
- mockView.handPanel.stoneClickEvent.emit(firstStone, true);
- mockView.tablePanel.stoneClickEvent.emit(secondStone, true);
- mockView.handPanel.stoneClickEvent.emit(thirdStone, true);
+ mockView.handPanel.stoneClickEvent.emit(redJoker, true);
+ mockView.tablePanel.stoneClickEvent.emit(blackJoker, true);
+ mockView.handPanel.stoneClickEvent.emit(black13, true);
mockView.handPanel.clickEvent.emit(new Position(2, 0.25f));
- assertCollection(Arrays.asList(secondStone));
+ assertCollection(Arrays.asList(blackJoker));
- Set<Stone> expected = new HashSet<Stone>(Arrays.asList(firstStone,
- thirdStone));
+ Set<Stone> expected = new HashSet<Stone>(Arrays.asList(redJoker,
+ black13));
assertEquals(expected, mockHand.pickups);
Set<Stone> handStones = new HashSet<Stone>();