diff options
author | Uwe Klotz <uklotz@mixxx.org> | 2022-01-06 17:42:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-06 17:42:15 +0100 |
commit | bdf09780425d42082fb1d5f0c5bfb79d865a74a5 (patch) | |
tree | b6614336686eecb5ae7ec012a57ff80daeb10bb5 | |
parent | 67dc7dc6c58b7408aee3282d6093d44180cb548c (diff) | |
parent | 17a4b16970333dcdd337225295054ce0b80355fa (diff) |
Merge pull request #4602 from Holzhaus/soundsource-filetype-detection-fix
Soundsource filetype detection fix
-rw-r--r-- | src/sources/soundsource.cpp | 3 | ||||
-rw-r--r-- | src/test/soundproxy_test.cpp | 15 |
2 files changed, 8 insertions, 10 deletions
diff --git a/src/sources/soundsource.cpp b/src/sources/soundsource.cpp index 71c4b5d3de..e686a4c75a 100644 --- a/src/sources/soundsource.cpp +++ b/src/sources/soundsource.cpp @@ -48,7 +48,8 @@ QString SoundSource::getTypeFromFile(const QFileInfo& fileInfo) { const QString fileSuffix = fileInfo.suffix(); const QString fileType = fileTypeFromSuffix(fileSuffix); DEBUG_ASSERT(!fileType.isEmpty() || fileType == QString{}); - const QMimeType mimeType = QMimeDatabase().mimeTypeForFile(fileInfo); + const QMimeType mimeType = QMimeDatabase().mimeTypeForFile( + fileInfo, QMimeDatabase::MatchContent); // According to the documentation mimeTypeForFile always returns a valid // type, using the generic type application/octet-stream as a fallback. // This might also occur for missing files as seen on Qt 5.12. diff --git a/src/test/soundproxy_test.cpp b/src/test/soundproxy_test.cpp index 0da9c8ade3..fe75fec0e8 100644 --- a/src/test/soundproxy_test.cpp +++ b/src/test/soundproxy_test.cpp @@ -740,11 +740,8 @@ TEST_F(SoundSourceProxyTest, getTypeFromFile) { tempDir.filePath("file_with_empty_suffix."); const QString filePathWithUnknownSuffix = tempDir.filePath("file_with.unknown_suffix"); - // TODO: Currently, our SoundSource::getTypeFromFile() can not detect the - // file type of files with a known but wrong file extension properly, so - // this test needs to be disabled. - //const QString filePathWithWrongSuffix = - // tempDir.filePath("file_with_wrong_suffix.wav"); + const QString filePathWithWrongSuffix = + tempDir.filePath("file_with_wrong_suffix.wav"); const QString filePathWithUppercaseAndLeadingTrailingWhitespaceSuffix = tempDir.filePath("file_with_uppercase_suffix. MP3 "); @@ -753,7 +750,7 @@ TEST_F(SoundSourceProxyTest, getTypeFromFile) { mixxxtest::copyFile(validFilePath, filePathWithoutSuffix); mixxxtest::copyFile(validFilePath, filePathWithEmptySuffix); mixxxtest::copyFile(validFilePath, filePathWithUnknownSuffix); - //mixxxtest::copyFile(validFilePath, filePathWithWrongSuffix); + mixxxtest::copyFile(validFilePath, filePathWithWrongSuffix); mixxxtest::copyFile(validFilePath, filePathWithUppercaseAndLeadingTrailingWhitespaceSuffix); ASSERT_STREQ(qPrintable("mp3"), @@ -769,9 +766,9 @@ TEST_F(SoundSourceProxyTest, getTypeFromFile) { EXPECT_STREQ(qPrintable("mp3"), qPrintable(mixxx::SoundSource::getTypeFromFile( QFileInfo(filePathWithUnknownSuffix)))); - //EXPECT_STREQ(qPrintable("mp3"), - // qPrintable(mixxx::SoundSource::getTypeFromFile( - // QFileInfo(filePathWithWrongSuffix)))); + EXPECT_STREQ(qPrintable("mp3"), + qPrintable(mixxx::SoundSource::getTypeFromFile( + QFileInfo(filePathWithWrongSuffix)))); EXPECT_STREQ(qPrintable("mp3"), qPrintable(mixxx::SoundSource::getTypeFromFile( QFileInfo(filePathWithUppercaseAndLeadingTrailingWhitespaceSuffix)))); |