diff options
author | Leander Beernaert <leander.beernaert@qt.io> | 2019-11-14 13:03:46 +0100 |
---|---|---|
committer | Leander Beernaert <leander.beernaert@qt.io> | 2019-11-19 13:53:21 +0100 |
commit | 26e876912435bdafbca2b425af43824d7ec5b876 (patch) | |
tree | b7ee83cdd9de18ce5970bab0bb217a972d3d2445 /tests/auto/widgets/kernel/qaction | |
parent | 7a6c6da2ebbfef33f7284ce5c96aa0c3acabc6bc (diff) | |
parent | bac999f38ca10147832846f6d7df1e4a051d3760 (diff) |
Merge remote-tracking branch 'origin/dev' into wip/cmake
Change-Id: Ifecc2d9db396d783124df8567553ba5f846f30bb
Diffstat (limited to 'tests/auto/widgets/kernel/qaction')
-rw-r--r-- | tests/auto/widgets/kernel/qaction/.gitignore | 1 | ||||
-rw-r--r-- | tests/auto/widgets/kernel/qaction/tst_qaction.cpp | 170 |
2 files changed, 21 insertions, 150 deletions
diff --git a/tests/auto/widgets/kernel/qaction/.gitignore b/tests/auto/widgets/kernel/qaction/.gitignore deleted file mode 100644 index bf81f5bf2c..0000000000 --- a/tests/auto/widgets/kernel/qaction/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qaction diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp index 0d62c2cd4b..cf8539da68 100644 --- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp +++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp @@ -35,6 +35,7 @@ #include <qaction.h> #include <qmenu.h> #include <qpa/qplatformtheme.h> +#include <qpa/qplatformintegration.h> #include <private/qguiapplication_p.h> class tst_QAction : public QObject @@ -49,30 +50,25 @@ public: private slots: void init(); void cleanup(); - void getSetCheck(); - void setText_data(); - void setText(); - void setIconText_data() { setText_data(); } - void setIconText(); void setUnknownFont(); void actionEvent(); - void setStandardKeys(); +#if QT_CONFIG(shortcut) void alternateShortcuts(); void enabledVisibleInteraction(); - void task200823_tooltip(); - void task229128TriggeredSignalWithoutActiongroup(); +#endif void task229128TriggeredSignalWhenInActiongroup(); +#if QT_CONFIG(shortcut) void repeat(); - void setData(); void keysequence(); // QTBUG-53381 void disableShortcutsWithBlockedWidgets_data(); void disableShortcutsWithBlockedWidgets(); void shortcutFromKeyEvent(); // QTBUG-48325 +#endif private: QEvent::Type m_lastEventType; const int m_keyboardScheme; - QAction *m_lastAction; + QGuiAction *m_lastAction; }; tst_QAction::tst_QAction() @@ -91,33 +87,6 @@ void tst_QAction::cleanup() QVERIFY(QApplication::topLevelWidgets().isEmpty()); } -// Testing get/set functions -void tst_QAction::getSetCheck() -{ - QAction obj1(nullptr); - // QActionGroup * QAction::actionGroup() - // void QAction::setActionGroup(QActionGroup *) - QActionGroup *var1 = new QActionGroup(nullptr); - obj1.setActionGroup(var1); - QCOMPARE(var1, obj1.actionGroup()); - obj1.setActionGroup(nullptr); - QCOMPARE(obj1.actionGroup(), nullptr); - delete var1; - - // QMenu * QAction::menu() - // void QAction::setMenu(QMenu *) - QMenu *var2 = new QMenu(nullptr); - obj1.setMenu(var2); - QCOMPARE(var2, obj1.menu()); - obj1.setMenu(nullptr); - QCOMPARE(obj1.menu(), nullptr); - delete var2; - - QCOMPARE(obj1.priority(), QAction::NormalPriority); - obj1.setPriority(QAction::LowPriority); - QCOMPARE(obj1.priority(), QAction::LowPriority); -} - class MyWidget : public QWidget { Q_OBJECT @@ -132,43 +101,6 @@ private: tst_QAction *m_test; }; -void tst_QAction::setText_data() -{ - QTest::addColumn<QString>("text"); - QTest::addColumn<QString>("iconText"); - QTest::addColumn<QString>("textFromIconText"); - - //next we fill it with data - QTest::newRow("Normal") << "Action" << "Action" << "Action"; - QTest::newRow("Ampersand") << "Search && Destroy" << "Search & Destroy" << "Search && Destroy"; - QTest::newRow("Mnemonic and ellipsis") << "O&pen File ..." << "Open File" << "Open File"; -} - -void tst_QAction::setText() -{ - QFETCH(QString, text); - - QAction action(nullptr); - action.setText(text); - - QCOMPARE(action.text(), text); - - QFETCH(QString, iconText); - QCOMPARE(action.iconText(), iconText); -} - -void tst_QAction::setIconText() -{ - QFETCH(QString, iconText); - - QAction action(nullptr); - action.setIconText(iconText); - QCOMPARE(action.iconText(), iconText); - - QFETCH(QString, textFromIconText); - QCOMPARE(action.text(), textFromIconText); -} - void tst_QAction::setUnknownFont() // QTBUG-42728 { QAction action(nullptr); @@ -220,34 +152,7 @@ void tst_QAction::actionEvent() QCOMPARE(m_lastAction, &a); } -//basic testing of standard keys -void tst_QAction::setStandardKeys() -{ - QAction act(nullptr); - act.setShortcut(QKeySequence("CTRL+L")); - QList<QKeySequence> list; - act.setShortcuts(list); - act.setShortcuts(QKeySequence::Copy); - QCOMPARE(act.shortcut(), act.shortcuts().constFirst()); - - QList<QKeySequence> expected; - const QKeySequence ctrlC = QKeySequence(QStringLiteral("CTRL+C")); - const QKeySequence ctrlInsert = QKeySequence(QStringLiteral("CTRL+INSERT")); - switch (m_keyboardScheme) { - case QPlatformTheme::MacKeyboardScheme: - expected << ctrlC; - break; - case QPlatformTheme::WindowsKeyboardScheme: - expected << ctrlC << ctrlInsert; - break; - default: // X11 - expected << ctrlC << ctrlInsert << QKeySequence(QStringLiteral("F16")); - break; - } - - QCOMPARE(act.shortcuts(), expected); -} - +#if QT_CONFIG(shortcut) void tst_QAction::alternateShortcuts() { @@ -353,38 +258,7 @@ void tst_QAction::enabledVisibleInteraction() QCOMPARE(spy.count(), 1); //act is visible and enabled, so trigger } -void tst_QAction::task200823_tooltip() -{ - const QScopedPointer<QAction> action(new QAction("foo", nullptr)); - QString shortcut("ctrl+o"); - action->setShortcut(shortcut); - - // we want a non-standard tooltip that shows the shortcut - action->setToolTip(action->text() + QLatin1String(" (") + action->shortcut().toString() + QLatin1Char(')')); - - QString ref = QLatin1String("foo (") + QKeySequence(shortcut).toString() + QLatin1Char(')'); - QCOMPARE(action->toolTip(), ref); -} - -void tst_QAction::task229128TriggeredSignalWithoutActiongroup() -{ - // test without a group - const QScopedPointer<QAction> actionWithoutGroup(new QAction("Test", nullptr)); - QSignalSpy spyWithoutGroup(actionWithoutGroup.data(), QOverload<bool>::of(&QAction::triggered)); - QCOMPARE(spyWithoutGroup.count(), 0); - actionWithoutGroup->trigger(); - // signal should be emitted - QCOMPARE(spyWithoutGroup.count(), 1); - - // it is now a checkable checked action - actionWithoutGroup->setCheckable(true); - actionWithoutGroup->setChecked(true); - spyWithoutGroup.clear(); - QCOMPARE(spyWithoutGroup.count(), 0); - actionWithoutGroup->trigger(); - // signal should be emitted - QCOMPARE(spyWithoutGroup.count(), 1); -} +#endif // QT_CONFIG(shortcut) void tst_QAction::task229128TriggeredSignalWhenInActiongroup() { @@ -407,8 +281,13 @@ void tst_QAction::task229128TriggeredSignalWhenInActiongroup() QCOMPARE(actionSpy.count(), 1); } +#if QT_CONFIG(shortcut) + void tst_QAction::repeat() { + if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) + QSKIP("Wayland: This fails. Figure out why."); + MyWidget testWidget(this); testWidget.show(); QApplication::setActiveWindow(&testWidget); @@ -448,21 +327,6 @@ 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"); @@ -484,6 +348,9 @@ void tst_QAction::disableShortcutsWithBlockedWidgets_data() void tst_QAction::disableShortcutsWithBlockedWidgets() { + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QSKIP("Window activation is not supported"); + QMainWindow window; QFETCH(Qt::ShortcutContext, shortcutContext); @@ -528,6 +395,9 @@ protected: // ShortcutOverride event first before passing it on as a normal KeyEvent. void tst_QAction::shortcutFromKeyEvent() { + if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) + QSKIP("Wayland: This fails. Figure out why."); + ShortcutOverrideWidget testWidget; QAction action; action.setShortcut(Qt::Key_1); @@ -546,5 +416,7 @@ void tst_QAction::shortcutFromKeyEvent() QCOMPARE(testWidget.shortcutOverrideCount, 1); } +#endif // QT_CONFIG(shortcut) + QTEST_MAIN(tst_QAction) #include "tst_qaction.moc" |