2017-04-01 16:56:36 +02:00
|
|
|
#ifndef SYNCTHINGTESTHELPER_SYNCTHINGTESTINSTANCE_H
|
|
|
|
#define SYNCTHINGTESTHELPER_SYNCTHINGTESTINSTANCE_H
|
|
|
|
|
|
|
|
#include "./global.h"
|
|
|
|
#include "./helper.h"
|
|
|
|
|
2021-01-25 19:48:11 +01:00
|
|
|
#include <syncthingconnector/syncthingprocess.h>
|
2017-07-09 23:34:43 +02:00
|
|
|
|
2017-04-01 16:56:36 +02:00
|
|
|
#include <QCoreApplication>
|
|
|
|
#include <QProcess>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2019-06-10 22:48:26 +02:00
|
|
|
namespace CppUtilities {
|
2017-07-14 16:23:32 +02:00
|
|
|
|
2017-04-01 16:56:36 +02:00
|
|
|
/*!
|
|
|
|
* \brief The SyncthingTestInstance class provides running a test instance of Syncthing.
|
|
|
|
*
|
|
|
|
* The class is meant to be subclassed by tests requiring a running Syncthing instance.
|
|
|
|
*/
|
2017-05-01 03:34:43 +02:00
|
|
|
class SYNCTHINGTESTHELPER_EXPORT SyncthingTestInstance {
|
2017-04-01 16:56:36 +02:00
|
|
|
public:
|
|
|
|
SyncthingTestInstance();
|
|
|
|
|
|
|
|
const QString &apiKey() const;
|
|
|
|
const QString &syncthingPort() const;
|
2018-01-27 16:04:17 +01:00
|
|
|
QCoreApplication &application();
|
2021-06-09 20:59:09 +02:00
|
|
|
Data::SyncthingProcess &syncthingProcess();
|
2017-04-01 16:56:36 +02:00
|
|
|
|
2022-10-29 21:05:13 +02:00
|
|
|
public:
|
2017-04-01 16:56:36 +02:00
|
|
|
void start();
|
|
|
|
void stop();
|
2018-10-20 23:48:24 +02:00
|
|
|
bool isInterleavedOutputEnabled() const;
|
|
|
|
void setInterleavedOutputEnabled(bool interleavedOutputEnabled);
|
|
|
|
void setInterleavedOutputEnabledFromEnv();
|
2017-04-01 16:56:36 +02:00
|
|
|
|
2022-10-29 21:22:21 +02:00
|
|
|
private:
|
|
|
|
void handleError(QProcess::ProcessError error);
|
|
|
|
void handleFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
|
|
|
|
2017-04-01 16:56:36 +02:00
|
|
|
private:
|
|
|
|
QString m_apiKey;
|
|
|
|
QString m_syncthingPort;
|
|
|
|
QCoreApplication m_app;
|
2017-07-09 23:34:43 +02:00
|
|
|
Data::SyncthingProcess m_syncthingProcess;
|
2018-10-20 23:48:24 +02:00
|
|
|
bool m_interleavedOutput;
|
2022-10-29 21:22:21 +02:00
|
|
|
bool m_processSupposedToRun;
|
2017-04-01 16:56:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
inline const QString &SyncthingTestInstance::apiKey() const
|
|
|
|
{
|
|
|
|
return m_apiKey;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const QString &SyncthingTestInstance::syncthingPort() const
|
|
|
|
{
|
|
|
|
return m_syncthingPort;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline QCoreApplication &SyncthingTestInstance::application()
|
|
|
|
{
|
|
|
|
return m_app;
|
|
|
|
}
|
|
|
|
|
2021-06-09 20:59:09 +02:00
|
|
|
inline Data::SyncthingProcess &SyncthingTestInstance::syncthingProcess()
|
2017-04-01 16:56:36 +02:00
|
|
|
{
|
|
|
|
return m_syncthingProcess;
|
|
|
|
}
|
2018-10-20 23:48:24 +02:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Whether Syncthing's output should be forwarded to see what Syncthing and the test is doing at the same time.
|
|
|
|
*/
|
|
|
|
inline bool SyncthingTestInstance::isInterleavedOutputEnabled() const
|
|
|
|
{
|
|
|
|
return m_interleavedOutput;
|
|
|
|
}
|
2019-06-10 22:48:26 +02:00
|
|
|
} // namespace CppUtilities
|
2017-04-01 16:56:36 +02:00
|
|
|
|
|
|
|
#endif // SYNCTHINGTESTHELPER_SYNCTHINGTESTINSTANCE_H
|