Kommentare
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@559 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
fd378778d1
commit
1823fb1610
5 changed files with 144 additions and 76 deletions
|
@ -38,8 +38,10 @@ public class NetworkRoundControlTest {
|
|||
gameSettings.getPlayerList().add(new PlayerSettings("Ida", Color.RED));
|
||||
gameSettings.getPlayerList().add(
|
||||
new PlayerSettings("Matthias", Color.YELLOW));
|
||||
gameSettings.getPlayerList().add(new PlayerSettings("Jannis", Color.GREEN));
|
||||
gameSettings.getPlayerList().add(new PlayerSettings("Bennet", Color.BLACK));
|
||||
gameSettings.getPlayerList().add(
|
||||
new PlayerSettings("Jannis", Color.GREEN));
|
||||
gameSettings.getPlayerList().add(
|
||||
new PlayerSettings("Bennet", Color.BLACK));
|
||||
|
||||
gameSettings.getPlayerList().get(1).setType(Type.COMPUTER);
|
||||
gameSettings.getPlayerList().get(2).setType(Type.NETWORK);
|
||||
|
@ -49,9 +51,11 @@ public class NetworkRoundControlTest {
|
|||
connectionControl = new MockConnectionControl();
|
||||
}
|
||||
|
||||
/** */
|
||||
@Test
|
||||
public void testHostRound() {
|
||||
connectionControl.nickname = gameSettings.getPlayerList().get(0).getName();
|
||||
connectionControl.nickname = gameSettings.getPlayerList().get(0)
|
||||
.getName();
|
||||
|
||||
testRoundState = new RoundState(gameSettings, null);
|
||||
testRound = new NetworkRoundControl(testRoundState, view,
|
||||
|
@ -67,8 +71,8 @@ public class NetworkRoundControlTest {
|
|||
IPlayer player = testRoundState.getNthPlayer(i);
|
||||
assertSame(gameSettings.getPlayerList().get(i),
|
||||
player.getPlayerSettings());
|
||||
assertEquals(gameSettings.getNumberOfStonesDealt(), player.getHand()
|
||||
.getSize());
|
||||
assertEquals(gameSettings.getNumberOfStonesDealt(), player
|
||||
.getHand().getSize());
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
|
@ -80,7 +84,8 @@ public class NetworkRoundControlTest {
|
|||
}
|
||||
}
|
||||
|
||||
assertSame(testRoundState.getNthPlayer(0), testRoundState.getActivePlayer());
|
||||
assertSame(testRoundState.getNthPlayer(0),
|
||||
testRoundState.getActivePlayer());
|
||||
assertTrue(connectionControl.turnStarted);
|
||||
connectionControl.turnStarted = false;
|
||||
|
||||
|
@ -95,7 +100,8 @@ public class NetworkRoundControlTest {
|
|||
connectionControl.nextPlayer = false;
|
||||
|
||||
connectionControl.nextPlayerEvent.emit();
|
||||
assertSame(testRoundState.getNthPlayer(1), testRoundState.getActivePlayer());
|
||||
assertSame(testRoundState.getNthPlayer(1),
|
||||
testRoundState.getActivePlayer());
|
||||
assertTrue(connectionControl.turnStarted);
|
||||
connectionControl.turnStarted = false;
|
||||
|
||||
|
@ -107,50 +113,59 @@ public class NetworkRoundControlTest {
|
|||
connectionControl.nextPlayer = false;
|
||||
|
||||
connectionControl.nextPlayerEvent.emit();
|
||||
assertSame(testRoundState.getNthPlayer(2), testRoundState.getActivePlayer());
|
||||
assertSame(testRoundState.getNthPlayer(2),
|
||||
testRoundState.getActivePlayer());
|
||||
assertTrue(connectionControl.turnStarted);
|
||||
connectionControl.turnStarted = false;
|
||||
|
||||
connectionControl.turnStartEvent.emit();
|
||||
assertFalse(connectionControl.turnEnded);
|
||||
|
||||
connectionControl.turnEndEvent.emit(testRoundState, new InvalidTurnInfo(
|
||||
testRoundState.getTable(), null, Collections.<StoneSet> emptyList()));
|
||||
connectionControl.turnEndEvent.emit(testRoundState,
|
||||
new InvalidTurnInfo(testRoundState.getTable(), null,
|
||||
Collections.<StoneSet> emptyList()));
|
||||
|
||||
assertFalse(connectionControl.nextPlayer);
|
||||
|
||||
connectionControl.nextPlayerEvent.emit();
|
||||
assertSame(testRoundState.getNthPlayer(3), testRoundState.getActivePlayer());
|
||||
assertSame(testRoundState.getNthPlayer(3),
|
||||
testRoundState.getActivePlayer());
|
||||
assertFalse(connectionControl.turnStarted);
|
||||
|
||||
connectionControl.turnStartEvent.emit();
|
||||
assertFalse(connectionControl.turnEnded);
|
||||
|
||||
connectionControl.turnEndEvent.emit(testRoundState, new InvalidTurnInfo(
|
||||
testRoundState.getTable(), null, Collections.<StoneSet> emptyList()));
|
||||
connectionControl.turnEndEvent.emit(testRoundState,
|
||||
new InvalidTurnInfo(testRoundState.getTable(), null,
|
||||
Collections.<StoneSet> emptyList()));
|
||||
|
||||
assertFalse(connectionControl.nextPlayer);
|
||||
|
||||
connectionControl.nextPlayerEvent.emit();
|
||||
assertSame(testRoundState.getNthPlayer(0), testRoundState.getActivePlayer());
|
||||
assertSame(testRoundState.getNthPlayer(0),
|
||||
testRoundState.getActivePlayer());
|
||||
assertFalse(connectionControl.turnStarted);
|
||||
|
||||
connectionControl.turnStartEvent.emit();
|
||||
assertFalse(connectionControl.turnEnded);
|
||||
}
|
||||
|
||||
/** */
|
||||
@Test
|
||||
public void testClientRound() {
|
||||
connectionControl.nickname = gameSettings.getPlayerList().get(2).getName();
|
||||
connectionControl.nickname = gameSettings.getPlayerList().get(2)
|
||||
.getName();
|
||||
|
||||
testRoundState = new RoundState(gameSettings, null);
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
IPlayer player = testRoundState.getNthPlayer(i);
|
||||
|
||||
player.getHand().drop(new Stone(StoneColor.RED), new Position(0, 0));
|
||||
player.getHand()
|
||||
.drop(new Stone(StoneColor.RED), new Position(0, 0));
|
||||
}
|
||||
|
||||
testRound = new NetworkRoundControl(null, view, connectionControl, false);
|
||||
testRound = new NetworkRoundControl(null, view, connectionControl,
|
||||
false);
|
||||
|
||||
connectionControl.turnStarted = false;
|
||||
connectionControl.turnEnded = false;
|
||||
|
@ -159,33 +174,38 @@ public class NetworkRoundControlTest {
|
|||
|
||||
connectionControl.roundStateUpdateEvent.emit(testRoundState);
|
||||
|
||||
assertSame(testRoundState.getNthPlayer(0), testRoundState.getActivePlayer());
|
||||
assertSame(testRoundState.getNthPlayer(0),
|
||||
testRoundState.getActivePlayer());
|
||||
assertFalse(connectionControl.turnStarted);
|
||||
|
||||
connectionControl.turnStartEvent.emit();
|
||||
assertFalse(connectionControl.turnEnded);
|
||||
|
||||
connectionControl.turnEndEvent.emit(testRoundState, new InvalidTurnInfo(
|
||||
testRoundState.getTable(), null, Collections.<StoneSet> emptyList()));
|
||||
connectionControl.turnEndEvent.emit(testRoundState,
|
||||
new InvalidTurnInfo(testRoundState.getTable(), null,
|
||||
Collections.<StoneSet> emptyList()));
|
||||
|
||||
assertFalse(connectionControl.turnEnded);
|
||||
|
||||
assertFalse(connectionControl.nextPlayer);
|
||||
|
||||
connectionControl.nextPlayerEvent.emit();
|
||||
assertSame(testRoundState.getNthPlayer(1), testRoundState.getActivePlayer());
|
||||
assertSame(testRoundState.getNthPlayer(1),
|
||||
testRoundState.getActivePlayer());
|
||||
assertFalse(connectionControl.turnStarted);
|
||||
|
||||
connectionControl.turnStartEvent.emit();
|
||||
assertFalse(connectionControl.turnEnded);
|
||||
|
||||
connectionControl.turnEndEvent.emit(testRoundState, new InvalidTurnInfo(
|
||||
testRoundState.getTable(), null, Collections.<StoneSet> emptyList()));
|
||||
connectionControl.turnEndEvent.emit(testRoundState,
|
||||
new InvalidTurnInfo(testRoundState.getTable(), null,
|
||||
Collections.<StoneSet> emptyList()));
|
||||
|
||||
assertFalse(connectionControl.nextPlayer);
|
||||
|
||||
connectionControl.nextPlayerEvent.emit();
|
||||
assertSame(testRoundState.getNthPlayer(2), testRoundState.getActivePlayer());
|
||||
assertSame(testRoundState.getNthPlayer(2),
|
||||
testRoundState.getActivePlayer());
|
||||
assertFalse(connectionControl.turnStarted);
|
||||
|
||||
connectionControl.turnStartEvent.emit();
|
||||
|
@ -199,7 +219,8 @@ public class NetworkRoundControlTest {
|
|||
connectionControl.nextPlayer = false;
|
||||
|
||||
connectionControl.nextPlayerEvent.emit();
|
||||
assertSame(testRoundState.getNthPlayer(3), testRoundState.getActivePlayer());
|
||||
assertSame(testRoundState.getNthPlayer(3),
|
||||
testRoundState.getActivePlayer());
|
||||
assertTrue(connectionControl.turnStarted);
|
||||
connectionControl.turnStarted = false;
|
||||
|
||||
|
@ -211,7 +232,8 @@ public class NetworkRoundControlTest {
|
|||
connectionControl.nextPlayer = false;
|
||||
|
||||
connectionControl.nextPlayerEvent.emit();
|
||||
assertSame(testRoundState.getNthPlayer(0), testRoundState.getActivePlayer());
|
||||
assertSame(testRoundState.getNthPlayer(0),
|
||||
testRoundState.getActivePlayer());
|
||||
assertTrue(connectionControl.turnStarted);
|
||||
connectionControl.turnStarted = false;
|
||||
|
||||
|
|
Reference in a new issue