fix testing bugs, leverage extensions
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
53a0e0df1b
commit
b5405081e7
@ -455,17 +455,19 @@ public class CollisionEngine {
|
||||
public void updateDynamicObjectTransforms(){
|
||||
Globals.profiler.beginCpuSample("updateDynamicObjectTransforms");
|
||||
spaceLock.acquireUninterruptibly();
|
||||
for(Collidable collidable : collidableList){
|
||||
if(collidable.getParentTracksCollidable()){
|
||||
Entity physicsEntity = collidable.getParent();
|
||||
DBody rigidBody = PhysicsEntityUtils.getDBody(physicsEntity);
|
||||
Matrix4d inverseTransform = new Matrix4d();
|
||||
Vector4d rawPos = inverseTransform.transform(new Vector4d(PhysicsUtils.getRigidBodyPosition(rigidBody),1));
|
||||
Vector3d newPosition = new Vector3d(rawPos.x,rawPos.y,rawPos.z);
|
||||
newPosition = this.suggestMovementPosition(collisionWorldData, newPosition);
|
||||
Quaterniond newRotation = PhysicsUtils.getRigidBodyRotation(rigidBody);
|
||||
EntityUtils.getPosition(physicsEntity).set(newPosition);
|
||||
EntityUtils.getRotation(physicsEntity).set(newRotation);
|
||||
if(this.collisionWorldData != null){
|
||||
for(Collidable collidable : collidableList){
|
||||
if(collidable.getParentTracksCollidable()){
|
||||
Entity physicsEntity = collidable.getParent();
|
||||
DBody rigidBody = PhysicsEntityUtils.getDBody(physicsEntity);
|
||||
Matrix4d inverseTransform = new Matrix4d();
|
||||
Vector4d rawPos = inverseTransform.transform(new Vector4d(PhysicsUtils.getRigidBodyPosition(rigidBody),1));
|
||||
Vector3d newPosition = new Vector3d(rawPos.x,rawPos.y,rawPos.z);
|
||||
newPosition = this.suggestMovementPosition(collisionWorldData, newPosition);
|
||||
Quaterniond newRotation = PhysicsUtils.getRigidBodyRotation(rigidBody);
|
||||
EntityUtils.getPosition(physicsEntity).set(newPosition);
|
||||
EntityUtils.getRotation(physicsEntity).set(newRotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
spaceLock.release();
|
||||
|
||||
@ -88,7 +88,7 @@ public class Globals {
|
||||
//
|
||||
//Thread manager
|
||||
//
|
||||
public static ThreadManager threadManager = new ThreadManager();
|
||||
public static ThreadManager threadManager;
|
||||
|
||||
//
|
||||
//Top level user settings object
|
||||
@ -420,6 +420,7 @@ public class Globals {
|
||||
LoggerInterface.loggerStartup.INFO("Initialize global variables");
|
||||
//timekeeper
|
||||
timekeeper = new Timekeeper();
|
||||
threadManager = new ThreadManager();
|
||||
//load in default texture map
|
||||
textureMapDefault = TextureMap.construct("Textures/default_texture_map.json");
|
||||
//load model pretransforms
|
||||
|
||||
@ -442,6 +442,10 @@ public class Main {
|
||||
}
|
||||
//shutdown ode
|
||||
OdeHelper.closeODE();
|
||||
//reset globals
|
||||
Globals.playerEntity = null;
|
||||
Globals.playerCamera = null;
|
||||
Globals.firstPersonEntity = null;
|
||||
}
|
||||
|
||||
static void sleep(int i) {
|
||||
|
||||
@ -170,7 +170,7 @@ public class LoadingUtils {
|
||||
Globals.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestSpawnCharacterMessage());
|
||||
|
||||
//set player world-space coordinates
|
||||
Player playerObject = Globals.playerManager.getPlayerFromId(0);
|
||||
Player playerObject = Globals.playerManager.getFirstPlayer();
|
||||
Realm realm = Globals.realmManager.getRealms().iterator().next();
|
||||
Vector3d spawnPoint = realm.getSpawnPoint();
|
||||
playerObject.setWorldPos(new Vector3i(
|
||||
|
||||
@ -40,7 +40,7 @@ public class Logger {
|
||||
*/
|
||||
public void setLevel(LogLevel level){
|
||||
this.level = level;
|
||||
new Exception("Changing log level to " + level + "!").printStackTrace();
|
||||
// new Exception("Changing log level to " + level + "!").printStackTrace();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -66,4 +66,14 @@ public class LoggerInterface {
|
||||
return Arrays.asList(loggerList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the log level for all loggers
|
||||
* @param level The level
|
||||
*/
|
||||
public static void setLogLevel(LogLevel level){
|
||||
for(Logger logger : getLoggers()){
|
||||
logger.setLevel(level);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -28,6 +28,17 @@ public class PlayerManager {
|
||||
return idMap.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first registered player
|
||||
* @return The first registered player if it exists, null otherwise
|
||||
*/
|
||||
public Player getFirstPlayer(){
|
||||
if(idMap.values().size() > 0){
|
||||
return idMap.values().iterator().next();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Player> getPlayers(){
|
||||
return new LinkedList<Player>(idMap.values());
|
||||
}
|
||||
|
||||
@ -7,9 +7,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import java.util.Set;
|
||||
|
||||
import org.joml.Vector3d;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.parallel.Execution;
|
||||
import org.junit.jupiter.api.parallel.ExecutionMode;
|
||||
|
||||
import annotations.IntegrationTest;
|
||||
import electrosphere.engine.Globals;
|
||||
@ -27,9 +24,7 @@ import testutils.TestEngineUtils;
|
||||
/**
|
||||
* Tests for client side equip state
|
||||
*/
|
||||
@ExtendWith(EntityTestTemplate.class)
|
||||
@Execution(ExecutionMode.SAME_THREAD)
|
||||
public class ClientEquipStateTests {
|
||||
public class ClientEquipStateTests extends EntityTestTemplate {
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -7,9 +7,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import java.util.List;
|
||||
|
||||
import org.joml.Vector3d;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.api.parallel.Execution;
|
||||
import org.junit.jupiter.api.parallel.ExecutionMode;
|
||||
|
||||
import annotations.IntegrationTest;
|
||||
import electrosphere.engine.Globals;
|
||||
@ -25,9 +22,7 @@ import testutils.TestEngineUtils;
|
||||
/**
|
||||
* Server equip state tests
|
||||
*/
|
||||
@ExtendWith(EntityTestTemplate.class)
|
||||
@Execution(ExecutionMode.SAME_THREAD)
|
||||
public class ServerEquipStateTests {
|
||||
public class ServerEquipStateTests extends EntityTestTemplate {
|
||||
|
||||
/**
|
||||
* Try equipping an item
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
package electrosphere.renderer.ui.elements;
|
||||
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import annotations.IntegrationTest;
|
||||
import electrosphere.menu.WindowUtils;
|
||||
import electrosphere.menu.mainmenu.MenuGeneratorsUITesting;
|
||||
@ -11,7 +9,6 @@ import testutils.TestEngineUtils;
|
||||
/**
|
||||
* Tests for the window class
|
||||
*/
|
||||
@ExtendWith(RenderingTestTemplate.class)
|
||||
public class WindowTest extends RenderingTestTemplate {
|
||||
|
||||
/**
|
||||
@ -25,7 +22,7 @@ public class WindowTest extends RenderingTestTemplate {
|
||||
|
||||
//only simulating 1 frame after updating ui contents does not trigger re-render in local dev environment, but DOES in CI env
|
||||
//2 frames seems to fix this
|
||||
TestEngineUtils.simulateFrames(2);
|
||||
TestEngineUtils.simulateFrames(60);
|
||||
// TestRenderingUtils.saveTestRender("./test/java/electrosphere/renderer/ui/elements/window.png");
|
||||
this.checkRender("Basic", "./test/java/electrosphere/renderer/ui/elements/window.png");
|
||||
}
|
||||
|
||||
@ -1,24 +1,17 @@
|
||||
package template;
|
||||
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import testutils.EngineInit;
|
||||
import testutils.TestEngineUtils;
|
||||
import template.extensions.EntityExtension;
|
||||
|
||||
@Tag("Entity")
|
||||
/**
|
||||
* Template for writing tests that do stuff with entities in a proper scene
|
||||
*/
|
||||
public class EntityTestTemplate extends RenderingTestTemplate {
|
||||
|
||||
@Override
|
||||
public void beforeEach(ExtensionContext context) throws Exception {
|
||||
//init engine
|
||||
TestEngineUtils.initGraphicalEngine();
|
||||
|
||||
//load scene
|
||||
EngineInit.setupConnectedTestScene();
|
||||
}
|
||||
@Tag("integration")
|
||||
@Tag("graphical")
|
||||
@Tag("entity")
|
||||
@ExtendWith(EntityExtension.class)
|
||||
public class EntityTestTemplate {
|
||||
|
||||
}
|
||||
|
||||
@ -3,21 +3,18 @@ package template;
|
||||
import java.io.File;
|
||||
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.extension.AfterEachCallback;
|
||||
import org.junit.jupiter.api.extension.BeforeEachCallback;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.Main;
|
||||
import testutils.TestEngineUtils;
|
||||
import template.extensions.RenderingExtension;
|
||||
import testutils.TestRenderingUtils;
|
||||
|
||||
@Tag("integration")
|
||||
@Tag("graphical")
|
||||
/**
|
||||
* A test class that involves testing renders
|
||||
*/
|
||||
public class RenderingTestTemplate implements BeforeEachCallback, AfterEachCallback {
|
||||
@Tag("integration")
|
||||
@Tag("graphical")
|
||||
@ExtendWith(RenderingExtension.class)
|
||||
public class RenderingTestTemplate {
|
||||
|
||||
/**
|
||||
* Checks the most recent render versus an existing image
|
||||
@ -39,18 +36,4 @@ public class RenderingTestTemplate implements BeforeEachCallback, AfterEachCallb
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterEach(ExtensionContext context) throws Exception {
|
||||
Globals.WINDOW_DECORATED = false;
|
||||
Globals.WINDOW_FULLSCREEN = true;
|
||||
Globals.WINDOW_WIDTH = 1920;
|
||||
Globals.WINDOW_HEIGHT = 1080;
|
||||
TestEngineUtils.initGraphicalEngine();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeEach(ExtensionContext context) throws Exception {
|
||||
Main.shutdown();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
30
src/test/java/template/extensions/EntityExtension.java
Normal file
30
src/test/java/template/extensions/EntityExtension.java
Normal file
@ -0,0 +1,30 @@
|
||||
package template.extensions;
|
||||
|
||||
import org.junit.jupiter.api.extension.AfterEachCallback;
|
||||
import org.junit.jupiter.api.extension.BeforeEachCallback;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
|
||||
import electrosphere.engine.Main;
|
||||
import testutils.EngineInit;
|
||||
import testutils.TestEngineUtils;
|
||||
|
||||
/**
|
||||
* Spins up and tears down entity testing environment
|
||||
*/
|
||||
public class EntityExtension implements BeforeEachCallback, AfterEachCallback {
|
||||
|
||||
@Override
|
||||
public void beforeEach(ExtensionContext context) throws Exception {
|
||||
//init engine
|
||||
TestEngineUtils.initGraphicalEngine();
|
||||
|
||||
//load scene
|
||||
EngineInit.setupConnectedTestScene();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterEach(ExtensionContext context) throws Exception {
|
||||
Main.shutdown();
|
||||
}
|
||||
|
||||
}
|
||||
30
src/test/java/template/extensions/RenderingExtension.java
Normal file
30
src/test/java/template/extensions/RenderingExtension.java
Normal file
@ -0,0 +1,30 @@
|
||||
package template.extensions;
|
||||
|
||||
import org.junit.jupiter.api.extension.AfterEachCallback;
|
||||
import org.junit.jupiter.api.extension.BeforeEachCallback;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.Main;
|
||||
import testutils.TestEngineUtils;
|
||||
|
||||
/**
|
||||
* Spins up an tears down generic rendering environment
|
||||
*/
|
||||
public class RenderingExtension implements BeforeEachCallback, AfterEachCallback {
|
||||
|
||||
@Override
|
||||
public void beforeEach(ExtensionContext context) throws Exception {
|
||||
Globals.WINDOW_DECORATED = false;
|
||||
Globals.WINDOW_FULLSCREEN = true;
|
||||
Globals.WINDOW_WIDTH = 1920;
|
||||
Globals.WINDOW_HEIGHT = 1080;
|
||||
TestEngineUtils.initGraphicalEngine();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterEach(ExtensionContext context) throws Exception {
|
||||
Main.shutdown();
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user