Fixed all tests
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@531 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
26086f1130
commit
bafbd6cac1
3 changed files with 32 additions and 16 deletions
|
@ -18,7 +18,7 @@ public class MockTable implements ITable {
|
||||||
/** */
|
/** */
|
||||||
public boolean valid = false;
|
public boolean valid = false;
|
||||||
/** */
|
/** */
|
||||||
public MockTable clonedTable;
|
public ITable clonedTable;
|
||||||
/** */
|
/** */
|
||||||
public List<Pair<StoneSet, Position>> sets = new ArrayList<Pair<StoneSet, Position>>();
|
public List<Pair<StoneSet, Position>> sets = new ArrayList<Pair<StoneSet, Position>>();
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ public class MockTable implements ITable {
|
||||||
return findStoneSet.get(stone);
|
return findStoneSet.get(stone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MockTable clone() {
|
public ITable clone() {
|
||||||
if (clonedTable == null)
|
if (clonedTable == null)
|
||||||
return this;
|
return this;
|
||||||
return clonedTable;
|
return clonedTable;
|
||||||
|
|
|
@ -135,7 +135,7 @@ public class RoundControlTest {
|
||||||
Iterator<Pair<StoneSet, Position>> stoneSetsView = view.tablePanel.stoneSets
|
Iterator<Pair<StoneSet, Position>> stoneSetsView = view.tablePanel.stoneSets
|
||||||
.iterator();
|
.iterator();
|
||||||
Iterator<Pair<StoneSet, Position>> stoneSetsModel = testRoundState.table
|
Iterator<Pair<StoneSet, Position>> stoneSetsModel = testRoundState.table
|
||||||
.clone().sets.iterator();
|
.clone().iterator();
|
||||||
|
|
||||||
while (stoneSetsView.hasNext()) {
|
while (stoneSetsView.hasNext()) {
|
||||||
assertTrue(stoneSetsModel.hasNext());
|
assertTrue(stoneSetsModel.hasNext());
|
||||||
|
|
|
@ -143,7 +143,10 @@ public class TurnControlTest {
|
||||||
mockRoundState = new MockRoundState();
|
mockRoundState = new MockRoundState();
|
||||||
mockTimer = new MockTimer();
|
mockTimer = new MockTimer();
|
||||||
mockTable = new MockTable();
|
mockTable = new MockTable();
|
||||||
|
|
||||||
|
mockRoundState.table = mockTable;
|
||||||
mockHand = new MockHand();
|
mockHand = new MockHand();
|
||||||
|
mockRoundState.players.get(0).hand = mockHand;
|
||||||
mockPlayer = new MockPlayer(null, null);
|
mockPlayer = new MockPlayer(null, null);
|
||||||
mockPlayer.hand = mockHand;
|
mockPlayer.hand = mockHand;
|
||||||
testControl = new HumanTurnControl(mockTimer);
|
testControl = new HumanTurnControl(mockTimer);
|
||||||
|
@ -163,6 +166,7 @@ public class TurnControlTest {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Test
|
@Test
|
||||||
public void showInitialHand() {
|
public void showInitialHand() {
|
||||||
|
mockRoundState.turnNumber = -1;
|
||||||
mockView.bottomPanelType = BottomPanelType.START_TURN_PANEL;
|
mockView.bottomPanelType = BottomPanelType.START_TURN_PANEL;
|
||||||
|
|
||||||
List<Pair<Stone, Position>> stones = Arrays.asList(
|
List<Pair<Stone, Position>> stones = Arrays.asList(
|
||||||
|
@ -170,11 +174,13 @@ public class TurnControlTest {
|
||||||
new Pair<Stone, Position>(blackJoker, new Position(1, 0)));
|
new Pair<Stone, Position>(blackJoker, new Position(1, 0)));
|
||||||
|
|
||||||
mockHand.iterable = stones;
|
mockHand.iterable = stones;
|
||||||
|
mockRoundState.players.get(0).hand = mockHand;
|
||||||
|
|
||||||
testControl = new HumanTurnControl(mockTimer);
|
testControl = new HumanTurnControl(mockTimer);
|
||||||
testControl.setup(new ITurnControl.TurnInfo(mockRoundState,
|
testControl.setup(new ITurnControl.TurnInfo(mockRoundState,
|
||||||
TurnMode.NORMAL_TURN), new GameSettings(), mockView);
|
TurnMode.INSPECT_ONLY), new GameSettings(), mockView);
|
||||||
testControl.startTurn();
|
testControl.startTurn();
|
||||||
|
mockView.startTurnEvent.emit();
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Pair<Stone, Position> pair : mockView.handPanel.stones) {
|
for (Pair<Stone, Position> pair : mockView.handPanel.stones) {
|
||||||
|
@ -590,18 +596,21 @@ public class TurnControlTest {
|
||||||
public void testAddLeft() {
|
public void testAddLeft() {
|
||||||
AccessibleTable table = new AccessibleTable();
|
AccessibleTable table = new AccessibleTable();
|
||||||
HumanTurnControl turnControl = new HumanTurnControl(mockTimer);
|
HumanTurnControl turnControl = new HumanTurnControl(mockTimer);
|
||||||
turnControl.setup(new ITurnControl.TurnInfo(mockRoundState,
|
mockTable.clonedTable = table;
|
||||||
TurnMode.NORMAL_TURN), new GameSettings(), mockView);
|
|
||||||
turnControl.startTurn();
|
|
||||||
|
|
||||||
|
mockHand.drop(blueThree, new Position(0, 0));
|
||||||
|
mockHand.drop(blueFour, new Position(0, 0));
|
||||||
StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne,
|
StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne,
|
||||||
blackOne, redTwo, redThree, redFour, blackTwo, blackThree));
|
blackOne, redTwo, redThree, redFour, blackTwo, blackThree));
|
||||||
StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blackFour,
|
StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blackFour,
|
||||||
blackFive));
|
blackFive));
|
||||||
table.drop(oldSet1, new Position(0, 0));
|
table.drop(oldSet1, new Position(0, 0));
|
||||||
table.drop(oldSet2, 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 ITurnControl.TurnInfo(mockRoundState,
|
||||||
|
TurnMode.NORMAL_TURN), new GameSettings(), mockView);
|
||||||
|
turnControl.startTurn();
|
||||||
|
|
||||||
mockView.handPanel.stoneClickEvent.emit(blueThree, false);
|
mockView.handPanel.stoneClickEvent.emit(blueThree, false);
|
||||||
mockView.tablePanel.stoneClickEvent.emit(redOne, true);
|
mockView.tablePanel.stoneClickEvent.emit(redOne, true);
|
||||||
mockView.tablePanel.stoneClickEvent.emit(redThree, true);
|
mockView.tablePanel.stoneClickEvent.emit(redThree, true);
|
||||||
|
@ -695,10 +704,9 @@ public class TurnControlTest {
|
||||||
@Test
|
@Test
|
||||||
public void testAddRight() {
|
public void testAddRight() {
|
||||||
AccessibleTable table = new AccessibleTable();
|
AccessibleTable table = new AccessibleTable();
|
||||||
|
mockTable.clonedTable = table;
|
||||||
HumanTurnControl turnControl = new HumanTurnControl(mockTimer);
|
HumanTurnControl turnControl = new HumanTurnControl(mockTimer);
|
||||||
turnControl.setup(new TurnInfo(mockRoundState, TurnMode.NORMAL_TURN),
|
|
||||||
new GameSettings(), mockView);
|
|
||||||
turnControl.startTurn();
|
|
||||||
StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne,
|
StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne,
|
||||||
blackOne, redTwo, redThree, redFour, blackTwo, blackThree));
|
blackOne, redTwo, redThree, redFour, blackTwo, blackThree));
|
||||||
StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blackFour,
|
StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blackFour,
|
||||||
|
@ -707,6 +715,11 @@ public class TurnControlTest {
|
||||||
table.drop(oldSet2, new Position(0, 0));
|
table.drop(oldSet2, new Position(0, 0));
|
||||||
mockHand.drop(blueThree, new Position(0, 0));
|
mockHand.drop(blueThree, new Position(0, 0));
|
||||||
mockHand.drop(blueFour, new Position(0, 0));
|
mockHand.drop(blueFour, new Position(0, 0));
|
||||||
|
|
||||||
|
turnControl.setup(new TurnInfo(mockRoundState, TurnMode.NORMAL_TURN),
|
||||||
|
new GameSettings(), mockView);
|
||||||
|
turnControl.startTurn();
|
||||||
|
|
||||||
mockView.handPanel.stoneClickEvent.emit(blueThree, false);
|
mockView.handPanel.stoneClickEvent.emit(blueThree, false);
|
||||||
mockView.tablePanel.stoneClickEvent.emit(redOne, true);
|
mockView.tablePanel.stoneClickEvent.emit(redOne, true);
|
||||||
mockView.tablePanel.stoneClickEvent.emit(redThree, true);
|
mockView.tablePanel.stoneClickEvent.emit(redThree, true);
|
||||||
|
@ -800,10 +813,7 @@ public class TurnControlTest {
|
||||||
@Test
|
@Test
|
||||||
public void testAddNewSet() {
|
public void testAddNewSet() {
|
||||||
AccessibleTable table = new AccessibleTable();
|
AccessibleTable table = new AccessibleTable();
|
||||||
HumanTurnControl turnControl = new HumanTurnControl(mockTimer);
|
mockTable.clonedTable = table;
|
||||||
turnControl.setup(new TurnInfo(mockRoundState, TurnMode.NORMAL_TURN),
|
|
||||||
new GameSettings(), mockView);
|
|
||||||
turnControl.startTurn();
|
|
||||||
StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne,
|
StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne,
|
||||||
blackOne, redTwo, redThree, redFour, blackTwo, blackThree));
|
blackOne, redTwo, redThree, redFour, blackTwo, blackThree));
|
||||||
StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blackFour,
|
StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blackFour,
|
||||||
|
@ -812,11 +822,17 @@ public class TurnControlTest {
|
||||||
table.drop(oldSet2, new Position(0, 0));
|
table.drop(oldSet2, new Position(0, 0));
|
||||||
mockHand.drop(blueThree, new Position(0, 0));
|
mockHand.drop(blueThree, new Position(0, 0));
|
||||||
mockHand.drop(blueFour, new Position(0, 0));
|
mockHand.drop(blueFour, new Position(0, 0));
|
||||||
|
|
||||||
|
HumanTurnControl turnControl = new HumanTurnControl(mockTimer);
|
||||||
|
turnControl.setup(new TurnInfo(mockRoundState, TurnMode.NORMAL_TURN),
|
||||||
|
new GameSettings(), mockView);
|
||||||
|
turnControl.startTurn();
|
||||||
mockView.handPanel.stoneClickEvent.emit(blueThree, false);
|
mockView.handPanel.stoneClickEvent.emit(blueThree, false);
|
||||||
mockView.tablePanel.stoneClickEvent.emit(redOne, true);
|
mockView.tablePanel.stoneClickEvent.emit(redOne, true);
|
||||||
mockView.tablePanel.stoneClickEvent.emit(redThree, true);
|
mockView.tablePanel.stoneClickEvent.emit(redThree, true);
|
||||||
mockView.tablePanel.stoneClickEvent.emit(blueTwo, true);
|
mockView.tablePanel.stoneClickEvent.emit(blueTwo, true);
|
||||||
mockView.tablePanel.clickEvent.emit(new Position(0, 0));
|
mockView.tablePanel.clickEvent.emit(new Position(0, 0));
|
||||||
|
|
||||||
// handcheck
|
// handcheck
|
||||||
assertEquals(1, mockHand.getSize());
|
assertEquals(1, mockHand.getSize());
|
||||||
assertSame(blueFour, mockHand.stones.get(0).getFirst());
|
assertSame(blueFour, mockHand.stones.get(0).getFirst());
|
||||||
|
|
Reference in a new issue