diff options
author | Liang Qi <liang.qi@qt.io> | 2017-11-09 11:05:03 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-11-09 11:47:57 +0100 |
commit | 88cf04458002d863750e9121af7dcd9bcbfaa169 (patch) | |
tree | caccae211eef1a27fa5caae3a8403830b615bd5e /tests/auto/widgets/kernel/qaction | |
parent | 19b0ce5daa31e2ffebfcf2701143742302f1deb4 (diff) | |
parent | 579d0cb2bed193ccb1901b121a360f85d1c57a54 (diff) |
Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts:
src/gui/kernel/qwindow.cpp
src/plugins/platforms/cocoa/qcocoawindow.mm
src/plugins/platforms/windows/qwindowssystemtrayicon.cpp
src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
tests/auto/widgets/kernel/qaction/tst_qaction.cpp
Change-Id: Ifa515dc0ece7eb1471b00c1214149629a7e6a233
Diffstat (limited to 'tests/auto/widgets/kernel/qaction')
-rw-r--r-- | tests/auto/widgets/kernel/qaction/tst_qaction.cpp | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp index 4b3db6bd9c..ac0174d19a 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> @@ -64,6 +65,8 @@ private slots: void repeat(); void setData(); void keysequence(); // QTBUG-53381 + void disableShortcutsWithBlockedWidgets_data(); + void disableShortcutsWithBlockedWidgets(); private: int m_lastEventType; @@ -459,5 +462,52 @@ void tst_QAction::setData() // QTBUG-62006 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" |