Simulate flaky syncthing service

This commit is contained in:
Martchus 2018-12-23 21:28:43 +01:00
parent adc0fa724e
commit 35903fc996
1 changed files with 15 additions and 1 deletions

View File

@ -82,7 +82,7 @@ SyncthingService::SyncthingService(QObject *parent)
connect(m_serviceWatcher, &QDBusServiceWatcher::serviceRegistered, this, &SyncthingService::handleServiceRegisteredChanged);
connect(m_serviceWatcher, &QDBusServiceWatcher::serviceUnregistered, this, &SyncthingService::handleServiceRegisteredChanged);
#else
// let the mocked service initially be stopped and simulate start after 5 seconds
// let the mocked service initially be stopped and simulate start after 5 seconds, then stop after 10 seconds and start after 15 seconds
QTimer::singleShot(5000, this, [this] {
m_activeSince = DateTime::gmtNow() - TimeSpan::fromMilliseconds(250);
handlePropertiesChanged(QStringLiteral("syncthing.mocked-service"),
@ -90,6 +90,20 @@ SyncthingService::SyncthingService(QObject *parent)
{ QStringLiteral("Description"), QStringLiteral("This service is fake.") } },
QStringList());
});
QTimer::singleShot(10000, this, [this] {
m_activeSince = DateTime();
handlePropertiesChanged(QStringLiteral("syncthing.mocked-service"),
QVariantMap{ { QStringLiteral("ActiveState"), QStringLiteral("inactive") }, { QStringLiteral("SubState"), QStringLiteral("dead") },
{ QStringLiteral("Description"), QStringLiteral("This service is still fake.") } },
QStringList());
});
QTimer::singleShot(15000, this, [this] {
m_activeSince = DateTime::gmtNow();
handlePropertiesChanged(QStringLiteral("syncthing.mocked-service"),
QVariantMap{ { QStringLiteral("ActiveState"), QStringLiteral("active") }, { QStringLiteral("SubState"), QStringLiteral("running") },
{ QStringLiteral("Description"), QStringLiteral("This service is alive again!") } },
QStringList());
});
#endif
}