File: syncthingtestinstance.h

package info (click to toggle)
syncthingtray 1.7.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,804 kB
  • sloc: cpp: 31,085; xml: 1,694; java: 570; sh: 81; javascript: 53; makefile: 25
file content (79 lines) | stat: -rw-r--r-- 1,980 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef SYNCTHINGTESTHELPER_SYNCTHINGTESTINSTANCE_H
#define SYNCTHINGTESTHELPER_SYNCTHINGTESTINSTANCE_H

#include "./global.h"
#include "./helper.h"

#include <syncthingconnector/syncthingprocess.h>

#include <QCoreApplication>
#include <QProcess>

using namespace std;

namespace CppUtilities {

/*!
 * \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.
 */
class SYNCTHINGTESTHELPER_EXPORT SyncthingTestInstance {
public:
    SyncthingTestInstance();

    const QString &apiKey() const;
    const QString &syncthingPort() const;
    QCoreApplication &application();
    Data::SyncthingProcess &syncthingProcess();

public:
    void start();
    void stop();
    bool isInterleavedOutputEnabled() const;
    void setInterleavedOutputEnabled(bool interleavedOutputEnabled);
    void setInterleavedOutputEnabledFromEnv();

private:
    void handleError(QProcess::ProcessError error);
    void handleFinished(int exitCode, QProcess::ExitStatus exitStatus);

private:
    QString m_apiKey;
    QString m_syncthingPort;
    QCoreApplication m_app;
    Data::SyncthingProcess m_syncthingProcess;
    bool m_interleavedOutput;
    bool m_processSupposedToRun;
};

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;
}

inline Data::SyncthingProcess &SyncthingTestInstance::syncthingProcess()
{
    return m_syncthingProcess;
}

/*!
 * \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;
}
} // namespace CppUtilities

#endif // SYNCTHINGTESTHELPER_SYNCTHINGTESTINSTANCE_H