more testing work
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
4aed133a97
commit
d0e5f3b7d2
@ -1,3 +1,3 @@
|
|||||||
#maven.buildNumber.plugin properties file
|
#maven.buildNumber.plugin properties file
|
||||||
#Thu Aug 22 17:01:13 EDT 2024
|
#Thu Aug 22 19:29:58 EDT 2024
|
||||||
buildNumber=287
|
buildNumber=288
|
||||||
|
|||||||
@ -109,7 +109,7 @@ public class ImGuiEntityMacros {
|
|||||||
clientEntityDetailWindow.setCallback(new ImGuiWindowCallback() {
|
clientEntityDetailWindow.setCallback(new ImGuiWindowCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void exec() {
|
public void exec() {
|
||||||
ImGui.sameLine();
|
ImGui.text("Current ID: " + detailViewEntity.getId());
|
||||||
if(ImGui.treeNode("Views")){
|
if(ImGui.treeNode("Views")){
|
||||||
if(EntityUtils.getActor(detailViewEntity) != null && ImGui.checkbox("Actor Details", showActorTab)){
|
if(EntityUtils.getActor(detailViewEntity) != null && ImGui.checkbox("Actor Details", showActorTab)){
|
||||||
showActorTab = !showActorTab;
|
showActorTab = !showActorTab;
|
||||||
|
|||||||
@ -0,0 +1,139 @@
|
|||||||
|
package electrosphere.entity.state.equip;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.joml.Vector3d;
|
||||||
|
|
||||||
|
import annotations.IntegrationTest;
|
||||||
|
import electrosphere.engine.Globals;
|
||||||
|
import electrosphere.entity.Entity;
|
||||||
|
import electrosphere.entity.EntityTags;
|
||||||
|
import electrosphere.entity.state.inventory.InventoryUtils;
|
||||||
|
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
|
||||||
|
import electrosphere.entity.types.attach.AttachUtils;
|
||||||
|
import electrosphere.entity.types.creature.CreatureTemplate;
|
||||||
|
import electrosphere.entity.types.creature.CreatureUtils;
|
||||||
|
import electrosphere.entity.types.item.ItemUtils;
|
||||||
|
import template.EntityTestTemplate;
|
||||||
|
import testutils.TestEngineUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for client side equip state
|
||||||
|
*/
|
||||||
|
public class ClientEquipStateTests extends EntityTestTemplate {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make sure server notifies client if ANY item is equipped
|
||||||
|
*/
|
||||||
|
@IntegrationTest
|
||||||
|
public void testEquipItem(){
|
||||||
|
//warm up engine
|
||||||
|
TestEngineUtils.simulateFrames(1);
|
||||||
|
|
||||||
|
//spawn entities
|
||||||
|
CreatureTemplate creatureTemplate = CreatureTemplate.createDefault("human");
|
||||||
|
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", creatureTemplate);
|
||||||
|
Entity katana = ItemUtils.serverSpawnBasicItem(Globals.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
||||||
|
|
||||||
|
//wait for entities to propagate to client
|
||||||
|
TestEngineUtils.simulateFrames(5);
|
||||||
|
|
||||||
|
//verify the client got the extra entities
|
||||||
|
Set<Entity> clientSideCreatures = Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.CREATURE);
|
||||||
|
assertEquals(2, clientSideCreatures.size());
|
||||||
|
Set<Entity> clientSideItems = Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
||||||
|
assertEquals(1, clientSideItems.size());
|
||||||
|
|
||||||
|
//equip
|
||||||
|
Entity inInventoryItem = InventoryUtils.serverAttemptStoreItem(creature, katana);
|
||||||
|
ServerEquipState serverEquipState = ServerEquipState.getServerEquipState(creature);
|
||||||
|
serverEquipState.commandAttemptEquip(inInventoryItem, serverEquipState.getEquipPoint("handsCombined"));
|
||||||
|
|
||||||
|
//propagate to client
|
||||||
|
TestEngineUtils.simulateFrames(2);
|
||||||
|
|
||||||
|
//verify we still have everything
|
||||||
|
clientSideCreatures = Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.CREATURE);
|
||||||
|
assertEquals(2, clientSideCreatures.size());
|
||||||
|
clientSideItems = Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
||||||
|
assertEquals(1, clientSideItems.size());
|
||||||
|
|
||||||
|
//grab the item in particular
|
||||||
|
Entity child = clientSideItems.iterator().next();
|
||||||
|
|
||||||
|
//
|
||||||
|
//verify was equipped
|
||||||
|
assertTrue(ItemUtils.isItem(child));
|
||||||
|
assertTrue(ItemUtils.isWeapon(child));
|
||||||
|
assertNotNull(AttachUtils.getParent(child));
|
||||||
|
Entity parentOfChild = AttachUtils.getParent(child);
|
||||||
|
assertTrue(CreatureUtils.isCreature(parentOfChild));
|
||||||
|
assertNotNull(AttachUtils.getChildrenList(parentOfChild));
|
||||||
|
assertEquals(1, AttachUtils.getChildrenList(parentOfChild).size());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try requesting that an item is equipped from the client
|
||||||
|
*/
|
||||||
|
@IntegrationTest
|
||||||
|
public void testPlayerRequestEquip(){
|
||||||
|
//warm up engine
|
||||||
|
TestEngineUtils.simulateFrames(1);
|
||||||
|
|
||||||
|
//spawn entities
|
||||||
|
ItemUtils.serverSpawnBasicItem(Globals.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
||||||
|
|
||||||
|
//wait for entities to propagate to client
|
||||||
|
TestEngineUtils.simulateFrames(5);
|
||||||
|
|
||||||
|
//verify the client got the extra entities
|
||||||
|
Set<Entity> clientSideCreatures = Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.CREATURE);
|
||||||
|
assertEquals(1, clientSideCreatures.size());
|
||||||
|
Set<Entity> clientSideItems = Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
||||||
|
assertEquals(1, clientSideItems.size());
|
||||||
|
|
||||||
|
//try to store item in inventory
|
||||||
|
Entity katanaOnClient = clientSideItems.iterator().next();
|
||||||
|
InventoryUtils.clientAttemptStoreItem(Globals.playerEntity, katanaOnClient);
|
||||||
|
|
||||||
|
//wait for server to perform transform
|
||||||
|
TestEngineUtils.simulateFrames(5);
|
||||||
|
|
||||||
|
//try equipping
|
||||||
|
UnrelationalInventoryState inventory = InventoryUtils.getNaturalInventory(Globals.playerEntity);
|
||||||
|
Entity inInventoryItem = inventory.getItems().get(0);
|
||||||
|
ClientEquipState clientEquipState = ClientEquipState.getClientEquipState(Globals.playerEntity);
|
||||||
|
clientEquipState.commandAttemptEquip(inInventoryItem, clientEquipState.getEquipPoint("handsCombined"));
|
||||||
|
|
||||||
|
//propagate to client
|
||||||
|
TestEngineUtils.simulateFrames(5);
|
||||||
|
|
||||||
|
//verify we still have everything
|
||||||
|
clientSideCreatures = Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.CREATURE);
|
||||||
|
assertEquals(1, clientSideCreatures.size());
|
||||||
|
clientSideItems = Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
||||||
|
assertEquals(2, clientSideItems.size());
|
||||||
|
|
||||||
|
//verify the equip state thinks it has something equipped
|
||||||
|
assertEquals(1,clientEquipState.getEquippedPoints().size());
|
||||||
|
|
||||||
|
//grab the item in particular
|
||||||
|
Entity child = clientEquipState.getEquippedItemAtPoint("handsCombined");
|
||||||
|
|
||||||
|
//
|
||||||
|
//verify was equipped
|
||||||
|
assertTrue(ItemUtils.isItem(child));
|
||||||
|
assertTrue(ItemUtils.isWeapon(child));
|
||||||
|
assertNotNull(AttachUtils.getParent(child));
|
||||||
|
Entity parentOfChild = AttachUtils.getParent(child);
|
||||||
|
assertNotNull(AttachUtils.getChildrenList(parentOfChild));
|
||||||
|
assertEquals(1, AttachUtils.getChildrenList(parentOfChild).size());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -24,8 +24,11 @@ import testutils.TestEngineUtils;
|
|||||||
*/
|
*/
|
||||||
public class ServerEquipStateTests extends EntityTestTemplate {
|
public class ServerEquipStateTests extends EntityTestTemplate {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try equipping an item
|
||||||
|
*/
|
||||||
@IntegrationTest
|
@IntegrationTest
|
||||||
public void spawningWithEquippedItem(){
|
public void testEquipItem(){
|
||||||
TestEngineUtils.simulateFrames(1);
|
TestEngineUtils.simulateFrames(1);
|
||||||
//spawn entities
|
//spawn entities
|
||||||
CreatureTemplate creatureTemplate = CreatureTemplate.createDefault("human");
|
CreatureTemplate creatureTemplate = CreatureTemplate.createDefault("human");
|
||||||
@ -52,5 +55,42 @@ public class ServerEquipStateTests extends EntityTestTemplate {
|
|||||||
assertNotNull(AttachUtils.getParent(child));
|
assertNotNull(AttachUtils.getParent(child));
|
||||||
assertEquals(AttachUtils.getParent(child), creature);
|
assertEquals(AttachUtils.getParent(child), creature);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try equipping two items to the same slot
|
||||||
|
*/
|
||||||
|
@IntegrationTest
|
||||||
|
public void testFailEquipToOccupied(){
|
||||||
|
TestEngineUtils.simulateFrames(1);
|
||||||
|
//spawn entities
|
||||||
|
CreatureTemplate creatureTemplate = CreatureTemplate.createDefault("human");
|
||||||
|
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", creatureTemplate);
|
||||||
|
Entity katana = ItemUtils.serverSpawnBasicItem(Globals.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
||||||
|
Entity katana2 = ItemUtils.serverSpawnBasicItem(Globals.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
||||||
|
|
||||||
|
//equip
|
||||||
|
Entity inInventoryItem = InventoryUtils.serverAttemptStoreItem(creature, katana);
|
||||||
|
ServerEquipState serverEquipState = ServerEquipState.getServerEquipState(creature);
|
||||||
|
serverEquipState.commandAttemptEquip(inInventoryItem, serverEquipState.getEquipPoint("handsCombined"));
|
||||||
|
|
||||||
|
//attempt to equip second katana
|
||||||
|
Entity inInventoryItem2 = InventoryUtils.serverAttemptStoreItem(creature, katana2);
|
||||||
|
serverEquipState.commandAttemptEquip(inInventoryItem2, serverEquipState.getEquipPoint("handsCombined"));
|
||||||
|
|
||||||
|
//propagate to client
|
||||||
|
TestEngineUtils.simulateFrames(2);
|
||||||
|
|
||||||
|
//
|
||||||
|
//verify that only one item was equipped
|
||||||
|
assertNotNull(serverEquipState.getEquippedItemAtPoint("handsCombined"));
|
||||||
|
List<Entity> children = AttachUtils.getChildrenList(creature);
|
||||||
|
assertNotNull(children);
|
||||||
|
assertEquals(1, children.size());
|
||||||
|
Entity child = children.get(0);
|
||||||
|
assertTrue(ItemUtils.isItem(child));
|
||||||
|
assertTrue(ItemUtils.isWeapon(child));
|
||||||
|
assertNotNull(AttachUtils.getParent(child));
|
||||||
|
assertEquals(AttachUtils.getParent(child), creature);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,15 @@
|
|||||||
package template;
|
package template;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Tag;
|
||||||
|
|
||||||
import annotations.IntegrationSetup;
|
import annotations.IntegrationSetup;
|
||||||
import electrosphere.net.server.ServerConnectionHandler;
|
import electrosphere.net.server.ServerConnectionHandler;
|
||||||
import testutils.EngineInit;
|
import testutils.EngineInit;
|
||||||
import testutils.TestEngineUtils;
|
import testutils.TestEngineUtils;
|
||||||
|
|
||||||
|
@Tag("Entity")
|
||||||
/**
|
/**
|
||||||
*
|
* Template for writing tests that do stuff with entities in a proper scene
|
||||||
*/
|
*/
|
||||||
public abstract class EntityTestTemplate extends RenderingTestTemplate {
|
public abstract class EntityTestTemplate extends RenderingTestTemplate {
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,8 @@ package template;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Tag;
|
||||||
|
|
||||||
import annotations.IntegrationSetup;
|
import annotations.IntegrationSetup;
|
||||||
import annotations.IntegrationTeardown;
|
import annotations.IntegrationTeardown;
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
@ -9,6 +11,7 @@ import electrosphere.engine.Main;
|
|||||||
import testutils.TestEngineUtils;
|
import testutils.TestEngineUtils;
|
||||||
import testutils.TestRenderingUtils;
|
import testutils.TestRenderingUtils;
|
||||||
|
|
||||||
|
@Tag("Graphical")
|
||||||
/**
|
/**
|
||||||
* A test class that involves testing renders
|
* A test class that involves testing renders
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -5,8 +5,6 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.engine.loadingthreads.LoadingThread;
|
import electrosphere.engine.loadingthreads.LoadingThread;
|
||||||
import electrosphere.engine.loadingthreads.LoadingThread.LoadingThreadType;
|
import electrosphere.engine.loadingthreads.LoadingThread.LoadingThreadType;
|
||||||
import electrosphere.logger.LoggerInterface;
|
|
||||||
import electrosphere.logger.Logger.LogLevel;
|
|
||||||
import electrosphere.menu.WindowStrings;
|
import electrosphere.menu.WindowStrings;
|
||||||
import electrosphere.renderer.ui.elements.Window;
|
import electrosphere.renderer.ui.elements.Window;
|
||||||
|
|
||||||
@ -16,14 +14,9 @@ public class EngineInit {
|
|||||||
* Setups up a locally-connected client and server that have loaded a test scene
|
* Setups up a locally-connected client and server that have loaded a test scene
|
||||||
*/
|
*/
|
||||||
public static void setupConnectedTestScene(){
|
public static void setupConnectedTestScene(){
|
||||||
|
|
||||||
LoadingThread loadingThread = null;
|
|
||||||
LoggerInterface.loggerNetworking.setLevel(LogLevel.LOOP_DEBUG);
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//load the scene
|
//load the scene
|
||||||
loadingThread = new LoadingThread(LoadingThreadType.LEVEL,"testscene1");
|
LoadingThread loadingThread = new LoadingThread(LoadingThreadType.LEVEL,"testscene1");
|
||||||
loadingThread.start();
|
loadingThread.start();
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user