From 151c2a2bd5e764555f32e6141024172e77788efd Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 14 Apr 2010 16:37:21 +0100 Subject: tst_mediaobject: ensure MediaObject is in StoppedState before each step Many of the steps in the tst_mediaobject suite (a) check that the MediaObject is in StoppedState at the start of the step and (b) call stopPlayback() at the end. If, however, a QTest check fails during the test, stopPlayback may not be called. This patch adds a call to MediaObject::stop() in the suite's init() function. This is a symptom of a wider problem with this test suite, namely that it re-uses a single instance of Phonon::MediaObject for all steps. Given the highly stateful nature of MediaObject, this can lead to test steps failing due to some state which was erroneously carried forward from an earlier step. While this test suite design may more faithfully represent real-world usage of Phonon, it makes tracking down the root causes of test failures needlessly difficult. Reviewed-by: Frans Englich --- tests/auto/mediaobject/tst_mediaobject.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/auto/mediaobject/tst_mediaobject.cpp b/tests/auto/mediaobject/tst_mediaobject.cpp index 5328f63..127b775 100644 --- a/tests/auto/mediaobject/tst_mediaobject.cpp +++ b/tests/auto/mediaobject/tst_mediaobject.cpp @@ -251,6 +251,13 @@ void tst_MediaObject::init() } m_stateChangedSignalSpy->clear(); } + + // Ensure that m_media is in StoppedState + if (m_media->state() != Phonon::StoppedState) { + m_media->stop(); + QTest::waitForSignal(m_media, SIGNAL(stateChanged(Phonon::State, Phonon::State))); + QCOMPARE(m_media->state(), Phonon::StoppedState); + } } void tst_MediaObject::cleanup() -- cgit v0.12