Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sources/soundsource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ inline QString fileTypeFromSuffix(const QString& suffix) {
//static
QString SoundSource::getTypeFromUrl(const QUrl& url) {
const QString filePath = validateLocalFileUrl(url).toLocalFile();
return getTypeFromFile(filePath);
return getTypeFromFile(QFileInfo(filePath));
}

//static
Expand Down
3 changes: 2 additions & 1 deletion src/test/controller_mapping_validation_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ void LegacyControllerMappingValidationTest::SetUp() {

bool LegacyControllerMappingValidationTest::testLoadMapping(const MappingInfo& mapping) {
std::shared_ptr<LegacyControllerMapping> pMapping =
LegacyControllerMappingFileHandler::loadMapping(mapping.getPath(), m_mappingPath);
LegacyControllerMappingFileHandler::loadMapping(
QFileInfo(mapping.getPath()), m_mappingPath);
if (!pMapping) {
return false;
}
Expand Down
24 changes: 13 additions & 11 deletions src/test/soundproxy_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,36 +732,38 @@ TEST_F(SoundSourceProxyTest, getTypeFromFile) {
mixxxtest::copyFile(validFilePath, filePathWithWrongSuffix);
mixxxtest::copyFile(validFilePath, filePathWithUppercaseAndLeadingTrailingWhitespaceSuffix);

ASSERT_STREQ(qPrintable("mp3"), qPrintable(mixxx::SoundSource::getTypeFromFile(validFilePath)));
ASSERT_STREQ(qPrintable("mp3"),
qPrintable(mixxx::SoundSource::getTypeFromFile(
QFileInfo(validFilePath))));

EXPECT_STREQ(qPrintable("mp3"),
qPrintable(mixxx::SoundSource::getTypeFromFile(
filePathWithoutSuffix)));
QFileInfo(filePathWithoutSuffix))));
EXPECT_STREQ(qPrintable("mp3"),
qPrintable(mixxx::SoundSource::getTypeFromFile(
filePathWithEmptySuffix)));
QFileInfo(filePathWithEmptySuffix))));
EXPECT_STREQ(qPrintable("mp3"),
qPrintable(mixxx::SoundSource::getTypeFromFile(
filePathWithUnknownSuffix)));
QFileInfo(filePathWithUnknownSuffix))));
EXPECT_STREQ(qPrintable("mp3"),
qPrintable(mixxx::SoundSource::getTypeFromFile(
filePathWithWrongSuffix)));
QFileInfo(filePathWithWrongSuffix))));
EXPECT_STREQ(qPrintable("mp3"),
qPrintable(mixxx::SoundSource::getTypeFromFile(
filePathWithUppercaseAndLeadingTrailingWhitespaceSuffix)));
QFileInfo(filePathWithUppercaseAndLeadingTrailingWhitespaceSuffix))));
}

TEST_F(SoundSourceProxyTest, getTypeFromMissingFile) {
// Also verify that the shortened suffix ".aif" (case-insensitive) is
// mapped to file type "aiff", independent of whether the file exists or not!
const QFileInfo missingFileWithUppercaseSuffixAndLeadingTrailingWhitespaceSuffix =
kTestDir.absoluteFilePath(QStringLiteral("missing_file. AIF "));
const QFileInfo missingFileWithUppercaseSuffixAndLeadingTrailingWhitespaceSuffix(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be easier to read and resembles the let syntax as found in Rust:

const auto varName = VarType(..constructor args...);

Just a personal opinion and hint, no need to change anything.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't care.

kTestDir.absoluteFilePath(QStringLiteral("missing_file. AIF ")));

ASSERT_FALSE(missingFileWithUppercaseSuffixAndLeadingTrailingWhitespaceSuffix.exists());

EXPECT_STREQ(qPrintable("aiff"),
qPrintable(mixxx::SoundSource::getTypeFromFile(
missingFileWithUppercaseSuffixAndLeadingTrailingWhitespaceSuffix)));
QFileInfo(missingFileWithUppercaseSuffixAndLeadingTrailingWhitespaceSuffix))));
}

TEST_F(SoundSourceProxyTest, getTypeFromAiffFile) {
Expand All @@ -771,7 +773,7 @@ TEST_F(SoundSourceProxyTest, getTypeFromAiffFile) {
ASSERT_TRUE(QFileInfo::exists(aiffFilePath));
ASSERT_STREQ(qPrintable("aiff"),
qPrintable(mixxx::SoundSource::getTypeFromFile(
aiffFilePath)));
QFileInfo(aiffFilePath))));

const QString aiffFilePathWithShortenedSuffix =
mixxxtest::generateTemporaryFileName(QStringLiteral("cover-test.aif"));
Expand All @@ -780,5 +782,5 @@ TEST_F(SoundSourceProxyTest, getTypeFromAiffFile) {

EXPECT_STREQ(qPrintable("aiff"),
qPrintable(mixxx::SoundSource::getTypeFromFile(
aiffFilePathWithShortenedSuffix)));
QFileInfo(aiffFilePathWithShortenedSuffix))));
}
2 changes: 1 addition & 1 deletion src/track/serato/tags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace {

QString getPrimaryDecoderNameForFilePath(const QString& filePath) {
const QString fileExtension =
mixxx::SoundSource::getTypeFromFile(filePath);
mixxx::SoundSource::getTypeFromFile(QFileInfo(filePath));
const mixxx::SoundSourceProviderPointer pPrimaryProvider =
SoundSourceProxy::getPrimaryProviderForFileExtension(fileExtension);
if (pPrimaryProvider) {
Expand Down