DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
PMTCreationAndCleanup.c
См. документацию.
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())
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}
PlayerBase GetPlayer()
Определения ModifierBase.c:51
void PassCheckEvents(ParticleManager pm)
Определения PMTCreationAndCleanup.c:122
TFResult TestCleanup(string f, int p1=0)
Определения PMTCreationAndCleanup.c:149
TFResult TestCCSB()
Определения PMTCreationAndCleanup.c:41
TFResult TestMultiCreation(int instances)
Определения PMTCreationAndCleanup.c:171
TFResult TestCreationSmallBlocking(int size, bool enableAsserts=true)
Определения PMTCreationAndCleanup.c:131
class OwnershipTestDummyClass m_EventTestManagerID
TFResult TestOwnership()
Определения PMTCreationAndCleanup.c:67
void PMTCreationAndCleanup()
Определения PMTCreationAndCleanup.c:16
TFResult TestEvents()
Определения PMTCreationAndCleanup.c:48
bool m_bTestEventsPassed
Определения PMTCreationAndCleanup.c:9
TFResult TestInvalidSize()
Определения PMTCreationAndCleanup.c:28
int m_OwnershipTestManagerID
Определения PMTCreationAndCleanup.c:11
TFResult CheckTestEvents()
Определения PMTCreationAndCleanup.c:94
class ParticleManagerConstants ParticleManagerSettings(int poolSize, int flags=ParticleManagerSettingsFlags.NONE)
Settings given to ParticleManager on creation (in ctor)
Определения ParticleManager.c:39
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Определения ParticleManager.c:88
PlayerStats GetManager()
Определения PlayerStatBase.c:198
TFResult NTFR(TFR result)
Определения TestFramework.c:273
TFResult CTFR()
Определения TestFramework.c:286
bool Assert(bool condition)
Определения TestFramework.c:262
void TFResult(TFR result)
Определения TestFramework.c:12
TFR
Определения TestFramework.c:2
void AddFrameTest(string test)
Определения TestFramework.c:254
void AddInitTest(string test)
Определения TestFramework.c:249
TFResult BTFR(bool result)
Определения TestFramework.c:278
ScriptModule GameScript
Определения Game.c:12
static void ParticleLog(string message=LOG_DEFAULT, Managed caller=null, string function="", Managed entity=null)
Определения Debug.c:172
Определения Debug.c:2
void PrintActiveStats()
Определения PMTF.c:32
void PrintPMStats(notnull ParticleManager pm)
Определения PMTF.c:25
int InsertManager(ParticleManager pm)
Определения PMTF.c:9
ParticleManager CreatePMFixedBlocking(int size)
Определения PMTF.c:42
Определения PMTF.c:2
static string GetParticleFullPath(int particle_id)
Returns particle's full path (with .ptc suffix) based on its ID.
Определения ParticleList.c:485
static const int EXPLOSION_LANDMINE
Определения ParticleList.c:267
Определения ParticleList.c:12
proto static native int GetStaticActiveCount()
Gets the amount of ParticleSource that are currently existing.
Entity which has the particle instance as an ObjectComponent.
Определения ParticleSource.c:124
static const vector Zero
Определения EnConvert.c:110
Определения EnConvert.c:106
proto native CGame GetGame()
proto volatile int CallFunction(Class inst, string function, out void returnVal, void parm)
class JsonUndergroundAreaTriggerData GetPosition
Определения UndergroundAreaLoader.c:9