--- a/tests/auto/mediaobject/tst_mediaobject.cpp Wed Apr 21 12:15:23 2010 +0300
+++ b/tests/auto/mediaobject/tst_mediaobject.cpp Wed Apr 21 20:15:53 2010 +0300
@@ -193,31 +193,17 @@
return *reinterpret_cast<const qint32 *>(variant.constData());
}
-static const char *const red = "\033[0;31m";
-static const char *const green = "\033[0;32m";
-static const char *const yellow = "\033[0;33m";
-static const char *const blue = "\033[0;34m";
-static const char *const purple = "\033[0;35m";
-static const char *const cyan = "\033[0;36m";
-static const char *const white = "\033[0;37m";
-static const char *const normal = "\033[0m";
-
void tst_MediaObject::stateChanged(Phonon::State newstate, Phonon::State oldstate)
{
- if (newstate == Phonon::ErrorState) {
- QWARN(QByteArray(QByteArray(red) + ".......................................................... ") + QByteArray(QTest::toString(oldstate)) + " to " + QByteArray(QTest::toString(newstate)) + normal);
- } else {
- //qDebug() << ".........................................................." << cyan << QTest::toString(oldstate) << "to" << QTest::toString(newstate) << normal;
- }
+ if (newstate == Phonon::ErrorState)
+ QWARN(QByteArray(QByteArray(QTest::toString(oldstate)) + " to " + QByteArray(QTest::toString(newstate))));
}
void tst_MediaObject::testPlayFromResource()
{
#ifdef Q_OS_SYMBIAN
QSKIP("Not implemented yet.", SkipAll);
- return;
-#endif
-
+#else
QFile file(MEDIA_FILEPATH);
MediaObject media;
media.setCurrentSource(&file);
@@ -229,6 +215,7 @@
if (media.state() != Phonon::PlayingState)
QTest::waitForSignal(&media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), 10000);
QCOMPARE(media.state(), Phonon::PlayingState);
+#endif
}
void tst_MediaObject::testPlayIllegalFile()
@@ -264,6 +251,13 @@
}
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()
@@ -579,13 +573,18 @@
if (m_media->state() != Phonon::StoppedState)
QTest::waitForSignal(m_media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), 10000);
- // At this point we're in error state due to absent media, but it has now loaded the SDP:
- QCOMPARE(m_media->errorString(), QString::fromLatin1("Buffering clip failed: Unknown error (-39)"));
+ // MediaObject should have loaded the SDP, but be in error state due to absent media
+ const bool stateMatch = (m_media->state() == Phonon::ErrorState);
+ const bool errorStringMatch = (m_media->errorString() == QString::fromLatin1("Loading clip failed: Unknown error (-39)"));
- // We cannot play the SDP, we can neither attempt to play it, because we
- // won't get a state change from ErrorState to ErrorState, and hence block
- // on a never occuring signal.
+ // Ensure that m_media is back in ground state prior to starting next test step
m_media->setCurrentSource(oldSource);
+ if (m_media->state() != Phonon::StoppedState)
+ QTest::waitForSignal(m_media, SIGNAL(stateChanged(Phonon::State, Phonon::State)));
+ QCOMPARE(m_media->state(), Phonon::StoppedState);
+
+ QVERIFY(stateMatch);
+ QVERIFY(errorStringMatch);
#else
QSKIP("Unsupported on this platform.", SkipAll);