summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/io/qprocess/tst_qprocess.cpp')
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index f01e319872..613bfd5c17 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -152,6 +152,7 @@ private slots:
void invalidProgramString_data();
void invalidProgramString();
void onlyOneStartedSignal();
+ void finishProcessBeforeReadingDone();
// keep these at the end, since they use lots of processes and sometimes
// caused obscure failures to occur in tests that followed them (esp. on the Mac)
@@ -2168,6 +2169,39 @@ void tst_QProcess::onlyOneStartedSignal()
QCOMPARE(spyFinished.count(), 1);
}
+//-----------------------------------------------------------------------------
+
+class BlockOnReadStdOut : public QObject
+{
+ Q_OBJECT
+public:
+ BlockOnReadStdOut(QProcess *process)
+ {
+ connect(process, SIGNAL(readyReadStandardOutput()), SLOT(block()));
+ }
+
+public slots:
+ void block()
+ {
+ QThread::sleep(1);
+ }
+};
+
+void tst_QProcess::finishProcessBeforeReadingDone()
+{
+ QProcess process;
+ BlockOnReadStdOut blocker(&process);
+ QEventLoop loop;
+ connect(&process, SIGNAL(finished(int)), &loop, SLOT(quit()));
+ process.start("testProcessOutput/testProcessOutput");
+ QVERIFY(process.waitForStarted());
+ loop.exec();
+ QStringList lines = QString::fromLocal8Bit(process.readAllStandardOutput()).split(
+ QRegExp(QStringLiteral("[\r\n]")), QString::SkipEmptyParts);
+ QVERIFY(!lines.isEmpty());
+ QCOMPARE(lines.last(), QStringLiteral("10239 -this is a number"));
+}
+
#endif //QT_NO_PROCESS
QTEST_MAIN(tst_QProcess)