File indexing completed on 2024-04-28 08:49:15
0001 /** 0002 * SPDX-FileCopyrightText: 2015 Aleix Pol Gonzalez <aleixpol@kde.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #include <QCoreApplication> 0008 #include <QSignalSpy> 0009 #include <QSocketNotifier> 0010 #include <QStandardPaths> 0011 #include <QTemporaryFile> 0012 #include <QTest> 0013 0014 #include "core/daemon.h" 0015 #include "core/device.h" 0016 #include "core/kdeconnectplugin.h" 0017 #include "kdeconnect-version.h" 0018 #include "testdaemon.h" 0019 #include <backends/pairinghandler.h> 0020 0021 class PluginLoadTest : public QObject 0022 { 0023 Q_OBJECT 0024 public: 0025 PluginLoadTest() 0026 { 0027 QStandardPaths::setTestModeEnabled(true); 0028 m_daemon = new TestDaemon; 0029 } 0030 0031 private Q_SLOTS: 0032 void testPlugins() 0033 { 0034 if (!(m_daemon->getLinkProviders().size() > 0)) { 0035 QFAIL("No links available, but loopback should have been provided by the test"); 0036 } 0037 0038 Device *d = nullptr; 0039 const QList<Device *> devicesList = m_daemon->devicesList(); 0040 for (Device *id : devicesList) { 0041 if (id->isReachable()) { 0042 if (!id->isPaired()) 0043 id->requestPairing(); 0044 d = id; 0045 break; 0046 } 0047 } 0048 if (d == nullptr) { 0049 QFAIL("Unable to determine device"); 0050 } 0051 0052 if (!d->loadedPlugins().contains(QStringLiteral("kdeconnect_remotecontrol"))) { 0053 QSKIP("kdeconnect_remotecontrol is required for this test"); 0054 } 0055 0056 QVERIFY(d); 0057 QVERIFY(d->isPaired()); 0058 QVERIFY(d->isReachable()); 0059 0060 d->setPluginEnabled(QStringLiteral("kdeconnect_mousepad"), false); 0061 QCOMPARE(d->isPluginEnabled(QStringLiteral("kdeconnect_mousepad")), false); 0062 QVERIFY(d->supportedPlugins().contains(QStringLiteral("kdeconnect_remotecontrol"))); 0063 0064 d->setPluginEnabled(QStringLiteral("kdeconnect_mousepad"), true); 0065 QCOMPARE(d->isPluginEnabled(QStringLiteral("kdeconnect_mousepad")), true); 0066 QVERIFY(d->supportedPlugins().contains(QStringLiteral("kdeconnect_remotecontrol"))); 0067 } 0068 0069 private: 0070 TestDaemon *m_daemon; 0071 }; 0072 0073 QTEST_MAIN(PluginLoadTest); 0074 0075 #include "pluginloadtest.moc"