summaryrefslogtreecommitdiffstats
path: root/tests/auto/mediaobject
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/mediaobject')
-rw-r--r--tests/auto/mediaobject/qtesthelper.h1
-rw-r--r--tests/auto/mediaobject/tst_mediaobject.cpp43
2 files changed, 21 insertions, 23 deletions
diff --git a/tests/auto/mediaobject/qtesthelper.h b/tests/auto/mediaobject/qtesthelper.h
index f082296..39d5b91 100644
--- a/tests/auto/mediaobject/qtesthelper.h
+++ b/tests/auto/mediaobject/qtesthelper.h
@@ -215,7 +215,6 @@ namespace QTest
default:
return 0;
}
- return 0;
}
} // namespace QTest
QT_END_NAMESPACE
diff --git a/tests/auto/mediaobject/tst_mediaobject.cpp b/tests/auto/mediaobject/tst_mediaobject.cpp
index 5b0943e..994057b 100644
--- a/tests/auto/mediaobject/tst_mediaobject.cpp
+++ b/tests/auto/mediaobject/tst_mediaobject.cpp
@@ -193,31 +193,17 @@ static qint32 castQVariantToInt32(const QVariant &variant)
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 @@ void tst_MediaObject::testPlayFromResource()
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 @@ 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()
@@ -579,13 +573,18 @@ void tst_MediaObject::playSDP()
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);