Tests für NetworkControl
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@473 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
80f0c0d43f
commit
d47e291d19
6 changed files with 26 additions and 23 deletions
|
@ -39,6 +39,8 @@ public class MockConnectionControl implements IConnectionControl {
|
|||
public boolean connected;
|
||||
/** */
|
||||
public boolean failOnConnect;
|
||||
/** */
|
||||
public GameData joinedGame;
|
||||
|
||||
@Override
|
||||
public String getNickname() {
|
||||
|
@ -112,20 +114,18 @@ public class MockConnectionControl implements IConnectionControl {
|
|||
|
||||
@Override
|
||||
public GameData getCurrentGame() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return currentGame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentGame(GameData game) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
currentGame = game;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void joinGame(GameData game) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
currentGame = game;
|
||||
joinedGame = game;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package jrummikub.view;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import jrummikub.util.GameData;
|
||||
|
@ -16,6 +17,10 @@ public class MockGameListPanel implements IGameListPanel {
|
|||
public MockEvent openNewGameEvent = new MockEvent();
|
||||
/** */
|
||||
public MockEvent cancelEvent = new MockEvent();
|
||||
/** */
|
||||
public List<GameData> gameList = new ArrayList<GameData>();
|
||||
/** */
|
||||
public String channelName;
|
||||
|
||||
@Override
|
||||
public IEvent getOpenNewGameEvent() {
|
||||
|
@ -34,14 +39,12 @@ public class MockGameListPanel implements IGameListPanel {
|
|||
|
||||
@Override
|
||||
public void setChannelName(String name) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
channelName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGameList(List<GameData> games) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
gameList = games;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@ public class MockSettingsPanel implements ISettingsPanel {
|
|||
/** */
|
||||
public Set<StoneColor> stoneColors;
|
||||
private MockEvent backEvent = new MockEvent();
|
||||
public SettingsMode settingsMode;
|
||||
|
||||
@Override
|
||||
public IEvent getAddPlayerEvent() {
|
||||
|
@ -216,8 +217,7 @@ public class MockSettingsPanel implements ISettingsPanel {
|
|||
|
||||
@Override
|
||||
public void setSettingsMode(SettingsMode mode) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
settingsMode = mode;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package jrummikub.control;
|
||||
|
||||
import jrummikub.control.network.ConnectionControl;
|
||||
import jrummikub.control.network.NetworkControl;
|
||||
import jrummikub.model.GameSettings;
|
||||
import jrummikub.model.GameState;
|
||||
|
@ -149,7 +150,8 @@ public class ApplicationControl {
|
|||
}
|
||||
|
||||
private void createNetworkControl(LoginData loginData) {
|
||||
networkControl = new NetworkControl(loginData, view);
|
||||
ConnectionControl connectionControl = new ConnectionControl(loginData);
|
||||
networkControl = new NetworkControl(loginData, connectionControl, view);
|
||||
|
||||
networkControl.getStopNetworkEvent().add(new IListener() {
|
||||
@Override
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.jivesoftware.smack.util.Base64;
|
|||
import org.jivesoftware.smackx.muc.DiscussionHistory;
|
||||
import org.jivesoftware.smackx.muc.MultiUserChat;
|
||||
|
||||
class ConnectionControl implements IConnectionControl {
|
||||
public class ConnectionControl implements IConnectionControl {
|
||||
private final static String ELEMENT_NAME = "rummikub";
|
||||
private final static String NAMESPACE = "http://home.universe-factory.net/rummikub/";
|
||||
|
||||
|
@ -57,7 +57,7 @@ class ConnectionControl implements IConnectionControl {
|
|||
|
||||
private volatile GameData offeredGame;
|
||||
|
||||
ConnectionControl(LoginData loginData) {
|
||||
public ConnectionControl(LoginData loginData) {
|
||||
this.loginData = loginData;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,12 +40,13 @@ public class NetworkControl {
|
|||
* @param view
|
||||
* for events and handlers
|
||||
*/
|
||||
public NetworkControl(final LoginData loginData, final IView view) {
|
||||
public NetworkControl(final LoginData loginData,
|
||||
IConnectionControl connectionControl, final IView view) {
|
||||
this.view = view;
|
||||
connectionControl = new ConnectionControl(loginData);
|
||||
this.connectionControl = connectionControl;
|
||||
|
||||
addConnectionSetupListeners(loginData, view);
|
||||
addConnectionControlListeners(loginData, view);
|
||||
addConnectionControlListeners(view);
|
||||
|
||||
connections.add(view.getGameListPanel().getJoinEvent().add(
|
||||
new IListener1<GameData>() {
|
||||
|
@ -81,13 +82,10 @@ public class NetworkControl {
|
|||
/**
|
||||
* Adds the listeners for connection control events
|
||||
*
|
||||
* @param loginData
|
||||
* player's login data
|
||||
* @param view
|
||||
* view for events
|
||||
*/
|
||||
public void addConnectionControlListeners(final LoginData loginData,
|
||||
final IView view) {
|
||||
public void addConnectionControlListeners(final IView view) {
|
||||
connections.add(connectionControl.getGameOfferEvent().add(
|
||||
new IListener1<GameData>() {
|
||||
@Override
|
||||
|
|
Reference in a new issue