Commit b56b876d authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Media: Add sort by filename

Fix #34
parent 30c7bf0c
......@@ -69,6 +69,7 @@ enum class SortingCriteria
Artist,
PlayCount,
Album,
Filename,
};
enum class InitializeResult
......
......@@ -495,6 +495,9 @@ std::vector<MediaPtr> Media::listAll( MediaLibraryPtr ml, IMedia::Type type, Sor
req += "play_count";
desc = !desc; // Make decreasing order default for play count sorting
break;
case SortingCriteria::Filename:
req += "filename";
break;
default:
req += "title";
break;
......
......@@ -426,6 +426,29 @@ TEST_F( Medias, SortByFileSize )
ASSERT_EQ( m1->id(), media[0]->id() );
}
TEST_F( Medias, SortByFilename )
{
auto m1 = std::static_pointer_cast<Media>( ml->addMedia( "zzzzz.mp3" ) );
m1->setType( Media::Type::Video );
m1->setTitle( "aaaaa" );
m1->save();
auto m2 = std::static_pointer_cast<Media>( ml->addMedia( "aaaaa.mp3" ) );
m2->setType( Media::Type::Video );
m2->setTitle( "zzzzz" );
m2->save();
auto media = ml->videoFiles( SortingCriteria::Filename, false );
ASSERT_EQ( 2u, media.size() );
ASSERT_EQ( m2->id(), media[0]->id() );
ASSERT_EQ( m1->id(), media[1]->id() );
media = ml->videoFiles( SortingCriteria::LastModificationDate, true );
ASSERT_EQ( 2u, media.size() );
ASSERT_EQ( m2->id(), media[1]->id() );
ASSERT_EQ( m1->id(), media[0]->id() );
}
TEST_F( Medias, SetType )
{
auto m1 = std::static_pointer_cast<Media>( ml->addMedia( "media1.mp3" ) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment