diff options
author | Daniel Teske <qt@squorn.de> | 2017-07-13 16:32:53 +0200 |
---|---|---|
committer | Daniel Teske <qt@squorn.de> | 2018-04-30 19:00:34 +0000 |
commit | d6b9cba812ffc6c191edcc9d578067b374b169af (patch) | |
tree | 80ef2471426112fc02ad73f52e4d85765d5bf237 /tests/auto/widgets/widgets/qlineedit | |
parent | 578c96f0bbe281f710248f0015ec133fa0083b48 (diff) |
tst_QLineEdit: Use correct keys to move to Start/End of Line
Home/End don't actually work on macOS. The "select all and delete" key
was not actually testing anything at all.
Change-Id: I44d3e9dd27da418afd699bf8720d5369325d20df
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Diffstat (limited to 'tests/auto/widgets/widgets/qlineedit')
-rw-r--r-- | tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 23e52a8bf9..17462a5f86 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -319,6 +319,7 @@ private: void psKeyClick(QWidget *target, Qt::Key key, Qt::KeyboardModifiers pressState = 0); void psKeyClick(QTestEventList &keys, Qt::Key key, Qt::KeyboardModifiers pressState = 0); bool unselectingWithLeftOrRightChangesCursorPosition(); + void addKeySequenceStandardKey(QTestEventList &keys, QKeySequence::StandardKey); QLineEdit *ensureTestWidget(); bool validInput; @@ -724,7 +725,7 @@ void tst_QLineEdit::keypress_inputMask_data() { QTestEventList keys; // inserting 'A1.2B' - keys.addKeyClick(Qt::Key_Home); + addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine); keys.addKeyClick(Qt::Key_A); keys.addKeyClick(Qt::Key_1); keys.addKeyClick(Qt::Key_Period); @@ -735,7 +736,7 @@ void tst_QLineEdit::keypress_inputMask_data() { QTestEventList keys; // inserting 'A1.2B' - keys.addKeyClick(Qt::Key_Home); + addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine); keys.addKeyClick(Qt::Key_0); keys.addKeyClick(Qt::Key_Exclam); keys.addKeyClick('P'); @@ -745,22 +746,24 @@ void tst_QLineEdit::keypress_inputMask_data() { QTestEventList keys; // pressing delete - keys.addKeyClick(Qt::Key_Home); + addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine); keys.addKeyClick(Qt::Key_Delete); QTest::newRow("delete") << QString("000.000;_") << keys << QString(".") << QString("___.___"); } { QTestEventList keys; // selecting all and delete - keys.addKeyClick(Qt::Key_Home); - keys.addKeyClick(Qt::Key_End, Qt::ShiftModifier); + keys.addKeyClick(Qt::Key_1); + keys.addKeyClick(Qt::Key_2); + addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine); + addKeySequenceStandardKey(keys, QKeySequence::SelectEndOfLine); keys.addKeyClick(Qt::Key_Delete); QTest::newRow("deleting all") << QString("000.000;_") << keys << QString(".") << QString("___.___"); } { QTestEventList keys; // inserting '12.12' then two backspaces - keys.addKeyClick(Qt::Key_Home); + addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine); keys.addKeyClick(Qt::Key_1); keys.addKeyClick(Qt::Key_2); keys.addKeyClick(Qt::Key_Period); @@ -773,7 +776,7 @@ void tst_QLineEdit::keypress_inputMask_data() { QTestEventList keys; // inserting '12ab' - keys.addKeyClick(Qt::Key_Home); + addKeySequenceStandardKey(keys, QKeySequence::MoveToStartOfLine); keys.addKeyClick(Qt::Key_1); keys.addKeyClick(Qt::Key_2); keys.addKeyClick(Qt::Key_A); @@ -1971,6 +1974,13 @@ void tst_QLineEdit::psKeyClick(QTestEventList &keys, Qt::Key key, Qt::KeyboardMo keys.addKeyClick(key, pressState); } +void tst_QLineEdit::addKeySequenceStandardKey(QTestEventList &keys, QKeySequence::StandardKey key) +{ + QKeySequence keyseq = QKeySequence(key); + for (int i = 0; i < keyseq.count(); ++i) + keys.addKeyClick( Qt::Key( keyseq[i] & ~Qt::KeyboardModifierMask), Qt::KeyboardModifier(keyseq[i] & Qt::KeyboardModifierMask) ); +} + void tst_QLineEdit::cursorPosition() { QLineEdit *testWidget = ensureTestWidget(); |