Stabilize tst_qmenu on Mac.

Position cursor outside and move once more.

Task-number: QTBUG-33972

Change-Id: If060f1359361981cf1243d8d2a4ebef181689d74
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
This commit is contained in:
Friedemann Kleint 2013-10-14 16:52:34 +03:00 committed by The Qt Project
parent 535e356749
commit 12b68ed072

View File

@ -764,14 +764,20 @@ void tst_QMenu::task258920_mouseBorder()
menu.setMouseTracking(true);
QAction *action = menu.addAction("test");
menu.popup(QApplication::desktop()->availableGeometry().center());
const QPoint center = QApplication::desktop()->availableGeometry().center();
#ifndef QT_NO_CURSOR
QCursor::setPos(center - QPoint(100, 100)); // Mac: Ensure cursor is outside
#endif
menu.popup(center);
QVERIFY(QTest::qWaitForWindowExposed(&menu));
QTest::qWait(100);
QRect actionRect = menu.actionGeometry(action);
QTest::mouseMove(&menu, actionRect.center());
const QPoint actionCenter = actionRect.center();
QTest::mouseMove(&menu, actionCenter - QPoint(-10, 0));
QTest::qWait(30);
QTest::mouseMove(&menu, actionRect.center() + QPoint(10, 0));
QTest::mouseMove(&menu, actionCenter);
QTest::qWait(30);
QTest::mouseMove(&menu, actionCenter + QPoint(10, 0));
QTRY_COMPARE(action, menu.activeAction());
menu.painted = false;
QTest::mouseMove(&menu, QPoint(actionRect.center().x(), actionRect.bottom() + 1));