summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp')
-rw-r--r--tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp b/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp
index 4d95345de9..a53524e956 100644
--- a/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp
+++ b/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp
@@ -69,6 +69,10 @@ public slots:
}
};
+#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
+# define CAN_IMPLICITLY_UNSET
+#endif
+
void tst_qdesktopservices::handlers()
{
MyUrlHandler fooHandler;
@@ -76,6 +80,12 @@ void tst_qdesktopservices::handlers()
QDesktopServices::setUrlHandler(QString("foo"), &fooHandler, "handle");
QDesktopServices::setUrlHandler(QString("bar"), &barHandler, "handle");
+#ifndef CAN_IMPLICITLY_UNSET
+ const auto unsetHandlers = qScopeGuard([] {
+ QDesktopServices::unsetUrlHandler(u"bar"_qs);
+ QDesktopServices::unsetUrlHandler(u"foo"_qs);
+ });
+#endif
QUrl fooUrl("foo://blub/meh");
QUrl barUrl("bar://hmm/hmmmm");
@@ -85,6 +95,15 @@ void tst_qdesktopservices::handlers()
QCOMPARE(fooHandler.lastHandledUrl.toString(), fooUrl.toString());
QCOMPARE(barHandler.lastHandledUrl.toString(), barUrl.toString());
+
+#ifdef CAN_IMPLICITLY_UNSET
+ for (int i = 0; i < 2; ++i)
+ QTest::ignoreMessage(QtWarningMsg,
+ "Please call QDesktopServices::unsetUrlHandler() before destroying a "
+ "registered URL handler object.\n"
+ "Support for destroying a registered URL handler object is deprecated, "
+ "and will be removed in Qt 6.6.");
+#endif
}
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)