mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-02-25 17:33:33 +00:00
Another revamp to vehicle spawn process. Wrote tests.
This commit is contained in:
parent
5d5c609a2f
commit
68422401e5
22 changed files with 1267 additions and 340 deletions
|
|
@ -56,18 +56,4 @@ class ServerVehicleOverrideMsgTest extends Specification {
|
|||
|
||||
pkt mustEqual string2
|
||||
}
|
||||
|
||||
"encode (3)" in {
|
||||
val msg = ServerVehicleOverrideMsg.Lock(0, 12)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string1
|
||||
}
|
||||
|
||||
"encode (4)" in {
|
||||
val msg = ServerVehicleOverrideMsg.Auto(5)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string2
|
||||
}
|
||||
}
|
||||
|
|
|
|||
498
common/src/test/scala/objects/AutoDriveControlsTest.scala
Normal file
498
common/src/test/scala/objects/AutoDriveControlsTest.scala
Normal file
|
|
@ -0,0 +1,498 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects
|
||||
|
||||
import akka.actor.Props
|
||||
import akka.testkit.TestProbe
|
||||
import net.psforever.objects.serverobject.pad.{VehicleSpawnControl, VehicleSpawnPad}
|
||||
import net.psforever.objects.{Avatar, GlobalDefinitions, Player, Vehicle}
|
||||
import net.psforever.objects.serverobject.pad.process.{AutoDriveControls, VehicleSpawnControlGuided}
|
||||
import net.psforever.packet.game.PlanetSideGUID
|
||||
import net.psforever.types.{CharacterGender, PlanetSideEmpire, Vector3}
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
import scala.concurrent.duration._
|
||||
|
||||
class AutoDriveControlsTest extends Specification {
|
||||
"CancelEntry" should {
|
||||
val vehicle = Vehicle(GlobalDefinitions.fury)
|
||||
def exampleTest(vehicle : Vehicle) : Boolean = { vehicle.Position == Vector3(1,1,1) }
|
||||
|
||||
"create" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.CancelEarly(exampleTest)
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
setting.Type mustEqual AutoDriveControls.State.Cancel
|
||||
setting.Data mustEqual None
|
||||
setting.Delay mustEqual 200L
|
||||
}
|
||||
|
||||
"validate" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.CancelEarly(exampleTest)
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
|
||||
vehicle.Position mustEqual Vector3.Zero
|
||||
setting.Validate(vehicle) mustEqual false
|
||||
vehicle.Position = Vector3(1,1,1)
|
||||
setting.Validate(vehicle) mustEqual true
|
||||
}
|
||||
|
||||
"completion" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.CancelEarly(exampleTest)
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
setting.CompletionTest(vehicle) mustEqual true //always true
|
||||
}
|
||||
}
|
||||
|
||||
"Climb" should {
|
||||
val vehicle = Vehicle(GlobalDefinitions.mosquito)
|
||||
|
||||
"create" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.Climb(10.5f)
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
setting.Type mustEqual AutoDriveControls.State.Climb
|
||||
setting.Data mustEqual Some(10.5f)
|
||||
setting.Delay mustEqual 200L
|
||||
}
|
||||
|
||||
"validate" in {
|
||||
val vehicle_fury = Vehicle(GlobalDefinitions.fury)
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.Climb(10.5f)
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
|
||||
setting.Validate(vehicle) mustEqual true //mosquito is a flying vehicle
|
||||
setting.Validate(vehicle_fury) mustEqual false
|
||||
}
|
||||
|
||||
"completion" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.Climb(10.5f)
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
|
||||
vehicle.Position mustEqual Vector3.Zero
|
||||
setting.CompletionTest(vehicle) mustEqual false
|
||||
vehicle.Position = Vector3(0,0,10.5f)
|
||||
setting.CompletionTest(vehicle) mustEqual true
|
||||
}
|
||||
}
|
||||
|
||||
"Distance" should {
|
||||
val vehicle = Vehicle(GlobalDefinitions.fury)
|
||||
|
||||
"create" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.Distance(Vector3.Zero, 10.5f)
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
setting.Type mustEqual AutoDriveControls.State.Wait
|
||||
setting.Data mustEqual None
|
||||
setting.Delay mustEqual 200L
|
||||
}
|
||||
"validate" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.Distance(Vector3.Zero, 10.5f)
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
|
||||
vehicle.Velocity mustEqual None
|
||||
setting.Validate(vehicle) mustEqual false
|
||||
vehicle.Velocity = Vector3.Zero
|
||||
setting.Validate(vehicle) mustEqual false
|
||||
vehicle.Velocity = Vector3(1,0,0)
|
||||
setting.Validate(vehicle) mustEqual true
|
||||
}
|
||||
|
||||
"completion" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.Distance(Vector3.Zero, 10.5f)
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
|
||||
vehicle.Position = Vector3(0,0,0)
|
||||
setting.CompletionTest(vehicle) mustEqual false
|
||||
vehicle.Position = Vector3(10.5f,0,0)
|
||||
setting.CompletionTest(vehicle) mustEqual false
|
||||
vehicle.Position = Vector3(11,0,0)
|
||||
setting.CompletionTest(vehicle) mustEqual true
|
||||
vehicle.Position = Vector3(0,11,0)
|
||||
setting.CompletionTest(vehicle) mustEqual true
|
||||
vehicle.Position = Vector3(0,0,11)
|
||||
setting.CompletionTest(vehicle) mustEqual false
|
||||
vehicle.Position = Vector3(7.5f,7.5f,0)
|
||||
setting.CompletionTest(vehicle) mustEqual true
|
||||
}
|
||||
}
|
||||
|
||||
"DistanceFromHere" should {
|
||||
val vehicle = Vehicle(GlobalDefinitions.fury)
|
||||
|
||||
"create" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.DistanceFromHere(10.5f)
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
setting.Type mustEqual AutoDriveControls.State.Wait
|
||||
setting.Data mustEqual None
|
||||
setting.Delay mustEqual 200L
|
||||
}
|
||||
|
||||
"validate" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.DistanceFromHere(10.5f)
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
|
||||
vehicle.Velocity mustEqual None
|
||||
setting.Validate(vehicle) mustEqual false
|
||||
vehicle.Velocity = Vector3.Zero
|
||||
setting.Validate(vehicle) mustEqual false
|
||||
vehicle.Velocity = Vector3(1,0,0)
|
||||
setting.Validate(vehicle) mustEqual true
|
||||
}
|
||||
|
||||
"completion" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.DistanceFromHere(10.5f)
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
|
||||
vehicle.Position = Vector3(0,0,0)
|
||||
setting.CompletionTest(vehicle) mustEqual false
|
||||
vehicle.Position = Vector3(10.5f,0,0)
|
||||
setting.CompletionTest(vehicle) mustEqual false
|
||||
vehicle.Position = Vector3(11,0,0)
|
||||
setting.CompletionTest(vehicle) mustEqual true
|
||||
vehicle.Position = Vector3(0,11,0)
|
||||
setting.CompletionTest(vehicle) mustEqual true
|
||||
vehicle.Position = Vector3(0,0,11)
|
||||
setting.CompletionTest(vehicle) mustEqual false
|
||||
vehicle.Position = Vector3(7.5f,7.5f,0)
|
||||
setting.CompletionTest(vehicle) mustEqual true
|
||||
}
|
||||
}
|
||||
|
||||
"Drive" should {
|
||||
val vehicle = Vehicle(GlobalDefinitions.fury)
|
||||
|
||||
"create" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.Drive(3)
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
setting.Type mustEqual AutoDriveControls.State.Drive
|
||||
setting.Data mustEqual Some(3)
|
||||
setting.Delay mustEqual 200L
|
||||
}
|
||||
|
||||
"validate" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.Drive(3)
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
setting.Validate(vehicle) mustEqual true
|
||||
}
|
||||
|
||||
"completion" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.Drive(3)
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
vehicle.Velocity mustEqual None
|
||||
setting.CompletionTest(vehicle) mustEqual false
|
||||
|
||||
vehicle.Velocity = Vector3.Zero
|
||||
vehicle.Velocity mustEqual Some(Vector3.Zero)
|
||||
setting.CompletionTest(vehicle) mustEqual false
|
||||
|
||||
vehicle.Velocity = Vector3(1,0,0)
|
||||
vehicle.Velocity mustEqual Some(Vector3(1,0,0))
|
||||
setting.CompletionTest(vehicle) mustEqual true
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
"FirstGear" should {
|
||||
val veh_def = GlobalDefinitions.mediumtransport
|
||||
val vehicle = Vehicle(veh_def)
|
||||
|
||||
"create" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.FirstGear()
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
setting.Type mustEqual AutoDriveControls.State.Drive
|
||||
setting.Data mustEqual Some(0)
|
||||
setting.Delay mustEqual 200L
|
||||
}
|
||||
|
||||
"validate" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.FirstGear()
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
setting.Validate(vehicle) mustEqual true //always true
|
||||
}
|
||||
|
||||
"completion" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.FirstGear()
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
|
||||
vehicle.Velocity mustEqual None
|
||||
setting.CompletionTest(vehicle) mustEqual false
|
||||
vehicle.Velocity = Vector3.Zero
|
||||
setting.CompletionTest(vehicle) mustEqual false
|
||||
vehicle.Velocity = Vector3(1,0,0)
|
||||
setting.CompletionTest(vehicle) mustEqual true
|
||||
}
|
||||
|
||||
"data" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.FirstGear()
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
|
||||
setting.Data mustEqual Some(0)
|
||||
setting.Validate(vehicle)
|
||||
setting.Data mustEqual Some(veh_def.AutoPilotSpeed1)
|
||||
}
|
||||
}
|
||||
|
||||
"ForTime" should {
|
||||
val veh_def = GlobalDefinitions.mediumtransport
|
||||
val vehicle = Vehicle(veh_def)
|
||||
|
||||
"create" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.ForTime(1200L)
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
setting.Type mustEqual AutoDriveControls.State.Wait
|
||||
setting.Data mustEqual None
|
||||
setting.Delay mustEqual 200L
|
||||
}
|
||||
|
||||
"validate" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.ForTime(1200L)
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
setting.Validate(vehicle) mustEqual true //always true
|
||||
}
|
||||
|
||||
"completion" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.ForTime(1200L)
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
setting.CompletionTest(vehicle) mustEqual false
|
||||
|
||||
Thread.sleep(1100)
|
||||
setting.CompletionTest(vehicle) mustEqual false
|
||||
|
||||
Thread.sleep(200)
|
||||
setting.CompletionTest(vehicle) mustEqual true
|
||||
}
|
||||
}
|
||||
|
||||
"SecondGear" should {
|
||||
val veh_def = GlobalDefinitions.mediumtransport
|
||||
val vehicle = Vehicle(veh_def)
|
||||
|
||||
"create" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.SecondGear()
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
setting.Type mustEqual AutoDriveControls.State.Drive
|
||||
setting.Data mustEqual Some(0)
|
||||
setting.Delay mustEqual 200L
|
||||
}
|
||||
|
||||
"validate" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.SecondGear()
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
setting.Validate(vehicle) mustEqual true //always true
|
||||
}
|
||||
|
||||
"completion" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.SecondGear()
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
|
||||
vehicle.Velocity mustEqual None
|
||||
setting.CompletionTest(vehicle) mustEqual false
|
||||
vehicle.Velocity = Vector3.Zero
|
||||
setting.CompletionTest(vehicle) mustEqual false
|
||||
vehicle.Velocity = Vector3(1,0,0)
|
||||
setting.CompletionTest(vehicle) mustEqual true
|
||||
}
|
||||
|
||||
"data" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.SecondGear()
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
|
||||
setting.Data mustEqual Some(0)
|
||||
setting.Validate(vehicle)
|
||||
setting.Data mustEqual Some(veh_def.AutoPilotSpeed2)
|
||||
}
|
||||
}
|
||||
|
||||
"Stop" should {
|
||||
val vehicle = Vehicle(GlobalDefinitions.mediumtransport)
|
||||
|
||||
"create" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.Stop()
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
setting.Type mustEqual AutoDriveControls.State.Stop
|
||||
setting.Data mustEqual None
|
||||
setting.Delay mustEqual 200L
|
||||
}
|
||||
|
||||
"validate" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.Stop()
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
setting.Validate(vehicle) mustEqual true //always true
|
||||
}
|
||||
|
||||
"completion" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.Stop()
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
setting.CompletionTest(vehicle) mustEqual true //always true
|
||||
}
|
||||
}
|
||||
|
||||
"TurnBy" should {
|
||||
"create" in {
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.TurnBy(35.5f, 23)
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
setting.Type mustEqual AutoDriveControls.State.Turn
|
||||
setting.Data mustEqual Some(23)
|
||||
setting.Delay mustEqual 100L
|
||||
}
|
||||
|
||||
"validate (velocity)" in {
|
||||
val vehicle = Vehicle(GlobalDefinitions.mediumtransport)
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.TurnBy(35.5f, 23)
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
|
||||
vehicle.Velocity mustEqual None
|
||||
setting.Validate(vehicle) mustEqual false
|
||||
vehicle.Velocity = Vector3(1,1,1)
|
||||
setting.Validate(vehicle) mustEqual true
|
||||
}
|
||||
|
||||
"validate (wheel direction = 15)" in {
|
||||
val vehicle = Vehicle(GlobalDefinitions.mediumtransport)
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.TurnBy(35.5f, 15)
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
|
||||
vehicle.Velocity = Vector3(1,1,1)
|
||||
setting.Validate(vehicle) mustEqual false
|
||||
}
|
||||
|
||||
"completion (passing 35.5-up)" in {
|
||||
val vehicle = Vehicle(GlobalDefinitions.mediumtransport)
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.TurnBy(35.5f, 25)
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
|
||||
vehicle.Orientation mustEqual Vector3.Zero
|
||||
setting.CompletionTest(vehicle) mustEqual false
|
||||
vehicle.Orientation = Vector3(0,0,34.5f)
|
||||
setting.CompletionTest(vehicle) mustEqual false
|
||||
vehicle.Orientation = Vector3(0,0,35f)
|
||||
setting.CompletionTest(vehicle) mustEqual false
|
||||
vehicle.Orientation = Vector3(0,0,36.0f)
|
||||
setting.CompletionTest(vehicle) mustEqual true
|
||||
}
|
||||
|
||||
"completion (passing 35.5 down)" in {
|
||||
val vehicle = Vehicle(GlobalDefinitions.mediumtransport)
|
||||
val config : AutoDriveControls.Configuration = AutoDriveControls.TurnBy(-35.5f, 25)
|
||||
val setting : AutoDriveControls.Setting = config.Create
|
||||
|
||||
vehicle.Orientation = Vector3(0,0,40f)
|
||||
setting.CompletionTest(vehicle) mustEqual false
|
||||
vehicle.Orientation = Vector3(0,0,5f)
|
||||
setting.CompletionTest(vehicle) mustEqual false
|
||||
vehicle.Orientation = Vector3(0,0,4f)
|
||||
setting.CompletionTest(vehicle) mustEqual true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GuidedControlTest1 extends ActorTest {
|
||||
"VehicleSpawnControlGuided" should {
|
||||
"unguided" in {
|
||||
val vehicle = Vehicle(GlobalDefinitions.mediumtransport)
|
||||
vehicle.GUID = PlanetSideGUID(1)
|
||||
val driver = Player(Avatar("", PlanetSideEmpire.TR, CharacterGender.Male, 0,0))
|
||||
driver.VehicleSeated = vehicle.GUID
|
||||
val sendTo = TestProbe()
|
||||
val order = VehicleSpawnControl.Order(driver, vehicle, sendTo.ref)
|
||||
val pad = VehicleSpawnPad(GlobalDefinitions.spawn_pad)
|
||||
pad.GUID = PlanetSideGUID(1)
|
||||
pad.Railed = false //suppress certain events
|
||||
val guided = system.actorOf(Props(classOf[VehicleSpawnControlGuided], pad), "pad")
|
||||
|
||||
guided ! VehicleSpawnControl.Process.StartGuided(order)
|
||||
val msg = sendTo.receiveOne(100 milliseconds)
|
||||
assert(msg.isInstanceOf[VehicleSpawnPad.ServerVehicleOverrideEnd])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GuidedControlTest2 extends ActorTest {
|
||||
"VehicleSpawnControlGuided" should {
|
||||
"guided (one)" in {
|
||||
val vehicle = Vehicle(GlobalDefinitions.mediumtransport)
|
||||
vehicle.GUID = PlanetSideGUID(1)
|
||||
vehicle.Velocity = Vector3(1,1,1)
|
||||
val driver = Player(Avatar("", PlanetSideEmpire.TR, CharacterGender.Male, 0,0))
|
||||
driver.VehicleSeated = vehicle.GUID
|
||||
val sendTo = TestProbe()
|
||||
val order = VehicleSpawnControl.Order(driver, vehicle, sendTo.ref)
|
||||
val pad = VehicleSpawnPad(GlobalDefinitions.spawn_pad)
|
||||
pad.Railed = false //suppress certain events
|
||||
val guided = system.actorOf(Props(classOf[VehicleSpawnControlGuided], pad), "pad")
|
||||
|
||||
pad.Guide = List(AutoDriveControls.FirstGear())
|
||||
guided ! VehicleSpawnControl.Process.StartGuided(order)
|
||||
val msg1 = sendTo.receiveOne(100 milliseconds)
|
||||
assert(msg1.isInstanceOf[VehicleSpawnControlGuided.GuidedControl])
|
||||
assert(msg1.asInstanceOf[VehicleSpawnControlGuided.GuidedControl].command == AutoDriveControls.State.Drive)
|
||||
val msg2 = sendTo.receiveOne(200 milliseconds)
|
||||
assert(msg2.isInstanceOf[VehicleSpawnPad.ServerVehicleOverrideEnd])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GuidedControlTest3 extends ActorTest {
|
||||
"VehicleSpawnControlGuided" should {
|
||||
"guided (three)" in {
|
||||
val vehicle = Vehicle(GlobalDefinitions.mediumtransport)
|
||||
vehicle.GUID = PlanetSideGUID(1)
|
||||
vehicle.Velocity = Vector3(1,1,1)
|
||||
val driver = Player(Avatar("", PlanetSideEmpire.TR, CharacterGender.Male, 0,0))
|
||||
driver.VehicleSeated = vehicle.GUID
|
||||
val sendTo = TestProbe()
|
||||
val order = VehicleSpawnControl.Order(driver, vehicle, sendTo.ref)
|
||||
val pad = VehicleSpawnPad(GlobalDefinitions.spawn_pad)
|
||||
pad.Railed = false //suppress certain events
|
||||
val guided = system.actorOf(Props(classOf[VehicleSpawnControlGuided], pad), "pad")
|
||||
|
||||
pad.Guide = List(
|
||||
AutoDriveControls.FirstGear(),
|
||||
AutoDriveControls.ForTime(1000L),
|
||||
AutoDriveControls.SecondGear()
|
||||
)
|
||||
guided ! VehicleSpawnControl.Process.StartGuided(order)
|
||||
val msg1 = sendTo.receiveOne(100 milliseconds)
|
||||
assert(msg1.isInstanceOf[VehicleSpawnControlGuided.GuidedControl])
|
||||
assert(msg1.asInstanceOf[VehicleSpawnControlGuided.GuidedControl].command == AutoDriveControls.State.Drive)
|
||||
val msg2 = sendTo.receiveOne(100 milliseconds)
|
||||
assert(msg2.isInstanceOf[VehicleSpawnControlGuided.GuidedControl])
|
||||
assert(msg2.asInstanceOf[VehicleSpawnControlGuided.GuidedControl].command == AutoDriveControls.State.Wait)
|
||||
sendTo.expectNoMsg(1000 milliseconds)
|
||||
val msg3 = sendTo.receiveOne(100 milliseconds)
|
||||
assert(msg3.isInstanceOf[VehicleSpawnControlGuided.GuidedControl])
|
||||
assert(msg3.asInstanceOf[VehicleSpawnControlGuided.GuidedControl].command == AutoDriveControls.State.Drive)
|
||||
val msg4 = sendTo.receiveOne(200 milliseconds)
|
||||
assert(msg4.isInstanceOf[VehicleSpawnPad.ServerVehicleOverrideEnd])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GuidedControlTest4 extends ActorTest {
|
||||
"VehicleSpawnControlGuided" should {
|
||||
"fail validation test" in {
|
||||
def validationFailure(vehicle : Vehicle) : Boolean = false
|
||||
|
||||
val vehicle = Vehicle(GlobalDefinitions.mediumtransport)
|
||||
vehicle.GUID = PlanetSideGUID(1)
|
||||
vehicle.Velocity = Vector3(1,1,1)
|
||||
val driver = Player(Avatar("", PlanetSideEmpire.TR, CharacterGender.Male, 0,0))
|
||||
driver.VehicleSeated = vehicle.GUID
|
||||
val sendTo = TestProbe()
|
||||
val order = VehicleSpawnControl.Order(driver, vehicle, sendTo.ref)
|
||||
val pad = VehicleSpawnPad(GlobalDefinitions.spawn_pad)
|
||||
pad.Railed = false //suppress certain events
|
||||
val guided = system.actorOf(Props(classOf[VehicleSpawnControlGuided], pad), "pad")
|
||||
|
||||
pad.Guide = List(
|
||||
AutoDriveControls.FirstGear(),
|
||||
AutoDriveControls.CancelEarly(validationFailure),
|
||||
AutoDriveControls.SecondGear()
|
||||
)
|
||||
guided ! VehicleSpawnControl.Process.StartGuided(order)
|
||||
val msg1 = sendTo.receiveOne(100 milliseconds)
|
||||
assert(msg1.isInstanceOf[VehicleSpawnControlGuided.GuidedControl])
|
||||
assert(msg1.asInstanceOf[VehicleSpawnControlGuided.GuidedControl].command == AutoDriveControls.State.Drive)
|
||||
val msg2 = sendTo.receiveOne(200 milliseconds)
|
||||
assert(msg2.isInstanceOf[VehicleSpawnPad.ServerVehicleOverrideEnd])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -85,7 +85,7 @@ class VehicleSpawnControl2aTest extends ActorTest() {
|
|||
val probe1Msg3 = probe1.receiveOne(3 seconds)
|
||||
assert(probe1Msg3.isInstanceOf[VehicleSpawnPad.PlayerSeatedInVehicle])
|
||||
|
||||
val probe3Msg4 = probe3.receiveOne(200 milliseconds)
|
||||
val probe3Msg4 = probe3.receiveOne(1 seconds)
|
||||
assert(probe3Msg4.isInstanceOf[VehicleSpawnPad.DetachFromRails])
|
||||
|
||||
val probe1Msg4 = probe1.receiveOne(1 seconds)
|
||||
|
|
@ -93,20 +93,20 @@ class VehicleSpawnControl2aTest extends ActorTest() {
|
|||
val probe1Msg5 = probe1.receiveOne(4 seconds)
|
||||
assert(probe1Msg5.isInstanceOf[VehicleSpawnPad.ServerVehicleOverrideEnd])
|
||||
|
||||
val probe1Msg6 = probe1.receiveOne(10 seconds)
|
||||
val probe1Msg6 = probe1.receiveOne(11 seconds)
|
||||
assert(probe1Msg6.isInstanceOf[VehicleSpawnPad.PeriodicReminder])
|
||||
assert(probe1Msg6.asInstanceOf[VehicleSpawnPad.PeriodicReminder].reason == VehicleSpawnPad.Reminders.Blocked)
|
||||
val probe2Msg2 = probe2.receiveOne(100 milliseconds)
|
||||
assert(probe2Msg2.isInstanceOf[VehicleSpawnPad.PeriodicReminder])
|
||||
assert(probe2Msg2.asInstanceOf[VehicleSpawnPad.PeriodicReminder].reason == VehicleSpawnPad.Reminders.Blocked)
|
||||
|
||||
//if we move the vehicle more than 10m away from the pad, we should receive a ResetSpawnPad, and a second ConcealPlayer message
|
||||
//if we move the vehicle more than 25m away from the pad, we should receive a ResetSpawnPad, and a second ConcealPlayer message
|
||||
//that means that the first order has cleared and the spawn pad is now working on the second order successfully
|
||||
vehicle.Position = Vector3(0,0,11)
|
||||
vehicle.Position = Vector3(11,0,0)
|
||||
player.VehicleSeated = None //since shared between orders, is necessary
|
||||
val probe3Msg5 = probe3.receiveOne(4 seconds)
|
||||
assert(probe3Msg5.isInstanceOf[VehicleSpawnPad.ResetSpawnPad])
|
||||
val probe3Msg6 = probe3.receiveOne(4 seconds)
|
||||
val probe3Msg6 = probe3.receiveOne(5 seconds)
|
||||
assert(probe3Msg6.isInstanceOf[VehicleSpawnPad.ConcealPlayer])
|
||||
}
|
||||
}
|
||||
|
|
@ -147,15 +147,12 @@ class VehicleSpawnControl2bTest extends ActorTest() {
|
|||
val probe1Msg3 = probe1.receiveOne(3 seconds)
|
||||
assert(probe1Msg3.isInstanceOf[VehicleSpawnPad.PlayerSeatedInVehicle])
|
||||
|
||||
val probe3Msg4 = probe3.receiveOne(200 milliseconds)
|
||||
assert(probe3Msg4.isInstanceOf[VehicleSpawnPad.DetachFromRails])
|
||||
|
||||
val probe1Msg4 = probe1.receiveOne(1 seconds)
|
||||
assert(probe1Msg4.isInstanceOf[VehicleSpawnPad.ServerVehicleOverrideStart])
|
||||
val probe1Msg5 = probe1.receiveOne(4 seconds)
|
||||
assert(probe1Msg5.isInstanceOf[VehicleSpawnPad.ServerVehicleOverrideEnd])
|
||||
|
||||
val probe1Msg6 = probe1.receiveOne(10 seconds)
|
||||
val probe1Msg6 = probe1.receiveOne(11 seconds)
|
||||
assert(probe1Msg6.isInstanceOf[VehicleSpawnPad.PeriodicReminder])
|
||||
assert(probe1Msg6.asInstanceOf[VehicleSpawnPad.PeriodicReminder].reason == VehicleSpawnPad.Reminders.Blocked)
|
||||
val probe2Msg2 = probe2.receiveOne(100 milliseconds)
|
||||
|
|
@ -164,7 +161,7 @@ class VehicleSpawnControl2bTest extends ActorTest() {
|
|||
|
||||
//if we move the vehicle more than 10m away from the pad, we should receive a second ConcealPlayer message
|
||||
//that means that the first order has cleared and the spawn pad is now working on the second order successfully
|
||||
vehicle.Position = Vector3(0,0,11)
|
||||
vehicle.Position = Vector3(11,0,0)
|
||||
player.VehicleSeated = None //since shared between orders, is necessary
|
||||
val probe3Msg6 = probe3.receiveOne(4 seconds)
|
||||
assert(probe3Msg6.isInstanceOf[VehicleSpawnPad.ConcealPlayer])
|
||||
|
|
@ -215,35 +212,35 @@ class VehicleSpawnControl4Test extends ActorTest() {
|
|||
}
|
||||
}
|
||||
|
||||
class VehicleSpawnControl5aTest extends ActorTest() {
|
||||
"VehicleSpawnControl" should {
|
||||
"the vehicle is destroyed before being fully loaded; the vehicle is cleaned up" in {
|
||||
val (vehicle, player, pad, zone) = VehicleSpawnPadControlTest.SetUpAgents(PlanetSideEmpire.TR)
|
||||
//we can recycle the vehicle and the player for each order
|
||||
val probe1 = new TestProbe(system, "first-order")
|
||||
val probe3 = new TestProbe(system, "zone-events")
|
||||
zone.VehicleEvents = probe3.ref
|
||||
//class VehicleSpawnControl5aTest extends ActorTest() {
|
||||
// "VehicleSpawnControl" should {
|
||||
// "the vehicle is destroyed before being fully loaded; the vehicle is cleaned up" in {
|
||||
// val (vehicle, player, pad, zone) = VehicleSpawnPadControlTest.SetUpAgents(PlanetSideEmpire.TR)
|
||||
// //we can recycle the vehicle and the player for each order
|
||||
// val probe1 = new TestProbe(system, "first-order")
|
||||
// val probe3 = new TestProbe(system, "zone-events")
|
||||
// zone.VehicleEvents = probe3.ref
|
||||
//
|
||||
// pad.Actor.tell(VehicleSpawnPad.VehicleOrder(player, vehicle), probe1.ref)
|
||||
//
|
||||
// val probe3Msg1 = probe3.receiveOne(3 seconds)
|
||||
// assert(probe3Msg1.isInstanceOf[VehicleSpawnPad.ConcealPlayer])
|
||||
//
|
||||
// val probe3Msg2 = probe3.receiveOne(3 seconds)
|
||||
// assert(probe3Msg2.isInstanceOf[VehicleSpawnPad.LoadVehicle])
|
||||
// vehicle.Health = 0 //problem
|
||||
//
|
||||
// val probe3Msg3 = probe3.receiveOne(3 seconds)
|
||||
// assert(probe3Msg3.isInstanceOf[VehicleSpawnPad.DisposeVehicle])
|
||||
// val probe3Msg4 = probe3.receiveOne(100 milliseconds)
|
||||
// assert(probe3Msg4.isInstanceOf[VehicleSpawnPad.RevealPlayer])
|
||||
// //note: the vehicle will not be unregistered by this logic alone
|
||||
// //since LoadVehicle should introduce it into the game world properly, it has to be handled properly
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
pad.Actor.tell(VehicleSpawnPad.VehicleOrder(player, vehicle), probe1.ref)
|
||||
|
||||
val probe3Msg1 = probe3.receiveOne(3 seconds)
|
||||
assert(probe3Msg1.isInstanceOf[VehicleSpawnPad.ConcealPlayer])
|
||||
|
||||
val probe3Msg2 = probe3.receiveOne(3 seconds)
|
||||
assert(probe3Msg2.isInstanceOf[VehicleSpawnPad.LoadVehicle])
|
||||
vehicle.Health = 0 //problem
|
||||
|
||||
val probe3Msg3 = probe3.receiveOne(3 seconds)
|
||||
assert(probe3Msg3.isInstanceOf[VehicleSpawnPad.DisposeVehicle])
|
||||
val probe3Msg4 = probe3.receiveOne(100 milliseconds)
|
||||
assert(probe3Msg4.isInstanceOf[VehicleSpawnPad.RevealPlayer])
|
||||
//note: the vehicle will not be unregistered by this logic alone
|
||||
//since LoadVehicle should introduce it into the game world properly, it has to be handled properly
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class VehicleSpawnControl5bTest extends ActorTest() {
|
||||
class VehicleSpawnControl5Test extends ActorTest() {
|
||||
"VehicleSpawnControl" should {
|
||||
"player dies right after vehicle partially loads; the vehicle spawns and blocks the pad" in {
|
||||
val (vehicle, player, pad, zone) = VehicleSpawnPadControlTest.SetUpAgents(PlanetSideEmpire.TR)
|
||||
|
|
@ -266,91 +263,14 @@ class VehicleSpawnControl5bTest extends ActorTest() {
|
|||
val probe3Msg4 = probe3.receiveOne(3 seconds)
|
||||
assert(probe3Msg4.isInstanceOf[VehicleSpawnPad.DetachFromRails])
|
||||
|
||||
val probe1Msg = probe1.receiveOne(10 seconds)
|
||||
val probe1Msg = probe1.receiveOne(12 seconds)
|
||||
assert(probe1Msg.isInstanceOf[VehicleSpawnPad.PeriodicReminder])
|
||||
assert(probe1Msg.asInstanceOf[VehicleSpawnPad.PeriodicReminder].reason == VehicleSpawnPad.Reminders.Blocked)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class VehicleSpawnControl6aTest extends ActorTest() {
|
||||
"VehicleSpawnControl" should {
|
||||
"the vehicle is destroyed while the player is sitting down; the vehicle is cleaned up" in {
|
||||
val (vehicle, player, pad, zone) = VehicleSpawnPadControlTest.SetUpAgents(PlanetSideEmpire.TR)
|
||||
//we can recycle the vehicle and the player for each order
|
||||
val probe1 = new TestProbe(system, "first-order")
|
||||
val probe3 = new TestProbe(system, "zone-events")
|
||||
zone.VehicleEvents = probe3.ref
|
||||
|
||||
pad.Actor.tell(VehicleSpawnPad.VehicleOrder(player, vehicle), probe1.ref)
|
||||
|
||||
val probe3Msg1 = probe3.receiveOne(3 seconds)
|
||||
assert(probe3Msg1.isInstanceOf[VehicleSpawnPad.ConcealPlayer])
|
||||
|
||||
val probe3Msg2 = probe3.receiveOne(3 seconds)
|
||||
assert(probe3Msg2.isInstanceOf[VehicleSpawnPad.LoadVehicle])
|
||||
|
||||
val probe3Msg3 = probe3.receiveOne(3 seconds)
|
||||
assert(probe3Msg3.isInstanceOf[VehicleSpawnPad.AttachToRails])
|
||||
|
||||
val probe1Msg1 = probe1.receiveOne(200 milliseconds)
|
||||
assert(probe1Msg1.isInstanceOf[VehicleSpawnPad.StartPlayerSeatedInVehicle])
|
||||
vehicle.Health = 0 //problem
|
||||
|
||||
val probe3Msg5 = probe3.receiveOne(4 seconds)
|
||||
assert(probe3Msg5.isInstanceOf[VehicleSpawnPad.ResetSpawnPad])
|
||||
val probe3Msg6 = probe3.receiveOne(100 milliseconds)
|
||||
assert(probe3Msg6.isInstanceOf[VehicleSpawnPad.DisposeVehicle])
|
||||
val probe3Msg7 = probe3.receiveOne(100 milliseconds)
|
||||
assert(probe3Msg7.isInstanceOf[VehicleSpawnPad.RevealPlayer])
|
||||
//note: the vehicle will not be unregistered by this logic alone
|
||||
//since LoadVehicle should introduce it into the game world properly, it has to be handled properly
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO test was poor; attempting to check the "if(vehicle.Health ..." cases in VehicleSpawnControlSeatDriver
|
||||
//class VehicleSpawnControl6bTest extends ActorTest() {
|
||||
// "VehicleSpawnControl" should {
|
||||
// "player on wrong continent; the vehicle is then destroyed after being partially spawned, but is cleaned up" in {
|
||||
// val (vehicle, player, pad, zone) = VehicleSpawnPadControlTest.SetUpAgents(PlanetSideEmpire.TR)
|
||||
// //we can recycle the vehicle and the player for each order
|
||||
// val probe1 = new TestProbe(system, "first-order")
|
||||
// val probe3 = new TestProbe(system, "zone-events")
|
||||
// zone.VehicleEvents = probe3.ref
|
||||
//
|
||||
// pad.Actor.tell(VehicleSpawnPad.VehicleOrder(player, vehicle), probe1.ref)
|
||||
//
|
||||
// val probe3Msg1 = probe3.receiveOne(3 seconds)
|
||||
// assert(probe3Msg1.isInstanceOf[VehicleSpawnPad.ConcealPlayer])
|
||||
//
|
||||
// val probe3Msg2 = probe3.receiveOne(3 seconds)
|
||||
// assert(probe3Msg2.isInstanceOf[VehicleSpawnPad.LoadVehicle])
|
||||
//
|
||||
// val probe3Msg3 = probe3.receiveOne(3 seconds)
|
||||
// assert(probe3Msg3.isInstanceOf[VehicleSpawnPad.AttachToRails])
|
||||
//
|
||||
// val probe1Msg1 = probe1.receiveOne(200 milliseconds)
|
||||
// assert(probe1Msg1.isInstanceOf[VehicleSpawnPad.StartPlayerSeatedInVehicle])
|
||||
// player.Continent = "problem" //problem 1
|
||||
//
|
||||
// vehicle.Health = 0 //problem 2
|
||||
// val probe3Msg3b = probe3.receiveOne(3 seconds)
|
||||
// assert(probe3Msg3b.isInstanceOf[VehicleSpawnPad.DetachFromRails])
|
||||
//
|
||||
// val probe3Msg4 = probe3.receiveOne(3 seconds)
|
||||
// assert(probe3Msg4.isInstanceOf[VehicleSpawnPad.ResetSpawnPad])
|
||||
// val probe3Msg5 = probe3.receiveOne(1 seconds)
|
||||
// assert(probe3Msg5.isInstanceOf[VehicleSpawnPad.DisposeVehicle])
|
||||
// val probe3Msg6 = probe3.receiveOne(1 seconds)
|
||||
// assert(probe3Msg6.isInstanceOf[VehicleSpawnPad.RevealPlayer])
|
||||
// //note: the vehicle will not be unregistered by this logic alone
|
||||
// //since LoadVehicle should introduce it into the game world properly, it has to be handled properly
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
class VehicleSpawnControl6cTest extends ActorTest() {
|
||||
class VehicleSpawnControl6Test extends ActorTest() {
|
||||
"VehicleSpawnControl" should {
|
||||
"the player can not sit in vehicle; vehicle spawns and blocks the pad" in {
|
||||
val (vehicle, player, pad, zone) = VehicleSpawnPadControlTest.SetUpAgents(PlanetSideEmpire.TR)
|
||||
|
|
@ -380,57 +300,14 @@ class VehicleSpawnControl6cTest extends ActorTest() {
|
|||
val probe3Msg5 = probe3.receiveOne(3 seconds)
|
||||
assert(probe3Msg5.isInstanceOf[VehicleSpawnPad.ResetSpawnPad])
|
||||
|
||||
val probe1Msg2 = probe1.receiveOne(10 seconds)
|
||||
val probe1Msg2 = probe1.receiveOne(12 seconds)
|
||||
assert(probe1Msg2.isInstanceOf[VehicleSpawnPad.PeriodicReminder])
|
||||
assert(probe1Msg2.asInstanceOf[VehicleSpawnPad.PeriodicReminder].reason == VehicleSpawnPad.Reminders.Blocked)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class VehicleSpawnControl7aTest extends ActorTest() {
|
||||
"VehicleSpawnControl" should {
|
||||
"the vehicle is destroyed while attached to the rails; it is cleaned up" in {
|
||||
val (vehicle, player, pad, zone) = VehicleSpawnPadControlTest.SetUpAgents(PlanetSideEmpire.TR)
|
||||
//we can recycle the vehicle and the player for each order
|
||||
val probe1 = new TestProbe(system, "first-order")
|
||||
val probe3 = new TestProbe(system, "zone-events")
|
||||
zone.VehicleEvents = probe3.ref
|
||||
|
||||
pad.Actor.tell(VehicleSpawnPad.VehicleOrder(player, vehicle), probe1.ref)
|
||||
|
||||
val probe3Msg1 = probe3.receiveOne(3 seconds)
|
||||
assert(probe3Msg1.isInstanceOf[VehicleSpawnPad.ConcealPlayer])
|
||||
|
||||
val probe3Msg2 = probe3.receiveOne(3 seconds)
|
||||
assert(probe3Msg2.isInstanceOf[VehicleSpawnPad.LoadVehicle])
|
||||
|
||||
val probe3Msg3 = probe3.receiveOne(3 seconds)
|
||||
assert(probe3Msg3.isInstanceOf[VehicleSpawnPad.AttachToRails])
|
||||
|
||||
val probe1Msg1 = probe1.receiveOne(200 milliseconds)
|
||||
assert(probe1Msg1.isInstanceOf[VehicleSpawnPad.StartPlayerSeatedInVehicle])
|
||||
val probe1Msg2 = probe1.receiveOne(200 milliseconds)
|
||||
assert(probe1Msg2.isInstanceOf[Mountable.MountMessages])
|
||||
val probe1Msg2Contents = probe1Msg2.asInstanceOf[Mountable.MountMessages]
|
||||
assert(probe1Msg2Contents.response.isInstanceOf[Mountable.CanMount])
|
||||
val probe1Msg3 = probe1.receiveOne(3 seconds)
|
||||
assert(probe1Msg3.isInstanceOf[VehicleSpawnPad.PlayerSeatedInVehicle])
|
||||
vehicle.Health = 0 //problem
|
||||
|
||||
val probe3Msg4 = probe3.receiveOne(200 milliseconds)
|
||||
assert(probe3Msg4.isInstanceOf[VehicleSpawnPad.DetachFromRails])
|
||||
val probe3Msg5 = probe3.receiveOne(200 milliseconds)
|
||||
assert(probe3Msg5.isInstanceOf[VehicleSpawnPad.ResetSpawnPad])
|
||||
|
||||
probe1.receiveOne(200 milliseconds) //Mountable.MountMessage
|
||||
val probe1Msg4 = probe1.receiveOne(10 seconds)
|
||||
assert(probe1Msg4.isInstanceOf[VehicleSpawnPad.PeriodicReminder])
|
||||
assert(probe1Msg4.asInstanceOf[VehicleSpawnPad.PeriodicReminder].reason == VehicleSpawnPad.Reminders.Blocked)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class VehicleSpawnControl7bTest extends ActorTest() {
|
||||
class VehicleSpawnControl7Test extends ActorTest() {
|
||||
"VehicleSpawnControl" should {
|
||||
"player dies after getting in driver seat; the vehicle blocks the pad" in {
|
||||
val (vehicle, player, pad, zone) = VehicleSpawnPadControlTest.SetUpAgents(PlanetSideEmpire.TR)
|
||||
|
|
@ -465,7 +342,7 @@ class VehicleSpawnControl7bTest extends ActorTest() {
|
|||
val probe3Msg5 = probe3.receiveOne(100 milliseconds)
|
||||
assert(probe3Msg5.isInstanceOf[VehicleSpawnPad.ResetSpawnPad])
|
||||
|
||||
val probe1Msg4 = probe1.receiveOne(10 seconds)
|
||||
val probe1Msg4 = probe1.receiveOne(12 seconds)
|
||||
assert(probe1Msg4.isInstanceOf[VehicleSpawnPad.PeriodicReminder])
|
||||
assert(probe1Msg4.asInstanceOf[VehicleSpawnPad.PeriodicReminder].reason == VehicleSpawnPad.Reminders.Blocked)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue