DayZ 1.24
Loading...
Searching...
No Matches
PMTCreationAndCleanup.c
Go to the documentation of this file.
2{
3 // Simply exists
4}
5
7{
9 bool m_bTestEventsPassed = false;
10
12
13 //---------------------------------------------------------------------------
14 // Ctor - Decides the tests to run
15 //---------------------------------------------------------------------------
17 {
18 //AddInitTest("TestInvalidSize");
19 AddInitTest("TestCCSB");
20 AddInitTest("TestEvents");
21 AddInitTest("TestOwnership");
22 }
23
24 //---------------------------------------------------------------------------
25 // Tests
26 //---------------------------------------------------------------------------
27 // Test invalid size VMEs
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 }
38
39 //---------------------------------------------------------------------------
40 // TestCreationCleanupSmallBlocking
42 {
43 return TestCleanup("TestMultiCreation", 3000);
44 }
45
46 //---------------------------------------------------------------------------
47 // Test if events are called properly
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
57 AddFrameTest("CheckTestEvents");
58
59 return NTFR(TFR.SUCCESS);
60 }
61
62 return NTFR(TFR.FAIL);
63 }
64
65 //---------------------------------------------------------------------------
66 // Test ownership
68 {
70 bool success = pm.IsFinishedAllocating(); // We need it to be done in the same frame
71 if (Assert(success))
72 {
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 }
90
91 //---------------------------------------------------------------------------
92 // OnFrame Checks
93 //---------------------------------------------------------------------------
95 {
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 }
112
113 //---------------------------------------------------------------------------
114 // Passes
115 //---------------------------------------------------------------------------
117 {
118 Assert(pm.IsFinishedAllocating());
119 m_bTestEventsPassed = true;
120 }
121
122 //---------------------------------------------------------------------------
123 // Helpers
124 //---------------------------------------------------------------------------
126 {
127 // Blocking, so that we can test AllocatedCount
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 }
142
143 TFResult TestCleanup(string f, int p1 = 0)
144 {
145 int pmTotal = ParticleManager.GetStaticActiveCount();
147
149
150 TFResult res = CTFR();
151
152 GetGame().GameScript.CallFunction(this, f, res, p1);
153
154 int pmTotalPost = ParticleManager.GetStaticActiveCount();
156
158
161
162 return res.And(BTFR(success));
163 }
164
166 {
167 TFResult res = CTFR();
168 for (int i = 0; i < instances; ++i)
170 return res;
171 }
172}
PlayerBase GetPlayer()
void PassCheckEvents(ParticleManager pm)
TFResult TestCleanup(string f, int p1=0)
TFResult TestCCSB()
TFResult TestMultiCreation(int instances)
TFResult TestCreationSmallBlocking(int size, bool enableAsserts=true)
class OwnershipTestDummyClass m_EventTestManagerID
TFResult TestOwnership()
void PMTCreationAndCleanup()
TFResult TestEvents()
bool m_bTestEventsPassed
TFResult TestInvalidSize()
int m_OwnershipTestManagerID
TFResult CheckTestEvents()
class ParticleManagerConstants ParticleManagerSettings(int poolSize, int flags=ParticleManagerSettingsFlags.NONE)
Settings given to ParticleManager on creation (in ctor)
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
TFResult NTFR(TFR result)
TFResult CTFR()
bool Assert(bool condition)
void TFResult(TFR result)
TFR
void AddFrameTest(string test)
void AddInitTest(string test)
TFResult BTFR(bool result)
class JsonUndergroundAreaTriggerData GetPosition
Definition Debug.c:14
static void ParticleLog(string message=LOG_DEFAULT, Managed caller=null, string function="", Managed entity=null)
Definition Debug.c:233
Definition PMTF.c:2
bool GetManager(int id, out ParticleManager pm)
Definition PMTF.c:17
void PrintActiveStats()
Definition PMTF.c:32
void PrintPMStats(notnull ParticleManager pm)
Definition PMTF.c:25
int InsertManager(ParticleManager pm)
Definition PMTF.c:9
ParticleManager CreatePMFixedBlocking(int size)
Definition PMTF.c:42
static string GetParticleFullPath(int particle_id)
Returns particle's full path (with .ptc suffix) based on its ID.
static const int EXPLOSION_LANDMINE
Entity which has the particle instance as an ObjectComponent.
proto static native int GetStaticActiveCount()
Gets the amount of ParticleSource that are currently existing.
static const vector Zero
Definition EnConvert.c:110
proto native CGame GetGame()