mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-10 14:58:10 -05:00
chore: generalize default asset creators
This commit is contained in:
@ -1,8 +1,9 @@
|
||||
#include "Game/IW3/AssetLoaders/AssetLoaderStringTable.h"
|
||||
#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"
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
@ -21,16 +22,23 @@ namespace
|
||||
"lorem,ipsum");
|
||||
|
||||
Zone zone("MockZone", 0, IGame::GetGameById(GameId::IW3));
|
||||
MockAssetLoadingManager assetLoadingManager(zone, searchPath);
|
||||
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);
|
||||
|
||||
AssetLoaderStringTable assetLoader;
|
||||
MemoryManager memory;
|
||||
AssetCreatorCollection creatorCollection(zone);
|
||||
AssetLoaderStringTable assetLoader(memory, searchPath);
|
||||
IgnoredAssetLookup ignoredAssetLookup;
|
||||
|
||||
assetLoader.LoadFromRaw("mp/cooltable.csv", &searchPath, &memory, &assetLoadingManager, &zone);
|
||||
AssetCreationContext context(&zone, &creatorCollection, &ignoredAssetLookup);
|
||||
|
||||
auto* assetInfo = reinterpret_cast<XAssetInfo<StringTable>*>(assetLoadingManager.MockGetAddedAsset("mp/cooltable.csv"));
|
||||
REQUIRE(assetInfo != nullptr);
|
||||
const auto result = assetLoader.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);
|
Reference in New Issue
Block a user