mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
vcmi: fix test building for 1.2
This commit is contained in:
parent
924b456b0f
commit
7c56fbd16b
@ -85,7 +85,7 @@ TEST_F(ERM_MA, Example)
|
||||
static_assert(FLAG_MASK_NEW == (1 << 0 | 1 << 1 | 1 << 7 | 1 << 12 | 1 << 17 | 1 << 18), "Wrong flag mask meaning");
|
||||
|
||||
creatureBonuses.addNewBonus(std::make_shared<Bonus>(Bonus::PERMANENT, Bonus::FLYING, Bonus::CREATURE_ABILITY, 0, 0));
|
||||
creatureBonuses.addNewBonus(std::make_shared<Bonus>(Bonus::PERMANENT, Bonus::KING1, Bonus::CREATURE_ABILITY, 0, 0));
|
||||
creatureBonuses.addNewBonus(std::make_shared<Bonus>(Bonus::PERMANENT, Bonus::KING, Bonus::CREATURE_ABILITY, 0, 0));
|
||||
|
||||
std::shared_ptr<Bonus> removed = std::make_shared<Bonus>(Bonus::PERMANENT, Bonus::MIND_IMMUNITY, Bonus::CREATURE_ABILITY, 0, 0);
|
||||
|
||||
@ -204,7 +204,7 @@ TEST_F(ERM_MA, Bonuses)
|
||||
static_assert(FLAG_MASK_NEW == ( 1 << 1 | 1 << 7 | 1 << 12 | 1 << 17 | 1 << 18), "Wrong flag mask meaning");
|
||||
|
||||
creatureBonuses.addNewBonus(std::make_shared<Bonus>(Bonus::PERMANENT, Bonus::FLYING, Bonus::CREATURE_ABILITY, 0, 0));
|
||||
creatureBonuses.addNewBonus(std::make_shared<Bonus>(Bonus::PERMANENT, Bonus::KING1, Bonus::CREATURE_ABILITY, 0, 0));
|
||||
creatureBonuses.addNewBonus(std::make_shared<Bonus>(Bonus::PERMANENT, Bonus::KING, Bonus::CREATURE_ABILITY, 0, 0));
|
||||
|
||||
std::shared_ptr<Bonus> removed = std::make_shared<Bonus>(Bonus::PERMANENT, Bonus::MIND_IMMUNITY, Bonus::CREATURE_ABILITY, 0, 0);
|
||||
|
||||
@ -266,7 +266,7 @@ TEST_F(ERM_MA, BonusesNoChanges)
|
||||
static_assert(FLAG_MASK == (1 << 1 | 1 << 7 | 1 << 10 | 1 << 17 | 1 << 18), "Wrong flag mask meaning");
|
||||
|
||||
creatureBonuses.addNewBonus(std::make_shared<Bonus>(Bonus::PERMANENT, Bonus::FLYING, Bonus::CREATURE_ABILITY, 0, 0));
|
||||
creatureBonuses.addNewBonus(std::make_shared<Bonus>(Bonus::PERMANENT, Bonus::KING1, Bonus::CREATURE_ABILITY, 0, 0));
|
||||
creatureBonuses.addNewBonus(std::make_shared<Bonus>(Bonus::PERMANENT, Bonus::KING, Bonus::CREATURE_ABILITY, 0, 0));
|
||||
creatureBonuses.addNewBonus(std::make_shared<Bonus>(Bonus::PERMANENT, Bonus::MIND_IMMUNITY, Bonus::CREATURE_ABILITY, 0, 0));
|
||||
creatureBonuses.addNewBonus(std::make_shared<Bonus>(Bonus::PERMANENT, Bonus::NO_MORALE, Bonus::CREATURE_ABILITY, 0, 0));
|
||||
creatureBonuses.addNewBonus(std::make_shared<Bonus>(Bonus::PERMANENT, Bonus::UNDEAD, Bonus::CREATURE_ABILITY, 0, 0));
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
MOCK_CONST_METHOD0(battleActiveUnit, const battle::Unit *());
|
||||
|
||||
MOCK_CONST_METHOD2(battleGetAllObstaclesOnPos, std::vector<std::shared_ptr<const CObstacleInstance>>(BattleHex, bool));
|
||||
MOCK_CONST_METHOD1(getAllAffectedObstaclesByStack, std::vector<std::shared_ptr<const CObstacleInstance>>(const battle::Unit *));
|
||||
MOCK_CONST_METHOD2(getAllAffectedObstaclesByStack, std::vector<std::shared_ptr<const CObstacleInstance>>(const battle::Unit *, const std::set<BattleHex> &));
|
||||
|
||||
};
|
||||
|
||||
|
@ -26,6 +26,7 @@ public:
|
||||
MOCK_CONST_METHOD0(skills, const SkillService * ());
|
||||
MOCK_CONST_METHOD0(battlefields, const BattleFieldService *());
|
||||
MOCK_CONST_METHOD0(obstacles, const ObstacleService *());
|
||||
MOCK_CONST_METHOD0(settings, const IGameSettings *());
|
||||
|
||||
MOCK_METHOD3(updateEntity, void(Metatype, int32_t, const JsonNode &));
|
||||
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
MOCK_CONST_METHOD0(getTacticsSide, ui8());
|
||||
MOCK_CONST_METHOD0(getBonusBearer, const IBonusBearer *());
|
||||
MOCK_CONST_METHOD0(nextUnitId, uint32_t());
|
||||
MOCK_CONST_METHOD3(getActualDamage, int64_t(const TDmgRange &, int32_t, vstd::RNG &));
|
||||
MOCK_CONST_METHOD3(getActualDamage, int64_t(const DamageRange &, int32_t, vstd::RNG &));
|
||||
|
||||
MOCK_METHOD1(nextRound, void(int32_t));
|
||||
MOCK_METHOD1(nextTurn, void(uint32_t));
|
||||
|
@ -57,6 +57,7 @@ public:
|
||||
MOCK_CONST_METHOD0(requiresClearTiles, bool());
|
||||
MOCK_CONST_METHOD0(isNegativeSpell, bool());
|
||||
MOCK_CONST_METHOD0(isPositiveSpell, bool());
|
||||
MOCK_CONST_METHOD0(isMagicalEffect, bool());
|
||||
|
||||
MOCK_CONST_METHOD1(adjustEffectValue,int64_t(const battle::Unit *));
|
||||
MOCK_CONST_METHOD2(applySpellBonus,int64_t(int64_t, const battle::Unit *));
|
||||
|
@ -43,6 +43,7 @@ public:
|
||||
MOCK_CONST_METHOD0(isDamage, bool());
|
||||
MOCK_CONST_METHOD0(isOffensive, bool());
|
||||
MOCK_CONST_METHOD0(isSpecial, bool());
|
||||
MOCK_CONST_METHOD0(isMagical, bool());
|
||||
MOCK_CONST_METHOD1(forEachSchool, void(const SchoolCallback &));
|
||||
MOCK_CONST_METHOD0(getCastSound, const std::string &());
|
||||
MOCK_CONST_METHOD1(registerIcons, void(const IconRegistar &));
|
||||
|
@ -43,6 +43,7 @@ public:
|
||||
MOCK_CONST_METHOD0(createElemental, Object());
|
||||
MOCK_CONST_METHOD0(createNormalLevel, Object());
|
||||
MOCK_CONST_METHOD0(createNormalSpell, Object());
|
||||
MOCK_CONST_METHOD1(createFromJsonStruct, Object(const JsonNode &));
|
||||
MOCK_CONST_METHOD3(createConfigurable, Object(std::string, std::string, std::string));
|
||||
MOCK_CONST_METHOD0(createReceptiveFeature, Object());
|
||||
MOCK_CONST_METHOD0(createImmunityNegation, Object());
|
||||
|
@ -118,13 +118,18 @@ TEST_F(CatapultApplyTest, DamageToIntactPart)
|
||||
{
|
||||
JsonNode config(JsonNode::JsonType::DATA_STRUCT);
|
||||
config["targetsToAttack"].Integer() = 1;
|
||||
config["chanceToNormalHit"].Integer() = 100;
|
||||
EffectFixture::setupEffect(config);
|
||||
}
|
||||
|
||||
setDefaultExpectations();
|
||||
|
||||
const EWallPart targetPart = EWallPart::BELOW_GATE;
|
||||
auto & actualCaster = unitsFake.add(BattleSide::ATTACKER);
|
||||
|
||||
mechanicsMock.caster = &actualCaster;
|
||||
EXPECT_CALL(actualCaster, getCasterUnitId()).WillRepeatedly(Return(-1));
|
||||
EXPECT_CALL(mechanicsMock, isMassive()).WillRepeatedly(Return(true));
|
||||
EXPECT_CALL(*battleFake, getWallState(_)).WillRepeatedly(Return(EWallState::DESTROYED));
|
||||
EXPECT_CALL(*battleFake, getWallState(Eq(targetPart))).WillRepeatedly(Return(EWallState::INTACT));
|
||||
EXPECT_CALL(*battleFake, setWallState(Eq(targetPart), Eq(EWallState::DAMAGED))).Times(1);
|
||||
|
@ -45,7 +45,6 @@ TEST_F(DamageTest, ApplicableToAliveUnit)
|
||||
EXPECT_CALL(unit, isValidTarget(Eq(false))).WillOnce(Return(true));
|
||||
|
||||
EXPECT_CALL(mechanicsMock, isSmart()).WillOnce(Return(false));
|
||||
EXPECT_CALL(mechanicsMock, ownerMatches(Eq(&unit))).WillOnce(Return(true));
|
||||
|
||||
EffectTarget target;
|
||||
target.emplace_back(&unit, BattleHex());
|
||||
|
@ -79,7 +79,6 @@ TEST_F(DispelTest, ApplicableToAliveUnitWithTimedEffect)
|
||||
EXPECT_CALL(unit, isValidTarget(Eq(false))).WillOnce(Return(true));
|
||||
|
||||
EXPECT_CALL(mechanicsMock, isSmart()).WillOnce(Return(false));
|
||||
EXPECT_CALL(mechanicsMock, ownerMatches(Eq(&unit))).WillOnce(Return(true));
|
||||
EXPECT_CALL(mechanicsMock, getSpellIndex()).Times(AtLeast(1)).WillRepeatedly(Return(neutralID.toEnum()));
|
||||
|
||||
setDefaultExpectaions();
|
||||
|
@ -49,7 +49,6 @@ TEST_F(HealTest, NotApplicableToHealthyUnit)
|
||||
EXPECT_CALL(unit, getAvailableHealth()).WillOnce(Return(200));
|
||||
|
||||
EXPECT_CALL(mechanicsMock, isSmart()).Times(AtMost(1)).WillRepeatedly(Return(false));
|
||||
EXPECT_CALL(mechanicsMock, ownerMatches(Eq(&unit))).Times(AtMost(1)).WillRepeatedly(Return(true));
|
||||
|
||||
EffectTarget target;
|
||||
target.emplace_back(&unit, BattleHex());
|
||||
@ -67,7 +66,6 @@ TEST_F(HealTest, ApplicableToWoundedUnit)
|
||||
EXPECT_CALL(unit, getAvailableHealth()).WillOnce(Return(100));
|
||||
|
||||
EXPECT_CALL(mechanicsMock, isSmart()).WillOnce(Return(false));
|
||||
EXPECT_CALL(mechanicsMock, ownerMatches(Eq(&unit))).WillOnce(Return(true));
|
||||
|
||||
EffectTarget target;
|
||||
target.emplace_back(&unit, BattleHex());
|
||||
@ -92,7 +90,6 @@ TEST_F(HealTest, ApplicableIfActuallyResurrects)
|
||||
|
||||
EXPECT_CALL(mechanicsMock, getEffectValue()).Times(AtLeast(1)).WillRepeatedly(Return(1000));
|
||||
EXPECT_CALL(mechanicsMock, isSmart()).WillOnce(Return(false));
|
||||
EXPECT_CALL(mechanicsMock, ownerMatches(Eq(&unit))).WillOnce(Return(true));
|
||||
|
||||
unit.addNewBonus(std::make_shared<Bonus>(Bonus::PERMANENT, Bonus::STACK_HEALTH, Bonus::CREATURE_ABILITY, 200, 0));
|
||||
unitsFake.setDefaultBonusExpectations();
|
||||
@ -119,7 +116,6 @@ TEST_F(HealTest, NotApplicableIfNotEnoughCasualties)
|
||||
|
||||
EXPECT_CALL(mechanicsMock, getEffectValue()).Times(AtLeast(1)).WillRepeatedly(Return(999));
|
||||
EXPECT_CALL(mechanicsMock, isSmart()).WillRepeatedly(Return(false));
|
||||
EXPECT_CALL(mechanicsMock, ownerMatches(Eq(&unit))).WillRepeatedly(Return(true));
|
||||
|
||||
unit.addNewBonus(std::make_shared<Bonus>(Bonus::PERMANENT, Bonus::STACK_HEALTH, Bonus::CREATURE_ABILITY, 200, 0));
|
||||
unitsFake.setDefaultBonusExpectations();
|
||||
@ -146,7 +142,6 @@ TEST_F(HealTest, NotApplicableIfResurrectsLessThanRequired)
|
||||
|
||||
EXPECT_CALL(mechanicsMock, getEffectValue()).Times(AtLeast(1)).WillRepeatedly(Return(999));
|
||||
EXPECT_CALL(mechanicsMock, isSmart()).WillRepeatedly(Return(false));
|
||||
EXPECT_CALL(mechanicsMock, ownerMatches(Eq(&unit))).WillRepeatedly(Return(true));
|
||||
|
||||
unit.addNewBonus(std::make_shared<Bonus>(Bonus::PERMANENT, Bonus::STACK_HEALTH, Bonus::CREATURE_ABILITY, 200, 0));
|
||||
unitsFake.setDefaultBonusExpectations();
|
||||
@ -179,7 +174,6 @@ TEST_F(HealTest, ApplicableToDeadUnit)
|
||||
|
||||
|
||||
EXPECT_CALL(mechanicsMock, isSmart()).WillOnce(Return(false));
|
||||
EXPECT_CALL(mechanicsMock, ownerMatches(Eq(&unit))).WillOnce(Return(true));
|
||||
|
||||
EXPECT_CALL(*battleFake, getUnitsIf(_)).Times(AtLeast(0));
|
||||
|
||||
@ -217,7 +211,6 @@ TEST_F(HealTest, NotApplicableIfDeadUnitIsBlocked)
|
||||
EXPECT_CALL(blockingUnit, unitSide()).Times(AnyNumber());
|
||||
|
||||
EXPECT_CALL(mechanicsMock, isSmart()).WillRepeatedly(Return(false));
|
||||
EXPECT_CALL(mechanicsMock, ownerMatches(Eq(&unit))).WillRepeatedly(Return(true));
|
||||
|
||||
EXPECT_CALL(*battleFake, getUnitsIf(_)).Times(AtLeast(1));
|
||||
|
||||
@ -255,7 +248,6 @@ TEST_F(HealTest, ApplicableWithAnotherDeadUnitInSamePosition)
|
||||
EXPECT_CALL(blockingUnit, unitSide()).Times(AnyNumber());
|
||||
|
||||
EXPECT_CALL(mechanicsMock, isSmart()).WillRepeatedly(Return(false));
|
||||
EXPECT_CALL(mechanicsMock, ownerMatches(Eq(&unit))).WillRepeatedly(Return(true));
|
||||
|
||||
EXPECT_CALL(*battleFake, getUnitsIf(_)).Times(AtLeast(1));
|
||||
|
||||
@ -284,7 +276,6 @@ TEST_F(HealTest, NotApplicableIfEffectValueTooLow)
|
||||
EXPECT_CALL(mechanicsMock, getEffectValue()).Times(AtLeast(1)).WillRepeatedly(Return(199));
|
||||
|
||||
EXPECT_CALL(mechanicsMock, isSmart()).Times(AtMost(1)).WillRepeatedly(Return(false));
|
||||
EXPECT_CALL(mechanicsMock, ownerMatches(Eq(&unit))).Times(AtMost(1)).WillRepeatedly(Return(true));
|
||||
|
||||
unitsFake.setDefaultBonusExpectations();
|
||||
|
||||
@ -352,6 +343,7 @@ TEST_P(HealApplyTest, Heals)
|
||||
|
||||
|
||||
auto & targetUnit = unitsFake.add(BattleSide::ATTACKER);
|
||||
auto & actualCaster = unitsFake.add(BattleSide::ATTACKER);
|
||||
EXPECT_CALL(targetUnit, unitBaseAmount()).WillRepeatedly(Return(unitAmount));
|
||||
EXPECT_CALL(targetUnit, unitId()).WillRepeatedly(Return(unitId));
|
||||
EXPECT_CALL(targetUnit, unitType()).WillRepeatedly(Return(pikeman));
|
||||
@ -367,16 +359,19 @@ TEST_P(HealApplyTest, Heals)
|
||||
targetUnitState->health.damage(initialDmg);
|
||||
}
|
||||
|
||||
mechanicsMock.caster = &actualCaster;
|
||||
EXPECT_CALL(mechanicsMock, getEffectValue()).WillRepeatedly(Return(effectValue));
|
||||
EXPECT_CALL(mechanicsMock, applySpellBonus(Eq(effectValue), Eq(&targetUnit))).WillRepeatedly(Return(effectValue));
|
||||
|
||||
GTEST_ASSERT_EQ(targetUnitState->getAvailableHealth(), unitAmount * unitHP / 2 + 1);
|
||||
GTEST_ASSERT_EQ(targetUnitState->getFirstHPleft(), 1);
|
||||
|
||||
EXPECT_CALL(targetUnit, acquire()).WillOnce(Return(targetUnitState));
|
||||
EXPECT_CALL(targetUnit, acquire()).WillRepeatedly(Return(targetUnitState));
|
||||
|
||||
EXPECT_CALL(*battleFake, setUnitState(Eq(unitId), _, Gt(0))).Times(1);
|
||||
|
||||
EXPECT_CALL(actualCaster, getCasterUnitId()).WillRepeatedly(Return(-1));
|
||||
|
||||
//There should be battle log message if resurrect
|
||||
switch(healLevel)
|
||||
{
|
||||
|
@ -23,6 +23,7 @@ public:
|
||||
|
||||
void setDefaultExpectations()
|
||||
{
|
||||
EXPECT_CALL(mechanicsMock, isMagicalEffect()).WillRepeatedly(Return(true));
|
||||
EXPECT_CALL(unitMock, getAllBonuses(_, _, _, _)).Times(AtLeast(1));
|
||||
EXPECT_CALL(unitMock, getTreeVersion()).Times(AtLeast(0));
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ public:
|
||||
|
||||
void setDefaultExpectations()
|
||||
{
|
||||
EXPECT_CALL(mechanicsMock, isMagicalEffect()).WillRepeatedly(Return(true));
|
||||
EXPECT_CALL(unitMock, getAllBonuses(_, _, _, _)).Times(AtLeast(1));
|
||||
EXPECT_CALL(unitMock, getTreeVersion()).Times(AtLeast(0));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user