|
class OwnershipTestDummyClass |
|
{ |
|
|
|
} |
|
|
|
class PMTCreationAndCleanup : PMTF |
|
{ |
|
int m_EventTestManagerID; |
|
bool m_bTestEventsPassed = false; |
|
|
|
int m_OwnershipTestManagerID; |
|
|
|
|
|
|
|
|
|
void PMTCreationAndCleanup() |
|
{ |
|
|
|
AddInitTest("TestCCSB"); |
|
AddInitTest("TestEvents"); |
|
AddInitTest("TestOwnership"); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
TFResult TestInvalidSize() |
|
{ |
|
Debug.ParticleLog("Expecting VME: Invalid size. (0)", this, "TestInvalidSize"); |
|
TestCreationSmallBlocking(0, false); |
|
|
|
Debug.ParticleLog("Expecting VME: Invalid size. (-3)", this, "TestInvalidSize"); |
|
TestCreationSmallBlocking(-3, false); |
|
|
|
return NTFR(TFR.SUCCESS); |
|
} |
|
|
|
|
|
|
|
TFResult TestCCSB() |
|
{ |
|
return TestCleanup("TestMultiCreation", 3000); |
|
} |
|
|
|
|
|
|
|
TFResult TestEvents() |
|
{ |
|
ParticleManager pm = new ParticleManager(new ParticleManagerSettings(3000)); |
|
bool success = !pm.IsFinishedAllocating(); |
|
if (Assert(success)) |
|
{ |
|
pm.GetEvents().Event_OnAllocationEnd.Insert(PassCheckEvents); |
|
|
|
m_EventTestManagerID = InsertManager(pm); |
|
AddFrameTest("CheckTestEvents"); |
|
|
|
return NTFR(TFR.SUCCESS); |
|
} |
|
|
|
return NTFR(TFR.FAIL); |
|
} |
|
|
|
|
|
|
|
TFResult TestOwnership() |
|
{ |
|
ParticleManager pm = CreatePMFixedBlocking(1); |
|
bool success = pm.IsFinishedAllocating(); |
|
if (Assert(success)) |
|
{ |
|
m_OwnershipTestManagerID = InsertManager(pm); |
|
OwnershipTestDummyClass dummy = new OwnershipTestDummyClass(); |
|
|
|
ParticleProperties pp = new ParticleProperties(GetGame().GetPlayer().GetPosition(), ParticlePropertiesFlags.NONE, null, vector.Zero, dummy); |
|
string particlePath = ParticleList.GetParticleFullPath(ParticleList.EXPLOSION_LANDMINE); |
|
|
|
bool result = Assert(pm.CreateParticleByPath(particlePath, pp) != null); |
|
Debug.ParticleLog("Expecting VME: All particles in pool are already used.", this, "TestOwnership"); |
|
result &= Assert(pm.CreateParticleByPath(particlePath, pp) == null); |
|
delete dummy; |
|
result &= Assert(pm.CreateParticleByPath(particlePath, pp) != null); |
|
|
|
return BTFR(result); |
|
} |
|
|
|
return NTFR(TFR.FAIL); |
|
} |
|
|
|
|
|
|
|
|
|
TFResult CheckTestEvents() |
|
{ |
|
ParticleManager pm; |
|
if (GetManager(m_EventTestManagerID, pm)) |
|
{ |
|
if (pm) |
|
{ |
|
if (pm.IsFinishedAllocating()) |
|
{ |
|
return BTFR(Assert(m_bTestEventsPassed)); |
|
} |
|
} |
|
else |
|
{ |
|
return BTFR(Assert(false)); |
|
} |
|
} |
|
else |
|
{ |
|
return BTFR(Assert(false)); |
|
} |
|
|
|
return NTFR(TFR.PENDING); |
|
} |
|
|
|
|
|
|
|
|
|
void PassCheckEvents(ParticleManager pm) |
|
{ |
|
Assert(pm.IsFinishedAllocating()); |
|
m_bTestEventsPassed = true; |
|
} |
|
|
|
|
|
|
|
|
|
TFResult TestCreationSmallBlocking(int size, bool enableAsserts = true) |
|
{ |
|
|
|
ParticleManager pm = CreatePMFixedBlocking(size); |
|
PrintPMStats(pm); |
|
|
|
bool success = true; |
|
|
|
if (enableAsserts) |
|
{ |
|
success &= Assert(pm.GetPoolSize() == size); |
|
success &= Assert(pm.GetAllocatedCount() == size); |
|
success &= Assert(pm.GetEvents() != null); |
|
} |
|
|
|
return BTFR(success); |
|
} |
|
|
|
TFResult TestCleanup(string f, int p1 = 0) |
|
{ |
|
int pmTotal = ParticleManager.GetStaticActiveCount(); |
|
int psTotal = ParticleSource.GetStaticActiveCount(); |
|
|
|
PrintActiveStats(); |
|
|
|
TFResult res = CTFR(); |
|
|
|
GetGame().GameScript.CallFunction(this, f, res, p1); |
|
|
|
int pmTotalPost = ParticleManager.GetStaticActiveCount(); |
|
int psTotalPost = ParticleSource.GetStaticActiveCount(); |
|
|
|
PrintActiveStats(); |
|
|
|
bool success = Assert(pmTotal == pmTotalPost); |
|
success &= Assert(psTotal == psTotalPost); |
|
|
|
return res.And(BTFR(success)); |
|
} |
|
|
|
TFResult TestMultiCreation(int instances) |
|
{ |
|
TFResult res = CTFR(); |
|
for (int i = 0; i < instances; ++i) |
|
{ |
|
res.And(TestCreationSmallBlocking(1)); |
|
} |
|
return res; |
|
} |
|
} |