Fixed chat tests

#story[1246]
This commit is contained in:
Kusal Ekanayake
2017-09-05 17:27:34 +12:00
parent f33e4cc137
commit 0650ba30e2
4 changed files with 41 additions and 16 deletions
@@ -85,7 +85,7 @@ public class GameState implements Runnable {
players = new ArrayList<>(); players = new ArrayList<>();
GameState.hostIpAddress = hostIpAddress; GameState.hostIpAddress = hostIpAddress;
customizationFlag = false; customizationFlag = false;
speedMultiplier = 1.0;
currentStage = GameStages.LOBBYING; currentStage = GameStages.LOBBYING;
isRaceStarted = false; isRaceStarted = false;
//set this when game stage changes to prerace //set this when game stage changes to prerace
@@ -35,7 +35,15 @@
<CompoundMarkSequence> <CompoundMarkSequence>
<Corner SeqID="1" CompoundMarkID="1" Rounding="PS" ZoneSize="3" /> <Corner SeqID="1" CompoundMarkID="1" Rounding="PS" ZoneSize="3" />
<Corner SeqID="2" CompoundMarkID="2" Rounding="Port" ZoneSize="3" /> <Corner SeqID="2" CompoundMarkID="2" Rounding="Port" ZoneSize="3" />
<Corner SeqID="3" CompoundMarkID="5" Rounding="PS" ZoneSize="3" /> <Corner SeqID="3" CompoundMarkID="3" Rounding="SP" ZoneSize="3" />
<Corner SeqID="4" CompoundMarkID="4" Rounding="PS" ZoneSize="3" />
<Corner SeqID="5" CompoundMarkID="3" Rounding="SP" ZoneSize="3" />
<Corner SeqID="6" CompoundMarkID="4" Rounding="PS" ZoneSize="3" />
<Corner SeqID="7" CompoundMarkID="3" Rounding="SP" ZoneSize="3" />
<Corner SeqID="8" CompoundMarkID="4" Rounding="PS" ZoneSize="3" />
<Corner SeqID="9" CompoundMarkID="3" Rounding="SP" ZoneSize="3" />
<Corner SeqID="10" CompoundMarkID="4" Rounding="PS" ZoneSize="3" />
<Corner SeqID="11" CompoundMarkID="5" Rounding="PS" ZoneSize="3" />
</CompoundMarkSequence> </CompoundMarkSequence>
<CourseLimit> <CourseLimit>
<Limit SeqID="1" Lat="57.6739450" Lon="11.8417100" /> <Limit SeqID="1" Lat="57.6739450" Lon="11.8417100" />
+1 -1
View File
@@ -1,5 +1,5 @@
Feature: SendChat Feature: SendChat
Scenario: User send chat to another client Scenario: User send chat to another client
Given The are two games running Given There are two games running
When the user has pressed sends the message "Hello world" in a text box When the user has pressed sends the message "Hello world" in a text box
Then the other client should receive the message "Hello world" Then the other client should receive the message "Hello world"
+30 -13
View File
@@ -3,7 +3,11 @@ package steps;
import cucumber.api.java.en.Given; import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then; import cucumber.api.java.en.Then;
import cucumber.api.java.en.When; import cucumber.api.java.en.When;
import javafx.scene.layout.Pane;
import seng302.gameServer.GameStages;
import seng302.gameServer.GameState;
import seng302.gameServer.MainServerThread; import seng302.gameServer.MainServerThread;
import seng302.visualiser.ClientToServerThread;
import seng302.visualiser.GameClient; import seng302.visualiser.GameClient;
/** /**
@@ -11,31 +15,44 @@ import seng302.visualiser.GameClient;
*/ */
public class SendChatSteps { public class SendChatSteps {
MainServerThread mst; private boolean dcSent = false;
GameClient client1; private ClientToServerThread client;
GameClient client2; private ClientToServerThread host;
private MainServerThread mst;
//TODO Need to mock the controller pane in order to run the full game client //TODO Need to mock the controller pane in order to run the full game client
@Given("^The are two games running$") @Given("^There are two games running$")
public void the_are_two_games_running() throws Throwable { public void the_are_two_games_running() throws Throwable {
// client1 = new GameClient(new Pane()); mst = new MainServerThread();
// client1.runAsHost("localhost", 4942); host = new ClientToServerThread("localhost", 4942);
//// client2 = new ClientToServerThread("localhost", 4942); try {
// GameState.setCurrentStage(GameStages.RACING); Thread.sleep(100);
// Thread.sleep(200); } catch (InterruptedException ie) {
ie.printStackTrace();
}
client = new ClientToServerThread("localhost", 4942);
try {
Thread.sleep(100);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
mst.startGame();
Thread.sleep(200);
} }
@When("^the user has pressed sends the message \"([^\"]*)\" in a text box$") @When("^the user has pressed sends the message \"([^\"]*)\" in a text box$")
public void the_user_has_pressed_sends_the_message_in_a_text_box(String arg1) throws Throwable { public void the_user_has_pressed_sends_the_message_in_a_text_box(String arg1) throws Throwable {
// client1.getSocketThread().sendChatterMessage(arg1); client.sendChatterMessage("[time_prefix] <name_prefix> " + arg1);
} }
@Then("^the other client should receive the message \"([^\"]*)\"$") @Then("^the other client should receive the message \"([^\"]*)\"$")
public void the_other_client_should_recieve_the_message(String arg1) throws Throwable { public void the_other_client_should_receive_the_message(String arg1) throws Throwable {
// System.out.println(client2.getPacketQueue()); System.out.println("HERE IT IS" + host.getPacketQueue().peek());
// client2.setSocketToClose(); mst.terminate();
host.setSocketToClose();
client.setSocketToClose();
} }
} }