QSound/QSoundEffect: Use QFINDTESTDATA to locate test data.

Replace SRCDIR define by QFINDTESTDATA, which is the standard
method of locating test data. Remove apparently unused code path
within QT_QSOUNDEFFECT_USEAPPLICATIONPATH.

Change-Id: Id7120e75af727839ad2d1d2b3ef25c7ef2122fa5
Reviewed-by: Mithra Pattison <mithra.pattison@nokia.com>
Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
This commit is contained in:
Friedemann Kleint
2012-01-03 13:41:33 +01:00
committed by Qt by Nokia
parent 502d3c8eb3
commit 55c0505a00
4 changed files with 14 additions and 12 deletions

View File

@@ -7,6 +7,3 @@ CONFIG += no_private_qt_headers_warning
# CONFIG += testcase # CONFIG += testcase
SOURCES += tst_qsound.cpp SOURCES += tst_qsound.cpp
DEFINES += SRCDIR=\\\"$$PWD/\\\"

View File

@@ -67,7 +67,10 @@ private:
void tst_QSound::initTestCase() void tst_QSound::initTestCase()
{ {
sound = new QSound(QString(SRCDIR "test.wav"), this); const QString testFileName = QStringLiteral("test.wav");
const QString fullPath = QFINDTESTDATA(testFileName);
QVERIFY2(!fullPath.isEmpty(), qPrintable(QStringLiteral("Unable to locate ") + testFileName));
sound = new QSound(fullPath, this);
QVERIFY(!sound->fileName().isEmpty()); QVERIFY(!sound->fileName().isEmpty());
QCOMPARE(sound->loops(),1); QCOMPARE(sound->loops(),1);
@@ -120,7 +123,11 @@ void tst_QSound::testStop()
void tst_QSound::testStaticPlay() void tst_QSound::testStaticPlay()
{ {
// Check that you hear sound with static play also. // Check that you hear sound with static play also.
QSound::play(QString(SRCDIR "test2.wav")); const QString testFileName = QStringLiteral("test2.wav");
const QString fullPath = QFINDTESTDATA(testFileName);
QVERIFY2(!fullPath.isEmpty(), qPrintable(QStringLiteral("Unable to locate ") + testFileName));
QSound::play(fullPath);
QTest::qWait(1000); QTest::qWait(1000);
} }

View File

@@ -8,8 +8,6 @@ CONFIG += no_private_qt_headers_warning
SOURCES += tst_qsoundeffect.cpp SOURCES += tst_qsoundeffect.cpp
DEFINES += SRCDIR=\\\"$$PWD/\\\"
unix:!mac { unix:!mac {
!contains(QT_CONFIG, pulseaudio) { !contains(QT_CONFIG, pulseaudio) {
DEFINES += QT_MULTIMEDIA_QMEDIAPLAYER DEFINES += QT_MULTIMEDIA_QMEDIAPLAYER

View File

@@ -75,11 +75,11 @@ private:
void tst_QSoundEffect::initTestCase() void tst_QSoundEffect::initTestCase()
{ {
#ifdef QT_QSOUNDEFFECT_USEAPPLICATIONPATH const QString testFileName = QStringLiteral("test.wav");
url = QUrl::fromLocalFile(QCoreApplication::applicationDirPath() + QString("/test.wav")); const QString fullPath = QFINDTESTDATA(testFileName);
#else QVERIFY2(!fullPath.isEmpty(), qPrintable(QStringLiteral("Unable to locate ") + testFileName));
url = QUrl::fromLocalFile(QString(SRCDIR "test.wav"));
#endif url = QUrl::fromLocalFile(fullPath);
sound = new QSoundEffect(this); sound = new QSoundEffect(this);