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(){
|
public void updateDynamicObjectTransforms(){
|
||||||
Globals.profiler.beginCpuSample("updateDynamicObjectTransforms");
|
Globals.profiler.beginCpuSample("updateDynamicObjectTransforms");
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.acquireUninterruptibly();
|
||||||
for(Collidable collidable : collidableList){
|
if(this.collisionWorldData != null){
|
||||||
if(collidable.getParentTracksCollidable()){
|
for(Collidable collidable : collidableList){
|
||||||
Entity physicsEntity = collidable.getParent();
|
if(collidable.getParentTracksCollidable()){
|
||||||
DBody rigidBody = PhysicsEntityUtils.getDBody(physicsEntity);
|
Entity physicsEntity = collidable.getParent();
|
||||||
Matrix4d inverseTransform = new Matrix4d();
|
DBody rigidBody = PhysicsEntityUtils.getDBody(physicsEntity);
|
||||||
Vector4d rawPos = inverseTransform.transform(new Vector4d(PhysicsUtils.getRigidBodyPosition(rigidBody),1));
|
Matrix4d inverseTransform = new Matrix4d();
|
||||||
Vector3d newPosition = new Vector3d(rawPos.x,rawPos.y,rawPos.z);
|
Vector4d rawPos = inverseTransform.transform(new Vector4d(PhysicsUtils.getRigidBodyPosition(rigidBody),1));
|
||||||
newPosition = this.suggestMovementPosition(collisionWorldData, newPosition);
|
Vector3d newPosition = new Vector3d(rawPos.x,rawPos.y,rawPos.z);
|
||||||
Quaterniond newRotation = PhysicsUtils.getRigidBodyRotation(rigidBody);
|
newPosition = this.suggestMovementPosition(collisionWorldData, newPosition);
|
||||||
EntityUtils.getPosition(physicsEntity).set(newPosition);
|
Quaterniond newRotation = PhysicsUtils.getRigidBodyRotation(rigidBody);
|
||||||
EntityUtils.getRotation(physicsEntity).set(newRotation);
|
EntityUtils.getPosition(physicsEntity).set(newPosition);
|
||||||
|
EntityUtils.getRotation(physicsEntity).set(newRotation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spaceLock.release();
|
spaceLock.release();
|
||||||
|
|||||||
@ -88,7 +88,7 @@ public class Globals {
|
|||||||
//
|
//
|
||||||
//Thread manager
|
//Thread manager
|
||||||
//
|
//
|
||||||
public static ThreadManager threadManager = new ThreadManager();
|
public static ThreadManager threadManager;
|
||||||
|
|
||||||
//
|
//
|
||||||
//Top level user settings object
|
//Top level user settings object
|
||||||
@ -420,6 +420,7 @@ public class Globals {
|
|||||||
LoggerInterface.loggerStartup.INFO("Initialize global variables");
|
LoggerInterface.loggerStartup.INFO("Initialize global variables");
|
||||||
//timekeeper
|
//timekeeper
|
||||||
timekeeper = new Timekeeper();
|
timekeeper = new Timekeeper();
|
||||||
|
threadManager = new ThreadManager();
|
||||||
//load in default texture map
|
//load in default texture map
|
||||||
textureMapDefault = TextureMap.construct("Textures/default_texture_map.json");
|
textureMapDefault = TextureMap.construct("Textures/default_texture_map.json");
|
||||||
//load model pretransforms
|
//load model pretransforms
|
||||||
|
|||||||
@ -442,6 +442,10 @@ public class Main {
|
|||||||
}
|
}
|
||||||
//shutdown ode
|
//shutdown ode
|
||||||
OdeHelper.closeODE();
|
OdeHelper.closeODE();
|
||||||
|
//reset globals
|
||||||
|
Globals.playerEntity = null;
|
||||||
|
Globals.playerCamera = null;
|
||||||
|
Globals.firstPersonEntity = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sleep(int i) {
|
static void sleep(int i) {
|
||||||
|
|||||||
@ -170,7 +170,7 @@ public class LoadingUtils {
|
|||||||
Globals.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestSpawnCharacterMessage());
|
Globals.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestSpawnCharacterMessage());
|
||||||
|
|
||||||
//set player world-space coordinates
|
//set player world-space coordinates
|
||||||
Player playerObject = Globals.playerManager.getPlayerFromId(0);
|
Player playerObject = Globals.playerManager.getFirstPlayer();
|
||||||
Realm realm = Globals.realmManager.getRealms().iterator().next();
|
Realm realm = Globals.realmManager.getRealms().iterator().next();
|
||||||
Vector3d spawnPoint = realm.getSpawnPoint();
|
Vector3d spawnPoint = realm.getSpawnPoint();
|
||||||
playerObject.setWorldPos(new Vector3i(
|
playerObject.setWorldPos(new Vector3i(
|
||||||
|
|||||||
@ -40,7 +40,7 @@ public class Logger {
|
|||||||
*/
|
*/
|
||||||
public void setLevel(LogLevel level){
|
public void setLevel(LogLevel level){
|
||||||
this.level = 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);
|
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);
|
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(){
|
public List<Player> getPlayers(){
|
||||||
return new LinkedList<Player>(idMap.values());
|
return new LinkedList<Player>(idMap.values());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,9 +7,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.joml.Vector3d;
|
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 annotations.IntegrationTest;
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
@ -27,9 +24,7 @@ import testutils.TestEngineUtils;
|
|||||||
/**
|
/**
|
||||||
* Tests for client side equip state
|
* Tests for client side equip state
|
||||||
*/
|
*/
|
||||||
@ExtendWith(EntityTestTemplate.class)
|
public class ClientEquipStateTests extends EntityTestTemplate {
|
||||||
@Execution(ExecutionMode.SAME_THREAD)
|
|
||||||
public class ClientEquipStateTests {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -7,9 +7,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.joml.Vector3d;
|
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 annotations.IntegrationTest;
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
@ -25,9 +22,7 @@ import testutils.TestEngineUtils;
|
|||||||
/**
|
/**
|
||||||
* Server equip state tests
|
* Server equip state tests
|
||||||
*/
|
*/
|
||||||
@ExtendWith(EntityTestTemplate.class)
|
public class ServerEquipStateTests extends EntityTestTemplate {
|
||||||
@Execution(ExecutionMode.SAME_THREAD)
|
|
||||||
public class ServerEquipStateTests {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try equipping an item
|
* Try equipping an item
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
package electrosphere.renderer.ui.elements;
|
package electrosphere.renderer.ui.elements;
|
||||||
|
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
|
||||||
|
|
||||||
import annotations.IntegrationTest;
|
import annotations.IntegrationTest;
|
||||||
import electrosphere.menu.WindowUtils;
|
import electrosphere.menu.WindowUtils;
|
||||||
import electrosphere.menu.mainmenu.MenuGeneratorsUITesting;
|
import electrosphere.menu.mainmenu.MenuGeneratorsUITesting;
|
||||||
@ -11,7 +9,6 @@ import testutils.TestEngineUtils;
|
|||||||
/**
|
/**
|
||||||
* Tests for the window class
|
* Tests for the window class
|
||||||
*/
|
*/
|
||||||
@ExtendWith(RenderingTestTemplate.class)
|
|
||||||
public class WindowTest extends RenderingTestTemplate {
|
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
|
//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
|
//2 frames seems to fix this
|
||||||
TestEngineUtils.simulateFrames(2);
|
TestEngineUtils.simulateFrames(60);
|
||||||
// TestRenderingUtils.saveTestRender("./test/java/electrosphere/renderer/ui/elements/window.png");
|
// TestRenderingUtils.saveTestRender("./test/java/electrosphere/renderer/ui/elements/window.png");
|
||||||
this.checkRender("Basic", "./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;
|
package template;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Tag;
|
import org.junit.jupiter.api.Tag;
|
||||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
|
||||||
import testutils.EngineInit;
|
import template.extensions.EntityExtension;
|
||||||
import testutils.TestEngineUtils;
|
|
||||||
|
|
||||||
@Tag("Entity")
|
|
||||||
/**
|
/**
|
||||||
* Template for writing tests that do stuff with entities in a proper scene
|
* Template for writing tests that do stuff with entities in a proper scene
|
||||||
*/
|
*/
|
||||||
public class EntityTestTemplate extends RenderingTestTemplate {
|
@Tag("integration")
|
||||||
|
@Tag("graphical")
|
||||||
@Override
|
@Tag("entity")
|
||||||
public void beforeEach(ExtensionContext context) throws Exception {
|
@ExtendWith(EntityExtension.class)
|
||||||
//init engine
|
public class EntityTestTemplate {
|
||||||
TestEngineUtils.initGraphicalEngine();
|
|
||||||
|
|
||||||
//load scene
|
|
||||||
EngineInit.setupConnectedTestScene();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,21 +3,18 @@ package template;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Tag;
|
import org.junit.jupiter.api.Tag;
|
||||||
import org.junit.jupiter.api.extension.AfterEachCallback;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.junit.jupiter.api.extension.BeforeEachCallback;
|
|
||||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
|
||||||
|
|
||||||
import electrosphere.engine.Globals;
|
import template.extensions.RenderingExtension;
|
||||||
import electrosphere.engine.Main;
|
|
||||||
import testutils.TestEngineUtils;
|
|
||||||
import testutils.TestRenderingUtils;
|
import testutils.TestRenderingUtils;
|
||||||
|
|
||||||
@Tag("integration")
|
|
||||||
@Tag("graphical")
|
|
||||||
/**
|
/**
|
||||||
* A test class that involves testing renders
|
* 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
|
* 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