Test initial display of hand stones
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@133 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
75f1382b82
commit
16da68b0ae
3 changed files with 35 additions and 4 deletions
|
@ -6,18 +6,23 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import jrummikub.model.MockHand;
|
||||||
import jrummikub.model.MockTable;
|
import jrummikub.model.MockTable;
|
||||||
|
import jrummikub.model.Position;
|
||||||
import jrummikub.model.Stone;
|
import jrummikub.model.Stone;
|
||||||
import jrummikub.model.StoneColor;
|
import jrummikub.model.StoneColor;
|
||||||
import jrummikub.model.StoneSet;
|
import jrummikub.model.StoneSet;
|
||||||
import jrummikub.util.Event;
|
import jrummikub.util.Event;
|
||||||
import jrummikub.util.IEvent;
|
import jrummikub.util.IEvent;
|
||||||
import jrummikub.util.IListener;
|
import jrummikub.util.IListener;
|
||||||
|
import jrummikub.util.Pair;
|
||||||
import jrummikub.view.MockView;
|
import jrummikub.view.MockView;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static jrummikub.model.StoneColor.*;
|
||||||
|
|
||||||
public class TurnControlTest {
|
public class TurnControlTest {
|
||||||
|
|
||||||
class MockTimer implements ITurnTimer {
|
class MockTimer implements ITurnTimer {
|
||||||
|
@ -45,6 +50,7 @@ public class TurnControlTest {
|
||||||
MockView mockView;
|
MockView mockView;
|
||||||
MockTimer mockTimer;
|
MockTimer mockTimer;
|
||||||
MockTable mockTable;
|
MockTable mockTable;
|
||||||
|
MockHand mockHand;
|
||||||
boolean eventFired;
|
boolean eventFired;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
@ -52,6 +58,7 @@ public class TurnControlTest {
|
||||||
mockView = new MockView();
|
mockView = new MockView();
|
||||||
mockTimer = new MockTimer();
|
mockTimer = new MockTimer();
|
||||||
mockTable = new MockTable();
|
mockTable = new MockTable();
|
||||||
|
mockHand = new MockHand();
|
||||||
testControl = new TurnControl(null, mockTable, mockView, mockTimer);
|
testControl = new TurnControl(null, mockTable, mockView, mockTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +67,29 @@ public class TurnControlTest {
|
||||||
assertTrue(mockTimer.timerRunning);
|
assertTrue(mockTimer.timerRunning);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Test
|
||||||
|
public void showInitialHand() {
|
||||||
|
mockView = new MockView();
|
||||||
|
mockTimer = new MockTimer();
|
||||||
|
mockTable = new MockTable();
|
||||||
|
mockHand = new MockHand();
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
testControl = new TurnControl(null, mockTable, mockView, mockTimer);
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for (Pair<Stone, Position> pair : mockView.playerPanel.handPanel.stones) {
|
||||||
|
assertSame(stones.get(i), pair);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
assertEquals(stones.size(), i);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void viewEndOfTurn() {
|
public void viewEndOfTurn() {
|
||||||
eventFired = false;
|
eventFired = false;
|
||||||
|
|
|
@ -10,6 +10,8 @@ public class MockHand implements IHand {
|
||||||
|
|
||||||
public List<Stone> stones = new ArrayList<Stone>();
|
public List<Stone> stones = new ArrayList<Stone>();
|
||||||
|
|
||||||
|
public Iterable<Pair<Stone, Position>> iterable;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stone pickUp(Position position) {
|
public Stone pickUp(Position position) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -39,8 +41,7 @@ public class MockHand implements IHand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Pair<Stone, Position>> iterator() {
|
public Iterator<Pair<Stone, Position>> iterator() {
|
||||||
// TODO Auto-generated method stub
|
return iterable.iterator();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MockHand clone() {
|
public MockHand clone() {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import jrummikub.util.Pair;
|
||||||
|
|
||||||
public class MockHandPanel implements IHandPanel {
|
public class MockHandPanel implements IHandPanel {
|
||||||
public Event2<Stone, Boolean> stoneClickEvent = new Event2<Stone, Boolean>();
|
public Event2<Stone, Boolean> stoneClickEvent = new Event2<Stone, Boolean>();
|
||||||
|
public Iterable<Pair<Stone, Position>> stones;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEvent2<Stone, Boolean> getStoneClickEvent() {
|
public IEvent2<Stone, Boolean> getStoneClickEvent() {
|
||||||
|
@ -35,8 +36,7 @@ public class MockHandPanel implements IHandPanel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setStones(Iterable<Pair<Stone, Position>> stones) {
|
public void setStones(Iterable<Pair<Stone, Position>> stones) {
|
||||||
// TODO Auto-generated method stub
|
this.stones = stones;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue