AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
SpellProcConditionsTest.cpp File Reference

Unit tests for conditions system integration in proc system. More...

#include "ProcChanceTestHelper.h"
#include "ProcEventInfoHelper.h"
#include "gtest/gtest.h"

Go to the source code of this file.

Classes

class  SpellProcConditionsTest
 

Functions

 TEST_F (SpellProcConditionsTest, NoConditions_AllowsProc)
 
 TEST_F (SpellProcConditionsTest, ConditionsMet_AllowsProc)
 
 TEST_F (SpellProcConditionsTest, ConditionsNotMet_BlocksProc)
 
 TEST_F (SpellProcConditionsTest, SourceType_SpellProc)
 
 TEST_F (SpellProcConditionsTest, MultipleConditions_AllMet_AllowsProc)
 
 TEST_F (SpellProcConditionsTest, MultipleConditions_OneFails_BlocksProc)
 
 TEST_F (SpellProcConditionsTest, ElseGroup_OneGroupPasses_AllowsProc)
 
 TEST_F (SpellProcConditionsTest, ElseGroup_AllGroupsFail_BlocksProc)
 
 TEST_F (SpellProcConditionsTest, Scenario_ProcOnlyInCombat)
 
 TEST_F (SpellProcConditionsTest, Scenario_ProcOnlyVsUndead)
 
 TEST_F (SpellProcConditionsTest, Scenario_ProcRequiresAura)
 
 TEST_F (SpellProcConditionsTest, Scenario_ProcRequiresHealthBelow)
 
 TEST_F (SpellProcConditionsTest, Scenario_ProcInAreaOnly)
 
 TEST_F (SpellProcConditionsTest, ConditionType_Aura)
 
 TEST_F (SpellProcConditionsTest, ConditionType_Item)
 
 TEST_F (SpellProcConditionsTest, ConditionType_ItemEquipped)
 
 TEST_F (SpellProcConditionsTest, ConditionType_QuestRewarded)
 
 TEST_F (SpellProcConditionsTest, ConditionType_CreatureType)
 
 TEST_F (SpellProcConditionsTest, ConditionType_HPVal)
 
 TEST_F (SpellProcConditionsTest, ConditionType_HPPct)
 
 TEST_F (SpellProcConditionsTest, ConditionType_InCombat)
 
 TEST_F (SpellProcConditionsTest, EdgeCase_EmptyConditionList)
 
 TEST_F (SpellProcConditionsTest, EdgeCase_ConditionsButAlwaysTrue)
 
 TEST_F (SpellProcConditionsTest, EdgeCase_MultipleSourceTypes)
 

Detailed Description

Unit tests for conditions system integration in proc system.

Tests the logic from SpellAuras.cpp:2232-2236:

  • CONDITION_SOURCE_TYPE_SPELL_PROC (24) lookup
  • Condition met allows proc
  • Condition not met blocks proc
  • Empty conditions allow proc
  • Multiple conditions (AND logic within ElseGroup)
  • ElseGroup OR logic

TEST DESIGN: Configuration-Based Testing

These tests use ConditionsConfig structs to simulate the result of condition evaluation without requiring actual ConditionMgr queries. Each test configures:

  • sourceType: The condition source type (24 = CONDITION_SOURCE_TYPE_SPELL_PROC)
  • hasConditions: Whether any conditions are registered for this spell
  • conditionsMet: The result of ConditionMgr::IsObjectMeetToConditions()

The actual condition types (CONDITION_AURA, CONDITION_HP_PCT, etc.) are not evaluated here - we test the proc system's response to condition evaluation results. Individual condition types are tested in the conditions system unit tests.

No GTEST_SKIP() is used in this file - all tests run with their configured

scenarios, testing both positive and negative cases explicitly.

Definition in file SpellProcConditionsTest.cpp.

Function Documentation

◆ TEST_F() [1/24]

