From 0eee8066b7936e76015ac26bc780d92c7fffc8b8 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Fri, 18 Aug 2023 17:28:39 +0100 Subject: [PATCH] Add const GetType and GetDatabase methods to GameInterface --- include/loot/game_interface.h | 14 +++ src/api/game/game.cpp | 12 +- src/api/game/game.h | 6 +- src/api/sorting/plugin_sort.cpp | 4 +- .../api/internals/game/game_cache_test.h | 14 +-- src/tests/api/internals/game/game_test.h | 2 +- .../metadata/condition_evaluator_test.h | 2 +- src/tests/api/internals/plugin_test.h | 115 ++++++++++-------- .../sorting/plugin_sorting_data_test.h | 12 +- 9 files changed, 101 insertions(+), 80 deletions(-) diff --git a/include/loot/game_interface.h b/include/loot/game_interface.h index 09f6b525..d2e7ae1a 100644 --- a/include/loot/game_interface.h +++ b/include/loot/game_interface.h @@ -33,6 +33,12 @@ class GameInterface { public: virtual ~GameInterface() = default; + /** + * @brief Get the game's type. + * @returns The game's type. + */ + virtual GameType GetType() const = 0; + /** * @name Metadata Access * @{ @@ -46,6 +52,14 @@ public: */ virtual DatabaseInterface& GetDatabase() = 0; + /** + * @brief Get the database interface used for accessing metadata-related + * functionality. + * @returns A reference to the game's DatabaseInterface. The reference remains + * valid for the lifetime of the GameInterface instance. + */ + virtual const DatabaseInterface& GetDatabase() const = 0; + /** * @} * @name Plugin Data Access diff --git a/src/api/game/game.cpp b/src/api/game/game.cpp index 24a5aad9..002785bd 100644 --- a/src/api/game/game.cpp +++ b/src/api/game/game.cpp @@ -162,13 +162,13 @@ Game::Game(const GameType gameType, gamePath_(gamePath), loadOrderHandler_(type_, gamePath_, localDataPath), conditionEvaluator_( - std::make_shared(Type(), DataPath())), + std::make_shared(GetType(), DataPath())), database_(ApiDatabase(conditionEvaluator_)), - additionalDataPaths_(GetAdditionalDataPaths(Type(), DataPath())) { + additionalDataPaths_(GetAdditionalDataPaths(GetType(), DataPath())) { conditionEvaluator_->SetAdditionalDataPaths(additionalDataPaths_); } -GameType Game::Type() const { return type_; } +GameType Game::GetType() const { return type_; } std::filesystem::path Game::DataPath() const { if (type_ == GameType::tes3) { @@ -206,7 +206,7 @@ bool Game::IsValidPlugin(const std::string& pluginPath) const { } bool Game::IsValidPlugin(const std::filesystem::path& pluginPath) const { - return Plugin::IsValid(Type(), ResolvePluginPath(DataPath(), pluginPath)); + return Plugin::IsValid(GetType(), ResolvePluginPath(DataPath(), pluginPath)); } void Game::LoadPlugins(const std::vector& pluginPathStrings, @@ -279,7 +279,7 @@ void Game::LoadPlugins(const std::vector& pluginPaths, loot::equivalent(resolvedPluginPath, masterPath); cache_.AddPlugin( - Plugin(Type(), cache_, resolvedPluginPath, loadHeader)); + Plugin(GetType(), cache_, resolvedPluginPath, loadHeader)); } catch (const std::exception& e) { if (logger) { logger->error( @@ -355,7 +355,7 @@ void Game::SetLoadOrder(const std::vector& loadOrder) { } void Game::CacheArchives() { - const auto archiveFileExtension = GetArchiveFileExtension(Type()); + const auto archiveFileExtension = GetArchiveFileExtension(GetType()); std::set archivePaths; for (const auto& parentPath : additionalDataPaths_) { diff --git a/src/api/game/game.h b/src/api/game/game.h index f9e815f5..47e8000e 100644 --- a/src/api/game/game.h +++ b/src/api/game/game.h @@ -44,7 +44,6 @@ public: // Internal Methods // ////////////////////// - GameType Type() const; std::filesystem::path DataPath() const; GameCache& GetCache(); @@ -53,8 +52,6 @@ public: LoadOrderHandler& GetLoadOrderHandler(); const LoadOrderHandler& GetLoadOrderHandler() const; - const DatabaseInterface& GetDatabase() const; - void SetAdditionalDataPaths( const std::vector& additionalDataPaths); @@ -69,7 +66,10 @@ public: // Game Interface Methods // //////////////////////////// + GameType GetType() const override; + DatabaseInterface& GetDatabase() override; + const DatabaseInterface& GetDatabase() const override; bool IsValidPlugin(const std::string& pluginPath) const override; diff --git a/src/api/sorting/plugin_sort.cpp b/src/api/sorting/plugin_sort.cpp index f19b85a6..bc6d8d22 100644 --- a/src/api/sorting/plugin_sort.cpp +++ b/src/api/sorting/plugin_sort.cpp @@ -295,7 +295,7 @@ std::vector SortPlugins( Game& game, const std::vector& loadOrder) { auto pluginsSortingData = GetPluginsSortingData( - game.Type(), game.GetDatabase(), game.GetLoadedPlugins(), loadOrder); + game.GetType(), game.GetDatabase(), game.GetLoadedPlugins(), loadOrder); const auto logger = getLogger(); if (logger) { @@ -307,7 +307,7 @@ std::vector SortPlugins( const auto newLoadOrder = SortPlugins(std::move(pluginsSortingData), - game.Type(), + game.GetType(), game.GetDatabase().GetGroups(false), game.GetDatabase().GetUserGroups(), game.GetLoadOrderHandler().GetImplicitlyActivePlugins()); diff --git a/src/tests/api/internals/game/game_cache_test.h b/src/tests/api/internals/game/game_cache_test.h index 3336a682..a39085f2 100644 --- a/src/tests/api/internals/game/game_cache_test.h +++ b/src/tests/api/internals/game/game_cache_test.h @@ -53,18 +53,18 @@ INSTANTIATE_TEST_SUITE_P(, GameCacheTest, ::testing::Values(GameType::tes5)); TEST_P(GameCacheTest, addingAPluginThatDoesNotExistShouldSucceed) { cache_.AddPlugin( - Plugin(game_.Type(), GameCache(), game_.DataPath() / blankEsm, true)); + Plugin(game_.GetType(), GameCache(), game_.DataPath() / blankEsm, true)); EXPECT_EQ(blankEsm, cache_.GetPlugin(blankEsm)->GetName()); } TEST_P(GameCacheTest, addingAPluginThatIsAlreadyCachedShouldOverwriteExistingEntry) { cache_.AddPlugin( - Plugin(game_.Type(), GameCache(), game_.DataPath() / blankEsm, true)); + Plugin(game_.GetType(), GameCache(), game_.DataPath() / blankEsm, true)); EXPECT_FALSE(cache_.GetPlugin(blankEsm)->GetCRC()); cache_.AddPlugin( - Plugin(game_.Type(), GameCache(), game_.DataPath() / blankEsm, false)); + Plugin(game_.GetType(), GameCache(), game_.DataPath() / blankEsm, false)); EXPECT_EQ(blankEsmCrc, cache_.GetPlugin(blankEsm)->GetCRC().value()); } @@ -74,7 +74,7 @@ TEST_P(GameCacheTest, gettingAPluginThatIsNotCachedShouldReturnANullPointer) { TEST_P(GameCacheTest, gettingAPluginShouldBeCaseInsensitive) { cache_.AddPlugin( - Plugin(game_.Type(), GameCache(), game_.DataPath() / blankEsm, true)); + Plugin(game_.GetType(), GameCache(), game_.DataPath() / blankEsm, true)); EXPECT_EQ(blankEsm, cache_.GetPlugin(blankEsm)->GetName()); } @@ -86,8 +86,8 @@ TEST_P(GameCacheTest, TEST_P(GameCacheTest, gettingPluginsShouldReturnASetOfCachedPluginsIfPluginsHaveBeenCached) { cache_.AddPlugin( - Plugin(game_.Type(), GameCache(), game_.DataPath() / blankEsm, true)); - cache_.AddPlugin(Plugin(game_.Type(), + Plugin(game_.GetType(), GameCache(), game_.DataPath() / blankEsm, true)); + cache_.AddPlugin(Plugin(game_.GetType(), GameCache(), game_.DataPath() / blankMasterDependentEsm, true)); @@ -119,7 +119,7 @@ TEST_P(GameCacheTest, clearingCachedPluginsShouldNotThrowIfNoPluginsAreCached) { TEST_P(GameCacheTest, clearingCachedPluginsShouldClearAnyCachedPlugins) { cache_.AddPlugin( - Plugin(game_.Type(), GameCache(), game_.DataPath() / blankEsm, true)); + Plugin(game_.GetType(), GameCache(), game_.DataPath() / blankEsm, true)); cache_.ClearCachedPlugins(); EXPECT_TRUE(cache_.GetPlugins().empty()); diff --git a/src/tests/api/internals/game/game_test.h b/src/tests/api/internals/game/game_test.h index d7a8a6cd..ae3d2ff4 100644 --- a/src/tests/api/internals/game/game_test.h +++ b/src/tests/api/internals/game/game_test.h @@ -71,7 +71,7 @@ INSTANTIATE_TEST_SUITE_P(, TEST_P(GameTest, constructingShouldStoreTheGivenValues) { Game game = Game(GetParam(), dataPath.parent_path(), localPath); - EXPECT_EQ(GetParam(), game.Type()); + EXPECT_EQ(GetParam(), game.GetType()); EXPECT_EQ(dataPath, game.DataPath()); } diff --git a/src/tests/api/internals/metadata/condition_evaluator_test.h b/src/tests/api/internals/metadata/condition_evaluator_test.h index 8179f8d4..f72569ff 100644 --- a/src/tests/api/internals/metadata/condition_evaluator_test.h +++ b/src/tests/api/internals/metadata/condition_evaluator_test.h @@ -40,7 +40,7 @@ protected: nonAsciiEsm(u8"non\u00C1scii.esm"), nonAsciiNestedFile(u8"non\u00C1scii/test.txt"), game_(GetParam(), dataPath.parent_path(), localPath), - evaluator_(game_.Type(), game_.DataPath()) { + evaluator_(game_.GetType(), game_.DataPath()) { // Make sure the plugin with a non-ASCII filename exists. std::filesystem::copy_file(dataPath / blankEsm, dataPath / std::filesystem::u8path(nonAsciiEsm)); diff --git a/src/tests/api/internals/plugin_test.h b/src/tests/api/internals/plugin_test.h index ed2fc373..33bcc061 100644 --- a/src/tests/api/internals/plugin_test.h +++ b/src/tests/api/internals/plugin_test.h @@ -101,14 +101,14 @@ protected: auto nonAsciiArchivePath = dataPath / std::filesystem::u8path(u8"non\u00E1scii" + - GetArchiveFileExtension(game_.Type())); + GetArchiveFileExtension(game_.GetType())); out.open(nonAsciiArchivePath); out.close(); auto nonAsciiPrefixArchivePath = dataPath / std::filesystem::u8path(u8"other non\u00E1scii2 - suffix" + - GetArchiveFileExtension(game_.Type())); + GetArchiveFileExtension(game_.GetType())); out.open(nonAsciiPrefixArchivePath); out.close(); @@ -208,7 +208,7 @@ INSTANTIATE_TEST_SUITE_P(, GameType::tes5se)); TEST_P(PluginTest, loadingShouldHandleNonAsciiFilenamesCorrectly) { - Plugin plugin(game_.Type(), + Plugin plugin(game_.GetType(), game_.GetCache(), game_.DataPath() / std::filesystem::u8path(nonAsciiEsp), true); @@ -219,7 +219,7 @@ TEST_P(PluginTest, loadingShouldHandleNonAsciiFilenamesCorrectly) { TEST_P(PluginTest, loadingHeaderOnlyShouldReadHeaderData) { Plugin plugin( - game_.Type(), game_.GetCache(), game_.DataPath() / blankEsm, true); + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsm, true); EXPECT_EQ(blankEsm, plugin.GetName()); EXPECT_TRUE(plugin.GetMasters().empty()); @@ -238,14 +238,14 @@ TEST_P(PluginTest, loadingHeaderOnlyShouldReadHeaderData) { TEST_P(PluginTest, loadingHeaderOnlyShouldNotReadFieldsOrCalculateCrc) { Plugin plugin( - game_.Type(), game_.GetCache(), game_.DataPath() / blankEsm, true); + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsm, true); EXPECT_FALSE(plugin.GetCRC()); } TEST_P(PluginTest, loadingWholePluginShouldReadHeaderData) { Plugin plugin( - game_.Type(), game_.GetCache(), game_.DataPath() / blankEsm, true); + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsm, true); EXPECT_EQ(blankEsm, plugin.GetName()); EXPECT_TRUE(plugin.GetMasters().empty()); @@ -263,7 +263,7 @@ TEST_P(PluginTest, loadingWholePluginShouldReadHeaderData) { } TEST_P(PluginTest, loadingWholePluginShouldReadFields) { - Plugin plugin(game_.Type(), + Plugin plugin(game_.GetType(), game_.GetCache(), game_.DataPath() / blankMasterDependentEsm, false); @@ -277,13 +277,13 @@ TEST_P(PluginTest, loadingWholePluginShouldReadFields) { TEST_P(PluginTest, loadingWholePluginShouldCalculateCrc) { Plugin plugin( - game_.Type(), game_.GetCache(), game_.DataPath() / blankEsm, false); + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsm, false); EXPECT_EQ(blankEsmCrc, plugin.GetCRC()); } TEST_P(PluginTest, loadingANonMasterPluginShouldReadTheMasterFlagAsFalse) { - Plugin plugin(game_.Type(), + Plugin plugin(game_.GetType(), game_.GetCache(), game_.DataPath() / blankMasterDependentEsp, true); @@ -295,13 +295,13 @@ TEST_P( PluginTest, isLightPluginShouldBeTrueForAPluginWithEslFileExtensionForFallout4AndSkyrimSeAndFalseOtherwise) { Plugin plugin1( - game_.Type(), game_.GetCache(), game_.DataPath() / blankEsm, true); - Plugin plugin2(game_.Type(), + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsm, true); + Plugin plugin2(game_.GetType(), game_.GetCache(), game_.DataPath() / blankMasterDependentEsp, true); Plugin plugin3( - game_.Type(), game_.GetCache(), game_.DataPath() / blankEsl, true); + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsl, true); EXPECT_FALSE(plugin1.IsLightPlugin()); EXPECT_FALSE(plugin2.IsLightPlugin()); @@ -310,7 +310,7 @@ TEST_P( } TEST_P(PluginTest, loadingAPluginWithMastersShouldReadThemCorrectly) { - Plugin plugin(game_.Type(), + Plugin plugin(game_.GetType(), game_.GetCache(), game_.DataPath() / blankMasterDependentEsp, true); @@ -319,7 +319,7 @@ TEST_P(PluginTest, loadingAPluginWithMastersShouldReadThemCorrectly) { } TEST_P(PluginTest, loadingAPluginThatDoesNotExistShouldThrow) { - EXPECT_THROW(Plugin(game_.Type(), + EXPECT_THROW(Plugin(game_.GetType(), game_.GetCache(), game_.DataPath() / "Blank\\.esp", true), @@ -330,7 +330,8 @@ TEST_P( PluginTest, loadsArchiveForAnArchiveThatExactlyMatchesAnEsmFileBasenameShouldReturnTrueForAllGamesExceptMorrowindAndOblivion) { bool loadsArchive = - Plugin(game_.Type(), game_.GetCache(), game_.DataPath() / blankEsm, true) + Plugin( + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsm, true) .LoadsArchive(); if (GetParam() == GameType::tes3 || GetParam() == GameType::tes4) @@ -344,7 +345,7 @@ TEST_P( PluginTest, loadsArchiveForAnArchiveThatExactlyMatchesANonAsciiEspFileBasenameShouldReturnTrueForAllGamesExceptMorrowind) { bool loadsArchive = - Plugin(game_.Type(), + Plugin(game_.GetType(), game_.GetCache(), game_.DataPath() / std::filesystem::u8path(nonAsciiEsp), true) @@ -361,7 +362,8 @@ TEST_P( PluginTest, loadsArchiveForAnArchiveThatExactlyMatchesAnEspFileBasenameShouldReturnTrueForAllGamesExceptMorrowind) { bool loadsArchive = - Plugin(game_.Type(), game_.GetCache(), game_.DataPath() / blankEsp, true) + Plugin( + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsp, true) .LoadsArchive(); if (GetParam() == GameType::tes3) @@ -373,7 +375,7 @@ TEST_P( TEST_P( PluginTest, loadsArchiveForAnArchiveWithAFilenameWhichStartsWithTheEsmFileBasenameShouldReturnTrueForAllGamesExceptMorrowindOblivionAndSkyrim) { - bool loadsArchive = Plugin(game_.Type(), + bool loadsArchive = Plugin(game_.GetType(), game_.GetCache(), game_.DataPath() / blankDifferentEsm, true) @@ -389,7 +391,7 @@ TEST_P( TEST_P( PluginTest, loadsArchiveForAnArchiveWithAFilenameWhichStartsWithTheEspFileBasenameShouldReturnTrueForAllGamesExceptMorrowindAndSkyrim) { - bool loadsArchive = Plugin(game_.Type(), + bool loadsArchive = Plugin(game_.GetType(), game_.GetCache(), game_.DataPath() / blankDifferentEsp, true) @@ -407,7 +409,7 @@ TEST_P( PluginTest, loadsArchiveForAnArchiveWithAFilenameWhichStartsWithTheNonAsciiEspFileBasenameShouldReturnTrueForAllGamesExceptMorrowindAndSkyrim) { bool loadsArchive = - Plugin(game_.Type(), + Plugin(game_.GetType(), game_.GetCache(), game_.DataPath() / std::filesystem::u8path(otherNonAsciiEsp), true) @@ -423,7 +425,7 @@ TEST_P( TEST_P(PluginTest, loadsArchiveShouldReturnFalseForAPluginThatDoesNotLoadAnArchive) { - EXPECT_FALSE(Plugin(game_.Type(), + EXPECT_FALSE(Plugin(game_.GetType(), game_.GetCache(), game_.DataPath() / blankDifferentMasterDependentEsp, true) @@ -431,27 +433,30 @@ TEST_P(PluginTest, } TEST_P(PluginTest, isValidShouldReturnTrueForAValidPlugin) { - EXPECT_TRUE(Plugin::IsValid(game_.Type(), game_.DataPath() / blankEsm)); + EXPECT_TRUE(Plugin::IsValid(game_.GetType(), game_.DataPath() / blankEsm)); } TEST_P(PluginTest, isValidShouldReturnTrueForAValidNonAsciiPlugin) { - EXPECT_TRUE(Plugin::IsValid( - game_.Type(), game_.DataPath() / std::filesystem::u8path(nonAsciiEsp))); + EXPECT_TRUE( + Plugin::IsValid(game_.GetType(), + game_.DataPath() / std::filesystem::u8path(nonAsciiEsp))); } TEST_P(PluginTest, isValidShouldReturnFalseForANonPluginFile) { - EXPECT_FALSE(Plugin::IsValid(game_.Type(), game_.DataPath() / nonPluginFile)); + EXPECT_FALSE( + Plugin::IsValid(game_.GetType(), game_.DataPath() / nonPluginFile)); } TEST_P(PluginTest, isValidShouldReturnFalseForAnEmptyFile) { - EXPECT_FALSE(Plugin::IsValid(game_.Type(), game_.DataPath() / emptyFile)); + EXPECT_FALSE(Plugin::IsValid(game_.GetType(), game_.DataPath() / emptyFile)); } TEST_P( PluginTest, isValidAsLightPluginShouldReturnTrueOnlyForASkyrimSEOrFallout4PluginWithNewFormIdsBetween0x800And0xFFFInclusive) { bool valid = - Plugin(game_.Type(), game_.GetCache(), game_.DataPath() / blankEsm, true) + Plugin( + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsm, true) .IsValidAsLightPlugin(); if (GetParam() == GameType::fo4 || GetParam() == GameType::tes5se) { EXPECT_TRUE(valid); @@ -479,7 +484,7 @@ TEST_P(PluginTest, getFileSizeShouldReturnCorrectValueForAGhostedPlugin) { TEST_P(PluginTest, doRecordsOverlapShouldReturnFalseIfTheArgumentIsNotAPluginObject) { Plugin plugin1( - game_.Type(), game_.GetCache(), game_.DataPath() / blankEsm, false); + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsm, false); OtherPluginType plugin2; EXPECT_FALSE(plugin1.DoRecordsOverlap(plugin2)); @@ -489,8 +494,8 @@ TEST_P(PluginTest, TEST_P(PluginTest, doRecordsOverlapShouldReturnFalseForTwoPluginsWithOnlyHeadersLoaded) { Plugin plugin1( - game_.Type(), game_.GetCache(), game_.DataPath() / blankEsm, true); - Plugin plugin2(game_.Type(), + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsm, true); + Plugin plugin2(game_.GetType(), game_.GetCache(), game_.DataPath() / blankMasterDependentEsm, true); @@ -502,9 +507,9 @@ TEST_P(PluginTest, TEST_P(PluginTest, doRecordsOverlapShouldReturnFalseIfThePluginsHaveUnrelatedRecords) { Plugin plugin1( - game_.Type(), game_.GetCache(), game_.DataPath() / blankEsm, false); + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsm, false); Plugin plugin2( - game_.Type(), game_.GetCache(), game_.DataPath() / blankEsp, false); + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsp, false); EXPECT_FALSE(plugin1.DoRecordsOverlap(plugin2)); EXPECT_FALSE(plugin2.DoRecordsOverlap(plugin1)); @@ -513,8 +518,8 @@ TEST_P(PluginTest, TEST_P(PluginTest, doRecordsOverlapShouldReturnTrueIfOnePluginOverridesTheOthersRecords) { Plugin plugin1( - game_.Type(), game_.GetCache(), game_.DataPath() / blankEsm, false); - Plugin plugin2(game_.Type(), + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsm, false); + Plugin plugin2(game_.GetType(), game_.GetCache(), game_.DataPath() / blankMasterDependentEsm, false); @@ -526,7 +531,7 @@ TEST_P(PluginTest, TEST_P(PluginTest, getOverlapSizeShouldThrowIfGivenAVectorContainingANonPluginObject) { Plugin plugin1( - game_.Type(), game_.GetCache(), game_.DataPath() / blankEsm, false); + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsm, false); OtherPluginType plugin2; EXPECT_THROW(plugin1.GetOverlapSize({&plugin2, &plugin2}), @@ -536,8 +541,8 @@ TEST_P(PluginTest, TEST_P(PluginTest, getOverlapSizeShouldCountEachRecordOnce) { Plugin plugin1( - game_.Type(), game_.GetCache(), game_.DataPath() / blankEsm, false); - Plugin plugin2(game_.Type(), + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsm, false); + Plugin plugin2(game_.GetType(), game_.GetCache(), game_.DataPath() / blankMasterDependentEsm, false); @@ -547,10 +552,10 @@ TEST_P(PluginTest, getOverlapSizeShouldCountEachRecordOnce) { TEST_P(PluginTest, getOverlapSizeShouldCheckAgainstAllGivenPlugins) { Plugin plugin1( - game_.Type(), game_.GetCache(), game_.DataPath() / blankEsm, false); + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsm, false); Plugin plugin2( - game_.Type(), game_.GetCache(), game_.DataPath() / blankEsp, false); - Plugin plugin3(game_.Type(), + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsp, false); + Plugin plugin3(game_.GetType(), game_.GetCache(), game_.DataPath() / blankMasterDependentEsm, false); @@ -561,8 +566,8 @@ TEST_P(PluginTest, getOverlapSizeShouldCheckAgainstAllGivenPlugins) { TEST_P(PluginTest, getOverlapSizeShouldReturnZeroForPluginsWithOnlyHeadersLoaded) { Plugin plugin1( - game_.Type(), game_.GetCache(), game_.DataPath() / blankEsm, true); - Plugin plugin2(game_.Type(), + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsm, true); + Plugin plugin2(game_.GetType(), game_.GetCache(), game_.DataPath() / blankMasterDependentEsm, true); @@ -572,16 +577,16 @@ TEST_P(PluginTest, TEST_P(PluginTest, getOverlapSizeShouldReturnZeroForPluginsThatDoNotOverlap) { Plugin plugin1( - game_.Type(), game_.GetCache(), game_.DataPath() / blankEsm, false); + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsm, false); Plugin plugin2( - game_.Type(), game_.GetCache(), game_.DataPath() / blankEsp, false); + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsp, false); EXPECT_EQ(0, plugin1.GetOverlapSize({&plugin2})); } TEST_P(PluginTest, getRecordAndGroupCountShouldReturnTheHeaderFieldValue) { Plugin plugin( - game_.Type(), game_.GetCache(), game_.DataPath() / blankEsm, true); + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsm, true); if (GetParam() == GameType::tes3) { EXPECT_EQ(10u, plugin.GetRecordAndGroupCount()); @@ -595,7 +600,8 @@ TEST_P(PluginTest, getRecordAndGroupCountShouldReturnTheHeaderFieldValue) { TEST_P(PluginTest, getAssetCountShouldReturnNumberOfFilesInArchivesLoadedByPlugin) { const auto assetCount = - Plugin(game_.Type(), game_.GetCache(), game_.DataPath() / blankEsp, false) + Plugin( + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsp, false) .GetAssetCount(); if (GetParam() == GameType::tes3) { @@ -609,7 +615,8 @@ TEST_P(PluginTest, TEST_P(PluginTest, getAssetCountShouldReturnZeroIfOnlyPluginHeaderWasLoaded) { const auto assetCount = - Plugin(game_.Type(), game_.GetCache(), game_.DataPath() / blankEsp, true) + Plugin( + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsp, true) .GetAssetCount(); EXPECT_EQ(0, assetCount); @@ -618,7 +625,7 @@ TEST_P(PluginTest, getAssetCountShouldReturnZeroIfOnlyPluginHeaderWasLoaded) { TEST_P(PluginTest, doAssetsOverlapShouldReturnFalseOrThrowIfTheArgumentIsNotAPluginObject) { Plugin plugin1( - game_.Type(), game_.GetCache(), game_.DataPath() / blankEsp, false); + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsp, false); OtherPluginType plugin2; if (GetParam() == GameType::tes3) { @@ -632,8 +639,8 @@ TEST_P(PluginTest, TEST_P(PluginTest, doAssetsOverlapShouldReturnFalseForTwoPluginsWithOnlyHeadersLoaded) { Plugin plugin1( - game_.Type(), game_.GetCache(), game_.DataPath() / blankEsp, true); - Plugin plugin2(game_.Type(), + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsp, true); + Plugin plugin2(game_.GetType(), game_.GetCache(), game_.DataPath() / blankMasterDependentEsp, true); @@ -645,9 +652,9 @@ TEST_P(PluginTest, TEST_P(PluginTest, doAssetsOverlapShouldReturnFalseIfThePluginsDoNotLoadTheSameAssetPath) { Plugin plugin1( - game_.Type(), game_.GetCache(), game_.DataPath() / blankEsp, false); + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsp, false); // Blank - Different.esp does not load any assets. - Plugin plugin2(game_.Type(), + Plugin plugin2(game_.GetType(), game_.GetCache(), game_.DataPath() / blankDifferentEsp, false); @@ -659,8 +666,8 @@ TEST_P(PluginTest, TEST_P(PluginTest, doAssetsOverlapShouldReturnTrueIfThePluginsLoadTheSameAssetPath) { Plugin plugin1( - game_.Type(), game_.GetCache(), game_.DataPath() / blankEsp, false); - Plugin plugin2(game_.Type(), + game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsp, false); + Plugin plugin2(game_.GetType(), game_.GetCache(), game_.DataPath() / blankMasterDependentEsp, false); diff --git a/src/tests/api/internals/sorting/plugin_sorting_data_test.h b/src/tests/api/internals/sorting/plugin_sorting_data_test.h index 84d95621..1ee0d686 100644 --- a/src/tests/api/internals/sorting/plugin_sorting_data_test.h +++ b/src/tests/api/internals/sorting/plugin_sorting_data_test.h @@ -101,7 +101,7 @@ TEST_P(PluginSortingDataTest, lightFlaggedEspFilesShouldNotBeTreatedAsMasters) { PluginMetadata(), PluginMetadata(), getLoadOrder(), - game_.Type(), + game_.GetType(), loadedPlugins); EXPECT_FALSE(esp.IsMaster()); @@ -110,7 +110,7 @@ TEST_P(PluginSortingDataTest, lightFlaggedEspFilesShouldNotBeTreatedAsMasters) { PluginMetadata(), PluginMetadata(), getLoadOrder(), - game_.Type(), + game_.GetType(), loadedPlugins); EXPECT_TRUE(master.IsMaster()); @@ -120,7 +120,7 @@ TEST_P(PluginSortingDataTest, lightFlaggedEspFilesShouldNotBeTreatedAsMasters) { PluginMetadata(), PluginMetadata(), getLoadOrder(), - game_.Type(), + game_.GetType(), loadedPlugins); EXPECT_TRUE(lightMaster.IsMaster()); @@ -130,7 +130,7 @@ TEST_P(PluginSortingDataTest, lightFlaggedEspFilesShouldNotBeTreatedAsMasters) { PluginMetadata(), PluginMetadata(), getLoadOrder(), - game_.Type(), + game_.GetType(), loadedPlugins); EXPECT_FALSE(lightPlugin.IsMaster()); } @@ -145,7 +145,7 @@ TEST_P(PluginSortingDataTest, PluginMetadata(), PluginMetadata(), getLoadOrder(), - game_.Type(), + game_.GetType(), getLoadedPlugins()); EXPECT_EQ(4, plugin.GetOverrideRecordCount()); } @@ -174,7 +174,7 @@ TEST_P( PluginMetadata(), PluginMetadata(), getLoadOrder(), - game_.Type(), + game_.GetType(), loadedPlugins); EXPECT_EQ(10, plugin.GetOverrideRecordCount());