tst_QDialog::snapToDefaultButton - tune the test for OS X

QCursor::setPos with Cocoa integration is calling CGEventPost. Some time is required
before the cursor position is really set, so we can not immediately call QCOMPARE.

Change-Id: I83a4c13f06ec151a4b9ab18c83de1eb5247ea9cc
Task-number: QTBUG-45553
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
Reviewed-by: Caroline Chao <caroline.chao@theqtcompany.com>
This commit is contained in:
Timur Pocheptsov 2015-05-13 09:55:03 +02:00 committed by Caroline Chao
parent 1842322b2b
commit 1485c2f3fa

View File

@ -564,6 +564,11 @@ void tst_QDialog::snapToDefaultButton()
topLeftPos = QPoint(topLeftPos.x() + 100, topLeftPos.y() + 100);
QPoint startingPos(topLeftPos.x() + 250, topLeftPos.y() + 250);
QCursor::setPos(startingPos);
#ifdef Q_OS_OSX
// On OS X we use CGEventPost to move the cursor, it needs at least
// some time before the event handled and the position really set.
QTest::qWait(100);
#endif
QCOMPARE(QCursor::pos(), startingPos);
QDialog dialog;
QPushButton *button = new QPushButton(&dialog);