Add testDestroyWhileRestartPlaying for qsoundeffect

This covers the potential crash reported by qfeedbackmmk test.

Change-Id: Ib533e80b25c4c7fb291527d62445aaa40960baa0
Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
This commit is contained in:
Ling Hu
2011-11-22 16:17:23 +10:00
committed by Qt by Nokia
parent 290523bc4c
commit d2a4f632cd

View File

@@ -65,6 +65,9 @@ private slots:
void testPlaying();
void testStatus();
void testDestroyWhilePlaying();
void testDestroyWhileRestartPlaying();
private:
QSoundEffect* sound;
QUrl url;
@@ -189,6 +192,29 @@ void tst_QSoundEffect::testStatus()
QCOMPARE(sound->status(), QSoundEffect::Error);
}
void tst_QSoundEffect::testDestroyWhilePlaying()
{
QSoundEffect *instance = new QSoundEffect();
instance->setSource(url);
QTestEventLoop::instance().enterLoop(1);
instance->play();
QTest::qWait(500);
delete instance;
QTestEventLoop::instance().enterLoop(1);
}
void tst_QSoundEffect::testDestroyWhileRestartPlaying()
{
QSoundEffect *instance = new QSoundEffect();
instance->setSource(url);
QTestEventLoop::instance().enterLoop(1);
instance->play();
QTest::qWait(1000);
//restart playing
instance->play();
delete instance;
QTestEventLoop::instance().enterLoop(1);
}
QTEST_MAIN(tst_QSoundEffect)