TEST_F ( SpellProcConditionsTest  ,
ConditionsMet_AllowsProc   
)
77{
79 config.hasConditions = true;
80 config.conditionsMet = true;
81
83 << "Conditions met should allow proc";
84}
static bool ShouldBlockDueToConditions(ConditionsConfig const &config)
Simulate conditions check Returns true if proc should be blocked due to conditions.
Definition ProcChanceTestHelper.h:598
Configuration for simulating conditions system.
Definition ProcChanceTestHelper.h:585
bool hasConditions
Definition ProcChanceTestHelper.h:586
bool conditionsMet
Definition ProcChanceTestHelper.h:587

References ProcChanceTestHelper::ConditionsConfig::conditionsMet, ProcChanceTestHelper::ConditionsConfig::hasConditions, and ProcChanceTestHelper::ShouldBlockDueToConditions().

◆ TEST_F() [2/24]

TEST_F ( SpellProcConditionsTest  ,
ConditionsNotMet_BlocksProc   
)

◆ TEST_F() [3/24]

◆ TEST_F() [4/24]

TEST_F ( SpellProcConditionsTest  ,
ConditionType_CreatureType   
)
306{
307 // CONDITION_CREATURE_TYPE = 18
309 config.hasConditions = true;
310 config.conditionsMet = false; // Wrong creature type
311
313 << "Proc blocked when creature type doesn't match";
314}

References ProcChanceTestHelper::ConditionsConfig::conditionsMet, ProcChanceTestHelper::ConditionsConfig::hasConditions, and ProcChanceTestHelper::ShouldBlockDueToConditions().

◆ TEST_F() [5/24]

TEST_F ( SpellProcConditionsTest  ,
ConditionType_HPPct   
)

◆ TEST_F() [6/24]

TEST_F ( SpellProcConditionsTest  ,
ConditionType_HPVal   
)

◆ TEST_F() [7/24]

TEST_F ( SpellProcConditionsTest  ,
ConditionType_InCombat   
)

◆ TEST_F() [8/24]

◆ TEST_F() [9/24]

TEST_F ( SpellProcConditionsTest  ,
ConditionType_ItemEquipped   
)
284{
285 // CONDITION_ITEM_EQUIPPED = 3
287 config.hasConditions = true;
288 config.conditionsMet = false; // Required item not equipped
289
291 << "Proc blocked when required item not equipped";
292}

References ProcChanceTestHelper::ConditionsConfig::conditionsMet, ProcChanceTestHelper::ConditionsConfig::hasConditions, and ProcChanceTestHelper::ShouldBlockDueToConditions().

◆ TEST_F() [10/24]

TEST_F ( SpellProcConditionsTest  ,
ConditionType_QuestRewarded   
)
295{
296 // CONDITION_QUESTREWARDED = 8
298 config.hasConditions = true;
299 config.conditionsMet = true; // Required quest completed
300
302 << "Proc allowed when quest completed";
303}

References ProcChanceTestHelper::ConditionsConfig::conditionsMet, ProcChanceTestHelper::ConditionsConfig::hasConditions, and ProcChanceTestHelper::ShouldBlockDueToConditions().

◆ TEST_F() [11/24]

TEST_F ( SpellProcConditionsTest  ,
EdgeCase_ConditionsButAlwaysTrue   
)
361{
362 // Conditions exist but are always satisfied (e.g., always-true condition)
364 config.hasConditions = true;
365 config.conditionsMet = true;
366
368}

References ProcChanceTestHelper::ConditionsConfig::conditionsMet, ProcChanceTestHelper::ConditionsConfig::hasConditions, and ProcChanceTestHelper::ShouldBlockDueToConditions().

◆ TEST_F() [12/24]

TEST_F ( SpellProcConditionsTest  ,
EdgeCase_EmptyConditionList   
)
351{
353 config.hasConditions = false;
354 config.conditionsMet = false; // Doesn't matter when no conditions
355
357 << "Empty condition list should allow proc";
358}

References ProcChanceTestHelper::ConditionsConfig::conditionsMet, ProcChanceTestHelper::ConditionsConfig::hasConditions, and ProcChanceTestHelper::ShouldBlockDueToConditions().

