Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/system/ComponentTest.h
Show All 23 Lines | |||||
#include "ps/XML/Xeromyces.h" | #include "ps/XML/Xeromyces.h" | ||||
#include "simulation2/MessageTypes.h" | #include "simulation2/MessageTypes.h" | ||||
#include "simulation2/system/Component.h" | #include "simulation2/system/Component.h" | ||||
#include "simulation2/components/ICmpTerrain.h" | #include "simulation2/components/ICmpTerrain.h" | ||||
#include "simulation2/serialization/DebugSerializer.h" | #include "simulation2/serialization/DebugSerializer.h" | ||||
#include "simulation2/serialization/HashSerializer.h" | #include "simulation2/serialization/HashSerializer.h" | ||||
#include "simulation2/serialization/StdSerializer.h" | #include "simulation2/serialization/StdSerializer.h" | ||||
#include "simulation2/serialization/StdDeserializer.h" | #include "simulation2/serialization/StdDeserializer.h" | ||||
#include "simulation2/system/SimSynchronization.h" | |||||
#include <iostream> | #include <iostream> | ||||
/** | /** | ||||
* @file | * @file | ||||
* Various common features for component test cases. | * Various common features for component test cases. | ||||
*/ | */ | ||||
/** | /** | ||||
* Class to test a single component. | * Class to test a single component. | ||||
* - Create an instance of this class | * - Create an instance of this class | ||||
* - Use AddMock to add mock components that the tested component relies on | * - Use AddMock to add mock components that the tested component relies on | ||||
* - Use Add to add the test component itself, and it returns a component pointer | * - Use Add to add the test component itself, and it returns a component pointer | ||||
* - Call methods on the component pointer | * - Call methods on the component pointer | ||||
* - Use Roundtrip to test the consistency of serialization | * - Use Roundtrip to test the consistency of serialization | ||||
*/ | */ | ||||
class ComponentTestHelper | class ComponentTestHelper | ||||
{ | { | ||||
CSimContext m_Context; | CSimContext m_Context; | ||||
CComponentManager m_ComponentManager; | CComponentManager m_ComponentManager; | ||||
CParamNode m_Param; | CParamNode m_Param; | ||||
SSimSynchronization m_SynchronizationData; | |||||
IComponent* m_Cmp; | IComponent* m_Cmp; | ||||
EComponentTypeId m_Cid; | EComponentTypeId m_Cid; | ||||
bool m_isSystemEntityInit = false; | bool m_isSystemEntityInit = false; | ||||
public: | public: | ||||
ComponentTestHelper(shared_ptr<ScriptContext> scriptContext) : | ComponentTestHelper(shared_ptr<ScriptContext> scriptContext) : | ||||
m_Context(), m_ComponentManager(m_Context, scriptContext), m_Cmp(NULL) | m_Context(), m_ComponentManager(m_Context, scriptContext), m_Cmp(NULL) | ||||
{ | { | ||||
m_Context.m_SynchronizationData = &m_SynchronizationData; | |||||
m_ComponentManager.LoadComponentTypes(); | m_ComponentManager.LoadComponentTypes(); | ||||
} | } | ||||
const ScriptInterface& GetScriptInterface() | const ScriptInterface& GetScriptInterface() | ||||
{ | { | ||||
return m_ComponentManager.GetScriptInterface(); | return m_ComponentManager.GetScriptInterface(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 182 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator