globals tests
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2024-09-05 17:09:18 -04:00
parent 199d1b925c
commit b9ccf5990c
3 changed files with 58 additions and 2 deletions

View File

@ -634,7 +634,9 @@ public class Globals {
Globals.clientScene = new Scene();
Globals.clientSceneWrapper = new ClientSceneWrapper(Globals.clientScene, new CollisionEngine());
Globals.clientSynchronizationManager = new ClientSynchronizationManager();
Globals.realmManager = null;
if(Globals.realmManager != null){
Globals.realmManager.reset();
}
}
/**
@ -645,9 +647,13 @@ public class Globals {
//
//Actual globals to destroy
Globals.assetManager = null;
Globals.elementService = null;
Globals.realmManager = null;
//
//Destroy services
Globals.serviceManager.destroy();
if(Globals.serviceManager != null){
Globals.serviceManager.destroy();
}
Globals.serviceManager = null;
}

View File

@ -171,5 +171,14 @@ public class RealmManager {
return realms.iterator().next();
}
/**
* Resets the realm manager
*/
public void reset(){
this.realms.clear();
this.entityToRealmMap.clear();
this.playerToRealmMap.clear();
}
}

View File

@ -0,0 +1,41 @@
package electrosphere.engine;
import static org.junit.jupiter.api.Assertions.*;
import electrosphere.game.config.UserSettings;
import electrosphere.logger.LoggerInterface;
import electrosphere.test.annotations.IntegrationTest;
/**
* Tests for globals
*/
public class GlobalsTests {
@IntegrationTest
public void resetGlobals_Variables_null(){
LoggerInterface.initLoggers();
UserSettings.loadUserSettings();
Globals.initGlobals();
Globals.resetGlobals();
assertNull(Globals.assetManager);
assertNull(Globals.elementService);
}
@IntegrationTest
public void resetGlobalsWithoutInit_ThrowsError_false(){
assertDoesNotThrow(() -> {
Globals.resetGlobals();
});
}
@IntegrationTest
public void unloadScene_Variables_notNull(){
LoggerInterface.initLoggers();
UserSettings.loadUserSettings();
Globals.initGlobals();
Globals.unloadScene();
assertNotNull(Globals.assetManager);
assertNotNull(Globals.realmManager);
}
}