refactor(tests): reorganize tests directory to match engine structure
- Created tests/Core/Asset/ with tests for IResource, ResourceTypes, ResourceHandle, ResourceCache, ResourceDependencyGraph, ResourceGUID
- Created tests/Core/IO/ with tests for IResourceLoader, ResourcePath, ResourceFileSystem, FileArchive, ResourcePackage
- Reorganized tests/Resources/ into subdirectories: Texture/, Mesh/, Material/, Shader/, AudioClip/
- Added CMakeLists.txt for each new test subdirectory
- Fixed Material.h missing ResourceManager.h include (lost during engine refactor)
- tests/Core/CMakeLists.txt updated to include Asset/ and IO/ subdirectories
2026-03-24 15:44:13 +08:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
#include <XCEngine/Resources/Texture/TextureLoader.h>
|
|
|
|
|
#include <XCEngine/Core/Asset/ResourceTypes.h>
|
|
|
|
|
#include <XCEngine/Core/Containers/Array.h>
|
2026-03-26 16:22:24 +08:00
|
|
|
#include <filesystem>
|
refactor(tests): reorganize tests directory to match engine structure
- Created tests/Core/Asset/ with tests for IResource, ResourceTypes, ResourceHandle, ResourceCache, ResourceDependencyGraph, ResourceGUID
- Created tests/Core/IO/ with tests for IResourceLoader, ResourcePath, ResourceFileSystem, FileArchive, ResourcePackage
- Reorganized tests/Resources/ into subdirectories: Texture/, Mesh/, Material/, Shader/, AudioClip/
- Added CMakeLists.txt for each new test subdirectory
- Fixed Material.h missing ResourceManager.h include (lost during engine refactor)
- tests/Core/CMakeLists.txt updated to include Asset/ and IO/ subdirectories
2026-03-24 15:44:13 +08:00
|
|
|
|
|
|
|
|
using namespace XCEngine::Resources;
|
|
|
|
|
using namespace XCEngine::Containers;
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
2026-03-26 16:22:24 +08:00
|
|
|
std::string GetTextureFixturePath(const char* fileName) {
|
|
|
|
|
return (std::filesystem::path(XCENGINE_TEST_FIXTURES_DIR) / "Resources" / "Texture" / fileName).string();
|
|
|
|
|
}
|
|
|
|
|
|
refactor(tests): reorganize tests directory to match engine structure
- Created tests/Core/Asset/ with tests for IResource, ResourceTypes, ResourceHandle, ResourceCache, ResourceDependencyGraph, ResourceGUID
- Created tests/Core/IO/ with tests for IResourceLoader, ResourcePath, ResourceFileSystem, FileArchive, ResourcePackage
- Reorganized tests/Resources/ into subdirectories: Texture/, Mesh/, Material/, Shader/, AudioClip/
- Added CMakeLists.txt for each new test subdirectory
- Fixed Material.h missing ResourceManager.h include (lost during engine refactor)
- tests/Core/CMakeLists.txt updated to include Asset/ and IO/ subdirectories
2026-03-24 15:44:13 +08:00
|
|
|
TEST(TextureLoader, GetResourceType) {
|
|
|
|
|
TextureLoader loader;
|
|
|
|
|
EXPECT_EQ(loader.GetResourceType(), ResourceType::Texture);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(TextureLoader, GetSupportedExtensions) {
|
|
|
|
|
TextureLoader loader;
|
|
|
|
|
auto extensions = loader.GetSupportedExtensions();
|
|
|
|
|
EXPECT_GE(extensions.Size(), 1u);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(TextureLoader, CanLoad) {
|
|
|
|
|
TextureLoader loader;
|
|
|
|
|
EXPECT_TRUE(loader.CanLoad("test.png"));
|
|
|
|
|
EXPECT_TRUE(loader.CanLoad("test.jpg"));
|
|
|
|
|
EXPECT_TRUE(loader.CanLoad("test.tga"));
|
|
|
|
|
EXPECT_FALSE(loader.CanLoad("test.txt"));
|
|
|
|
|
EXPECT_FALSE(loader.CanLoad("test.obj"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(TextureLoader, LoadInvalidPath) {
|
|
|
|
|
TextureLoader loader;
|
|
|
|
|
LoadResult result = loader.Load("invalid/path/texture.png");
|
|
|
|
|
EXPECT_FALSE(result);
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-26 16:22:24 +08:00
|
|
|
TEST(TextureLoader, LoadValidBmpTexture) {
|
|
|
|
|
TextureLoader loader;
|
|
|
|
|
const std::string path = GetTextureFixturePath("checker.bmp");
|
|
|
|
|
|
|
|
|
|
LoadResult result = loader.Load(path.c_str());
|
|
|
|
|
ASSERT_TRUE(result);
|
|
|
|
|
ASSERT_NE(result.resource, nullptr);
|
|
|
|
|
|
|
|
|
|
auto* texture = static_cast<Texture*>(result.resource);
|
|
|
|
|
EXPECT_EQ(texture->GetWidth(), 2u);
|
|
|
|
|
EXPECT_EQ(texture->GetHeight(), 2u);
|
|
|
|
|
EXPECT_EQ(texture->GetTextureType(), TextureType::Texture2D);
|
|
|
|
|
EXPECT_EQ(texture->GetFormat(), TextureFormat::RGBA8_UNORM);
|
|
|
|
|
EXPECT_EQ(texture->GetPixelDataSize(), 16u);
|
|
|
|
|
|
|
|
|
|
delete texture;
|
|
|
|
|
}
|
|
|
|
|
|
refactor(tests): reorganize tests directory to match engine structure
- Created tests/Core/Asset/ with tests for IResource, ResourceTypes, ResourceHandle, ResourceCache, ResourceDependencyGraph, ResourceGUID
- Created tests/Core/IO/ with tests for IResourceLoader, ResourcePath, ResourceFileSystem, FileArchive, ResourcePackage
- Reorganized tests/Resources/ into subdirectories: Texture/, Mesh/, Material/, Shader/, AudioClip/
- Added CMakeLists.txt for each new test subdirectory
- Fixed Material.h missing ResourceManager.h include (lost during engine refactor)
- tests/Core/CMakeLists.txt updated to include Asset/ and IO/ subdirectories
2026-03-24 15:44:13 +08:00
|
|
|
} // namespace
|