diff options
author | Pekka Gehör <pekka.gehor@qt.io> | 2022-02-18 13:13:53 +0200 |
---|---|---|
committer | Pekka Gehör <pekka.gehor@qt.io> | 2022-05-31 13:23:42 +0300 |
commit | 238678e4dd0a45ea13cddbc11dde640a898a1042 (patch) | |
tree | 193c91494a5abfc0d97c276c9447fe0ff34dbd9a /tests | |
parent | 22409061c3d54a9b0c1add92ef0a1c826d3aa446 (diff) |
Android: fix for tst_qaudiodecoderbackend test
QRC files taken to use for Android.
Added a few conditions for Android due to Android limitations.
Fixes: QTBUG-99094
Pick-to: 6.2 6.3
Change-Id: I13afc038ab7f2ea725c2aa1180800fe1d33f53f4
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/integration/qaudiodecoderbackend/tst_qaudiodecoderbackend.cpp | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/tests/auto/integration/qaudiodecoderbackend/tst_qaudiodecoderbackend.cpp b/tests/auto/integration/qaudiodecoderbackend/tst_qaudiodecoderbackend.cpp index c04d7ea2f..f9efea713 100644 --- a/tests/auto/integration/qaudiodecoderbackend/tst_qaudiodecoderbackend.cpp +++ b/tests/auto/integration/qaudiodecoderbackend/tst_qaudiodecoderbackend.cpp @@ -65,6 +65,7 @@ private slots: private: bool isWavSupported(); + QUrl testFileUrl(const QString filePath); }; void tst_QAudioDecoderBackend::init() @@ -91,6 +92,24 @@ bool tst_QAudioDecoderBackend::isWavSupported() #endif } +QUrl tst_QAudioDecoderBackend::testFileUrl(const QString filePath) +{ + QUrl url; +#ifndef Q_OS_ANDROID + QFileInfo fileInfo(QFINDTESTDATA(filePath)); + url = QUrl::fromLocalFile(fileInfo.absoluteFilePath()); +#else + QFile file(":/" + filePath); + QTemporaryFile *temporaryFile = nullptr; + if (file.open(QIODevice::ReadOnly)) { + temporaryFile = QTemporaryFile::createNativeFile(file); + url = QUrl(temporaryFile->fileName()); + } + temporaryFile->deleteLater(); +#endif + return url; +} + void tst_QAudioDecoderBackend::fileTest() { if (!isWavSupported()) @@ -110,8 +129,7 @@ void tst_QAudioDecoderBackend::fileTest() QVERIFY(d.audioFormat() == QAudioFormat()); // Test local file - QFileInfo fileInfo(QFINDTESTDATA(TEST_FILE_NAME)); - QUrl url = QUrl::fromLocalFile(fileInfo.absoluteFilePath()); + QUrl url = testFileUrl(TEST_FILE_NAME); d.setSource(url); QVERIFY(!d.isDecoding()); QVERIFY(!d.bufferAvailable()); @@ -126,7 +144,7 @@ void tst_QAudioDecoderBackend::fileTest() QSignalSpy positionSpy(&d, SIGNAL(positionChanged(qint64))); d.start(); - QTRY_VERIFY(d.isDecoding()); + QTRY_VERIFY(!isDecodingSpy.isEmpty()); QTRY_VERIFY(!readySpy.isEmpty()); QTRY_VERIFY(!bufferChangedSpy.isEmpty()); @@ -192,6 +210,9 @@ void tst_QAudioDecoderBackend::fileTest() finishedSpy.clear(); positionSpy.clear(); +#ifdef Q_OS_ANDROID + QSKIP("Setting a desired audio format is not yet supported on Android", QTest::SkipSingle); +#endif // change output audio format QAudioFormat format; format.setChannelCount(2); @@ -367,8 +388,7 @@ void tst_QAudioDecoderBackend::corruptedFileTest() QVERIFY(d.audioFormat() == QAudioFormat()); // Test local file - QFileInfo fileInfo(QFINDTESTDATA(TEST_CORRUPTED_FILE_NAME)); - QUrl url = QUrl::fromLocalFile(fileInfo.absoluteFilePath()); + QUrl url = testFileUrl(TEST_CORRUPTED_FILE_NAME); d.setSource(url); QVERIFY(!d.isDecoding()); QVERIFY(!d.bufferAvailable()); @@ -422,7 +442,6 @@ void tst_QAudioDecoderBackend::corruptedFileTest() QVERIFY(positionSpy.isEmpty()); QVERIFY(durationSpy.isEmpty()); - d.stop(); QTRY_VERIFY(!d.isDecoding()); QCOMPARE(d.duration(), qint64(-1)); @@ -544,9 +563,12 @@ void tst_QAudioDecoderBackend::deviceTest() QVERIFY(d.bufferAvailable() == false); QCOMPARE(d.source(), QString("")); QVERIFY(d.audioFormat() == QAudioFormat()); - +#ifndef Q_OS_ANDROID QFileInfo fileInfo(QFINDTESTDATA(TEST_FILE_NAME)); QFile file(fileInfo.absoluteFilePath()); +#else + QFile file(":/" TEST_FILE_NAME); +#endif QVERIFY(file.open(QIODevice::ReadOnly)); d.setSourceDevice(&file); @@ -558,7 +580,6 @@ void tst_QAudioDecoderBackend::deviceTest() d.start(); - QTRY_VERIFY(d.isDecoding()); QTRY_VERIFY(!isDecodingSpy.isEmpty()); QTRY_VERIFY(!readySpy.isEmpty()); QTRY_VERIFY(!bufferChangedSpy.isEmpty()); @@ -618,6 +639,9 @@ void tst_QAudioDecoderBackend::deviceTest() finishedSpy.clear(); positionSpy.clear(); +#ifdef Q_OS_ANDROID + QSKIP("Setting a desired audio format is not yet supported on Android", QTest::SkipSingle); +#endif // Now try changing formats QAudioFormat format; format.setChannelCount(2); |