◆ TEST_F() [13/24]

TEST_F ( SpellProcConditionsTest  ,
EdgeCase_MultipleSourceTypes   
)
371{
372 // Different source types shouldn't interfere
373 // Each spell proc has its own conditions by spell ID
375 spell1.sourceType = 24;
376 spell1.hasConditions = true;
377 spell1.conditionsMet = true;
378
380 spell2.sourceType = 24;
381 spell2.hasConditions = true;
382 spell2.conditionsMet = false;
383
386}
uint32 sourceType
Definition ProcChanceTestHelper.h:588

References ProcChanceTestHelper::ConditionsConfig::conditionsMet, ProcChanceTestHelper::ConditionsConfig::hasConditions, ProcChanceTestHelper::ShouldBlockDueToConditions(), and ProcChanceTestHelper::ConditionsConfig::sourceType.

◆ TEST_F() [14/24]

TEST_F ( SpellProcConditionsTest  ,
ElseGroup_AllGroupsFail_BlocksProc   
)
155{
156 // All ElseGroups fail
158 config.hasConditions = true;
159 config.conditionsMet = false; // No groups passed
160
162 << "All ElseGroups failing should block proc";
163}

References ProcChanceTestHelper::ConditionsConfig::conditionsMet, ProcChanceTestHelper::ConditionsConfig::hasConditions, and ProcChanceTestHelper::ShouldBlockDueToConditions().

◆ TEST_F() [15/24]

TEST_F ( SpellProcConditionsTest  ,
ElseGroup_OneGroupPasses_AllowsProc   
)
144{
145 // ElseGroup logic: any group passing means conditions met
147 config.hasConditions = true;
148 config.conditionsMet = true; // At least one group passed
149
151 << "At least one ElseGroup passing should allow proc";
152}

References ProcChanceTestHelper::ConditionsConfig::conditionsMet, ProcChanceTestHelper::ConditionsConfig::hasConditions, and ProcChanceTestHelper::ShouldBlockDueToConditions().

◆ TEST_F() [16/24]

TEST_F ( SpellProcConditionsTest  ,
MultipleConditions_AllMet_AllowsProc   
)
117{
118 // Simulating multiple conditions in same ElseGroup (AND)
119 // In reality, ConditionMgr evaluates all - we just test the result
121 config.hasConditions = true;
122 config.conditionsMet = true; // All conditions passed
123
125 << "All conditions met (AND) should allow proc";
126}

References ProcChanceTestHelper::ConditionsConfig::conditionsMet, ProcChanceTestHelper::ConditionsConfig::hasConditions, and ProcChanceTestHelper::ShouldBlockDueToConditions().

◆ TEST_F() [17/24]

TEST_F ( SpellProcConditionsTest  ,
MultipleConditions_OneFails_BlocksProc   
)
129{
130 // One condition in the group fails
132 config.hasConditions = true;
133 config.conditionsMet = false; // At least one condition failed
134
136 << "One failed condition (AND) should block proc";
137}

References ProcChanceTestHelper::ConditionsConfig::conditionsMet, ProcChanceTestHelper::ConditionsConfig::hasConditions, and ProcChanceTestHelper::ShouldBlockDueToConditions().

◆ TEST_F() [18/24]

TEST_F ( SpellProcConditionsTest  ,
NoConditions_AllowsProc   
)
68{
70 config.hasConditions = false; // No conditions registered
71
73 << "No conditions should allow proc";
74}

References ProcChanceTestHelper::ConditionsConfig::hasConditions, and ProcChanceTestHelper::ShouldBlockDueToConditions().

◆ TEST_F() [19/24]

TEST_F ( SpellProcConditionsTest  ,
Scenario_ProcInAreaOnly   
)
242{
243 // Condition: Must be in specific zone/area
245 inArea.hasConditions = true;
246 inArea.conditionsMet = true;
247
249 << "Proc should work when in required area";
250
252 notInArea.hasConditions = true;
253 notInArea.conditionsMet = false;
254
256 << "Proc should be blocked when not in required area";
257}

