@@ -0,0 +1,66 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/execution_monitor.hpp>
|
||||
using boost::unit_test_framework::test_suite;
|
||||
using boost::unit_test_framework::test_case;
|
||||
#include <stdlib.h>//srand
|
||||
|
||||
//#define private public
|
||||
#include "Engine\Core\ConfigFile.h"
|
||||
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <crtdbg.h>
|
||||
#define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__)
|
||||
#define new DEBUG_CLIENTBLOCK
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(confTest)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(configFileTest)
|
||||
{
|
||||
//note: this ConfigFileclass currently has memleaks!
|
||||
|
||||
ResourceManager::RegisterType<ConfigFile>("ConfigFile");
|
||||
auto m_Config = ResourceManager::Load<ConfigFile>("ConfigTest.ini");
|
||||
|
||||
//bägge måste vara av samma typ, T typen är string
|
||||
//http://www.boost.org/doc/libs/1_42_0/doc/html/boost_propertytree/tutorial.html
|
||||
//"Note that we construct the path to the value by separating the individual keys with dots"
|
||||
|
||||
//get from tree tests
|
||||
auto getSomething = m_Config->Get("Test.Test1", 0);
|
||||
BOOST_CHECK(getSomething == 423);
|
||||
|
||||
auto getSomething2 = m_Config->Get("fsdfdsfd.T", std::string(""));
|
||||
BOOST_CHECK(getSomething2 == "\"gfdjakflsdl!\"");
|
||||
|
||||
//set/get tests
|
||||
m_Config->Set("Test.4321", 123);
|
||||
auto getSomething3 = m_Config->Get("Test.4321", 0);
|
||||
BOOST_CHECK(getSomething3 == 123);
|
||||
|
||||
m_Config->Set("3_2_1_0_5", "t454j54hj5k32");
|
||||
auto getSomething4 = m_Config->Get("3_2_1_0_5", std::string(""));
|
||||
BOOST_CHECK(getSomething4 == "t454j54hj5k32");
|
||||
|
||||
//***check so outputwindow says: EE: Failed to find "DefaultConfigTestNotExists.ini"! Relying on hardcoded default values!
|
||||
auto m_Config2 = ResourceManager::Load<ConfigFile>("ConfigTestNotExists.ini");
|
||||
|
||||
//set value/savetodisk/load/checkvalue...
|
||||
m_Config->SaveToDisk();
|
||||
m_Config->Set("Test.4321", 145);
|
||||
m_Config->SaveToDisk();
|
||||
auto m_Config3 = ResourceManager::Load<ConfigFile>("ConfigTest.ini");
|
||||
auto getSomething5 = m_Config->Get("Test.4321", 0);
|
||||
BOOST_CHECK(getSomething5 == 145);
|
||||
|
||||
//***check so outputwindow says: EE: Failed to parse "DefaultConfigTestFailed.ini"
|
||||
//***check so outputwindow says: EE: Failed to parse "ConfigTestFailed.ini":
|
||||
auto m_Config4 = ResourceManager::Load<ConfigFile>("ConfigTestFailed.ini");
|
||||
|
||||
//reload,onchildreload unimplemented
|
||||
|
||||
//NOTE:still massive amount of memoryleaks from this method
|
||||
_CrtDumpMemoryLeaks();
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
#ifndef EVENTFIXTURE_H
|
||||
#define EVENTFIXTURE_H
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include "Core\EventBroker.h"
|
||||
|
||||
template <typename EventType>
|
||||
struct EventFixture
|
||||
{
|
||||
EventFixture()
|
||||
{
|
||||
this->ventBroker = new EventBroker();
|
||||
m_EEventType = decltype(m_EEventType)(std::bind(&EventFixture::OnEvent, this, std::placeholders::_1));
|
||||
this->ventBroker->Subscribe(m_EEventType);
|
||||
Run();
|
||||
Check();
|
||||
}
|
||||
~EventFixture()
|
||||
{
|
||||
this->ventBroker->Unsubscribe(m_EEventType);
|
||||
delete this->ventBroker;
|
||||
}
|
||||
|
||||
EventBroker* ventBroker = nullptr;
|
||||
EventRelay<EventFixture, EventType> m_EEventType;
|
||||
bool m_EventRecieved = false;
|
||||
EventType Before;
|
||||
EventType After;
|
||||
|
||||
bool OnEvent(const EventType& event)
|
||||
{
|
||||
m_EventRecieved = true;
|
||||
After = event;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Run()
|
||||
{
|
||||
// Publish the event
|
||||
this->ventBroker->Publish(Before);
|
||||
// Clear to swap buffers
|
||||
this->ventBroker->Swap();
|
||||
// Process the event
|
||||
this->ventBroker->template Process<EventFixture>();
|
||||
}
|
||||
|
||||
void Check()
|
||||
{
|
||||
BOOST_CHECK(m_EventRecieved);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include "EventFixture.h"
|
||||
|
||||
struct ETestEvent : public Event
|
||||
{
|
||||
int Int = 5;
|
||||
float Float = 1.33333f;
|
||||
double Double = 1.33333;
|
||||
std::string String = "Hello World";
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(EventBrokerTest)
|
||||
{
|
||||
EventFixture<ETestEvent> f;
|
||||
BOOST_CHECK(f.Before.Int == f.After.Int);
|
||||
BOOST_CHECK_CLOSE(f.Before.Float, f.After.Float, 0.00001f);
|
||||
BOOST_CHECK_CLOSE(f.Before.Double, f.After.Double, 0.00001f);
|
||||
BOOST_CHECK(f.Before.String == f.After.String);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include "Engine\Core\InputManager.h"
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(inputManagerTests)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(inputManagerTest)
|
||||
{
|
||||
//already tested eventbroker so inputManager is indirectly already tested
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
@@ -34,16 +34,12 @@ BOOST_AUTO_TEST_CASE(octTreeTest)
|
||||
BOOST_CHECK(someAABB.MaxCorner() == maxCorner);
|
||||
BOOST_CHECK(someAABB.Center() == 0.5f * (minCorner + maxCorner));
|
||||
|
||||
//simple OctTree constructor check
|
||||
//OctTree someOctTree(someAABB, 5);
|
||||
//BOOST_CHECK(someOctTree.m_Children[0] != nullptr);
|
||||
|
||||
//simple destructor check in the end, just look for memleaks, then it didnt clear the AABB structure
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(octTreeTest2)
|
||||
{
|
||||
//octtree ritningen osv
|
||||
//octtree draw etc
|
||||
Game game(0, nullptr);
|
||||
while (game.Running()) {
|
||||
game.Tick();
|
||||
|
||||
@@ -5,6 +5,8 @@ Game::Game(int argc, char* argv[]) : someOctTree(AABB(-0.5f*worldSize, 0.5f*worl
|
||||
ResourceManager::RegisterType<ConfigFile>("ConfigFile");
|
||||
ResourceManager::RegisterType<Model>("Model");
|
||||
ResourceManager::RegisterType<Texture>("Texture");
|
||||
ResourceManager::RegisterType<EntityXMLFile>("EntityXMLFile");
|
||||
ResourceManager::RegisterType<ShaderProgram>("ShaderProgram");
|
||||
|
||||
m_Config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||
LOG_LEVEL = static_cast<_LOG_LEVEL>(m_Config->Get<int>("Debug.LogLevel", 1));
|
||||
@@ -25,9 +27,14 @@ Game::Game(int argc, char* argv[]) : someOctTree(AABB(-0.5f*worldSize, 0.5f*worl
|
||||
m_Config->Get<int>("Video.Height", 720)
|
||||
));
|
||||
m_Renderer->Initialize();
|
||||
m_Renderer->Camera()->SetFOV(glm::radians(m_Config->Get<float>("Video.FOV", 90.f)));
|
||||
|
||||
// Create input manager
|
||||
m_InputManager = new InputManager(m_Renderer->Window(), m_EventBroker);
|
||||
m_InputProxy = new InputProxy(m_EventBroker);
|
||||
m_InputProxy->AddHandler<KeyboardInputHandler>();
|
||||
m_InputProxy->AddHandler<MouseInputHandler>();
|
||||
m_InputProxy->LoadBindings("Input.ini");
|
||||
|
||||
// Create the root level GUI frame
|
||||
m_FrameStack = new GUI::Frame(m_EventBroker);
|
||||
@@ -37,6 +44,9 @@ Game::Game(int argc, char* argv[]) : someOctTree(AABB(-0.5f*worldSize, 0.5f*worl
|
||||
// Create a TEST WORLD
|
||||
m_World = new HardcodedTestWorld();
|
||||
|
||||
m_SystemPipeline = new SystemPipeline(m_EventBroker);
|
||||
m_SystemPipeline->AddSystem<PlayerSystem>();
|
||||
|
||||
m_LastTime = glfwGetTime();
|
||||
}
|
||||
|
||||
@@ -52,9 +62,14 @@ void Game::Tick()
|
||||
double dt = currentTime - m_LastTime;
|
||||
m_LastTime = currentTime;
|
||||
|
||||
// Handle input in a weird looking but responsive way
|
||||
m_EventBroker->Process<InputManager>();
|
||||
m_EventBroker->Swap();
|
||||
m_InputManager->Update(dt);
|
||||
m_Renderer->Update(dt);
|
||||
m_EventBroker->Swap();
|
||||
m_InputProxy->Update(dt);
|
||||
m_EventBroker->Swap();
|
||||
m_InputProxy->Process();
|
||||
m_EventBroker->Swap();
|
||||
|
||||
#define TEST1
|
||||
@@ -70,7 +85,7 @@ void Game::Tick()
|
||||
AABB boxi;
|
||||
boxi.CreateFromCenter(pos, maxPos - minPos);
|
||||
frameCounter++;
|
||||
if (frameCounter > 50) {
|
||||
if (frameCounter > 1) {
|
||||
m_World->someOctTree.ClearDynamicObjects();
|
||||
m_World->someOctTree.AddDynamicObject(boxi);
|
||||
frameCounter = 0;
|
||||
@@ -149,8 +164,8 @@ void Game::Tick()
|
||||
if (someOctTree.BoxCollides(redBox, AABB())) {
|
||||
//this checks AABB vs AABB
|
||||
//if (Collision::AABBVsAABB(redBox, aabb)) {
|
||||
m_Renderer->Camera()->SetPosition(m_PrevPos);
|
||||
m_Renderer->Camera()->SetOrientation(m_PrevOri);
|
||||
//m_Renderer->Camera()->SetPosition(m_PrevPos);
|
||||
//m_Renderer->Camera()->SetOrientation(m_PrevOri);
|
||||
model["Color"] = greenCol;
|
||||
}
|
||||
else {
|
||||
@@ -163,8 +178,14 @@ void Game::Tick()
|
||||
m_RenderQueueFactory->Update(m_World);
|
||||
#endif
|
||||
|
||||
m_Renderer->Draw(m_RenderQueueFactory->RenderQueues());
|
||||
// Iterate through systems and update world!
|
||||
m_SystemPipeline->Update(m_World, dt);
|
||||
m_Renderer->Update(dt);
|
||||
|
||||
m_RenderQueueFactory->Update(m_World);
|
||||
GLERROR("Game::Tick m_RenderQueueFactory->Update");
|
||||
m_Renderer->Draw(m_RenderQueueFactory->RenderQueues());
|
||||
GLERROR("Game::Tick m_Renderer->Draw");
|
||||
m_EventBroker->Swap();
|
||||
m_EventBroker->Clear();
|
||||
|
||||
|
||||
@@ -9,11 +9,19 @@
|
||||
#include "GUI/Frame.h"
|
||||
#include "Core/World.h"
|
||||
#include "Rendering/RenderQueueFactory.h"
|
||||
#include "Input/InputProxy.h"
|
||||
#include "Input/KeyboardInputHandler.h"
|
||||
#include "Input/MouseInputHandler.h"
|
||||
#include "Core/EKeyDown.h"
|
||||
#include "Core/EntityXMLFile.h"
|
||||
#include "Core/SystemPipeline.h"
|
||||
#include "RaptorCopterSystem.h"
|
||||
#include "PlayerSystem.h"
|
||||
#include "Editor/EditorSystem.h"
|
||||
|
||||
#include "OctTreeTestHardCodedTestWorld.h"
|
||||
#include "Collision/Collision.h"
|
||||
|
||||
|
||||
class Game
|
||||
{
|
||||
public:
|
||||
@@ -32,6 +40,8 @@ private:
|
||||
GUI::Frame* m_FrameStack;
|
||||
HardcodedTestWorld* m_World;
|
||||
RenderQueueFactory* m_RenderQueueFactory;
|
||||
InputProxy* m_InputProxy;
|
||||
SystemPipeline* m_SystemPipeline;
|
||||
|
||||
//Test1
|
||||
int frameCounter = 0;
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include "Core/World.h"
|
||||
|
||||
//private->public hack doesnt work, tons of link errors
|
||||
//so there is currently no good way to test this class
|
||||
//#define private public
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Core/ConfigFile.h"
|
||||
#include "Rendering/Renderer.h"
|
||||
#include "Core/EntityXMLFile.h"
|
||||
#include "Engine\Rendering\Texture.h"
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(resourceManagerTests)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(resourceManagerTest)
|
||||
{
|
||||
World m_World;
|
||||
|
||||
//private static metoder/variabler
|
||||
|
||||
ResourceManager::RegisterType<ConfigFile>("ConfigFile");
|
||||
BOOST_CHECK(!ResourceManager::IsResourceLoaded("ConfigFile", "Config.ini"));
|
||||
auto m_Config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||
BOOST_CHECK(ResourceManager::IsResourceLoaded("ConfigFile", "Config.ini"));
|
||||
ResourceManager::Release("ConfigFile", "Config.ini");
|
||||
BOOST_CHECK(!ResourceManager::IsResourceLoaded("ConfigFile", "Config.ini"));
|
||||
|
||||
//configfile without register
|
||||
//check so output says "EE failed to load: type not registered..."
|
||||
auto m_ScreenQuadNoRegister = ResourceManager::Load<Model>("Models/Core/ScreenQuad.obj");
|
||||
BOOST_CHECK(!ResourceManager::IsResourceLoaded("Model", "Models/Core/ScreenQuad.obj"));
|
||||
|
||||
//there is no error feedback to check if you try to release the wrong resources - hence that cant be tested either
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
Reference in New Issue
Block a user