From bf5c7ca718a4a84e28a17ff69c4b18abee81ff93 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Wed, 10 Aug 2016 12:53:13 +0200 Subject: Make tst_QMediaObject::notifySignals() less flaky Rather than expecting a certain amount of signals to be fired within a fixed period, check that all the required signals are emitted and that it doesn't take longer than expected. Use a margin of error to take into account timers firing later because of high system load. Change-Id: I1569ce524e87efc47eb8d11066e509e5dc90f6f8 (cherry picked from commit 586abbd9732f9ccce127429fe0698c25a09ecefb) Reviewed-by: Christian Stromme --- tests/auto/unit/qmediaobject/tst_qmediaobject.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/auto/unit/qmediaobject/tst_qmediaobject.cpp b/tests/auto/unit/qmediaobject/tst_qmediaobject.cpp index 355af5676..e79d9b586 100644 --- a/tests/auto/unit/qmediaobject/tst_qmediaobject.cpp +++ b/tests/auto/unit/qmediaobject/tst_qmediaobject.cpp @@ -293,14 +293,19 @@ void tst_QMediaObject::notifySignals() QFETCH(int, count); QtTestMediaObject object; + QSignalSpy spy(&object, SIGNAL(aChanged(int))); + object.setNotifyInterval(interval); object.addPropertyWatch("a"); - QSignalSpy spy(&object, SIGNAL(aChanged(int))); + QElapsedTimer timer; + timer.start(); - QTestEventLoop::instance().enterLoop(1); + QTRY_COMPARE(spy.count(), count); - QCOMPARE(spy.count(), count); + qint64 elapsed = timer.elapsed(); + int expectedElapsed = count * interval * 1.3; // give it some margin of error + QVERIFY2(elapsed < expectedElapsed, QString("elapsed: %1, expected: %2").arg(elapsed).arg(expectedElapsed).toLocal8Bit().constData()); } void tst_QMediaObject::notifyInterval_data() -- cgit v1.2.3 From 7d00a457e455e159a3dde30ad798be744cf38bb1 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Wed, 21 Sep 2016 10:59:20 +0300 Subject: Stabilize tst_QAudioOutput::pullSuspendResume() Don't wait after resume(); the test is meant to check the state of the QAudioOutput right after the call, not later. The state and the error status are supposed to change immediately, even if the backend runs in another thread. Ignore any state change that can happen because of underrun errors (likely to happen on CI). Removed the test from blacklist. Change-Id: Idaef6a9e0dfcfc89424fb2383cf3830a3184f975 Reviewed-by: Milla Pohjanheimo Reviewed-by: Christian Stromme --- tests/auto/integration/qaudiooutput/BLACKLIST | 5 ----- tests/auto/integration/qaudiooutput/tst_qaudiooutput.cpp | 7 ++----- 2 files changed, 2 insertions(+), 10 deletions(-) delete mode 100644 tests/auto/integration/qaudiooutput/BLACKLIST (limited to 'tests') diff --git a/tests/auto/integration/qaudiooutput/BLACKLIST b/tests/auto/integration/qaudiooutput/BLACKLIST deleted file mode 100644 index 4d45efe06..000000000 --- a/tests/auto/integration/qaudiooutput/BLACKLIST +++ /dev/null @@ -1,5 +0,0 @@ -[pullSuspendResume] -redhatenterpriselinuxworkstation-6.6 -rhel-7.1 -ubuntu-14.04 -opensuse-13.1 64bit diff --git a/tests/auto/integration/qaudiooutput/tst_qaudiooutput.cpp b/tests/auto/integration/qaudiooutput/tst_qaudiooutput.cpp index b887d3f9a..dfe9d3e54 100644 --- a/tests/auto/integration/qaudiooutput/tst_qaudiooutput.cpp +++ b/tests/auto/integration/qaudiooutput/tst_qaudiooutput.cpp @@ -612,9 +612,6 @@ void tst_QAudioOutput::pullSuspendResume() audioOutput.resume(); - // Give backends running in separate threads a chance to suspend. - QTest::qWait(100); - // Check that QAudioOutput immediately transitions to ActiveState QVERIFY2((stateSignal.count() == 1), QString("didn't emit signal after resume(), got %1 signals instead").arg(stateSignal.count()).toLocal8Bit().constData()); @@ -626,8 +623,8 @@ void tst_QAudioOutput::pullSuspendResume() QTest::qWait(3000); // 3 seconds should be plenty QVERIFY2(audioFile->atEnd(), "didn't play to EOF"); - QVERIFY2((stateSignal.count() == 1), - QString("didn't emit IdleState signal when at EOF, got %1 signals instead").arg(stateSignal.count()).toLocal8Bit().constData()); + QVERIFY(stateSignal.count() > 0); + QCOMPARE(qvariant_cast(stateSignal.last().at(0)), QAudio::IdleState); QVERIFY2((audioOutput.state() == QAudio::IdleState), "didn't transitions to IdleState when at EOF"); stateSignal.clear(); -- cgit v1.2.3