Dayz Explorer 1.28.160049
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
56 m_EventTestManagerID = InsertManager(pm);
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 {
73 m_OwnershipTestManagerID = InsertManager(pm);
75
76 ParticleProperties pp = new ParticleProperties(GetGame().GetPlayer().GetPosition(), ParticlePropertiesFlags.NONE, null, vector.Zero, dummy);
77 string particlePath = ParticleList.GetParticleFullPath(ParticleList.EXPLOSION_LANDMINE);
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())
102 {
104 }
105 }
106 else
107 {
108 return BTFR(Assert(false));
109 }
110 }
111 else
112 {
113 return BTFR(Assert(false));
114 }
115
116 return NTFR(TFR.PENDING);
117 }
118
119 //---------------------------------------------------------------------------
120 // Passes
121 //---------------------------------------------------------------------------
123 {
124 Assert(pm.IsFinishedAllocating());
125 m_bTestEventsPassed = true;
126 }
127
128 //---------------------------------------------------------------------------
129 // Helpers
130 //---------------------------------------------------------------------------
131 TFResult TestCreationSmallBlocking(int size, bool enableAsserts = true)
132 {
133 // Blocking, so that we can test AllocatedCount
135 PrintPMStats(pm);
136
137 bool success = true;
138
139 if (enableAsserts)
140 {
141 success &= Assert(pm.GetPoolSize() == size);
142 success &= Assert(pm.GetAllocatedCount() == size);
143 success &= Assert(pm.GetEvents() != null);
144 }
145
146 return BTFR(success);
147 }
148
149 TFResult TestCleanup(string f, int p1 = 0)
150 {
151 int pmTotal = ParticleManager.GetStaticActiveCount();
152 int psTotal = ParticleSource.GetStaticActiveCount();
153
155
156 TFResult res = CTFR();
157
158 GetGame().GameScript.CallFunction(this, f, res, p1);
159
160 int pmTotalPost = ParticleManager.GetStaticActiveCount();
161 int psTotalPost = ParticleSource.GetStaticActiveCount();
162
164
165 bool success = Assert(pmTotal == pmTotalPost);
166 success &= Assert(psTotal == psTotalPost);
167
168 return res.And(BTFR(success));
169 }
170
172 {
173 TFResult res = CTFR();
174 for (int i = 0; i < instances; ++i)
175 {
176 res.And(TestCreationSmallBlocking(1));
177 }
178 return res;
179 }
180}
Definition debug.c:2
Definition pmtf.c:2
void PrintActiveStats()
Definition pmtf.c:32
void PrintPMStats(notnull ParticleManager pm)
Definition pmtf.c:25
ParticleManager CreatePMFixedBlocking(int size)
Definition pmtf.c:42
Entity which has the particle instance as an ObjectComponent.
proto native CGame GetGame()
class JsonUndergroundAreaTriggerData GetPosition
PlayerBase GetPlayer()
class ParticleManagerConstants ParticleManagerSettings(int poolSize, int flags=ParticleManagerSettingsFlags.NONE)
Settings given to ParticleManager on creation (in ctor)
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
PlayerStats GetManager()
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()
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)