Files
sloposk/tests/tst_deadkeys.cpp
T
ericek111andClaude Opus 5.5 536fc12d2f Dead keys: act on compose status at press time
- Two dead keys that compose (´´ → ´) type the result right away; a dead
  key that can't continue the sequence types the old accents and starts anew
- With Ctrl/Alt/Super, a dead key sends its dead keysym, as the physical
  key does, not the spacing accent from its label

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 10:13:49 +02:00

54 lines
1.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "input/DeadKeys.h"
#include <QTest>
#include <xkbcommon/xkbcommon-keysyms.h>
using namespace Qt::StringLiterals;
class TestDeadKeys : public QObject
{
Q_OBJECT
private Q_SLOTS:
void composesWithTheNextLetter()
{
DeadKeys dead(u"en_US.UTF-8"_s);
QVERIFY(!dead.isPending());
dead.press(XKB_KEY_dead_acute);
QVERIFY(dead.isPending());
QCOMPARE(dead.compose(u"e"_s), u"é");
QVERIFY(!dead.isPending());
dead.press(XKB_KEY_dead_caron);
QCOMPARE(dead.compose(u"C"_s), u"Č");
}
void typesAccentAndLetterWhenNothingComposes()
{
DeadKeys dead(u"en_US.UTF-8"_s);
dead.press(XKB_KEY_dead_caron);
QCOMPARE(dead.compose(u"q"_s), u"ˇq");
}
void twoDeadKeysComposeAtOnce()
{
DeadKeys dead(u"en_US.UTF-8"_s);
QVERIFY(dead.press(XKB_KEY_dead_acute).isEmpty());
QCOMPARE(dead.press(XKB_KEY_dead_acute), u"´");
QVERIFY(!dead.isPending());
dead.press(XKB_KEY_dead_acute); // a fresh sequence
QCOMPARE(dead.compose(u"e"_s), u"é");
}
void cancelForgetsTheAccent()
{
DeadKeys dead(u"en_US.UTF-8"_s);
dead.press(XKB_KEY_dead_acute);
dead.cancel();
QVERIFY(!dead.isPending());
}
};
QTEST_GUILESS_MAIN(TestDeadKeys)
#include "tst_deadkeys.moc"