diff options
author | Andy Shaw <andy.shaw@digia.com> | 2013-08-22 14:25:46 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-23 08:42:35 +0200 |
commit | 1baf293548aa859e922dface4cd7b4bac5754b3c (patch) | |
tree | f5eba023471368e6dddc69ff70fe8c7be42711d3 /tests/auto/widgets/dialogs | |
parent | 3abecf2ee9fc724af571f8c7da4302f7bee9eadb (diff) |
Move SnapToDefaultButton from QPlatformDialogHelper to QPlatformTheme
Since QPlatformTheme covers all dialogs whereas QPlatformDialogHelper is
really only for the native dialogs then the SnapToDefaultButton hint is
moved as it has relevance for all dialogs
Task-number: QTBUG-32631
Change-Id: I1dce0bb4abcd4cfd39c4a199a33fc7078176ab4b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'tests/auto/widgets/dialogs')
-rw-r--r-- | tests/auto/widgets/dialogs/qdialog/qdialog.pro | 2 | ||||
-rw-r--r-- | tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp | 33 |
2 files changed, 32 insertions, 3 deletions
diff --git a/tests/auto/widgets/dialogs/qdialog/qdialog.pro b/tests/auto/widgets/dialogs/qdialog/qdialog.pro index 72a2dc52b3..c7917e8ff6 100644 --- a/tests/auto/widgets/dialogs/qdialog/qdialog.pro +++ b/tests/auto/widgets/dialogs/qdialog/qdialog.pro @@ -1,5 +1,5 @@ CONFIG += testcase CONFIG += parallel_test TARGET = tst_qdialog -QT += widgets testlib +QT += widgets testlib gui-private core-private SOURCES += tst_qdialog.cpp diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp index 6d847086d9..1aab794e1b 100644 --- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp +++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp @@ -49,8 +49,10 @@ #include <qstyle.h> #include <QVBoxLayout> #include <QSizeGrip> - - +#include <QDesktopWidget> +#include <private/qguiapplication_p.h> +#include <qpa/qplatformtheme.h> +#include <qpa/qplatformtheme_p.h> QT_FORWARD_DECLARE_CLASS(QDialog) @@ -82,6 +84,7 @@ private slots: #endif void setVisible(); void reject(); + void snapToDefaultButton(); private: QDialog *testWidget; @@ -554,6 +557,32 @@ void tst_QDialog::reject() QCOMPARE(dialog.called, 4); } +void tst_QDialog::snapToDefaultButton() +{ +#ifdef QT_NO_CURSOR + QSKIP("Test relies on there being a cursor"); +#else + QPoint topLeftPos = QApplication::desktop()->availableGeometry().topLeft(); + topLeftPos = QPoint(topLeftPos.x() + 100, topLeftPos.y() + 100); + QPoint startingPos(topLeftPos.x() + 250, topLeftPos.y() + 250); + QCursor::setPos(startingPos); + QVERIFY(QCursor::pos() == startingPos); + QDialog dialog; + QPushButton *button = new QPushButton(&dialog); + button->setDefault(true); + dialog.setGeometry(QRect(topLeftPos, QSize(200, 200))); + 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 { + QVERIFY(startingPos == QCursor::pos()); + } + } +#endif // !QT_NO_CURSOR +} QTEST_MAIN(tst_QDialog) #include "tst_qdialog.moc" |