entity-scene testing tools
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2024-08-22 19:09:21 -04:00
parent 6dc82d0b5e
commit ea0902d22f
7 changed files with 23 additions and 8 deletions

View File

@ -1,6 +1,8 @@
package electrosphere.game.data.item.type.model;
import electrosphere.game.data.item.type.Item;
import electrosphere.logger.LoggerInterface;
import java.util.List;
public class ItemTypeMap {
@ -16,6 +18,8 @@ public class ItemTypeMap {
if(item.getItemId().equals(name)){
rVal = item;
break;
} else if(item.getItemId().equalsIgnoreCase(name)){
LoggerInterface.loggerEngine.WARNING("Failed to fetch item type data; however, item with different-capitalized name exists! May be a capitalization error!");
}
}
return rVal;

View File

@ -8,6 +8,8 @@ import electrosphere.net.parser.net.message.ServerMessage;
import electrosphere.net.parser.net.message.NetworkMessage.MessageType;
import electrosphere.net.parser.net.message.ServerMessage.ServerMessageType;
import electrosphere.net.parser.net.raw.NetworkParser;
import electrosphere.net.server.ServerConnectionHandler;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -168,7 +170,7 @@ public class ClientNetworking implements Runnable {
//start parsing messages
initialized = true;
while(Main.isRunning()){
while((Main.isRunning() || !ServerConnectionHandler.AUTO_CLOSE_THREAD)){
//attempt poll incoming messages
parser.readMessagesIn();
//outgoing messages

View File

@ -25,6 +25,12 @@ import java.util.concurrent.TimeUnit;
* A connection to the server
*/
public class ServerConnectionHandler implements Runnable {
/**
* Automatically close threads if the main thread ends.
* Used to make sure threads don't close while running test suite.
*/
public static boolean AUTO_CLOSE_THREAD = true;
//the player id associated with this connection
static int playerIdIncrementer = 0;
@ -193,7 +199,7 @@ public class ServerConnectionHandler implements Runnable {
initialized = true;
while(Main.isRunning() && this.isConnected == true){
while((Main.isRunning() || !ServerConnectionHandler.AUTO_CLOSE_THREAD) && this.isConnected == true){
//
// Main Loop

View File

@ -3,7 +3,6 @@ package electrosphere.entity.state.equip;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.joml.Vector3d;
import org.junit.jupiter.api.Disabled;
import annotations.IntegrationTest;
import electrosphere.engine.Globals;
@ -20,14 +19,13 @@ import testutils.TestEngineUtils;
*/
public class ServerEquipStateTests extends EntityTestTemplate {
@Disabled
@IntegrationTest
public void spawningWithEquippedItem(){
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 katana = ItemUtils.serverSpawnBasicItem(Globals.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
//equip
Entity inInventoryItem = InventoryUtils.serverAttemptStoreItem(creature, katana);

View File

@ -5,7 +5,6 @@ import electrosphere.menu.WindowUtils;
import electrosphere.menu.mainmenu.MenuGeneratorsUITesting;
import template.RenderingTestTemplate;
import testutils.TestEngineUtils;
import testutils.TestRenderingUtils;
/**
* Tests for the window class

View File

@ -1,6 +1,7 @@
package template;
import annotations.IntegrationSetup;
import electrosphere.net.server.ServerConnectionHandler;
import testutils.EngineInit;
import testutils.TestEngineUtils;
@ -12,7 +13,13 @@ public abstract class EntityTestTemplate extends RenderingTestTemplate {
@IntegrationSetup
@Override
public void initEngine(){
//init engine
TestEngineUtils.initGraphicalEngine();
//make sure the server network threads continue to execute even if the main thread dies
ServerConnectionHandler.AUTO_CLOSE_THREAD = false;
//load scene
EngineInit.setupConnectedTestScene();
}

View File

@ -18,6 +18,7 @@ public class EngineInit {
public static void setupConnectedTestScene(){
LoadingThread loadingThread = null;
LoggerInterface.loggerNetworking.setLevel(LogLevel.LOOP_DEBUG);
//
@ -25,8 +26,6 @@ public class EngineInit {
loadingThread = new LoadingThread(LoadingThreadType.LEVEL,"testscene1");
loadingThread.start();
LoggerInterface.loggerNetworking.setLevel(LogLevel.LOOP_DEBUG);
//
//wait for client to be fully init'd
while(((Window)Globals.elementManager.getWindow(WindowStrings.WINDOW_LOADING)).getVisible() || Globals.playerEntity == null){