Repository navigation
backport(qt): run Qt tests on macOS with the minimal platform (bitcoin-core/gui#950, bitcoin-core/gui#951) #8077
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,15 +111,16 @@ MnShareSession FrozenSession(const MnShareSession& draft, const std::vector<CKey | |
| } | ||
|
|
||
| //! Answer the next message box with its button labelled `answer`, recording | ||
| //! the box's title in `title`, which stays empty if no box opens before the | ||
| //! caller processes events | ||
| void AnswerMessageBox(const QString& answer, QString& title) | ||
| //! the box's text in `text`, which stays empty if no box opens before the | ||
| //! caller processes events. The text, not the title, identifies the box: | ||
| //! macOS message boxes have no title. | ||
| void AnswerMessageBox(const QString& answer, QString& text) | ||
| { | ||
| title.clear(); | ||
| QTimer::singleShot(0, [answer, &title] { | ||
| text.clear(); | ||
| QTimer::singleShot(0, [answer, &text] { | ||
| auto* const box{qobject_cast<QMessageBox*>(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)); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| QVERIFY(!wallet_model.wallet().isLockedCoin(bob_coin)); | ||
| QVERIFY(dialog.m_status_label->text().startsWith(QStringLiteral("Released"))); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 */); | ||
|
Comment on lines
+97
to
+101
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| #endif | ||
|
|
||
| BitcoinApplication app; | ||
| app.setApplicationName("Dash-Qt-test"); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems unrelated, isn't it?why string is changed?
bcs match by content: