diff --git a/src/qt/macdockiconhandler.mm b/src/qt/macdockiconhandler.mm index 5eb23c76e678..9cd234e582fd 100644 --- a/src/qt/macdockiconhandler.mm +++ b/src/qt/macdockiconhandler.mm @@ -20,7 +20,8 @@ bool dockClickHandler(id self, SEL _cmd, ...) { } void setupDockClickHandler() { - Class delClass = (Class)[[[NSApplication sharedApplication] delegate] class]; + if (NSApp == nil) return; + Class delClass = (Class)[[NSApp delegate] class]; SEL shouldHandle = sel_registerName("applicationShouldHandleReopen:hasVisibleWindows:"); class_replaceMethod(delClass, shouldHandle, (IMP)dockClickHandler, "B@:"); } @@ -49,5 +50,6 @@ void setupDockClickHandler() { */ void ForceActivation() { - [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; + if (NSApp == nil) return; + [NSApp activateIgnoringOtherApps:YES]; } diff --git a/src/qt/test/addressbooktests.cpp b/src/qt/test/addressbooktests.cpp index b038bc842598..62c8e51290be 100644 --- a/src/qt/test/addressbooktests.cpp +++ b/src/qt/test/addressbooktests.cpp @@ -211,16 +211,5 @@ void TestAddAddressesToSendBook(interfaces::Node& node) void AddressBookTests::addressBookTests() { -#ifdef Q_OS_MACOS - if (QApplication::platformName() == "minimal") { - // Disable for mac on "minimal" platform to avoid crashes inside the Qt - // framework when it tries to look up unimplemented cocoa functions, - // and fails to handle returned nulls - // (https://bugreports.qt.io/browse/QTBUG-49686). - QWARN("Skipping AddressBookTests on mac build with 'minimal' platform set due to Qt bugs. To run AppTests, invoke " - "with 'QT_QPA_PLATFORM=cocoa test_dash-qt' on mac, or else use a linux or windows build."); - return; - } -#endif TestAddAddressesToSendBook(m_node); } diff --git a/src/qt/test/apptests.cpp b/src/qt/test/apptests.cpp index 470f4dc5e3af..3ecdabb336ff 100644 --- a/src/qt/test/apptests.cpp +++ b/src/qt/test/apptests.cpp @@ -57,18 +57,6 @@ void TestRpcCommand(RPCConsole* console) //! Entry point for BitcoinApplication tests. void AppTests::appTests() { -#ifdef Q_OS_MACOS - if (QApplication::platformName() == "minimal") { - // Disable for mac on "minimal" platform to avoid crashes inside the Qt - // framework when it tries to look up unimplemented cocoa functions, - // and fails to handle returned nulls - // (https://bugreports.qt.io/browse/QTBUG-49686). - QWARN("Skipping AppTests on mac build with 'minimal' platform set due to Qt bugs. To run AppTests, invoke " - "with 'QT_QPA_PLATFORM=cocoa test_dash-qt' on mac, or else use a linux or windows build."); - return; - } -#endif - qRegisterMetaType("interfaces::BlockAndHeaderTipInfo"); m_app.parameterSetup(); GUIUtil::loadFonts(); diff --git a/src/qt/test/coincontroltreewidgettests.cpp b/src/qt/test/coincontroltreewidgettests.cpp index ab3918075b6e..fa74d43f3e76 100644 --- a/src/qt/test/coincontroltreewidgettests.cpp +++ b/src/qt/test/coincontroltreewidgettests.cpp @@ -6,7 +6,6 @@ #include -#include #include #include #include @@ -90,16 +89,6 @@ void ShiftClickCheckbox(CoinControlTreeWidget& tree, QTreeWidgetItem* item) } } // namespace -void CoinControlTreeWidgetTests::init() -{ -#if defined(Q_OS_MACOS) - if (QApplication::platformName() == "minimal") { - // Showing widgets with the minimal platform crashes on macOS (QTBUG-49686) - QSKIP("Run with QT_QPA_PLATFORM=cocoa on macOS"); - } -#endif -} - void CoinControlTreeWidgetTests::shiftClickChecksRange() { CoinControlTreeWidget tree; diff --git a/src/qt/test/coincontroltreewidgettests.h b/src/qt/test/coincontroltreewidgettests.h index b16c07336f91..89737a8c0990 100644 --- a/src/qt/test/coincontroltreewidgettests.h +++ b/src/qt/test/coincontroltreewidgettests.h @@ -12,7 +12,6 @@ class CoinControlTreeWidgetTests : public QObject Q_OBJECT private Q_SLOTS: - void init(); void shiftClickChecksRange(); void shiftClickUnchecksRange(); void clicksOutsideCheckboxIgnored(); diff --git a/src/qt/test/masternodemaintenancetests.cpp b/src/qt/test/masternodemaintenancetests.cpp index 69e2adbb26a5..2b9079281a7a 100644 --- a/src/qt/test/masternodemaintenancetests.cpp +++ b/src/qt/test/masternodemaintenancetests.cpp @@ -579,12 +579,6 @@ void MasternodeMaintenanceTests::revokeRequestConstruction() void MasternodeMaintenanceTests::dialogFieldGeometry() { -#if defined(Q_OS_MACOS) - if (QApplication::platformName() == "minimal") { - QWARN("Skipping dialogFieldGeometry on macOS with the minimal platform due to QTBUG-49686"); - return; - } -#endif TestChain100Setup test; m_node.setContext(&test.m_node); auto source{std::make_shared(MnType::Regular)}; @@ -622,12 +616,6 @@ void MasternodeMaintenanceTests::dialogFieldGeometry() void MasternodeMaintenanceTests::dialogLifecycleAndSubmissionStates() { -#if defined(Q_OS_MACOS) - if (QApplication::platformName() == "minimal") { - QWARN("Skipping dialogLifecycleAndSubmissionStates on macOS with the minimal platform due to QTBUG-49686"); - return; - } -#endif TestChain100Setup test; m_node.setContext(&test.m_node); auto source{std::make_shared(MnType::Regular)}; diff --git a/src/qt/test/masternodewidgettests.cpp b/src/qt/test/masternodewidgettests.cpp index f612a4ff0c37..86c04735b327 100644 --- a/src/qt/test/masternodewidgettests.cpp +++ b/src/qt/test/masternodewidgettests.cpp @@ -664,12 +664,6 @@ void MasternodeWidgetTests::registeredCollateralExclusion() void MasternodeWidgetTests::wizardMinimumGeometry() { -#if defined(Q_OS_MACOS) - if (QApplication::platformName() == "minimal") { - QWARN("Skipping wizardMinimumGeometry on macOS with the minimal platform due to QTBUG-49686"); - return; - } -#endif TestChain100Setup test; m_node.setContext(&test.m_node); @@ -762,12 +756,6 @@ void MasternodeWidgetTests::wizardMinimumGeometry() void MasternodeWidgetTests::wizardPageValidation() { -#if defined(Q_OS_MACOS) - if (QApplication::platformName() == "minimal") { - QWARN("Skipping wizardPageValidation on macOS with the minimal platform due to QTBUG-49686"); - return; - } -#endif TestChain100Setup test; m_node.setContext(&test.m_node); @@ -880,12 +868,6 @@ void MasternodeWidgetTests::wizardPageValidation() void MasternodeWidgetTests::broadcastConfirmation() { -#if defined(Q_OS_MACOS) - if (QApplication::platformName() == "minimal") { - QWARN("Skipping broadcastConfirmation on macOS with the minimal platform due to QTBUG-49686"); - return; - } -#endif TestChain100Setup test; m_node.setContext(&test.m_node); @@ -1220,12 +1202,6 @@ void MasternodeWidgetTests::sharedMasternodeDetails() void MasternodeWidgetTests::wizardInteractionLifecycle() { -#if defined(Q_OS_MACOS) - if (QApplication::platformName() == "minimal") { - QWARN("Skipping wizardInteractionLifecycle on macOS with the minimal platform due to QTBUG-49686"); - return; - } -#endif TestChain100Setup test; m_node.setContext(&test.m_node); WalletContext& context{*m_node.walletLoader().context()}; @@ -1303,12 +1279,6 @@ void MasternodeWidgetTests::wizardInteractionLifecycle() void MasternodeWidgetTests::registrationResultStates() { -#if defined(Q_OS_MACOS) - if (QApplication::platformName() == "minimal") { - QWARN("Skipping registrationResultStates on macOS with the minimal platform due to QTBUG-49686"); - return; - } -#endif TestChain100Setup test; m_node.setContext(&test.m_node); WalletContext& context{*m_node.walletLoader().context()}; diff --git a/src/qt/test/providertransactiontests.cpp b/src/qt/test/providertransactiontests.cpp index 71668cf10d2d..c718a1b4a1ae 100644 --- a/src/qt/test/providertransactiontests.cpp +++ b/src/qt/test/providertransactiontests.cpp @@ -31,7 +31,6 @@ #include #include -#include #include #include #include @@ -366,11 +365,6 @@ void ProviderTransactionTests::providerTransactionHistory() filter.setTypeFilter(TransactionFilterProxy::TYPE(TransactionRecord::AssetLock)); QCOMPARE(filter.rowCount(), 1); -#if defined(Q_OS_MACOS) - if (QApplication::platformName() == "minimal") { - QWARN("Skipping TransactionView checks on macOS with the minimal platform due to QTBUG-49686"); - } else -#endif { CoinJoinOptionsRestorer coinjoin_restorer{m_node.coinJoinOptions()}; m_node.coinJoinOptions().setEnabled(false); diff --git a/src/qt/test/sharedmnwalkthroughtests.cpp b/src/qt/test/sharedmnwalkthroughtests.cpp index 4168c493b09c..7fdc7c06e525 100644 --- a/src/qt/test/sharedmnwalkthroughtests.cpp +++ b/src/qt/test/sharedmnwalkthroughtests.cpp @@ -56,7 +56,6 @@ #include #include #include -#include #include #include #include @@ -186,8 +185,6 @@ class ModalPilot : public QObject //! Everything answered so far, for failure messages const QStringList& seen() const { return m_seen; } - //! Window titles of those boxes, in the same order - const QStringList& titles() const { return m_titles; } private: void poll() @@ -211,7 +208,6 @@ class ModalPilot : public QObject // counts down; wait for it rather than cancelling the flow. if (target != nullptr && !target->isEnabled()) return; m_pending = nullptr; - m_titles << box->windowTitle(); m_seen << (box->text() + QLatin1Char('\n') + box->informativeText() + QLatin1Char('\n') + box->detailedText()); if (!m_queued.isEmpty()) { const Shot shot{m_queued.takeFirst()}; @@ -239,7 +235,6 @@ class ModalPilot : public QObject QTimer m_timer; QWidget* m_pending{nullptr}; QStringList m_seen; - QStringList m_titles; QList m_queued; }; @@ -315,16 +310,6 @@ QString TakeClipboardEnvelope(QString& fingerprint) void SharedMnWalkthroughTests::initTestCase() { -#if defined(Q_OS_MACOS) - // The native macOS style paints through an NSView, which does not exist on - // the minimal platform and crashes there (QTBUG-49686). Fusion is what the - // Linux builds use anyway, and the Dash stylesheet still applies on top. - if (QApplication::platformName() == "minimal") { - if (QStyle* const fusion = QStyleFactory::create("Fusion"); fusion != nullptr) { - QApplication::setStyle(fusion); - } - } -#endif // Grab the dialogs the way a user sees them: real fonts, real (light) theme // stylesheet. Both are loaded from Qt resources, so this works headless // under "minimal:enable_fonts". The plain "minimal" platform has no font @@ -1072,9 +1057,9 @@ void SharedMnWalkthroughTests::walkthrough() list.openSharedMessage(standby_hex); QCOMPARE(pilot.seen().size(), answered + 2); const QString result{pilot.seen().last()}; - QVERIFY2(pilot.titles().last() == QStringLiteral("Broadcast failed") && result.contains("early-exit penalty") && - result.contains("bad-prodis-penalty-floor"), - qPrintable(pilot.titles().last() + QLatin1Char('\n') + result)); + QVERIFY2(result.startsWith(QStringLiteral("This dissolution pays a share less than the network requires")) && + result.contains("early-exit penalty") && result.contains("bad-prodis-penalty-floor"), + qPrintable(result)); CMutableTransaction standby_full; QVERIFY(DecodeHexTx(standby_full, standby_hex.toStdString())); UniValue params(UniValue::VOBJ); diff --git a/src/qt/test/sharedmnwizardtests.cpp b/src/qt/test/sharedmnwizardtests.cpp index 8d417ac0bf16..cb713243879d 100644 --- a/src/qt/test/sharedmnwizardtests.cpp +++ b/src/qt/test/sharedmnwizardtests.cpp @@ -111,15 +111,16 @@ MnShareSession FrozenSession(const MnShareSession& draft, const std::vector(QApplication::activeModalWidget())}; if (box == nullptr) return; - title = box->windowTitle(); + text = box->text(); for (QAbstractButton* const button : box->buttons()) { if (button->text() == answer) { button->click(); @@ -564,7 +565,7 @@ void SharedMnWizardTests::signedSessionReservation() return button->text() == QStringLiteral("Release my coins") && !button->isHidden(); }); }; - const QString keep_prompt{QStringLiteral("Keep this session for later?")}; + const QString keep_prompt{QStringLiteral("Saving keeps your coins reserved")}; QString prompt; { // Nothing was changed since the session was opened, but its coins stay @@ -576,14 +577,14 @@ void SharedMnWizardTests::signedSessionReservation() AnswerMessageBox(QStringLiteral("Cancel"), prompt); dialog.onNext(); QCoreApplication::processEvents(); - QCOMPARE(prompt, keep_prompt); + QVERIFY2(prompt.startsWith(keep_prompt), qPrintable(prompt)); QVERIFY(dialog.isVisible()); QVERIFY(wallet_model.wallet().isLockedCoin(bob_coin)); AnswerMessageBox(QStringLiteral("Discard and Release Coins"), prompt); dialog.reject(); QCoreApplication::processEvents(); - QCOMPARE(prompt, keep_prompt); + QVERIFY2(prompt.startsWith(keep_prompt), qPrintable(prompt)); QVERIFY(!dialog.isVisible()); QVERIFY(!wallet_model.wallet().isLockedCoin(bob_coin)); } @@ -601,7 +602,7 @@ void SharedMnWizardTests::signedSessionReservation() AnswerMessageBox(QStringLiteral("Cancel"), prompt); dialog.reject(); QCoreApplication::processEvents(); - QCOMPARE(prompt, keep_prompt); + QVERIFY2(prompt.startsWith(keep_prompt), qPrintable(prompt)); QVERIFY(dialog.isVisible()); QVERIFY(wallet_model.wallet().isLockedCoin(bob_coin)); } @@ -614,7 +615,7 @@ void SharedMnWizardTests::signedSessionReservation() AnswerMessageBox(QStringLiteral("Release"), prompt); dialog.releaseReservedCoins(); QCoreApplication::processEvents(); - QCOMPARE(prompt, QStringLiteral("Release your coins?")); + QVERIFY2(prompt.startsWith(QStringLiteral("The coins you reserved for Session")), qPrintable(prompt)); QVERIFY(!wallet_model.wallet().isLockedCoin(bob_coin)); QVERIFY(dialog.m_status_label->text().startsWith(QStringLiteral("Released"))); diff --git a/src/qt/test/test_main.cpp b/src/qt/test/test_main.cpp index 3d91e02bd925..f626c3bdc584 100644 --- a/src/qt/test/test_main.cpp +++ b/src/qt/test/test_main.cpp @@ -88,11 +88,18 @@ int main(int argc, char* argv[]) // Prefer the "minimal" platform for the test instead of the normal default // platform ("xcb", "windows", or "cocoa") so tests can't unintentionally // interfere with any background GUIs and don't require extra resources. - #if defined(WIN32) - if (getenv("QT_QPA_PLATFORM") == nullptr) _putenv_s("QT_QPA_PLATFORM", "minimal"); - #else - setenv("QT_QPA_PLATFORM", "minimal", 0 /* overwrite */); - #endif +#if defined(WIN32) + if (getenv("QT_QPA_PLATFORM") == nullptr) _putenv_s("QT_QPA_PLATFORM", "minimal"); +#else + setenv("QT_QPA_PLATFORM", "minimal", 0 /* overwrite */); +#endif + +#ifdef Q_OS_MACOS + // QMacStyle assumes a Cocoa platform window, which the minimal platform + // does not provide. In particular, painting a QGroupBox can make Qt call + // addSubview: on an invalid native object (QTBUG-49686). + setenv("QT_STYLE_OVERRIDE", "fusion", 0 /* overwrite */); +#endif BitcoinApplication app; app.setApplicationName("Dash-Qt-test"); diff --git a/src/qt/test/wallettests.cpp b/src/qt/test/wallettests.cpp index dc6b7a0153f3..4a253163e221 100644 --- a/src/qt/test/wallettests.cpp +++ b/src/qt/test/wallettests.cpp @@ -491,17 +491,6 @@ void TestGUI(interfaces::Node& node) void WalletTests::walletTests() { -#ifdef Q_OS_MACOS - if (QApplication::platformName() == "minimal") { - // Disable for mac on "minimal" platform to avoid crashes inside the Qt - // framework when it tries to look up unimplemented cocoa functions, - // and fails to handle returned nulls - // (https://bugreports.qt.io/browse/QTBUG-49686). - QWARN("Skipping WalletTests on mac build with 'minimal' platform set due to Qt bugs. To run AppTests, invoke " - "with 'QT_QPA_PLATFORM=cocoa test_dash-qt' on mac, or else use a linux or windows build."); - return; - } -#endif TestGUI(m_node); }