summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-02-26 15:58:09 +0100
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-02-26 19:17:19 +0000
commitc3761bf6a74a7ed0dee0e256794672fb73d3276d (patch)
tree4af0504e93bd7cb0d5e2e07141c208a74858acfa /tests/auto
parent9f134750a1ab677cfba4f42fbf72208405e04b84 (diff)
tst_QDialog::snapToDefaultButton(): Do not check on exact cursor position unless hint is set.
Given the flakyness of cursor positioning, loosen the check to only verify that the cursor is outside the window. The hint is only active on Windows depending on a system setting. Task-number: QTBUG-51516 Change-Id: I474d251cc41e68f182baf8dba84eaf38d914d7ee Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
index 37afa7f0a5..438884df33 100644
--- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
+++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
@@ -560,6 +560,11 @@ void tst_QDialog::reject()
QCOMPARE(dialog.called, 4);
}
+static QByteArray formatPoint(QPoint p)
+{
+ return QByteArray::number(p.x()) + ", " + QByteArray::number(p.y());
+}
+
void tst_QDialog::snapToDefaultButton()
{
#ifdef QT_NO_CURSOR
@@ -568,9 +573,9 @@ void tst_QDialog::snapToDefaultButton()
if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: Wayland does not support setting the cursor position.");
- QPoint topLeftPos = QApplication::desktop()->availableGeometry().topLeft();
- topLeftPos = QPoint(topLeftPos.x() + 100, topLeftPos.y() + 100);
- QPoint startingPos(topLeftPos.x() + 250, topLeftPos.y() + 250);
+ const QRect dialogGeometry(QApplication::desktop()->availableGeometry().topLeft()
+ + QPoint(100, 100), QSize(200, 200));
+ const QPoint startingPos = dialogGeometry.bottomRight() + QPoint(100, 100);
QCursor::setPos(startingPos);
#ifdef Q_OS_OSX
// On OS X we use CGEventPost to move the cursor, it needs at least
@@ -581,17 +586,14 @@ void tst_QDialog::snapToDefaultButton()
QDialog dialog;
QPushButton *button = new QPushButton(&dialog);
button->setDefault(true);
- dialog.setGeometry(QRect(topLeftPos, QSize(200, 200)));
+ dialog.setGeometry(dialogGeometry);
dialog.show();
QVERIFY(QTest::qWaitForWindowExposed(&dialog));
- if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
- if (theme->themeHint(QPlatformTheme::DialogSnapToDefaultButton).toBool()) {
- QPoint localPos = button->mapFromGlobal(QCursor::pos());
- QVERIFY(button->rect().contains(localPos));
- } else {
- QCOMPARE(startingPos, QCursor::pos());
- }
- }
+ const QPoint localPos = button->mapFromGlobal(QCursor::pos());
+ if (QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::DialogSnapToDefaultButton).toBool())
+ QVERIFY2(button->rect().contains(localPos), formatPoint(localPos).constData());
+ else
+ QVERIFY2(!button->rect().contains(localPos), formatPoint(localPos).constData());
#endif // !QT_NO_CURSOR
}