diff options
author | Christian Strømme <christian.stromme@nokia.com> | 2011-06-03 15:55:09 (GMT) |
---|---|---|
committer | Christian Strømme <christian.stromme@nokia.com> | 2011-07-07 11:02:27 (GMT) |
commit | 999047177846695a809aa1a730330ce676d85959 (patch) | |
tree | e6af2dff2c13f4a75a17019a01116721f3e44444 /tests/auto/qprocess | |
parent | f650c43d130d28fa7eca2f6accf8aacd76ae508d (diff) | |
download | Qt-999047177846695a809aa1a730330ce676d85959.zip Qt-999047177846695a809aa1a730330ce676d85959.tar.gz Qt-999047177846695a809aa1a730330ce676d85959.tar.bz2 |
Fix QProcess emitting two started signals on X11
On X11 QProcess would emit two started signals when calling
QProcess::waitForStarted(). We should expect that the private
implementation of waitForStarted() should emit the started signal
and return true or false appropriately.
Task-number: QTBUG-7039
Change-Id: I3d381399ab7a39bf57db03a110fa6747a4fc6a24
Reviewed-on: http://codereview.qt.nokia.com/331
Reviewed-by: Thiago Macieira <thiago.macieira@nokia.com>
(cherry picked from commit 883b120d2f39c532cdd1a98d962af83be5adc4bd)
Diffstat (limited to 'tests/auto/qprocess')
-rw-r--r-- | tests/auto/qprocess/tst_qprocess.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/tests/auto/qprocess/tst_qprocess.cpp b/tests/auto/qprocess/tst_qprocess.cpp index 91e0abe..f54dfa3 100644 --- a/tests/auto/qprocess/tst_qprocess.cpp +++ b/tests/auto/qprocess/tst_qprocess.cpp @@ -73,7 +73,7 @@ Q_DECLARE_METATYPE(QProcess::ProcessState); { \ const bool ret = Process.Fn; \ if (ret == false) \ - qWarning("QProcess error: %d: %s", Process.error(), qPrintable(Process.errorString())); \ + qWarning("QProcess error: %d: %s", Process.error(), qPrintable(Process.errorString())); \ QVERIFY(ret); \ } @@ -157,6 +157,7 @@ private slots: void startFinishStartFinish(); void invalidProgramString_data(); void invalidProgramString(); + void onlyOneStartedSignal(); // 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) @@ -2089,7 +2090,7 @@ void tst_QProcess::setStandardInputFile() #endif QPROCESS_VERIFY(process, waitForFinished()); - QByteArray all = process.readAll(); + QByteArray all = process.readAll(); QCOMPARE(all.size(), int(sizeof data) - 1); // testProcessEcho drops the ending \0 QVERIFY(all == data); } @@ -2442,6 +2443,29 @@ void tst_QProcess::invalidProgramString() QVERIFY(!QProcess::startDetached(programString)); } +//----------------------------------------------------------------------------- +void tst_QProcess::onlyOneStartedSignal() +{ + QProcess process; + + QSignalSpy spyStarted(&process, SIGNAL(started())); + QSignalSpy spyFinished(&process, SIGNAL(finished(int, QProcess::ExitStatus))); + + process.start("testProcessNormal/testProcessNormal"); + QVERIFY(process.waitForStarted(5000)); + QVERIFY(process.waitForFinished(5000)); + QCOMPARE(spyStarted.count(), 1); + QCOMPARE(spyFinished.count(), 1); + + spyStarted.clear(); + spyFinished.clear(); + + process.start("testProcessNormal/testProcessNormal"); + QVERIFY(process.waitForFinished(5000)); + QCOMPARE(spyStarted.count(), 1); + QCOMPARE(spyFinished.count(), 1); +} + QTEST_MAIN(tst_QProcess) #include "tst_qprocess.moc" #endif |