diff options
author | Rainer Keller <Rainer.Keller@qt.io> | 2018-09-20 11:11:42 +0200 |
---|---|---|
committer | Rainer Keller <Rainer.Keller@qt.io> | 2018-10-04 06:07:44 +0000 |
commit | 5e5cb0729866f2cb0c04e29f5ed34030d0cfa0f7 (patch) | |
tree | 2f46ea3562f7d7d36e0b8290ca296f3b0353a61d | |
parent | 34b086c44fa140a42b7e178b38b2dda77172e5fe (diff) |
qml: Use finished signal from tests to kill server
Task-number: QTBUG-70618
Change-Id: I564411c426537a5746ed90a7ec9e5281128c2641
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r-- | tests/auto/declarative/tst_opcua.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/tests/auto/declarative/tst_opcua.cpp b/tests/auto/declarative/tst_opcua.cpp index f0beb51..a14b05d 100644 --- a/tests/auto/declarative/tst_opcua.cpp +++ b/tests/auto/declarative/tst_opcua.cpp @@ -52,12 +52,10 @@ class SetupClass : public QObject Q_OBJECT public: SetupClass() { - m_serverProcess = new QProcess(); }; ~SetupClass() { - if (m_serverProcess && m_serverProcess->state() == QProcess::Running) - m_serverProcess->kill(); } + public slots: void applicationAvailable() { const quint16 defaultPort = 43344; @@ -94,9 +92,9 @@ public slots: server.close(); qDebug() << "Starting test server"; - m_serverProcess->setProcessChannelMode(QProcess::ForwardedChannels); - m_serverProcess->start(m_testServerPath); - QVERIFY2(m_serverProcess->waitForStarted(), qPrintable(m_serverProcess->errorString())); + m_serverProcess.setProcessChannelMode(QProcess::ForwardedChannels); + m_serverProcess.start(m_testServerPath); + QVERIFY2(m_serverProcess.waitForStarted(), qPrintable(m_serverProcess.errorString())); // Let the server come up QTest::qSleep(2000); } @@ -107,8 +105,14 @@ public slots: Q_UNUSED(engine); // nothing } + void cleanupTestCase() { + if (m_serverProcess.state() == QProcess::Running) { + m_serverProcess.kill(); + m_serverProcess.waitForFinished(2000); + } + } private: - QProcess *m_serverProcess = nullptr; + QProcess m_serverProcess; QString m_testServerPath; }; |