| 375 | |
| 376 | #ifdef HAVE_QT_WIDGETS |
| 377 | static void testActionValidator() |
| 378 | { |
| 379 | QAction *a1 = new QAction(QStringLiteral("Action 1"), qApp); |
| 380 | a1->setShortcut(QKeySequence(QStringLiteral("Ctrl+K"))); |
| 381 | a1->setShortcutContext(Qt::ApplicationShortcut); |
| 382 | QAction *a2 = new QAction(QStringLiteral("Action 2"), qApp); |
| 383 | a2->setShortcut(QKeySequence(QStringLiteral("Ctrl+K"))); |
| 384 | a2->setShortcutContext(Qt::WidgetShortcut); |
| 385 | QTest::qWait(1); // event loop re-entry |
| 386 | |
| 387 | QVERIFY(ProblemCollector::instance()->isCheckerRegistered("gammaray_actioninspector.ShortcutDuplicates")); |
| 388 | |
| 389 | ProblemCollector::instance()->requestScan(); |
| 390 | |
| 391 | const auto &problems = ProblemCollector::instance()->problems(); |
| 392 | QVERIFY(std::any_of(problems.begin(), problems.end(), |
| 393 | [=](const Problem &p) { |
| 394 | return p.problemId.startsWith("gammaray_actioninspector.ShortcutDuplicates") |
| 395 | && (p.object == ObjectId(a1) || p.object == ObjectId(a2)) |
| 396 | && p.description.contains("ambiguous") |
| 397 | && p.description.contains(QKeySequence(QStringLiteral("Ctrl+K")).toString(QKeySequence::NativeText)) |
| 398 | && p.problemId.endsWith(QKeySequence(QStringLiteral("Ctrl+K")).toString(QKeySequence::PortableText)); |
| 399 | })); |
| 400 | } |
| 401 | #endif |
| 402 | }; |
| 403 |
nothing calls this directly
no test coverage detected