Files
XCEngine/tests/NewEditor/test_xcui_layout_lab_runtime.cpp

533 lines
23 KiB
C++
Raw Normal View History

2026-04-05 04:55:25 +08:00
#include <gtest/gtest.h>
#include "XCUIBackend/XCUILayoutLabRuntime.h"
#include <XCEngine/UI/Types.h>
#include <string>
#include <vector>
namespace {
using XCEngine::UI::UIDrawCommand;
using XCEngine::UI::UIDrawCommandType;
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState BuildInputState(
float width = 960.0f,
float height = 640.0f) {
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState input = {};
input.canvasRect = XCEngine::UI::UIRect(0.0f, 0.0f, width, height);
input.pointerPosition = XCEngine::UI::UIPoint(width * 0.5f, height * 0.5f);
input.pointerInside = true;
return input;
}
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState BuildKeyboardInputState(
float width = 960.0f,
float height = 640.0f) {
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState input = BuildInputState(width, height);
input.pointerInside = false;
return input;
}
XCEngine::UI::UIPoint RectCenter(const XCEngine::UI::UIRect& rect) {
return XCEngine::UI::UIPoint(
rect.x + rect.width * 0.5f,
rect.y + rect.height * 0.5f);
}
2026-04-05 04:55:25 +08:00
std::vector<const UIDrawCommand*> CollectTextCommands(const XCEngine::UI::UIDrawData& drawData) {
std::vector<const UIDrawCommand*> textCommands = {};
for (const XCEngine::UI::UIDrawList& drawList : drawData.GetDrawLists()) {
for (const UIDrawCommand& command : drawList.GetCommands()) {
if (command.type == UIDrawCommandType::Text) {
textCommands.push_back(&command);
}
}
}
return textCommands;
}
const UIDrawCommand* FindTextCommand(
const XCEngine::UI::UIDrawData& drawData,
const std::string& text) {
for (const XCEngine::UI::UIDrawList& drawList : drawData.GetDrawLists()) {
for (const UIDrawCommand& command : drawList.GetCommands()) {
if (command.type == UIDrawCommandType::Text && command.text == text) {
return &command;
}
}
}
return nullptr;
}
std::size_t CountCommandsOfType(
const XCEngine::UI::UIDrawData& drawData,
UIDrawCommandType type) {
std::size_t count = 0;
for (const XCEngine::UI::UIDrawList& drawList : drawData.GetDrawLists()) {
for (const UIDrawCommand& command : drawList.GetCommands()) {
if (command.type == type) {
++count;
}
}
}
return count;
}
} // namespace
TEST(NewEditorXCUILayoutLabRuntimeTest, UpdateBuildsLayoutSmokeFrame) {
XCEngine::Editor::XCUIBackend::XCUILayoutLabRuntime runtime;
const bool reloadSucceeded = runtime.ReloadDocuments();
const auto& frame = runtime.Update(BuildInputState());
EXPECT_EQ(frame.stats.documentsReady, reloadSucceeded);
EXPECT_EQ(frame.stats.drawListCount, frame.drawData.GetDrawListCount());
EXPECT_EQ(frame.stats.commandCount, frame.drawData.GetTotalCommandCount());
if (frame.stats.documentsReady) {
EXPECT_GT(frame.stats.drawListCount, 0u);
EXPECT_GT(frame.stats.commandCount, 0u);
EXPECT_GE(frame.stats.rowCount, 1u);
EXPECT_GE(frame.stats.columnCount, 1u);
EXPECT_GE(frame.stats.overlayCount, 1u);
EXPECT_GE(frame.stats.scrollViewCount, 2u);
2026-04-05 05:44:07 +08:00
EXPECT_GE(frame.stats.treeViewCount, 1u);
EXPECT_GE(frame.stats.treeItemCount, 3u);
EXPECT_GE(frame.stats.listViewCount, 1u);
EXPECT_GE(frame.stats.listItemCount, 3u);
EXPECT_GE(frame.stats.propertySectionCount, 2u);
EXPECT_GE(frame.stats.fieldRowCount, 4u);
2026-04-05 04:55:25 +08:00
XCEngine::UI::UIRect heroRect = {};
EXPECT_TRUE(runtime.TryGetElementRect("heroCard", heroRect));
EXPECT_GT(heroRect.width, 0.0f);
EXPECT_GT(heroRect.height, 0.0f);
} else {
EXPECT_FALSE(frame.stats.statusMessage.empty());
}
}
TEST(NewEditorXCUILayoutLabRuntimeTest, FrameIncludesTextCommandsWithThemeFontSizes) {
XCEngine::Editor::XCUIBackend::XCUILayoutLabRuntime runtime;
ASSERT_TRUE(runtime.ReloadDocuments());
const auto& frame = runtime.Update(BuildInputState());
ASSERT_TRUE(frame.stats.documentsReady);
const std::vector<const UIDrawCommand*> textCommands = CollectTextCommands(frame.drawData);
ASSERT_FALSE(textCommands.empty());
for (const UIDrawCommand* command : textCommands) {
ASSERT_NE(command, nullptr);
EXPECT_FALSE(command->text.empty());
EXPECT_GT(command->fontSize, 0.0f);
}
const UIDrawCommand* titleCommand = FindTextCommand(frame.drawData, "XCUI Layout Lab");
ASSERT_NE(titleCommand, nullptr);
EXPECT_FLOAT_EQ(titleCommand->fontSize, 16.0f);
const UIDrawCommand* subtitleCommand = FindTextCommand(
frame.drawData,
"Editor-style panels with overlay and scroll semantics.");
ASSERT_NE(subtitleCommand, nullptr);
EXPECT_FLOAT_EQ(subtitleCommand->fontSize, 13.0f);
}
TEST(NewEditorXCUILayoutLabRuntimeTest, HoverProbeResolvesTrackedElementRect) {
XCEngine::Editor::XCUIBackend::XCUILayoutLabRuntime runtime;
ASSERT_TRUE(runtime.ReloadDocuments());
const auto& baseline = runtime.Update(BuildInputState());
ASSERT_TRUE(baseline.stats.documentsReady);
XCEngine::UI::UIRect probeRect = {};
ASSERT_TRUE(runtime.TryGetElementRect("assetLighting", probeRect));
ASSERT_GT(probeRect.width, 0.0f);
ASSERT_GT(probeRect.height, 0.0f);
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState input = BuildInputState();
input.pointerPosition = XCEngine::UI::UIPoint(
probeRect.x + probeRect.width * 0.5f,
probeRect.y + probeRect.height * 0.5f);
const auto& frame = runtime.Update(input);
ASSERT_TRUE(frame.stats.documentsReady);
EXPECT_FALSE(frame.stats.hoveredElementId.empty());
XCEngine::UI::UIRect hoveredRect = {};
EXPECT_TRUE(runtime.TryGetElementRect(frame.stats.hoveredElementId, hoveredRect));
EXPECT_GT(hoveredRect.width, 0.0f);
EXPECT_GT(hoveredRect.height, 0.0f);
}
2026-04-05 05:44:07 +08:00
TEST(NewEditorXCUILayoutLabRuntimeTest, EditorPrototypeWidgetsExposeRectsAndLabels) {
XCEngine::Editor::XCUIBackend::XCUILayoutLabRuntime runtime;
ASSERT_TRUE(runtime.ReloadDocuments());
const auto& frame = runtime.Update(BuildInputState());
ASSERT_TRUE(frame.stats.documentsReady);
XCEngine::UI::UIRect projectTreeRect = {};
XCEngine::UI::UIRect fieldPositionRect = {};
ASSERT_TRUE(runtime.TryGetElementRect("projectTree", projectTreeRect));
ASSERT_TRUE(runtime.TryGetElementRect("fieldPosition", fieldPositionRect));
EXPECT_GT(projectTreeRect.height, 0.0f);
EXPECT_GT(fieldPositionRect.width, 0.0f);
EXPECT_NE(FindTextCommand(frame.drawData, "Assets"), nullptr);
EXPECT_NE(FindTextCommand(frame.drawData, "Lighting_GlobalRig"), nullptr);
EXPECT_NE(FindTextCommand(frame.drawData, "Position"), nullptr);
EXPECT_NE(FindTextCommand(frame.drawData, "0.0, 1.5, 0.0"), nullptr);
}
2026-04-05 04:55:25 +08:00
TEST(NewEditorXCUILayoutLabRuntimeTest, ScrollViewOffsetsContentAndAddsNestedClips) {
XCEngine::Editor::XCUIBackend::XCUILayoutLabRuntime runtime;
ASSERT_TRUE(runtime.ReloadDocuments());
const auto& frame = runtime.Update(BuildInputState());
ASSERT_TRUE(frame.stats.documentsReady);
XCEngine::UI::UIRect assetListRect = {};
XCEngine::UI::UIRect headerRect = {};
XCEngine::UI::UIRect visibleItemRect = {};
ASSERT_TRUE(runtime.TryGetElementRect("assetList", assetListRect));
ASSERT_TRUE(runtime.TryGetElementRect("assetListHeader", headerRect));
ASSERT_TRUE(runtime.TryGetElementRect("assetLighting", visibleItemRect));
EXPECT_LT(headerRect.y, assetListRect.y);
EXPECT_GT(visibleItemRect.y, assetListRect.y);
EXPECT_LT(visibleItemRect.y, assetListRect.y + assetListRect.height);
EXPECT_EQ(
CountCommandsOfType(frame.drawData, UIDrawCommandType::PushClipRect),
frame.stats.clipPushCommandCount);
EXPECT_EQ(
CountCommandsOfType(frame.drawData, UIDrawCommandType::PopClipRect),
frame.stats.clipPopCommandCount);
EXPECT_GE(frame.stats.clipPushCommandCount, 3u);
EXPECT_GE(frame.stats.clipPopCommandCount, 3u);
}
TEST(NewEditorXCUILayoutLabRuntimeTest, HoverIgnoresClippedScrollViewContent) {
XCEngine::Editor::XCUIBackend::XCUILayoutLabRuntime runtime;
ASSERT_TRUE(runtime.ReloadDocuments());
const auto& baseline = runtime.Update(BuildInputState());
ASSERT_TRUE(baseline.stats.documentsReady);
XCEngine::UI::UIRect assetListRect = {};
ASSERT_TRUE(runtime.TryGetElementRect("assetList", assetListRect));
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState input = BuildInputState();
input.pointerPosition = XCEngine::UI::UIPoint(
assetListRect.x + assetListRect.width * 0.5f,
assetListRect.y + assetListRect.height + 6.0f);
const auto& frame = runtime.Update(input);
ASSERT_TRUE(frame.stats.documentsReady);
EXPECT_TRUE(frame.stats.hoveredElementId.empty());
}
TEST(NewEditorXCUILayoutLabRuntimeTest, ClickSelectionPersistsOnSharedCollectionItems) {
XCEngine::Editor::XCUIBackend::XCUILayoutLabRuntime runtime;
ASSERT_TRUE(runtime.ReloadDocuments());
const auto& baseline = runtime.Update(BuildInputState());
ASSERT_TRUE(baseline.stats.documentsReady);
XCEngine::UI::UIRect targetRect = {};
ASSERT_TRUE(runtime.TryGetElementRect("fieldPosition", targetRect));
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState clickInput = BuildInputState();
clickInput.pointerPosition = XCEngine::UI::UIPoint(
targetRect.x + targetRect.width * 0.5f,
targetRect.y + targetRect.height * 0.5f);
clickInput.pointerPressed = true;
const auto& selectedFrame = runtime.Update(clickInput);
ASSERT_TRUE(selectedFrame.stats.documentsReady);
ASSERT_FALSE(selectedFrame.stats.hoveredElementId.empty());
EXPECT_EQ(
selectedFrame.stats.selectedElementId,
selectedFrame.stats.hoveredElementId);
const std::string selectedElementId = selectedFrame.stats.selectedElementId;
XCEngine::UI::UIRect selectedRect = {};
EXPECT_TRUE(runtime.TryGetElementRect(selectedElementId, selectedRect));
EXPECT_GT(selectedRect.width, 0.0f);
EXPECT_GT(selectedRect.height, 0.0f);
const auto& persistedFrame = runtime.Update(BuildInputState());
ASSERT_TRUE(persistedFrame.stats.documentsReady);
EXPECT_EQ(persistedFrame.stats.selectedElementId, selectedElementId);
}
TEST(NewEditorXCUILayoutLabRuntimeTest, ClickingTreeRootTogglesIndentedChildrenVisibility) {
XCEngine::Editor::XCUIBackend::XCUILayoutLabRuntime runtime;
ASSERT_TRUE(runtime.ReloadDocuments());
const auto& baseline = runtime.Update(BuildInputState());
ASSERT_TRUE(baseline.stats.documentsReady);
EXPECT_EQ(baseline.stats.expandedTreeItemCount, 1u);
XCEngine::UI::UIRect treeRootRect = {};
XCEngine::UI::UIRect treeChildRect = {};
ASSERT_TRUE(runtime.TryGetElementRect("treeAssetsRoot", treeRootRect));
ASSERT_TRUE(runtime.TryGetElementRect("treeScenes", treeChildRect));
ASSERT_GT(treeRootRect.width, 0.0f);
ASSERT_GT(treeRootRect.height, 0.0f);
const XCEngine::UI::UIPoint rootClickPoint(
treeRootRect.x + 18.0f,
treeRootRect.y + treeRootRect.height * 0.5f);
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState hoverInput = BuildInputState();
hoverInput.pointerPosition = rootClickPoint;
const auto& hoveredFrame = runtime.Update(hoverInput);
ASSERT_TRUE(hoveredFrame.stats.documentsReady);
ASSERT_EQ(hoveredFrame.stats.hoveredElementId, "treeAssetsRoot")
<< "treeRootRect=("
<< treeRootRect.x << ", "
<< treeRootRect.y << ", "
<< treeRootRect.width << ", "
<< treeRootRect.height << ")";
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState collapseInput = BuildInputState();
collapseInput.pointerPosition = rootClickPoint;
collapseInput.pointerPressed = true;
const auto& collapsedFrame = runtime.Update(collapseInput);
ASSERT_TRUE(collapsedFrame.stats.documentsReady);
EXPECT_EQ(collapsedFrame.stats.selectedElementId, "treeAssetsRoot");
const auto& collapsedPersistedFrame = runtime.Update(BuildInputState());
ASSERT_TRUE(collapsedPersistedFrame.stats.documentsReady);
EXPECT_EQ(collapsedPersistedFrame.stats.selectedElementId, "treeAssetsRoot");
EXPECT_EQ(collapsedPersistedFrame.stats.expandedTreeItemCount, 0u);
EXPECT_FALSE(runtime.TryGetElementRect("treeScenes", treeChildRect));
ASSERT_TRUE(runtime.TryGetElementRect("treeAssetsRoot", treeRootRect));
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState expandInput = BuildInputState();
expandInput.pointerPosition = XCEngine::UI::UIPoint(
treeRootRect.x + 18.0f,
treeRootRect.y + treeRootRect.height * 0.5f);
expandInput.pointerPressed = true;
const auto& expandedClickFrame = runtime.Update(expandInput);
ASSERT_TRUE(expandedClickFrame.stats.documentsReady);
const auto& expandedFrame = runtime.Update(BuildInputState());
ASSERT_TRUE(expandedFrame.stats.documentsReady);
EXPECT_EQ(expandedFrame.stats.expandedTreeItemCount, 1u);
EXPECT_TRUE(runtime.TryGetElementRect("treeScenes", treeChildRect));
EXPECT_GT(treeChildRect.height, 0.0f);
}
TEST(NewEditorXCUILayoutLabRuntimeTest, ClickingPropertySectionHeaderTogglesFieldVisibility) {
XCEngine::Editor::XCUIBackend::XCUILayoutLabRuntime runtime;
ASSERT_TRUE(runtime.ReloadDocuments());
const auto& baseline = runtime.Update(BuildInputState());
ASSERT_TRUE(baseline.stats.documentsReady);
XCEngine::UI::UIRect sectionRect = {};
XCEngine::UI::UIRect fieldRect = {};
ASSERT_TRUE(runtime.TryGetElementRect("inspectorTransform", sectionRect));
ASSERT_TRUE(runtime.TryGetElementRect("fieldPosition", fieldRect));
const float expandedHeight = sectionRect.height;
const XCEngine::UI::UIPoint sectionHeaderPoint(
sectionRect.x + 18.0f,
sectionRect.y + 10.0f);
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState hoverInput = BuildInputState();
hoverInput.pointerPosition = sectionHeaderPoint;
const auto& hoveredFrame = runtime.Update(hoverInput);
ASSERT_TRUE(hoveredFrame.stats.documentsReady);
ASSERT_EQ(hoveredFrame.stats.hoveredElementId, "inspectorTransform")
<< "sectionRect=("
<< sectionRect.x << ", "
<< sectionRect.y << ", "
<< sectionRect.width << ", "
<< sectionRect.height << "), expandedPropertySectionCount="
<< baseline.stats.expandedPropertySectionCount;
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState collapseInput = BuildInputState();
collapseInput.pointerPosition = sectionHeaderPoint;
collapseInput.pointerPressed = true;
const auto& collapsedFrame = runtime.Update(collapseInput);
ASSERT_TRUE(collapsedFrame.stats.documentsReady);
const auto& collapsedPersistedFrame = runtime.Update(BuildInputState());
ASSERT_TRUE(collapsedPersistedFrame.stats.documentsReady);
EXPECT_EQ(collapsedPersistedFrame.stats.selectedElementId, "inspectorTransform");
ASSERT_TRUE(runtime.TryGetElementRect("inspectorTransform", sectionRect));
EXPECT_LT(sectionRect.height, expandedHeight);
EXPECT_FALSE(runtime.TryGetElementRect("fieldPosition", fieldRect));
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState expandInput = BuildInputState();
expandInput.pointerPosition = XCEngine::UI::UIPoint(
sectionRect.x + 18.0f,
sectionRect.y + 10.0f);
expandInput.pointerPressed = true;
const auto& expandedClickFrame = runtime.Update(expandInput);
ASSERT_TRUE(expandedClickFrame.stats.documentsReady);
const auto& expandedFrame = runtime.Update(BuildInputState());
ASSERT_TRUE(expandedFrame.stats.documentsReady);
EXPECT_TRUE(runtime.TryGetElementRect("fieldPosition", fieldRect));
EXPECT_GT(fieldRect.height, 0.0f);
}
TEST(NewEditorXCUILayoutLabRuntimeTest, KeyboardNavigationMovesSelectionAcrossListItems) {
XCEngine::Editor::XCUIBackend::XCUILayoutLabRuntime runtime;
ASSERT_TRUE(runtime.ReloadDocuments());
const auto& baseline = runtime.Update(BuildInputState());
ASSERT_TRUE(baseline.stats.documentsReady);
XCEngine::UI::UIRect listItemRect = {};
ASSERT_TRUE(runtime.TryGetElementRect("assetLighting", listItemRect));
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState selectInput = BuildInputState();
selectInput.pointerPosition = RectCenter(listItemRect);
selectInput.pointerPressed = true;
const auto& selectedFrame = runtime.Update(selectInput);
ASSERT_TRUE(selectedFrame.stats.documentsReady);
EXPECT_EQ(selectedFrame.stats.selectedElementId, "assetLighting");
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState nextInput = BuildKeyboardInputState();
nextInput.navigateNext = true;
const auto& nextFrame = runtime.Update(nextInput);
ASSERT_TRUE(nextFrame.stats.documentsReady);
EXPECT_EQ(nextFrame.stats.selectedElementId, "assetMaterials");
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState endInput = BuildKeyboardInputState();
endInput.navigateEnd = true;
const auto& endFrame = runtime.Update(endInput);
ASSERT_TRUE(endFrame.stats.documentsReady);
ASSERT_FALSE(endFrame.stats.selectedElementId.empty());
EXPECT_NE(endFrame.stats.selectedElementId, "assetLighting");
const std::string lastListSelection = endFrame.stats.selectedElementId;
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState nextAtEndInput = BuildKeyboardInputState();
nextAtEndInput.navigateNext = true;
const auto& nextAtEndFrame = runtime.Update(nextAtEndInput);
ASSERT_TRUE(nextAtEndFrame.stats.documentsReady);
EXPECT_EQ(nextAtEndFrame.stats.selectedElementId, lastListSelection);
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState homeInput = BuildKeyboardInputState();
homeInput.navigateHome = true;
const auto& homeFrame = runtime.Update(homeInput);
ASSERT_TRUE(homeFrame.stats.documentsReady);
EXPECT_EQ(homeFrame.stats.selectedElementId, "assetLighting");
}
TEST(NewEditorXCUILayoutLabRuntimeTest, KeyboardCollapseAndExpandFollowTreeHierarchy) {
XCEngine::Editor::XCUIBackend::XCUILayoutLabRuntime runtime;
ASSERT_TRUE(runtime.ReloadDocuments());
const auto& baseline = runtime.Update(BuildInputState());
ASSERT_TRUE(baseline.stats.documentsReady);
XCEngine::UI::UIRect treeChildRect = {};
ASSERT_TRUE(runtime.TryGetElementRect("treeScenes", treeChildRect));
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState selectInput = BuildInputState();
selectInput.pointerPosition = RectCenter(treeChildRect);
selectInput.pointerPressed = true;
const auto& selectedFrame = runtime.Update(selectInput);
ASSERT_TRUE(selectedFrame.stats.documentsReady);
EXPECT_EQ(selectedFrame.stats.selectedElementId, "treeScenes");
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState collapseToParent = BuildKeyboardInputState();
collapseToParent.navigateCollapse = true;
const auto& parentFrame = runtime.Update(collapseToParent);
ASSERT_TRUE(parentFrame.stats.documentsReady);
EXPECT_EQ(parentFrame.stats.selectedElementId, "treeAssetsRoot");
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState collapseRoot = BuildKeyboardInputState();
collapseRoot.navigateCollapse = true;
const auto& collapsedFrame = runtime.Update(collapseRoot);
ASSERT_TRUE(collapsedFrame.stats.documentsReady);
EXPECT_EQ(collapsedFrame.stats.selectedElementId, "treeAssetsRoot");
const auto& collapsedPersistedFrame = runtime.Update(BuildKeyboardInputState());
ASSERT_TRUE(collapsedPersistedFrame.stats.documentsReady);
EXPECT_EQ(collapsedPersistedFrame.stats.expandedTreeItemCount, 0u);
EXPECT_FALSE(runtime.TryGetElementRect("treeScenes", treeChildRect));
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState expandRoot = BuildKeyboardInputState();
expandRoot.navigateExpand = true;
const auto& expandedRootFrame = runtime.Update(expandRoot);
ASSERT_TRUE(expandedRootFrame.stats.documentsReady);
EXPECT_EQ(expandedRootFrame.stats.selectedElementId, "treeAssetsRoot");
const auto& expandedPersistedFrame = runtime.Update(BuildKeyboardInputState());
ASSERT_TRUE(expandedPersistedFrame.stats.documentsReady);
EXPECT_EQ(expandedPersistedFrame.stats.expandedTreeItemCount, 1u);
ASSERT_TRUE(runtime.TryGetElementRect("treeScenes", treeChildRect));
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState moveIntoChild = BuildKeyboardInputState();
moveIntoChild.navigateExpand = true;
const auto& childFrame = runtime.Update(moveIntoChild);
ASSERT_TRUE(childFrame.stats.documentsReady);
EXPECT_EQ(childFrame.stats.selectedElementId, "treeScenes");
}
TEST(NewEditorXCUILayoutLabRuntimeTest, KeyboardNavigationTraversesPropertySectionsAndFields) {
XCEngine::Editor::XCUIBackend::XCUILayoutLabRuntime runtime;
ASSERT_TRUE(runtime.ReloadDocuments());
const auto& baseline = runtime.Update(BuildInputState());
ASSERT_TRUE(baseline.stats.documentsReady);
XCEngine::UI::UIRect sectionRect = {};
ASSERT_TRUE(runtime.TryGetElementRect("inspectorTransform", sectionRect));
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState selectInput = BuildInputState();
selectInput.pointerPosition = XCEngine::UI::UIPoint(sectionRect.x + 18.0f, sectionRect.y + 10.0f);
selectInput.pointerPressed = true;
const auto& selectedFrame = runtime.Update(selectInput);
ASSERT_TRUE(selectedFrame.stats.documentsReady);
EXPECT_EQ(selectedFrame.stats.selectedElementId, "inspectorTransform");
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState nextSectionInput = BuildKeyboardInputState();
nextSectionInput.navigateNext = true;
const auto& nextSectionFrame = runtime.Update(nextSectionInput);
ASSERT_TRUE(nextSectionFrame.stats.documentsReady);
EXPECT_EQ(nextSectionFrame.stats.selectedElementId, "inspectorMesh");
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState previousSectionInput = BuildKeyboardInputState();
previousSectionInput.navigatePrevious = true;
const auto& previousSectionFrame = runtime.Update(previousSectionInput);
ASSERT_TRUE(previousSectionFrame.stats.documentsReady);
EXPECT_EQ(previousSectionFrame.stats.selectedElementId, "inspectorTransform");
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState expandIntoFieldsInput = BuildKeyboardInputState();
expandIntoFieldsInput.navigateExpand = true;
const auto& expandedSectionFrame = runtime.Update(expandIntoFieldsInput);
ASSERT_TRUE(expandedSectionFrame.stats.documentsReady);
EXPECT_EQ(expandedSectionFrame.stats.selectedElementId, "inspectorTransform");
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState enterFieldsInput = BuildKeyboardInputState();
enterFieldsInput.navigateExpand = true;
const auto& firstFieldFrame = runtime.Update(enterFieldsInput);
ASSERT_TRUE(firstFieldFrame.stats.documentsReady);
EXPECT_EQ(firstFieldFrame.stats.selectedElementId, "fieldPosition");
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState nextFieldInput = BuildKeyboardInputState();
nextFieldInput.navigateNext = true;
const auto& nextFieldFrame = runtime.Update(nextFieldInput);
ASSERT_TRUE(nextFieldFrame.stats.documentsReady);
EXPECT_EQ(nextFieldFrame.stats.selectedElementId, "fieldRotation");
XCEngine::Editor::XCUIBackend::XCUILayoutLabInputState collapseToSectionInput = BuildKeyboardInputState();
collapseToSectionInput.navigateCollapse = true;
const auto& collapseToSectionFrame = runtime.Update(collapseToSectionInput);
ASSERT_TRUE(collapseToSectionFrame.stats.documentsReady);
EXPECT_EQ(collapseToSectionFrame.stats.selectedElementId, "inspectorTransform");
}