From a6545e7600cc5895ad473c134f78ec82083961e5 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Tue, 15 Mar 2016 20:46:30 +0000 Subject: [PATCH] Improve Game tests --- CMakeLists.txt | 2 +- src/tests/backend/game/game_test.h | 379 +++++++++++++++++ src/tests/backend/game/test_game.h | 662 ----------------------------- src/tests/base_game_test.h | 12 +- src/tests/main.cpp | 2 +- 5 files changed, 392 insertions(+), 665 deletions(-) create mode 100644 src/tests/backend/game/game_test.h delete mode 100644 src/tests/backend/game/test_game.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a4465ff..e63f2525 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -235,7 +235,7 @@ set (LOOT_TESTS_HEADERS "${CMAKE_SOURCE_DIR}/src/tests/base_game_test.h" "${CMAKE_SOURCE_DIR}/src/tests/api/loot_write_minimal_list_test.h" "${CMAKE_SOURCE_DIR}/src/tests/api/test_api.h" - "${CMAKE_SOURCE_DIR}/src/tests/backend/game/test_game.h" + "${CMAKE_SOURCE_DIR}/src/tests/backend/game/game_test.h" "${CMAKE_SOURCE_DIR}/src/tests/backend/game/test_game_cache.h" "${CMAKE_SOURCE_DIR}/src/tests/backend/game/test_game_settings.h" "${CMAKE_SOURCE_DIR}/src/tests/backend/game/test_load_order_handler.h" diff --git a/src/tests/backend/game/game_test.h b/src/tests/backend/game/game_test.h new file mode 100644 index 00000000..bef5ab03 --- /dev/null +++ b/src/tests/backend/game/game_test.h @@ -0,0 +1,379 @@ +/* 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 +. +*/ + +#ifndef LOOT_TEST_BACKEND_GAME +#define LOOT_TEST_BACKEND_GAME + +#include "backend/error.h" +#include "backend/globals.h" +#include "backend/game/game.h" + +#include "tests/base_game_test.h" + +namespace loot { + namespace test { + class GameTest : public BaseGameTest { + protected: + + void SetUp() { + BaseGameTest::SetUp(); + + setLoadOrder(); + setActivePlugins(); + } +#ifndef _WIN32 + void TearDown() { + BaseGameTest::TearDown(); + + ASSERT_NO_THROW(boost::filesystem::remove_all(g_path_local)); + } +#endif + + inline std::vector getExpectedLoadOrder() const { + return std::vector({ + masterFile, + blankEsm, + blankDifferentEsm, + blankMasterDependentEsm, + blankDifferentMasterDependentEsm, + blankEsp, + blankDifferentEsp, + blankMasterDependentEsp, + blankDifferentMasterDependentEsp, + blankPluginDependentEsp, + blankDifferentPluginDependentEsp, + }); + } + + inline void setLoadOrder() { + if (isTimestampLoadOrderMethod()) { + time_t modificationTime = time(NULL); // Current time. + for (const auto &plugin : getExpectedLoadOrder()) { + if (boost::filesystem::exists(dataPath / boost::filesystem::path(plugin + ".ghost"))) { + boost::filesystem::last_write_time(dataPath / boost::filesystem::path(plugin + ".ghost"), modificationTime); + } + else { + boost::filesystem::last_write_time(dataPath / plugin, modificationTime); + } + modificationTime += 60; + } + } + else { + boost::filesystem::ofstream loadOrder(localPath / "loadorder.txt"); + for (const auto &plugin : getExpectedLoadOrder()) + loadOrder << plugin << std::endl; + loadOrder.close(); + } + } + + inline void setActivePlugins() { + boost::filesystem::ofstream activePlugins(localPath / "plugins.txt"); + activePlugins + << blankEsm << std::endl; + activePlugins.close(); + } + + inline bool isTimestampLoadOrderMethod() { + return GetParam() == Game::tes4 || GetParam() == Game::fo3 || GetParam() == Game::fonv; + } + }; + + // 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(, + GameTest, + ::testing::Values( + GameSettings::tes4, + GameSettings::tes5, + GameSettings::fo3, + GameSettings::fonv, + GameSettings::fo4)); + + TEST_P(GameTest, defaultConstructorShouldConstructWithDefaultGameSettings) { + GameSettings settings; + Game game; + + EXPECT_EQ(settings.Id(), game.Id()); + EXPECT_EQ(settings.FolderName(), game.FolderName()); + } + + TEST_P(GameTest, constructingFromGameSettingsShouldUseTheirValues) { + GameSettings settings = GameSettings(GetParam(), "folder"); + settings.SetName("foo"); + settings.SetMaster(blankEsm); + settings.SetRegistryKey("foo"); + settings.SetRepoURL("foo"); + settings.SetRepoBranch("foo"); + settings.SetGamePath(localPath); + Game game = Game(settings); + + EXPECT_EQ(GetParam(), game.Id()); + EXPECT_EQ(settings.Name(), game.Name()); + EXPECT_EQ(settings.FolderName(), game.FolderName()); + EXPECT_EQ(settings.Master(), game.Master()); + EXPECT_EQ(settings.RegistryKey(), game.RegistryKey()); + EXPECT_EQ(settings.RepoURL(), game.RepoURL()); + EXPECT_EQ(settings.RepoBranch(), game.RepoBranch()); + + EXPECT_EQ(settings.GamePath(), game.GamePath()); + } + + TEST_P(GameTest, constructingFromIdAndFolderShouldPassThemToGameSettingsConstructor) { + GameSettings settings = GameSettings(GetParam(), "folder"); + Game game = Game(GetParam(), "folder"); + + EXPECT_EQ(settings.Id(), game.Id()); + EXPECT_EQ(settings.FolderName(), game.FolderName()); + } + + TEST_P(GameTest, initShouldThrowIfGameHasAnInvalidId) { + Game game; + EXPECT_THROW(game.Init(false), error); + EXPECT_THROW(game.Init(true), error); + EXPECT_THROW(game.Init(false, localPath), error); + EXPECT_THROW(game.Init(true, localPath), error); + } + +#ifndef _WIN32 + // Testing on Windows will find real game installs in the Registry, so cannot + // test autodetection fully unless on Linux. + TEST_P(GameTest, initShouldThrowOnLinuxIfGamePathIsNotGiven) { + Game game = Game(GetParam()); + EXPECT_THROW(game.Init(false), error); + EXPECT_THROW(game.Init(true), error); + EXPECT_THROW(game.Init(false, localPath), error); + EXPECT_THROW(game.Init(true, localPath), error); + } + + TEST_P(GameTest, initShouldThrowOnLinuxIfLocalPathIsNotGiven) { + Game game = Game(GetParam()).SetGamePath(dataPath.parent_path()); + ASSERT_FALSE(boost::filesystem::exists(g_path_local / game.FolderName())); + EXPECT_THROW(game.Init(false), error); + } + + // Testing on Windows will find real LOOT installs, and they shouldn't be + // interfered with. + TEST_P(GameTest, initShouldNotCreateAGameFolderIfTheCreateFolderArgumentIsFalse) { + Game game = Game(GetParam()).SetGamePath(dataPath.parent_path()); + + ASSERT_FALSE(boost::filesystem::exists(g_path_local / game.FolderName())); + EXPECT_NO_THROW(game.Init(false, localPath)); + + EXPECT_FALSE(boost::filesystem::exists(g_path_local / game.FolderName())); + } + + TEST_P(GameTest, initShouldCreateAGameFolderIfTheCreateFolderArgumentIsTrue) { + Game game = Game(GetParam()).SetGamePath(dataPath.parent_path()); + + ASSERT_FALSE(boost::filesystem::exists(g_path_local / game.FolderName())); + EXPECT_NO_THROW(game.Init(true, localPath)); + + EXPECT_TRUE(boost::filesystem::exists(g_path_local / game.FolderName())); + } +#else + TEST_P(GameTest, initShouldNotThrowOnWindowsIfLocalPathIsNotGiven) { + Game game = Game(GetParam()).SetGamePath(dataPath.parent_path()); + + EXPECT_NO_THROW(game.Init(false)); + } +#endif + + TEST_P(GameTest, initShouldNotThrowIfGameAndLocalPathsAreGiven) { + Game game = Game(GetParam()).SetGamePath(dataPath.parent_path()); + + EXPECT_NO_THROW(game.Init(false, localPath)); + } + + TEST_P(GameTest, redatePluginsShouldThrowIfTheGameHasNotYetBeenInitialisedForSkyrimAndNotForOtherGames) { + Game game(GetParam()); + game.SetGamePath(dataPath.parent_path()); + + if (GetParam() == Game::tes5) + EXPECT_THROW(game.RedatePlugins(), error); + else + EXPECT_NO_THROW(game.RedatePlugins()); + } + + TEST_P(GameTest, redatePluginsShouldRedatePluginsForSkyrimAndDoNothingForOtherGames) { + Game game(GetParam()); + game.SetGamePath(dataPath.parent_path()); + game.Init(false, localPath); + + std::vector loadOrder = getExpectedLoadOrder(); + + // First set reverse timestamps to be sure. + time_t time = boost::filesystem::last_write_time(dataPath / masterFile); + for (size_t i = 1; i < loadOrder.size(); ++i) { + boost::filesystem::last_write_time(dataPath / loadOrder[i], time - i * 60); + ASSERT_EQ(time - i * 60, boost::filesystem::last_write_time(dataPath / loadOrder[i])); + } + + EXPECT_NO_THROW(game.RedatePlugins()); + + if (GetParam() == Game::tes5) { + for (size_t i = 0; i < loadOrder.size(); ++i) { + ASSERT_EQ(time + i * 60, boost::filesystem::last_write_time(dataPath / loadOrder[i])); + } + } + else { + for (size_t i = 0; i < loadOrder.size(); ++i) { + ASSERT_EQ(time - i * 60, boost::filesystem::last_write_time(dataPath / loadOrder[i])); + } + } + } + + TEST_P(GameTest, loadPluginsWithHeadersOnlyTrueShouldLoadTheHeadersOfAllInstalledPlugins) { + Game game(GetParam()); + game.SetGamePath(dataPath.parent_path()); + + EXPECT_NO_THROW(game.LoadPlugins(true)); + EXPECT_EQ(11, game.GetPlugins().size()); + + // Check that one plugin's header has been read. + ASSERT_NO_THROW(game.GetPlugin(masterFile)); + Plugin plugin = game.GetPlugin(masterFile); + EXPECT_EQ("v5.0", plugin.getDescription()); + + // Check that only the header has been read. + EXPECT_EQ(0, plugin.Crc()); + } + + TEST_P(GameTest, loadPluginsWithHeadersOnlyFalseShouldFullyLoadAllInstalledPlugins) { + Game game(GetParam()); + game.SetGamePath(dataPath.parent_path()); + + EXPECT_NO_THROW(game.LoadPlugins(false)); + EXPECT_EQ(11, game.GetPlugins().size()); + + // Check that one plugin's header has been read. + ASSERT_NO_THROW(game.GetPlugin(blankEsm)); + Plugin plugin = game.GetPlugin(blankEsm); + EXPECT_EQ("v5.0", plugin.getDescription()); + + // Check that not only the header has been read. + EXPECT_EQ(blankEsmCrc, plugin.Crc()); + } + + TEST_P(GameTest, pluginsShouldNotBeFullyLoadedByDefault) { + EXPECT_FALSE(Game().ArePluginsFullyLoaded()); + EXPECT_FALSE(Game(GameSettings()).ArePluginsFullyLoaded()); + EXPECT_FALSE(Game(GetParam(), "folder").ArePluginsFullyLoaded()); + } + + TEST_P(GameTest, pluginsShouldNotBeFullyLoadedAfterLoadingHeadersOnly) { + Game game(GetParam()); + game.SetGamePath(dataPath.parent_path()); + + ASSERT_NO_THROW(game.LoadPlugins(true)); + + EXPECT_FALSE(game.ArePluginsFullyLoaded()); + } + + TEST_P(GameTest, pluginsShouldBeFullyLoadedAfterFullyLoadingThem) { + Game game(GetParam()); + game.SetGamePath(dataPath.parent_path()); + + ASSERT_NO_THROW(game.LoadPlugins(false)); + + EXPECT_TRUE(game.ArePluginsFullyLoaded()); + } + + TEST_P(GameTest, shouldThrowIfCheckingIfPluginThatIsntLoadedIsActiveAndGameHasNotBeenInitialised) { + Game game(GetParam()); + game.SetGamePath(dataPath.parent_path()); + + EXPECT_ANY_THROW(game.IsPluginActive(blankEsm)); + } + + TEST_P(GameTest, shouldShowBlankEsmAsActiveIfItHasNotBeenLoadedAndTheGameHasBeenInitialised) { + Game game(GetParam()); + game.SetGamePath(dataPath.parent_path()); + ASSERT_NO_THROW(game.Init(false, localPath)); + + EXPECT_TRUE(game.IsPluginActive(blankEsm)); + } + + TEST_P(GameTest, shouldShowBlankEspAsInactiveIfItHasNotBeenLoadedAndTheGameHasBeenInitialised) { + Game game(GetParam()); + game.SetGamePath(dataPath.parent_path()); + ASSERT_NO_THROW(game.Init(false, localPath)); + + EXPECT_FALSE(game.IsPluginActive(blankEsp)); + } + + TEST_P(GameTest, shouldShowBlankEsmAsInactiveIfItsHeaderHasBeenLoadedAndGameHasNotBeenInitialised) { + Game game(GetParam()); + game.SetGamePath(dataPath.parent_path()); + ASSERT_NO_THROW(game.LoadPlugins(true)); + + EXPECT_FALSE(game.IsPluginActive(blankEsm)); + } + + TEST_P(GameTest, shouldShowBlankEspAsInactiveIfItsHeaderHasBeenLoadedAndGameHasNotBeenInitialised) { + Game game(GetParam()); + game.SetGamePath(dataPath.parent_path()); + ASSERT_NO_THROW(game.LoadPlugins(true)); + + EXPECT_FALSE(game.IsPluginActive(blankEsp)); + } + + TEST_P(GameTest, shouldShowBlankEsmAsActiveIfItsHeaderHasBeenLoadedAndTheGameHasBeenInitialised) { + Game game(GetParam()); + game.SetGamePath(dataPath.parent_path()); + ASSERT_NO_THROW(game.Init(false, localPath)); + ASSERT_NO_THROW(game.LoadPlugins(true)); + + EXPECT_TRUE(game.IsPluginActive(blankEsm)); + } + + TEST_P(GameTest, shouldShowBlankEspAsInactiveIfItsHeaderHasBeenLoadedAndTheGameHasBeenInitialised) { + Game game(GetParam()); + game.SetGamePath(dataPath.parent_path()); + ASSERT_NO_THROW(game.Init(false, localPath)); + ASSERT_NO_THROW(game.LoadPlugins(true)); + + EXPECT_FALSE(game.IsPluginActive(blankEsp)); + } + + TEST_P(GameTest, shouldShowBlankEsmAsActiveIfItHasBeenFullyLoadedAndTheGameHasBeenInitialised) { + Game game(GetParam()); + game.SetGamePath(dataPath.parent_path()); + ASSERT_NO_THROW(game.Init(false, localPath)); + ASSERT_NO_THROW(game.LoadPlugins(false)); + + EXPECT_TRUE(game.IsPluginActive(blankEsm)); + } + + TEST_P(GameTest, shouldShowBlankEspAsInactiveIfItHasBeenFullyLoadedAndTheGameHasBeenInitialised) { + Game game(GetParam()); + game.SetGamePath(dataPath.parent_path()); + ASSERT_NO_THROW(game.Init(false, localPath)); + ASSERT_NO_THROW(game.LoadPlugins(false)); + + EXPECT_FALSE(game.IsPluginActive(blankEsp)); + } +} +} + +#endif diff --git a/src/tests/backend/game/test_game.h b/src/tests/backend/game/test_game.h deleted file mode 100644 index 23d41620..00000000 --- a/src/tests/backend/game/test_game.h +++ /dev/null @@ -1,662 +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 -. -*/ - -#ifndef LOOT_TEST_BACKEND_GAME -#define LOOT_TEST_BACKEND_GAME - -#include "backend/error.h" -#include "backend/globals.h" -#include "backend/game/game.h" - -#include "tests/fixtures.h" - -namespace loot { - namespace test { - class GameTest : public SkyrimTest {}; - - TEST_F(GameTest, Constructors) { - // The constructors should just passthrough to the GameSettings - // members, so just check that is happening. - Game game; - GameSettings settings; - - EXPECT_EQ(Game::autodetect, game.Id()); - EXPECT_EQ(settings.Name(), game.Name()); - EXPECT_EQ(settings.FolderName(), game.FolderName()); - EXPECT_EQ(settings.Master(), game.Master()); - EXPECT_EQ(settings.RegistryKey(), game.RegistryKey()); - EXPECT_EQ(settings.RepoURL(), game.RepoURL()); - EXPECT_EQ(settings.RepoBranch(), game.RepoBranch()); - - EXPECT_EQ(settings.GamePath(), game.GamePath()); - EXPECT_EQ(settings.DataPath(), game.DataPath()); - EXPECT_EQ(settings.MasterlistPath(), game.MasterlistPath()); - EXPECT_EQ(settings.UserlistPath(), game.UserlistPath()); - - EXPECT_FALSE(game.ArePluginsFullyLoaded()); - - game = Game(Game::tes5); - settings = GameSettings(GameSettings::tes5); - - EXPECT_EQ(Game::tes5, game.Id()); - EXPECT_EQ(settings.Name(), game.Name()); - EXPECT_EQ(settings.FolderName(), game.FolderName()); - EXPECT_EQ(settings.Master(), game.Master()); - EXPECT_EQ(settings.RegistryKey(), game.RegistryKey()); - EXPECT_EQ(settings.RepoURL(), game.RepoURL()); - EXPECT_EQ(settings.RepoBranch(), game.RepoBranch()); - - EXPECT_EQ(settings.GamePath(), game.GamePath()); - EXPECT_EQ(settings.DataPath(), game.DataPath()); - EXPECT_EQ(settings.MasterlistPath(), game.MasterlistPath()); - EXPECT_EQ(settings.UserlistPath(), game.UserlistPath()); - - EXPECT_FALSE(game.ArePluginsFullyLoaded()); - - game = Game(Game::tes5, "folder"); - settings = GameSettings(GameSettings::tes5, "folder"); - - EXPECT_EQ(Game::tes5, game.Id()); - EXPECT_EQ(settings.Name(), game.Name()); - EXPECT_EQ(settings.FolderName(), game.FolderName()); - EXPECT_EQ(settings.Master(), game.Master()); - EXPECT_EQ(settings.RegistryKey(), game.RegistryKey()); - EXPECT_EQ(settings.RepoURL(), game.RepoURL()); - EXPECT_EQ(settings.RepoBranch(), game.RepoBranch()); - - EXPECT_EQ(settings.GamePath(), game.GamePath()); - EXPECT_EQ(settings.DataPath(), game.DataPath()); - EXPECT_EQ(settings.MasterlistPath(), game.MasterlistPath()); - EXPECT_EQ(settings.UserlistPath(), game.UserlistPath()); - - EXPECT_FALSE(game.ArePluginsFullyLoaded()); - - game = Game(settings); - - EXPECT_EQ(Game::tes5, game.Id()); - EXPECT_EQ(settings.Name(), game.Name()); - EXPECT_EQ(settings.FolderName(), game.FolderName()); - EXPECT_EQ(settings.Master(), game.Master()); - EXPECT_EQ(settings.RegistryKey(), game.RegistryKey()); - EXPECT_EQ(settings.RepoURL(), game.RepoURL()); - EXPECT_EQ(settings.RepoBranch(), game.RepoBranch()); - - EXPECT_EQ(settings.GamePath(), game.GamePath()); - EXPECT_EQ(settings.DataPath(), game.DataPath()); - EXPECT_EQ(settings.MasterlistPath(), game.MasterlistPath()); - EXPECT_EQ(settings.UserlistPath(), game.UserlistPath()); - - EXPECT_FALSE(game.ArePluginsFullyLoaded()); - } - - TEST_F(GameTest, Init) { - // Should throw for invalid ID. - Game game; - EXPECT_THROW(game.Init(false), error); - EXPECT_THROW(game.Init(true), error); - EXPECT_THROW(game.Init(false, localPath), error); - EXPECT_THROW(game.Init(true, localPath), error); - -#ifndef _WIN32 - // No point testing installation detection on Windows, because it will - // find real installs, and the multi-game fixtures are set up so that they - // won't get auto-detected. Test for failure on Linux though. - game = Game(Game::tes5); - EXPECT_THROW(game.Init(false), error); - EXPECT_THROW(game.Init(true), error); - EXPECT_THROW(game.Init(false, localPath), error); - EXPECT_THROW(game.Init(true, localPath), error); - - // No point testing LOOT folder creation on Windows, because there may be - // a real LOOT install. - // Not supplying a game local path on Linux should throw an exception. - game = Game(Game::tes5).SetGamePath(dataPath.parent_path()); - ASSERT_FALSE(boost::filesystem::exists(g_path_local / game.FolderName())); - EXPECT_THROW(game.Init(false), error); - EXPECT_FALSE(boost::filesystem::exists(g_path_local / game.FolderName())); - - game = Game(Game::tes5).SetGamePath(dataPath.parent_path()); - EXPECT_NO_THROW(game.Init(false, localPath)); - EXPECT_FALSE(boost::filesystem::exists(g_path_local / game.FolderName())); - EXPECT_TRUE(game.IsPluginActive("Skyrim.esm")); - EXPECT_TRUE(game.IsPluginActive("skyrim.esm")); - EXPECT_TRUE(game.IsPluginActive("Blank.esm")); - EXPECT_FALSE(game.IsPluginActive("Blank - Different.esm")); - EXPECT_FALSE(game.IsPluginActive("Blank - Master Dependent.esm")); - EXPECT_FALSE(game.IsPluginActive("Blank - Different Master Dependent.esm")); - EXPECT_FALSE(game.IsPluginActive("Blank.esp")); - EXPECT_FALSE(game.IsPluginActive("Blank - Different.esp")); - EXPECT_FALSE(game.IsPluginActive("Blank - Master Dependent.esp")); - EXPECT_TRUE(game.IsPluginActive("Blank - Different Master Dependent.esp")); - EXPECT_FALSE(game.IsPluginActive("Blank - Plugin Dependent.esp")); - EXPECT_FALSE(game.IsPluginActive("Blank - Different Plugin Dependent.esp")); - - game = Game(Game::tes5).SetGamePath(dataPath.parent_path()); - EXPECT_NO_THROW(game.Init(true, localPath)); - EXPECT_TRUE(boost::filesystem::exists(g_path_local / game.FolderName())); - EXPECT_TRUE(game.IsPluginActive("Skyrim.esm")); - EXPECT_TRUE(game.IsPluginActive("skyrim.esm")); - EXPECT_TRUE(game.IsPluginActive("Blank.esm")); - EXPECT_FALSE(game.IsPluginActive("Blank - Different.esm")); - EXPECT_FALSE(game.IsPluginActive("Blank - Master Dependent.esm")); - EXPECT_FALSE(game.IsPluginActive("Blank - Different Master Dependent.esm")); - EXPECT_FALSE(game.IsPluginActive("Blank.esp")); - EXPECT_FALSE(game.IsPluginActive("Blank - Different.esp")); - EXPECT_FALSE(game.IsPluginActive("Blank - Master Dependent.esp")); - EXPECT_TRUE(game.IsPluginActive("Blank - Different Master Dependent.esp")); - EXPECT_FALSE(game.IsPluginActive("Blank - Plugin Dependent.esp")); - EXPECT_FALSE(game.IsPluginActive("Blank - Different Plugin Dependent.esp")); -#else - game = Game(Game::tes5).SetGamePath(dataPath.parent_path()); - EXPECT_NO_THROW(game.Init(false)); - - game = Game(Game::tes5).SetGamePath(dataPath.parent_path()); - EXPECT_NO_THROW(game.Init(false, localPath)); - -#endif - } - - TEST_F(GameTest, RedatePlugins) { - Game game(Game::tes5); - game.SetGamePath(dataPath.parent_path()); - - // Throw because game hasn't been initialised yet. - EXPECT_THROW(game.RedatePlugins(), error); - - game.Init(false, localPath); - - std::vector loadOrder({ - "Skyrim.esm", - "Blank.esm", - "Blank - Different.esm", - "Blank - Master Dependent.esm.ghost", - "Blank - Different Master Dependent.esm", - "Blank.esp", - "Blank - Different.esp", - "Blank - Master Dependent.esp", - "Blank - Different Master Dependent.esp", - "Blank - Plugin Dependent.esp", - "Blank - Different Plugin Dependent.esp", - }); - - time_t time = boost::filesystem::last_write_time(dataPath / "Skyrim.esm"); - // First set reverse timestamps to be sure. - for (size_t i = 1; i < loadOrder.size(); ++i) { - boost::filesystem::last_write_time(dataPath / loadOrder[i], time - i * 60); - ASSERT_EQ(time - i * 60, boost::filesystem::last_write_time(dataPath / loadOrder[i])); - } - EXPECT_NO_THROW(game.RedatePlugins()); - EXPECT_EQ(time, boost::filesystem::last_write_time(dataPath / "Skyrim.esm")); - for (size_t i = 1; i < loadOrder.size(); ++i) { - ASSERT_EQ(time + i * 60, boost::filesystem::last_write_time(dataPath / loadOrder[i])); - } - } - - TEST_F(GameTest, LoadPlugins) { - Game game(Game::tes5); - game.SetGamePath(dataPath.parent_path()); - - EXPECT_NO_THROW(game.LoadPlugins(false)); - EXPECT_EQ(11, game.GetPlugins().size()); - - // Check that all the plugins' data have loaded correctly. - ASSERT_NO_THROW(game.GetPlugin("Skyrim.esm")); - Plugin plugin = game.GetPlugin("Skyrim.esm"); - EXPECT_EQ("Skyrim.esm", plugin.Name()); - EXPECT_FALSE(plugin.IsEmpty()); - EXPECT_TRUE(plugin.isMasterFile()); - EXPECT_EQ(std::set({ - libespm::FormId("Skyrim.esm", std::vector(), 0xCF0), - libespm::FormId("Skyrim.esm", std::vector(), 0xCF1), - libespm::FormId("Skyrim.esm", std::vector(), 0xCF2), - libespm::FormId("Skyrim.esm", std::vector(), 0xCF3), - libespm::FormId("Skyrim.esm", std::vector(), 0xCF4), - libespm::FormId("Skyrim.esm", std::vector(), 0xCF5), - libespm::FormId("Skyrim.esm", std::vector(), 0xCF6), - libespm::FormId("Skyrim.esm", std::vector(), 0xCF7), - libespm::FormId("Skyrim.esm", std::vector(), 0xCF8), - libespm::FormId("Skyrim.esm", std::vector(), 0xCF9), - }), plugin.getFormIds()); - EXPECT_TRUE(plugin.getMasters().empty()); - EXPECT_EQ("v5.0", plugin.getDescription()); - EXPECT_EQ(0x187BE342, plugin.Crc()); - EXPECT_EQ(0, plugin.NumOverrideFormIDs()); - - ASSERT_NO_THROW(game.GetPlugin("blank.esm")); - plugin = game.GetPlugin("blank.esm"); - EXPECT_EQ("Blank.esm", plugin.Name()); - EXPECT_FALSE(plugin.IsEmpty()); - EXPECT_TRUE(plugin.isMasterFile()); - EXPECT_EQ(std::set({ - libespm::FormId("Blank.esm", std::vector(), 0xCF0), - libespm::FormId("Blank.esm", std::vector(), 0xCF1), - libespm::FormId("Blank.esm", std::vector(), 0xCF2), - libespm::FormId("Blank.esm", std::vector(), 0xCF3), - libespm::FormId("Blank.esm", std::vector(), 0xCF4), - libespm::FormId("Blank.esm", std::vector(), 0xCF5), - libespm::FormId("Blank.esm", std::vector(), 0xCF6), - libespm::FormId("Blank.esm", std::vector(), 0xCF7), - libespm::FormId("Blank.esm", std::vector(), 0xCF8), - libespm::FormId("Blank.esm", std::vector(), 0xCF9), - }), plugin.getFormIds()); - EXPECT_TRUE(plugin.getMasters().empty()); - EXPECT_EQ("v5.0", plugin.getDescription()); - EXPECT_EQ(0x187BE342, plugin.Crc()); - EXPECT_EQ(0, plugin.NumOverrideFormIDs()); - - ASSERT_NO_THROW(game.GetPlugin("Blank - Different.esm")); - plugin = game.GetPlugin("Blank - Different.esm"); - EXPECT_EQ("Blank - Different.esm", plugin.Name()); - EXPECT_FALSE(plugin.IsEmpty()); - EXPECT_TRUE(plugin.isMasterFile()); - EXPECT_EQ(std::set({ - libespm::FormId("Blank - Different.esm", std::vector(), 0xCEF), - libespm::FormId("Blank - Different.esm", std::vector(), 0xCF0), - libespm::FormId("Blank - Different.esm", std::vector(), 0xCF1), - libespm::FormId("Blank - Different.esm", std::vector(), 0xCF2), - libespm::FormId("Blank - Different.esm", std::vector(), 0xCF3), - libespm::FormId("Blank - Different.esm", std::vector(), 0xCF4), - libespm::FormId("Blank - Different.esm", std::vector(), 0xCF5), - libespm::FormId("Blank - Different.esm", std::vector(), 0xCF6), - libespm::FormId("Blank - Different.esm", std::vector(), 0xCF7), - }), plugin.getFormIds()); - EXPECT_TRUE(plugin.getMasters().empty()); - EXPECT_EQ("", plugin.getDescription()); - EXPECT_EQ(0x64B9F757, plugin.Crc()); - EXPECT_EQ(0, plugin.NumOverrideFormIDs()); - - ASSERT_NO_THROW(game.GetPlugin("blank - master dependent.esm")); - plugin = game.GetPlugin("blank - master dependent.esm"); - EXPECT_EQ("Blank - Master Dependent.esm", plugin.Name()); - EXPECT_FALSE(plugin.IsEmpty()); - EXPECT_TRUE(plugin.isMasterFile()); - EXPECT_EQ(std::set({ - libespm::FormId("Blank.esm", std::vector(), 0xCF0), - libespm::FormId("Blank.esm", std::vector(), 0xCF1), - libespm::FormId("Blank.esm", std::vector(), 0xCF2), - libespm::FormId("Blank.esm", std::vector(), 0xCF3), - libespm::FormId("Blank - Master Dependent.esm", std::vector(), 0xCEA), - libespm::FormId("Blank - Master Dependent.esm", std::vector(), 0xCEB), - libespm::FormId("Blank - Master Dependent.esm", std::vector(), 0xCEC), - libespm::FormId("Blank - Master Dependent.esm", std::vector(), 0xCED), - }), plugin.getFormIds()); - EXPECT_EQ(std::vector({ - "Blank.esm" - }), plugin.getMasters()); - EXPECT_EQ("", plugin.getDescription()); - EXPECT_EQ(0xB2D4119E, plugin.Crc()); - EXPECT_EQ(4, plugin.NumOverrideFormIDs()); - - ASSERT_NO_THROW(game.GetPlugin("blank - different master dependent.esm")); - plugin = game.GetPlugin("blank - different master dependent.esm"); - EXPECT_EQ("Blank - Different Master Dependent.esm", plugin.Name()); - EXPECT_FALSE(plugin.IsEmpty()); - EXPECT_TRUE(plugin.isMasterFile()); - EXPECT_EQ(std::set({ - libespm::FormId("Blank - Different.esm", std::vector(), 0xCEF), - libespm::FormId("Blank - Different.esm", std::vector(), 0xCF0), - libespm::FormId("Blank - Different.esm", std::vector(), 0xCF1), - libespm::FormId("Blank - Different.esm", std::vector(), 0xCF2), - libespm::FormId("Blank - Different Master Dependent.esm", std::vector(), 0xCE9), - libespm::FormId("Blank - Different Master Dependent.esm", std::vector(), 0xCEA), - libespm::FormId("Blank - Different Master Dependent.esm", std::vector(), 0xCEB), - }), plugin.getFormIds()); - EXPECT_EQ(std::vector({ - "Blank - Different.esm" - }), plugin.getMasters()); - EXPECT_EQ("", plugin.getDescription()); - EXPECT_EQ(0xAADF6710, plugin.Crc()); - EXPECT_EQ(4, plugin.NumOverrideFormIDs()); - - ASSERT_NO_THROW(game.GetPlugin("blank.esp")); - plugin = game.GetPlugin("blank.esp"); - EXPECT_EQ("Blank.esp", plugin.Name()); - EXPECT_FALSE(plugin.IsEmpty()); - EXPECT_FALSE(plugin.isMasterFile()); - EXPECT_EQ(std::set({ - libespm::FormId("Blank.esp", std::vector(), 0xCEC), - libespm::FormId("Blank.esp", std::vector(), 0xCED), - libespm::FormId("Blank.esp", std::vector(), 0xCEE), - libespm::FormId("Blank.esp", std::vector(), 0xCEF), - libespm::FormId("Blank.esp", std::vector(), 0xCF0), - libespm::FormId("Blank.esp", std::vector(), 0xCF1), - }), plugin.getFormIds()); - EXPECT_TRUE(plugin.getMasters().empty()); - EXPECT_EQ("\xE2\x82\xAC\xC6\x92\xC5\xA0", plugin.getDescription()); - EXPECT_EQ(0x24F0E2A1, plugin.Crc()); - EXPECT_EQ(0, plugin.NumOverrideFormIDs()); - - ASSERT_NO_THROW(game.GetPlugin("blank - different.esp")); - plugin = game.GetPlugin("blank - different.esp"); - EXPECT_EQ("Blank - Different.esp", plugin.Name()); - EXPECT_FALSE(plugin.IsEmpty()); - EXPECT_FALSE(plugin.isMasterFile()); - EXPECT_EQ(std::set({ - libespm::FormId("Blank - Different.esp", std::vector(), 0xCEB), - libespm::FormId("Blank - Different.esp", std::vector(), 0xCEC), - libespm::FormId("Blank - Different.esp", std::vector(), 0xCED), - libespm::FormId("Blank - Different.esp", std::vector(), 0xCEE), - libespm::FormId("Blank - Different.esp", std::vector(), 0xCEF), - }), plugin.getFormIds()); - EXPECT_TRUE(plugin.getMasters().empty()); - EXPECT_EQ("", plugin.getDescription()); - EXPECT_EQ(0xD4C9B7AE, plugin.Crc()); - EXPECT_EQ(0, plugin.NumOverrideFormIDs()); - - ASSERT_NO_THROW(game.GetPlugin("blank - master dependent.esp")); - plugin = game.GetPlugin("blank - master dependent.esp"); - EXPECT_EQ("Blank - Master Dependent.esp", plugin.Name()); - EXPECT_FALSE(plugin.IsEmpty()); - EXPECT_FALSE(plugin.isMasterFile()); - EXPECT_EQ(std::set({ - libespm::FormId("Blank.esm", std::vector(), 0xCF0), - libespm::FormId("Blank.esm", std::vector(), 0xCF1), - libespm::FormId("Blank - Master Dependent.esp", std::vector(), 0xCE9), - libespm::FormId("Blank - Master Dependent.esp", std::vector(), 0xCEA), - }), plugin.getFormIds()); - EXPECT_EQ(std::vector({ - "Blank.esm" - }), plugin.getMasters()); - EXPECT_EQ("", plugin.getDescription()); - EXPECT_EQ(0x832152DC, plugin.Crc()); - EXPECT_EQ(2, plugin.NumOverrideFormIDs()); - - ASSERT_NO_THROW(game.GetPlugin("blank - different master dependent.esp")); - plugin = game.GetPlugin("blank - different master dependent.esp"); - EXPECT_EQ("Blank - Different Master Dependent.esp", plugin.Name()); - EXPECT_FALSE(plugin.IsEmpty()); - EXPECT_FALSE(plugin.isMasterFile()); - EXPECT_EQ(std::set({ - libespm::FormId("Blank - Different.esm", std::vector(), 0xCEF), - libespm::FormId("Blank - Different.esm", std::vector(), 0xCF0), - libespm::FormId("Blank - Different Master Dependent.esp", std::vector(), 0xCE7), - }), plugin.getFormIds()); - EXPECT_EQ(std::vector({ - "Blank - Different.esm" - }), plugin.getMasters()); - EXPECT_EQ("", plugin.getDescription()); - EXPECT_EQ(0x3AD17683, plugin.Crc()); - EXPECT_EQ(2, plugin.NumOverrideFormIDs()); - - ASSERT_NO_THROW(game.GetPlugin("blank - plugin dependent.esp")); - plugin = game.GetPlugin("blank - plugin dependent.esp"); - EXPECT_EQ("Blank - Plugin Dependent.esp", plugin.Name()); - EXPECT_FALSE(plugin.IsEmpty()); - EXPECT_FALSE(plugin.isMasterFile()); - EXPECT_EQ(std::set({ - libespm::FormId("Blank.esp", std::vector(), 0xCEC), - libespm::FormId("Blank - Plugin Dependent.esp", std::vector(), 0xCE7), - }), plugin.getFormIds()); - EXPECT_EQ(std::vector({ - "Blank.esp" - }), plugin.getMasters()); - EXPECT_EQ("", plugin.getDescription()); - EXPECT_EQ(0x28EF26DB, plugin.Crc()); - EXPECT_EQ(1, plugin.NumOverrideFormIDs()); - - ASSERT_NO_THROW(game.GetPlugin("blank - different plugin dependent.esp")); - plugin = game.GetPlugin("blank - different plugin dependent.esp"); - EXPECT_EQ("Blank - Different Plugin Dependent.esp", plugin.Name()); - EXPECT_FALSE(plugin.IsEmpty()); - EXPECT_FALSE(plugin.isMasterFile()); - EXPECT_EQ(std::set({ - libespm::FormId("Blank - Different.esp", std::vector(), 0xCEB), - }), plugin.getFormIds()); - EXPECT_EQ(std::vector({ - "Blank - Different.esp" - }), plugin.getMasters()); - EXPECT_EQ("", plugin.getDescription()); - EXPECT_EQ(0xEB47BE63, plugin.Crc()); - EXPECT_EQ(1, plugin.NumOverrideFormIDs()); - } - - TEST_F(GameTest, LoadPlugins_HeadersOnly) { - Game game(Game::tes5); - game.SetGamePath(dataPath.parent_path()); - - EXPECT_NO_THROW(game.LoadPlugins(true)); - EXPECT_EQ(11, game.GetPlugins().size()); - - // Check that all the plugins' data have loaded correctly. - ASSERT_NO_THROW(game.GetPlugin("Skyrim.esm")); - Plugin plugin = game.GetPlugin("Skyrim.esm"); - EXPECT_EQ("Skyrim.esm", plugin.Name()); - EXPECT_FALSE(plugin.IsEmpty()); - EXPECT_TRUE(plugin.isMasterFile()); - EXPECT_TRUE(plugin.getFormIds().empty()); - EXPECT_TRUE(plugin.getMasters().empty()); - EXPECT_EQ("v5.0", plugin.getDescription()); - EXPECT_EQ(0, plugin.Crc()); - EXPECT_EQ(0, plugin.NumOverrideFormIDs()); - - ASSERT_NO_THROW(game.GetPlugin("blank.esm")); - plugin = game.GetPlugin("blank.esm"); - EXPECT_EQ("Blank.esm", plugin.Name()); - EXPECT_FALSE(plugin.IsEmpty()); - EXPECT_TRUE(plugin.isMasterFile()); - EXPECT_TRUE(plugin.getFormIds().empty()); - EXPECT_TRUE(plugin.getMasters().empty()); - EXPECT_EQ("v5.0", plugin.getDescription()); - EXPECT_EQ(0, plugin.Crc()); - EXPECT_EQ(0, plugin.NumOverrideFormIDs()); - - ASSERT_NO_THROW(game.GetPlugin("Blank - Different.esm")); - plugin = game.GetPlugin("Blank - Different.esm"); - EXPECT_EQ("Blank - Different.esm", plugin.Name()); - EXPECT_FALSE(plugin.IsEmpty()); - EXPECT_TRUE(plugin.isMasterFile()); - EXPECT_TRUE(plugin.getFormIds().empty()); - EXPECT_TRUE(plugin.getMasters().empty()); - EXPECT_EQ("", plugin.getDescription()); - EXPECT_EQ(0, plugin.Crc()); - EXPECT_EQ(0, plugin.NumOverrideFormIDs()); - - ASSERT_NO_THROW(game.GetPlugin("blank - master dependent.esm")); - plugin = game.GetPlugin("blank - master dependent.esm"); - EXPECT_EQ("Blank - Master Dependent.esm", plugin.Name()); - EXPECT_FALSE(plugin.IsEmpty()); - EXPECT_TRUE(plugin.isMasterFile()); - EXPECT_TRUE(plugin.getFormIds().empty()); - EXPECT_EQ(std::vector({ - "Blank.esm" - }), plugin.getMasters()); - EXPECT_EQ("", plugin.getDescription()); - EXPECT_EQ(0, plugin.Crc()); - EXPECT_EQ(0, plugin.NumOverrideFormIDs()); - - ASSERT_NO_THROW(game.GetPlugin("blank - different master dependent.esm")); - plugin = game.GetPlugin("blank - different master dependent.esm"); - EXPECT_EQ("Blank - Different Master Dependent.esm", plugin.Name()); - EXPECT_FALSE(plugin.IsEmpty()); - EXPECT_TRUE(plugin.isMasterFile()); - EXPECT_TRUE(plugin.getFormIds().empty()); - EXPECT_EQ(std::vector({ - "Blank - Different.esm" - }), plugin.getMasters()); - EXPECT_EQ("", plugin.getDescription()); - EXPECT_EQ(0, plugin.Crc()); - EXPECT_EQ(0, plugin.NumOverrideFormIDs()); - - ASSERT_NO_THROW(game.GetPlugin("blank.esp")); - plugin = game.GetPlugin("blank.esp"); - EXPECT_EQ("Blank.esp", plugin.Name()); - EXPECT_FALSE(plugin.IsEmpty()); - EXPECT_FALSE(plugin.isMasterFile()); - EXPECT_TRUE(plugin.getFormIds().empty()); - EXPECT_TRUE(plugin.getMasters().empty()); - EXPECT_EQ("\xE2\x82\xAC\xC6\x92\xC5\xA0", plugin.getDescription()); - EXPECT_EQ(0, plugin.Crc()); - EXPECT_EQ(0, plugin.NumOverrideFormIDs()); - - ASSERT_NO_THROW(game.GetPlugin("blank - different.esp")); - plugin = game.GetPlugin("blank - different.esp"); - EXPECT_EQ("Blank - Different.esp", plugin.Name()); - EXPECT_FALSE(plugin.IsEmpty()); - EXPECT_FALSE(plugin.isMasterFile()); - EXPECT_TRUE(plugin.getFormIds().empty()); - EXPECT_TRUE(plugin.getMasters().empty()); - EXPECT_EQ("", plugin.getDescription()); - EXPECT_EQ(0, plugin.Crc()); - EXPECT_EQ(0, plugin.NumOverrideFormIDs()); - - ASSERT_NO_THROW(game.GetPlugin("blank - master dependent.esp")); - plugin = game.GetPlugin("blank - master dependent.esp"); - EXPECT_EQ("Blank - Master Dependent.esp", plugin.Name()); - EXPECT_FALSE(plugin.IsEmpty()); - EXPECT_FALSE(plugin.isMasterFile()); - EXPECT_TRUE(plugin.getFormIds().empty()); - EXPECT_EQ(std::vector({ - "Blank.esm" - }), plugin.getMasters()); - EXPECT_EQ("", plugin.getDescription()); - EXPECT_EQ(0, plugin.Crc()); - EXPECT_EQ(0, plugin.NumOverrideFormIDs()); - - ASSERT_NO_THROW(game.GetPlugin("blank - different master dependent.esp")); - plugin = game.GetPlugin("blank - different master dependent.esp"); - EXPECT_EQ("Blank - Different Master Dependent.esp", plugin.Name()); - EXPECT_FALSE(plugin.IsEmpty()); - EXPECT_FALSE(plugin.isMasterFile()); - EXPECT_TRUE(plugin.getFormIds().empty()); - EXPECT_EQ(std::vector({ - "Blank - Different.esm" - }), plugin.getMasters()); - EXPECT_EQ("", plugin.getDescription()); - EXPECT_EQ(0, plugin.Crc()); - EXPECT_EQ(0, plugin.NumOverrideFormIDs()); - - ASSERT_NO_THROW(game.GetPlugin("blank - plugin dependent.esp")); - plugin = game.GetPlugin("blank - plugin dependent.esp"); - EXPECT_EQ("Blank - Plugin Dependent.esp", plugin.Name()); - EXPECT_FALSE(plugin.IsEmpty()); - EXPECT_FALSE(plugin.isMasterFile()); - EXPECT_TRUE(plugin.getFormIds().empty()); - EXPECT_EQ(std::vector({ - "Blank.esp" - }), plugin.getMasters()); - EXPECT_EQ("", plugin.getDescription()); - EXPECT_EQ(0, plugin.Crc()); - EXPECT_EQ(0, plugin.NumOverrideFormIDs()); - - ASSERT_NO_THROW(game.GetPlugin("blank - different plugin dependent.esp")); - plugin = game.GetPlugin("blank - different plugin dependent.esp"); - EXPECT_EQ("Blank - Different Plugin Dependent.esp", plugin.Name()); - EXPECT_FALSE(plugin.IsEmpty()); - EXPECT_FALSE(plugin.isMasterFile()); - EXPECT_TRUE(plugin.getFormIds().empty()); - EXPECT_EQ(std::vector({ - "Blank - Different.esp" - }), plugin.getMasters()); - EXPECT_EQ("", plugin.getDescription()); - EXPECT_EQ(0, plugin.Crc()); - EXPECT_EQ(0, plugin.NumOverrideFormIDs()); - } - - TEST_F(GameTest, ArePluginsFullyLoaded) { - Game game(Game::tes5); - game.SetGamePath(dataPath.parent_path()); - EXPECT_FALSE(game.ArePluginsFullyLoaded()); - - ASSERT_NO_THROW(game.LoadPlugins(false)); - EXPECT_TRUE(game.ArePluginsFullyLoaded()); - } - - TEST_F(GameTest, shouldThrowIfCheckingIfPluginThatIsntLoadedIsActiveAndGameHasNotBeenInitialised) { - Game game(Game::tes5); - game.SetGamePath(dataPath.parent_path()); - - EXPECT_ANY_THROW(game.IsPluginActive("Blank.esm")); - } - - TEST_F(GameTest, shouldShowBlankEsmAsActiveIfItHasNotBeenLoadedAndTheGameHasBeenInitialised) { - Game game(Game::tes5); - game.SetGamePath(dataPath.parent_path()); - ASSERT_NO_THROW(game.Init(false, localPath)); - - EXPECT_TRUE(game.IsPluginActive("Blank.esm")); - } - - TEST_F(GameTest, shouldShowBlankEspAsInctiveIfItHasNotBeenLoadedAndTheGameHasBeenInitialised) { - Game game(Game::tes5); - game.SetGamePath(dataPath.parent_path()); - ASSERT_NO_THROW(game.Init(false, localPath)); - - EXPECT_FALSE(game.IsPluginActive("Blank.esp")); - } - - TEST_F(GameTest, shouldShowBlankEsmAsInactiveIfItsHeaderHasBeenLoadedAndGameHasNotBeenInitialised) { - Game game(Game::tes5); - game.SetGamePath(dataPath.parent_path()); - ASSERT_NO_THROW(game.LoadPlugins(true)); - - EXPECT_FALSE(game.IsPluginActive("Blank.esm")); - } - - TEST_F(GameTest, shouldShowBlankEspAsActiveIfItsHeaderHasBeenLoadedAndGameHasNotBeenInitialised) { - Game game(Game::tes5); - game.SetGamePath(dataPath.parent_path()); - ASSERT_NO_THROW(game.LoadPlugins(true)); - - EXPECT_FALSE(game.IsPluginActive("Blank.esp")); - } - - TEST_F(GameTest, shouldShowBlankEsmAsActiveIfItsHeaderHasBeenLoadedAndTheGameHasBeenInitialised) { - Game game(Game::tes5); - game.SetGamePath(dataPath.parent_path()); - ASSERT_NO_THROW(game.Init(false, localPath)); - ASSERT_NO_THROW(game.LoadPlugins(true)); - - EXPECT_TRUE(game.IsPluginActive("Blank.esm")); - } - - TEST_F(GameTest, shouldShowBlankEspAsActiveIfItsHeaderHasBeenLoadedAndTheGameHasBeenInitialised) { - Game game(Game::tes5); - game.SetGamePath(dataPath.parent_path()); - ASSERT_NO_THROW(game.Init(false, localPath)); - ASSERT_NO_THROW(game.LoadPlugins(true)); - - EXPECT_FALSE(game.IsPluginActive("Blank.esp")); - } - - TEST_F(GameTest, shouldShowBlankEsmAsActiveIfItHasBeenFullyLoadedAndTheGameHasBeenInitialised) { - Game game(Game::tes5); - game.SetGamePath(dataPath.parent_path()); - ASSERT_NO_THROW(game.Init(false, localPath)); - ASSERT_NO_THROW(game.LoadPlugins(false)); - - EXPECT_TRUE(game.IsPluginActive("Blank.esm")); - } - - TEST_F(GameTest, shouldShowBlankEspAsActiveIfItHasBeenFullyLoadedAndTheGameHasBeenInitialised) { - Game game(Game::tes5); - game.SetGamePath(dataPath.parent_path()); - ASSERT_NO_THROW(game.Init(false, localPath)); - ASSERT_NO_THROW(game.LoadPlugins(false)); - - EXPECT_FALSE(game.IsPluginActive("Blank.esp")); - } - } -} - -#endif diff --git a/src/tests/base_game_test.h b/src/tests/base_game_test.h index 105db2c4..c38507ec 100644 --- a/src/tests/base_game_test.h +++ b/src/tests/base_game_test.h @@ -46,7 +46,8 @@ namespace loot { blankMasterDependentEsp("Blank - Master Dependent.esp"), blankDifferentMasterDependentEsp("Blank - Different Master Dependent.esp"), blankPluginDependentEsp("Blank - Plugin Dependent.esp"), - blankDifferentPluginDependentEsp("Blank - Different Plugin Dependent.esp") {} + blankDifferentPluginDependentEsp("Blank - Different Plugin Dependent.esp"), + blankEsmCrc(getBlankEsmCrc()) {} inline virtual void SetUp() { ASSERT_NO_THROW(boost::filesystem::create_directories(localPath)); @@ -91,6 +92,8 @@ namespace loot { const std::string blankPluginDependentEsp; const std::string blankDifferentPluginDependentEsp; + const uint32_t blankEsmCrc; + private: inline boost::filesystem::path getLocalPath() const { if (GetParam() == loot_game_tes4) @@ -118,6 +121,13 @@ namespace loot { else return "Fallout4.esm"; } + + inline uint32_t getBlankEsmCrc() const { + if (GetParam() == loot_game_tes4) + return 0x374E2A6F; + else + return 0x187BE342; + } }; } } diff --git a/src/tests/main.cpp b/src/tests/main.cpp index 45f5a154..c56c909c 100644 --- a/src/tests/main.cpp +++ b/src/tests/main.cpp @@ -41,7 +41,7 @@ #include "api/loot_update_masterlist_test.h" #include "api/loot_write_minimal_list_test.h" #include "api/test_api.h" -#include "backend/game/test_game.h" +#include "backend/game/game_test.h" #include "backend/game/test_game_cache.h" #include "backend/game/test_game_settings.h" #include "backend/game/test_load_order_handler.h"