Stabilize XCUI demo runtime editing tests
This commit is contained in:
@@ -185,6 +185,13 @@ TEST(NewEditorXCUIDemoRuntimeTest, RuntimeFrameEmitsTextCommandsWithResolvedFont
|
|||||||
const UIDrawCommand* buttonLabelCommand = FindTextCommand(frame.drawData, "Toggle Accent");
|
const UIDrawCommand* buttonLabelCommand = FindTextCommand(frame.drawData, "Toggle Accent");
|
||||||
ASSERT_NE(buttonLabelCommand, nullptr);
|
ASSERT_NE(buttonLabelCommand, nullptr);
|
||||||
EXPECT_FLOAT_EQ(buttonLabelCommand->fontSize, 14.0f);
|
EXPECT_FLOAT_EQ(buttonLabelCommand->fontSize, 14.0f);
|
||||||
|
|
||||||
|
EXPECT_NE(
|
||||||
|
FindTextCommand(frame.drawData, "Single-line input, Enter submits, 0 chars"),
|
||||||
|
nullptr);
|
||||||
|
EXPECT_NE(
|
||||||
|
FindTextCommand(frame.drawData, "Multiline input, click caret, Tab indent, 1 lines"),
|
||||||
|
nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(NewEditorXCUIDemoRuntimeTest, InputStateTransitionsAreAcceptedAndFrameStillBuilds) {
|
TEST(NewEditorXCUIDemoRuntimeTest, InputStateTransitionsAreAcceptedAndFrameStillBuilds) {
|
||||||
@@ -386,39 +393,64 @@ TEST(NewEditorXCUIDemoRuntimeTest, TextAreaAcceptsMultilineInputAndCaretMovement
|
|||||||
EXPECT_NE(FindTextCommand(typedFrame.drawData, "2"), nullptr);
|
EXPECT_NE(FindTextCommand(typedFrame.drawData, "2"), nullptr);
|
||||||
EXPECT_NE(FindTextCommand(typedFrame.drawData, "OK"), nullptr);
|
EXPECT_NE(FindTextCommand(typedFrame.drawData, "OK"), nullptr);
|
||||||
EXPECT_NE(FindTextCommand(typedFrame.drawData, "X"), nullptr);
|
EXPECT_NE(FindTextCommand(typedFrame.drawData, "X"), nullptr);
|
||||||
|
EXPECT_NE(
|
||||||
|
FindTextCommand(typedFrame.drawData, "Multiline input, click caret, Tab indent, 2 lines"),
|
||||||
|
nullptr);
|
||||||
|
|
||||||
|
const UIDrawCommand* secondLineText = FindTextCommand(typedFrame.drawData, "X");
|
||||||
|
ASSERT_NE(secondLineText, nullptr);
|
||||||
|
|
||||||
|
XCEngine::Editor::XCUIBackend::XCUIDemoInputState secondLinePressed = BuildInputState();
|
||||||
|
secondLinePressed.pointerPosition = XCEngine::UI::UIPoint(
|
||||||
|
secondLineText->position.x + 1.0f,
|
||||||
|
secondLineText->position.y + secondLineText->fontSize * 0.5f);
|
||||||
|
secondLinePressed.pointerPressed = true;
|
||||||
|
secondLinePressed.pointerDown = true;
|
||||||
|
runtime.Update(secondLinePressed);
|
||||||
|
|
||||||
|
XCEngine::Editor::XCUIBackend::XCUIDemoInputState secondLineReleased = BuildInputState();
|
||||||
|
secondLineReleased.pointerPosition = secondLinePressed.pointerPosition;
|
||||||
|
secondLineReleased.pointerReleased = true;
|
||||||
|
const auto& secondLineCaretFrame = runtime.Update(secondLineReleased);
|
||||||
|
|
||||||
|
ASSERT_TRUE(secondLineCaretFrame.stats.documentsReady);
|
||||||
|
EXPECT_EQ(secondLineCaretFrame.stats.focusedElementId, "sessionNotes");
|
||||||
|
|
||||||
XCEngine::Editor::XCUIBackend::XCUIDemoInputState tabInput = BuildInputState();
|
XCEngine::Editor::XCUIBackend::XCUIDemoInputState tabInput = BuildInputState();
|
||||||
tabInput.events.push_back(MakeKeyDownEvent(XCEngine::Input::KeyCode::Home));
|
|
||||||
tabInput.events.push_back(MakeKeyDownEvent(XCEngine::Input::KeyCode::Tab));
|
tabInput.events.push_back(MakeKeyDownEvent(XCEngine::Input::KeyCode::Tab));
|
||||||
const auto& indentedFrame = runtime.Update(tabInput);
|
const auto& indentedFrame = runtime.Update(tabInput);
|
||||||
|
|
||||||
ASSERT_TRUE(indentedFrame.stats.documentsReady);
|
ASSERT_TRUE(indentedFrame.stats.documentsReady);
|
||||||
EXPECT_EQ(indentedFrame.stats.focusedElementId, "sessionNotes");
|
EXPECT_EQ(indentedFrame.stats.focusedElementId, "sessionNotes");
|
||||||
EXPECT_EQ(indentedFrame.stats.lastCommandId, "demo.text.edit.sessionNotes");
|
EXPECT_EQ(indentedFrame.stats.lastCommandId, "demo.text.edit.sessionNotes");
|
||||||
|
EXPECT_NE(FindTextCommand(indentedFrame.drawData, "OK"), nullptr);
|
||||||
|
EXPECT_NE(FindTextCommand(indentedFrame.drawData, " X"), nullptr);
|
||||||
|
|
||||||
const XCEngine::UI::UIPoint firstLineStart(
|
const UIDrawCommand* firstLineText = FindTextCommand(indentedFrame.drawData, "OK");
|
||||||
notesRect.x + 8.0f,
|
ASSERT_NE(firstLineText, nullptr);
|
||||||
notesRect.y + 10.0f);
|
|
||||||
|
|
||||||
XCEngine::Editor::XCUIBackend::XCUIDemoInputState caretPressed = BuildInputState();
|
XCEngine::Editor::XCUIBackend::XCUIDemoInputState firstLinePressed = BuildInputState();
|
||||||
caretPressed.pointerPosition = firstLineStart;
|
firstLinePressed.pointerPosition = XCEngine::UI::UIPoint(
|
||||||
caretPressed.pointerPressed = true;
|
firstLineText->position.x + 1.0f,
|
||||||
caretPressed.pointerDown = true;
|
firstLineText->position.y + firstLineText->fontSize * 0.5f);
|
||||||
runtime.Update(caretPressed);
|
firstLinePressed.pointerPressed = true;
|
||||||
|
firstLinePressed.pointerDown = true;
|
||||||
|
runtime.Update(firstLinePressed);
|
||||||
|
|
||||||
XCEngine::Editor::XCUIBackend::XCUIDemoInputState caretReleased = BuildInputState();
|
XCEngine::Editor::XCUIBackend::XCUIDemoInputState firstLineReleased = BuildInputState();
|
||||||
caretReleased.pointerPosition = firstLineStart;
|
firstLineReleased.pointerPosition = firstLinePressed.pointerPosition;
|
||||||
caretReleased.pointerReleased = true;
|
firstLineReleased.pointerReleased = true;
|
||||||
const auto& caretFrame = runtime.Update(caretReleased);
|
const auto& caretFrame = runtime.Update(firstLineReleased);
|
||||||
|
|
||||||
ASSERT_TRUE(caretFrame.stats.documentsReady);
|
ASSERT_TRUE(caretFrame.stats.documentsReady);
|
||||||
EXPECT_EQ(caretFrame.stats.focusedElementId, "sessionNotes");
|
EXPECT_EQ(caretFrame.stats.focusedElementId, "sessionNotes");
|
||||||
|
|
||||||
XCEngine::Editor::XCUIBackend::XCUIDemoInputState caretInput = BuildInputState();
|
XCEngine::Editor::XCUIBackend::XCUIDemoInputState editInput = BuildInputState();
|
||||||
caretInput.events.push_back(MakeCharacterEvent('!'));
|
editInput.events.push_back(MakeCharacterEvent('!'));
|
||||||
const auto& editedFrame = runtime.Update(caretInput);
|
const auto& editedFrame = runtime.Update(editInput);
|
||||||
|
|
||||||
ASSERT_TRUE(editedFrame.stats.documentsReady);
|
ASSERT_TRUE(editedFrame.stats.documentsReady);
|
||||||
EXPECT_NE(FindTextCommand(editedFrame.drawData, "!OK"), nullptr);
|
EXPECT_NE(FindTextCommand(editedFrame.drawData, "!OK"), nullptr);
|
||||||
|
EXPECT_NE(FindTextCommand(editedFrame.drawData, " X"), nullptr);
|
||||||
EXPECT_EQ(editedFrame.stats.focusedElementId, "sessionNotes");
|
EXPECT_EQ(editedFrame.stats.focusedElementId, "sessionNotes");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user