viewport loading integration with testing
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
a95086e6db
commit
95aff671c9
@ -1,5 +1,7 @@
|
|||||||
package electrosphere.engine.loadingthreads;
|
package electrosphere.engine.loadingthreads;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
|
||||||
import annotations.IntegrationTest;
|
import annotations.IntegrationTest;
|
||||||
import electrosphere.engine.Main;
|
import electrosphere.engine.Main;
|
||||||
import testutils.EngineInit;
|
import testutils.EngineInit;
|
||||||
@ -12,14 +14,16 @@ public class ViewportLoadingTests {
|
|||||||
|
|
||||||
@IntegrationTest
|
@IntegrationTest
|
||||||
public void testViewportLoading(){
|
public void testViewportLoading(){
|
||||||
//init engine
|
Assertions.assertDoesNotThrow(() -> {
|
||||||
TestEngineUtils.initGraphicalEngine();
|
//init engine
|
||||||
|
TestEngineUtils.initGraphicalEngine();
|
||||||
|
|
||||||
//load scene
|
//load scene
|
||||||
EngineInit.setupConnectedTestScene();
|
EngineInit.setupConnectedTestViewport();
|
||||||
|
|
||||||
//shutdown engine
|
//shutdown engine
|
||||||
Main.shutdown();
|
Main.shutdown();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,12 +3,15 @@ package electrosphere.entity.state.attack;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
|
|
||||||
|
import org.joml.Vector3d;
|
||||||
|
|
||||||
import annotations.IntegrationTest;
|
import annotations.IntegrationTest;
|
||||||
import electrosphere.controls.ControlHandler;
|
import electrosphere.controls.ControlHandler;
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.state.attack.ClientAttackTree.AttackTreeState;
|
import electrosphere.entity.state.attack.ClientAttackTree.AttackTreeState;
|
||||||
import electrosphere.server.datacell.utils.EntityLookupUtils;
|
import electrosphere.entity.types.creature.CreatureTemplate;
|
||||||
|
import electrosphere.entity.types.creature.CreatureUtils;
|
||||||
import template.EntityTestTemplate;
|
import template.EntityTestTemplate;
|
||||||
import testutils.InputAPI;
|
import testutils.InputAPI;
|
||||||
import testutils.TestEngineUtils;
|
import testutils.TestEngineUtils;
|
||||||
@ -16,7 +19,7 @@ import testutils.TestEngineUtils;
|
|||||||
/**
|
/**
|
||||||
* Testing the client's attacking trees
|
* Testing the client's attacking trees
|
||||||
*/
|
*/
|
||||||
public class ClientAttackTreeTests extends EntityTestTemplate {
|
public class ServerAttackTreeTests extends EntityTestTemplate {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,16 +30,13 @@ public class ClientAttackTreeTests extends EntityTestTemplate {
|
|||||||
//warm up engine
|
//warm up engine
|
||||||
TestEngineUtils.simulateFrames(1);
|
TestEngineUtils.simulateFrames(1);
|
||||||
|
|
||||||
//Get the client-side player's attack state
|
//spawn on server
|
||||||
ClientAttackTree clientAttackTree = ClientAttackTree.getClientAttackTree(Globals.playerEntity);
|
Entity entity = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", CreatureTemplate.createDefault("human"));
|
||||||
|
|
||||||
//Get the server-side player's attack tree
|
//Get the server-side player's attack tree
|
||||||
int serverIdForClientEntity = Globals.clientSceneWrapper.mapClientToServerId(Globals.playerEntity.getId());
|
ServerAttackTree serverAttackTree = ServerAttackTree.getServerAttackTree(entity);
|
||||||
Entity serverPlayerEntity = EntityLookupUtils.getEntityById(serverIdForClientEntity);
|
|
||||||
ServerAttackTree serverAttackTree = ServerAttackTree.getServerAttackTree(serverPlayerEntity);
|
|
||||||
|
|
||||||
//verify can attack
|
//verify can attack
|
||||||
assertEquals(true, clientAttackTree.canAttack(clientAttackTree.getAttackType()));
|
|
||||||
assertEquals(true, serverAttackTree.canAttack(serverAttackTree.getAttackType()));
|
assertEquals(true, serverAttackTree.canAttack(serverAttackTree.getAttackType()));
|
||||||
|
|
||||||
//try attacking
|
//try attacking
|
||||||
@ -48,9 +48,6 @@ public class ClientAttackTreeTests extends EntityTestTemplate {
|
|||||||
|
|
||||||
//verify it was started on server
|
//verify it was started on server
|
||||||
assertNotEquals(serverAttackTree.getState(), AttackTreeState.IDLE);
|
assertNotEquals(serverAttackTree.getState(), AttackTreeState.IDLE);
|
||||||
|
|
||||||
//verify state transition was triggered on client
|
|
||||||
assertNotEquals(clientAttackTree.getState(), AttackTreeState.IDLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -46,9 +46,9 @@ public class ClientEquipStateTests extends EntityTestTemplate {
|
|||||||
|
|
||||||
//verify the client got the extra entities
|
//verify the client got the extra entities
|
||||||
Set<Entity> clientSideCreatures = Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.CREATURE);
|
Set<Entity> clientSideCreatures = Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.CREATURE);
|
||||||
assertEquals(2, clientSideCreatures.size());
|
assertEquals(1, clientSideCreatures.size());
|
||||||
Set<Entity> clientSideItems = Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
Set<Entity> clientSideItems = Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
||||||
assertEquals(2, clientSideItems.size());
|
assertEquals(1, clientSideItems.size());
|
||||||
|
|
||||||
//equip
|
//equip
|
||||||
Entity inInventoryItem = InventoryUtils.serverAttemptStoreItem(creature, katana);
|
Entity inInventoryItem = InventoryUtils.serverAttemptStoreItem(creature, katana);
|
||||||
@ -98,7 +98,7 @@ public class ClientEquipStateTests extends EntityTestTemplate {
|
|||||||
Set<Entity> clientSideCreatures = Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.CREATURE);
|
Set<Entity> clientSideCreatures = Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.CREATURE);
|
||||||
assertEquals(1, clientSideCreatures.size());
|
assertEquals(1, clientSideCreatures.size());
|
||||||
Set<Entity> clientSideItems = Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
Set<Entity> clientSideItems = Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.ITEM);
|
||||||
assertEquals(2, clientSideItems.size());
|
assertEquals(1, clientSideItems.size());
|
||||||
|
|
||||||
//try to store item in inventory
|
//try to store item in inventory
|
||||||
Entity katanaOnClient = clientSideItems.iterator().next();
|
Entity katanaOnClient = clientSideItems.iterator().next();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user