diff options
Diffstat (limited to 'tests/auto/widgets/kernel/qaction/tst_qaction.cpp')
-rw-r--r-- | tests/auto/widgets/kernel/qaction/tst_qaction.cpp | 68 |
1 files changed, 67 insertions, 1 deletions
diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp index 2eb8c17359..272ec6d60b 100644 --- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp +++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp @@ -26,7 +26,8 @@ ** ****************************************************************************/ - +#include <QDialog> +#include <QMainWindow> #include <QtTest/QtTest> #include <qapplication.h> @@ -62,7 +63,10 @@ private slots: void task229128TriggeredSignalWithoutActiongroup(); void task229128TriggeredSignalWhenInActiongroup(); void repeat(); + void setData(); void keysequence(); // QTBUG-53381 + void disableShortcutsWithBlockedWidgets_data(); + void disableShortcutsWithBlockedWidgets(); private: int m_lastEventType; @@ -443,5 +447,67 @@ void tst_QAction::repeat() QCOMPARE(spy.count(), 2); } +void tst_QAction::setData() // QTBUG-62006 +{ + QAction act(nullptr); + QSignalSpy spy(&act, &QAction::changed); + QCOMPARE(act.data(), QVariant()); + QCOMPARE(spy.count(), 0); + act.setData(QVariant()); + QCOMPARE(spy.count(), 0); + + act.setData(-1); + QCOMPARE(spy.count(), 1); + act.setData(-1); + QCOMPARE(spy.count(), 1); +} + +void tst_QAction::disableShortcutsWithBlockedWidgets_data() +{ + QTest::addColumn<Qt::ShortcutContext>("shortcutContext"); + QTest::addColumn<Qt::WindowModality>("windowModality"); + + QTest::newRow("application modal dialog should block window shortcut.") + << Qt::WindowShortcut << Qt::ApplicationModal; + + QTest::newRow("application modal dialog should block application shortcut.") + << Qt::ApplicationShortcut << Qt::ApplicationModal; + + QTest::newRow("window modal dialog should block application shortcut.") + << Qt::ApplicationShortcut << Qt::WindowModal; + + QTest::newRow("window modal dialog should block window shortcut.") + << Qt::WindowShortcut << Qt::WindowModal; +} + + +void tst_QAction::disableShortcutsWithBlockedWidgets() +{ + QMainWindow window; + + QFETCH(Qt::ShortcutContext, shortcutContext); + QAction action(&window); + window.addAction(&action); + action.setShortcut(QKeySequence(Qt::Key_1)); + action.setShortcutContext(shortcutContext); + + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + + QDialog dialog(&window); + QFETCH(Qt::WindowModality, windowModality); + dialog.setWindowModality(windowModality); + + dialog.show(); + QVERIFY(QTest::qWaitForWindowExposed(&dialog)); + + QApplication::setActiveWindow(&window); + QVERIFY(QTest::qWaitForWindowActive(&window)); + + QSignalSpy spy(&action, &QAction::triggered); + QTest::keyPress(&window, Qt::Key_1); + QCOMPARE(spy.count(), 0); +} + QTEST_MAIN(tst_QAction) #include "tst_qaction.moc" |