feat(editor): unify component registration pipeline

This commit is contained in:
2026-03-26 02:24:11 +08:00
parent 1ef3048da1
commit d018a4c82c
17 changed files with 268 additions and 116 deletions

View File

@@ -1,4 +1,6 @@
#include <gtest/gtest.h>
#include <XCEngine/Components/AudioListenerComponent.h>
#include <XCEngine/Components/AudioSourceComponent.h>
#include <XCEngine/Scene/Scene.h>
#include <XCEngine/Components/CameraComponent.h>
#include <XCEngine/Components/GameObject.h>
@@ -262,6 +264,30 @@ TEST_F(SceneTest, Save_ContainsGameObjectData) {
std::filesystem::remove(scenePath);
}
TEST_F(SceneTest, Save_And_Load_PreservesAudioComponents) {
GameObject* listenerObject = testScene->CreateGameObject("Listener");
GameObject* sourceObject = testScene->CreateGameObject("Source");
listenerObject->AddComponent<AudioListenerComponent>();
sourceObject->AddComponent<AudioSourceComponent>();
const std::filesystem::path scenePath = GetTempScenePath("test_scene_audio_components.xc");
testScene->Save(scenePath.string());
Scene loadedScene;
loadedScene.Load(scenePath.string());
GameObject* loadedListenerObject = loadedScene.Find("Listener");
GameObject* loadedSourceObject = loadedScene.Find("Source");
ASSERT_NE(loadedListenerObject, nullptr);
ASSERT_NE(loadedSourceObject, nullptr);
EXPECT_NE(loadedListenerObject->GetComponent<AudioListenerComponent>(), nullptr);
EXPECT_NE(loadedSourceObject->GetComponent<AudioSourceComponent>(), nullptr);
std::filesystem::remove(scenePath);
}
TEST_F(SceneTest, Save_And_Load_PreservesHierarchyAndComponents) {
testScene->SetName("Serialized Scene");
testScene->SetActive(false);