diff options
author | Thomas Hartmann <Thomas.Hartmann@digia.com> | 2012-10-02 11:54:50 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-02 13:22:49 +0200 |
commit | ad4111116720bb03cd6da42e5f6448e511879d24 (patch) | |
tree | a8f5169b84f4b2fa481d390f2714ade9fab67056 /tests/auto | |
parent | a5e3e9eaf16e4b146659f4f5b9227fb2435ee8f2 (diff) |
QProcess.tests: adding test for channel forwarding
This tests QProcess::setProcessChannelMode().
The tests verifies if testForwarding really forwards
the output of testProcessEcho (spawned by testForwarding).
Change-Id: Ifc4164569256aeaeab0edef42116986272362c01
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'tests/auto')
4 files changed, 89 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qprocess/qprocess.pri b/tests/auto/corelib/io/qprocess/qprocess.pri index 4ed64ce11e..299432db77 100644 --- a/tests/auto/corelib/io/qprocess/qprocess.pri +++ b/tests/auto/corelib/io/qprocess/qprocess.pri @@ -16,5 +16,7 @@ SUBPROGRAMS = \ testSetWorkingDirectory \ testSoftExit +!contains(QMAKE_PLATFORM, wince): SUBPROGRAMS += testForwarding + contains(QT_CONFIG, no-widgets): SUBPROGRAMS -= \ testGuiProcess diff --git a/tests/auto/corelib/io/qprocess/testForwarding/main.cpp b/tests/auto/corelib/io/qprocess/testForwarding/main.cpp new file mode 100644 index 0000000000..ca0dc3986a --- /dev/null +++ b/tests/auto/corelib/io/qprocess/testForwarding/main.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore/QProcess> + +int main() +{ + QProcess process; + process.setProcessChannelMode(QProcess::ForwardedChannels); + if (process.processChannelMode() != QProcess::ForwardedChannels) + return -1; + + process.start("testProcessEcho/testProcessEcho"); + + if (!process.waitForStarted(5000)) + return -1; + + if (process.write("forwarded\n") != 10) + return -1; + + process.waitForReadyRead(250); + if (process.bytesAvailable() != 0) + return -1; + + process.closeWriteChannel(); + process.waitForFinished(5000); + + return 0; +} diff --git a/tests/auto/corelib/io/qprocess/testForwarding/testForwarding.pro b/tests/auto/corelib/io/qprocess/testForwarding/testForwarding.pro new file mode 100644 index 0000000000..271c7ead13 --- /dev/null +++ b/tests/auto/corelib/io/qprocess/testForwarding/testForwarding.pro @@ -0,0 +1,4 @@ +SOURCES = main.cpp +CONFIG -= app_bundle +CONFIG += console +DESTDIR = ./ diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index 0d03d00feb..a294dca506 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -110,6 +110,7 @@ private slots: void softExitInSlots(); void mergedChannels(); void forwardedChannels(); + void forwardedChannelsOutput(); void atEnd(); void atEnd2(); void processInAThread(); @@ -1128,6 +1129,21 @@ void tst_QProcess::forwardedChannels() QVERIFY(process.waitForFinished(5000)); } +void tst_QProcess::forwardedChannelsOutput() +{ +#ifdef Q_OS_WINCE + QSKIP("Reading and writing to a process is not supported on Qt/CE"); +#endif + + QProcess process; + process.start("testForwarding/testForwarding"); + QVERIFY(process.waitForStarted(5000)); + QVERIFY(process.waitForFinished(5000)); + QVERIFY(!process.exitCode()); + QByteArray data = process.readAll(); + QVERIFY(!data.isEmpty()); + QVERIFY(data.contains("forwarded")); +} //----------------------------------------------------------------------------- void tst_QProcess::atEnd() |