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

tests: Fix a bunch of warning when building with clang

parent 7f6f6539
......@@ -49,17 +49,9 @@ std::shared_ptr<Media> MediaLibraryTester::media( int64_t id )
return std::static_pointer_cast<Media>( MediaLibrary::media( id ) );
}
std::shared_ptr<Folder> MediaLibraryTester::folder( const std::string& mrl )
FolderPtr MediaLibraryTester::folder( const std::string& mrl ) const
{
static const std::string req = "SELECT * FROM " + Folder::Table::Name +
" WHERE is_blacklisted = 0 AND is_present != 0";
auto folders = Folder::DatabaseHelpers::fetchAll<Folder>( this, req );
for ( auto &f : folders )
{
if ( f->mrl() == mrl )
return f;
}
return nullptr;
return Folder::fromMrl( this, mrl, Folder::BannedType::No );
}
std::shared_ptr<Media> MediaLibraryTester::addFile( const std::string& path, IMedia::Type type )
......@@ -110,11 +102,6 @@ void MediaLibraryTester::addLocalFsFactory()
}
}
std::shared_ptr<Playlist> MediaLibraryTester::playlist( int64_t playlistId )
{
return Playlist::fetch( this, playlistId );
}
void MediaLibraryTester::deleteAlbum( int64_t albumId )
{
Album::destroy( this, albumId );
......
......@@ -46,8 +46,7 @@ public:
using MediaLibrary::media;
// And override the ID getter to return a Media instead of IMedia
std::shared_ptr<Media> media( int64_t id );
std::shared_ptr<Folder> folder( const std::string& path );
std::shared_ptr<Playlist> playlist( int64_t playlistId );
FolderPtr folder( const std::string& path ) const override;
void deleteAlbum( int64_t albumId );
std::shared_ptr<Album> createAlbum( const std::string& title );
std::shared_ptr<Genre> createGenre( const std::string& name );
......@@ -74,8 +73,8 @@ public:
std::shared_ptr<fs::IDirectory> parentFolderFs,
std::pair<std::shared_ptr<Playlist>, unsigned int> parentPlaylist ) override;
sqlite::Connection* getDbConn();
virtual void startThumbnailer();
virtual void populateFsFactories();
virtual void startThumbnailer() override;
virtual void populateFsFactories() override;
MediaPtr addMedia( const std::string& mrl, IMedia::Type type = IMedia::Type::External );
void deleteMedia( int64_t mediaId );
void outdateAllDevices();
......
......@@ -53,7 +53,7 @@ public:
virtual const std::string& mountpoint() const override;
void setRemovable( bool value );
void setPresent( bool value );
virtual void setPresent( bool value ) override;
std::string relativePath( const std::string& path );
void addFile( const std::string& filePath );
......
......@@ -51,7 +51,7 @@ public:
protected:
virtual void onDiscoveryCompleted( const std::string&, bool ) override;
virtual void onParsingStatsUpdated(uint32_t percent) override;
virtual void onMediaThumbnailReady( MediaPtr media, bool success );
virtual void onMediaThumbnailReady( MediaPtr media, bool success ) override;
compat::ConditionVariable m_parsingCompleteVar;
compat::Mutex m_parsingMutex;
......@@ -112,7 +112,7 @@ public:
};
virtual void InitializeMediaLibrary() override;
virtual void InitializeCallback();
virtual void InitializeCallback() override;
};
#endif // TESTER_H
......@@ -104,21 +104,21 @@ TEST_F( FoldersNoDiscover, InvalidPath )
TEST_F( Folders, List )
{
auto f = ml->folder( mock::FileSystemFactory::Root );
auto f = std::static_pointer_cast<Folder>( ml->folder( mock::FileSystemFactory::Root ) );
ASSERT_NE( f, nullptr );
auto files = f->files();
ASSERT_EQ( files.size(), 2u );
Reload();
f = ml->folder( f->mrl() );
f = std::static_pointer_cast<Folder>( ml->folder( f->mrl() ) );
files = f->files();
ASSERT_EQ( files.size(), 2u );
}
TEST_F( Folders, ListFolders )
{
auto f = ml->folder( mock::FileSystemFactory::Root );
auto f = std::static_pointer_cast<Folder>( ml->folder( mock::FileSystemFactory::Root ) );
ASSERT_NE( f, nullptr );
auto subFolders = f->folders();
ASSERT_EQ( 1u, subFolders.size() );
......@@ -132,7 +132,7 @@ TEST_F( Folders, ListFolders )
// Now again, without cache. No need to wait for fs discovery reload here
Reload();
f = ml->folder( f->mrl() );
f = std::static_pointer_cast<Folder>( ml->folder( f->mrl() ) );
subFolders = f->folders();
ASSERT_EQ( 1u, subFolders.size() );
......@@ -163,10 +163,10 @@ TEST_F( Folders, NewFolderWithFile )
// This is expected to fail until we fix the file system modifications detection
TEST_F( Folders, NewFileInSubFolder )
{
auto f = ml->folder( mock::FileSystemFactory::Root );
auto f = std::static_pointer_cast<Folder>( ml->folder( mock::FileSystemFactory::Root ) );
ASSERT_EQ( 3u, ml->files().size() );
f = ml->folder( mock::FileSystemFactory::SubFolder );
f = std::static_pointer_cast<Folder>( ml->folder( mock::FileSystemFactory::SubFolder ) );
// Do not watch for live changes
ml.reset();
fsMock->addFile( mock::FileSystemFactory::SubFolder + "newfile.avi" );
......@@ -175,7 +175,7 @@ TEST_F( Folders, NewFileInSubFolder )
ASSERT_EQ( 4u, ml->files().size() );
auto media = ml->media( mock::FileSystemFactory::SubFolder + "newfile.avi" );
f = ml->folder( mock::FileSystemFactory::SubFolder );
f = std::static_pointer_cast<Folder>( ml->folder( mock::FileSystemFactory::SubFolder ) );
ASSERT_EQ( 2u, f->files().size() );
ASSERT_NE( nullptr, media );
}
......@@ -191,7 +191,7 @@ TEST_F( Folders, RemoveFileFromDirectory )
ASSERT_EQ( 2u, ml->files().size() );
auto media = ml->media( mock::FileSystemFactory::SubFolder + "subfile.mp4" );
auto f = ml->folder( mock::FileSystemFactory::SubFolder );
auto f = std::static_pointer_cast<Folder>( ml->folder( mock::FileSystemFactory::SubFolder ) );
ASSERT_EQ( 0u, f->files().size() );
ASSERT_EQ( nullptr, media );
}
......@@ -257,7 +257,7 @@ TEST_F( FoldersNoDiscover, DiscoverBlacklisted )
TEST_F( Folders, BlacklistAfterDiscovery )
{
auto f = ml->folder( mock::FileSystemFactory::SubFolder );
auto f = std::static_pointer_cast<Folder>( ml->folder( mock::FileSystemFactory::SubFolder ) );
ASSERT_NE( nullptr, f );
auto files = f->files();
ASSERT_NE( 0u, files.size() );
......
......@@ -87,7 +87,7 @@ TEST_F( Playlists, SetName )
Reload();
pl = ml->playlist( pl->id() );
pl = std::static_pointer_cast<Playlist>( ml->playlist( pl->id() ) );
ASSERT_EQ( newName, pl->name() );
}
......@@ -248,8 +248,8 @@ TEST_F( Playlists, DeleteFile )
}
media = pl->media()->all();
ASSERT_EQ( 0u, media.size() );
pl = ml->playlist( pl->id() );
ASSERT_NE( nullptr, pl );
auto pl2 = ml->playlist( pl->id() );
ASSERT_NE( nullptr, pl2 );
}
TEST_F( Playlists, Search )
......@@ -382,7 +382,7 @@ TEST_F( Playlists, ReinsertMedia )
ml->deleteMedia( m2->id() );
Reload();
pl = ml->playlist( pl->id() );
pl = std::static_pointer_cast<Playlist>( ml->playlist( pl->id() ) );
m1 = ml->addMedia( "http://sea.otters/fluffy.mkv" );
m2 = ml->addMedia( "file:///cute_otters_holding_hands.mp4" );
......@@ -416,7 +416,7 @@ TEST_F( Playlists, RemoveMedia )
Reload();
pl = ml->playlist( pl->id() );
pl = std::static_pointer_cast<Playlist>( ml->playlist( pl->id() ) );
media = pl->media()->all();
ASSERT_EQ( 1u, media.size() );
......
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