- PointerTracker: per-finger gesture state machine (pure, unit-tested) - AlternatesPicker + AlternatesPopup.qml: long-press choices, finger selects - Space long-press trackpad moves the cursor with arrow keysyms - Slide from .?123 onto a symbol types it and switches back - New finger commits pending taps (iOS rollover) - Flick animation: secondary symbol slides down as the finger moves - Transparent popup margin with an input region that passes clicks through - tst_keyboardsurface: end-to-end gesture tests on the real QML Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
53 lines
1.5 KiB
C++
53 lines
1.5 KiB
C++
#include "input/AlternatesPicker.h"
|
|
|
|
#include <QTest>
|
|
|
|
using namespace Qt::StringLiterals;
|
|
|
|
class TestAlternatesPicker : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
private Q_SLOTS:
|
|
void opensAboveKeyExtendingRight()
|
|
{
|
|
AlternatesPicker picker;
|
|
picker.open(QRectF(100, 100, 50, 60), {u"é"_s, u"è"_s, u"ê"_s}, 1000, 8);
|
|
QVERIFY(picker.isOpen());
|
|
QCOMPARE(picker.rect(), QRectF(100, 32, 150, 60));
|
|
QCOMPARE(picker.selectedText(), u"é");
|
|
}
|
|
|
|
void staysInsideRightEdgeAndSelectsUnderFinger()
|
|
{
|
|
AlternatesPicker picker;
|
|
picker.open(QRectF(900, 100, 50, 60), {u"a"_s, u"b"_s, u"c"_s}, 1000, 8);
|
|
QCOMPARE(picker.rect().left(), 850.0);
|
|
QCOMPARE(picker.selectedText(), u"b"); // key center x=925 lies over the second cell
|
|
}
|
|
|
|
void selectionFollowsFingerAndClamps()
|
|
{
|
|
AlternatesPicker picker;
|
|
picker.open(QRectF(100, 100, 50, 60), {u"a"_s, u"b"_s, u"c"_s}, 1000, 8);
|
|
picker.selectAt(210);
|
|
QCOMPARE(picker.selected(), 2);
|
|
picker.selectAt(-50);
|
|
QCOMPARE(picker.selected(), 0);
|
|
picker.selectAt(5000);
|
|
QCOMPARE(picker.selected(), 2);
|
|
}
|
|
|
|
void closeClears()
|
|
{
|
|
AlternatesPicker picker;
|
|
picker.open(QRectF(0, 0, 10, 10), {u"a"_s}, 100, 0);
|
|
picker.close();
|
|
QVERIFY(!picker.isOpen());
|
|
QVERIFY(picker.selectedText().isEmpty());
|
|
}
|
|
};
|
|
|
|
QTEST_GUILESS_MAIN(TestAlternatesPicker)
|
|
#include "tst_alternatespicker.moc"
|