summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJøger Hansegård <joger.hansegard@qt.io>2024-03-25 12:13:29 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2024-03-26 20:10:15 +0000
commit10d5015f1d6553e07b4968630b1879611373eef4 (patch)
tree46515ecde98193fc9adef7ae3654283629660e6b
parent469ae2acab2b0330b2510b7760b74a2995e49bb1 (diff)
Test that QAudioDecoder emits error when source has no audio track
This patch adds a test that verifies that QAudioDecoder is well behaved when no audio track is present in the input media file. Task-number: QTBUG-123597 Pick-to: 6.5 Change-Id: Iecf745cab3b0cd70506399c06d9a7fdd15d29e8a Reviewed-by: Artem Dyomin <artem.dyomin@qt.io> (cherry picked from commit cd8330b98314faf1bbdd069e5c74e0e97765260b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 301900232721c035f3caad2d5146f940abf0fe15)
-rw-r--r--tests/auto/integration/qaudiodecoderbackend/testdata/test-no-audio-track.mp4bin0 -> 1589 bytes
-rw-r--r--tests/auto/integration/qaudiodecoderbackend/tst_qaudiodecoderbackend.cpp23
2 files changed, 19 insertions, 4 deletions
diff --git a/tests/auto/integration/qaudiodecoderbackend/testdata/test-no-audio-track.mp4 b/tests/auto/integration/qaudiodecoderbackend/testdata/test-no-audio-track.mp4
new file mode 100644
index 000000000..6b67a3433
--- /dev/null
+++ b/tests/auto/integration/qaudiodecoderbackend/testdata/test-no-audio-track.mp4
Binary files differ
diff --git a/tests/auto/integration/qaudiodecoderbackend/tst_qaudiodecoderbackend.cpp b/tests/auto/integration/qaudiodecoderbackend/tst_qaudiodecoderbackend.cpp
index 3b3864491..f26b23977 100644
--- a/tests/auto/integration/qaudiodecoderbackend/tst_qaudiodecoderbackend.cpp
+++ b/tests/auto/integration/qaudiodecoderbackend/tst_qaudiodecoderbackend.cpp
@@ -7,10 +7,11 @@
#include "../shared/mediafileselector.h"
-#define TEST_FILE_NAME "testdata/test.wav"
-#define TEST_UNSUPPORTED_FILE_NAME "testdata/test-unsupported.avi"
-#define TEST_CORRUPTED_FILE_NAME "testdata/test-corrupted.wav"
-#define TEST_INVALID_SOURCE "invalid"
+constexpr char TEST_FILE_NAME[] = "testdata/test.wav";
+constexpr char TEST_UNSUPPORTED_FILE_NAME[] = "testdata/test-unsupported.avi";
+constexpr char TEST_CORRUPTED_FILE_NAME[] = "testdata/test-corrupted.wav";
+constexpr char TEST_INVALID_SOURCE[] = "invalid";
+constexpr char TEST_NO_AUDIO_TRACK[] = "testdata/test-no-audio-track.mp4";
QT_USE_NAMESPACE
@@ -42,6 +43,7 @@ private slots:
void corruptedFileTest();
void invalidSource();
void deviceTest();
+ void play_emitsFormatError_whenMediaHasNoAudioTrack();
private:
QUrl testFileUrl(const QString filePath);
@@ -921,6 +923,19 @@ void tst_QAudioDecoderBackend::deviceTest()
QCOMPARE(d.duration(), qint64(-1));
}
+void tst_QAudioDecoderBackend::play_emitsFormatError_whenMediaHasNoAudioTrack() {
+ QAudioDecoder decoder;
+
+ QSignalSpy errors{ &decoder, qOverload<QAudioDecoder::Error>(&QAudioDecoder::error) };
+
+ decoder.setSource(testFileUrl(TEST_NO_AUDIO_TRACK));
+ decoder.start();
+
+ QTRY_VERIFY(!errors.empty());
+
+ QCOMPARE_EQ(decoder.error(), QAudioDecoder::Error::FormatError);
+}
+
QTEST_MAIN(tst_QAudioDecoderBackend)
#include "tst_qaudiodecoderbackend.moc"