Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
pmtcreationandcleanup.c
Go to the documentation of this file.
1
class
OwnershipTestDummyClass
2
{
3
// Simply exists
4
}
5
6
class
PMTCreationAndCleanup
:
PMTF
7
{
8
int
m_EventTestManagerID
;
9
bool
m_bTestEventsPassed
=
false
;
10
11
int
m_OwnershipTestManagerID
;
12
13
//---------------------------------------------------------------------------
14
// Ctor - Decides the tests to run
15
//---------------------------------------------------------------------------
16
void
PMTCreationAndCleanup
()
17
{
18
//AddInitTest("TestInvalidSize");
19
AddInitTest
(
"TestCCSB"
);
20
AddInitTest
(
"TestEvents"
);
21
AddInitTest
(
"TestOwnership"
);
22
}
23
24
//---------------------------------------------------------------------------
25
// Tests
26
//---------------------------------------------------------------------------
27
// Test invalid size VMEs
28
TFResult
TestInvalidSize
()
29
{
30
Debug
.
ParticleLog
(
"Expecting VME: Invalid size. (0)"
,
this
,
"TestInvalidSize"
);
31
TestCreationSmallBlocking
(0,
false
);
32
33
Debug
.
ParticleLog
(
"Expecting VME: Invalid size. (-3)"
,
this
,
"TestInvalidSize"
);
34
TestCreationSmallBlocking
(-3,
false
);
35
36
return
NTFR
(
TFR
.SUCCESS);
// No way to check if a VME popped or not...
37
}
38
39
//---------------------------------------------------------------------------
40
// TestCreationCleanupSmallBlocking
41
TFResult
TestCCSB
()
42
{
43
return
TestCleanup
(
"TestMultiCreation"
, 3000);
44
}
45
46
//---------------------------------------------------------------------------
47
// Test if events are called properly
48
TFResult
TestEvents
()
49
{
50
ParticleManager
pm =
new
ParticleManager
(
new
ParticleManagerSettings
(3000));
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
67
TFResult
TestOwnership
()
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);
74
OwnershipTestDummyClass
dummy =
new
OwnershipTestDummyClass
();
75
76
ParticleProperties pp =
new
ParticleProperties(
g_Game
.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
//---------------------------------------------------------------------------
94
TFResult
CheckTestEvents
()
95
{
96
ParticleManager
pm;
97
if
(
GetManager
(
m_EventTestManagerID
, pm))
98
{
99
if
(pm)
100
{
101
if
(pm.IsFinishedAllocating())
102
{
103
return
BTFR
(
Assert
(
m_bTestEventsPassed
));
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
//---------------------------------------------------------------------------
122
void
PassCheckEvents
(
ParticleManager
pm)
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
134
ParticleManager
pm =
CreatePMFixedBlocking
(size);
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
154
PrintActiveStats
();
155
156
TFResult
res =
CTFR
();
157
158
g_Game
.GameScript.CallFunction(
this
, f, res, p1);
159
160
int
pmTotalPost =
ParticleManager
.GetStaticActiveCount();
161
int
psTotalPost =
ParticleSource
.
GetStaticActiveCount
();
162
163
PrintActiveStats
();
164
165
bool
success =
Assert
(pmTotal == pmTotalPost);
166
success &=
Assert
(psTotal == psTotalPost);
167
168
return
res.And(
BTFR
(success));
169
}
170
171
TFResult
TestMultiCreation
(
int
instances)
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
}
Debug
Definition
debug.c:2
Debug::ParticleLog
static void ParticleLog(string message=LOG_DEFAULT, Managed caller=null, string function="", Managed entity=null)
Definition
debug.c:232
OwnershipTestDummyClass
Definition
pmtcreationandcleanup.c:2
PMTF
Definition
pmtf.c:2
PMTF::InsertManager
int InsertManager(ParticleManager pm)
Definition
pmtf.c:9
PMTF::PrintActiveStats
void PrintActiveStats()
Definition
pmtf.c:32
PMTF::CreatePMFixedBlocking
ParticleManager CreatePMFixedBlocking(int size)
Definition
pmtf.c:42
PMTF::PrintPMStats
void PrintPMStats(notnull ParticleManager pm)
Definition
pmtf.c:25
ParticleList
Definition
particlelist.c:12
ParticleList::GetParticleFullPath
static string GetParticleFullPath(int particle_id)
Returns particle's full path (with .ptc suffix) based on its ID.
Definition
particlelist.c:491
ParticleList::EXPLOSION_LANDMINE
static const int EXPLOSION_LANDMINE
Definition
particlelist.c:268
ParticleSource
Entity which has the particle instance as an ObjectComponent.
Definition
particlesource.c:124
ParticleSource::GetStaticActiveCount
proto static native int GetStaticActiveCount()
Gets the amount of ParticleSource that are currently existing.
vector
Definition
enconvert.c:119
vector::Zero
static const vector Zero
Definition
enconvert.c:123
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
ParticleManagerSettings
class ParticleManagerConstants ParticleManagerSettings(int poolSize, int flags=ParticleManagerSettingsFlags.NONE)
Settings given to ParticleManager on creation (in ctor).
Definition
particlemanager.c:39
ParticleManager
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor).
Definition
particlemanager.c:88
GetManager
PlayerStats GetManager()
Definition
playerstatbase.c:198
PassCheckEvents
void PassCheckEvents(ParticleManager pm)
Definition
pmtcreationandcleanup.c:122
TestCleanup
TFResult TestCleanup(string f, int p1=0)
Definition
pmtcreationandcleanup.c:149
TestCCSB
TFResult TestCCSB()
Definition
pmtcreationandcleanup.c:41
TestMultiCreation
TFResult TestMultiCreation(int instances)
Definition
pmtcreationandcleanup.c:171
TestCreationSmallBlocking
TFResult TestCreationSmallBlocking(int size, bool enableAsserts=true)
Definition
pmtcreationandcleanup.c:131
m_EventTestManagerID
class OwnershipTestDummyClass m_EventTestManagerID
TestOwnership
TFResult TestOwnership()
Definition
pmtcreationandcleanup.c:67
PMTCreationAndCleanup
void PMTCreationAndCleanup()
Definition
pmtcreationandcleanup.c:16
TestEvents
TFResult TestEvents()
Definition
pmtcreationandcleanup.c:48
m_bTestEventsPassed
bool m_bTestEventsPassed
Definition
pmtcreationandcleanup.c:9
TestInvalidSize
TFResult TestInvalidSize()
Definition
pmtcreationandcleanup.c:28
m_OwnershipTestManagerID
int m_OwnershipTestManagerID
Definition
pmtcreationandcleanup.c:11
CheckTestEvents
TFResult CheckTestEvents()
Definition
pmtcreationandcleanup.c:94
NTFR
TFResult NTFR(TFR result)
Definition
testframework.c:273
CTFR
TFResult CTFR()
Definition
testframework.c:286
Assert
bool Assert(bool condition)
Definition
testframework.c:262
TFResult
void TFResult(TFR result)
Definition
testframework.c:12
TFR
TFR
Definition
testframework.c:2
AddFrameTest
void AddFrameTest(string test)
Definition
testframework.c:254
AddInitTest
void AddInitTest(string test)
Definition
testframework.c:249
BTFR
TFResult BTFR(bool result)
Definition
testframework.c:278
Games
Dayz
scripts
3_game
particles
tests
pmtcreationandcleanup.c
Generated by
1.17.0