From 2eabdfaef79e21034209014d462c009d1153a220 Mon Sep 17 00:00:00 2001 From: JavaZeroo <71128095+JavaZeroo@users.noreply.github.com> Date: Fri, 30 Oct 2026 04:46:17 +0800 Subject: [PATCH 1/3] test(qt): assert input-method composition, commit and cancel behaviour refs #155 The smoke test now sends a preedit, a commit and a cancelled preedit through QInputMethodEvent and asserts that only the committed text reaches the session. --- src/qt/shell_smoke.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/qt/shell_smoke.cpp b/src/qt/shell_smoke.cpp index 7f25cc78..828a4705 100644 --- a/src/qt/shell_smoke.cpp +++ b/src/qt/shell_smoke.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -357,6 +358,29 @@ int main(int argc, char** argv) { const QRect cell(8 + column * cell_width, 8 + answer_row * cell_height, cell_width, cell_height); require(result.copy(cell) != prompt.copy(cell), "arithmetic answer cell has no new rendered ink"); } + // #155: composition must stay a preview, a commit must reach the + // session, and cancelling (empty preedit) must write nothing. + { + QInputMethodEvent composing; + composing.setPreeditString(QStringLiteral("tfime_preedit"), 0); + QApplication::sendEvent(&window, &composing); + QApplication::processEvents(); + require(!has_text(model.screen(), "tfime_preedit"), "preedit text reached the session"); + QInputMethodEvent committed; + committed.setCommitString(QStringLiteral("TFIME_COMMIT")); + QApplication::sendEvent(&window, &committed); + await([&] { return has_text(model.screen(), "TFIME_COMMIT"); }, model, + "committed input-method text did not reach the session"); + QInputMethodEvent cancelling; + cancelling.setPreeditString(QStringLiteral("tfime_cancel"), 0); + QApplication::sendEvent(&window, &cancelling); + QInputMethodEvent cleared; + cleared.setPreeditString(QString(), 0); + QApplication::sendEvent(&window, &cleared); + QApplication::processEvents(); + require(!has_text(model.screen(), "tfime_cancel"), "cancelled preedit reached the session"); + require(has_text(model.screen(), "TFIME_COMMIT"), "cancel removed already committed text"); + } QTest::keyClicks(&window, QStringLiteral("exit 37")); QTest::keyClick(&window, Qt::Key_Return); await([&] { return model.finished(); }, model, "cmd exit and output drain did not finish"); From 50d8ae2bdf48b82890baa95d1fcfcbf5b148587a Mon Sep 17 00:00:00 2001 From: JavaZeroo <71128095+JavaZeroo@users.noreply.github.com> Date: Fri, 30 Oct 2026 04:48:50 +0800 Subject: [PATCH 2/3] test(qt): construct IME preedit events through the Qt 6 constructor refs #155 QInputMethodEvent no longer exposes setPreeditString; the smoke test builds preedit events with the constructor instead. --- src/qt/shell_smoke.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/qt/shell_smoke.cpp b/src/qt/shell_smoke.cpp index 828a4705..ab2aae5c 100644 --- a/src/qt/shell_smoke.cpp +++ b/src/qt/shell_smoke.cpp @@ -361,8 +361,7 @@ int main(int argc, char** argv) { // #155: composition must stay a preview, a commit must reach the // session, and cancelling (empty preedit) must write nothing. { - QInputMethodEvent composing; - composing.setPreeditString(QStringLiteral("tfime_preedit"), 0); + QInputMethodEvent composing(QStringLiteral("tfime_preedit"), {}); QApplication::sendEvent(&window, &composing); QApplication::processEvents(); require(!has_text(model.screen(), "tfime_preedit"), "preedit text reached the session"); @@ -371,11 +370,9 @@ int main(int argc, char** argv) { QApplication::sendEvent(&window, &committed); await([&] { return has_text(model.screen(), "TFIME_COMMIT"); }, model, "committed input-method text did not reach the session"); - QInputMethodEvent cancelling; - cancelling.setPreeditString(QStringLiteral("tfime_cancel"), 0); + QInputMethodEvent cancelling(QStringLiteral("tfime_cancel"), {}); QApplication::sendEvent(&window, &cancelling); - QInputMethodEvent cleared; - cleared.setPreeditString(QString(), 0); + QInputMethodEvent cleared(QString(), {}); QApplication::sendEvent(&window, &cleared); QApplication::processEvents(); require(!has_text(model.screen(), "tfime_cancel"), "cancelled preedit reached the session"); From aff31f0fbf00bd5b5e875f2aa5effb75b95caa4d Mon Sep 17 00:00:00 2001 From: JavaZeroo <71128095+JavaZeroo@users.noreply.github.com> Date: Fri, 30 Oct 2026 04:51:46 +0800 Subject: [PATCH 3/3] test(qt): erase the committed IME text before the exit command refs #155 The commit path leaves text in cmd's line editor; the smoke test now backspaces it away and asserts the line is clean before typing exit. --- src/qt/shell_smoke.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/qt/shell_smoke.cpp b/src/qt/shell_smoke.cpp index ab2aae5c..ef0c6ad3 100644 --- a/src/qt/shell_smoke.cpp +++ b/src/qt/shell_smoke.cpp @@ -377,6 +377,12 @@ int main(int argc, char** argv) { QApplication::processEvents(); require(!has_text(model.screen(), "tfime_cancel"), "cancelled preedit reached the session"); require(has_text(model.screen(), "TFIME_COMMIT"), "cancel removed already committed text"); + // The commit wrote into cmd's line editor without running it; erase + // it so the following exit command is not prefixed by that text. + for (int i = 0; i < static_cast(QStringLiteral("TFIME_COMMIT").size()); ++i) + QTest::keyClick(&window, Qt::Key_Backspace); + await([&] { return !has_text(model.screen(), "TFIME_COMMIT"); }, model, + "committed text was not erased from the shell line"); } QTest::keyClicks(&window, QStringLiteral("exit 37")); QTest::keyClick(&window, Qt::Key_Return);