diff options
Diffstat (limited to 'tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp')
-rw-r--r-- | tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp index a23938959b..37afa7f0a5 100644 --- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp +++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp @@ -42,6 +42,8 @@ #include <QVBoxLayout> #include <QSizeGrip> #include <QDesktopWidget> +#include <QGraphicsProxyWidget> +#include <QGraphicsView> #include <QWindow> #include <private/qguiapplication_p.h> #include <qpa/qplatformtheme.h> @@ -88,6 +90,7 @@ private slots: void snapToDefaultButton(); void transientParent_data(); void transientParent(); + void dialogInGraphicsView(); private: DummyDialog *testWidget; @@ -119,9 +122,11 @@ void tst_QDialog::getSetCheck() class ToolDialog : public QDialog { public: - ToolDialog(QWidget *parent = 0) : QDialog(parent, Qt::Tool), mWasActive(false), tId(-1) { - } + ToolDialog(QWidget *parent = 0) + : QDialog(parent, Qt::Tool), mWasActive(false), mWasModalWindow(false), tId(-1) {} + bool wasActive() const { return mWasActive; } + bool wasModalWindow() const { return mWasModalWindow; } int exec() { tId = startTimer(300); @@ -132,12 +137,14 @@ protected: if (tId == event->timerId()) { killTimer(tId); mWasActive = isActiveWindow(); + mWasModalWindow = QGuiApplication::modalWindow() == windowHandle(); reject(); } } private: int mWasActive; + bool mWasModalWindow; int tId; }; @@ -558,7 +565,7 @@ void tst_QDialog::snapToDefaultButton() #ifdef QT_NO_CURSOR QSKIP("Test relies on there being a cursor"); #else - if (qApp->platformName().toLower() == QLatin1String("wayland")) + if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive)) QSKIP("Wayland: Wayland does not support setting the cursor position."); QPoint topLeftPos = QApplication::desktop()->availableGeometry().topLeft(); @@ -617,5 +624,27 @@ void tst_QDialog::transientParent() QCOMPARE(dialog.windowHandle()->transientParent(), topLevel.windowHandle()); } +void tst_QDialog::dialogInGraphicsView() +{ + // QTBUG-49124: A dialog embedded into QGraphicsView has Qt::WA_DontShowOnScreen + // set (as has a native dialog). It must not trigger the modal handling though + // as not to lock up. + QGraphicsScene scene; + QGraphicsView view(&scene); + view.setWindowTitle(QTest::currentTestFunction()); + const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); + view.resize(availableGeometry.size() / 2); + view.move(availableGeometry.left() + availableGeometry.width() / 4, + availableGeometry.top() + availableGeometry.height() / 4); + ToolDialog *dialog = new ToolDialog; + scene.addWidget(dialog); + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + for (int i = 0; i < 3; ++i) { + dialog->exec(); + QVERIFY(!dialog->wasModalWindow()); + } +} + QTEST_MAIN(tst_QDialog) #include "tst_qdialog.moc" |