feat(xcui): advance core and editor validation flow
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
add_subdirectory(input)
|
||||
add_subdirectory(layout)
|
||||
file(TO_CMAKE_PATH "${CMAKE_SOURCE_DIR}" XCENGINE_EDITOR_UI_TESTS_REPO_ROOT_PATH)
|
||||
|
||||
add_subdirectory(shared)
|
||||
add_subdirectory(workspace_shell_compose)
|
||||
add_subdirectory(state)
|
||||
|
||||
add_custom_target(editor_ui_integration_tests
|
||||
DEPENDS
|
||||
editor_ui_input_integration_tests
|
||||
editor_ui_layout_integration_tests
|
||||
editor_ui_workspace_shell_compose_validation
|
||||
editor_ui_panel_session_flow_validation
|
||||
)
|
||||
|
||||
@@ -1,19 +1,56 @@
|
||||
# Editor UI Integration Validation
|
||||
|
||||
This directory contains the manual XCUI validation system for editor-facing scenarios.
|
||||
This directory contains editor-only XCUI manual validation scenarios.
|
||||
|
||||
Structure:
|
||||
Current status:
|
||||
|
||||
- `shared/`: shared host, native renderer, screenshot helper, scenario registry
|
||||
- `input/`: input-related validation category
|
||||
- `layout/`: layout and shell-foundation validation category
|
||||
- Shared Core primitives remain in `tests/UI/Core/integration/`.
|
||||
- Only editor-only host, shell, widget, and domain-integrated validation should live here.
|
||||
- The first authored scenario is `workspace_shell_compose/`, focused on shell compose only:
|
||||
splitters, tab host, panel chrome placeholders, and hot reload.
|
||||
- The second scenario is `state/panel_session_flow/`, focused on editor command dispatch and panel session state only:
|
||||
`command dispatch + workspace controller + open / close / show / hide / activate`.
|
||||
|
||||
Rules:
|
||||
Layout:
|
||||
|
||||
- One scenario directory maps to one executable.
|
||||
- Do not accumulate unrelated checks into one monolithic app.
|
||||
- Shared infrastructure belongs in `shared/`, not duplicated per scenario.
|
||||
- Screenshots are stored per scenario inside that scenario's `captures/` folder.
|
||||
- `shared/`: editor validation scenario registry, Win32 host wrapper, shared theme
|
||||
- `workspace_shell_compose/`: first manual editor shell compose scenario
|
||||
- `state/panel_session_flow/`: custom host scenario for editor panel session state flow
|
||||
|
||||
Current scenario:
|
||||
|
||||
- Scenario id: `editor.shell.workspace_compose`
|
||||
- Build target: `editor_ui_workspace_shell_compose_validation`
|
||||
- Executable name: `XCUIEditorWorkspaceShellComposeValidation`
|
||||
- Validation scope: split/tab/panel shell compose only, no business panels
|
||||
|
||||
Additional scenario:
|
||||
|
||||
- Scenario id: `editor.state.panel_session_flow`
|
||||
- Build target: `editor_ui_panel_session_flow_validation`
|
||||
- Executable name: `XCUIEditorPanelSessionFlowValidation`
|
||||
- Validation scope: editor command dispatch and panel session state only, no business panels
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
cmake --build build --config Debug --target editor_ui_workspace_shell_compose_validation
|
||||
```
|
||||
|
||||
Then launch `XCUIEditorWorkspaceShellComposeValidation.exe` from the build output, or run it from your IDE by target name.
|
||||
|
||||
Controls:
|
||||
|
||||
- Drag authored splitters to verify live resize and min clamps.
|
||||
- Click `Document A/B/C` to verify only the selected tab placeholder is visible.
|
||||
- Press `F12` to write screenshots into `workspace_shell_compose/captures/`.
|
||||
- Authored `.xcui` and `.xctheme` changes hot reload while the host is running.
|
||||
|
||||
Panel session flow controls:
|
||||
|
||||
- Click `Hide Active / Show Doc A / Close Doc B / Open Doc B / Activate Details / Reset`.
|
||||
- Check `Last command` shows `Changed / NoOp / Rejected` consistently with the current state.
|
||||
- Press `F12` to write screenshots into `state/panel_session_flow/captures/`.
|
||||
|
||||
Build:
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
add_subdirectory(keyboard_focus)
|
||||
add_subdirectory(pointer_states)
|
||||
add_subdirectory(scroll_view)
|
||||
add_subdirectory(shortcut_scope)
|
||||
|
||||
add_custom_target(editor_ui_input_integration_tests
|
||||
DEPENDS
|
||||
editor_ui_input_keyboard_focus_validation
|
||||
editor_ui_input_pointer_states_validation
|
||||
editor_ui_input_scroll_view_validation
|
||||
editor_ui_input_shortcut_scope_validation
|
||||
)
|
||||
@@ -1,9 +0,0 @@
|
||||
# Editor Input Integration
|
||||
|
||||
这个分类只放 editor 输入相关的手工验证场景。
|
||||
|
||||
规则:
|
||||
|
||||
- 一个场景目录对应一个独立 exe
|
||||
- 共享宿主层只放在 `integration/shared/`
|
||||
- 不允许把多个无关检查点塞进同一个 exe
|
||||
@@ -1,35 +0,0 @@
|
||||
set(EDITOR_UI_INPUT_KEYBOARD_FOCUS_RESOURCES
|
||||
View.xcui
|
||||
${CMAKE_SOURCE_DIR}/tests/UI/Editor/integration/shared/themes/editor_validation.xctheme
|
||||
)
|
||||
|
||||
add_executable(editor_ui_input_keyboard_focus_validation WIN32
|
||||
main.cpp
|
||||
${EDITOR_UI_INPUT_KEYBOARD_FOCUS_RESOURCES}
|
||||
)
|
||||
|
||||
target_include_directories(editor_ui_input_keyboard_focus_validation PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/tests/UI/Editor/integration/shared/src
|
||||
${CMAKE_SOURCE_DIR}/engine/include
|
||||
)
|
||||
|
||||
target_compile_definitions(editor_ui_input_keyboard_focus_validation PRIVATE
|
||||
UNICODE
|
||||
_UNICODE
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
target_compile_options(editor_ui_input_keyboard_focus_validation PRIVATE /utf-8 /FS)
|
||||
set_property(TARGET editor_ui_input_keyboard_focus_validation PROPERTY
|
||||
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
||||
endif()
|
||||
|
||||
target_link_libraries(editor_ui_input_keyboard_focus_validation PRIVATE
|
||||
editor_ui_integration_host
|
||||
)
|
||||
|
||||
set_target_properties(editor_ui_input_keyboard_focus_validation PROPERTIES
|
||||
OUTPUT_NAME "XCUIEditorInputKeyboardFocusValidation"
|
||||
)
|
||||
|
||||
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES View.xcui)
|
||||
@@ -1,18 +0,0 @@
|
||||
# Keyboard Focus Validation
|
||||
|
||||
可执行 target:
|
||||
|
||||
- `editor_ui_input_keyboard_focus_validation`
|
||||
|
||||
运行:
|
||||
|
||||
```bash
|
||||
build\tests\UI\Editor\integration\input\keyboard_focus\Debug\XCUIEditorInputKeyboardFocusValidation.exe
|
||||
```
|
||||
|
||||
检查点:
|
||||
|
||||
1. 按 `Tab`,焦点依次切换三个按钮
|
||||
2. 按 `Shift+Tab`,焦点反向切换
|
||||
3. 按 `Enter` 或 `Space`,当前 `focus` 按钮进入 `active`
|
||||
4. 松开按键后,`active` 清空
|
||||
@@ -1,30 +0,0 @@
|
||||
<View
|
||||
name="EditorInputKeyboardFocus"
|
||||
theme="../../shared/themes/editor_validation.xctheme">
|
||||
<Column padding="24" gap="16">
|
||||
<Card
|
||||
title="Editor Validation | Keyboard Focus"
|
||||
subtitle="当前批次:Tab 焦点遍历 | Enter / Space 激活"
|
||||
tone="accent"
|
||||
height="90">
|
||||
<Column gap="8">
|
||||
<Text text="这是 editor 侧验证场景,不承载 runtime 游戏 UI。" />
|
||||
<Text text="这一轮只检查键盘焦点和激活,不混入复杂 editor 面板。" />
|
||||
</Column>
|
||||
</Card>
|
||||
|
||||
<Card title="Keyboard Focus" subtitle="tab focus active" height="214">
|
||||
<Column gap="12">
|
||||
<Text text="只检查下面三个可聚焦按钮和右下角状态叠层。" />
|
||||
<Row gap="12">
|
||||
<Button id="focus-first" text="First Focus" />
|
||||
<Button id="focus-second" text="Second Focus" />
|
||||
<Button id="focus-third" text="Third Focus" />
|
||||
</Row>
|
||||
<Text text="1. 按 Tab:focus 应依次切到 First / Second / Third。" />
|
||||
<Text text="2. 按 Shift+Tab:focus 应反向切换。" />
|
||||
<Text text="3. focus 停在任一按钮后,按 Enter 或 Space:active 应出现;松开后 active 清空。" />
|
||||
</Column>
|
||||
</Card>
|
||||
</Column>
|
||||
</View>
|
||||
@@ -1,8 +0,0 @@
|
||||
#include "Application.h"
|
||||
|
||||
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR, int nCmdShow) {
|
||||
return XCEngine::Tests::EditorUI::RunEditorUIValidationApp(
|
||||
hInstance,
|
||||
nCmdShow,
|
||||
"editor.input.keyboard_focus");
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
set(EDITOR_UI_INPUT_POINTER_STATES_RESOURCES
|
||||
View.xcui
|
||||
${CMAKE_SOURCE_DIR}/tests/UI/Editor/integration/shared/themes/editor_validation.xctheme
|
||||
)
|
||||
|
||||
add_executable(editor_ui_input_pointer_states_validation WIN32
|
||||
main.cpp
|
||||
${EDITOR_UI_INPUT_POINTER_STATES_RESOURCES}
|
||||
)
|
||||
|
||||
target_include_directories(editor_ui_input_pointer_states_validation PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/tests/UI/Editor/integration/shared/src
|
||||
${CMAKE_SOURCE_DIR}/engine/include
|
||||
)
|
||||
|
||||
target_compile_definitions(editor_ui_input_pointer_states_validation PRIVATE
|
||||
UNICODE
|
||||
_UNICODE
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
target_compile_options(editor_ui_input_pointer_states_validation PRIVATE /utf-8 /FS)
|
||||
set_property(TARGET editor_ui_input_pointer_states_validation PROPERTY
|
||||
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
||||
endif()
|
||||
|
||||
target_link_libraries(editor_ui_input_pointer_states_validation PRIVATE
|
||||
editor_ui_integration_host
|
||||
)
|
||||
|
||||
set_target_properties(editor_ui_input_pointer_states_validation PROPERTIES
|
||||
OUTPUT_NAME "XCUIEditorInputPointerStatesValidation"
|
||||
)
|
||||
|
||||
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES View.xcui)
|
||||
@@ -1,17 +0,0 @@
|
||||
# Pointer States Validation
|
||||
|
||||
可执行 target:
|
||||
|
||||
- `editor_ui_input_pointer_states_validation`
|
||||
|
||||
运行:
|
||||
|
||||
```bash
|
||||
build\tests\UI\Editor\integration\input\pointer_states\Debug\XCUIEditorInputPointerStatesValidation.exe
|
||||
```
|
||||
|
||||
检查点:
|
||||
|
||||
1. hover 左侧按钮,只应变化 `hover`
|
||||
2. 按住中间按钮,应看到 `focus`、`active`、`capture`
|
||||
3. 拖到右侧再松开,应看到 `capture` 清空,route 转到新的目标
|
||||
@@ -1,30 +0,0 @@
|
||||
<View
|
||||
name="EditorInputPointerStates"
|
||||
theme="../../shared/themes/editor_validation.xctheme">
|
||||
<Column padding="24" gap="16">
|
||||
<Card
|
||||
title="Editor Validation | Pointer States"
|
||||
subtitle="当前批次:鼠标 hover / focus / active / capture"
|
||||
tone="accent"
|
||||
height="90">
|
||||
<Column gap="8">
|
||||
<Text text="这是 editor 侧验证场景,不承载 runtime 游戏 UI。" />
|
||||
<Text text="这一轮只检查鼠标输入状态,不混入别的控件实验。" />
|
||||
</Column>
|
||||
</Card>
|
||||
|
||||
<Card title="Pointer Input" subtitle="hover focus active capture" height="196">
|
||||
<Column gap="12">
|
||||
<Text text="这一轮只需要检查下面这三个按钮。" />
|
||||
<Row gap="12">
|
||||
<Button id="input-hover" text="Hover / Focus" />
|
||||
<Button id="input-capture" text="Pointer Capture" capturePointer="true" />
|
||||
<Button id="input-route" text="Route Target" />
|
||||
</Row>
|
||||
<Text text="1. 鼠标移到左侧按钮:hover 应变化,focus 保持空。" />
|
||||
<Text text="2. 按住中间按钮:focus、active、capture 都应留在中间。" />
|
||||
<Text text="3. 拖到右侧再松开:hover 移到右侧,capture 清空,focus 仍留中间。" />
|
||||
</Column>
|
||||
</Card>
|
||||
</Column>
|
||||
</View>
|
||||
@@ -1,8 +0,0 @@
|
||||
#include "Application.h"
|
||||
|
||||
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR, int nCmdShow) {
|
||||
return XCEngine::Tests::EditorUI::RunEditorUIValidationApp(
|
||||
hInstance,
|
||||
nCmdShow,
|
||||
"editor.input.pointer_states");
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
set(EDITOR_UI_INPUT_SCROLL_VIEW_RESOURCES
|
||||
View.xcui
|
||||
${CMAKE_SOURCE_DIR}/tests/UI/Editor/integration/shared/themes/editor_validation.xctheme
|
||||
)
|
||||
|
||||
add_executable(editor_ui_input_scroll_view_validation WIN32
|
||||
main.cpp
|
||||
${EDITOR_UI_INPUT_SCROLL_VIEW_RESOURCES}
|
||||
)
|
||||
|
||||
target_include_directories(editor_ui_input_scroll_view_validation PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/tests/UI/Editor/integration/shared/src
|
||||
${CMAKE_SOURCE_DIR}/engine/include
|
||||
)
|
||||
|
||||
target_compile_definitions(editor_ui_input_scroll_view_validation PRIVATE
|
||||
UNICODE
|
||||
_UNICODE
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
target_compile_options(editor_ui_input_scroll_view_validation PRIVATE /utf-8 /FS)
|
||||
set_property(TARGET editor_ui_input_scroll_view_validation PROPERTY
|
||||
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
||||
endif()
|
||||
|
||||
target_link_libraries(editor_ui_input_scroll_view_validation PRIVATE
|
||||
editor_ui_integration_host
|
||||
)
|
||||
|
||||
set_target_properties(editor_ui_input_scroll_view_validation PROPERTIES
|
||||
OUTPUT_NAME "XCUIEditorInputScrollViewValidation"
|
||||
)
|
||||
|
||||
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES View.xcui)
|
||||
@@ -1,61 +0,0 @@
|
||||
<View
|
||||
name="EditorInputScrollView"
|
||||
theme="../../shared/themes/editor_validation.xctheme">
|
||||
<Column padding="20" gap="12">
|
||||
<Card
|
||||
title="功能:ScrollView 滚动 / clip / overflow"
|
||||
subtitle="只检查滚轮滚动、裁剪、overflow 与 target 路由,不检查业务面板"
|
||||
tone="accent"
|
||||
height="118">
|
||||
<Column gap="6">
|
||||
<Text text="1. 把鼠标放到下方日志区内滚动滚轮:内容应上下移动,右下角 Scroll target 应落到 validation-scroll。" />
|
||||
<Text text="2. 连续向下滚到末尾再继续滚:Offset 应被 clamp,Result 应显示 Scroll delta clamped to current offset。" />
|
||||
<Text text="3. 把鼠标移到日志区外再滚动:日志位置不应变化,Result 应显示 No hovered ScrollView。" />
|
||||
<Text text="4. 这个场景只验证 ScrollView 基础能力,不验证 editor 业务面板。" />
|
||||
</Column>
|
||||
</Card>
|
||||
|
||||
<Card
|
||||
title="Scrollable Log"
|
||||
subtitle="wheel inside this viewport"
|
||||
height="fill">
|
||||
<ScrollView id="validation-scroll" height="fill">
|
||||
<Column gap="8">
|
||||
<Text text="Line 01 - Scroll validation log" />
|
||||
<Text text="Line 02 - Scroll validation log" />
|
||||
<Text text="Line 03 - Scroll validation log" />
|
||||
<Text text="Line 04 - Scroll validation log" />
|
||||
<Text text="Line 05 - Scroll validation log" />
|
||||
<Text text="Line 06 - Scroll validation log" />
|
||||
<Text text="Line 07 - Scroll validation log" />
|
||||
<Text text="Line 08 - Scroll validation log" />
|
||||
<Text text="Line 09 - Scroll validation log" />
|
||||
<Text text="Line 10 - Scroll validation log" />
|
||||
<Text text="Line 11 - Scroll validation log" />
|
||||
<Text text="Line 12 - Scroll validation log" />
|
||||
<Text text="Line 13 - Scroll validation log" />
|
||||
<Text text="Line 14 - Scroll validation log" />
|
||||
<Text text="Line 15 - Scroll validation log" />
|
||||
<Text text="Line 16 - Scroll validation log" />
|
||||
<Text text="Line 17 - Scroll validation log" />
|
||||
<Text text="Line 18 - Scroll validation log" />
|
||||
<Text text="Line 19 - Scroll validation log" />
|
||||
<Text text="Line 20 - Scroll validation log" />
|
||||
<Text text="Line 21 - Scroll validation log" />
|
||||
<Text text="Line 22 - Scroll validation log" />
|
||||
<Text text="Line 23 - Scroll validation log" />
|
||||
<Text text="Line 24 - Scroll validation log" />
|
||||
</Column>
|
||||
</ScrollView>
|
||||
</Card>
|
||||
|
||||
<Card
|
||||
title="Outside Area"
|
||||
subtitle="wheel here should not move the log"
|
||||
height="84">
|
||||
<Column gap="8">
|
||||
<Text text="把鼠标移到这个区域再滚动,用来检查 No hovered ScrollView。" />
|
||||
</Column>
|
||||
</Card>
|
||||
</Column>
|
||||
</View>
|
||||
@@ -1,35 +0,0 @@
|
||||
set(EDITOR_UI_INPUT_SHORTCUT_SCOPE_RESOURCES
|
||||
View.xcui
|
||||
${CMAKE_SOURCE_DIR}/tests/UI/Editor/integration/shared/themes/editor_validation.xctheme
|
||||
)
|
||||
|
||||
add_executable(editor_ui_input_shortcut_scope_validation WIN32
|
||||
main.cpp
|
||||
${EDITOR_UI_INPUT_SHORTCUT_SCOPE_RESOURCES}
|
||||
)
|
||||
|
||||
target_include_directories(editor_ui_input_shortcut_scope_validation PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/tests/UI/Editor/integration/shared/src
|
||||
${CMAKE_SOURCE_DIR}/engine/include
|
||||
)
|
||||
|
||||
target_compile_definitions(editor_ui_input_shortcut_scope_validation PRIVATE
|
||||
UNICODE
|
||||
_UNICODE
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
target_compile_options(editor_ui_input_shortcut_scope_validation PRIVATE /utf-8 /FS)
|
||||
set_property(TARGET editor_ui_input_shortcut_scope_validation PROPERTY
|
||||
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
||||
endif()
|
||||
|
||||
target_link_libraries(editor_ui_input_shortcut_scope_validation PRIVATE
|
||||
editor_ui_integration_host
|
||||
)
|
||||
|
||||
set_target_properties(editor_ui_input_shortcut_scope_validation PROPERTIES
|
||||
OUTPUT_NAME "XCUIEditorInputShortcutScopeValidation"
|
||||
)
|
||||
|
||||
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES View.xcui)
|
||||
@@ -1,69 +0,0 @@
|
||||
<View
|
||||
name="EditorInputShortcutScope"
|
||||
theme="../../shared/themes/editor_validation.xctheme"
|
||||
shortcut="Ctrl+P"
|
||||
shortcutCommand="global.command"
|
||||
shortcutScope="global">
|
||||
<Column padding="20" gap="12">
|
||||
<Card
|
||||
title="Editor Validation | Shortcut Scope"
|
||||
subtitle="验证功能:Editor shortcut scope 路由与 text input suppression"
|
||||
tone="accent"
|
||||
height="100">
|
||||
<Column gap="6">
|
||||
<Text text="功能 1:验证 Ctrl+P 在 Widget / Panel / Window / Global 间按优先级命中 shortcut。" />
|
||||
<Text text="功能 2:验证 Text Input Proxy 会抑制 Ctrl+P 和 Tab 焦点遍历。" />
|
||||
</Column>
|
||||
</Card>
|
||||
|
||||
<Button id="global-focus" text="Global Focus" />
|
||||
|
||||
<Card
|
||||
id="window-shell"
|
||||
title="Window Scope"
|
||||
subtitle="Ctrl+P -> window.command"
|
||||
shortcutScopeRoot="window"
|
||||
shortcut="Ctrl+P"
|
||||
shortcutCommand="window.command"
|
||||
shortcutScope="window">
|
||||
<Column gap="10">
|
||||
<Text text="先检查优先级:widget > panel > window > global。" />
|
||||
<Button id="window-focus" text="Window Focus" />
|
||||
|
||||
<Card
|
||||
id="panel-shell"
|
||||
title="Panel Scope"
|
||||
subtitle="Ctrl+P -> panel.command"
|
||||
shortcutScopeRoot="panel"
|
||||
shortcut="Ctrl+P"
|
||||
shortcutCommand="panel.command"
|
||||
shortcutScope="panel">
|
||||
<Column gap="10">
|
||||
<Button id="panel-focus" text="Panel Focus" />
|
||||
|
||||
<Card
|
||||
id="widget-shell"
|
||||
title="Widget Scope"
|
||||
subtitle="Ctrl+P -> widget.command"
|
||||
tone="accent-alt"
|
||||
shortcutScopeRoot="widget"
|
||||
shortcut="Ctrl+P"
|
||||
shortcutCommand="widget.command"
|
||||
shortcutScope="widget">
|
||||
<Column gap="10">
|
||||
<Button id="widget-focus" text="Widget Focus" />
|
||||
</Column>
|
||||
</Card>
|
||||
|
||||
<Button id="text-input" text="Text Input Proxy" textInput="true" />
|
||||
<Text text="操作指引:" />
|
||||
<Text text="1. 依次点 Widget / Panel / Window / Global Focus,再按 Ctrl+P。" />
|
||||
<Text text="2. 右下角 Recent shortcut 应分别显示 widget / panel / window / global,且状态为 handled。" />
|
||||
<Text text="3. 点 Text Input Proxy 再按 Ctrl+P,Recent shortcut 状态应变为 suppressed。" />
|
||||
<Text text="4. 保持 Text Input Proxy focus 再按 Tab,Result 应显示 focus traversal suppressed,focus 不应跳走。" />
|
||||
</Column>
|
||||
</Card>
|
||||
</Column>
|
||||
</Card>
|
||||
</Column>
|
||||
</View>
|
||||
@@ -1,8 +0,0 @@
|
||||
#include "Application.h"
|
||||
|
||||
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR, int nCmdShow) {
|
||||
return XCEngine::Tests::EditorUI::RunEditorUIValidationApp(
|
||||
hInstance,
|
||||
nCmdShow,
|
||||
"editor.input.shortcut_scope");
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
add_subdirectory(splitter_resize)
|
||||
add_subdirectory(tab_strip_selection)
|
||||
add_subdirectory(workspace_compose)
|
||||
|
||||
add_custom_target(editor_ui_layout_integration_tests
|
||||
DEPENDS
|
||||
editor_ui_layout_splitter_resize_validation
|
||||
editor_ui_layout_tab_strip_selection_validation
|
||||
editor_ui_layout_workspace_compose_validation
|
||||
)
|
||||
@@ -1,35 +0,0 @@
|
||||
set(EDITOR_UI_LAYOUT_SPLITTER_RESIZE_RESOURCES
|
||||
View.xcui
|
||||
${CMAKE_SOURCE_DIR}/tests/UI/Editor/integration/shared/themes/editor_validation.xctheme
|
||||
)
|
||||
|
||||
add_executable(editor_ui_layout_splitter_resize_validation WIN32
|
||||
main.cpp
|
||||
${EDITOR_UI_LAYOUT_SPLITTER_RESIZE_RESOURCES}
|
||||
)
|
||||
|
||||
target_include_directories(editor_ui_layout_splitter_resize_validation PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/tests/UI/Editor/integration/shared/src
|
||||
${CMAKE_SOURCE_DIR}/engine/include
|
||||
)
|
||||
|
||||
target_compile_definitions(editor_ui_layout_splitter_resize_validation PRIVATE
|
||||
UNICODE
|
||||
_UNICODE
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
target_compile_options(editor_ui_layout_splitter_resize_validation PRIVATE /utf-8 /FS)
|
||||
set_property(TARGET editor_ui_layout_splitter_resize_validation PROPERTY
|
||||
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
||||
endif()
|
||||
|
||||
target_link_libraries(editor_ui_layout_splitter_resize_validation PRIVATE
|
||||
editor_ui_integration_host
|
||||
)
|
||||
|
||||
set_target_properties(editor_ui_layout_splitter_resize_validation PROPERTIES
|
||||
OUTPUT_NAME "XCUIEditorLayoutSplitterResizeValidation"
|
||||
)
|
||||
|
||||
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES View.xcui)
|
||||
@@ -1,39 +0,0 @@
|
||||
<View
|
||||
name="EditorSplitterResizeValidation"
|
||||
theme="../../shared/themes/editor_validation.xctheme">
|
||||
<Column width="fill" height="fill" padding="20" gap="12">
|
||||
<Card
|
||||
title="功能:Splitter / pane resize"
|
||||
subtitle="这一轮只检查分割条拖拽和最小尺寸 clamp"
|
||||
tone="accent"
|
||||
height="128">
|
||||
<Column gap="6">
|
||||
<Text text="1. 鼠标移到中间 divider:右下角 Hover 应落到 workspace-splitter。" />
|
||||
<Text text="2. 按住左键拖拽:左右 pane 宽度应实时变化,Result 应出现 Splitter drag started / Splitter resized。" />
|
||||
<Text text="3. 向左右极限拖拽:布局应被 primaryMin / secondaryMin clamp 住,不应穿透。" />
|
||||
<Text text="4. 松开左键:Result 应显示 Splitter drag finished。" />
|
||||
</Column>
|
||||
</Card>
|
||||
|
||||
<Splitter
|
||||
id="workspace-splitter"
|
||||
axis="horizontal"
|
||||
splitRatio="0.38"
|
||||
splitterSize="10"
|
||||
splitterHitSize="18"
|
||||
primaryMin="180"
|
||||
secondaryMin="220"
|
||||
height="fill">
|
||||
<Card id="left-pane" title="Left Empty Pane" subtitle="min 180" height="fill">
|
||||
<Column gap="8">
|
||||
<Text text="这里只保留空 pane,用来观察 resize。" />
|
||||
</Column>
|
||||
</Card>
|
||||
<Card id="right-pane" title="Right Empty Pane" subtitle="min 220" height="fill">
|
||||
<Column gap="8">
|
||||
<Text text="拖拽过程中不应出现翻转、穿透或抖动。" />
|
||||
</Column>
|
||||
</Card>
|
||||
</Splitter>
|
||||
</Column>
|
||||
</View>
|
||||
@@ -1,8 +0,0 @@
|
||||
#include "Application.h"
|
||||
|
||||
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR, int nCmdShow) {
|
||||
return XCEngine::Tests::EditorUI::RunEditorUIValidationApp(
|
||||
hInstance,
|
||||
nCmdShow,
|
||||
"editor.layout.splitter_resize");
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
set(EDITOR_UI_LAYOUT_TAB_STRIP_SELECTION_RESOURCES
|
||||
View.xcui
|
||||
${CMAKE_SOURCE_DIR}/tests/UI/Editor/integration/shared/themes/editor_validation.xctheme
|
||||
)
|
||||
|
||||
add_executable(editor_ui_layout_tab_strip_selection_validation WIN32
|
||||
main.cpp
|
||||
${EDITOR_UI_LAYOUT_TAB_STRIP_SELECTION_RESOURCES}
|
||||
)
|
||||
|
||||
target_include_directories(editor_ui_layout_tab_strip_selection_validation PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/tests/UI/Editor/integration/shared/src
|
||||
${CMAKE_SOURCE_DIR}/engine/include
|
||||
)
|
||||
|
||||
target_compile_definitions(editor_ui_layout_tab_strip_selection_validation PRIVATE
|
||||
UNICODE
|
||||
_UNICODE
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
target_compile_options(editor_ui_layout_tab_strip_selection_validation PRIVATE /utf-8 /FS)
|
||||
set_property(TARGET editor_ui_layout_tab_strip_selection_validation PROPERTY
|
||||
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
||||
endif()
|
||||
|
||||
target_link_libraries(editor_ui_layout_tab_strip_selection_validation PRIVATE
|
||||
editor_ui_integration_host
|
||||
)
|
||||
|
||||
set_target_properties(editor_ui_layout_tab_strip_selection_validation PROPERTIES
|
||||
OUTPUT_NAME "XCUIEditorLayoutTabStripSelectionValidation"
|
||||
)
|
||||
|
||||
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES View.xcui)
|
||||
@@ -1,46 +0,0 @@
|
||||
<View
|
||||
name="EditorTabStripSelectionValidation"
|
||||
theme="../../shared/themes/editor_validation.xctheme">
|
||||
<Column width="fill" height="fill" padding="20" gap="12">
|
||||
<Card
|
||||
title="功能:TabStrip 选择切换"
|
||||
subtitle="只验证 tab 头部点击、键盘导航,以及只渲染 selected tab 内容"
|
||||
tone="accent"
|
||||
height="156">
|
||||
<Column gap="6">
|
||||
<Text text="1. 点击 Scene / Console / Inspector 任一 tab:下方内容区应立即切换,旧内容不应继续显示。" />
|
||||
<Text text="2. 先点击一个 tab 让它获得 focus,再按 Left / Right / Home / End:selected tab 应变化。" />
|
||||
<Text text="3. 右下角 Result 正常应显示 Tab selected 或 Tab navigated;Focused 应落在当前 tab。" />
|
||||
<Text text="4. 这个场景只检查 TabStrip 基础能力,不检查 editor 业务面板。" />
|
||||
</Column>
|
||||
</Card>
|
||||
|
||||
<TabStrip
|
||||
id="editor-workspace-tabs"
|
||||
tabHeaderHeight="34"
|
||||
tabMinWidth="96"
|
||||
height="fill">
|
||||
<Tab id="tab-scene" label="Scene" selected="true">
|
||||
<Card title="Scene Tab Content" subtitle="selected = Scene" height="fill">
|
||||
<Column gap="8">
|
||||
<Text text="这里应该只显示 Scene 的内容占位。" />
|
||||
</Column>
|
||||
</Card>
|
||||
</Tab>
|
||||
<Tab id="tab-console" label="Console">
|
||||
<Card title="Console Tab Content" subtitle="selected = Console" height="fill">
|
||||
<Column gap="8">
|
||||
<Text text="切换到 Console 后,Scene 内容应消失。" />
|
||||
</Column>
|
||||
</Card>
|
||||
</Tab>
|
||||
<Tab id="tab-inspector" label="Inspector">
|
||||
<Card title="Inspector Tab Content" subtitle="selected = Inspector" height="fill">
|
||||
<Column gap="8">
|
||||
<Text text="按 Home / End 时,也应只保留当前 selected 内容。" />
|
||||
</Column>
|
||||
</Card>
|
||||
</Tab>
|
||||
</TabStrip>
|
||||
</Column>
|
||||
</View>
|
||||
@@ -1,8 +0,0 @@
|
||||
#include "Application.h"
|
||||
|
||||
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR, int nCmdShow) {
|
||||
return XCEngine::Tests::EditorUI::RunEditorUIValidationApp(
|
||||
hInstance,
|
||||
nCmdShow,
|
||||
"editor.layout.tab_strip_selection");
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
set(EDITOR_UI_LAYOUT_WORKSPACE_COMPOSE_RESOURCES
|
||||
View.xcui
|
||||
${CMAKE_SOURCE_DIR}/tests/UI/Editor/integration/shared/themes/editor_validation.xctheme
|
||||
)
|
||||
|
||||
add_executable(editor_ui_layout_workspace_compose_validation WIN32
|
||||
main.cpp
|
||||
${EDITOR_UI_LAYOUT_WORKSPACE_COMPOSE_RESOURCES}
|
||||
)
|
||||
|
||||
target_include_directories(editor_ui_layout_workspace_compose_validation PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/tests/UI/Editor/integration/shared/src
|
||||
${CMAKE_SOURCE_DIR}/engine/include
|
||||
)
|
||||
|
||||
target_compile_definitions(editor_ui_layout_workspace_compose_validation PRIVATE
|
||||
UNICODE
|
||||
_UNICODE
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
target_compile_options(editor_ui_layout_workspace_compose_validation PRIVATE /utf-8 /FS)
|
||||
set_property(TARGET editor_ui_layout_workspace_compose_validation PROPERTY
|
||||
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
||||
endif()
|
||||
|
||||
target_link_libraries(editor_ui_layout_workspace_compose_validation PRIVATE
|
||||
editor_ui_integration_host
|
||||
)
|
||||
|
||||
set_target_properties(editor_ui_layout_workspace_compose_validation PROPERTIES
|
||||
OUTPUT_NAME "XCUIEditorLayoutWorkspaceComposeValidation"
|
||||
)
|
||||
|
||||
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES View.xcui)
|
||||
@@ -1,94 +0,0 @@
|
||||
<View
|
||||
name="EditorWorkspaceComposeValidation"
|
||||
theme="../../shared/themes/editor_validation.xctheme">
|
||||
<Column width="fill" height="fill" padding="20" gap="12">
|
||||
<Card
|
||||
title="功能:Workspace compose"
|
||||
subtitle="只检查 editor 工作区的 split + tab + placeholder 组合,不检查任何业务面板"
|
||||
tone="accent"
|
||||
height="156">
|
||||
<Column gap="6">
|
||||
<Text text="1. 先看布局:左、中、右、下四个区域应边界清晰,没有重叠、穿透或错位。" />
|
||||
<Text text="2. 拖拽 workspace-left-right 和 workspace-top-bottom:各区域尺寸应实时变化,并被最小尺寸 clamp 住。" />
|
||||
<Text text="3. 点击中间的 Document A / B / C:只应显示当前 selected tab 的 placeholder 内容。" />
|
||||
<Text text="4. 这个场景只验证工作区组合基础,不代表 Hierarchy / Inspector / Console 已开始实现。" />
|
||||
</Column>
|
||||
</Card>
|
||||
|
||||
<Splitter
|
||||
id="workspace-top-bottom"
|
||||
axis="vertical"
|
||||
splitRatio="0.76"
|
||||
splitterSize="10"
|
||||
splitterHitSize="18"
|
||||
primaryMin="320"
|
||||
secondaryMin="120"
|
||||
height="fill">
|
||||
<Splitter
|
||||
id="workspace-left-right"
|
||||
axis="horizontal"
|
||||
splitRatio="0.24"
|
||||
splitterSize="10"
|
||||
splitterHitSize="18"
|
||||
primaryMin="160"
|
||||
secondaryMin="420"
|
||||
height="fill">
|
||||
<Card id="workspace-left-slot" title="Navigation Slot" subtitle="placeholder panel host" height="fill">
|
||||
<Column gap="8">
|
||||
<Text text="这里是左侧 placeholder slot,只检查 pane compose。" />
|
||||
</Column>
|
||||
</Card>
|
||||
|
||||
<Splitter
|
||||
id="workspace-center-right"
|
||||
axis="horizontal"
|
||||
splitRatio="0.70"
|
||||
splitterSize="10"
|
||||
splitterHitSize="18"
|
||||
primaryMin="260"
|
||||
secondaryMin="180"
|
||||
height="fill">
|
||||
<TabStrip
|
||||
id="workspace-document-tabs"
|
||||
tabHeaderHeight="34"
|
||||
tabMinWidth="112"
|
||||
height="fill">
|
||||
<Tab id="tab-document-a" label="Document A" selected="true">
|
||||
<Card title="Primary Document Slot" subtitle="selected = Document A" height="fill">
|
||||
<Column gap="8">
|
||||
<Text text="这里应只显示 Document A 的 placeholder 内容。" />
|
||||
</Column>
|
||||
</Card>
|
||||
</Tab>
|
||||
<Tab id="tab-document-b" label="Document B">
|
||||
<Card title="Secondary Document Slot" subtitle="selected = Document B" height="fill">
|
||||
<Column gap="8">
|
||||
<Text text="切换到 Document B 后,A 的内容应消失。" />
|
||||
</Column>
|
||||
</Card>
|
||||
</Tab>
|
||||
<Tab id="tab-document-c" label="Document C">
|
||||
<Card title="Tertiary Document Slot" subtitle="selected = Document C" height="fill">
|
||||
<Column gap="8">
|
||||
<Text text="这里只是第三个 placeholder,不代表真实面板业务。" />
|
||||
</Column>
|
||||
</Card>
|
||||
</Tab>
|
||||
</TabStrip>
|
||||
|
||||
<Card id="workspace-right-slot" title="Details Slot" subtitle="placeholder panel host" height="fill">
|
||||
<Column gap="8">
|
||||
<Text text="这里是右侧 placeholder slot,只检查嵌套 split 稳定性。" />
|
||||
</Column>
|
||||
</Card>
|
||||
</Splitter>
|
||||
</Splitter>
|
||||
|
||||
<Card id="workspace-bottom-slot" title="Output Slot" subtitle="placeholder panel host" height="fill">
|
||||
<Column gap="8">
|
||||
<Text text="这里是底部 placeholder slot,用来检查上下 split compose。" />
|
||||
</Column>
|
||||
</Card>
|
||||
</Splitter>
|
||||
</Column>
|
||||
</View>
|
||||
@@ -1,8 +0,0 @@
|
||||
#include "Application.h"
|
||||
|
||||
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR, int nCmdShow) {
|
||||
return XCEngine::Tests::EditorUI::RunEditorUIValidationApp(
|
||||
hInstance,
|
||||
nCmdShow,
|
||||
"editor.layout.workspace_compose");
|
||||
}
|
||||
@@ -7,7 +7,6 @@ add_library(editor_ui_validation_registry STATIC
|
||||
target_include_directories(editor_ui_validation_registry
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
${CMAKE_SOURCE_DIR}/engine/include
|
||||
)
|
||||
|
||||
target_compile_definitions(editor_ui_validation_registry
|
||||
@@ -21,11 +20,6 @@ if(MSVC)
|
||||
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
||||
endif()
|
||||
|
||||
target_link_libraries(editor_ui_validation_registry
|
||||
PUBLIC
|
||||
XCEngine
|
||||
)
|
||||
|
||||
add_library(editor_ui_integration_host STATIC
|
||||
src/Application.cpp
|
||||
)
|
||||
@@ -33,8 +27,8 @@ add_library(editor_ui_integration_host STATIC
|
||||
target_include_directories(editor_ui_integration_host
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
${CMAKE_SOURCE_DIR}/new_editor/include
|
||||
${CMAKE_SOURCE_DIR}/engine/include
|
||||
${CMAKE_SOURCE_DIR}/new_editor/include
|
||||
)
|
||||
|
||||
target_compile_definitions(editor_ui_integration_host
|
||||
@@ -54,4 +48,5 @@ target_link_libraries(editor_ui_integration_host
|
||||
PUBLIC
|
||||
editor_ui_validation_registry
|
||||
XCNewEditorHost
|
||||
XCEngine
|
||||
)
|
||||
|
||||
@@ -11,14 +11,11 @@
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#ifndef XCENGINE_EDITOR_UI_TESTS_REPO_ROOT
|
||||
#define XCENGINE_EDITOR_UI_TESTS_REPO_ROOT "."
|
||||
#endif
|
||||
|
||||
namespace XCEngine::Tests::EditorUI {
|
||||
|
||||
namespace {
|
||||
|
||||
using ::XCEngine::Input::KeyCode;
|
||||
using ::XCEngine::UI::UIColor;
|
||||
using ::XCEngine::UI::UIDrawData;
|
||||
using ::XCEngine::UI::UIDrawList;
|
||||
@@ -28,10 +25,9 @@ using ::XCEngine::UI::UIPoint;
|
||||
using ::XCEngine::UI::UIPointerButton;
|
||||
using ::XCEngine::UI::UIRect;
|
||||
using ::XCEngine::UI::Runtime::UIScreenFrameInput;
|
||||
using ::XCEngine::Input::KeyCode;
|
||||
|
||||
constexpr const wchar_t* kWindowClassName = L"XCUIEditorValidationHost";
|
||||
constexpr const wchar_t* kWindowTitle = L"XCUI Editor Validation";
|
||||
constexpr const wchar_t* kWindowTitle = L"XCUI Editor 验证";
|
||||
constexpr auto kReloadPollInterval = std::chrono::milliseconds(150);
|
||||
|
||||
constexpr UIColor kOverlayBgColor(0.10f, 0.10f, 0.10f, 0.95f);
|
||||
@@ -45,14 +41,6 @@ Application* GetApplicationFromWindow(HWND hwnd) {
|
||||
return reinterpret_cast<Application*>(GetWindowLongPtrW(hwnd, GWLP_USERDATA));
|
||||
}
|
||||
|
||||
std::filesystem::path GetRepoRootPath() {
|
||||
std::string root = XCENGINE_EDITOR_UI_TESTS_REPO_ROOT;
|
||||
if (root.size() >= 2u && root.front() == '"' && root.back() == '"') {
|
||||
root = root.substr(1u, root.size() - 2u);
|
||||
}
|
||||
return std::filesystem::path(root).lexically_normal();
|
||||
}
|
||||
|
||||
std::string TruncateText(const std::string& text, std::size_t maxLength) {
|
||||
if (text.size() <= maxLength) {
|
||||
return text;
|
||||
@@ -90,14 +78,6 @@ std::string FormatPoint(const UIPoint& point) {
|
||||
return "(" + FormatFloat(point.x) + ", " + FormatFloat(point.y) + ")";
|
||||
}
|
||||
|
||||
std::string FormatRect(const UIRect& rect) {
|
||||
return "(" + FormatFloat(rect.x) +
|
||||
", " + FormatFloat(rect.y) +
|
||||
", " + FormatFloat(rect.width) +
|
||||
", " + FormatFloat(rect.height) +
|
||||
")";
|
||||
}
|
||||
|
||||
std::int32_t MapVirtualKeyToUIKeyCode(WPARAM wParam) {
|
||||
switch (wParam) {
|
||||
case 'A': return static_cast<std::int32_t>(KeyCode::A);
|
||||
@@ -242,14 +222,14 @@ bool Application::Initialize(HINSTANCE hInstance, int nCmdShow) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_startTime = std::chrono::steady_clock::now();
|
||||
m_lastFrameTime = m_startTime;
|
||||
m_lastFrameTime = std::chrono::steady_clock::now();
|
||||
const EditorValidationScenario* initialScenario = m_requestedScenarioId.empty()
|
||||
? &GetDefaultEditorValidationScenario()
|
||||
: FindEditorValidationScenario(m_requestedScenarioId);
|
||||
if (initialScenario == nullptr) {
|
||||
initialScenario = &GetDefaultEditorValidationScenario();
|
||||
}
|
||||
|
||||
m_autoScreenshot.Initialize(initialScenario->captureRootPath);
|
||||
LoadStructuredScreen("startup");
|
||||
return true;
|
||||
@@ -315,12 +295,12 @@ void Application::RenderFrame() {
|
||||
|
||||
m_runtimeStatus = m_activeScenario != nullptr
|
||||
? m_activeScenario->displayName
|
||||
: "Editor UI Validation";
|
||||
: "Editor UI 验证";
|
||||
m_runtimeError = frame.errorMessage;
|
||||
}
|
||||
|
||||
if (drawData.Empty()) {
|
||||
m_runtimeStatus = "Editor UI Validation | Load Error";
|
||||
m_runtimeStatus = "Editor UI 验证 | 加载失败";
|
||||
if (m_runtimeError.empty() && !m_screenPlayer.IsLoaded()) {
|
||||
m_runtimeError = m_screenPlayer.GetLastError();
|
||||
}
|
||||
@@ -352,7 +332,7 @@ void Application::QueuePointerEvent(UIInputEventType type, UIPointerButton butto
|
||||
event.position = UIPoint(
|
||||
static_cast<float>(GET_X_LPARAM(lParam)),
|
||||
static_cast<float>(GET_Y_LPARAM(lParam)));
|
||||
event.modifiers = m_inputModifierTracker.BuildPointerModifiers(static_cast<size_t>(wParam));
|
||||
event.modifiers = m_inputModifierTracker.BuildPointerModifiers(static_cast<std::size_t>(wParam));
|
||||
m_pendingInputEvents.push_back(event);
|
||||
}
|
||||
|
||||
@@ -383,7 +363,7 @@ void Application::QueuePointerWheelEvent(short wheelDelta, WPARAM wParam, LPARAM
|
||||
event.type = UIInputEventType::PointerWheel;
|
||||
event.position = UIPoint(static_cast<float>(screenPoint.x), static_cast<float>(screenPoint.y));
|
||||
event.wheelDelta = static_cast<float>(wheelDelta);
|
||||
event.modifiers = m_inputModifierTracker.BuildPointerModifiers(static_cast<size_t>(wParam));
|
||||
event.modifiers = m_inputModifierTracker.BuildPointerModifiers(static_cast<std::size_t>(wParam));
|
||||
m_pendingInputEvents.push_back(event);
|
||||
}
|
||||
|
||||
@@ -412,6 +392,7 @@ void Application::QueueWindowFocusEvent(UIInputEventType type) {
|
||||
|
||||
bool Application::LoadStructuredScreen(const char* triggerReason) {
|
||||
(void)triggerReason;
|
||||
|
||||
std::string scenarioLoadWarning = {};
|
||||
const EditorValidationScenario* scenario = m_requestedScenarioId.empty()
|
||||
? &GetDefaultEditorValidationScenario()
|
||||
@@ -429,7 +410,7 @@ bool Application::LoadStructuredScreen(const char* triggerReason) {
|
||||
|
||||
const bool loaded = m_screenPlayer.Load(m_screenAsset);
|
||||
m_useStructuredScreen = loaded;
|
||||
m_runtimeStatus = loaded ? scenario->displayName : "Editor UI Validation | Load Error";
|
||||
m_runtimeStatus = loaded ? scenario->displayName : "Editor UI 验证 | 加载失败";
|
||||
m_runtimeError = loaded
|
||||
? scenarioLoadWarning
|
||||
: (scenarioLoadWarning.empty()
|
||||
@@ -518,19 +499,19 @@ bool Application::DetectTrackedFileChange() const {
|
||||
|
||||
void Application::AppendRuntimeOverlay(UIDrawData& drawData, float width, float height) const {
|
||||
const bool authoredMode = m_useStructuredScreen && m_screenPlayer.IsLoaded();
|
||||
const float panelWidth = authoredMode ? 460.0f : 360.0f;
|
||||
const float panelWidth = authoredMode ? 470.0f : 390.0f;
|
||||
std::vector<std::string> detailLines = {};
|
||||
detailLines.push_back(
|
||||
authoredMode
|
||||
? "Hot reload watches authored UI resources."
|
||||
: "Authored validation scene failed to load.");
|
||||
? "热重载正在监听当前 Editor 集成测试资源。"
|
||||
: "当前 Editor 验证场景加载失败。");
|
||||
if (m_activeScenario != nullptr) {
|
||||
detailLines.push_back("Scenario: " + m_activeScenario->id);
|
||||
detailLines.push_back("当前场景: " + m_activeScenario->id);
|
||||
}
|
||||
detailLines.push_back("验证范围: Splitter / TabStrip / Panel Frame / 占位内容");
|
||||
|
||||
if (authoredMode) {
|
||||
const auto& inputDebug = m_documentHost.GetInputDebugSnapshot();
|
||||
const auto& scrollDebug = m_documentHost.GetScrollDebugSnapshot();
|
||||
detailLines.push_back(
|
||||
"Hover | Focus: " +
|
||||
ExtractStateKeyTail(inputDebug.hoveredStateKey) +
|
||||
@@ -541,32 +522,6 @@ void Application::AppendRuntimeOverlay(UIDrawData& drawData, float width, float
|
||||
ExtractStateKeyTail(inputDebug.activeStateKey) +
|
||||
" | " +
|
||||
ExtractStateKeyTail(inputDebug.captureStateKey));
|
||||
detailLines.push_back(
|
||||
"Scope W/P/Wg: " +
|
||||
ExtractStateKeyTail(inputDebug.windowScopeStateKey) +
|
||||
" | " +
|
||||
ExtractStateKeyTail(inputDebug.panelScopeStateKey) +
|
||||
" | " +
|
||||
ExtractStateKeyTail(inputDebug.widgetScopeStateKey));
|
||||
detailLines.push_back(
|
||||
std::string("Text input: ") +
|
||||
(inputDebug.textInputActive ? "active" : "idle"));
|
||||
if (!inputDebug.recentShortcutCommandId.empty()) {
|
||||
detailLines.push_back(
|
||||
"Recent shortcut: " +
|
||||
inputDebug.recentShortcutScope +
|
||||
" -> " +
|
||||
inputDebug.recentShortcutCommandId);
|
||||
detailLines.push_back(
|
||||
std::string("Recent shortcut state: ") +
|
||||
(inputDebug.recentShortcutHandled
|
||||
? "handled"
|
||||
: (inputDebug.recentShortcutSuppressed ? "suppressed" : "observed")) +
|
||||
" @ " +
|
||||
ExtractStateKeyTail(inputDebug.recentShortcutOwnerStateKey));
|
||||
} else {
|
||||
detailLines.push_back("Recent shortcut: none");
|
||||
}
|
||||
if (!inputDebug.lastEventType.empty()) {
|
||||
const std::string eventPosition = inputDebug.lastEventType == "KeyDown" ||
|
||||
inputDebug.lastEventType == "KeyUp" ||
|
||||
@@ -576,59 +531,26 @@ void Application::AppendRuntimeOverlay(UIDrawData& drawData, float width, float
|
||||
? std::string()
|
||||
: " at " + FormatPoint(inputDebug.pointerPosition);
|
||||
detailLines.push_back(
|
||||
"Last input: " +
|
||||
"最近输入: " +
|
||||
inputDebug.lastEventType +
|
||||
eventPosition);
|
||||
detailLines.push_back(
|
||||
"Route: " +
|
||||
"命中路径: " +
|
||||
inputDebug.lastTargetKind +
|
||||
" -> " +
|
||||
ExtractStateKeyTail(inputDebug.lastTargetStateKey));
|
||||
if (!inputDebug.lastShortcutCommandId.empty()) {
|
||||
detailLines.push_back(
|
||||
"Shortcut: " +
|
||||
inputDebug.lastShortcutScope +
|
||||
" -> " +
|
||||
inputDebug.lastShortcutCommandId);
|
||||
detailLines.push_back(
|
||||
std::string("Shortcut state: ") +
|
||||
(inputDebug.lastShortcutHandled
|
||||
? "handled"
|
||||
: (inputDebug.lastShortcutSuppressed ? "suppressed" : "observed")) +
|
||||
" @ " +
|
||||
ExtractStateKeyTail(inputDebug.lastShortcutOwnerStateKey));
|
||||
}
|
||||
detailLines.push_back(
|
||||
"Last event result: " +
|
||||
"Result: " +
|
||||
(inputDebug.lastResult.empty() ? std::string("n/a") : inputDebug.lastResult));
|
||||
}
|
||||
detailLines.push_back(
|
||||
"Scroll target | Primary: " +
|
||||
ExtractStateKeyTail(scrollDebug.lastTargetStateKey) +
|
||||
" | " +
|
||||
ExtractStateKeyTail(scrollDebug.primaryTargetStateKey));
|
||||
detailLines.push_back(
|
||||
"Scroll offset B/A: " +
|
||||
FormatFloat(scrollDebug.lastOffsetBefore) +
|
||||
" -> " +
|
||||
FormatFloat(scrollDebug.lastOffsetAfter) +
|
||||
" | overflow " +
|
||||
FormatFloat(scrollDebug.lastOverflow));
|
||||
detailLines.push_back(
|
||||
"Scroll H/T: " +
|
||||
std::to_string(scrollDebug.handledWheelEventCount) +
|
||||
"/" +
|
||||
std::to_string(scrollDebug.totalWheelEventCount) +
|
||||
" | " +
|
||||
(scrollDebug.lastResult.empty() ? std::string("n/a") : scrollDebug.lastResult));
|
||||
}
|
||||
|
||||
if (m_autoScreenshot.HasPendingCapture()) {
|
||||
detailLines.push_back("Shot pending...");
|
||||
detailLines.push_back("截图排队中...");
|
||||
} else if (!m_autoScreenshot.GetLastCaptureSummary().empty()) {
|
||||
detailLines.push_back(TruncateText(m_autoScreenshot.GetLastCaptureSummary(), 78u));
|
||||
} else {
|
||||
detailLines.push_back("Screenshots: F12 -> current scenario captures/");
|
||||
detailLines.push_back("截图: F12 -> 当前场景 captures/");
|
||||
}
|
||||
|
||||
if (!m_runtimeError.empty()) {
|
||||
@@ -636,13 +558,13 @@ void Application::AppendRuntimeOverlay(UIDrawData& drawData, float width, float
|
||||
} else if (!m_autoScreenshot.GetLastCaptureError().empty()) {
|
||||
detailLines.push_back(TruncateText(m_autoScreenshot.GetLastCaptureError(), 78u));
|
||||
} else if (!authoredMode) {
|
||||
detailLines.push_back("No fallback sandbox is rendered in this host.");
|
||||
detailLines.push_back("当前宿主不会回退到 sandbox 画面。");
|
||||
}
|
||||
|
||||
const float panelHeight = 38.0f + static_cast<float>(detailLines.size()) * 18.0f;
|
||||
const UIRect panelRect(width - panelWidth - 16.0f, height - panelHeight - 42.0f, panelWidth, panelHeight);
|
||||
|
||||
UIDrawList& overlay = drawData.EmplaceDrawList("Editor UI Validation Overlay");
|
||||
UIDrawList& overlay = drawData.EmplaceDrawList("Editor UI 验证浮层");
|
||||
overlay.AddFilledRect(panelRect, kOverlayBgColor, 10.0f);
|
||||
overlay.AddRectOutline(panelRect, kOverlayBorderColor, 1.0f, 10.0f);
|
||||
overlay.AddFilledRect(
|
||||
@@ -651,7 +573,7 @@ void Application::AppendRuntimeOverlay(UIDrawData& drawData, float width, float
|
||||
4.0f);
|
||||
overlay.AddText(
|
||||
UIPoint(panelRect.x + 28.0f, panelRect.y + 10.0f),
|
||||
m_runtimeStatus.empty() ? "Editor UI Validation" : m_runtimeStatus,
|
||||
m_runtimeStatus.empty() ? "Editor UI 验证" : m_runtimeStatus,
|
||||
kOverlayTextPrimary,
|
||||
14.0f);
|
||||
|
||||
@@ -669,10 +591,6 @@ void Application::AppendRuntimeOverlay(UIDrawData& drawData, float width, float
|
||||
}
|
||||
}
|
||||
|
||||
std::filesystem::path Application::ResolveRepoRelativePath(const char* relativePath) {
|
||||
return (GetRepoRootPath() / relativePath).lexically_normal();
|
||||
}
|
||||
|
||||
LRESULT CALLBACK Application::WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
|
||||
if (message == WM_NCCREATE) {
|
||||
const auto* createStruct = reinterpret_cast<CREATESTRUCTW*>(lParam);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#endif
|
||||
|
||||
#include "EditorValidationScenario.h"
|
||||
|
||||
#include <XCNewEditor/Host/AutoScreenshot.h>
|
||||
#include <XCNewEditor/Host/InputModifierTracker.h>
|
||||
#include <XCNewEditor/Host/NativeRenderer.h>
|
||||
@@ -53,7 +54,6 @@ private:
|
||||
void RebuildTrackedFileStates();
|
||||
bool DetectTrackedFileChange() const;
|
||||
void AppendRuntimeOverlay(::XCEngine::UI::UIDrawData& drawData, float width, float height) const;
|
||||
static std::filesystem::path ResolveRepoRelativePath(const char* relativePath);
|
||||
|
||||
HWND m_hwnd = nullptr;
|
||||
HINSTANCE m_hInstance = nullptr;
|
||||
@@ -66,7 +66,6 @@ private:
|
||||
const EditorValidationScenario* m_activeScenario = nullptr;
|
||||
std::string m_requestedScenarioId = {};
|
||||
std::vector<TrackedFileState> m_trackedFiles = {};
|
||||
std::chrono::steady_clock::time_point m_startTime = {};
|
||||
std::chrono::steady_clock::time_point m_lastFrameTime = {};
|
||||
std::chrono::steady_clock::time_point m_lastReloadPollTime = {};
|
||||
std::uint64_t m_frameIndex = 0;
|
||||
|
||||
@@ -17,6 +17,7 @@ fs::path RepoRootPath() {
|
||||
if (root.size() >= 2u && root.front() == '"' && root.back() == '"') {
|
||||
root = root.substr(1u, root.size() - 2u);
|
||||
}
|
||||
|
||||
return fs::path(root).lexically_normal();
|
||||
}
|
||||
|
||||
@@ -24,72 +25,19 @@ fs::path RepoRelative(const char* relativePath) {
|
||||
return (RepoRootPath() / relativePath).lexically_normal();
|
||||
}
|
||||
|
||||
const std::array<EditorValidationScenario, 7>& GetEditorValidationScenarios() {
|
||||
static const std::array<EditorValidationScenario, 7> scenarios = { {
|
||||
const std::array<EditorValidationScenario, 1>& GetEditorValidationScenarios() {
|
||||
static const std::array<EditorValidationScenario, 1> scenarios = { {
|
||||
{
|
||||
"editor.input.keyboard_focus",
|
||||
"editor.shell.workspace_compose",
|
||||
UIValidationDomain::Editor,
|
||||
"input",
|
||||
"Editor Input | Keyboard Focus",
|
||||
RepoRelative("tests/UI/Editor/integration/input/keyboard_focus/View.xcui"),
|
||||
"shell",
|
||||
"Editor 壳层 | 工作区组合",
|
||||
RepoRelative("tests/UI/Editor/integration/workspace_shell_compose/View.xcui"),
|
||||
RepoRelative("tests/UI/Editor/integration/shared/themes/editor_validation.xctheme"),
|
||||
RepoRelative("tests/UI/Editor/integration/input/keyboard_focus/captures")
|
||||
},
|
||||
{
|
||||
"editor.input.pointer_states",
|
||||
UIValidationDomain::Editor,
|
||||
"input",
|
||||
"Editor Input | Pointer States",
|
||||
RepoRelative("tests/UI/Editor/integration/input/pointer_states/View.xcui"),
|
||||
RepoRelative("tests/UI/Editor/integration/shared/themes/editor_validation.xctheme"),
|
||||
RepoRelative("tests/UI/Editor/integration/input/pointer_states/captures")
|
||||
},
|
||||
{
|
||||
"editor.input.scroll_view",
|
||||
UIValidationDomain::Editor,
|
||||
"input",
|
||||
"Editor Input | Scroll View",
|
||||
RepoRelative("tests/UI/Editor/integration/input/scroll_view/View.xcui"),
|
||||
RepoRelative("tests/UI/Editor/integration/shared/themes/editor_validation.xctheme"),
|
||||
RepoRelative("tests/UI/Editor/integration/input/scroll_view/captures")
|
||||
},
|
||||
{
|
||||
"editor.input.shortcut_scope",
|
||||
UIValidationDomain::Editor,
|
||||
"input",
|
||||
"Editor Input | Shortcut Scope",
|
||||
RepoRelative("tests/UI/Editor/integration/input/shortcut_scope/View.xcui"),
|
||||
RepoRelative("tests/UI/Editor/integration/shared/themes/editor_validation.xctheme"),
|
||||
RepoRelative("tests/UI/Editor/integration/input/shortcut_scope/captures")
|
||||
},
|
||||
{
|
||||
"editor.layout.splitter_resize",
|
||||
UIValidationDomain::Editor,
|
||||
"layout",
|
||||
"Editor Layout | Splitter Resize",
|
||||
RepoRelative("tests/UI/Editor/integration/layout/splitter_resize/View.xcui"),
|
||||
RepoRelative("tests/UI/Editor/integration/shared/themes/editor_validation.xctheme"),
|
||||
RepoRelative("tests/UI/Editor/integration/layout/splitter_resize/captures")
|
||||
},
|
||||
{
|
||||
"editor.layout.tab_strip_selection",
|
||||
UIValidationDomain::Editor,
|
||||
"layout",
|
||||
"Editor Layout | TabStrip Selection",
|
||||
RepoRelative("tests/UI/Editor/integration/layout/tab_strip_selection/View.xcui"),
|
||||
RepoRelative("tests/UI/Editor/integration/shared/themes/editor_validation.xctheme"),
|
||||
RepoRelative("tests/UI/Editor/integration/layout/tab_strip_selection/captures")
|
||||
},
|
||||
{
|
||||
"editor.layout.workspace_compose",
|
||||
UIValidationDomain::Editor,
|
||||
"layout",
|
||||
"Editor Layout | Workspace Compose",
|
||||
RepoRelative("tests/UI/Editor/integration/layout/workspace_compose/View.xcui"),
|
||||
RepoRelative("tests/UI/Editor/integration/shared/themes/editor_validation.xctheme"),
|
||||
RepoRelative("tests/UI/Editor/integration/layout/workspace_compose/captures")
|
||||
RepoRelative("tests/UI/Editor/integration/workspace_shell_compose/captures")
|
||||
}
|
||||
} };
|
||||
|
||||
return scenarios;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
namespace XCEngine::Tests::EditorUI {
|
||||
|
||||
enum class UIValidationDomain : unsigned char {
|
||||
Editor = 0,
|
||||
Runtime
|
||||
Editor = 0
|
||||
};
|
||||
|
||||
struct EditorValidationScenario {
|
||||
|
||||
@@ -1,30 +1,29 @@
|
||||
<Theme name="EditorValidationTheme">
|
||||
<Tokens>
|
||||
<Color name="color.bg.workspace" value="#1C1C1C" />
|
||||
<Color name="color.bg.panel" value="#292929" />
|
||||
<Color name="color.bg.accent" value="#3A3A3A" />
|
||||
<Color name="color.bg.selection" value="#4A4A4A" />
|
||||
<Color name="color.text.primary" value="#EEEEEE" />
|
||||
<Color name="color.text.muted" value="#B0B0B0" />
|
||||
<Spacing name="space.panel" value="12" />
|
||||
<Color name="color.bg.workspace" value="#1A1A1A" />
|
||||
<Color name="color.bg.panel" value="#262626" />
|
||||
<Color name="color.bg.selection" value="#3A3A3A" />
|
||||
<Color name="color.text.primary" value="#F2F2F2" />
|
||||
<Color name="color.text.muted" value="#B4B4B4" />
|
||||
<Spacing name="space.shell" value="18" />
|
||||
<Spacing name="space.panel" value="12" />
|
||||
<Radius name="radius.panel" value="10" />
|
||||
<Radius name="radius.control" value="8" />
|
||||
</Tokens>
|
||||
|
||||
<Widgets>
|
||||
<Widget type="View" style="EditorWorkspace">
|
||||
<Widget type="View" style="EditorValidationWorkspace">
|
||||
<Property name="background" value="color.bg.workspace" />
|
||||
<Property name="padding" value="space.shell" />
|
||||
</Widget>
|
||||
|
||||
<Widget type="Card" style="EditorPanel">
|
||||
<Widget type="Card" style="EditorShellPanel">
|
||||
<Property name="background" value="color.bg.panel" />
|
||||
<Property name="radius" value="radius.panel" />
|
||||
<Property name="padding" value="space.panel" />
|
||||
</Widget>
|
||||
|
||||
<Widget type="Button" style="EditorChip">
|
||||
<Widget type="Button" style="EditorShellChip">
|
||||
<Property name="background" value="color.bg.selection" />
|
||||
<Property name="radius" value="radius.control" />
|
||||
</Widget>
|
||||
|
||||
1
tests/UI/Editor/integration/state/CMakeLists.txt
Normal file
1
tests/UI/Editor/integration/state/CMakeLists.txt
Normal file
@@ -0,0 +1 @@
|
||||
add_subdirectory(panel_session_flow)
|
||||
@@ -0,0 +1,29 @@
|
||||
add_executable(editor_ui_panel_session_flow_validation WIN32
|
||||
main.cpp
|
||||
)
|
||||
|
||||
target_include_directories(editor_ui_panel_session_flow_validation PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/engine/include
|
||||
${CMAKE_SOURCE_DIR}/new_editor/include
|
||||
)
|
||||
|
||||
target_compile_definitions(editor_ui_panel_session_flow_validation PRIVATE
|
||||
UNICODE
|
||||
_UNICODE
|
||||
XCENGINE_EDITOR_UI_TESTS_REPO_ROOT="${XCENGINE_EDITOR_UI_TESTS_REPO_ROOT_PATH}"
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
target_compile_options(editor_ui_panel_session_flow_validation PRIVATE /utf-8 /FS)
|
||||
set_property(TARGET editor_ui_panel_session_flow_validation PROPERTY
|
||||
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
||||
endif()
|
||||
|
||||
target_link_libraries(editor_ui_panel_session_flow_validation PRIVATE
|
||||
XCNewEditorLib
|
||||
XCNewEditorHost
|
||||
)
|
||||
|
||||
set_target_properties(editor_ui_panel_session_flow_validation PROPERTIES
|
||||
OUTPUT_NAME "XCUIEditorPanelSessionFlowValidation"
|
||||
)
|
||||
648
tests/UI/Editor/integration/state/panel_session_flow/main.cpp
Normal file
648
tests/UI/Editor/integration/state/panel_session_flow/main.cpp
Normal file
@@ -0,0 +1,648 @@
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
|
||||
#include <XCNewEditor/Editor/UIEditorWorkspaceController.h>
|
||||
#include <XCNewEditor/Host/AutoScreenshot.h>
|
||||
#include <XCNewEditor/Host/NativeRenderer.h>
|
||||
|
||||
#include <XCEngine/UI/DrawData.h>
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#ifndef XCENGINE_EDITOR_UI_TESTS_REPO_ROOT
|
||||
#define XCENGINE_EDITOR_UI_TESTS_REPO_ROOT "."
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
using XCEngine::NewEditor::BuildDefaultUIEditorWorkspaceController;
|
||||
using XCEngine::NewEditor::BuildUIEditorWorkspacePanel;
|
||||
using XCEngine::NewEditor::BuildUIEditorWorkspaceSplit;
|
||||
using XCEngine::NewEditor::BuildUIEditorWorkspaceTabStack;
|
||||
using XCEngine::NewEditor::CollectUIEditorWorkspaceVisiblePanels;
|
||||
using XCEngine::NewEditor::FindUIEditorPanelSessionState;
|
||||
using XCEngine::NewEditor::GetUIEditorWorkspaceCommandKindName;
|
||||
using XCEngine::NewEditor::GetUIEditorWorkspaceCommandStatusName;
|
||||
using XCEngine::NewEditor::UIEditorPanelRegistry;
|
||||
using XCEngine::NewEditor::UIEditorWorkspaceCommand;
|
||||
using XCEngine::NewEditor::UIEditorWorkspaceCommandKind;
|
||||
using XCEngine::NewEditor::UIEditorWorkspaceCommandResult;
|
||||
using XCEngine::NewEditor::UIEditorWorkspaceController;
|
||||
using XCEngine::NewEditor::UIEditorWorkspaceModel;
|
||||
using XCEngine::NewEditor::UIEditorWorkspaceSession;
|
||||
using XCEngine::NewEditor::UIEditorWorkspaceSplitAxis;
|
||||
using XCEngine::UI::UIColor;
|
||||
using XCEngine::UI::UIDrawData;
|
||||
using XCEngine::UI::UIDrawList;
|
||||
using XCEngine::UI::UIPoint;
|
||||
using XCEngine::UI::UIRect;
|
||||
using XCEngine::XCUI::Host::AutoScreenshotController;
|
||||
using XCEngine::XCUI::Host::NativeRenderer;
|
||||
|
||||
constexpr const wchar_t* kWindowClassName = L"XCUIEditorPanelSessionFlowValidation";
|
||||
constexpr const wchar_t* kWindowTitle = L"XCUI Editor | Panel Session 状态流";
|
||||
|
||||
constexpr UIColor kWindowBg(0.15f, 0.15f, 0.15f, 1.0f);
|
||||
constexpr UIColor kCardBg(0.20f, 0.20f, 0.20f, 1.0f);
|
||||
constexpr UIColor kCardBorder(0.29f, 0.29f, 0.29f, 1.0f);
|
||||
constexpr UIColor kTextPrimary(0.94f, 0.94f, 0.94f, 1.0f);
|
||||
constexpr UIColor kTextMuted(0.72f, 0.72f, 0.72f, 1.0f);
|
||||
constexpr UIColor kAccent(0.33f, 0.55f, 0.84f, 1.0f);
|
||||
constexpr UIColor kSuccess(0.43f, 0.71f, 0.47f, 1.0f);
|
||||
constexpr UIColor kWarning(0.78f, 0.60f, 0.30f, 1.0f);
|
||||
constexpr UIColor kDanger(0.78f, 0.34f, 0.34f, 1.0f);
|
||||
constexpr UIColor kButtonEnabled(0.32f, 0.32f, 0.32f, 1.0f);
|
||||
constexpr UIColor kButtonDisabled(0.24f, 0.24f, 0.24f, 1.0f);
|
||||
constexpr UIColor kButtonBorder(0.44f, 0.44f, 0.44f, 1.0f);
|
||||
|
||||
enum class ActionId : unsigned char {
|
||||
HideActive = 0,
|
||||
ShowDocA,
|
||||
CloseDocB,
|
||||
OpenDocB,
|
||||
ActivateDetails,
|
||||
Reset
|
||||
};
|
||||
|
||||
struct ButtonState {
|
||||
ActionId action = ActionId::HideActive;
|
||||
std::string label = {};
|
||||
UIRect rect = {};
|
||||
bool enabled = false;
|
||||
};
|
||||
|
||||
std::filesystem::path ResolveRepoRootPath() {
|
||||
std::string root = XCENGINE_EDITOR_UI_TESTS_REPO_ROOT;
|
||||
if (root.size() >= 2u && root.front() == '"' && root.back() == '"') {
|
||||
root = root.substr(1u, root.size() - 2u);
|
||||
}
|
||||
|
||||
return std::filesystem::path(root).lexically_normal();
|
||||
}
|
||||
|
||||
UIEditorPanelRegistry BuildPanelRegistry() {
|
||||
UIEditorPanelRegistry registry = {};
|
||||
registry.panels = {
|
||||
{ "doc-a", "Document A", {}, true, true, true },
|
||||
{ "doc-b", "Document B", {}, true, true, true },
|
||||
{ "details", "Details", {}, true, true, true }
|
||||
};
|
||||
return registry;
|
||||
}
|
||||
|
||||
UIEditorWorkspaceModel BuildWorkspace() {
|
||||
UIEditorWorkspaceModel workspace = {};
|
||||
workspace.root = BuildUIEditorWorkspaceSplit(
|
||||
"root-split",
|
||||
UIEditorWorkspaceSplitAxis::Horizontal,
|
||||
0.66f,
|
||||
BuildUIEditorWorkspaceTabStack(
|
||||
"document-tabs",
|
||||
{
|
||||
BuildUIEditorWorkspacePanel("doc-a-node", "doc-a", "Document A", true),
|
||||
BuildUIEditorWorkspacePanel("doc-b-node", "doc-b", "Document B", true)
|
||||
},
|
||||
0u),
|
||||
BuildUIEditorWorkspacePanel("details-node", "details", "Details", true));
|
||||
workspace.activePanelId = "doc-a";
|
||||
return workspace;
|
||||
}
|
||||
|
||||
bool ContainsPoint(const UIRect& rect, float x, float y) {
|
||||
return x >= rect.x &&
|
||||
x <= rect.x + rect.width &&
|
||||
y >= rect.y &&
|
||||
y <= rect.y + rect.height;
|
||||
}
|
||||
|
||||
std::string JoinVisiblePanelIds(
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
const UIEditorWorkspaceSession& session) {
|
||||
const auto panels = CollectUIEditorWorkspaceVisiblePanels(workspace, session);
|
||||
if (panels.empty()) {
|
||||
return "(none)";
|
||||
}
|
||||
|
||||
std::ostringstream stream;
|
||||
for (std::size_t index = 0; index < panels.size(); ++index) {
|
||||
if (index > 0u) {
|
||||
stream << ", ";
|
||||
}
|
||||
stream << panels[index].panelId;
|
||||
}
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
std::string DescribePanelState(
|
||||
const UIEditorWorkspaceSession& session,
|
||||
std::string_view panelId,
|
||||
std::string_view displayName) {
|
||||
const auto* state = FindUIEditorPanelSessionState(session, panelId);
|
||||
if (state == nullptr) {
|
||||
return std::string(displayName) + ": missing";
|
||||
}
|
||||
|
||||
std::string visibility = {};
|
||||
if (!state->open) {
|
||||
visibility = "closed";
|
||||
} else if (!state->visible) {
|
||||
visibility = "hidden";
|
||||
} else {
|
||||
visibility = "visible";
|
||||
}
|
||||
|
||||
return std::string(displayName) + ": " + visibility;
|
||||
}
|
||||
|
||||
UIColor ResolvePanelStateColor(
|
||||
const UIEditorWorkspaceSession& session,
|
||||
std::string_view panelId) {
|
||||
const auto* state = FindUIEditorPanelSessionState(session, panelId);
|
||||
if (state == nullptr) {
|
||||
return kDanger;
|
||||
}
|
||||
|
||||
if (!state->open) {
|
||||
return kDanger;
|
||||
}
|
||||
|
||||
if (!state->visible) {
|
||||
return kWarning;
|
||||
}
|
||||
|
||||
return kSuccess;
|
||||
}
|
||||
|
||||
void DrawCard(
|
||||
UIDrawList& drawList,
|
||||
const UIRect& rect,
|
||||
std::string_view title,
|
||||
std::string_view subtitle = {}) {
|
||||
drawList.AddFilledRect(rect, kCardBg, 12.0f);
|
||||
drawList.AddRectOutline(rect, kCardBorder, 1.0f, 12.0f);
|
||||
drawList.AddText(UIPoint(rect.x + 18.0f, rect.y + 16.0f), std::string(title), kTextPrimary, 17.0f);
|
||||
if (!subtitle.empty()) {
|
||||
drawList.AddText(UIPoint(rect.x + 18.0f, rect.y + 42.0f), std::string(subtitle), kTextMuted, 12.0f);
|
||||
}
|
||||
}
|
||||
|
||||
class ScenarioApp {
|
||||
public:
|
||||
int Run(HINSTANCE hInstance, int nCmdShow) {
|
||||
if (!Initialize(hInstance, nCmdShow)) {
|
||||
Shutdown();
|
||||
return 1;
|
||||
}
|
||||
|
||||
MSG message = {};
|
||||
while (message.message != WM_QUIT) {
|
||||
if (PeekMessageW(&message, nullptr, 0U, 0U, PM_REMOVE)) {
|
||||
TranslateMessage(&message);
|
||||
DispatchMessageW(&message);
|
||||
continue;
|
||||
}
|
||||
|
||||
RenderFrame();
|
||||
Sleep(8);
|
||||
}
|
||||
|
||||
Shutdown();
|
||||
return static_cast<int>(message.wParam);
|
||||
}
|
||||
|
||||
private:
|
||||
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
|
||||
if (message == WM_NCCREATE) {
|
||||
const auto* createStruct = reinterpret_cast<CREATESTRUCTW*>(lParam);
|
||||
auto* app = reinterpret_cast<ScenarioApp*>(createStruct->lpCreateParams);
|
||||
SetWindowLongPtrW(hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(app));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
auto* app = reinterpret_cast<ScenarioApp*>(GetWindowLongPtrW(hwnd, GWLP_USERDATA));
|
||||
switch (message) {
|
||||
case WM_SIZE:
|
||||
if (app != nullptr && wParam != SIZE_MINIMIZED) {
|
||||
app->OnResize(static_cast<UINT>(LOWORD(lParam)), static_cast<UINT>(HIWORD(lParam)));
|
||||
}
|
||||
return 0;
|
||||
case WM_PAINT:
|
||||
if (app != nullptr) {
|
||||
PAINTSTRUCT paintStruct = {};
|
||||
BeginPaint(hwnd, &paintStruct);
|
||||
app->RenderFrame();
|
||||
EndPaint(hwnd, &paintStruct);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case WM_LBUTTONUP:
|
||||
if (app != nullptr) {
|
||||
app->HandleClick(
|
||||
static_cast<float>(GET_X_LPARAM(lParam)),
|
||||
static_cast<float>(GET_Y_LPARAM(lParam)));
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case WM_KEYDOWN:
|
||||
case WM_SYSKEYDOWN:
|
||||
if (app != nullptr) {
|
||||
if (wParam == VK_F12) {
|
||||
app->m_autoScreenshot.RequestCapture("manual_f12");
|
||||
} else {
|
||||
app->HandleShortcut(static_cast<UINT>(wParam));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case WM_ERASEBKGND:
|
||||
return 1;
|
||||
case WM_DESTROY:
|
||||
if (app != nullptr) {
|
||||
app->m_hwnd = nullptr;
|
||||
}
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return DefWindowProcW(hwnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
bool Initialize(HINSTANCE hInstance, int nCmdShow) {
|
||||
m_hInstance = hInstance;
|
||||
ResetScenario();
|
||||
|
||||
WNDCLASSEXW windowClass = {};
|
||||
windowClass.cbSize = sizeof(windowClass);
|
||||
windowClass.style = CS_HREDRAW | CS_VREDRAW;
|
||||
windowClass.lpfnWndProc = &ScenarioApp::WndProc;
|
||||
windowClass.hInstance = hInstance;
|
||||
windowClass.hCursor = LoadCursorW(nullptr, IDC_ARROW);
|
||||
windowClass.lpszClassName = kWindowClassName;
|
||||
|
||||
m_windowClassAtom = RegisterClassExW(&windowClass);
|
||||
if (m_windowClassAtom == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_hwnd = CreateWindowExW(
|
||||
0,
|
||||
kWindowClassName,
|
||||
kWindowTitle,
|
||||
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
1320,
|
||||
860,
|
||||
nullptr,
|
||||
nullptr,
|
||||
hInstance,
|
||||
this);
|
||||
if (m_hwnd == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ShowWindow(m_hwnd, nCmdShow);
|
||||
UpdateWindow(m_hwnd);
|
||||
|
||||
if (!m_renderer.Initialize(m_hwnd)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_autoScreenshot.Initialize(
|
||||
(ResolveRepoRootPath() / "tests/UI/Editor/integration/state/panel_session_flow/captures")
|
||||
.lexically_normal());
|
||||
return true;
|
||||
}
|
||||
|
||||
void Shutdown() {
|
||||
m_autoScreenshot.Shutdown();
|
||||
m_renderer.Shutdown();
|
||||
|
||||
if (m_hwnd != nullptr && IsWindow(m_hwnd)) {
|
||||
DestroyWindow(m_hwnd);
|
||||
}
|
||||
m_hwnd = nullptr;
|
||||
|
||||
if (m_windowClassAtom != 0 && m_hInstance != nullptr) {
|
||||
UnregisterClassW(kWindowClassName, m_hInstance);
|
||||
m_windowClassAtom = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void ResetScenario() {
|
||||
m_controller =
|
||||
BuildDefaultUIEditorWorkspaceController(BuildPanelRegistry(), BuildWorkspace());
|
||||
m_hasLastCommandResult = false;
|
||||
m_lastActionSummary = "等待操作:先点 Hide Active,确认命令结果为 Changed,并检查 active/visible 状态联动。";
|
||||
}
|
||||
|
||||
void OnResize(UINT width, UINT height) {
|
||||
if (width == 0 || height == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_renderer.Resize(width, height);
|
||||
}
|
||||
|
||||
void RenderFrame() {
|
||||
if (m_hwnd == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
RECT clientRect = {};
|
||||
GetClientRect(m_hwnd, &clientRect);
|
||||
const float width = static_cast<float>((std::max)(clientRect.right - clientRect.left, 1L));
|
||||
const float height = static_cast<float>((std::max)(clientRect.bottom - clientRect.top, 1L));
|
||||
|
||||
UIDrawData drawData = {};
|
||||
BuildDrawData(drawData, width, height);
|
||||
|
||||
const bool framePresented = m_renderer.Render(drawData);
|
||||
m_autoScreenshot.CaptureIfRequested(
|
||||
m_renderer,
|
||||
drawData,
|
||||
static_cast<unsigned int>(width),
|
||||
static_cast<unsigned int>(height),
|
||||
framePresented);
|
||||
}
|
||||
|
||||
void HandleClick(float x, float y) {
|
||||
for (const ButtonState& button : m_buttons) {
|
||||
if (button.enabled && ContainsPoint(button.rect, x, y)) {
|
||||
DispatchAction(button.action);
|
||||
InvalidateRect(m_hwnd, nullptr, FALSE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HandleShortcut(UINT keyCode) {
|
||||
switch (keyCode) {
|
||||
case '1':
|
||||
DispatchAction(ActionId::HideActive);
|
||||
break;
|
||||
case '2':
|
||||
DispatchAction(ActionId::ShowDocA);
|
||||
break;
|
||||
case '3':
|
||||
DispatchAction(ActionId::CloseDocB);
|
||||
break;
|
||||
case '4':
|
||||
DispatchAction(ActionId::OpenDocB);
|
||||
break;
|
||||
case '5':
|
||||
DispatchAction(ActionId::ActivateDetails);
|
||||
break;
|
||||
case 'R':
|
||||
DispatchAction(ActionId::Reset);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
InvalidateRect(m_hwnd, nullptr, FALSE);
|
||||
}
|
||||
|
||||
void DispatchAction(ActionId action) {
|
||||
std::string label = {};
|
||||
UIEditorWorkspaceCommand command = {};
|
||||
|
||||
switch (action) {
|
||||
case ActionId::HideActive:
|
||||
label = "Hide Active";
|
||||
command.kind = UIEditorWorkspaceCommandKind::HidePanel;
|
||||
command.panelId = m_controller.GetWorkspace().activePanelId;
|
||||
break;
|
||||
case ActionId::ShowDocA:
|
||||
label = "Show Doc A";
|
||||
command.kind = UIEditorWorkspaceCommandKind::ShowPanel;
|
||||
command.panelId = "doc-a";
|
||||
break;
|
||||
case ActionId::CloseDocB:
|
||||
label = "Close Doc B";
|
||||
command.kind = UIEditorWorkspaceCommandKind::ClosePanel;
|
||||
command.panelId = "doc-b";
|
||||
break;
|
||||
case ActionId::OpenDocB:
|
||||
label = "Open Doc B";
|
||||
command.kind = UIEditorWorkspaceCommandKind::OpenPanel;
|
||||
command.panelId = "doc-b";
|
||||
break;
|
||||
case ActionId::ActivateDetails:
|
||||
label = "Activate Details";
|
||||
command.kind = UIEditorWorkspaceCommandKind::ActivatePanel;
|
||||
command.panelId = "details";
|
||||
break;
|
||||
case ActionId::Reset:
|
||||
label = "Reset";
|
||||
command.kind = UIEditorWorkspaceCommandKind::ResetWorkspace;
|
||||
break;
|
||||
}
|
||||
|
||||
m_lastCommandResult = m_controller.Dispatch(command);
|
||||
m_hasLastCommandResult = true;
|
||||
m_lastActionSummary =
|
||||
label + " -> " +
|
||||
std::string(GetUIEditorWorkspaceCommandStatusName(m_lastCommandResult.status));
|
||||
}
|
||||
|
||||
bool IsButtonEnabled(ActionId action) const {
|
||||
const UIEditorWorkspaceModel& workspace = m_controller.GetWorkspace();
|
||||
const UIEditorWorkspaceSession& session = m_controller.GetSession();
|
||||
switch (action) {
|
||||
case ActionId::HideActive: {
|
||||
if (workspace.activePanelId.empty()) {
|
||||
return false;
|
||||
}
|
||||
const auto* state = FindUIEditorPanelSessionState(session, workspace.activePanelId);
|
||||
return state != nullptr && state->open && state->visible;
|
||||
}
|
||||
case ActionId::ShowDocA: {
|
||||
const auto* state = FindUIEditorPanelSessionState(session, "doc-a");
|
||||
return state != nullptr && state->open && !state->visible;
|
||||
}
|
||||
case ActionId::CloseDocB: {
|
||||
const auto* state = FindUIEditorPanelSessionState(session, "doc-b");
|
||||
return state != nullptr && state->open;
|
||||
}
|
||||
case ActionId::OpenDocB: {
|
||||
const auto* state = FindUIEditorPanelSessionState(session, "doc-b");
|
||||
return state != nullptr && !state->open;
|
||||
}
|
||||
case ActionId::ActivateDetails: {
|
||||
const auto* state = FindUIEditorPanelSessionState(session, "details");
|
||||
return state != nullptr &&
|
||||
state->open &&
|
||||
state->visible &&
|
||||
workspace.activePanelId != "details";
|
||||
}
|
||||
case ActionId::Reset:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void BuildDrawData(UIDrawData& drawData, float width, float height) {
|
||||
const UIEditorWorkspaceModel& workspace = m_controller.GetWorkspace();
|
||||
const UIEditorWorkspaceSession& session = m_controller.GetSession();
|
||||
const auto validation = m_controller.ValidateState();
|
||||
|
||||
UIDrawList& drawList = drawData.EmplaceDrawList("Editor Panel Session Flow");
|
||||
drawList.AddFilledRect(UIRect(0.0f, 0.0f, width, height), kWindowBg);
|
||||
|
||||
const float margin = 20.0f;
|
||||
const UIRect headerRect(margin, margin, width - margin * 2.0f, 170.0f);
|
||||
const UIRect actionRect(margin, headerRect.y + headerRect.height + 16.0f, 320.0f, height - 246.0f);
|
||||
const UIRect stateRect(actionRect.x + actionRect.width + 16.0f, actionRect.y, width - actionRect.width - margin * 2.0f - 16.0f, height - 246.0f);
|
||||
const UIRect footerRect(margin, height - 96.0f, width - margin * 2.0f, 76.0f);
|
||||
|
||||
DrawCard(drawList, headerRect, "测试功能:Editor Command Dispatch + Workspace Controller", "只验证命令分发、状态变更结果和 panel session 联动;不验证业务面板。");
|
||||
drawList.AddText(UIPoint(headerRect.x + 18.0f, headerRect.y + 70.0f), "1. 点 `1 Hide Active`,Result 应是 Changed;active 从 doc-a 切到 doc-b,selected tab 也同步到 B。", kTextPrimary, 13.0f);
|
||||
drawList.AddText(UIPoint(headerRect.x + 18.0f, headerRect.y + 92.0f), "2. 再点 `1 Hide Active`,如果当前 panel 已 hidden,Result 应变成 NoOp,而不是乱改状态。", kTextPrimary, 13.0f);
|
||||
drawList.AddText(UIPoint(headerRect.x + 18.0f, headerRect.y + 114.0f), "3. 点 `3 Close Doc B` 后再点 `5 Activate Details` / `4 Open Doc B`,检查 Changed / Rejected / NoOp 是否符合提示。", kTextPrimary, 13.0f);
|
||||
drawList.AddText(UIPoint(headerRect.x + 18.0f, headerRect.y + 136.0f), "4. `R Reset` 必须把状态拉回基线;按 `F12` 保存当前窗口截图。", kTextPrimary, 13.0f);
|
||||
|
||||
DrawCard(drawList, actionRect, "操作区", "每个按钮都会先生成 command,再交给 Workspace Controller 分发。");
|
||||
DrawCard(drawList, stateRect, "状态摘要", "重点检查 active panel、visible panels、selected tab index 和每个 panel session 状态。");
|
||||
DrawCard(drawList, footerRect, "最近结果", "这块显示 last command、status、message 与当前 validation。");
|
||||
|
||||
m_buttons.clear();
|
||||
const std::vector<std::pair<ActionId, std::string>> buttonDefs = {
|
||||
{ ActionId::HideActive, "1 Hide Active" },
|
||||
{ ActionId::ShowDocA, "2 Show Doc A" },
|
||||
{ ActionId::CloseDocB, "3 Close Doc B" },
|
||||
{ ActionId::OpenDocB, "4 Open Doc B" },
|
||||
{ ActionId::ActivateDetails, "5 Activate Details" },
|
||||
{ ActionId::Reset, "R Reset" }
|
||||
};
|
||||
|
||||
float buttonY = actionRect.y + 72.0f;
|
||||
for (const auto& [action, label] : buttonDefs) {
|
||||
ButtonState button = {};
|
||||
button.action = action;
|
||||
button.label = label;
|
||||
button.rect = UIRect(actionRect.x + 18.0f, buttonY, actionRect.width - 36.0f, 46.0f);
|
||||
button.enabled = IsButtonEnabled(action);
|
||||
m_buttons.push_back(button);
|
||||
|
||||
drawList.AddFilledRect(
|
||||
button.rect,
|
||||
button.enabled ? kButtonEnabled : kButtonDisabled,
|
||||
8.0f);
|
||||
drawList.AddRectOutline(button.rect, kButtonBorder, 1.0f, 8.0f);
|
||||
drawList.AddText(
|
||||
UIPoint(button.rect.x + 14.0f, button.rect.y + 13.0f),
|
||||
button.label,
|
||||
button.enabled ? kTextPrimary : kTextMuted,
|
||||
13.0f);
|
||||
buttonY += 58.0f;
|
||||
}
|
||||
|
||||
const float leftX = stateRect.x + 18.0f;
|
||||
drawList.AddText(UIPoint(leftX, stateRect.y + 70.0f), "Current active panel:", kTextMuted, 12.0f);
|
||||
drawList.AddText(UIPoint(leftX, stateRect.y + 90.0f), workspace.activePanelId.empty() ? "(none)" : workspace.activePanelId, kAccent, 15.0f);
|
||||
|
||||
drawList.AddText(UIPoint(leftX, stateRect.y + 124.0f), "Visible panels:", kTextMuted, 12.0f);
|
||||
drawList.AddText(UIPoint(leftX, stateRect.y + 144.0f), JoinVisiblePanelIds(workspace, session), kTextPrimary, 14.0f);
|
||||
|
||||
drawList.AddText(UIPoint(leftX, stateRect.y + 178.0f), "Selected tab index:", kTextMuted, 12.0f);
|
||||
drawList.AddText(
|
||||
UIPoint(leftX, stateRect.y + 198.0f),
|
||||
std::to_string(workspace.root.children.front().selectedTabIndex),
|
||||
kTextPrimary,
|
||||
14.0f);
|
||||
|
||||
const float pillX = leftX;
|
||||
const float pillY = stateRect.y + 244.0f;
|
||||
const std::vector<std::pair<std::string, std::string>> panelDefs = {
|
||||
{ "doc-a", "Document A" },
|
||||
{ "doc-b", "Document B" },
|
||||
{ "details", "Details" }
|
||||
};
|
||||
|
||||
float rowY = pillY;
|
||||
for (const auto& [panelId, label] : panelDefs) {
|
||||
const UIRect rowRect(leftX, rowY, stateRect.width - 36.0f, 54.0f);
|
||||
drawList.AddFilledRect(rowRect, UIColor(0.17f, 0.17f, 0.17f, 1.0f), 8.0f);
|
||||
drawList.AddRectOutline(rowRect, kCardBorder, 1.0f, 8.0f);
|
||||
drawList.AddFilledRect(
|
||||
UIRect(rowRect.x + 12.0f, rowRect.y + 15.0f, 10.0f, 10.0f),
|
||||
ResolvePanelStateColor(session, panelId),
|
||||
5.0f);
|
||||
drawList.AddText(
|
||||
UIPoint(rowRect.x + 32.0f, rowRect.y + 11.0f),
|
||||
DescribePanelState(session, panelId, label),
|
||||
kTextPrimary,
|
||||
14.0f);
|
||||
const bool active = workspace.activePanelId == panelId;
|
||||
drawList.AddText(
|
||||
UIPoint(rowRect.x + 32.0f, rowRect.y + 31.0f),
|
||||
active ? "active = true" : "active = false",
|
||||
active ? kAccent : kTextMuted,
|
||||
12.0f);
|
||||
rowY += 64.0f;
|
||||
}
|
||||
|
||||
drawList.AddText(UIPoint(footerRect.x + 18.0f, footerRect.y + 28.0f), m_lastActionSummary, kTextPrimary, 13.0f);
|
||||
if (m_hasLastCommandResult) {
|
||||
drawList.AddText(
|
||||
UIPoint(footerRect.x + 18.0f, footerRect.y + 48.0f),
|
||||
"Last command: " +
|
||||
std::string(GetUIEditorWorkspaceCommandKindName(m_lastCommandResult.kind)) +
|
||||
" | Status: " +
|
||||
std::string(GetUIEditorWorkspaceCommandStatusName(m_lastCommandResult.status)) +
|
||||
" | " +
|
||||
m_lastCommandResult.message,
|
||||
m_lastCommandResult.status == XCEngine::NewEditor::UIEditorWorkspaceCommandStatus::Rejected
|
||||
? kDanger
|
||||
: (m_lastCommandResult.status == XCEngine::NewEditor::UIEditorWorkspaceCommandStatus::NoOp
|
||||
? kWarning
|
||||
: kSuccess),
|
||||
12.0f);
|
||||
}
|
||||
drawList.AddText(
|
||||
UIPoint(footerRect.x + 18.0f, footerRect.y + 66.0f),
|
||||
validation.IsValid() ? "Validation: OK" : "Validation: " + validation.message,
|
||||
validation.IsValid() ? kSuccess : kDanger,
|
||||
12.0f);
|
||||
|
||||
const std::string captureSummary =
|
||||
m_autoScreenshot.HasPendingCapture()
|
||||
? "截图排队中..."
|
||||
: (m_autoScreenshot.GetLastCaptureSummary().empty()
|
||||
? std::string("F12 -> tests/UI/Editor/integration/state/panel_session_flow/captures/")
|
||||
: m_autoScreenshot.GetLastCaptureSummary());
|
||||
drawList.AddText(UIPoint(footerRect.x + 530.0f, footerRect.y + 66.0f), captureSummary, kTextMuted, 12.0f);
|
||||
}
|
||||
|
||||
HWND m_hwnd = nullptr;
|
||||
HINSTANCE m_hInstance = nullptr;
|
||||
ATOM m_windowClassAtom = 0;
|
||||
NativeRenderer m_renderer = {};
|
||||
AutoScreenshotController m_autoScreenshot = {};
|
||||
UIEditorWorkspaceController m_controller = {};
|
||||
std::vector<ButtonState> m_buttons = {};
|
||||
UIEditorWorkspaceCommandResult m_lastCommandResult = {};
|
||||
bool m_hasLastCommandResult = false;
|
||||
std::string m_lastActionSummary = {};
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR, int nCmdShow) {
|
||||
ScenarioApp app;
|
||||
return app.Run(hInstance, nCmdShow);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
set(EDITOR_UI_WORKSPACE_SHELL_COMPOSE_RESOURCES
|
||||
View.xcui
|
||||
${CMAKE_SOURCE_DIR}/tests/UI/Editor/integration/shared/themes/editor_validation.xctheme
|
||||
)
|
||||
|
||||
add_executable(editor_ui_workspace_shell_compose_validation WIN32
|
||||
main.cpp
|
||||
${EDITOR_UI_WORKSPACE_SHELL_COMPOSE_RESOURCES}
|
||||
)
|
||||
|
||||
target_include_directories(editor_ui_workspace_shell_compose_validation PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/tests/UI/Editor/integration/shared/src
|
||||
${CMAKE_SOURCE_DIR}/engine/include
|
||||
)
|
||||
|
||||
target_compile_definitions(editor_ui_workspace_shell_compose_validation PRIVATE
|
||||
UNICODE
|
||||
_UNICODE
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
target_compile_options(editor_ui_workspace_shell_compose_validation PRIVATE /utf-8 /FS)
|
||||
set_property(TARGET editor_ui_workspace_shell_compose_validation PROPERTY
|
||||
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
||||
endif()
|
||||
|
||||
target_link_libraries(editor_ui_workspace_shell_compose_validation PRIVATE
|
||||
editor_ui_integration_host
|
||||
)
|
||||
|
||||
set_target_properties(editor_ui_workspace_shell_compose_validation PROPERTIES
|
||||
OUTPUT_NAME "XCUIEditorWorkspaceShellComposeValidation"
|
||||
)
|
||||
|
||||
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES View.xcui)
|
||||
@@ -0,0 +1,94 @@
|
||||
<View
|
||||
name="EditorWorkspaceShellComposeValidation"
|
||||
theme="../shared/themes/editor_validation.xctheme">
|
||||
<Column width="fill" height="fill" padding="20" gap="12">
|
||||
<Card
|
||||
title="测试内容:Editor Shell 基础壳层组合"
|
||||
subtitle="只验证 Splitter / TabStrip / Panel Frame / 占位内容;不验证业务面板,不验证 new_editor 应用逻辑"
|
||||
tone="accent"
|
||||
height="156">
|
||||
<Column gap="6">
|
||||
<Text text="1. 检查左、中、右、下四个壳层区域边界是否干净,没有重叠、穿透或错位。" />
|
||||
<Text text="2. 拖动 shell-left-right、shell-center-right、shell-top-bottom,确认实时 resize 正常,并且会被最小尺寸正确 clamp。" />
|
||||
<Text text="3. 点击 Document A / B / C,确认中心区域只显示当前选中的 tab 占位内容。" />
|
||||
<Text text="4. 这个测试不负责验证业务面板、数据绑定、命令系统,也不负责验证 new_editor 整体行为。" />
|
||||
</Column>
|
||||
</Card>
|
||||
|
||||
<Splitter
|
||||
id="shell-top-bottom"
|
||||
axis="vertical"
|
||||
splitRatio="0.76"
|
||||
splitterSize="10"
|
||||
splitterHitSize="18"
|
||||
primaryMin="340"
|
||||
secondaryMin="120"
|
||||
height="fill">
|
||||
<Splitter
|
||||
id="shell-left-right"
|
||||
axis="horizontal"
|
||||
splitRatio="0.22"
|
||||
splitterSize="10"
|
||||
splitterHitSize="18"
|
||||
primaryMin="180"
|
||||
secondaryMin="480"
|
||||
height="fill">
|
||||
<Card id="left-dock-placeholder" title="左侧 Dock 占位" subtitle="仅用于验证壳层 panel frame" height="fill">
|
||||
<Column gap="8">
|
||||
<Text text="这里用于检查 panel chrome 的边界、padding 和 split 稳定性。" />
|
||||
</Column>
|
||||
</Card>
|
||||
|
||||
<Splitter
|
||||
id="shell-center-right"
|
||||
axis="horizontal"
|
||||
splitRatio="0.72"
|
||||
splitterSize="10"
|
||||
splitterHitSize="18"
|
||||
primaryMin="280"
|
||||
secondaryMin="200"
|
||||
height="fill">
|
||||
<TabStrip
|
||||
id="document-tab-host"
|
||||
tabHeaderHeight="34"
|
||||
tabMinWidth="120"
|
||||
height="fill">
|
||||
<Tab id="document-tab-a" label="Document A" selected="true">
|
||||
<Card title="文档占位 A" subtitle="当前选中 = Document A" height="fill">
|
||||
<Column gap="8">
|
||||
<Text text="中心主区域此时应该只渲染当前选中的 tab 占位内容。" />
|
||||
</Column>
|
||||
</Card>
|
||||
</Tab>
|
||||
<Tab id="document-tab-b" label="Document B">
|
||||
<Card title="文档占位 B" subtitle="当前选中 = Document B" height="fill">
|
||||
<Column gap="8">
|
||||
<Text text="切到 Document B 后,Document A 的内容应该被隐藏。" />
|
||||
</Column>
|
||||
</Card>
|
||||
</Tab>
|
||||
<Tab id="document-tab-c" label="Document C">
|
||||
<Card title="文档占位 C" subtitle="当前选中 = Document C" height="fill">
|
||||
<Column gap="8">
|
||||
<Text text="这只是壳层 tab 占位,不是真实的 Editor 业务面板。" />
|
||||
</Column>
|
||||
</Card>
|
||||
</Tab>
|
||||
</TabStrip>
|
||||
|
||||
<Card id="right-dock-placeholder" title="右侧 Dock 占位" subtitle="仅用于验证壳层 panel frame" height="fill">
|
||||
<Column gap="8">
|
||||
<Text text="这里用于检查嵌套 split 和右侧占位 panel shell 是否稳定。" />
|
||||
</Column>
|
||||
</Card>
|
||||
</Splitter>
|
||||
</Splitter>
|
||||
|
||||
<Card id="bottom-dock-placeholder" title="底部 Dock 占位" subtitle="仅用于验证壳层 panel frame" height="fill">
|
||||
<Column gap="8">
|
||||
<Text text="这里用于检查底部 dock shell 和上下分割组合是否正常。" />
|
||||
</Column>
|
||||
</Card>
|
||||
</Splitter>
|
||||
</Column>
|
||||
</View>
|
||||
@@ -4,5 +4,5 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR, int nCmdShow) {
|
||||
return XCEngine::Tests::EditorUI::RunEditorUIValidationApp(
|
||||
hInstance,
|
||||
nCmdShow,
|
||||
"editor.input.scroll_view");
|
||||
"editor.shell.workspace_compose");
|
||||
}
|
||||
Reference in New Issue
Block a user