File: connectorutilstest.cpp

package info (click to toggle)
kunifiedpush 25.08.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,036 kB
  • sloc: cpp: 4,524; xml: 154; java: 141; makefile: 5; sh: 1
file content (33 lines) | stat: -rw-r--r-- 1,563 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
    SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
    SPDX-License-Identifier: LGPL-2.0-or-later
*/

#include "../src/shared/connectorutils.cpp"

#include <QTest>

namespace KUnifiedPush {

class ConnectorUtilsTest : public QObject
{
    Q_OBJECT
private Q_SLOTS:
    void testSelectDistributor()
    {
        QCOMPARE(ConnectorUtils::selectDistributor({}), QString());
        QCOMPARE(ConnectorUtils::selectDistributor({ QStringLiteral("some.service") }), QString());
        QCOMPARE(ConnectorUtils::selectDistributor({ QStringLiteral("some.service"), QStringLiteral("org.unifiedpush.Distributor.mock") }), QLatin1String("org.unifiedpush.Distributor.mock"));
        QCOMPARE(ConnectorUtils::selectDistributor({ QStringLiteral("some.service"), QStringLiteral("org.unifiedpush.Distributor.mock2"), QStringLiteral("org.unifiedpush.Distributor.mock1") }), QLatin1String("org.unifiedpush.Distributor.mock1"));
        QCOMPARE(ConnectorUtils::selectDistributor({ QStringLiteral("some.service"), QStringLiteral("org.unifiedpush.Distributor.kde"), QStringLiteral("org.unifiedpush.Distributor.abc") }), QLatin1String("org.unifiedpush.Distributor.kde"));

        qputenv("UNIFIEDPUSH_DISTRIBUTOR", "abc");
        QCOMPARE(ConnectorUtils::selectDistributor({ QStringLiteral("some.service"), QStringLiteral("org.unifiedpush.Distributor.kde"), QStringLiteral("org.unifiedpush.Distributor.abc") }), QLatin1String("org.unifiedpush.Distributor.abc"));
    }
};

}

QTEST_GUILESS_MAIN(KUnifiedPush::ConnectorUtilsTest)

#include "connectorutilstest.moc"