Add XCUI runtime screen layer and demo textarea

This commit is contained in:
2026-04-05 05:14:16 +08:00
parent 67a28bdd4a
commit ade5be31d6
18 changed files with 2042 additions and 37 deletions

View File

@@ -334,3 +334,55 @@ TEST(NewEditorXCUIDemoRuntimeTest, TextFieldAcceptsUtf8CharactersAndBackspace) {
EXPECT_NE(FindTextCommand(backspacedFrame.drawData, "AI"), nullptr);
EXPECT_EQ(backspacedFrame.stats.focusedElementId, "agentPrompt");
}
TEST(NewEditorXCUIDemoRuntimeTest, TextAreaAcceptsMultilineInputAndCaretMovement) {
XCEngine::Editor::XCUIBackend::XCUIDemoRuntime runtime;
ASSERT_TRUE(runtime.ReloadDocuments());
const auto& baselineFrame = runtime.Update(BuildInputState());
ASSERT_TRUE(baselineFrame.stats.documentsReady);
XCEngine::UI::UIRect notesRect = {};
ASSERT_TRUE(runtime.TryGetElementRect("sessionNotes", notesRect));
const XCEngine::UI::UIPoint notesCenter(
notesRect.x + notesRect.width * 0.5f,
notesRect.y + notesRect.height * 0.5f);
XCEngine::Editor::XCUIBackend::XCUIDemoInputState pressedInput = BuildInputState();
pressedInput.pointerPosition = notesCenter;
pressedInput.pointerPressed = true;
pressedInput.pointerDown = true;
runtime.Update(pressedInput);
XCEngine::Editor::XCUIBackend::XCUIDemoInputState releasedInput = BuildInputState();
releasedInput.pointerPosition = notesCenter;
releasedInput.pointerReleased = true;
const auto& focusedFrame = runtime.Update(releasedInput);
ASSERT_TRUE(focusedFrame.stats.documentsReady);
EXPECT_EQ(focusedFrame.stats.focusedElementId, "sessionNotes");
XCEngine::Editor::XCUIBackend::XCUIDemoInputState textInput = BuildInputState();
textInput.events.push_back(MakeCharacterEvent('O'));
textInput.events.push_back(MakeCharacterEvent('K'));
textInput.events.push_back(MakeKeyDownEvent(XCEngine::Input::KeyCode::Enter));
textInput.events.push_back(MakeCharacterEvent('X'));
const auto& typedFrame = runtime.Update(textInput);
ASSERT_TRUE(typedFrame.stats.documentsReady);
EXPECT_EQ(typedFrame.stats.focusedElementId, "sessionNotes");
EXPECT_EQ(typedFrame.stats.lastCommandId, "demo.text.edit.sessionNotes");
EXPECT_NE(FindTextCommand(typedFrame.drawData, "OK"), nullptr);
EXPECT_NE(FindTextCommand(typedFrame.drawData, "X"), nullptr);
XCEngine::Editor::XCUIBackend::XCUIDemoInputState caretInput = BuildInputState();
caretInput.events.push_back(MakeKeyDownEvent(XCEngine::Input::KeyCode::Up));
caretInput.events.push_back(MakeKeyDownEvent(XCEngine::Input::KeyCode::End));
caretInput.events.push_back(MakeCharacterEvent('!'));
const auto& editedFrame = runtime.Update(caretInput);
ASSERT_TRUE(editedFrame.stats.documentsReady);
EXPECT_NE(FindTextCommand(editedFrame.drawData, "OK!"), nullptr);
EXPECT_NE(FindTextCommand(editedFrame.drawData, "X"), nullptr);
EXPECT_EQ(editedFrame.stats.focusedElementId, "sessionNotes");
}