globals tests
	
		
			
	
		
	
	
		
	
		
			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
							
								
									199d1b925c
								
							
						
					
					
						commit
						b9ccf5990c
					
				| @ -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; | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -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(); | ||||
|     } | ||||
| 
 | ||||
|      | ||||
| } | ||||
|  | ||||
							
								
								
									
										41
									
								
								src/test/java/electrosphere/engine/GlobalsTests.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								src/test/java/electrosphere/engine/GlobalsTests.java
									
									
									
									
									
										Normal 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); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user