diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2013-10-10 13:57:57 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-10-11 18:47:27 +0200 |
commit | 2b8e571f8458a533d1b902fff5a812db427b7da0 (patch) | |
tree | 7997166bbe3a8a6867c2d10c72ef163200951a2d /tests | |
parent | 65855d9d68255a50d5f1336c7b9be1f079bf3cc5 (diff) |
Stabilize tst_QComboBox::keyBoardNavigationWithMouse.
The cursor needs to be within the view from start on Mac.
Task-number: QTBUG-33973
Change-Id: I313c9fd1c3a917e135a92497f1818d1b0d8b7698
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 4631154230..eabb7aaa17 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -2587,6 +2587,18 @@ void tst_QComboBox::resetModel() } +static inline void centerCursor(const QWidget *w) +{ +#ifndef QT_NO_CURSOR + // Force cursor movement to prevent QCursor::setPos() from returning prematurely on QPA: + const QPoint target(w->mapToGlobal(w->rect().center())); + QCursor::setPos(QPoint(target.x() + 1, target.y())); + QCursor::setPos(target); +#else // !QT_NO_CURSOR + Q_UNUSED(w) +#endif +} + void tst_QComboBox::keyBoardNavigationWithMouse() { QComboBox combo; @@ -2597,6 +2609,7 @@ void tst_QComboBox::keyBoardNavigationWithMouse() combo.addItem( QString::number(i)); combo.show(); + centerCursor(&combo); // QTBUG-33973, cursor needs to be within view from start on Mac. QApplication::setActiveWindow(&combo); QVERIFY(QTest::qWaitForWindowActive(&combo)); QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&combo)); @@ -2617,10 +2630,7 @@ void tst_QComboBox::keyBoardNavigationWithMouse() // When calling cursor function, Windows CE responds with: This function is not supported on this system. #ifndef Q_OS_WINCE // Force cursor movement to prevent QCursor::setPos() from returning prematurely on QPA: - const QPoint target(combo.view()->mapToGlobal(combo.view()->rect().center())); - QCursor::setPos(QPoint(target.x() + 1, target.y())); - QCursor::setPos(target); - + centerCursor(combo.view()); QTest::qWait(200); #define GET_SELECTION(SEL) \ @@ -2632,7 +2642,7 @@ void tst_QComboBox::keyBoardNavigationWithMouse() GET_SELECTION(selection); //since we moved the mouse is in the middle it should even be around 5; - QVERIFY(selection > 3); + QVERIFY2(selection > 3, (QByteArrayLiteral("selection=") + QByteArray::number(selection)).constData()); static const int final = 40; for (int i = selection + 1; i <= final; i++) |