From d6b9cba812ffc6c191edcc9d578067b374b169af Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Thu, 13 Jul 2017 16:32:53 +0200 Subject: 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 Reviewed-by: Andy Shaw --- .../widgets/widgets/qlineedit/tst_qlineedit.cpp | 24 +++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'tests/auto/widgets/widgets') 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(); -- cgit v1.2.3 From 3761d99512244ae167a66e6894c75eb2ef1cca48 Mon Sep 17 00:00:00 2001 From: Kari Oikarinen Date: Wed, 2 May 2018 11:24:31 +0300 Subject: tst_QTabWidget: Add unconditional qWait() back paintEventCount() is currently flaky on macOS. It gets extra paint events after qWaitForWindowExposed() returns, which causes the following assertions to fail. Add the wait that was removed in 0cb940b1d3b9a1ba50f2d1973fca411706da266d back to fix those failures. Task-number: QTBUG-68032 Change-Id: I68e0b6008de40922ec740291dfdd1842e0f62f89 Reviewed-by: Sami Nurmenniemi Reviewed-by: Richard Moe Gustavsen Reviewed-by: Ville Voutilainen --- tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests/auto/widgets/widgets') diff --git a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp index cd7fe3710d..cbf5196bb9 100644 --- a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp +++ b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp @@ -549,7 +549,9 @@ void tst_QTabWidget::paintEventCount() QCOMPARE(tw->currentIndex(), 0); tw->show(); - QVERIFY(QTest::qWaitForWindowActive(tw)); + QVERIFY(QTest::qWaitForWindowExposed(tw)); + // Wait for extra paint events that happen at least on macOS + QTest::qWait(1000); // Mac, Windows and Windows CE get multiple repaints on the first show, so use those as a starting point. static const int MaxInitialPaintCount = -- cgit v1.2.3