DayZ 1.24
Loading...
Searching...
No Matches
PMTCreationAndCleanup.c File Reference

Go to the source code of this file.

Classes

class  OwnershipTestDummyClass
 

Functions

void PMTCreationAndCleanup ()
 
TFResult TestInvalidSize ()
 
TFResult TestCCSB ()
 
TFResult TestEvents ()
 
TFResult TestOwnership ()
 
TFResult CheckTestEvents ()
 
void PassCheckEvents (ParticleManager pm)
 
TFResult TestCreationSmallBlocking (int size, bool enableAsserts=true)
 
TFResult TestCleanup (string f, int p1=0)
 
TFResult TestMultiCreation (int instances)
 

Variables

class OwnershipTestDummyClass m_EventTestManagerID
 
bool m_bTestEventsPassed = false
 
int m_OwnershipTestManagerID
 

Function Documentation

◆ CheckTestEvents()

TFResult CheckTestEvents ( )

Definition at line 94 of file PMTCreationAndCleanup.c.

95 {
97 if (GetManager(m_EventTestManagerID, pm))
98 {
99 if (pm)
100 {
101 if (pm.IsFinishedAllocating())
103 }
104 else
105 return BTFR(Assert(false));
106 }
107 else
108 return BTFR(Assert(false));
109
110 return NTFR(TFR.PENDING);
111 }
class OwnershipTestDummyClass m_EventTestManagerID
bool m_bTestEventsPassed
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
TFResult NTFR(TFR result)
bool Assert(bool condition)
TFR
TFResult BTFR(bool result)

References Assert(), BTFR(), PMTF::GetManager(), m_bTestEventsPassed, m_EventTestManagerID, NTFR(), and ParticleManager().

◆ PassCheckEvents()

void PassCheckEvents ( ParticleManager pm)

Definition at line 116 of file PMTCreationAndCleanup.c.

117 {
118 Assert(pm.IsFinishedAllocating());
119 m_bTestEventsPassed = true;
120 }

References Assert(), and m_bTestEventsPassed.

Referenced by TestEvents().

◆ PMTCreationAndCleanup()

void PMTCreationAndCleanup ( )

Definition at line 16 of file PMTCreationAndCleanup.c.

17 {
18 //AddInitTest("TestInvalidSize");
19 AddInitTest("TestCCSB");
20 AddInitTest("TestEvents");
21 AddInitTest("TestOwnership");
22 }
void AddInitTest(string test)

References AddInitTest().

◆ TestCCSB()

TFResult TestCCSB ( )

Definition at line 41 of file PMTCreationAndCleanup.c.

42 {
43 return TestCleanup("TestMultiCreation", 3000);
44 }
TFResult TestCleanup(string f, int p1=0)

References TestCleanup().

◆ TestCleanup()

TFResult TestCleanup ( string f,
int p1 = 0 )

Definition at line 143 of file PMTCreationAndCleanup.c.

144 {
145 int pmTotal = ParticleManager.GetStaticActiveCount();
147
148 PrintActiveStats();
149
150 TFResult res = CTFR();
151
152 GetGame().GameScript.CallFunction(this, f, res, p1);
153
154 int pmTotalPost = ParticleManager.GetStaticActiveCount();
156
157 PrintActiveStats();
158
161
162 return res.And(BTFR(success));
163 }
TFResult CTFR()
void TFResult(TFR result)
Entity which has the particle instance as an ObjectComponent.
proto static native int GetStaticActiveCount()
Gets the amount of ParticleSource that are currently existing.
proto native CGame GetGame()

References Assert(), BTFR(), CTFR(), GetGame(), ParticleSource::GetStaticActiveCount(), ParticleManager(), PMTF::PrintActiveStats(), and TFResult().

Referenced by TestCCSB().

◆ TestCreationSmallBlocking()

TFResult TestCreationSmallBlocking ( int size,
bool enableAsserts = true )

Definition at line 125 of file PMTCreationAndCleanup.c.

126 {
127 // Blocking, so that we can test AllocatedCount
128 ParticleManager pm = CreatePMFixedBlocking(size);
129 PrintPMStats(pm);
130
131 bool success = true;
132
133 if (enableAsserts)
134 {
135 success &= Assert(pm.GetPoolSize() == size);
136 success &= Assert(pm.GetAllocatedCount() == size);
137 success &= Assert(pm.GetEvents() != null);
138 }
139
140 return BTFR(success);
141 }

References Assert(), BTFR(), PMTF::CreatePMFixedBlocking(), ParticleManager(), and PMTF::PrintPMStats().

