Add testDestroyWhileRestartPlaying for qsoundeffect
authorLing Hu <ling.hu@nokia.com>
Tue, 22 Nov 2011 06:17:23 +0000 (16:17 +1000)
committerQt by Nokia <qt-info@nokia.com>
Wed, 23 Nov 2011 11:49:52 +0000 (12:49 +0100)
This covers the potential crash reported by qfeedbackmmk test.

Change-Id: Ib533e80b25c4c7fb291527d62445aaa40960baa0
Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
tests/auto/integration/qsoundeffect/tst_qsoundeffect.cpp

index b3797625d8a5e20dc7fe9abd092c4ac116eef922..678d2be3627adf1f9345075ae03a0b225dcb8404 100644 (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)