Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/tests/test_ComponentManager.h
Show First 20 Lines • Show All 611 Lines • ▼ Show 20 Lines | void test_script_hotload() | ||||
man.AddComponent(hnd3, man.LookupCID("HotloadA"), testParam); | man.AddComponent(hnd3, man.LookupCID("HotloadA"), testParam); | ||||
man.AddComponent(hnd4, man.LookupCID("HotloadB"), testParam); | man.AddComponent(hnd4, man.LookupCID("HotloadB"), testParam); | ||||
TS_ASSERT_EQUALS(static_cast<ICmpTest1*> (man.QueryInterface(ent3, IID_Test1))->GetX(), 1000); | TS_ASSERT_EQUALS(static_cast<ICmpTest1*> (man.QueryInterface(ent3, IID_Test1))->GetX(), 1000); | ||||
TS_ASSERT_EQUALS(static_cast<ICmpTest1*> (man.QueryInterface(ent4, IID_Test1))->GetX(), 200); | TS_ASSERT_EQUALS(static_cast<ICmpTest1*> (man.QueryInterface(ent4, IID_Test1))->GetX(), 200); | ||||
} | } | ||||
void test_script_modding() | |||||
Itms: This test checks that one can redefine scripted components when modding, using `Engine. | |||||
wraitiiUnsubmitted Not Done Inline ActionsMaybe a separate "test" commit then? wraitii: Maybe a separate "test" commit then? | |||||
ItmsAuthorUnsubmitted Done Inline ActionsOK. Itms: OK. | |||||
{ | |||||
CSimContext context; | |||||
CComponentManager man(context, g_ScriptRuntime); | |||||
man.LoadComponentTypes(); | |||||
CParamNode testParam; | |||||
TS_ASSERT_EQUALS(CParamNode::LoadXMLString(testParam, "<x>100</x>"), PSRETURN_OK); | |||||
entity_id_t ent1 = 1, ent2 = 2; | |||||
CEntityHandle hnd1 = man.AllocateEntityHandle(ent1); | |||||
CEntityHandle hnd2 = man.AllocateEntityHandle(ent2); | |||||
TS_ASSERT(man.LoadScript(L"simulation/components/test-modding1.js")); | |||||
man.AddComponent(hnd1, man.LookupCID("Modding"), testParam); | |||||
TS_ASSERT_EQUALS(static_cast<ICmpTest1*> (man.QueryInterface(ent1, IID_Test1))->GetX(), 100); | |||||
TS_ASSERT(man.LoadScript(L"simulation/components/test-modding2.js")); | |||||
TS_ASSERT_EQUALS(static_cast<ICmpTest1*> (man.QueryInterface(ent1, IID_Test1))->GetX(), 1000); | |||||
man.AddComponent(hnd2, man.LookupCID("Modding"), testParam); | |||||
TS_ASSERT_EQUALS(static_cast<ICmpTest1*> (man.QueryInterface(ent2, IID_Test1))->GetX(), 1000); | |||||
} | |||||
void test_serialization() | void test_serialization() | ||||
{ | { | ||||
CSimContext context; | CSimContext context; | ||||
CComponentManager man(context, g_ScriptRuntime); | CComponentManager man(context, g_ScriptRuntime); | ||||
man.LoadComponentTypes(); | man.LoadComponentTypes(); | ||||
entity_id_t ent1 = 10, ent2 = 20, ent3 = FIRST_LOCAL_ENTITY; | entity_id_t ent1 = 10, ent2 = 20, ent3 = FIRST_LOCAL_ENTITY; | ||||
CEntityHandle hnd1 = man.AllocateEntityHandle(ent1); | CEntityHandle hnd1 = man.AllocateEntityHandle(ent1); | ||||
▲ Show 20 Lines • Show All 252 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
This test checks that one can redefine scripted components when modding, using Engine.ReRegisterComponent, even outside of hotloading. I think this useful function wasn't covered by the tests until now.