66 lines
2.1 KiB
C++
66 lines
2.1 KiB
C++
#include <gtest/gtest.h>
|
|
|
|
#include "Utils/ProjectFileUtils.h"
|
|
|
|
#include <chrono>
|
|
#include <filesystem>
|
|
|
|
namespace XCEngine::Editor::ProjectFileUtils {
|
|
namespace {
|
|
|
|
class ProjectFileUtilsTest : public ::testing::Test {
|
|
protected:
|
|
void SetUp() override {
|
|
const auto stamp = std::chrono::steady_clock::now()
|
|
.time_since_epoch()
|
|
.count();
|
|
m_projectRoot =
|
|
std::filesystem::temp_directory_path() /
|
|
("xc_project_file_utils_" + std::to_string(stamp));
|
|
std::filesystem::create_directories(m_projectRoot);
|
|
}
|
|
|
|
void TearDown() override {
|
|
std::error_code ec;
|
|
std::filesystem::remove_all(m_projectRoot, ec);
|
|
}
|
|
|
|
std::filesystem::path m_projectRoot;
|
|
};
|
|
|
|
TEST_F(ProjectFileUtilsTest, SavesAndLoadsGraphicsSettingsRoundTrip) {
|
|
GraphicsSettingsDescriptor savedDescriptor;
|
|
savedDescriptor.renderPipelineAssetAssembly = "GameScripts";
|
|
savedDescriptor.renderPipelineAssetNamespace = "Gameplay";
|
|
savedDescriptor.renderPipelineAssetClass =
|
|
"ManagedForwardRenderPipelineProbeAsset";
|
|
|
|
ASSERT_TRUE(SaveProjectGraphicsSettings(
|
|
m_projectRoot.string(),
|
|
savedDescriptor));
|
|
EXPECT_TRUE(std::filesystem::exists(
|
|
GetGraphicsSettingsFilePath(m_projectRoot.string())));
|
|
|
|
const auto loadedDescriptor =
|
|
LoadProjectGraphicsSettings(m_projectRoot.string());
|
|
ASSERT_TRUE(loadedDescriptor.has_value());
|
|
EXPECT_EQ(
|
|
loadedDescriptor->renderPipelineAssetAssembly,
|
|
savedDescriptor.renderPipelineAssetAssembly);
|
|
EXPECT_EQ(
|
|
loadedDescriptor->renderPipelineAssetNamespace,
|
|
savedDescriptor.renderPipelineAssetNamespace);
|
|
EXPECT_EQ(
|
|
loadedDescriptor->renderPipelineAssetClass,
|
|
savedDescriptor.renderPipelineAssetClass);
|
|
EXPECT_TRUE(loadedDescriptor->HasRenderPipelineAsset());
|
|
}
|
|
|
|
TEST_F(ProjectFileUtilsTest, MissingGraphicsSettingsFileReturnsNullopt) {
|
|
EXPECT_FALSE(
|
|
LoadProjectGraphicsSettings(m_projectRoot.string()).has_value());
|
|
}
|
|
|
|
} // namespace
|
|
} // namespace XCEngine::Editor::ProjectFileUtils
|