summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestregistry.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/testlib/qtestregistry.cpp')
-rw-r--r--src/testlib/qtestregistry.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/testlib/qtestregistry.cpp b/src/testlib/qtestregistry.cpp
new file mode 100644
index 0000000000..ff1f8a57e6
--- /dev/null
+++ b/src/testlib/qtestregistry.cpp
@@ -0,0 +1,36 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include <QtTest/private/qtestregistry_p.h>
+
+QT_REQUIRE_CONFIG(batch_test_support);
+
+QT_BEGIN_NAMESPACE
+
+namespace QTest {
+Q_GLOBAL_STATIC(TestRegistry, g_registry);
+
+TestRegistry *TestRegistry::instance()
+{
+ return g_registry;
+}
+
+void TestRegistry::registerTest(const QString& name, TestEntryFunction entry)
+{
+ m_tests.emplace(name, std::move(entry));
+}
+
+TestRegistry::TestEntryFunction
+TestRegistry::getTestEntryFunction(const QString& name) const
+{
+ const auto it = m_tests.find(name);
+ return it != m_tests.end() ? it.value() : nullptr;
+}
+
+QStringList TestRegistry::getAllTestNames() const
+{
+ return m_tests.keys();
+}
+}
+
+QT_END_NAMESPACE