Skip to content

Commit 4906594

Browse files
committed
Merge #950: qt, test: Run GUI tests on macOS with minimal QPA plugin
fd59d68 qt, test: Enable tests on macOS with `minimal` QPA plugin (Hennadii Stepanov) c8b2aeb qt: Avoid implicit `NSApplication` instantiation (Hennadii Stepanov) Pull request description: On macOS, `test_bitcoin-qt` has skipped `AppTests`, `WalletTests`, and `AddressBookTests` under the `minimal` QPA plugin since bitcoin/bitcoin@a3197c5 (2018, Qt 5.11), pointing to [QTBUG-49686](https://qt-project.atlassian.net/browse/QTBUG-49686). The recent re-evaluation of the Bitcoin Core codebase showed that the Qt bug report is no longer relevant. The remaining causes were in our own code, and they are fixed in the first commit. ACKs for top commit: maflcko: lgtm ACK fd59d68 pablomartin4btc: tACK fd59d68 Tree-SHA512: 9fae09668cffe8b207736c6a202af01666a06ae1a8adbd3061717b92a692c0b65b6fe853f192cdc8793073b1c02c3f6a61350a5974397ac016ff8924a51e084a
2 parents e0c196f + fd59d68 commit 4906594

4 files changed

Lines changed: 4 additions & 36 deletions

File tree

src/qt/macdockiconhandler.mm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ bool dockClickHandler(id self, SEL _cmd, ...) {
2020
}
2121

2222
void setupDockClickHandler() {
23-
Class delClass = (Class)[[[NSApplication sharedApplication] delegate] class];
23+
if (NSApp == nil) return;
24+
Class delClass = (Class)[[NSApp delegate] class];
2425
SEL shouldHandle = sel_registerName("applicationShouldHandleReopen:hasVisibleWindows:");
2526
class_replaceMethod(delClass, shouldHandle, (IMP)dockClickHandler, "B@:");
2627
}
@@ -49,5 +50,6 @@ void setupDockClickHandler() {
4950
*/
5051
void ForceActivation()
5152
{
52-
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
53+
if (NSApp == nil) return;
54+
[NSApp activateIgnoringOtherApps:YES];
5355
}

src/qt/test/addressbooktests.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -212,16 +212,5 @@ void TestAddAddressesToSendBook(interfaces::Node& node)
212212

213213
void AddressBookTests::addressBookTests()
214214
{
215-
#ifdef Q_OS_MACOS
216-
if (QApplication::platformName() == "minimal") {
217-
// Disable for mac on "minimal" platform to avoid crashes inside the Qt
218-
// framework when it tries to look up unimplemented cocoa functions,
219-
// and fails to handle returned nulls
220-
// (https://bugreports.qt.io/browse/QTBUG-49686).
221-
qWarning() << "Skipping AddressBookTests on mac build with 'minimal' platform set due to Qt bugs. To run AppTests, invoke "
222-
"with 'QT_QPA_PLATFORM=cocoa test_bitcoin-qt' on mac, or else use a linux or windows build.";
223-
return;
224-
}
225-
#endif
226215
TestAddAddressesToSendBook(m_node);
227216
}

src/qt/test/apptests.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,6 @@ void TestRpcCommand(RPCConsole* console)
5454
//! Entry point for BitcoinApplication tests.
5555
void AppTests::appTests()
5656
{
57-
#ifdef Q_OS_MACOS
58-
if (QApplication::platformName() == "minimal") {
59-
// Disable for mac on "minimal" platform to avoid crashes inside the Qt
60-
// framework when it tries to look up unimplemented cocoa functions,
61-
// and fails to handle returned nulls
62-
// (https://bugreports.qt.io/browse/QTBUG-49686).
63-
qWarning() << "Skipping AppTests on mac build with 'minimal' platform set due to Qt bugs. To run AppTests, invoke "
64-
"with 'QT_QPA_PLATFORM=cocoa test_bitcoin-qt' on mac, or else use a linux or windows build.";
65-
return;
66-
}
67-
#endif
68-
6957
qRegisterMetaType<interfaces::BlockAndHeaderTipInfo>("interfaces::BlockAndHeaderTipInfo");
7058
m_app.parameterSetup();
7159
QVERIFY(m_app.createOptionsModel(/*resetSettings=*/true));

src/qt/test/wallettests.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -455,16 +455,5 @@ void TestGUI(interfaces::Node& node)
455455

456456
void WalletTests::walletTests()
457457
{
458-
#ifdef Q_OS_MACOS
459-
if (QApplication::platformName() == "minimal") {
460-
// Disable for mac on "minimal" platform to avoid crashes inside the Qt
461-
// framework when it tries to look up unimplemented cocoa functions,
462-
// and fails to handle returned nulls
463-
// (https://bugreports.qt.io/browse/QTBUG-49686).
464-
qWarning() << "Skipping WalletTests on mac build with 'minimal' platform set due to Qt bugs. To run AppTests, invoke "
465-
"with 'QT_QPA_PLATFORM=cocoa test_bitcoin-qt' on mac, or else use a linux or windows build.";
466-
return;
467-
}
468-
#endif
469458
TestGUI(m_node);
470459
}

0 commit comments

Comments
 (0)