mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-09 22:38:06 -05:00
chore: fix test compilation
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
#include "Game/IW3/StringTable/AssetLoaderStringTableIW3.h"
|
||||
|
||||
#include "Game/IW3/GameIW3.h"
|
||||
#include "Mock/MockAssetLoadingManager.h"
|
||||
#include "Mock/MockSearchPath.h"
|
||||
#include "Pool/ZoneAssetPools.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
@ -22,24 +21,19 @@ namespace
|
||||
"lorem,ipsum");
|
||||
|
||||
Zone zone("MockZone", 0, IGame::GetGameById(GameId::IW3));
|
||||
zone.m_pools = ZoneAssetPools::CreateForGame(GameId::IW3, &zone, 1);
|
||||
|
||||
const auto assetTypeCount = zone.m_pools->GetAssetTypeCount();
|
||||
for (auto i = 0; i < assetTypeCount; i++)
|
||||
zone.m_pools->InitPoolDynamic(i);
|
||||
|
||||
MemoryManager memory;
|
||||
AssetCreatorCollection creatorCollection(zone);
|
||||
AssetLoaderStringTable assetLoader(memory, searchPath);
|
||||
IgnoredAssetLookup ignoredAssetLookup;
|
||||
|
||||
AssetCreationContext context(&zone, &creatorCollection, &ignoredAssetLookup);
|
||||
|
||||
const auto result = assetLoader.CreateAsset("mp/cooltable.csv", context);
|
||||
auto loader = CreateStringTableLoader(memory, searchPath);
|
||||
auto result = loader->CreateAsset("mp/cooltable.csv", context);
|
||||
REQUIRE(result.HasBeenSuccessful());
|
||||
|
||||
const auto* assetInfo = reinterpret_cast<XAssetInfo<StringTable>*>(result.GetAssetInfo());
|
||||
const auto* stringTable = assetInfo->Asset();
|
||||
|
||||
REQUIRE(stringTable->name == "mp/cooltable.csv"s);
|
||||
REQUIRE(stringTable->columnCount == 3);
|
||||
REQUIRE(stringTable->rowCount == 2);
|
||||
|
@ -1,8 +1,7 @@
|
||||
#include "Game/IW4/AssetLoaders/AssetLoaderStringTable.h"
|
||||
#include "Game/IW4/StringTable/LoaderStringTableIW4.h"
|
||||
|
||||
#include "Game/IW4/CommonIW4.h"
|
||||
#include "Game/IW4/GameIW4.h"
|
||||
#include "Mock/MockAssetLoadingManager.h"
|
||||
#include "Mock/MockSearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
|
||||
@ -22,17 +21,19 @@ namespace
|
||||
"lorem,ipsum");
|
||||
|
||||
Zone zone("MockZone", 0, IGame::GetGameById(GameId::IW4));
|
||||
MockAssetLoadingManager assetLoadingManager(zone, searchPath);
|
||||
|
||||
AssetLoaderStringTable assetLoader;
|
||||
MemoryManager memory;
|
||||
AssetCreatorCollection creatorCollection(zone);
|
||||
IgnoredAssetLookup ignoredAssetLookup;
|
||||
AssetCreationContext context(&zone, &creatorCollection, &ignoredAssetLookup);
|
||||
|
||||
assetLoader.LoadFromRaw("mp/cooltable.csv", &searchPath, &memory, &assetLoadingManager, &zone);
|
||||
|
||||
auto* assetInfo = reinterpret_cast<XAssetInfo<StringTable>*>(assetLoadingManager.MockGetAddedAsset("mp/cooltable.csv"));
|
||||
REQUIRE(assetInfo != nullptr);
|
||||
auto loader = CreateStringTableLoader(memory, searchPath);
|
||||
auto result = loader->CreateAsset("mp/cooltable.csv", context);
|
||||
REQUIRE(result.HasBeenSuccessful());
|
||||
|
||||
const auto* assetInfo = reinterpret_cast<XAssetInfo<StringTable>*>(result.GetAssetInfo());
|
||||
const auto* stringTable = assetInfo->Asset();
|
||||
|
||||
REQUIRE(stringTable->name == "mp/cooltable.csv"s);
|
||||
REQUIRE(stringTable->columnCount == 3);
|
||||
REQUIRE(stringTable->rowCount == 2);
|
@ -1,6 +1,6 @@
|
||||
#include "Game/IW4/AssetLoaders/AssetLoaderMenuList.h"
|
||||
#include "Game/IW4/Menu/LoaderMenuListIW4.h"
|
||||
|
||||
#include "Game/IW4/GameIW4.h"
|
||||
#include "Mock/MockAssetLoadingManager.h"
|
||||
#include "Mock/MockSearchPath.h"
|
||||
#include "Parsing/Menu/MenuFileReader.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
@ -8,6 +8,7 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
#include <catch2/matchers/catch_matchers_floating_point.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
using namespace menu;
|
||||
@ -23,14 +24,19 @@ namespace test::game::iw4::menu::parsing::it
|
||||
|
||||
Zone m_zone;
|
||||
MockSearchPath m_search_path;
|
||||
MockAssetLoadingManager m_manager;
|
||||
AssetLoaderMenuList m_asset_loader;
|
||||
std::unique_ptr<IAssetCreator> m_asset_creator;
|
||||
AssetCreatorCollection m_creator_collection;
|
||||
IgnoredAssetLookup m_ignored_asset_lookup;
|
||||
AssetCreationContext m_context;
|
||||
|
||||
public:
|
||||
MenuParsingItHelper()
|
||||
: m_zone("MockZone", 0, IGame::GetGameById(GameId::IW4)),
|
||||
m_manager(m_zone, m_search_path)
|
||||
m_creator_collection(m_zone),
|
||||
m_ignored_asset_lookup(),
|
||||
m_context(&m_zone, &m_creator_collection, &m_ignored_asset_lookup)
|
||||
{
|
||||
m_asset_creator = CreateMenuListLoader(*m_zone.GetMemory(), m_search_path);
|
||||
}
|
||||
|
||||
void AddFile(std::string fileName, std::string data)
|
||||
@ -48,28 +54,19 @@ namespace test::game::iw4::menu::parsing::it
|
||||
auto* material = m_zone.GetMemory()->Create<Material>();
|
||||
material->info.name = m_zone.GetMemory()->Dup(name.c_str());
|
||||
|
||||
m_manager.MockAddAvailableDependency(ASSET_TYPE_MATERIAL, name, material);
|
||||
m_context.AddAsset<AssetMaterial>(name, material);
|
||||
|
||||
return material;
|
||||
}
|
||||
|
||||
bool RunIntegrationTest()
|
||||
AssetCreationResult RunIntegrationTest()
|
||||
{
|
||||
return m_asset_loader.LoadFromRaw(DEFAULT_ASSET_NAME, &m_search_path, m_zone.GetMemory(), &m_manager, &m_zone);
|
||||
}
|
||||
|
||||
MenuList* GetMenuListAsset()
|
||||
{
|
||||
const auto addedAsset = m_manager.MockGetAddedAsset(DEFAULT_ASSET_NAME);
|
||||
REQUIRE(addedAsset);
|
||||
REQUIRE(addedAsset->m_type == ASSET_TYPE_MENULIST);
|
||||
|
||||
return static_cast<MenuList*>(addedAsset->m_ptr);
|
||||
return m_asset_creator->CreateAsset(DEFAULT_ASSET_NAME, m_context);
|
||||
}
|
||||
|
||||
menuDef_t* GetMenuAsset(const std::string& menuName)
|
||||
{
|
||||
const auto addedAsset = m_manager.MockGetAddedAsset(menuName);
|
||||
const auto addedAsset = m_zone.m_pools->GetAsset(ASSET_TYPE_MENU, menuName);
|
||||
REQUIRE(addedAsset);
|
||||
REQUIRE(addedAsset->m_type == ASSET_TYPE_MENU);
|
||||
|
||||
@ -91,9 +88,9 @@ namespace test::game::iw4::menu::parsing::it
|
||||
)testmenu");
|
||||
|
||||
const auto result = helper.RunIntegrationTest();
|
||||
REQUIRE(result);
|
||||
REQUIRE(result.HasBeenSuccessful());
|
||||
|
||||
const auto* menuList = helper.GetMenuListAsset();
|
||||
const auto* menuList = (MenuList*)result.GetAssetInfo()->m_ptr;
|
||||
const auto* menu = helper.GetMenuAsset("Hello");
|
||||
|
||||
REQUIRE(menuList->menuCount == 1);
|
||||
@ -172,9 +169,9 @@ namespace test::game::iw4::menu::parsing::it
|
||||
const auto* funnyDogMaterial = helper.AddMaterial("funny_dog.png");
|
||||
|
||||
const auto result = helper.RunIntegrationTest();
|
||||
REQUIRE(result);
|
||||
REQUIRE(result.HasBeenSuccessful());
|
||||
|
||||
const auto* menuList = helper.GetMenuListAsset();
|
||||
const auto* menuList = (MenuList*)result.GetAssetInfo()->m_ptr;
|
||||
const auto* menu = helper.GetMenuAsset("Bla");
|
||||
|
||||
REQUIRE(menuList->menuCount == 1);
|
||||
@ -343,9 +340,9 @@ namespace test::game::iw4::menu::parsing::it
|
||||
)testmenu");
|
||||
|
||||
const auto result = helper.RunIntegrationTest();
|
||||
REQUIRE(result);
|
||||
REQUIRE(result.HasBeenSuccessful());
|
||||
|
||||
const auto* menuList = helper.GetMenuListAsset();
|
||||
const auto* menuList = (MenuList*)result.GetAssetInfo()->m_ptr;
|
||||
const auto* menu = helper.GetMenuAsset("Blab");
|
||||
|
||||
REQUIRE(menuList->menuCount == 1);
|
@ -1,7 +1,6 @@
|
||||
#include "Game/IW5/AssetLoaders/AssetLoaderStringTable.h"
|
||||
#include "Game/IW5/StringTable/LoaderStringTableIW5.h"
|
||||
|
||||
#include "Game/IW5/GameIW5.h"
|
||||
#include "Mock/MockAssetLoadingManager.h"
|
||||
#include "Mock/MockSearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
|
||||
@ -21,17 +20,19 @@ namespace
|
||||
"lorem,ipsum");
|
||||
|
||||
Zone zone("MockZone", 0, IGame::GetGameById(GameId::IW5));
|
||||
MockAssetLoadingManager assetLoadingManager(zone, searchPath);
|
||||
|
||||
AssetLoaderStringTable assetLoader;
|
||||
MemoryManager memory;
|
||||
AssetCreatorCollection creatorCollection(zone);
|
||||
IgnoredAssetLookup ignoredAssetLookup;
|
||||
AssetCreationContext context(&zone, &creatorCollection, &ignoredAssetLookup);
|
||||
|
||||
assetLoader.LoadFromRaw("mp/cooltable.csv", &searchPath, &memory, &assetLoadingManager, &zone);
|
||||
|
||||
auto* assetInfo = reinterpret_cast<XAssetInfo<StringTable>*>(assetLoadingManager.MockGetAddedAsset("mp/cooltable.csv"));
|
||||
REQUIRE(assetInfo != nullptr);
|
||||
auto loader = CreateStringTableLoader(memory, searchPath);
|
||||
auto result = loader->CreateAsset("mp/cooltable.csv", context);
|
||||
REQUIRE(result.HasBeenSuccessful());
|
||||
|
||||
const auto* assetInfo = reinterpret_cast<XAssetInfo<StringTable>*>(result.GetAssetInfo());
|
||||
const auto* stringTable = assetInfo->Asset();
|
||||
|
||||
REQUIRE(stringTable->name == "mp/cooltable.csv"s);
|
||||
REQUIRE(stringTable->columnCount == 3);
|
||||
REQUIRE(stringTable->rowCount == 2);
|
@ -1,7 +1,6 @@
|
||||
#include "Game/T5/AssetLoaders/AssetLoaderStringTable.h"
|
||||
#include "Game/T5/StringTable/LoaderStringTableT5.h"
|
||||
|
||||
#include "Game/T5/GameT5.h"
|
||||
#include "Mock/MockAssetLoadingManager.h"
|
||||
#include "Mock/MockSearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
|
||||
@ -21,17 +20,19 @@ namespace
|
||||
"lorem,ipsum");
|
||||
|
||||
Zone zone("MockZone", 0, IGame::GetGameById(GameId::T5));
|
||||
MockAssetLoadingManager assetLoadingManager(zone, searchPath);
|
||||
|
||||
AssetLoaderStringTable assetLoader;
|
||||
MemoryManager memory;
|
||||
AssetCreatorCollection creatorCollection(zone);
|
||||
IgnoredAssetLookup ignoredAssetLookup;
|
||||
AssetCreationContext context(&zone, &creatorCollection, &ignoredAssetLookup);
|
||||
|
||||
assetLoader.LoadFromRaw("mp/cooltable.csv", &searchPath, &memory, &assetLoadingManager, &zone);
|
||||
|
||||
auto* assetInfo = reinterpret_cast<XAssetInfo<StringTable>*>(assetLoadingManager.MockGetAddedAsset("mp/cooltable.csv"));
|
||||
REQUIRE(assetInfo != nullptr);
|
||||
auto loader = CreateStringTableLoader(memory, searchPath);
|
||||
auto result = loader->CreateAsset("mp/cooltable.csv", context);
|
||||
REQUIRE(result.HasBeenSuccessful());
|
||||
|
||||
const auto* assetInfo = reinterpret_cast<XAssetInfo<StringTable>*>(result.GetAssetInfo());
|
||||
const auto* stringTable = assetInfo->Asset();
|
||||
|
||||
REQUIRE(stringTable->name == "mp/cooltable.csv"s);
|
||||
REQUIRE(stringTable->columnCount == 3);
|
||||
REQUIRE(stringTable->rowCount == 2);
|
@ -1,7 +1,6 @@
|
||||
#include "Game/T6/AssetLoaders/AssetLoaderStringTable.h"
|
||||
#include "Game/T6/StringTable/LoaderStringTableT6.h"
|
||||
|
||||
#include "Game/T6/GameT6.h"
|
||||
#include "Mock/MockAssetLoadingManager.h"
|
||||
#include "Mock/MockSearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
|
||||
@ -21,17 +20,19 @@ namespace
|
||||
"lorem,ipsum");
|
||||
|
||||
Zone zone("MockZone", 0, IGame::GetGameById(GameId::T6));
|
||||
MockAssetLoadingManager assetLoadingManager(zone, searchPath);
|
||||
|
||||
AssetLoaderStringTable assetLoader;
|
||||
MemoryManager memory;
|
||||
AssetCreatorCollection creatorCollection(zone);
|
||||
IgnoredAssetLookup ignoredAssetLookup;
|
||||
AssetCreationContext context(&zone, &creatorCollection, &ignoredAssetLookup);
|
||||
|
||||
assetLoader.LoadFromRaw("mp/cooltable.csv", &searchPath, &memory, &assetLoadingManager, &zone);
|
||||
|
||||
auto* assetInfo = reinterpret_cast<XAssetInfo<StringTable>*>(assetLoadingManager.MockGetAddedAsset("mp/cooltable.csv"));
|
||||
REQUIRE(assetInfo != nullptr);
|
||||
auto loader = CreateStringTableLoader(memory, searchPath);
|
||||
auto result = loader->CreateAsset("mp/cooltable.csv", context);
|
||||
REQUIRE(result.HasBeenSuccessful());
|
||||
|
||||
const auto* assetInfo = reinterpret_cast<XAssetInfo<StringTable>*>(result.GetAssetInfo());
|
||||
const auto* stringTable = assetInfo->Asset();
|
||||
|
||||
REQUIRE(stringTable->name == "mp/cooltable.csv"s);
|
||||
REQUIRE(stringTable->columnCount == 3);
|
||||
REQUIRE(stringTable->rowCount == 2);
|
Reference in New Issue
Block a user