diff --git a/src/qt/shell_smoke.cpp b/src/qt/shell_smoke.cpp index 7f25cc78..ef0c6ad3 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,32 @@ 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(QStringLiteral("tfime_preedit"), {}); + 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(QStringLiteral("tfime_cancel"), {}); + QApplication::sendEvent(&window, &cancelling); + QInputMethodEvent cleared(QString(), {}); + 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"); + // 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); await([&] { return model.finished(); }, model, "cmd exit and output drain did not finish");