Referenced by TestInvalidSize(), and TestMultiCreation().

◆ TestEvents()

TFResult TestEvents ( )

Definition at line 48 of file PMTCreationAndCleanup.c.

49 {
51 bool success = !pm.IsFinishedAllocating(); // We need it to not be done in the same frame
52 if (Assert(success))
53 {
54 pm.GetEvents().Event_OnAllocationEnd.Insert(PassCheckEvents);
55
56 m_EventTestManagerID = InsertManager(pm);
57 AddFrameTest("CheckTestEvents");
58
59 return NTFR(TFR.SUCCESS);
60 }
61
62 return NTFR(TFR.FAIL);
63 }
void PassCheckEvents(ParticleManager pm)
class ParticleManagerConstants ParticleManagerSettings(int poolSize, int flags=ParticleManagerSettingsFlags.NONE)
Settings given to ParticleManager on creation (in ctor)
void AddFrameTest(string test)

References AddFrameTest(), Assert(), PMTF::InsertManager(), m_EventTestManagerID, NTFR(), ParticleManager(), ParticleManagerSettings(), and PassCheckEvents().

◆ TestInvalidSize()

TFResult TestInvalidSize ( )

Definition at line 28 of file PMTCreationAndCleanup.c.

29 {
30 Debug.ParticleLog("Expecting VME: Invalid size. (0)", this, "TestInvalidSize");
32
33 Debug.ParticleLog("Expecting VME: Invalid size. (-3)", this, "TestInvalidSize");
35
36 return NTFR(TFR.SUCCESS); // No way to check if a VME popped or not...
37 }
TFResult TestCreationSmallBlocking(int size, bool enableAsserts=true)
Definition Debug.c:14
static void ParticleLog(string message=LOG_DEFAULT, Managed caller=null, string function="", Managed entity=null)
Definition Debug.c:233

References NTFR(), Debug::ParticleLog(), and TestCreationSmallBlocking().

◆ TestMultiCreation()

TFResult TestMultiCreation ( int instances)

Definition at line 165 of file PMTCreationAndCleanup.c.

166 {
167 TFResult res = CTFR();
168 for (int i = 0; i < instances; ++i)
170 return res;
171 }

References CTFR(), TestCreationSmallBlocking(), and TFResult().

◆ TestOwnership()

TFResult TestOwnership ( )

Definition at line 67 of file PMTCreationAndCleanup.c.

68 {
69 ParticleManager pm = CreatePMFixedBlocking(1);
70 bool success = pm.IsFinishedAllocating(); // We need it to be done in the same frame
71 if (Assert(success))
72 {
73 m_OwnershipTestManagerID = InsertManager(pm);
75
76 ParticleProperties pp = new ParticleProperties(GetGame().GetPlayer().GetPosition(), ParticlePropertiesFlags.NONE, null, vector.Zero, dummy);
78
79 bool result = Assert(pm.CreateParticleByPath(particlePath, pp) != null);
80 Debug.ParticleLog("Expecting VME: All particles in pool are already used.", this, "TestOwnership");
81 result &= Assert(pm.CreateParticleByPath(particlePath, pp) == null);
82 delete dummy;
83 result &= Assert(pm.CreateParticleByPath(particlePath, pp) != null);
84
85 return BTFR(result);
86 }
87
88 return NTFR(TFR.FAIL);
89 }
PlayerBase GetPlayer()
int m_OwnershipTestManagerID
class JsonUndergroundAreaTriggerData GetPosition
static string GetParticleFullPath(int particle_id)
Returns particle's full path (with .ptc suffix) based on its ID.
static const int EXPLOSION_LANDMINE
static const vector Zero
Definition EnConvert.c:110

References Assert(), BTFR(), PMTF::CreatePMFixedBlocking(), ParticleList::EXPLOSION_LANDMINE, GetGame(), ParticleList::GetParticleFullPath(), GetPlayer(), GetPosition, PMTF::InsertManager(), m_OwnershipTestManagerID, NTFR(), Debug::ParticleLog(), ParticleManager(), and vector::Zero.

Variable Documentation

◆ m_bTestEventsPassed

bool m_bTestEventsPassed = false

Definition at line 9 of file PMTCreationAndCleanup.c.

Referenced by CheckTestEvents(), and PassCheckEvents().

◆ m_EventTestManagerID

class OwnershipTestDummyClass m_EventTestManagerID

Referenced by CheckTestEvents(), and TestEvents().

◆ m_OwnershipTestManagerID

int m_OwnershipTestManagerID

Definition at line 11 of file PMTCreationAndCleanup.c.

Referenced by TestOwnership().