2015-09-08 16:28:47 +01:00
|
|
|
/**
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-FileCopyrightText: 2015 Aleix Pol Gonzalez <aleixpol@kde.org>
|
2015-09-08 16:28:47 +01:00
|
|
|
*
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
2015-09-08 16:28:47 +01:00
|
|
|
*/
|
|
|
|
|
2019-12-09 22:14:19 +00:00
|
|
|
#include <QCoreApplication>
|
2015-09-08 16:28:47 +01:00
|
|
|
#include <QSignalSpy>
|
2022-09-10 22:23:52 +01:00
|
|
|
#include <QSocketNotifier>
|
2015-09-08 16:28:47 +01:00
|
|
|
#include <QStandardPaths>
|
2022-09-10 22:23:52 +01:00
|
|
|
#include <QTemporaryFile>
|
|
|
|
#include <QTest>
|
2015-09-08 16:28:47 +01:00
|
|
|
|
|
|
|
#include "core/daemon.h"
|
|
|
|
#include "core/device.h"
|
|
|
|
#include "core/kdeconnectplugin.h"
|
|
|
|
#include "kdeconnect-version.h"
|
2015-12-05 23:08:02 +00:00
|
|
|
#include "testdaemon.h"
|
2022-09-10 22:23:52 +01:00
|
|
|
#include <backends/pairinghandler.h>
|
2015-09-08 16:28:47 +01:00
|
|
|
|
|
|
|
class PluginLoadTest : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2022-09-10 22:23:52 +01:00
|
|
|
public:
|
|
|
|
PluginLoadTest()
|
|
|
|
{
|
|
|
|
QStandardPaths::setTestModeEnabled(true);
|
|
|
|
m_daemon = new TestDaemon;
|
|
|
|
}
|
2015-09-08 16:28:47 +01:00
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
private Q_SLOTS:
|
|
|
|
void testPlugins()
|
|
|
|
{
|
|
|
|
if (!(m_daemon->getLinkProviders().size() > 0)) {
|
|
|
|
QFAIL("No links available, but loopback should have been provided by the test");
|
|
|
|
}
|
2019-06-02 22:26:47 +01:00
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
Device *d = nullptr;
|
|
|
|
const QList<Device *> devicesList = m_daemon->devicesList();
|
|
|
|
for (Device *id : devicesList) {
|
|
|
|
if (id->isReachable()) {
|
2023-06-01 01:25:37 +01:00
|
|
|
if (!id->isPaired())
|
|
|
|
id->requestPairing();
|
2022-09-10 22:23:52 +01:00
|
|
|
d = id;
|
|
|
|
break;
|
2015-09-08 19:11:52 +01:00
|
|
|
}
|
2022-09-10 22:23:52 +01:00
|
|
|
}
|
|
|
|
if (d == nullptr) {
|
|
|
|
QFAIL("Unable to determine device");
|
|
|
|
}
|
2015-09-12 14:17:08 +01:00
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
if (!d->loadedPlugins().contains(QStringLiteral("kdeconnect_remotecontrol"))) {
|
|
|
|
QSKIP("kdeconnect_remotecontrol is required for this test");
|
|
|
|
}
|
2015-09-12 14:17:08 +01:00
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
QVERIFY(d);
|
2023-06-01 01:25:37 +01:00
|
|
|
QVERIFY(d->isPaired());
|
2022-09-10 22:23:52 +01:00
|
|
|
QVERIFY(d->isReachable());
|
2015-09-08 16:28:47 +01:00
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
d->setPluginEnabled(QStringLiteral("kdeconnect_mousepad"), false);
|
|
|
|
QCOMPARE(d->isPluginEnabled(QStringLiteral("kdeconnect_mousepad")), false);
|
|
|
|
QVERIFY(d->supportedPlugins().contains(QStringLiteral("kdeconnect_remotecontrol")));
|
2015-09-08 16:28:47 +01:00
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
d->setPluginEnabled(QStringLiteral("kdeconnect_mousepad"), true);
|
|
|
|
QCOMPARE(d->isPluginEnabled(QStringLiteral("kdeconnect_mousepad")), true);
|
|
|
|
QVERIFY(d->supportedPlugins().contains(QStringLiteral("kdeconnect_remotecontrol")));
|
|
|
|
}
|
2015-09-08 16:28:47 +01:00
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
private:
|
|
|
|
TestDaemon *m_daemon;
|
2015-09-08 16:28:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
QTEST_MAIN(PluginLoadTest);
|
|
|
|
|
|
|
|
#include "pluginloadtest.moc"
|