summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/kernel/qaction/tst_qaction.cpp')
-rw-r--r--tests/auto/widgets/kernel/qaction/tst_qaction.cpp58
1 files changed, 29 insertions, 29 deletions
diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
index f1f2fbc1d8..2820fd710b 100644
--- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
+++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QDialog>
#include <QMainWindow>
@@ -113,7 +113,6 @@ void tst_QAction::actionEvent()
// add action
MyWidget testWidget(this);
testWidget.show();
- QApplicationPrivate::setActiveWindow(&testWidget);
testWidget.addAction(&a);
qApp->processEvents();
@@ -155,11 +154,11 @@ void tst_QAction::alternateShortcuts()
act.setAutoRepeat(true);
QTest::keyClick(&testWidget, Qt::Key_A, Qt::ControlModifier);
- QCOMPARE(spy.count(), 1); //act should have been triggered
+ QCOMPARE(spy.size(), 1); //act should have been triggered
act.setAutoRepeat(false);
QTest::keyClick(&testWidget, Qt::Key_A, Qt::ControlModifier);
- QCOMPARE(spy.count(), 2); //act should have been triggered a 2nd time
+ QCOMPARE(spy.size(), 2); //act should have been triggered a 2nd time
//end of the scope of the action, it will be destroyed and removed from wid
//This action should also unregister its shortcuts
@@ -189,12 +188,12 @@ void tst_QAction::keysequence()
act.setAutoRepeat(true);
QTest::keySequence(&testWidget, ks);
QCoreApplication::processEvents();
- QCOMPARE(spy.count(), 1); // act should have been triggered
+ QCOMPARE(spy.size(), 1); // act should have been triggered
act.setAutoRepeat(false);
QTest::keySequence(&testWidget, ks);
QCoreApplication::processEvents();
- QCOMPARE(spy.count(), 2); //act should have been triggered a 2nd time
+ QCOMPARE(spy.size(), 2); //act should have been triggered a 2nd time
// end of the scope of the action, it will be destroyed and removed from widget
// This action should also unregister its shortcuts
@@ -230,15 +229,15 @@ void tst_QAction::enabledVisibleInteraction()
act.setEnabled(true);
act.setVisible(false);
QTest::keyClick(&testWidget, Qt::Key_T, Qt::ControlModifier);
- QCOMPARE(spy.count(), 0); //act is not visible, so don't trigger
+ QCOMPARE(spy.size(), 0); //act is not visible, so don't trigger
act.setVisible(false);
act.setEnabled(true);
QTest::keyClick(&testWidget, Qt::Key_T, Qt::ControlModifier);
- QCOMPARE(spy.count(), 0); //act is not visible, so don't trigger
+ QCOMPARE(spy.size(), 0); //act is not visible, so don't trigger
act.setVisible(true);
act.setEnabled(true);
QTest::keyClick(&testWidget, Qt::Key_T, Qt::ControlModifier);
- QCOMPARE(spy.count(), 1); //act is visible and enabled, so trigger
+ QCOMPARE(spy.size(), 1); //act is visible and enabled, so trigger
}
#endif // QT_CONFIG(shortcut)
@@ -256,12 +255,12 @@ void tst_QAction::task229128TriggeredSignalWhenInActiongroup()
QSignalSpy actionSpy(checkedAction, QOverload<bool>::of(&QAction::triggered));
QSignalSpy actionGroupSpy(&ag, QOverload<QAction*>::of(&QActionGroup::triggered));
- QCOMPARE(actionGroupSpy.count(), 0);
- QCOMPARE(actionSpy.count(), 0);
+ QCOMPARE(actionGroupSpy.size(), 0);
+ QCOMPARE(actionSpy.size(), 0);
checkedAction->trigger();
// check that both the group and the action have emitted the signal
- QCOMPARE(actionGroupSpy.count(), 1);
- QCOMPARE(actionSpy.count(), 1);
+ QCOMPARE(actionGroupSpy.size(), 1);
+ QCOMPARE(actionSpy.size(), 1);
}
#if QT_CONFIG(shortcut)
@@ -273,7 +272,6 @@ void tst_QAction::repeat()
MyWidget testWidget(this);
testWidget.show();
- QApplicationPrivate::setActiveWindow(&testWidget);
QVERIFY(QTest::qWaitForWindowActive(&testWidget));
QAction act(&testWidget);
@@ -284,7 +282,7 @@ void tst_QAction::repeat()
act.setAutoRepeat(true);
QTest::keyPress(&testWidget, Qt::Key_F);
QTest::keyRelease(&testWidget, Qt::Key_F);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
QTest::keyPress(&testWidget, Qt::Key_F);
@@ -292,7 +290,7 @@ void tst_QAction::repeat()
QTest::simulateEvent(&testWidget, true, Qt::Key_F, Qt::NoModifier, QString("f"), true);
QTest::simulateEvent(&testWidget, true, Qt::Key_F, Qt::NoModifier, QString("f"), true);
QTest::keyRelease(&testWidget, Qt::Key_F);
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
spy.clear();
act.setAutoRepeat(false);
@@ -300,14 +298,14 @@ void tst_QAction::repeat()
QTest::simulateEvent(&testWidget, true, Qt::Key_F, Qt::NoModifier, QString("f"), true);
QTest::simulateEvent(&testWidget, true, Qt::Key_F, Qt::NoModifier, QString("f"), true);
QTest::keyRelease(&testWidget, Qt::Key_F);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
act.setAutoRepeat(true);
QTest::keyPress(&testWidget, Qt::Key_F);
QTest::simulateEvent(&testWidget, true, Qt::Key_F, Qt::NoModifier, QString("f"), true);
QTest::keyRelease(&testWidget, Qt::Key_F);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
void tst_QAction::disableShortcutsWithBlockedWidgets_data()
@@ -352,12 +350,11 @@ void tst_QAction::disableShortcutsWithBlockedWidgets()
dialog.show();
QVERIFY(QTest::qWaitForWindowExposed(&dialog));
- QApplicationPrivate::setActiveWindow(&window);
QVERIFY(QTest::qWaitForWindowActive(&window));
QSignalSpy spy(&action, &QAction::triggered);
QTest::keyPress(&window, Qt::Key_1);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
}
class ShortcutOverrideWidget : public QWidget
@@ -395,7 +392,7 @@ void tst_QAction::shortcutFromKeyEvent()
// shortcut route for us
QKeyEvent e(QEvent::KeyPress, Qt::Key_1, Qt::NoModifier);
QApplication::sendEvent(&testWidget, &e);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(testWidget.shortcutOverrideCount, 1);
}
@@ -414,6 +411,9 @@ void tst_QAction::disableShortcutInMenuAction_data()
void tst_QAction::disableShortcutInMenuAction()
{
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
QFETCH(QByteArray, property);
QMainWindow mw;
@@ -431,42 +431,42 @@ void tst_QAction::disableShortcutInMenuAction()
QKeyEvent event(QEvent::KeyPress, Qt::Key_A, Qt::ControlModifier);
QApplication::sendEvent(&mw, &event);
- QCOMPARE(spy.count(), ++expectedTriggerCount);
+ QCOMPARE(spy.size(), ++expectedTriggerCount);
testMenu->menuAction()->setProperty(property, false);
QApplication::sendEvent(&mw, &event);
- QCOMPARE(spy.count(), expectedTriggerCount);
+ QCOMPARE(spy.size(), expectedTriggerCount);
testMenu->menuAction()->setProperty(property, true);
QApplication::sendEvent(&mw, &event);
- QCOMPARE(spy.count(), ++expectedTriggerCount);
+ QCOMPARE(spy.size(), ++expectedTriggerCount);
// If the action lives somewhere else, then keep firing even
// if the menu has been hidden or disabled.
toolBar->addAction(testAction);
QApplication::sendEvent(&mw, &event);
- QCOMPARE(spy.count(), ++expectedTriggerCount);
+ QCOMPARE(spy.size(), ++expectedTriggerCount);
testMenu->menuAction()->setProperty(property, false);
QApplication::sendEvent(&mw, &event);
- QCOMPARE(spy.count(), ++expectedTriggerCount);
+ QCOMPARE(spy.size(), ++expectedTriggerCount);
// unless all other widgets in which the action lives have
// been hidden...
toolBar->hide();
QApplication::sendEvent(&mw, &event);
- QCOMPARE(spy.count(), expectedTriggerCount);
+ QCOMPARE(spy.size(), expectedTriggerCount);
// ... or disabled
toolBar->show();
toolBar->setEnabled(false);
QApplication::sendEvent(&mw, &event);
- QCOMPARE(spy.count(), expectedTriggerCount);
+ QCOMPARE(spy.size(), expectedTriggerCount);
// back to normal
toolBar->setEnabled(true);
QApplication::sendEvent(&mw, &event);
- QCOMPARE(spy.count(), ++expectedTriggerCount);
+ QCOMPARE(spy.size(), ++expectedTriggerCount);
}
#endif // QT_CONFIG(shortcut)