Fix tests

In case we need to discover the device (i.e. we're running the test in a
clean environment) we need to acquire the discovery mode.
Only initialize the test after setting the test mode enabled, so the
loopback is enabled.
This commit is contained in:
Aleix Pol 2016-06-05 19:19:31 +02:00
parent a594324d4f
commit 55c6014686
2 changed files with 13 additions and 4 deletions

View file

@ -39,19 +39,24 @@ class PluginLoadTest : public QObject
{
Q_OBJECT
public:
PluginLoadTest() : mDaemon(new TestDaemon) {
PluginLoadTest() {
QStandardPaths::setTestModeEnabled(true);
mDaemon = new TestDaemon;
}
private Q_SLOTS:
void testPlugins() {
Device* d = nullptr;
mDaemon->acquireDiscoveryMode("plugintest");
foreach(Device* id, mDaemon->devicesList()) {
if (id->isReachable()) {
id->requestPair();
if (!id->isTrusted())
id->requestPair();
d = id;
break;
}
}
mDaemon->releaseDiscoveryMode("plugintest");
if (!d->loadedPlugins().contains("kdeconnect_remotecontrol")) {
QSKIP("kdeconnect_remotecontrol is required for this test");

View file

@ -39,19 +39,23 @@ class TestSendFile : public QObject
{
Q_OBJECT
public:
TestSendFile() : mDaemon(new TestDaemon) {
TestSendFile() {
QStandardPaths::setTestModeEnabled(true);
mDaemon = new TestDaemon;
}
private Q_SLOTS:
void testSend() {
mDaemon->acquireDiscoveryMode("test");
Device* d = nullptr;
foreach(Device* id, mDaemon->devicesList()) {
if (id->isReachable()) {
id->requestPair();
if (!id->isTrusted())
id->requestPair();
d = id;
}
}
mDaemon->releaseDiscoveryMode("test");
QVERIFY(d);
QCOMPARE(d->isReachable(), true);
QCOMPARE(d->isTrusted(), true);