Extract XCUI selection model and layout lab click selection

This commit is contained in:
2026-04-05 07:03:51 +08:00
parent d46dcbfa9e
commit 646e5855ce
10 changed files with 202 additions and 15 deletions

View File

@@ -216,3 +216,37 @@ TEST(NewEditorXCUILayoutLabRuntimeTest, HoverIgnoresClippedScrollViewContent) {
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);
}