mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Improve Plugin tests
This commit is contained in:
+1
-1
@@ -253,7 +253,7 @@ set (LOOT_TESTS_HEADERS "${CMAKE_SOURCE_DIR}/src/tests/base_game_test.h"
|
||||
"${CMAKE_SOURCE_DIR}/src/tests/backend/metadata/plugin_dirty_info_test.h"
|
||||
"${CMAKE_SOURCE_DIR}/src/tests/backend/metadata/plugin_metadata_test.h"
|
||||
"${CMAKE_SOURCE_DIR}/src/tests/backend/metadata/tag_test.h"
|
||||
"${CMAKE_SOURCE_DIR}/src/tests/backend/plugin/test_plugin.h"
|
||||
"${CMAKE_SOURCE_DIR}/src/tests/backend/plugin/plugin_test.h"
|
||||
"${CMAKE_SOURCE_DIR}/src/tests/backend/test_metadata_list.h"
|
||||
"${CMAKE_SOURCE_DIR}/src/tests/backend/test_masterlist.h"
|
||||
"${CMAKE_SOURCE_DIR}/src/tests/backend/test_plugin_sorter.h"
|
||||
|
||||
@@ -0,0 +1,311 @@
|
||||
/* LOOT
|
||||
|
||||
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
|
||||
Fallout: New Vegas.
|
||||
|
||||
Copyright (C) 2014-2016 WrinklyNinja
|
||||
|
||||
This file is part of LOOT.
|
||||
|
||||
LOOT is free software: you can redistribute
|
||||
it and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
LOOT is distributed in the hope that it will
|
||||
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LOOT. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef LOOT_TEST_BACKEND_PLUGIN
|
||||
#define LOOT_TEST_BACKEND_PLUGIN
|
||||
|
||||
#include "backend/plugin/plugin.h"
|
||||
#include "tests/base_game_test.h"
|
||||
|
||||
namespace loot {
|
||||
namespace test {
|
||||
class PluginTest : public BaseGameTest {
|
||||
protected:
|
||||
PluginTest() :
|
||||
emptyFile("EmptyFile.esm"),
|
||||
nonPluginFile("NotAPlugin.esm") {}
|
||||
|
||||
inline void SetUp() {
|
||||
BaseGameTest::SetUp();
|
||||
|
||||
game = Game(GetParam());
|
||||
game.SetGamePath(dataPath.parent_path());
|
||||
game.Init(false, localPath);
|
||||
|
||||
// Write out an empty file.
|
||||
boost::filesystem::ofstream out(dataPath / emptyFile);
|
||||
out.close();
|
||||
ASSERT_TRUE(boost::filesystem::exists(dataPath / emptyFile));
|
||||
|
||||
// Write out an non-empty, non-plugin file.
|
||||
out.open(dataPath / nonPluginFile);
|
||||
out << "This isn't a valid plugin file.";
|
||||
out.close();
|
||||
ASSERT_TRUE(boost::filesystem::exists(dataPath / nonPluginFile));
|
||||
|
||||
if (GetParam() == GameSettings::tes4 || GetParam() == GameSettings::fo4) {
|
||||
// Create a dummy BSA file.
|
||||
out.open(dataPath / getArchiveName());
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
inline void TearDown() {
|
||||
BaseGameTest::TearDown();
|
||||
|
||||
boost::filesystem::remove(dataPath / emptyFile);
|
||||
boost::filesystem::remove(dataPath / nonPluginFile);
|
||||
|
||||
if (GetParam() == GameSettings::tes4 || GetParam() == GameSettings::fo4)
|
||||
boost::filesystem::remove(dataPath / getArchiveName());
|
||||
}
|
||||
|
||||
Game game;
|
||||
|
||||
const std::string emptyFile;
|
||||
const std::string nonPluginFile;
|
||||
|
||||
private:
|
||||
inline std::string getArchiveName() {
|
||||
if (GetParam() == GameSettings::fo4)
|
||||
return "Blank.ba2";
|
||||
else
|
||||
return "Blank.bsa";
|
||||
}
|
||||
};
|
||||
|
||||
// Pass an empty first argument, as it's a prefix for the test instantation,
|
||||
// but we only have the one so no prefix is necessary.
|
||||
INSTANTIATE_TEST_CASE_P(,
|
||||
PluginTest,
|
||||
::testing::Values(
|
||||
GameSettings::tes4,
|
||||
GameSettings::tes5,
|
||||
GameSettings::fo3,
|
||||
GameSettings::fonv,
|
||||
GameSettings::fo4));
|
||||
|
||||
TEST_P(PluginTest, loadingHeaderOnlyShouldReadHeaderData) {
|
||||
Plugin plugin(game, blankEsm, true);
|
||||
|
||||
EXPECT_EQ(blankEsm, plugin.Name());
|
||||
EXPECT_TRUE(plugin.getMasters().empty());
|
||||
EXPECT_TRUE(plugin.isMasterFile());
|
||||
EXPECT_FALSE(plugin.IsEmpty());
|
||||
EXPECT_EQ("v5.0", plugin.getDescription());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, loadingHeaderOnlyShouldNotReadFieldsOrCalculateCrc) {
|
||||
Plugin plugin(game, blankEsm, true);
|
||||
|
||||
EXPECT_TRUE(plugin.getFormIds().empty());
|
||||
EXPECT_EQ(0, plugin.Crc());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, loadingWholePluginShouldReadHeaderData) {
|
||||
Plugin plugin(game, blankEsm, true);
|
||||
|
||||
EXPECT_EQ(blankEsm, plugin.Name());
|
||||
EXPECT_TRUE(plugin.getMasters().empty());
|
||||
EXPECT_TRUE(plugin.isMasterFile());
|
||||
EXPECT_FALSE(plugin.IsEmpty());
|
||||
EXPECT_EQ("v5.0", plugin.getDescription());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, loadingWholePluginShouldReadFields) {
|
||||
Plugin plugin(game, blankMasterDependentEsm, false);
|
||||
|
||||
EXPECT_EQ(4, plugin.NumOverrideFormIDs());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, loadingWholePluginShouldCalculateCrc) {
|
||||
Plugin plugin(game, blankEsm, false);
|
||||
|
||||
EXPECT_EQ(blankEsmCrc, plugin.Crc());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, loadingANonMasterPluginShouldReadTheMasterFlagAsFalse) {
|
||||
Plugin plugin(game, blankMasterDependentEsp, true);
|
||||
|
||||
EXPECT_FALSE(plugin.isMasterFile());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, loadingAPluginWithMastersShouldReadThemCorrectly) {
|
||||
Plugin plugin(game, blankMasterDependentEsp, true);
|
||||
|
||||
EXPECT_EQ(std::vector<std::string>({
|
||||
blankEsm
|
||||
}), plugin.getMasters());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, loadsArchiveShouldReturnTrueForAPluginThatLoadsAnArchive) {
|
||||
EXPECT_TRUE(Plugin(game, blankEsp, true).LoadsArchive());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, loadsArchiveShouldReturnFalseForAPluginThatDoesNotLoadAnArchive) {
|
||||
EXPECT_FALSE(Plugin(game, blankDifferentEsm, true).LoadsArchive());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, loadsArchiveShouldReturnFalseForAPluginWithARegexFilename) {
|
||||
EXPECT_FALSE(Plugin(game, "Blank\\.esp", true).LoadsArchive());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, isValidShouldReturnTrueForAValidPlugin) {
|
||||
EXPECT_TRUE(Plugin::IsValid(blankEsm, game));
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, isValidShouldReturnFalseForANonPluginFile) {
|
||||
EXPECT_FALSE(Plugin::IsValid(nonPluginFile, game));
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, isValidShouldReturnFalseForAnEmptyFile) {
|
||||
EXPECT_FALSE(Plugin::IsValid(emptyFile, game));
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, isActiveShouldReturnTrueForAPluginThatIsActive) {
|
||||
EXPECT_TRUE(Plugin(game, blankEsm, true).IsActive());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, isActiveShouldReturnFalseForAPluginThatIsNotActive) {
|
||||
EXPECT_FALSE(Plugin(game, blankEsp, true).IsActive());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, lessThanOperatorShouldUseCaseInsensitiveLexicographicalNameComparison) {
|
||||
Plugin plugin1(game, "Blank.esp", true);
|
||||
Plugin plugin2(game, "blank.esp", true);
|
||||
|
||||
EXPECT_FALSE(plugin1 < plugin2);
|
||||
EXPECT_FALSE(plugin2 < plugin1);
|
||||
|
||||
plugin1 = Plugin(game, "blank.esm", true);
|
||||
plugin2 = Plugin(game, "blank.esp", true);
|
||||
|
||||
EXPECT_TRUE(plugin1 < plugin2);
|
||||
EXPECT_FALSE(plugin2 < plugin1);
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, doFormIDsOverlapShouldReturnFalseForTwoPluginsWithOnlyHeadersLoaded) {
|
||||
Plugin plugin1(game, blankEsm, true);
|
||||
Plugin plugin2(game, blankMasterDependentEsm, true);
|
||||
|
||||
EXPECT_FALSE(plugin1.DoFormIDsOverlap(plugin2));
|
||||
EXPECT_FALSE(plugin2.DoFormIDsOverlap(plugin1));
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, doFormIDsOverlapShouldReturnFalseIfThePluginsHaveUnrelatedRecords) {
|
||||
Plugin plugin1(game, blankEsm, false);
|
||||
Plugin plugin2(game, blankEsp, false);
|
||||
|
||||
EXPECT_FALSE(plugin1.DoFormIDsOverlap(plugin2));
|
||||
EXPECT_FALSE(plugin2.DoFormIDsOverlap(plugin1));
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, doFormIDsOverlapShouldReturnTrueIfOnePluginOverridesTheOthersRecords) {
|
||||
Plugin plugin1(game, blankEsm, false);
|
||||
Plugin plugin2(game, blankMasterDependentEsm, false);
|
||||
|
||||
EXPECT_TRUE(plugin1.DoFormIDsOverlap(plugin2));
|
||||
EXPECT_TRUE(plugin2.DoFormIDsOverlap(plugin1));
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, overlapFormIDsShouldReturnAnEmptySetForTwoPluginsWithOnlyHeadersLoaded) {
|
||||
Plugin plugin1(game, blankEsm, true);
|
||||
Plugin plugin2(game, blankMasterDependentEsm, true);
|
||||
|
||||
EXPECT_TRUE(plugin1.OverlapFormIDs(plugin2).empty());
|
||||
EXPECT_TRUE(plugin2.OverlapFormIDs(plugin1).empty());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, overlapFormIDsShouldReturnAnEmptySetIfThePluginsHaveUnrelatedRecords) {
|
||||
Plugin plugin1(game, blankEsm, false);
|
||||
Plugin plugin2(game, blankEsp, false);
|
||||
|
||||
EXPECT_TRUE(plugin1.OverlapFormIDs(plugin2).empty());
|
||||
EXPECT_TRUE(plugin2.OverlapFormIDs(plugin1).empty());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, overlapFormIDsShouldReturnTheFormIDsOfRecordsAddedByOnePluginAndOverriddenByTheOther) {
|
||||
Plugin plugin1(game, blankEsm, false);
|
||||
Plugin plugin2(game, blankMasterDependentEsm, false);
|
||||
|
||||
std::set<libespm::FormId> expectedFormIds({
|
||||
libespm::FormId(blankEsm, std::vector<std::string>(), 0xCF0),
|
||||
libespm::FormId(blankEsm, std::vector<std::string>(), 0xCF1),
|
||||
libespm::FormId(blankEsm, std::vector<std::string>(), 0xCF2),
|
||||
libespm::FormId(blankEsm, std::vector<std::string>(), 0xCF3),
|
||||
});
|
||||
EXPECT_EQ(expectedFormIds, plugin1.OverlapFormIDs(plugin2));
|
||||
EXPECT_EQ(expectedFormIds, plugin2.OverlapFormIDs(plugin1));
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, checkInstallValidityShouldCheckThatRequirementsArePresent) {
|
||||
Plugin plugin(game, blankEsm, false);
|
||||
plugin.Reqs({
|
||||
File(missingEsp),
|
||||
File(blankEsp),
|
||||
});
|
||||
|
||||
EXPECT_FALSE(plugin.CheckInstallValidity(game));
|
||||
EXPECT_EQ(std::list<Message>({
|
||||
Message(Message::error, "This plugin requires \"" + missingEsp + "\" to be installed, but it is missing."),
|
||||
}), plugin.Messages());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, checkInstallValidityShouldCheckThatIncompatibilitiesAreAbsent) {
|
||||
Plugin plugin(game, blankEsm, false);
|
||||
plugin.Incs({
|
||||
File(missingEsp),
|
||||
File(masterFile),
|
||||
});
|
||||
|
||||
EXPECT_FALSE(plugin.CheckInstallValidity(game));
|
||||
EXPECT_EQ(std::list<Message>({
|
||||
Message(Message::error, "This plugin is incompatible with \"" + masterFile + "\", but both are present."),
|
||||
}), plugin.Messages());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, checkInstallValidityShouldGenerateMessagesFromDirtyInfo) {
|
||||
Plugin plugin(game, blankEsm, false);
|
||||
plugin.DirtyInfo({
|
||||
PluginDirtyInfo(blankEsmCrc, 0, 1, 2, "utility1"),
|
||||
PluginDirtyInfo(0xDEADBEEF, 0, 5, 10, "utility2"),
|
||||
});
|
||||
|
||||
EXPECT_TRUE(plugin.CheckInstallValidity(game));
|
||||
EXPECT_EQ(std::list<Message>({
|
||||
PluginDirtyInfo(blankEsmCrc, 0, 1, 2, "utility1").AsMessage(),
|
||||
PluginDirtyInfo(0xDEADBEEF, 0, 5, 10, "utility2").AsMessage(),
|
||||
}), plugin.Messages());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, checkInstallValidityShouldCheckIfAPluginsMastersAreAllPresentAndActiveIfNoFilterTagIsPresent) {
|
||||
Plugin plugin(game, blankDifferentMasterDependentEsp, false);
|
||||
|
||||
EXPECT_FALSE(plugin.CheckInstallValidity(game));
|
||||
EXPECT_EQ(std::list<Message>({
|
||||
Message(Message::error, "This plugin requires \"" + blankDifferentEsm + "\" to be active, but it is inactive."),
|
||||
}), plugin.Messages());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, checkInstallValidityShouldNotCheckIfAPluginsMastersAreAllActiveIfAFilterTagIsPresent) {
|
||||
Plugin plugin(game, blankDifferentMasterDependentEsp, false);
|
||||
plugin.Tags({Tag("Filter")});
|
||||
|
||||
EXPECT_FALSE(plugin.CheckInstallValidity(game));
|
||||
EXPECT_TRUE(plugin.Messages().empty());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,258 +0,0 @@
|
||||
/* LOOT
|
||||
|
||||
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
|
||||
Fallout: New Vegas.
|
||||
|
||||
Copyright (C) 2014-2016 WrinklyNinja
|
||||
|
||||
This file is part of LOOT.
|
||||
|
||||
LOOT is free software: you can redistribute
|
||||
it and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
LOOT is distributed in the hope that it will
|
||||
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LOOT. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef LOOT_TEST_BACKEND_PLUGIN
|
||||
#define LOOT_TEST_BACKEND_PLUGIN
|
||||
|
||||
#include "backend/plugin/plugin.h"
|
||||
#include "tests/fixtures.h"
|
||||
|
||||
namespace loot {
|
||||
namespace test {
|
||||
class PluginTest : public SkyrimTest {
|
||||
protected:
|
||||
inline virtual void SetUp() {
|
||||
SkyrimTest::SetUp();
|
||||
|
||||
game = Game(Game::tes5);
|
||||
game.SetGamePath(dataPath.parent_path());
|
||||
ASSERT_NO_THROW(game.Init(false, localPath));
|
||||
}
|
||||
|
||||
Game game;
|
||||
};
|
||||
|
||||
TEST_F(PluginTest, ConstructorsAndDataAccess) {
|
||||
Plugin plugin(game, "Blank.esm", true);
|
||||
EXPECT_EQ("Blank.esm", plugin.Name());
|
||||
EXPECT_TRUE(plugin.getFormIds().empty());
|
||||
EXPECT_TRUE(plugin.getMasters().empty());
|
||||
EXPECT_TRUE(plugin.isMasterFile());
|
||||
EXPECT_FALSE(plugin.IsEmpty());
|
||||
EXPECT_EQ("v5.0", plugin.getDescription());
|
||||
EXPECT_EQ(0, plugin.Crc());
|
||||
|
||||
plugin = Plugin(game, "Blank.esm", false);
|
||||
EXPECT_EQ("Blank.esm", plugin.Name());
|
||||
EXPECT_EQ(std::set<libespm::FormId>({
|
||||
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF0),
|
||||
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF1),
|
||||
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF2),
|
||||
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF3),
|
||||
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF4),
|
||||
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF5),
|
||||
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF6),
|
||||
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF7),
|
||||
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF8),
|
||||
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF9),
|
||||
}), plugin.getFormIds());
|
||||
EXPECT_TRUE(plugin.getMasters().empty());
|
||||
EXPECT_TRUE(plugin.isMasterFile());
|
||||
EXPECT_FALSE(plugin.IsEmpty());
|
||||
EXPECT_EQ("v5.0", plugin.getDescription());
|
||||
EXPECT_EQ(0x187BE342, plugin.Crc());
|
||||
|
||||
plugin = Plugin(game, "Blank - Master Dependent.esp", false);
|
||||
EXPECT_EQ("Blank - Master Dependent.esp", plugin.Name());
|
||||
EXPECT_FALSE(plugin.IsEmpty());
|
||||
EXPECT_FALSE(plugin.isMasterFile());
|
||||
EXPECT_EQ(std::set<libespm::FormId>({
|
||||
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF0),
|
||||
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF1),
|
||||
libespm::FormId("Blank - Master Dependent.esp", std::vector<std::string>(), 0xCE9),
|
||||
libespm::FormId("Blank - Master Dependent.esp", std::vector<std::string>(), 0xCEA),
|
||||
}), plugin.getFormIds());
|
||||
EXPECT_EQ(std::vector<std::string>({
|
||||
"Blank.esm"
|
||||
}), plugin.getMasters());
|
||||
EXPECT_EQ("", plugin.getDescription());
|
||||
EXPECT_EQ(0x832152DC, plugin.Crc());
|
||||
}
|
||||
|
||||
TEST_F(PluginTest, LoadsArchive) {
|
||||
EXPECT_FALSE(Plugin(game, "Blank - Different.esm", true).LoadsArchive());
|
||||
EXPECT_FALSE(Plugin(game, "Blank\\.esm", true).LoadsArchive());
|
||||
EXPECT_TRUE(Plugin(game, "Blank.esm", true).LoadsArchive());
|
||||
}
|
||||
|
||||
TEST_F(PluginTest, IsValid) {
|
||||
EXPECT_TRUE(Plugin::IsValid("Blank.esm", game));
|
||||
EXPECT_FALSE(Plugin::IsValid("NotAPlugin.esm", game));
|
||||
EXPECT_FALSE(Plugin::IsValid("EmptyFile.esm", game));
|
||||
}
|
||||
|
||||
TEST_F(PluginTest, IsActive) {
|
||||
Plugin plugin(game, "Blank.esm", true);
|
||||
EXPECT_TRUE(plugin.IsActive());
|
||||
|
||||
plugin = Plugin(game, "Blank.esp", true);
|
||||
EXPECT_FALSE(plugin.IsActive());
|
||||
}
|
||||
|
||||
TEST_F(PluginTest, EqualityOperator) {
|
||||
Plugin plugin1(game, "Blank.esm", true);
|
||||
Plugin plugin2(game, "blank.esm", true);
|
||||
EXPECT_TRUE(plugin1 == plugin2);
|
||||
EXPECT_TRUE(plugin2 == plugin1);
|
||||
|
||||
plugin2 = Plugin(game, "Blank.esp", true);
|
||||
EXPECT_FALSE(plugin1 == plugin2);
|
||||
EXPECT_FALSE(plugin2 == plugin1);
|
||||
|
||||
plugin2 = Plugin(game, "Blan.\\.esm", true);
|
||||
EXPECT_TRUE(plugin1 == plugin2);
|
||||
EXPECT_TRUE(plugin2 == plugin1);
|
||||
|
||||
plugin1 = Plugin(game, "Blan.esm", true);
|
||||
EXPECT_FALSE(plugin1 == plugin2);
|
||||
EXPECT_FALSE(plugin2 == plugin1);
|
||||
|
||||
plugin1 = Plugin(game, "Blan.\\.esm", true);
|
||||
EXPECT_TRUE(plugin1 == plugin2);
|
||||
EXPECT_TRUE(plugin2 == plugin1);
|
||||
|
||||
plugin1 = Plugin(game, "Blan(k|p).esm", true);
|
||||
EXPECT_FALSE(plugin1 == plugin2);
|
||||
EXPECT_FALSE(plugin2 == plugin1);
|
||||
}
|
||||
|
||||
TEST_F(PluginTest, InequalityOperator) {
|
||||
Plugin plugin1(game, "Blank.esm", true);
|
||||
Plugin plugin2(game, "blank.esm", true);
|
||||
EXPECT_FALSE(plugin1 != plugin2);
|
||||
EXPECT_FALSE(plugin2 != plugin1);
|
||||
|
||||
plugin2 = Plugin(game, "Blank.esp", true);
|
||||
EXPECT_TRUE(plugin1 != plugin2);
|
||||
EXPECT_TRUE(plugin2 != plugin1);
|
||||
|
||||
plugin2 = Plugin(game, "Blan.\\.esm", true);
|
||||
EXPECT_FALSE(plugin1 != plugin2);
|
||||
EXPECT_FALSE(plugin2 != plugin1);
|
||||
|
||||
plugin1 = Plugin(game, "Blan.esm", true);
|
||||
EXPECT_TRUE(plugin1 != plugin2);
|
||||
EXPECT_TRUE(plugin2 != plugin1);
|
||||
|
||||
plugin1 = Plugin(game, "Blan.\\.esm", true);
|
||||
EXPECT_FALSE(plugin1 != plugin2);
|
||||
EXPECT_FALSE(plugin2 != plugin1);
|
||||
|
||||
plugin1 = Plugin(game, "Blan(k|p).esm", true);
|
||||
EXPECT_TRUE(plugin1 != plugin2);
|
||||
EXPECT_TRUE(plugin2 != plugin1);
|
||||
}
|
||||
|
||||
TEST_F(PluginTest, DoFormIDsOverlap) {
|
||||
Plugin plugin1(game, "Blank.esm", true);
|
||||
Plugin plugin2(game, "blank.esm", true);
|
||||
EXPECT_FALSE(plugin1.DoFormIDsOverlap(plugin2));
|
||||
EXPECT_FALSE(plugin2.DoFormIDsOverlap(plugin1));
|
||||
|
||||
plugin1 = Plugin(game, "Blank.esm", true);
|
||||
plugin2 = Plugin(game, "Blank - Master Dependent.esm", true);
|
||||
EXPECT_FALSE(plugin1.DoFormIDsOverlap(plugin2));
|
||||
EXPECT_FALSE(plugin2.DoFormIDsOverlap(plugin1));
|
||||
|
||||
plugin1 = Plugin(game, "Blank.esm", false);
|
||||
plugin2 = Plugin(game, "Blank.esp", false);
|
||||
EXPECT_FALSE(plugin1.DoFormIDsOverlap(plugin2));
|
||||
EXPECT_FALSE(plugin2.DoFormIDsOverlap(plugin1));
|
||||
|
||||
plugin1 = Plugin(game, "Blank.esm", false);
|
||||
plugin2 = Plugin(game, "Blank - Master Dependent.esm", false);
|
||||
EXPECT_TRUE(plugin1.DoFormIDsOverlap(plugin2));
|
||||
EXPECT_TRUE(plugin2.DoFormIDsOverlap(plugin1));
|
||||
}
|
||||
|
||||
TEST_F(PluginTest, OverlapFormIDs) {
|
||||
Plugin plugin1(game, "Blank.esm", true);
|
||||
Plugin plugin2(game, "blank.esm", true);
|
||||
EXPECT_TRUE(plugin1.OverlapFormIDs(plugin2).empty());
|
||||
EXPECT_TRUE(plugin2.OverlapFormIDs(plugin1).empty());
|
||||
|
||||
plugin1 = Plugin(game, "Blank.esm", true);
|
||||
plugin2 = Plugin(game, "Blank - Master Dependent.esm", true);
|
||||
EXPECT_TRUE(plugin1.OverlapFormIDs(plugin2).empty());
|
||||
EXPECT_TRUE(plugin2.OverlapFormIDs(plugin1).empty());
|
||||
|
||||
plugin1 = Plugin(game, "Blank.esm", false);
|
||||
plugin2 = Plugin(game, "Blank.esp", false);
|
||||
EXPECT_TRUE(plugin1.OverlapFormIDs(plugin2).empty());
|
||||
EXPECT_TRUE(plugin2.OverlapFormIDs(plugin1).empty());
|
||||
|
||||
plugin1 = Plugin(game, "Blank.esm", false);
|
||||
plugin2 = Plugin(game, "Blank - Master Dependent.esm", false);
|
||||
EXPECT_EQ(std::set<libespm::FormId>({
|
||||
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF0),
|
||||
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF1),
|
||||
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF2),
|
||||
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF3),
|
||||
}), plugin1.OverlapFormIDs(plugin2));
|
||||
EXPECT_EQ(std::set<libespm::FormId>({
|
||||
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF0),
|
||||
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF1),
|
||||
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF2),
|
||||
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF3),
|
||||
}), plugin2.OverlapFormIDs(plugin1));
|
||||
}
|
||||
|
||||
TEST_F(PluginTest, CheckInstallValidity) {
|
||||
Plugin plugin(game, "Blank.esm", false);
|
||||
plugin.Reqs({
|
||||
File("Blank.missing.esm"),
|
||||
File("Blank.esp"),
|
||||
File("Blank - Master Dependent.esm"),
|
||||
});
|
||||
plugin.Incs({
|
||||
File("Blank - Different.esm"),
|
||||
File("Skyrim.esm"),
|
||||
});
|
||||
plugin.DirtyInfo({
|
||||
PluginDirtyInfo(0x187BE342, 0, 1, 2, "utility1"),
|
||||
PluginDirtyInfo(0xDEADBEEF, 0, 5, 10, "utility2"),
|
||||
});
|
||||
EXPECT_TRUE(plugin.CheckInstallValidity(game));
|
||||
EXPECT_EQ(std::list<Message>({
|
||||
Message(Message::error, "This plugin requires \"Blank.missing.esm\" to be installed, but it is missing."),
|
||||
Message(Message::error, "This plugin is incompatible with \"Skyrim.esm\", but both are present."),
|
||||
PluginDirtyInfo(0x187BE342, 0, 1, 2, "utility1").AsMessage(),
|
||||
PluginDirtyInfo(0xDEADBEEF, 0, 5, 10, "utility2").AsMessage(),
|
||||
}), plugin.Messages());
|
||||
|
||||
plugin = Plugin(game, "Blank - Different Master Dependent.esp", false);
|
||||
EXPECT_FALSE(plugin.CheckInstallValidity(game));
|
||||
EXPECT_EQ(std::list<Message>({
|
||||
Message(Message::error, "This plugin requires \"Blank - Different.esm\" to be active, but it is inactive."),
|
||||
}), plugin.Messages());
|
||||
|
||||
plugin = Plugin(game, "Blank - Different Master Dependent.esp", false);
|
||||
plugin.Tags({Tag("Filter")});
|
||||
EXPECT_FALSE(plugin.CheckInstallValidity(game));
|
||||
EXPECT_TRUE(plugin.Messages().empty());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -145,6 +145,7 @@ namespace loot {
|
||||
return std::unordered_set<std::string>({
|
||||
masterFile,
|
||||
blankEsm,
|
||||
blankDifferentMasterDependentEsp,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@
|
||||
#include "backend/metadata/plugin_dirty_info_test.h"
|
||||
#include "backend/metadata/plugin_metadata_test.h"
|
||||
#include "backend/metadata/tag_test.h"
|
||||
#include "backend/plugin/test_plugin.h"
|
||||
#include "backend/plugin/plugin_test.h"
|
||||
#include "backend/test_metadata_list.h"
|
||||
#include "backend/test_masterlist.h"
|
||||
#include "backend/test_plugin_sorter.h"
|
||||
|
||||
Reference in New Issue
Block a user