AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
SpellProcDatabaseTest Class Reference
Inheritance diagram for SpellProcDatabaseTest:

Protected Member Functions

void SetUp () override
 
void TearDown () override
 
ProcFlagScenario const * FindMatchingScenario (uint32 procFlags)
 Find the first matching proc flag scenario for given flags.
 
uint32 GetEffectiveHitMask (SpellProcTestEntry const &entry, ProcFlagScenario const *scenario)
 Get effective hit mask for an entry.
 
uint32 GetEffectiveSpellTypeMask (SpellProcTestEntry const &entry, ProcFlagScenario const *scenario)
 Get effective spell type mask.
 
uint32 GetEffectiveSpellPhaseMask (SpellProcTestEntry const &entry, ProcFlagScenario const *scenario)
 Get effective spell phase mask.
 
bool RequiresSpellFamilyMatch (SpellProcTestEntry const &entry)
 Check if entry requires SpellFamily matching (which we can't test without SpellInfo) Any entry with SpellFamilyName > 0 will cause CanSpellTriggerProcOnEvent to access eventInfo.GetSpellInfo() which returns null in our test, causing a crash.
 
bool IsSpellTypeProc (uint32 procFlags)
 Check if the proc flags indicate a spell-type event that needs SpellInfo.
 
ProcEventInfo CreateEventInfo (uint32 typeMask, uint32 hitMask, uint32 spellTypeMask, uint32 spellPhaseMask)
 Create a ProcEventInfo with proper DamageInfo/HealInfo for spell-type procs.
 

Protected Attributes

IWorld_originalWorld = nullptr
 
NiceMock< WorldMock > * _worldMock = nullptr
 
SpellInfo_defaultSpellInfo = nullptr
 
DamageInfo_damageInfo = nullptr
 
HealInfo_healInfo = nullptr
 
std::vector< SpellProcTestEntry_allEntries
 

Detailed Description

Member Function Documentation

◆ CreateEventInfo()

ProcEventInfo SpellProcDatabaseTest::CreateEventInfo ( uint32  typeMask,
uint32  hitMask,
uint32  spellTypeMask,
uint32  spellPhaseMask 
)
inlineprotected

Create a ProcEventInfo with proper DamageInfo/HealInfo for spell-type procs.

219 {
220 auto builder = ProcEventInfoBuilder()
221 .WithTypeMask(typeMask)
222 .WithHitMask(hitMask)
224 .WithSpellPhaseMask(spellPhaseMask);
225
226 // For spell-type procs, provide DamageInfo or HealInfo with SpellInfo
227 if (IsSpellTypeProc(typeMask))
228 {
230 {
231 if (!_healInfo)
232 _healInfo = new HealInfo(nullptr, nullptr, 100, _defaultSpellInfo, SPELL_SCHOOL_MASK_HOLY);
233 builder.WithHealInfo(_healInfo);
234 }
235 else
236 {
237 if (!_damageInfo)
239 builder.WithDamageInfo(_damageInfo);
240 }
241 }
242
243 return builder.Build();
244 }
@ SPELL_SCHOOL_MASK_HOLY
Definition SharedDefines.h:286
@ SPELL_SCHOOL_MASK_FIRE
Definition SharedDefines.h:287
static uint32 spellTypeMask[TOTAL_AURAS]
Definition SpellMgr.cpp:1819
@ PROC_SPELL_TYPE_HEAL
Definition SpellMgr.h:240
@ SPELL_DIRECT_DAMAGE
Definition Unit.h:255
Definition Unit.h:336
Definition Unit.h:383
Builder class for creating ProcEventInfo test instances.
Definition ProcEventInfoHelper.h:31
ProcEventInfoBuilder & WithSpellPhaseMask(uint32 spellPhaseMask)
Definition ProcEventInfoHelper.h:69
ProcEventInfoBuilder & WithTypeMask(uint32 typeMask)
Definition ProcEventInfoHelper.h:57
ProcEventInfoBuilder & WithHitMask(uint32 hitMask)
Definition ProcEventInfoHelper.h:75
ProcEventInfoBuilder & WithSpellTypeMask(uint32 spellTypeMask)
Definition ProcEventInfoHelper.h:63
HealInfo * _healInfo
Definition SpellProcDataDrivenTest.cpp:250
DamageInfo * _damageInfo
Definition SpellProcDataDrivenTest.cpp:249
bool IsSpellTypeProc(uint32 procFlags)
Check if the proc flags indicate a spell-type event that needs SpellInfo.
Definition SpellProcDataDrivenTest.cpp:210
SpellInfo * _defaultSpellInfo
Definition SpellProcDataDrivenTest.cpp:248

References _damageInfo, _defaultSpellInfo, _healInfo, IsSpellTypeProc(), PROC_SPELL_TYPE_HEAL, SPELL_DIRECT_DAMAGE, SPELL_SCHOOL_MASK_FIRE, SPELL_SCHOOL_MASK_HOLY, spellTypeMask, ProcEventInfoBuilder::WithHitMask(), ProcEventInfoBuilder::WithSpellPhaseMask(), ProcEventInfoBuilder::WithSpellTypeMask(), and ProcEventInfoBuilder::WithTypeMask().

◆ FindMatchingScenario()

ProcFlagScenario const * SpellProcDatabaseTest::FindMatchingScenario ( uint32  procFlags)
inlineprotected

Find the first matching proc flag scenario for given flags.

141 {
142 for (auto const& scenario : PROC_FLAG_SCENARIOS)
143 {
144 if (procFlags & scenario.procFlag)
145 return &scenario;
146 }
147 return nullptr;
148 }
static const std::vector< ProcFlagScenario > PROC_FLAG_SCENARIOS
Definition SpellProcDataDrivenTest.cpp:52

References PROC_FLAG_SCENARIOS.

◆ GetEffectiveHitMask()

uint32 SpellProcDatabaseTest::GetEffectiveHitMask ( SpellProcTestEntry const &  entry,
ProcFlagScenario const *  scenario 
)
inlineprotected

Get effective hit mask for an entry.

154 {
155 if (entry.HitMask != 0)
156 {
157 // Return first set bit
158 for (auto const& [mask, name] : HIT_MASK_SCENARIOS)
159 {
160 if (entry.HitMask & mask)
161 return mask;
162 }
163 }
164 return scenario ? scenario->defaultHitMask : PROC_HIT_NORMAL;
165 }
@ PROC_HIT_NORMAL
Definition SpellMgr.h:257
static const std::vector< std::pair< uint32, const char * > > HIT_MASK_SCENARIOS
Definition SpellProcDataDrivenTest.cpp:80

References ProcFlagScenario::defaultHitMask, HIT_MASK_SCENARIOS, SpellProcTestEntry::HitMask, and PROC_HIT_NORMAL.

◆ GetEffectiveSpellPhaseMask()

uint32 SpellProcDatabaseTest::GetEffectiveSpellPhaseMask ( SpellProcTestEntry const &  entry,
ProcFlagScenario const *  scenario 
)
inlineprotected

Get effective spell phase mask.

188 {
189 if (entry.SpellPhaseMask != 0)
190 return entry.SpellPhaseMask;
191 if (scenario && scenario->requiresSpellPhase)
192 return scenario->defaultSpellPhaseMask ? scenario->defaultSpellPhaseMask : PROC_SPELL_PHASE_HIT;
193 return 0;
194 }
@ PROC_SPELL_PHASE_HIT
Definition SpellMgr.h:249

References ProcFlagScenario::defaultSpellPhaseMask, PROC_SPELL_PHASE_HIT, ProcFlagScenario::requiresSpellPhase, and SpellProcTestEntry::SpellPhaseMask.

◆ GetEffectiveSpellTypeMask()

uint32 SpellProcDatabaseTest::GetEffectiveSpellTypeMask ( SpellProcTestEntry const &  entry,
ProcFlagScenario const *  scenario 
)
inlineprotected

Get effective spell type mask.

171 {
172 if (entry.SpellTypeMask != 0)
173 {
174 if (entry.SpellTypeMask & PROC_SPELL_TYPE_DAMAGE)
176 if (entry.SpellTypeMask & PROC_SPELL_TYPE_HEAL)
178 if (entry.SpellTypeMask & PROC_SPELL_TYPE_NO_DMG_HEAL)
180 }
181 return scenario ? scenario->defaultSpellTypeMask : PROC_SPELL_TYPE_MASK_ALL;
182 }
@ PROC_SPELL_TYPE_MASK_ALL
Definition SpellMgr.h:242
@ PROC_SPELL_TYPE_DAMAGE
Definition SpellMgr.h:239
@ PROC_SPELL_TYPE_NO_DMG_HEAL
Definition SpellMgr.h:241

References ProcFlagScenario::defaultSpellTypeMask, PROC_SPELL_TYPE_DAMAGE, PROC_SPELL_TYPE_HEAL, PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_TYPE_NO_DMG_HEAL, and SpellProcTestEntry::SpellTypeMask.

◆ IsSpellTypeProc()

bool SpellProcDatabaseTest::IsSpellTypeProc ( uint32  procFlags)
inlineprotected

Check if the proc flags indicate a spell-type event that needs SpellInfo.

211 {
213 }
@ PERIODIC_PROC_FLAG_MASK
Definition SpellMgr.h:169
@ SPELL_PROC_FLAG_MASK
Definition SpellMgr.h:159
@ PROC_FLAG_DONE_TRAP_ACTIVATION
Definition SpellMgr.h:141

References PERIODIC_PROC_FLAG_MASK, PROC_FLAG_DONE_TRAP_ACTIVATION, and SPELL_PROC_FLAG_MASK.

Referenced by CreateEventInfo().

◆ RequiresSpellFamilyMatch()

bool SpellProcDatabaseTest::RequiresSpellFamilyMatch ( SpellProcTestEntry const &  entry)
inlineprotected

Check if entry requires SpellFamily matching (which we can't test without SpellInfo) Any entry with SpellFamilyName > 0 will cause CanSpellTriggerProcOnEvent to access eventInfo.GetSpellInfo() which returns null in our test, causing a crash.

202 {
203 // Skip any entry with SpellFamilyName set - the code will try to access SpellInfo
204 return entry.SpellFamilyName != 0;
205 }

References SpellProcTestEntry::SpellFamilyName.

◆ SetUp()

void SpellProcDatabaseTest::SetUp ( )
inlineoverrideprotected
104 {
105 _originalWorld = sWorld.release();
106 _worldMock = new NiceMock<WorldMock>();
107 sWorld.reset(_worldMock);
108
109 static std::string emptyString;
110 ON_CALL(*_worldMock, GetDataPath()).WillByDefault(ReturnRef(emptyString));
111
112 // Load all entries from generated data
114
115 // Create a default SpellInfo for spell-type procs
117 .WithId(99999)
119 .Build();
120 }
std::vector< SpellProcTestEntry > GetAllSpellProcTestEntries()
All spell_proc entries from the database Total: 869 entries.
Definition SpellProcTestData.h:106
Builder class for creating SpellInfo test instances.
Definition SpellInfoTestHelper.h:160
SpellInfoBuilder & WithId(uint32 id)
Definition SpellInfoTestHelper.h:164
SpellInfo * Build()
Definition SpellInfoTestHelper.h:250
SpellInfoBuilder & WithSpellFamilyName(uint32 familyName)
Definition SpellInfoTestHelper.h:170
IWorld * _originalWorld
Definition SpellProcDataDrivenTest.cpp:246
NiceMock< WorldMock > * _worldMock
Definition SpellProcDataDrivenTest.cpp:247
std::vector< SpellProcTestEntry > _allEntries
Definition SpellProcDataDrivenTest.cpp:251
#define sWorld
Definition World.h:316

References _allEntries, _defaultSpellInfo, _originalWorld, _worldMock, SpellInfoBuilder::Build(), GetAllSpellProcTestEntries(), sWorld, SpellInfoBuilder::WithId(), and SpellInfoBuilder::WithSpellFamilyName().

◆ TearDown()

void SpellProcDatabaseTest::TearDown ( )
inlineoverrideprotected
123 {
124 IWorld* currentWorld = sWorld.release();
125 delete currentWorld;
126 _worldMock = nullptr;
127 sWorld.reset(_originalWorld);
128
129 delete _defaultSpellInfo;
130 _defaultSpellInfo = nullptr;
131 delete _damageInfo;
132 _damageInfo = nullptr;
133 delete _healInfo;
134 _healInfo = nullptr;
135 }
Definition IWorld.h:63

References _damageInfo, _defaultSpellInfo, _healInfo, _originalWorld, _worldMock, and sWorld.

Member Data Documentation

◆ _allEntries

std::vector<SpellProcTestEntry> SpellProcDatabaseTest::_allEntries
protected

Referenced by SetUp().

◆ _damageInfo

DamageInfo* SpellProcDatabaseTest::_damageInfo = nullptr
protected

Referenced by CreateEventInfo(), and TearDown().

◆ _defaultSpellInfo

SpellInfo* SpellProcDatabaseTest::_defaultSpellInfo = nullptr
protected

Referenced by CreateEventInfo(), SetUp(), and TearDown().

◆ _healInfo

HealInfo* SpellProcDatabaseTest::_healInfo = nullptr
protected

Referenced by CreateEventInfo(), and TearDown().

◆ _originalWorld

IWorld* SpellProcDatabaseTest::_originalWorld = nullptr
protected

Referenced by SetUp(), and TearDown().

◆ _worldMock

NiceMock<WorldMock>* SpellProcDatabaseTest::_worldMock = nullptr
protected

Referenced by SetUp(), and TearDown().


The documentation for this class was generated from the following file: