mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Merged with remote changes
This commit is contained in:
@@ -2,4 +2,4 @@ Feature: SendChat
|
||||
Scenario: User send chat to another client
|
||||
Given The are two games running
|
||||
When the user has pressed sends the message "Hello world" in a text box
|
||||
Then the other client should recieve the message "Hello world"
|
||||
Then the other client should receive the message "Hello world"
|
||||
|
||||
@@ -26,6 +26,11 @@ public class ChatCommandsTest {
|
||||
|
||||
@Test
|
||||
public void sendFinishAsHost () {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ie) {
|
||||
ie.printStackTrace();
|
||||
}
|
||||
try {
|
||||
dcSent = false;
|
||||
new GameState("localhost");
|
||||
@@ -39,6 +44,7 @@ public class ChatCommandsTest {
|
||||
RaceStatusData rsd = StreamParser.extractRaceStatus(packet);
|
||||
if (rsd.getBoatData().get(0)[4] == BoatStatus.FINISHED.getCode()) {
|
||||
mst.terminate();
|
||||
System.out.println("AY WE DID IT");
|
||||
// host.setSocketToClose();
|
||||
Assert.assertTrue(dcSent);
|
||||
}
|
||||
@@ -76,6 +82,11 @@ public class ChatCommandsTest {
|
||||
|
||||
@Test
|
||||
public void sendSpeedAsHostValid () {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ie) {
|
||||
ie.printStackTrace();
|
||||
}
|
||||
new GameState("localhost");
|
||||
mst = new MainServerThread();
|
||||
host = null;
|
||||
@@ -97,6 +108,7 @@ public class ChatCommandsTest {
|
||||
ie.printStackTrace();
|
||||
}
|
||||
Assert.assertEquals(5.0, GameState.getSpeedMultiplier(), 0.00001);
|
||||
System.out.println("the thing " + GameState.getSpeedMultiplier());
|
||||
mst.terminate();
|
||||
// host.setSocketToClose();
|
||||
try {
|
||||
@@ -111,6 +123,11 @@ public class ChatCommandsTest {
|
||||
|
||||
@Test
|
||||
public void sendSpeedAsHostInvalid () {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ie) {
|
||||
ie.printStackTrace();
|
||||
}
|
||||
new GameState("localhost");
|
||||
mst = new MainServerThread();
|
||||
host = null;
|
||||
@@ -134,6 +151,7 @@ public class ChatCommandsTest {
|
||||
mst.terminate();
|
||||
// host.setSocketToClose();
|
||||
Assert.assertEquals(1.0, GameState.getSpeedMultiplier(), 0.00001);
|
||||
System.out.println("value " + GameState.getSpeedMultiplier());
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException ie) {
|
||||
@@ -143,10 +161,12 @@ public class ChatCommandsTest {
|
||||
|
||||
@Test
|
||||
public void sendCommandAsClient () {
|
||||
new GameState("localhost");
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ie) {
|
||||
ie.printStackTrace();
|
||||
}
|
||||
mst = new MainServerThread();
|
||||
host = null;
|
||||
client = null;
|
||||
try {
|
||||
host = new ClientToServerThread("localhost", 4942);
|
||||
try {
|
||||
@@ -189,13 +209,28 @@ public class ChatCommandsTest {
|
||||
|
||||
@Test
|
||||
public void receiveFinishedAsClient () {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ie) {
|
||||
ie.printStackTrace();
|
||||
}
|
||||
new GameState("localhost");
|
||||
dcSent = false;
|
||||
mst = new MainServerThread();
|
||||
host = null;
|
||||
try {
|
||||
host = new ClientToServerThread("localhost", 4942);
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException ie) {
|
||||
ie.printStackTrace();
|
||||
}
|
||||
client = new ClientToServerThread("localhost", 4942);
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException ie) {
|
||||
ie.printStackTrace();
|
||||
}
|
||||
client.addStreamObserver(() -> {
|
||||
while (client.getPacketQueue().peek() != null) {
|
||||
StreamPacket packet = client.getPacketQueue().poll();
|
||||
@@ -204,6 +239,7 @@ public class ChatCommandsTest {
|
||||
RaceStatusData rsd = StreamParser.extractRaceStatus(packet);
|
||||
if (rsd.getBoatData().get(0)[4] == BoatStatus.FINISHED.getCode()) {
|
||||
mst.terminate();
|
||||
System.out.println("TEST COMPLETE");
|
||||
// client.setSocketToClose();
|
||||
// host.setSocketToClose();
|
||||
Assert.assertTrue(dcSent);
|
||||
@@ -217,25 +253,26 @@ public class ChatCommandsTest {
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException ie) {
|
||||
ie.printStackTrace();
|
||||
}
|
||||
mst.startGame();
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException ie) {
|
||||
ie.printStackTrace();
|
||||
}
|
||||
// try {
|
||||
// Thread.sleep(100);
|
||||
// } catch (InterruptedException ie) {
|
||||
// ie.printStackTrace();
|
||||
// }
|
||||
// mst.startGame();
|
||||
// try {
|
||||
// Thread.sleep(100);
|
||||
// } catch (InterruptedException ie) {
|
||||
// ie.printStackTrace();
|
||||
// }
|
||||
host.sendChatterMessage("[time_prefix] <name_prefix> >finish");
|
||||
dcSent = true;
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
} catch (InterruptedException ie) {
|
||||
ie.printStackTrace();
|
||||
}
|
||||
// host.setSocketToClose();
|
||||
// try {
|
||||
// Thread.sleep(200);
|
||||
// } catch (InterruptedException ie) {
|
||||
// ie.printStackTrace();
|
||||
// }
|
||||
//// host.setSocketToClose();
|
||||
// mst.terminate();
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException ie) {
|
||||
|
||||
@@ -1,22 +1,10 @@
|
||||
package steps;
|
||||
|
||||
import cucumber.api.PendingException;
|
||||
import cucumber.api.java.en.Given;
|
||||
import cucumber.api.java.en.Then;
|
||||
import cucumber.api.java.en.When;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javafx.scene.layout.Pane;
|
||||
import org.junit.Assert;
|
||||
import org.mockito.Mock;
|
||||
import seng302.gameServer.GameStages;
|
||||
import seng302.gameServer.GameState;
|
||||
import seng302.gameServer.MainServerThread;
|
||||
import seng302.gameServer.messages.BoatAction;
|
||||
import seng302.model.ServerYacht;
|
||||
import seng302.visualiser.ClientToServerThread;
|
||||
import seng302.visualiser.GameClient;
|
||||
import seng302.visualiser.controllers.StartScreenController;
|
||||
|
||||
/**
|
||||
* Created by kre39 on 7/08/17.
|
||||
@@ -44,7 +32,7 @@ public class SendChatSteps {
|
||||
// client1.getSocketThread().sendChatterMessage(arg1);
|
||||
}
|
||||
|
||||
@Then("^the other client should recieve the message \"([^\"]*)\"$")
|
||||
@Then("^the other client should receive the message \"([^\"]*)\"$")
|
||||
public void the_other_client_should_recieve_the_message(String arg1) throws Throwable {
|
||||
// System.out.println(client2.getPacketQueue());
|
||||
// client2.setSocketToClose();
|
||||
|
||||
Reference in New Issue
Block a user