#include "Game/IW3/Image/ImageLoaderExternalIW3.h" #include "Game/IW3/GameIW3.h" #include "OatTestPaths.h" #include "SearchPath/MockSearchPath.h" #include "Utils/MemoryManager.h" #include #include #include #include #include namespace fs = std::filesystem; using namespace IW3; using namespace std::literals; namespace { TEST_CASE("ImageLoaderExternalIW3: Can parse iwi", "[iw3][image]") { MockSearchPath searchPath; const auto filePath = oat::paths::GetTestDirectory() / "ObjLoadingTests/Game/IW3/Image/TestImage.iwi"; const auto fileSize = fs::file_size(filePath); std::ifstream file(filePath, std::ios::binary); REQUIRE(file.is_open()); const auto data = std::make_unique(fileSize); file.read(data.get(), fileSize); searchPath.AddFileData("images/testimage.iwi", std::string(data.get(), fileSize)); Zone zone("MockZone", 0, GameId::IW3, GamePlatform::PC); MemoryManager memory; AssetCreatorCollection creatorCollection(zone); IgnoredAssetLookup ignoredAssetLookup; AssetCreationContext context(zone, &creatorCollection, &ignoredAssetLookup); auto loader = image::CreateLoaderExternalIW3(memory, searchPath); auto result = loader->CreateAsset("testimage", context); REQUIRE(result.HasBeenSuccessful()); const auto* assetInfo = reinterpret_cast*>(result.GetAssetInfo()); const auto* image = assetInfo->Asset(); REQUIRE(image->name == "testimage"s); REQUIRE(image->width == 64); REQUIRE(image->height == 64); REQUIRE(image->depth == 1); } } // namespace