The tests seems to work under boost 1.59 but test explorer window is broken in 1.60. also changed ResourceManagerTest.cpp
This commit is contained in:
@@ -12,6 +12,7 @@ include_directories(
|
||||
)
|
||||
|
||||
file(GLOB SOURCE_FILES
|
||||
"${INCLUDE_PATH}/Tests/*.h"
|
||||
"*.cpp"
|
||||
)
|
||||
|
||||
|
||||
@@ -16,53 +16,50 @@ BOOST_AUTO_TEST_SUITE(confTest)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(configFileTest)
|
||||
{
|
||||
////note: this ConfigFileclass currently has memleaks!
|
||||
//note: this ConfigFileclass currently has memleaks!
|
||||
|
||||
//ResourceManager::RegisterType<ConfigFile>("ConfigFile");
|
||||
//auto m_Config = ResourceManager::Load<ConfigFile>("ConfigTest.ini");
|
||||
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"
|
||||
//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);
|
||||
//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!\"");
|
||||
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);
|
||||
//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");
|
||||
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");
|
||||
//***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");
|
||||
//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");
|
||||
|
||||
////test to try to fix memleaks - failed, probably something else
|
||||
////ResourceManager::Release(std::string("ConfigFile"), std::string("ConfigTest.ini"));
|
||||
////ResourceManager::Release(std::string("ConfigFile"), std::string("ConfigTestNotExists.ini"));
|
||||
////ResourceManager::Release(std::string("ConfigFile"), std::string("ConfigTest.ini"));
|
||||
////ResourceManager::Release(std::string("ConfigFile"), std::string("ConfigTestFailed.ini"));
|
||||
////reload,onchildreload unimplemented
|
||||
//_CrtDumpMemoryLeaks();
|
||||
//reload,onchildreload unimplemented
|
||||
|
||||
//NOTE:still massive amount of memoryleaks from this method
|
||||
_CrtDumpMemoryLeaks();
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
#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
|
||||
@@ -1,51 +0,0 @@
|
||||
#ifndef Game_h__
|
||||
#define Game_h__
|
||||
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Core/ConfigFile.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Rendering/Renderer.h"
|
||||
#include "Core/InputManager.h"
|
||||
#include "GUI/Frame.h"
|
||||
#include "Core/World.h"
|
||||
#include "Rendering/RenderQueueFactory.h"
|
||||
|
||||
#include "OctTreeTestHardCodedTestWorld.h"
|
||||
#include "Core\Collision.h"
|
||||
|
||||
class Game
|
||||
{
|
||||
public:
|
||||
Game(int argc, char* argv[]);
|
||||
~Game();
|
||||
|
||||
bool Running() const { return !glfwWindowShouldClose(m_Renderer->Window()); }
|
||||
void Tick();
|
||||
|
||||
private:
|
||||
double m_LastTime;
|
||||
ConfigFile* m_Config = nullptr;
|
||||
EventBroker* m_EventBroker;
|
||||
IRenderer* m_Renderer;
|
||||
InputManager* m_InputManager;
|
||||
GUI::Frame* m_FrameStack;
|
||||
HardcodedTestWorld* m_World;
|
||||
RenderQueueFactory* m_RenderQueueFactory;
|
||||
|
||||
//Test1
|
||||
int frameCounter = 0;
|
||||
glm::vec3 minPos = glm::vec3(0.1f, 0.1f, 0.1f);
|
||||
glm::vec3 maxPos = glm::vec3(0.2f, 0.2f, 0.2f);
|
||||
|
||||
//Test2
|
||||
bool m_UpdatedOnce = false;
|
||||
unsigned int m_BoxID;
|
||||
glm::vec3 m_PrevPos;
|
||||
glm::quat m_PrevOri;
|
||||
|
||||
glm::vec3 worldSize = glm::vec3(50, 50, 50);
|
||||
OctTree someOctTree;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,134 +0,0 @@
|
||||
#include <list>
|
||||
#include <tuple>
|
||||
#include <boost/any.hpp>
|
||||
#include "GLM.h"
|
||||
#include "Core/World.h"
|
||||
#include "Core/Util/Any.h"
|
||||
|
||||
#include <vector>
|
||||
//last!
|
||||
#define private public
|
||||
#include <Engine\Core\OctTree.h>
|
||||
|
||||
class HardcodedTestWorld : public World
|
||||
{
|
||||
public:
|
||||
struct LinkOctTreeAndModel {
|
||||
EntityID entId;
|
||||
OctTree* child;
|
||||
glm::vec3 posxyz;
|
||||
LinkOctTreeAndModel(EntityID eId, OctTree* ch, glm::vec3 pos)
|
||||
{
|
||||
entId = eId;
|
||||
child = ch;
|
||||
posxyz = pos;
|
||||
}
|
||||
};
|
||||
EntityID anotherBoxTransformId;
|
||||
std::vector<LinkOctTreeAndModel> linkOM;
|
||||
OctTree someOctTree;
|
||||
|
||||
//constructor
|
||||
HardcodedTestWorld()
|
||||
: World()
|
||||
, someOctTree(AABB(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(1.0f, 1.0f, 1.0f)), 2)
|
||||
{
|
||||
registerTestComponents();
|
||||
//createTestEntities();
|
||||
}
|
||||
|
||||
private:
|
||||
void registerTestComponents()
|
||||
{
|
||||
ComponentWrapperFactory f;
|
||||
|
||||
|
||||
f = ComponentWrapperFactory("Test");
|
||||
f.AddProperty("TestInteger", 1337);
|
||||
f.AddProperty("TestFloat", 13.37f);
|
||||
f.AddProperty("TestString", std::string("Carlito"));
|
||||
RegisterComponent(f);
|
||||
|
||||
f = ComponentWrapperFactory("Debug");
|
||||
f.AddProperty("Name", std::string("Unnamed"));
|
||||
RegisterComponent(f);
|
||||
|
||||
f = ComponentWrapperFactory("Transform");
|
||||
f.AddProperty("Position", glm::vec3(0.f, 0.f, 0.f));
|
||||
f.AddProperty("Orientation", glm::quat());
|
||||
f.AddProperty("Scale", glm::vec3(1.f, 1.f, 1.f));
|
||||
RegisterComponent(f);
|
||||
|
||||
f = ComponentWrapperFactory("Model");
|
||||
f.AddProperty("Resource", std::string());
|
||||
f.AddProperty("Color", glm::vec4(1.f, 1.f, 1.f, 1.f));
|
||||
f.AddProperty("Visible", true);
|
||||
RegisterComponent(f);
|
||||
}
|
||||
|
||||
void createTestEntitiesTest1()
|
||||
{
|
||||
World& world = *this;
|
||||
EntityID tempId;
|
||||
//add octTree
|
||||
{
|
||||
//copy of mainbox
|
||||
auto someAABB = AABB(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(1.0f, 1.0f, 1.0f));
|
||||
|
||||
//draw main box first
|
||||
AddBoxModel(someAABB.Center(), someAABB.HalfSize().x, &someOctTree, tempId);
|
||||
|
||||
//add anotherbox in octTree
|
||||
auto anotherBox = AABB(glm::vec3(0.1f, 0.1f, 0.1f), glm::vec3(0.2f, 0.2f, 0.2f));
|
||||
//note: have to delete the box in the tree first, since were trying to move the box
|
||||
someOctTree.AddDynamicObject(anotherBox);
|
||||
|
||||
//draw anotherbox and save it in anotherBoxTransformId
|
||||
AddBoxModel(anotherBox.Center(), anotherBox.HalfSize().x, &someOctTree, anotherBoxTransformId);
|
||||
|
||||
//draw the octTree
|
||||
for (size_t j = 0; j < 8; j++)
|
||||
{
|
||||
AddBoxModel(someOctTree.m_Children[j]->m_Box.Center(),
|
||||
someOctTree.m_Children[j]->m_Box.HalfSize().x, someOctTree.m_Children[j], tempId);
|
||||
|
||||
auto someChild = someOctTree.m_Children[j];
|
||||
|
||||
for (size_t i = 0; i < 8; i++)
|
||||
{
|
||||
AddBoxModel(someChild->m_Children[i]->m_Box.Center(),
|
||||
someChild->m_Children[i]->m_Box.HalfSize().x, someChild->m_Children[i], tempId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}//end CreateEnt
|
||||
|
||||
void AddBoxModel(const glm::vec3 ¢er, const float &halfSize, OctTree* child, EntityID &outEntityId) {
|
||||
World& world = *this;
|
||||
|
||||
EntityID entityDummyScene = world.CreateEntity();
|
||||
outEntityId = entityDummyScene;
|
||||
ComponentWrapper transform = world.AttachComponent(entityDummyScene, "Transform");
|
||||
transform["Position"] = center;
|
||||
transform["Scale"] = glm::vec3(1.0f, 1.0f, 1.0f)*halfSize*2.0f*0.97f;
|
||||
ComponentWrapper model = world.AttachComponent(entityDummyScene, "Model");
|
||||
model["Resource"] = "Models/Core/UnitBox.obj";
|
||||
model["Color"] = glm::vec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
if (child->m_DynamicObjects.size() != 0)
|
||||
model["Color"] = glm::vec4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
linkOM.emplace_back(entityDummyScene, child, center);
|
||||
//extra
|
||||
//allModels.push_back(model);
|
||||
}
|
||||
void createTestEntitiesTest2()
|
||||
{
|
||||
World& world = *this;
|
||||
|
||||
EntityID entityCollisionBox = world.CreateEntity();
|
||||
ComponentWrapper transform = world.AttachComponent(entityCollisionBox, "Transform");
|
||||
transform["Position"] = glm::vec3(0.f, 2.f, 0.f);
|
||||
ComponentWrapper model = world.AttachComponent(entityCollisionBox, "Model");
|
||||
model["Resource"] = "Models/Core/UnitBox.obj";
|
||||
}
|
||||
};
|
||||
@@ -1,25 +1,15 @@
|
||||
#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"
|
||||
|
||||
//#include "Core/EventBroker.h"
|
||||
//#include "Core/InputManager.h"
|
||||
//#include "GUI/Frame.h"
|
||||
//#include "Rendering/RenderQueueFactory.h"
|
||||
//#include "Core/EKeyDown.h"
|
||||
//#include "Core/SystemPipeline.h"
|
||||
//#include "RaptorCopterSystem.h"
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(resourceManagerTests)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(resourceManagerTest)
|
||||
@@ -28,10 +18,6 @@ BOOST_AUTO_TEST_CASE(resourceManagerTest)
|
||||
|
||||
//private static metoder/variabler
|
||||
|
||||
//ugly private->public hack doesnt work, tons of link errors. hence cant test it properly
|
||||
//its not my job to implement testfunctions for unittests in the class either
|
||||
|
||||
//craptests ahead:
|
||||
ResourceManager::RegisterType<ConfigFile>("ConfigFile");
|
||||
BOOST_CHECK(!ResourceManager::IsResourceLoaded("ConfigFile", "Config.ini"));
|
||||
auto m_Config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||
@@ -45,12 +31,6 @@ BOOST_AUTO_TEST_CASE(resourceManagerTest)
|
||||
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
|
||||
|
||||
//registertype (bind with function)
|
||||
//m_CompilerTypenameToResourceType = global...
|
||||
//m_FactoryFunctions = global...
|
||||
//BOOST_CHECK(ResourceManager::m_CompilerTypenameToResourceType.size() != 0);
|
||||
//BOOST_CHECK(ResourceManager::m_FactoryFunctions.size() != 0);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
Reference in New Issue
Block a user