aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/debugger/shared/qqmldebugprocess_p.h
blob: 94554928a58d0489b364600b3abb75043802743f (plain)
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
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#ifndef QQMLDEBUGPROCESS_P_H
#define QQMLDEBUGPROCESS_P_H

//
//  W A R N I N G
//  -------------
//
// This file is not part of the Qt API.  It exists purely as an
// implementation detail.  This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//

#include <QtCore/qprocess.h>
#include <QtCore/qtimer.h>
#include <QtCore/qeventloop.h>
#include <QtCore/qmutex.h>

class QQmlDebugProcess : public QObject
{
    Q_OBJECT
public:
    QQmlDebugProcess(const QString &executable, QObject *parent = nullptr);
    ~QQmlDebugProcess();

    QString stateString() const;

    void addEnvironment(const QString &environment);

    void start(const QStringList &arguments);
    bool waitForSessionStart();
    int debugPort() const;

    bool waitForFinished();
    QProcess::ProcessState state() const;
    QProcess::ExitStatus exitStatus() const;

    QString output() const;
    void stop();
    void setMaximumBindErrors(int numErrors);

Q_SIGNALS:
    void readyReadStandardOutput();
    void finished();

private Q_SLOTS:
    void processAppOutput();
    void processError(QProcess::ProcessError error);

private:
    enum SessionState {
        SessionUnknown,
        SessionStarted,
        SessionFailed
    };

    void timeout();

    QString m_executable;
    QProcess m_process;
    QString m_outputBuffer;
    QString m_output;
    SessionState m_state = SessionUnknown;
    QStringList m_environment;
    int m_port = 0;
    int m_maximumBindErrors = 0;
    int m_receivedBindErrors = 0;
};

#endif // QQMLDEBUGPROCESS_P_H