Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/qt/shell_smoke.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <QApplication>
#include <QElapsedTimer>
#include <QImage>
#include <QInputMethodEvent>
#include <QFontMetricsF>
#include <QTemporaryDir>
#include <QTest>
Expand Down Expand Up @@ -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<int>(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");
}
Comment on lines +379 to +386

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Clear committed IME input before sending the exit command

In the Windows cmd smoke test, TFIME_COMMIT is committed without a Return or any subsequent line clearing, so it remains in cmd's current input buffer. The existing keyClicks("exit 37") then appends to it, executing TFIME_COMMITexit 37 rather than exiting. Consequently, the natural-exit wait times out and none of the subsequent lifecycle scenarios run. After checking cancellation, clear the pending command line before sending exit 37.

Useful? React with 👍 / 👎.

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");
Expand Down