From 45fede0b7632e954e4944c83059f1b9bee2705d7 Mon Sep 17 00:00:00 2001 From: ssdfasd <2156608475@qq.com> Date: Mon, 27 Apr 2026 22:48:29 +0800 Subject: [PATCH] Restore editor app feature test boundary --- docs/plan/editor-core-refactor-plan.md | 57 +++++++++++++------ editor/AGENTS.md | 17 ++++++ tests/UI/Editor/unit/CMakeLists.txt | 54 ++++++++++++++++++ .../unit/test_editor_window_input_routing.cpp | 2 +- ...est_editor_window_tab_drag_drop_target.cpp | 22 +++---- tests/UI/Editor/unit/test_project_panel.cpp | 56 ++++++++---------- .../unit/test_scene_viewport_render_plan.cpp | 9 ++- .../unit/test_scene_viewport_runtime.cpp | 3 +- .../unit/test_viewport_object_id_picker.cpp | 19 ++++--- 9 files changed, 166 insertions(+), 73 deletions(-) diff --git a/docs/plan/editor-core-refactor-plan.md b/docs/plan/editor-core-refactor-plan.md index 0dccd00d..e6c3cb23 100644 --- a/docs/plan/editor-core-refactor-plan.md +++ b/docs/plan/editor-core-refactor-plan.md @@ -42,11 +42,9 @@ incomplete: explicit module roots instead of a private `editor/app` compatibility root. Concrete host code has converged under `editor/app/Host/Win32` and `editor/app/Host/D3D12`. -- Feature panels no longer use `Composition/EditorContext.h` directly, and - the first app-core test target now exercises `XCEditorCore` outside the - executable host. -- Some app-side feature/viewport tests are still stale and reference removed - headers, so they remain outside the app-core target until fixed. +- Feature panels no longer use `Composition/EditorContext.h` directly. The + app-core and app feature/viewport test targets now exercise `XCEditorCore` + outside the executable host. Completed boundary cuts: @@ -89,15 +87,21 @@ Completed boundary cuts: app module include roots. Its initial suite covers host command routing, project runtime, shell asset validation, project browser model, hierarchy scene binding, and inspector presentation. +- `editor_app_feature_tests` now links `XCEditorCore` directly and uses + explicit app module include roots. It restores project panel, scene viewport, + viewport render-plan, viewport object-id picker, and app input-routing tests + without widening the include surface. +- The old Win32 tab-drag-drop target test now covers the current reusable + `XCEditor/Docking/UIEditorDockHostTransfer.h` API through + `editor_windowing_phase1_tests`. The root issue is not the existence of a single executable target by itself. The root issue was that shared app contracts were stored inside concrete layer directories, and CMake exposed the whole `editor/app` include root through `XCEditorCore` usage requirements. The public include surface has now been narrowed, and internal source compatibility with the private app root has now -been removed. The first app-core test target now exercises the narrowed -surface. Remaining work is to restore additional stale app feature/viewport -tests without widening the include surface. +been removed. App-core and app feature/viewport tests now exercise the +narrowed surface without using the whole `editor/app` include root. ## Target Directory Shape @@ -290,14 +294,15 @@ Important: do not hide Win32/D3D12 in `XCEditorCore` just to make the first CMake edit easier. If a source file needs `windows.h`, it belongs in the host side until a neutral interface exists. -## Phase 3: Restore App-Core Tests +## Phase 3: Restore App-Core And App Feature Tests -Status: completed for the initial app-core suite. +Status: completed for the initial app-core and app feature/viewport suites. Created: ```cmake editor_app_core_tests +editor_app_feature_tests ``` This target links: @@ -316,14 +321,29 @@ The initial suite contains tests that should not need Win32/D3D12: - `test_hierarchy_scene_binding.cpp` - `test_inspector_presentation.cpp` -Remaining stale test references to fix or remove in later cuts: +The restored app feature/viewport suite contains: -- `Ports/SystemInteractionPort.h` -- `Rendering/Viewport/ViewportRenderTargetInternal.h` -- `app/Platform/Win32/WindowManager/TabDragDropTarget.h` +- `test_editor_window_input_routing.cpp` +- `test_project_panel.cpp` +- `test_scene_viewport_render_plan.cpp` +- `test_scene_viewport_runtime.cpp` +- `test_viewport_object_id_picker.cpp` -The test target is part of the architecture. If app core cannot be tested -without starting the executable host, the boundary is not real. +Completed stale-reference cleanup: + +- `Ports/SystemInteractionPort.h` test use was replaced with + `SystemInteractionService.h`. +- `Rendering/Viewport/ViewportRenderTargetInternal.h` test use was replaced + with current `ViewportRenderTargets` and `ViewportRenderTargetUtils` + headers. +- `app/Platform/Win32/WindowManager/TabDragDropTarget.h` was not restored. + The test now covers `ResolveUIEditorDockHostTabDropTarget` from the + reusable `XCEditor/Docking/UIEditorDockHostTransfer.h` API through + `editor_windowing_phase1_tests`. + +These test targets are part of the architecture. If app core and app +feature/viewport behavior cannot be tested without starting the executable +host, the boundary is not real. ## Phase 4: Service and Feature Boundary Cleanup @@ -451,6 +471,8 @@ cmake --build build --config Debug --target XCEditorCore cmake --build build --config Debug --target XCEditor cmake --build build --config Debug --target editor_ui_tests cmake --build build --config Debug --target editor_app_core_tests +cmake --build build --config Debug --target editor_app_feature_tests +cmake --build build --config Debug --target editor_windowing_phase1_tests ``` When app smoke is available: @@ -471,6 +493,7 @@ The refactor is complete when: - `Composition` no longer includes concrete feature panel headers. - `Services` no longer include `Features/**`. - Win32 and D3D12 communicate through neutral host/render contracts. -- app-core tests are wired into CMake and build without running the executable. +- app-core and app feature/viewport tests are wired into CMake and build + without running the executable. - `editor/AGENTS.md` describes the new target shape and directory rules. diff --git a/editor/AGENTS.md b/editor/AGENTS.md index f6997fa0..f342d0c1 100644 --- a/editor/AGENTS.md +++ b/editor/AGENTS.md @@ -22,6 +22,9 @@ change. utility-window descriptors, viewport services, and editor window core. - `editor_app_core_tests` links `XCEditorCore` directly and is the build gate that proves the product-core boundary outside the executable host. +- `editor_app_feature_tests` also links `XCEditorCore` directly. It restores + app feature and viewport coverage without reintroducing the old app-wide + include root or concrete Win32/D3D12 host dependencies. - `XCEditorCore` does not publish the whole `editor/app` root as a usage include directory. Its public app include surface is limited to shared contracts under `app/Core`, `app/Commands`, `app/State`, and @@ -316,6 +319,10 @@ inside pure shell/widget code. - App-facing unit tests follow the same rule. `editor_app_core_tests` uses explicit module include roots and must not regain the whole `editor/app` root to make stale tests compile. +- App feature/viewport unit tests follow the same rule through + `editor_app_feature_tests`. Fix stale includes to current contracts instead + of adding compatibility headers for removed `Ports/**`, old + `Rendering/Viewport/**Internal.h`, or legacy `app/Platform/**` paths. - `XCEditor` is the thin executable host that wires `XCEditorCore` to concrete Win32 and D3D12 implementations. Do not move concrete platform/render host code into `XCEditorCore` without first introducing neutral host contracts. @@ -336,6 +343,9 @@ inside pure shell/widget code. `cmake --build --config Debug --target XCEditorCore`. - Build app-core tests after product editor core or app-facing test changes: `cmake --build --config Debug --target editor_app_core_tests`. +- Build app feature/viewport tests after feature panel, scene viewport, + viewport service, or app-facing input-routing changes: + `cmake --build --config Debug --target editor_app_feature_tests`. - Build the app after startup, windowing, rendering, feature-panel, or resource changes: `cmake --build --config Debug --target XCEditor`. @@ -450,3 +460,10 @@ ownership rule. validation, project browser model, hierarchy scene binding, and inspector presentation without starting `XCEditor` or using the `editor/app` include root. +- Stale app feature/viewport unit tests now build as + `editor_app_feature_tests` against `XCEditorCore` with explicit module + roots. Project panel tests use `SystemInteractionService`, viewport tests use + current `ViewportRenderTargets`/`ViewportRenderTargetUtils`, object-id picker + tests use `Viewport/ViewportObjectIdPicker.h`, and the old Win32 tab-drop + test now covers `XCEditor/Docking/UIEditorDockHostTransfer.h` through + `editor_windowing_phase1_tests`. diff --git a/tests/UI/Editor/unit/CMakeLists.txt b/tests/UI/Editor/unit/CMakeLists.txt index bef5a2bd..b63763ec 100644 --- a/tests/UI/Editor/unit/CMakeLists.txt +++ b/tests/UI/Editor/unit/CMakeLists.txt @@ -73,6 +73,14 @@ set(EDITOR_APP_CORE_TEST_SOURCES test_inspector_presentation.cpp ) +set(EDITOR_APP_FEATURE_TEST_SOURCES + test_editor_window_input_routing.cpp + test_project_panel.cpp + test_scene_viewport_render_plan.cpp + test_scene_viewport_runtime.cpp + test_viewport_object_id_picker.cpp +) + add_executable(editor_ui_tests ${EDITOR_UI_UNIT_TEST_SOURCES}) target_link_libraries(editor_ui_tests @@ -152,9 +160,55 @@ if(TARGET XCEditorCore) gtest_discover_tests(editor_app_core_tests DISCOVERY_MODE POST_BUILD ) + + add_executable(editor_app_feature_tests + ${EDITOR_APP_FEATURE_TEST_SOURCES} + ) + + target_link_libraries(editor_app_feature_tests + PRIVATE + XCEditorCore + GTest::gtest_main + ) + + target_include_directories(editor_app_feature_tests + PRIVATE + ${XCENGINE_EDITOR_UI_TESTS_EDITOR_ROOT}/app/Commands + ${XCENGINE_EDITOR_UI_TESTS_EDITOR_ROOT}/app/Composition + ${XCENGINE_EDITOR_UI_TESTS_EDITOR_ROOT}/app/Core + ${XCENGINE_EDITOR_UI_TESTS_EDITOR_ROOT}/app/Features + ${XCENGINE_EDITOR_UI_TESTS_EDITOR_ROOT}/app/Host/Interfaces + ${XCENGINE_EDITOR_UI_TESTS_EDITOR_ROOT}/app/Rendering + ${XCENGINE_EDITOR_UI_TESTS_EDITOR_ROOT}/app/Scene + ${XCENGINE_EDITOR_UI_TESTS_EDITOR_ROOT}/app/Services + ${XCENGINE_EDITOR_UI_TESTS_EDITOR_ROOT}/app/State + ${XCENGINE_EDITOR_UI_TESTS_EDITOR_ROOT}/app/Support + ${XCENGINE_EDITOR_UI_TESTS_EDITOR_ROOT}/include + ${CMAKE_SOURCE_DIR}/engine/include + ) + + if(MSVC) + target_compile_options(editor_app_feature_tests PRIVATE /utf-8 /FS) + set_target_properties(editor_app_feature_tests PROPERTIES + MSVC_DEBUG_INFORMATION_FORMAT "$<$:Embedded>" + COMPILE_PDB_NAME "editor_app_feature_tests-compile" + COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/compile-pdb" + COMPILE_PDB_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_BINARY_DIR}/compile-pdb/Debug" + COMPILE_PDB_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_BINARY_DIR}/compile-pdb/Release" + COMPILE_PDB_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_BINARY_DIR}/compile-pdb/MinSizeRel" + COMPILE_PDB_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_BINARY_DIR}/compile-pdb/RelWithDebInfo" + ) + set_property(TARGET editor_app_feature_tests PROPERTY + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") + endif() + + gtest_discover_tests(editor_app_feature_tests + DISCOVERY_MODE POST_BUILD + ) endif() add_executable(editor_windowing_phase1_tests + test_editor_window_tab_drag_drop_target.cpp test_editor_window_synchronization_planner.cpp ) diff --git a/tests/UI/Editor/unit/test_editor_window_input_routing.cpp b/tests/UI/Editor/unit/test_editor_window_input_routing.cpp index 659b902c..70204593 100644 --- a/tests/UI/Editor/unit/test_editor_window_input_routing.cpp +++ b/tests/UI/Editor/unit/test_editor_window_input_routing.cpp @@ -2,7 +2,7 @@ #include #include -#include "app/Host/Interfaces/EditorWindowPointerCapture.h" +#include "EditorWindowPointerCapture.h" #include diff --git a/tests/UI/Editor/unit/test_editor_window_tab_drag_drop_target.cpp b/tests/UI/Editor/unit/test_editor_window_tab_drag_drop_target.cpp index 32cb2ab6..bcdb48bb 100644 --- a/tests/UI/Editor/unit/test_editor_window_tab_drag_drop_target.cpp +++ b/tests/UI/Editor/unit/test_editor_window_tab_drag_drop_target.cpp @@ -1,6 +1,6 @@ #include -#include "app/Platform/Win32/WindowManager/TabDragDropTarget.h" +#include #include @@ -8,8 +8,8 @@ namespace { using XCEngine::UI::UIPoint; using XCEngine::UI::UIRect; -using XCEngine::UI::Editor::App::Internal::EditorWindowTabDragDropTarget; -using XCEngine::UI::Editor::App::Internal::ResolveEditorWindowTabDragDropTarget; +using XCEngine::UI::Editor::ResolveUIEditorDockHostTabDropTarget; +using XCEngine::UI::Editor::UIEditorDockHostTabDropTarget; using XCEngine::UI::Editor::UIEditorWorkspaceDockPlacement; using XCEngine::UI::Editor::Widgets::UIEditorDockHostLayout; using XCEngine::UI::Editor::Widgets::UIEditorDockHostTabItemLayout; @@ -44,8 +44,8 @@ UIEditorDockHostLayout BuildDockLayout() { TEST(EditorWindowTabDragDropTargetTests, ReturnsInvalidTargetOutsideDockHostBounds) { const UIEditorDockHostLayout layout = BuildDockLayout(); - const EditorWindowTabDragDropTarget target = - ResolveEditorWindowTabDragDropTarget(layout, UIPoint(460.0f, 40.0f)); + const UIEditorDockHostTabDropTarget target = + ResolveUIEditorDockHostTabDropTarget(layout, UIPoint(460.0f, 40.0f)); EXPECT_FALSE(target.valid); EXPECT_TRUE(target.nodeId.empty()); @@ -56,8 +56,8 @@ TEST(EditorWindowTabDragDropTargetTests, ReturnsInvalidTargetOutsideDockHostBoun TEST(EditorWindowTabDragDropTargetTests, HeaderGapResolvesCenterPlacementAndAppendInsertionIndex) { const UIEditorDockHostLayout layout = BuildDockLayout(); - const EditorWindowTabDragDropTarget target = - ResolveEditorWindowTabDragDropTarget(layout, UIPoint(190.0f, 32.0f)); + const UIEditorDockHostTabDropTarget target = + ResolveUIEditorDockHostTabDropTarget(layout, UIPoint(190.0f, 32.0f)); ASSERT_TRUE(target.valid); EXPECT_EQ(target.nodeId, "stack-a"); @@ -69,15 +69,15 @@ TEST(EditorWindowTabDragDropTargetTests, BodyEdgesResolveDirectionalDockPlacemen const UIEditorDockHostLayout layout = BuildDockLayout(); EXPECT_EQ( - ResolveEditorWindowTabDragDropTarget(layout, UIPoint(24.0f, 120.0f)).placement, + ResolveUIEditorDockHostTabDropTarget(layout, UIPoint(24.0f, 120.0f)).placement, UIEditorWorkspaceDockPlacement::Left); EXPECT_EQ( - ResolveEditorWindowTabDragDropTarget(layout, UIPoint(314.0f, 120.0f)).placement, + ResolveUIEditorDockHostTabDropTarget(layout, UIPoint(314.0f, 120.0f)).placement, UIEditorWorkspaceDockPlacement::Right); EXPECT_EQ( - ResolveEditorWindowTabDragDropTarget(layout, UIPoint(120.0f, 48.0f)).placement, + ResolveUIEditorDockHostTabDropTarget(layout, UIPoint(120.0f, 48.0f)).placement, UIEditorWorkspaceDockPlacement::Top); EXPECT_EQ( - ResolveEditorWindowTabDragDropTarget(layout, UIPoint(120.0f, 214.0f)).placement, + ResolveUIEditorDockHostTabDropTarget(layout, UIPoint(120.0f, 214.0f)).placement, UIEditorWorkspaceDockPlacement::Bottom); } diff --git a/tests/UI/Editor/unit/test_project_panel.cpp b/tests/UI/Editor/unit/test_project_panel.cpp index 3b6540cf..ef812f2e 100644 --- a/tests/UI/Editor/unit/test_project_panel.cpp +++ b/tests/UI/Editor/unit/test_project_panel.cpp @@ -1,6 +1,6 @@ #include "Project/ProjectPanel.h" -#include "Ports/SystemInteractionPort.h" #include "Assets/BuiltInIcons.h" +#include "SystemInteractionService.h" #include "Panels/EditorPanelIds.h" @@ -14,7 +14,7 @@ namespace XCEngine::UI::Editor::App { namespace { -class FakeSystemInteractionHost final : public Ports::SystemInteractionPort { +class FakeSystemInteractionHost final : public System::SystemInteractionService { public: bool CopyTextToClipboard(std::string_view text) override { lastClipboardText = std::string(text); @@ -88,15 +88,18 @@ private: std::filesystem::path m_root = {}; }; -UIEditorPanelContentHostFrame MakeProjectHostFrame() { - UIEditorPanelContentHostFrame frame = {}; - UIEditorPanelContentHostPanelState panelState = {}; - panelState.panelId = std::string(kProjectPanelId); - panelState.kind = UIEditorPanelPresentationKind::HostedContent; - panelState.mounted = true; - panelState.bounds = ::XCEngine::UI::UIRect(0.0f, 0.0f, 640.0f, 360.0f); - frame.panelStates.push_back(std::move(panelState)); - return frame; +UIEditorHostedPanelDispatchEntry MakeProjectDispatchEntry() { + UIEditorHostedPanelDispatchEntry entry = {}; + entry.panelId = std::string(kProjectPanelId); + entry.presentationKind = UIEditorPanelPresentationKind::HostedContent; + entry.mounted = true; + entry.bounds = ::XCEngine::UI::UIRect(0.0f, 0.0f, 640.0f, 360.0f); + entry.allowInteraction = true; + entry.attached = true; + entry.visible = true; + entry.active = true; + entry.focused = true; + return entry; } ::XCEngine::UI::UIInputEvent MakePointerButtonDown( @@ -110,13 +113,6 @@ UIEditorPanelContentHostFrame MakeProjectHostFrame() { return event; } -PanelInputContext MakeFocusedPanelInputContext() { - PanelInputContext inputContext = {}; - inputContext.allowInteraction = true; - inputContext.hasInputFocus = true; - return inputContext; -} - TEST(ProjectPanelTests, CreateFolderCommandCreatesDirectoryAndQueuesRename) { TemporaryRepo repo = {}; @@ -171,15 +167,13 @@ TEST(ProjectPanelTests, BackgroundContextMenuCreateFolderUsesCurrentFolder) { ProjectPanel panel = {}; panel.Initialize(repo.Root()); - const UIEditorPanelContentHostFrame hostFrame = MakeProjectHostFrame(); + const UIEditorHostedPanelDispatchEntry dispatchEntry = MakeProjectDispatchEntry(); panel.Update( - hostFrame, - { MakePointerButtonDown(520.0f, 180.0f, ::XCEngine::UI::UIPointerButton::Right) }, - MakeFocusedPanelInputContext()); + dispatchEntry, + { MakePointerButtonDown(520.0f, 180.0f, ::XCEngine::UI::UIPointerButton::Right) }); panel.Update( - hostFrame, - { MakePointerButtonDown(520.0f, 194.0f, ::XCEngine::UI::UIPointerButton::Left) }, - MakeFocusedPanelInputContext()); + dispatchEntry, + { MakePointerButtonDown(520.0f, 194.0f, ::XCEngine::UI::UIPointerButton::Left) }); EXPECT_TRUE(std::filesystem::exists(repo.Root() / "project/Assets/New Folder")); const UIEditorHostCommandEvaluationResult renameEvaluation = @@ -200,15 +194,13 @@ TEST(ProjectPanelTests, FolderContextMenuCreateFolderUsesFolderTarget) { ProjectPanel panel = {}; panel.Initialize(repo.Root()); - const UIEditorPanelContentHostFrame hostFrame = MakeProjectHostFrame(); + const UIEditorHostedPanelDispatchEntry dispatchEntry = MakeProjectDispatchEntry(); panel.Update( - hostFrame, - { MakePointerButtonDown(300.0f, 80.0f, ::XCEngine::UI::UIPointerButton::Right) }, - MakeFocusedPanelInputContext()); + dispatchEntry, + { MakePointerButtonDown(300.0f, 80.0f, ::XCEngine::UI::UIPointerButton::Right) }); panel.Update( - hostFrame, - { MakePointerButtonDown(320.0f, 120.0f, ::XCEngine::UI::UIPointerButton::Left) }, - MakeFocusedPanelInputContext()); + dispatchEntry, + { MakePointerButtonDown(320.0f, 120.0f, ::XCEngine::UI::UIPointerButton::Left) }); EXPECT_TRUE(std::filesystem::exists(repo.Root() / "project/Assets/FolderA/New Folder")); } diff --git a/tests/UI/Editor/unit/test_scene_viewport_render_plan.cpp b/tests/UI/Editor/unit/test_scene_viewport_render_plan.cpp index 80c927da..5ed426bb 100644 --- a/tests/UI/Editor/unit/test_scene_viewport_render_plan.cpp +++ b/tests/UI/Editor/unit/test_scene_viewport_render_plan.cpp @@ -123,7 +123,8 @@ TEST(SceneViewportRenderPlanTests, BuildRenderPlanCreatesOutlinePassWhenSelectio EXPECT_FLOAT_EQ(style.outlineWidthPixels, 2.0f); EXPECT_FALSE(style.debugSelectionMask); return std::make_unique(); - }); + }, + nullptr); EXPECT_EQ(result.plan.postScenePasses.GetPassCount(), 2u); EXPECT_TRUE(result.plan.usesGridPass); @@ -153,7 +154,8 @@ TEST(SceneViewportRenderPlanTests, BuildRenderPlanWarnsWhenSelectionResourcesAre const std::vector&, const SceneViewportSelectionOutlineStyle&) { return std::make_unique(); - }); + }, + nullptr); EXPECT_EQ(result.plan.postScenePasses.GetPassCount(), 1u); EXPECT_TRUE(result.plan.usesGridPass); @@ -218,7 +220,8 @@ TEST(SceneViewportRenderPlanTests, ApplyRenderPlanAttachesPassesAndMarksRenderSt const std::vector&, const SceneViewportSelectionOutlineStyle&) { return std::make_unique(); - }); + }, + nullptr); XCEngine::Rendering::CameraFramePlan framePlan = {}; framePlan.request.surface = RenderSurface(800u, 600u); diff --git a/tests/UI/Editor/unit/test_scene_viewport_runtime.cpp b/tests/UI/Editor/unit/test_scene_viewport_runtime.cpp index bc827c48..3d2798a1 100644 --- a/tests/UI/Editor/unit/test_scene_viewport_runtime.cpp +++ b/tests/UI/Editor/unit/test_scene_viewport_runtime.cpp @@ -3,7 +3,8 @@ #include "Inspector/InspectorSubject.h" #include "Viewport/SceneViewportRenderService.h" #include "Viewport/ViewportHostService.h" -#include "Rendering/Viewport/ViewportRenderTargetInternal.h" +#include "Viewport/ViewportRenderTargets.h" +#include "Viewport/ViewportRenderTargetUtils.h" #include "EditorSelectionService.h" #include "Panels/EditorPanelIds.h" diff --git a/tests/UI/Editor/unit/test_viewport_object_id_picker.cpp b/tests/UI/Editor/unit/test_viewport_object_id_picker.cpp index 295a4dbc..d6539e13 100644 --- a/tests/UI/Editor/unit/test_viewport_object_id_picker.cpp +++ b/tests/UI/Editor/unit/test_viewport_object_id_picker.cpp @@ -1,4 +1,4 @@ -#include "app/Rendering/Viewport/ViewportObjectIdPicker.h" +#include "Viewport/ViewportObjectIdPicker.h" #include @@ -9,7 +9,7 @@ using XCEngine::Rendering::RenderObjectId; using XCEngine::UI::UIPoint; using XCEngine::UI::UISize; using XCEngine::UI::Editor::App::BuildViewportObjectIdReadbackRequest; -using XCEngine::UI::Editor::App::PickViewportObjectIdEntity; +using XCEngine::UI::Editor::App::PickViewportRenderObjectId; using XCEngine::UI::Editor::App::ResolveViewportObjectIdPixelCoordinate; using XCEngine::UI::Editor::App::ViewportObjectIdPickContext; using XCEngine::UI::Editor::App::ViewportObjectIdPickStatus; @@ -40,6 +40,7 @@ TEST(ViewportObjectIdPickerTest, BuildViewportObjectIdReadbackRequestMapsViewpor context.textureWidth = 1024u; context.textureHeight = 512u; context.hasValidFrame = true; + context.frameSerial = 1u; context.viewportSize = UISize(256.0f, 128.0f); context.viewportMousePosition = UIPoint(128.0f, 64.0f); @@ -49,7 +50,7 @@ TEST(ViewportObjectIdPickerTest, BuildViewportObjectIdReadbackRequestMapsViewpor EXPECT_EQ(request.pixelY, 256u); } -TEST(ViewportObjectIdPickerTest, PickViewportObjectIdEntityDecodesRuntimeObjectIdFromReadbackColor) { +TEST(ViewportObjectIdPickerTest, PickViewportRenderObjectIdDecodesRenderObjectIdFromReadbackColor) { ViewportObjectIdPickContext context = {}; context.commandQueue = reinterpret_cast(static_cast(0x1)); context.texture = reinterpret_cast(static_cast(0x2)); @@ -57,11 +58,12 @@ TEST(ViewportObjectIdPickerTest, PickViewportObjectIdEntityDecodesRuntimeObjectI context.textureWidth = 256u; context.textureHeight = 256u; context.hasValidFrame = true; + context.frameSerial = 1u; context.viewportSize = UISize(256.0f, 256.0f); context.viewportMousePosition = UIPoint(32.0f, 48.0f); constexpr RenderObjectId kExpectedObjectId = 0x00030201u; - const auto result = PickViewportObjectIdEntity( + const auto result = PickViewportRenderObjectId( context, [](const auto&, std::array& outRgba) { outRgba = { 0x01u, 0x02u, 0x03u, 0x00u }; @@ -70,10 +72,10 @@ TEST(ViewportObjectIdPickerTest, PickViewportObjectIdEntityDecodesRuntimeObjectI EXPECT_EQ(result.status, ViewportObjectIdPickStatus::Success); EXPECT_EQ(result.renderObjectId, kExpectedObjectId); - EXPECT_EQ(result.entityId, static_cast(kExpectedObjectId)); + EXPECT_EQ(result.resolvedEntityId, 0u); } -TEST(ViewportObjectIdPickerTest, PickViewportObjectIdEntityReportsReadbackFailure) { +TEST(ViewportObjectIdPickerTest, PickViewportRenderObjectIdReportsReadbackFailure) { ViewportObjectIdPickContext context = {}; context.commandQueue = reinterpret_cast(static_cast(0x1)); context.texture = reinterpret_cast(static_cast(0x2)); @@ -81,17 +83,18 @@ TEST(ViewportObjectIdPickerTest, PickViewportObjectIdEntityReportsReadbackFailur context.textureWidth = 64u; context.textureHeight = 64u; context.hasValidFrame = true; + context.frameSerial = 1u; context.viewportSize = UISize(64.0f, 64.0f); context.viewportMousePosition = UIPoint(4.0f, 8.0f); - const auto result = PickViewportObjectIdEntity( + const auto result = PickViewportRenderObjectId( context, [](const auto&, std::array&) { return false; }); EXPECT_EQ(result.status, ViewportObjectIdPickStatus::ReadbackFailed); - EXPECT_EQ(result.entityId, 0u); + EXPECT_EQ(result.resolvedEntityId, 0u); } } // namespace