File indexing completed on 2024-05-19 04:45:14

0001 /*
0002     SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
0003     SPDX-License-Identifier: LGPL-2.0-or-later
0004 */
0005 
0006 #include "../src/shared/connectorutils.cpp"
0007 
0008 #include <QTest>
0009 
0010 namespace KUnifiedPush {
0011 
0012 class ConnectorUtilsTest : public QObject
0013 {
0014     Q_OBJECT
0015 private Q_SLOTS:
0016     void testSelectDistributor()
0017     {
0018         QCOMPARE(ConnectorUtils::selectDistributor({}), QString());
0019         QCOMPARE(ConnectorUtils::selectDistributor({ QStringLiteral("some.service") }), QString());
0020         QCOMPARE(ConnectorUtils::selectDistributor({ QStringLiteral("some.service"), QStringLiteral("org.unifiedpush.Distributor.mock") }), QLatin1String("org.unifiedpush.Distributor.mock"));
0021         QCOMPARE(ConnectorUtils::selectDistributor({ QStringLiteral("some.service"), QStringLiteral("org.unifiedpush.Distributor.mock2"), QStringLiteral("org.unifiedpush.Distributor.mock1") }), QLatin1String("org.unifiedpush.Distributor.mock1"));
0022         QCOMPARE(ConnectorUtils::selectDistributor({ QStringLiteral("some.service"), QStringLiteral("org.unifiedpush.Distributor.kde"), QStringLiteral("org.unifiedpush.Distributor.abc") }), QLatin1String("org.unifiedpush.Distributor.kde"));
0023 
0024         qputenv("UNIFIEDPUSH_DISTRIBUTOR", "abc");
0025         QCOMPARE(ConnectorUtils::selectDistributor({ QStringLiteral("some.service"), QStringLiteral("org.unifiedpush.Distributor.kde"), QStringLiteral("org.unifiedpush.Distributor.abc") }), QLatin1String("org.unifiedpush.Distributor.abc"));
0026     }
0027 };
0028 
0029 }
0030 
0031 QTEST_GUILESS_MAIN(KUnifiedPush::ConnectorUtilsTest)
0032 
0033 #include "connectorutilstest.moc"