mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Started work on cucumber tests. Trying to sort through threads, getting inconsistent results.
#story[1111] #pair[kre39,ptg19]
This commit is contained in:
@@ -26,6 +26,7 @@ public class MainServerThread extends Observable implements Runnable, ClientConn
|
||||
private ArrayList<ServerToClientThread> serverToClientThreads = new ArrayList<>();
|
||||
|
||||
public MainServerThread() {
|
||||
new GameState("localhost");
|
||||
try {
|
||||
serverSocket = new ServerSocket(PORT);
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -25,6 +25,8 @@ import seng302.gameServer.server.messages.Message;
|
||||
*/
|
||||
public class ClientToServerThread implements Runnable {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Functional interface for receiving packets from client socket.
|
||||
*/
|
||||
|
||||
@@ -250,9 +250,8 @@ public class GameClient {
|
||||
private void processRaceStatusUpdate(RaceStatusData data) {
|
||||
if (allXMLReceived()) {
|
||||
raceState.updateState(data);
|
||||
if (raceView != null) {
|
||||
raceView.getGameView().setWindDir(raceState.getWindDirection());
|
||||
}
|
||||
if (raceView != null)
|
||||
raceView.getGameView().setWindDir(raceState.getWindDirection());
|
||||
for (long[] boatData : data.getBoatData()) {
|
||||
Yacht yacht = allBoatsMap.get((int) boatData[0]);
|
||||
yacht.setEstimateTimeTillNextMark(raceState.getRaceTime() - boatData[1]);
|
||||
|
||||
@@ -66,7 +66,7 @@ public class StartScreenController implements Initializable {
|
||||
*/
|
||||
@FXML
|
||||
public void hostButtonPressed() {
|
||||
new GameState(getLocalHostIp());
|
||||
// new GameState(getLocalHostIp());
|
||||
gameClient = new GameClient(holder);
|
||||
gameClient.runAsHost(getLocalHostIp(), 4942);
|
||||
// try {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import cucumber.api.CucumberOptions;
|
||||
import cucumber.api.junit.Cucumber;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/**
|
||||
* Created by kre39 on 7/08/17.
|
||||
*/
|
||||
|
||||
@RunWith(Cucumber.class)
|
||||
@CucumberOptions(features = "src/test/java/features")
|
||||
public class RunCucumberTests {
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
Feature: SailsToggle
|
||||
Scenario: User toggles in sail
|
||||
Given The game is running
|
||||
When the user has pressed "shift"
|
||||
Then the sails are "in"
|
||||
@@ -16,13 +16,11 @@ public class BoatSailAnimationToggleTest {
|
||||
|
||||
private Yacht yacht;
|
||||
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception{
|
||||
yacht = new Yacht("Yacht", 1, "YACHT", "YAC", "Test Yacht", "NZ");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void sailToggleTest() throws Exception {
|
||||
assertFalse(yacht.getSailIn());
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package steps;
|
||||
|
||||
import cucumber.api.java.en.Given;
|
||||
import cucumber.api.java.en.Then;
|
||||
import cucumber.api.java.en.When;
|
||||
import seng302.gameServer.GameStages;
|
||||
import seng302.gameServer.GameState;
|
||||
import seng302.gameServer.MainServerThread;
|
||||
import seng302.gameServer.server.messages.BoatActionMessage;
|
||||
import seng302.gameServer.server.messages.BoatActionType;
|
||||
import seng302.model.Yacht;
|
||||
import seng302.visualiser.ClientToServerThread;
|
||||
|
||||
/**
|
||||
* Created by kre39 on 7/08/17.
|
||||
*/
|
||||
public class ToggleSailSteps {
|
||||
|
||||
|
||||
MainServerThread mst;
|
||||
ClientToServerThread client;
|
||||
boolean sailsIn = false;
|
||||
long startTime;
|
||||
private Yacht yacht;
|
||||
|
||||
|
||||
|
||||
@Given("^The game is running$")
|
||||
public void the_game_is_running() throws Throwable {
|
||||
mst = new MainServerThread();
|
||||
client = new ClientToServerThread("localhost", 4942);
|
||||
GameState.setCurrentStage(GameStages.RACING);
|
||||
}
|
||||
|
||||
@When("^the user has pressed \"([^\"]*)\"$")
|
||||
public void the_user_has_pressed(String arg1) throws Throwable {
|
||||
startTime = System.currentTimeMillis();
|
||||
if (arg1 == "shift") {
|
||||
if (sailsIn) {
|
||||
client.sendBoatActionMessage(new BoatActionMessage(BoatActionType.SAILS_OUT));
|
||||
} else {
|
||||
client.sendBoatActionMessage(new BoatActionMessage(BoatActionType.SAILS_IN));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Then("^the sails are \"([^\"]*)\"$")
|
||||
public void the_sails_are(String arg1) throws Throwable {
|
||||
System.out.println(GameState.getYachts().values());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user