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

Rework test file creations to get rid of stand alone files concept

parent 994c490d
...@@ -275,11 +275,6 @@ bool Media::save() ...@@ -275,11 +275,6 @@ bool Media::save()
return true; return true;
} }
bool Media::isStandAlone()
{
return m_folderId == 0;
}
unsigned int Media::lastModificationDate() unsigned int Media::lastModificationDate()
{ {
return m_lastModificationDate; return m_lastModificationDate;
......
...@@ -91,7 +91,6 @@ class Media : public IMedia, public DatabaseHelpers<Media, policy::MediaTable> ...@@ -91,7 +91,6 @@ class Media : public IMedia, public DatabaseHelpers<Media, policy::MediaTable>
void setSnapshot( const std::string& snapshot ); void setSnapshot( const std::string& snapshot );
bool save(); bool save();
bool isStandAlone();
unsigned int lastModificationDate(); unsigned int lastModificationDate();
/// Explicitely mark a file as fully parsed, meaning no metadata service needs to run anymore. /// Explicitely mark a file as fully parsed, meaning no metadata service needs to run anymore.
......
...@@ -180,7 +180,7 @@ std::vector<MediaPtr> MediaLibrary::videoFiles() ...@@ -180,7 +180,7 @@ std::vector<MediaPtr> MediaLibrary::videoFiles()
return Media::fetchAll<IMedia>( m_dbConnection.get(), req, IMedia::Type::VideoType ); return Media::fetchAll<IMedia>( m_dbConnection.get(), req, IMedia::Type::VideoType );
} }
std::shared_ptr<Media> MediaLibrary::addFile( const std::string& path, Folder* parentFolder, fs::IDirectory* parentFolderFs ) std::shared_ptr<Media> MediaLibrary::addFile( const std::string& path, Folder& parentFolder, fs::IDirectory& parentFolderFs )
{ {
std::unique_ptr<fs::IFile> file; std::unique_ptr<fs::IFile> file;
try try
...@@ -213,9 +213,8 @@ std::shared_ptr<Media> MediaLibrary::addFile( const std::string& path, Folder* p ...@@ -213,9 +213,8 @@ std::shared_ptr<Media> MediaLibrary::addFile( const std::string& path, Folder* p
return nullptr; return nullptr;
LOG_INFO( "Adding ", path ); LOG_INFO( "Adding ", path );
auto fptr = Media::create( m_dbConnection.get(), type, file.get(), auto fptr = Media::create( m_dbConnection.get(), type, file.get(), parentFolder.id(),
parentFolder != nullptr ? parentFolder->id() : 0, parentFolderFs.device()->isRemovable() );
parentFolderFs != nullptr ? parentFolderFs->device()->isRemovable() : false );
if ( fptr == nullptr ) if ( fptr == nullptr )
{ {
LOG_ERROR( "Failed to add file ", file->fullPath(), " to the media library" ); LOG_ERROR( "Failed to add file ", file->fullPath(), " to the media library" );
......
...@@ -53,7 +53,7 @@ class MediaLibrary : public IMediaLibrary ...@@ -53,7 +53,7 @@ class MediaLibrary : public IMediaLibrary
std::vector<MediaPtr> files(); std::vector<MediaPtr> files();
virtual std::vector<MediaPtr> audioFiles() override; virtual std::vector<MediaPtr> audioFiles() override;
virtual std::vector<MediaPtr> videoFiles() override; virtual std::vector<MediaPtr> videoFiles() override;
std::shared_ptr<Media> addFile(const std::string& path, Folder* parentFolder, fs::IDirectory* parentFolderFs); std::shared_ptr<Media> addFile( const std::string& path, Folder& parentFolder, fs::IDirectory& parentFolderFs );
virtual bool deleteFile(const Media* file ); virtual bool deleteFile(const Media* file );
bool deleteFolder( const Folder* folder ); bool deleteFolder( const Folder* folder );
......
...@@ -66,7 +66,7 @@ bool FsDiscoverer::discover( const std::string &entryPoint ) ...@@ -66,7 +66,7 @@ bool FsDiscoverer::discover( const std::string &entryPoint )
auto blist = blacklist(); auto blist = blacklist();
if ( isBlacklisted( *fsDir, blist ) == true ) if ( isBlacklisted( *fsDir, blist ) == true )
return false; return false;
return addFolder( fsDir.get(), nullptr, blist ); return addFolder( *fsDir, nullptr, blist );
} }
void FsDiscoverer::reload() void FsDiscoverer::reload()
...@@ -84,8 +84,8 @@ void FsDiscoverer::reload() ...@@ -84,8 +84,8 @@ void FsDiscoverer::reload()
m_ml->deleteFolder( f.get() ); m_ml->deleteFolder( f.get() );
continue; continue;
} }
checkSubfolders( folder.get(), f.get(), blist ); checkSubfolders( *folder, *f, blist );
checkFiles( folder.get(), f.get() ); checkFiles( *folder, *f );
} }
} }
...@@ -108,12 +108,12 @@ void FsDiscoverer::checkDevices() ...@@ -108,12 +108,12 @@ void FsDiscoverer::checkDevices()
} }
} }
bool FsDiscoverer::checkSubfolders( fs::IDirectory* folder, Folder* parentFolder, const std::vector<std::shared_ptr<Folder>> blacklist ) const bool FsDiscoverer::checkSubfolders( fs::IDirectory& folder, Folder& parentFolder, const std::vector<std::shared_ptr<Folder>> blacklist ) const
{ {
// Load the folders we already know of: // Load the folders we already know of:
LOG_INFO( "Checking for modifications in ", folder->path() ); LOG_INFO( "Checking for modifications in ", folder.path() );
auto subFoldersInDB = Folder::fetchAll( m_dbConn, parentFolder->id() ); auto subFoldersInDB = Folder::fetchAll( m_dbConn, parentFolder.id() );
for ( const auto& subFolderPath : folder->dirs() ) for ( const auto& subFolderPath : folder.dirs() )
{ {
auto subFolder = m_fsFactory->createDirectory( subFolderPath ); auto subFolder = m_fsFactory->createDirectory( subFolderPath );
if ( subFolder == nullptr ) if ( subFolder == nullptr )
...@@ -132,15 +132,15 @@ bool FsDiscoverer::checkSubfolders( fs::IDirectory* folder, Folder* parentFolder ...@@ -132,15 +132,15 @@ bool FsDiscoverer::checkSubfolders( fs::IDirectory* folder, Folder* parentFolder
continue; continue;
} }
LOG_INFO( "New folder detected: ", subFolderPath ); LOG_INFO( "New folder detected: ", subFolderPath );
addFolder( subFolder.get(), parentFolder, blacklist ); addFolder( *subFolder, &parentFolder, blacklist );
continue; continue;
} }
auto folderInDb = *it; auto folderInDb = *it;
// In any case, check for modifications, as a change related to a mountpoint might // In any case, check for modifications, as a change related to a mountpoint might
// not update the folder modification date. // not update the folder modification date.
// Also, relying on the modification date probably isn't portable // Also, relying on the modification date probably isn't portable
checkSubfolders( subFolder.get(), folderInDb.get(), blacklist ); checkSubfolders( *subFolder, *folderInDb, blacklist );
checkFiles( subFolder.get(), folderInDb.get() ); checkFiles( *subFolder, *folderInDb );
subFoldersInDB.erase( it ); subFoldersInDB.erase( it );
} }
// Now all folders we had in DB but haven't seen from the FS must have been deleted. // Now all folders we had in DB but haven't seen from the FS must have been deleted.
...@@ -149,17 +149,17 @@ bool FsDiscoverer::checkSubfolders( fs::IDirectory* folder, Folder* parentFolder ...@@ -149,17 +149,17 @@ bool FsDiscoverer::checkSubfolders( fs::IDirectory* folder, Folder* parentFolder
LOG_INFO( "Folder ", f->path(), " not found in FS, deleting it" ); LOG_INFO( "Folder ", f->path(), " not found in FS, deleting it" );
m_ml->deleteFolder( f.get() ); m_ml->deleteFolder( f.get() );
} }
LOG_INFO( "Done checking subfolders in ", folder->path() ); LOG_INFO( "Done checking subfolders in ", folder.path() );
return true; return true;
} }
void FsDiscoverer::checkFiles( fs::IDirectory* folder, Folder* parentFolder ) const void FsDiscoverer::checkFiles( fs::IDirectory& folder, Folder& parentFolder ) const
{ {
LOG_INFO( "Checking file in ", folder->path() ); LOG_INFO( "Checking file in ", folder.path() );
static const std::string req = "SELECT * FROM " + policy::MediaTable::Name static const std::string req = "SELECT * FROM " + policy::MediaTable::Name
+ " WHERE folder_id = ?"; + " WHERE folder_id = ?";
auto files = Media::fetchAll<Media>( m_dbConn, req, parentFolder->id() ); auto files = Media::fetchAll<Media>( m_dbConn, req, parentFolder.id() );
for ( const auto& filePath : folder->files() ) for ( const auto& filePath : folder.files() )
{ {
auto it = std::find_if( begin( files ), end( files ), [filePath](const std::shared_ptr<IMedia>& f) { auto it = std::find_if( begin( files ), end( files ), [filePath](const std::shared_ptr<IMedia>& f) {
return f->mrl() == filePath; return f->mrl() == filePath;
...@@ -186,7 +186,7 @@ void FsDiscoverer::checkFiles( fs::IDirectory* folder, Folder* parentFolder ) co ...@@ -186,7 +186,7 @@ void FsDiscoverer::checkFiles( fs::IDirectory* folder, Folder* parentFolder ) co
LOG_INFO( "File ", file->mrl(), " not found on filesystem, deleting it" ); LOG_INFO( "File ", file->mrl(), " not found on filesystem, deleting it" );
m_ml->deleteFile( file.get() ); m_ml->deleteFile( file.get() );
} }
LOG_INFO( "Done checking files ", folder->path() ); LOG_INFO( "Done checking files ", folder.path() );
} }
std::vector<std::shared_ptr<Folder> > FsDiscoverer::blacklist() const std::vector<std::shared_ptr<Folder> > FsDiscoverer::blacklist() const
...@@ -210,9 +210,9 @@ bool FsDiscoverer::isBlacklisted( const fs::IDirectory& directory, const std::ve ...@@ -210,9 +210,9 @@ bool FsDiscoverer::isBlacklisted( const fs::IDirectory& directory, const std::ve
}) != end( blacklist ); }) != end( blacklist );
} }
bool FsDiscoverer::addFolder( fs::IDirectory* folder, Folder* parentFolder, const std::vector<std::shared_ptr<Folder>>& blacklist ) const bool FsDiscoverer::addFolder( fs::IDirectory& folder, Folder* parentFolder, const std::vector<std::shared_ptr<Folder>>& blacklist ) const
{ {
auto deviceFs = folder->device(); auto deviceFs = folder.device();
// We are creating a folder, there has to be a device containing it. // We are creating a folder, there has to be a device containing it.
assert( deviceFs != nullptr ); assert( deviceFs != nullptr );
auto device = Device::fromUuid( m_dbConn, deviceFs->uuid() ); auto device = Device::fromUuid( m_dbConn, deviceFs->uuid() );
...@@ -222,12 +222,13 @@ bool FsDiscoverer::addFolder( fs::IDirectory* folder, Folder* parentFolder, cons ...@@ -222,12 +222,13 @@ bool FsDiscoverer::addFolder( fs::IDirectory* folder, Folder* parentFolder, cons
device = Device::create( m_dbConn, deviceFs->uuid(), deviceFs->isRemovable() ); device = Device::create( m_dbConn, deviceFs->uuid(), deviceFs->isRemovable() );
} }
auto f = Folder::create( m_dbConn, folder->path(), parentFolder != nullptr ? parentFolder->id() : 0, auto f = Folder::create( m_dbConn, folder.path(),
parentFolder != nullptr ? parentFolder->id() : 0,
*device, *deviceFs ); *device, *deviceFs );
if ( f == nullptr ) if ( f == nullptr )
return false; return false;
checkFiles( folder, f.get() ); checkFiles( folder, *f );
checkSubfolders( folder, f.get(), blacklist ); checkSubfolders( folder, *f, blacklist );
return true; return true;
} }
...@@ -39,11 +39,11 @@ public: ...@@ -39,11 +39,11 @@ public:
virtual void reload() override; virtual void reload() override;
private: private:
bool checkSubfolders( fs::IDirectory *folder, Folder* parentFolder, const std::vector<std::shared_ptr<Folder>> blacklist ) const; bool checkSubfolders(fs::IDirectory& folder, Folder& parentFolder, const std::vector<std::shared_ptr<Folder>> blacklist ) const;
void checkFiles( fs::IDirectory *folder, Folder* parentFolder ) const; void checkFiles(fs::IDirectory& folder, Folder& parentFolder ) const;
std::vector<std::shared_ptr<Folder>> blacklist() const; std::vector<std::shared_ptr<Folder>> blacklist() const;
bool isBlacklisted( const fs::IDirectory& directory, const std::vector<std::shared_ptr<Folder>>& blacklist ) const; bool isBlacklisted( const fs::IDirectory& directory, const std::vector<std::shared_ptr<Folder>>& blacklist ) const;
bool addFolder(fs::IDirectory* folder, Folder* parentFolder, const std::vector<std::shared_ptr<Folder> >& blacklist ) const; bool addFolder(fs::IDirectory& folder, Folder* parentFolder, const std::vector<std::shared_ptr<Folder> >& blacklist ) const;
void checkDevices(); void checkDevices();
private: private:
......
...@@ -534,6 +534,54 @@ public: ...@@ -534,6 +534,54 @@ public:
} }
}; };
class NoopDevice : public fs::IDevice
{
public:
virtual const std::string&uuid() const override
{
assert(false);
}
virtual bool isRemovable() const override
{
return false;
}
virtual bool isPresent() const override
{
return true;
}
virtual const std::string& mountpoint() const override
{
assert(false);
}
};
// We just need a valid instance of this one
class NoopDirectory : public fs::IDirectory
{
virtual const std::string& path() const override
{
assert(false);
}
virtual const std::vector<std::string>&files() override
{
assert(false);
}
virtual const std::vector<std::string>&dirs() override
{
assert(false);
}
virtual std::shared_ptr<fs::IDevice> device() const override
{
return std::make_shared<NoopDevice>();
}
};
class NoopFsFactory : public factory::IFileSystem class NoopFsFactory : public factory::IFileSystem
{ {
public: public:
......
...@@ -59,7 +59,7 @@ TEST_F( Albums, Fetch ) ...@@ -59,7 +59,7 @@ TEST_F( Albums, Fetch )
TEST_F( Albums, AddTrack ) TEST_F( Albums, AddTrack )
{ {
auto a = ml->createAlbum( "albumtag" ); auto a = ml->createAlbum( "albumtag" );
auto f = ml->addFile( "track.mp3", nullptr, nullptr ); auto f = ml->addFile( "track.mp3" );
auto track = a->addTrack( f, 10, 0 ); auto track = a->addTrack( f, 10, 0 );
ASSERT_NE( track, nullptr ); ASSERT_NE( track, nullptr );
...@@ -79,7 +79,7 @@ TEST_F( Albums, NbTracks ) ...@@ -79,7 +79,7 @@ TEST_F( Albums, NbTracks )
auto a = ml->createAlbum( "albumtag" ); auto a = ml->createAlbum( "albumtag" );
for ( auto i = 1u; i <= 10; ++i ) for ( auto i = 1u; i <= 10; ++i )
{ {
auto f = ml->addFile( "track" + std::to_string(i) + ".mp3", nullptr, nullptr ); auto f = ml->addFile( "track" + std::to_string(i) + ".mp3" );
auto track = a->addTrack( f, i, i ); auto track = a->addTrack( f, i, i );
ASSERT_NE( track, nullptr ); ASSERT_NE( track, nullptr );
} }
...@@ -96,7 +96,7 @@ TEST_F( Albums, NbTracks ) ...@@ -96,7 +96,7 @@ TEST_F( Albums, NbTracks )
TEST_F( Albums, SetGenre ) TEST_F( Albums, SetGenre )
{ {
auto a = ml->createAlbum( "album" ); auto a = ml->createAlbum( "album" );
auto f = ml->addFile( "track.mp3", nullptr, nullptr ); auto f = ml->addFile( "track.mp3" );
auto t = a->addTrack( f, 1, 0 ); auto t = a->addTrack( f, 1, 0 );
t->setGenre( "happy underground post progressive death metal" ); t->setGenre( "happy underground post progressive death metal" );
...@@ -167,7 +167,7 @@ TEST_F( Albums, SetArtworkUrl ) ...@@ -167,7 +167,7 @@ TEST_F( Albums, SetArtworkUrl )
TEST_F( Albums, FetchAlbumFromTrack ) TEST_F( Albums, FetchAlbumFromTrack )
{ {
auto a = ml->createAlbum( "album" ); auto a = ml->createAlbum( "album" );
auto f = ml->addFile( "file.mp3", nullptr, nullptr ); auto f = ml->addFile( "file.mp3" );
auto t = a->addTrack( f, 1, 0 ); auto t = a->addTrack( f, 1, 0 );
f->setAlbumTrack( t ); f->setAlbumTrack( t );
......
...@@ -34,7 +34,7 @@ class AlbumTracks : public Tests ...@@ -34,7 +34,7 @@ class AlbumTracks : public Tests
TEST_F( AlbumTracks, Create ) TEST_F( AlbumTracks, Create )
{ {
auto album = ml->createAlbum( "album" ); auto album = ml->createAlbum( "album" );
auto f = ml->addFile( "track1.mp3", nullptr, nullptr ); auto f = ml->addFile( "track1.mp3" );
auto track = album->addTrack( f, 1, 10 ); auto track = album->addTrack( f, 1, 10 );
ASSERT_NE( nullptr, track ); ASSERT_NE( nullptr, track );
ASSERT_EQ( 10u, track->discNumber() ); ASSERT_EQ( 10u, track->discNumber() );
...@@ -48,7 +48,7 @@ TEST_F( AlbumTracks, Create ) ...@@ -48,7 +48,7 @@ TEST_F( AlbumTracks, Create )
TEST_F( AlbumTracks, Artist ) TEST_F( AlbumTracks, Artist )
{ {
auto album = ml->createAlbum( "album" ); auto album = ml->createAlbum( "album" );
auto f = ml->addFile( "track1.mp3", nullptr, nullptr ); auto f = ml->addFile( "track1.mp3" );
auto track = album->addTrack( f, 1, 0 ); auto track = album->addTrack( f, 1, 0 );
ASSERT_EQ( track->artist(), "" ); ASSERT_EQ( track->artist(), "" );
...@@ -66,7 +66,7 @@ TEST_F( AlbumTracks, Artist ) ...@@ -66,7 +66,7 @@ TEST_F( AlbumTracks, Artist )
TEST_F( AlbumTracks, SetReleaseYear ) TEST_F( AlbumTracks, SetReleaseYear )
{ {
auto a = ml->createAlbum( "album" ); auto a = ml->createAlbum( "album" );
auto m = ml->addFile( "test.mp3", nullptr, nullptr ); auto m = ml->addFile( "test.mp3" );
auto t = a->addTrack( m, 1, 0 ); auto t = a->addTrack( m, 1, 0 );
ASSERT_EQ( 0u, t->releaseYear() ); ASSERT_EQ( 0u, t->releaseYear() );
......
...@@ -118,7 +118,7 @@ TEST_F( Artists, AllSongs ) ...@@ -118,7 +118,7 @@ TEST_F( Artists, AllSongs )
for (auto i = 1; i <= 3; ++i) for (auto i = 1; i <= 3; ++i)
{ {
auto f = ml->addFile( "song" + std::to_string(i) + ".mp3", nullptr, nullptr ); auto f = ml->addFile( "song" + std::to_string(i) + ".mp3" );
auto res = artist->addMedia( f.get() ); auto res = artist->addMedia( f.get() );
ASSERT_TRUE( res ); ASSERT_TRUE( res );
} }
......
...@@ -31,14 +31,14 @@ class AudioTracks : public Tests ...@@ -31,14 +31,14 @@ class AudioTracks : public Tests
TEST_F( AudioTracks, AddTrack ) TEST_F( AudioTracks, AddTrack )
{ {
auto f = std::static_pointer_cast<Media>( ml->addFile( "file.mp3", nullptr, nullptr ) ); auto f = std::static_pointer_cast<Media>( ml->addFile( "file.mp3" ) );
bool res = f->addAudioTrack( "PCM", 128, 44100, 2, "fr", "test" ); bool res = f->addAudioTrack( "PCM", 128, 44100, 2, "fr", "test" );
ASSERT_TRUE( res ); ASSERT_TRUE( res );
} }
TEST_F( AudioTracks, GetSetProperties ) TEST_F( AudioTracks, GetSetProperties )
{ {
auto f = std::static_pointer_cast<Media>( ml->addFile( "file.mp3", nullptr, nullptr ) ); auto f = std::static_pointer_cast<Media>( ml->addFile( "file.mp3" ) );
ASSERT_NE( f, nullptr ); ASSERT_NE( f, nullptr );
f->addAudioTrack( "PCM", 128, 44100, 2, "en", "test desc" ); f->addAudioTrack( "PCM", 128, 44100, 2, "en", "test desc" );
auto tracks = f->audioTracks(); auto tracks = f->audioTracks();
...@@ -68,7 +68,7 @@ TEST_F( AudioTracks, GetSetProperties ) ...@@ -68,7 +68,7 @@ TEST_F( AudioTracks, GetSetProperties )
TEST_F( AudioTracks, FetchTracks ) TEST_F( AudioTracks, FetchTracks )
{ {
auto f = std::static_pointer_cast<Media>( ml->addFile( "file.mp3", nullptr, nullptr ) ); auto f = std::static_pointer_cast<Media>( ml->addFile( "file.mp3" ) );
f->addAudioTrack( "PCM", 128, 44100, 2, "en", "test desc" ); f->addAudioTrack( "PCM", 128, 44100, 2, "en", "test desc" );
f->addAudioTrack( "WMA", 128, 48000, 2, "fr", "test desc 2" ); f->addAudioTrack( "WMA", 128, 48000, 2, "fr", "test desc 2" );
......
...@@ -66,7 +66,6 @@ TEST_F( Folders, Add ) ...@@ -66,7 +66,6 @@ TEST_F( Folders, Add )
auto files = ml->files(); auto files = ml->files();
ASSERT_EQ( files.size(), 3u ); ASSERT_EQ( files.size(), 3u );
ASSERT_FALSE( std::static_pointer_cast<Media>( files[0] )->isStandAlone() );
} }
TEST_F( Folders, Delete ) TEST_F( Folders, Delete )
...@@ -116,8 +115,6 @@ TEST_F( Folders, Load ) ...@@ -116,8 +115,6 @@ TEST_F( Folders, Load )
auto files = ml->files(); auto files = ml->files();
ASSERT_EQ( files.size(), 3u ); ASSERT_EQ( files.size(), 3u );
for ( auto& f : files )
ASSERT_FALSE( std::static_pointer_cast<Media>( f )->isStandAlone() );
} }
TEST_F( Folders, InvalidPath ) TEST_F( Folders, InvalidPath )
...@@ -238,7 +235,6 @@ TEST_F( Folders, NewFileInSubFolder ) ...@@ -238,7 +235,6 @@ TEST_F( Folders, NewFileInSubFolder )
f = ml->folder( mock::FileSystemFactory::SubFolder ); f = ml->folder( mock::FileSystemFactory::SubFolder );
ASSERT_EQ( 2u, f->files().size() ); ASSERT_EQ( 2u, f->files().size() );
ASSERT_NE( nullptr, file ); ASSERT_NE( nullptr, file );
ASSERT_FALSE( std::static_pointer_cast<Media>( file )->isStandAlone() );
} }
TEST_F( Folders, RemoveFileFromDirectory ) TEST_F( Folders, RemoveFileFromDirectory )
......
...@@ -32,7 +32,7 @@ class Labels : public Tests ...@@ -32,7 +32,7 @@ class Labels : public Tests
TEST_F( Labels, Add ) TEST_F( Labels, Add )
{ {
auto f = ml->addFile( "media.avi", nullptr, nullptr ); auto f = ml->addFile( "media.avi" );
auto l1 = ml->createLabel( "sea otter" ); auto l1 = ml->createLabel( "sea otter" );
auto l2 = ml->createLabel( "cony the cone" ); auto l2 = ml->createLabel( "cony the cone" );
...@@ -54,7 +54,7 @@ TEST_F( Labels, Add ) ...@@ -54,7 +54,7 @@ TEST_F( Labels, Add )
TEST_F( Labels, Remove ) TEST_F( Labels, Remove )
{ {
auto f = ml->addFile( "media.avi", nullptr, nullptr ); auto f = ml->addFile( "media.avi" );
auto l1 = ml->createLabel( "sea otter" ); auto l1 = ml->createLabel( "sea otter" );
auto l2 = ml->createLabel( "cony the cone" ); auto l2 = ml->createLabel( "cony the cone" );
...@@ -97,9 +97,9 @@ TEST_F( Labels, Remove ) ...@@ -97,9 +97,9 @@ TEST_F( Labels, Remove )
TEST_F( Labels, Files ) TEST_F( Labels, Files )
{ {
auto f = ml->addFile( "media.avi", nullptr, nullptr ); auto f = ml->addFile( "media.avi" );
auto f2 = ml->addFile( "file.mp3", nullptr, nullptr ); auto f2 = ml->addFile( "file.mp3" );
auto f3 = ml->addFile( "otter.mkv", nullptr, nullptr ); auto f3 = ml->addFile( "otter.mkv" );
auto l1 = ml->createLabel( "label1" ); auto l1 = ml->createLabel( "label1" );
auto l2 = ml->createLabel( "label2" ); auto l2 = ml->createLabel( "label2" );
...@@ -124,7 +124,7 @@ TEST_F( Labels, Files ) ...@@ -124,7 +124,7 @@ TEST_F( Labels, Files )
TEST_F( Labels, Delete ) TEST_F( Labels, Delete )
{ {
auto f = ml->addFile( "media.avi", nullptr, nullptr ); auto f = ml->addFile( "media.avi" );
auto l1 = ml->createLabel( "sea otter" ); auto l1 = ml->createLabel( "sea otter" );
auto l2 = ml->createLabel( "cony the cone" ); auto l2 = ml->createLabel( "cony the cone" );
......
...@@ -40,13 +40,12 @@ TEST_F( Medias, Init ) ...@@ -40,13 +40,12 @@ TEST_F( Medias, Init )
TEST_F( Medias, Create ) TEST_F( Medias, Create )
{ {
auto f = ml->addFile( "media.avi", nullptr, nullptr ); auto f = ml->addFile( "media.avi" );
ASSERT_NE( f, nullptr ); ASSERT_NE( f, nullptr );
ASSERT_EQ( f->playCount(), 0 ); ASSERT_EQ( f->playCount(), 0 );
ASSERT_EQ( f->albumTrack(), nullptr ); ASSERT_EQ( f->albumTrack(), nullptr );
ASSERT_EQ( f->showEpisode(), nullptr ); ASSERT_EQ( f->showEpisode(), nullptr );
ASSERT_TRUE( f->isStandAlone() );
ASSERT_FALSE( f->isParsed() ); ASSERT_FALSE( f->isParsed() );
ASSERT_EQ( f->duration(), -1 ); ASSERT_EQ( f->duration(), -1 );
ASSERT_NE( 0u, f->insertionDate() ); ASSERT_NE( 0u, f->insertionDate() );
...@@ -58,7 +57,7 @@ TEST_F( Medias, Create ) ...@@ -58,7 +57,7 @@ TEST_F( Medias, Create )
TEST_F( Medias, Fetch ) TEST_F( Medias, Fetch )
{ {
auto f = ml->addFile( "media.avi", nullptr, nullptr ); auto f = ml->addFile( "media.avi" );
auto f2 = std::static_pointer_cast<Media>( ml->media( f->id() ) ); auto f2 = std::static_pointer_cast<Media>( ml->media( f->id() ) );
ASSERT_EQ( f->mrl(), f2->mrl() ); ASSERT_EQ( f->mrl(), f2->mrl() );
ASSERT_EQ( f, f2 ); ASSERT_EQ( f, f2 );
...@@ -68,12 +67,11 @@ TEST_F( Medias, Fetch ) ...@@ -68,12 +67,11 @@ TEST_F( Medias, Fetch )
f2 = std::static_pointer_cast<Media>( ml->media( f->id() ) ); f2 = std::static_pointer_cast<Media>( ml->media( f->id() ) );
ASSERT_EQ( f->mrl(), f2->mrl() ); ASSERT_EQ( f->mrl(), f2->mrl() );
ASSERT_TRUE( f2->isStandAlone() );
} }
TEST_F( Medias, Delete ) TEST_F( Medias, Delete )
{ {
auto f = ml->addFile( "media.avi", nullptr, nullptr ); auto f = ml->addFile( "media.avi" );
auto f2 = ml->media( f->id() ); auto f2 = ml->media( f->id() );
ASSERT_EQ( f, f2 ); ASSERT_EQ( f, f2 );
...@@ -85,7 +83,7 @@ TEST_F( Medias, Delete ) ...@@ -85,7 +83,7 @@ TEST_F( Medias, Delete )
TEST_F( Medias, LastModificationDate ) TEST_F( Medias, LastModificationDate )
{ {
auto f = ml->addFile( "media.avi", nullptr, nullptr ); auto f = ml->addFile( "media.avi" );
ASSERT_NE( 0u, f->lastModificationDate() ); ASSERT_NE( 0u, f->lastModificationDate() );
Reload(); Reload();
...@@ -95,7 +93,7 @@ TEST_F( Medias, LastModificationDate ) ...@@ -95,7 +93,7 @@ TEST_F( Medias, LastModificationDate )
TEST_F( Medias, Duration ) TEST_F( Medias, Duration )
{ {
auto f = ml->addFile( "media.avi", nullptr, nullptr ); auto f = ml->addFile( "media.avi" );
ASSERT_EQ( f->duration(), -1 ); ASSERT_EQ( f->duration(), -1 );
// Use a value that checks we're using a 64bits value // Use a value that checks we're using a 64bits value
...@@ -114,7 +112,7 @@ TEST_F( Medias, Duration ) ...@@ -114,7 +112,7 @@ TEST_F( Medias, Duration )
TEST_F( Medias, Artist ) TEST_F( Medias, Artist )
{ {
auto f = std::static_pointer_cast<Media>( ml->addFile( "media.avi", nullptr, nullptr ) ); auto f = std::static_pointer_cast<Media>( ml->addFile( "media.avi" ) );
ASSERT_EQ( f->artist(), "" ); ASSERT_EQ( f->artist(), "" );
std::string newArtist( "Rage Against The Otters" ); std::string newArtist( "Rage Against The Otters" );
...@@ -131,7 +129,7 @@ TEST_F( Medias, Artist ) ...@@ -131,7 +129,7 @@ TEST_F( Medias, Artist )
TEST_F( Medias, Snapshot ) TEST_F( Medias, Snapshot )
{ {
auto f = ml->addFile( "media.avi", nullptr, nullptr ); auto f = ml->addFile( "media.avi" );
ASSERT_EQ( f->snapshot(), "" ); ASSERT_EQ( f->snapshot(), "" );
std::string newSnapshot( "/path/to/snapshot" ); std::string newSnapshot( "/path/to/snapshot" );
...@@ -148,7 +146,7 @@ TEST_F( Medias, Snapshot ) ...@@ -148,7 +146,7 @@ TEST_F( Medias, Snapshot )
TEST_F( Medias, PlayCount ) TEST_F( Medias, PlayCount )
{ {
auto f = ml->addFile( "media.avi", nullptr, nullptr ); auto f = ml->addFile( "media.avi" );
ASSERT_EQ( 0, f->playCount() ); ASSERT_EQ( 0, f->playCount() );
f->increasePlayCount(); f->increasePlayCount();
ASSERT_EQ( 1, f->playCount() ); ASSERT_EQ( 1, f->playCount() );
......
...@@ -105,7 +105,7 @@ TEST_F( Movies, SetImdbId ) ...@@ -105,7 +105,7 @@ TEST_F( Movies, SetImdbId )
TEST_F( Movies, AssignToFile ) TEST_F( Movies, AssignToFile )
{ {
auto f = ml->addFile( "file.avi", nullptr, nullptr ); auto f = ml->addFile( "file.avi" );
auto m = ml->createMovie( "movie" ); auto m = ml->createMovie( "movie" );