References ProcChanceTestHelper::ConditionsConfig::conditionsMet, ProcChanceTestHelper::ConditionsConfig::hasConditions, and ProcChanceTestHelper::ShouldBlockDueToConditions().

◆ TEST_F() [20/24]

TEST_F ( SpellProcConditionsTest  ,
Scenario_ProcOnlyInCombat   
)
170{
171 // Condition: Player must be in combat
173 inCombat.hasConditions = true;
174 inCombat.conditionsMet = true; // In combat
175
177 << "Proc should work when in combat";
178
180 outOfCombat.hasConditions = true;
181 outOfCombat.conditionsMet = false; // Out of combat
182
184 << "Proc should be blocked when out of combat";
185}

References ProcChanceTestHelper::ConditionsConfig::conditionsMet, ProcChanceTestHelper::ConditionsConfig::hasConditions, and ProcChanceTestHelper::ShouldBlockDueToConditions().

◆ TEST_F() [21/24]

TEST_F ( SpellProcConditionsTest  ,
Scenario_ProcOnlyVsUndead   
)
188{
189 // Condition: Target must be undead creature type
191 vsUndead.hasConditions = true;
192 vsUndead.conditionsMet = true; // Target is undead
193
195 << "Proc should work against undead";
196
198 vsHumanoid.hasConditions = true;
199 vsHumanoid.conditionsMet = false; // Target is humanoid
200
202 << "Proc should be blocked against non-undead";
203}

References ProcChanceTestHelper::ConditionsConfig::conditionsMet, ProcChanceTestHelper::ConditionsConfig::hasConditions, and ProcChanceTestHelper::ShouldBlockDueToConditions().

◆ TEST_F() [22/24]

TEST_F ( SpellProcConditionsTest  ,
Scenario_ProcRequiresAura   
)
206{
207 // Condition: Actor must have specific aura
209 hasAura.hasConditions = true;
210 hasAura.conditionsMet = true;
211
213 << "Proc should work when required aura is present";
214
216 noAura.hasConditions = true;
217 noAura.conditionsMet = false;
218
220 << "Proc should be blocked when required aura is missing";
221}

References ProcChanceTestHelper::ConditionsConfig::conditionsMet, ProcChanceTestHelper::ConditionsConfig::hasConditions, and ProcChanceTestHelper::ShouldBlockDueToConditions().

◆ TEST_F() [23/24]

TEST_F ( SpellProcConditionsTest  ,
Scenario_ProcRequiresHealthBelow   
)
224{
225 // Condition: Actor health must be below threshold
227 lowHealth.hasConditions = true;
228 lowHealth.conditionsMet = true; // Health below 35%
229
231 << "Proc should work when health is below threshold";
232
234 highHealth.hasConditions = true;
235 highHealth.conditionsMet = false; // Health above 35%
236
238 << "Proc should be blocked when health is above threshold";
239}

References ProcChanceTestHelper::ConditionsConfig::conditionsMet, ProcChanceTestHelper::ConditionsConfig::hasConditions, and ProcChanceTestHelper::ShouldBlockDueToConditions().

◆ TEST_F() [24/24]

TEST_F ( SpellProcConditionsTest  ,
SourceType_SpellProc   
)
101{
103 config.sourceType = 24; // CONDITION_SOURCE_TYPE_SPELL_PROC
104 config.hasConditions = true;
105 config.conditionsMet = true;
106
107 EXPECT_EQ(config.sourceType, 24u)
108 << "Source type should be CONDITION_SOURCE_TYPE_SPELL_PROC (24)";
110}

References ProcChanceTestHelper::ConditionsConfig::conditionsMet, ProcChanceTestHelper::ConditionsConfig::hasConditions, ProcChanceTestHelper::ShouldBlockDueToConditions(), and ProcChanceTestHelper::ConditionsConfig::sourceType.