MediaLibraryTester.h 3.77 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*****************************************************************************
 * Media Library
 *****************************************************************************
 * Copyright (C) 2015 Hugo Beauzée-Luyssen, Videolabs
 *
 * Authors: Hugo Beauzée-Luyssen<hugo@beauzee.fr>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#pragma once

#include "MediaLibrary.h"
#include "Folder.h"
27
#include "filesystem/IDirectory.h"
28

29
30
31
32
33
34
35
using namespace medialibrary;

namespace medialibrary
{
    class Playlist;
    class AlbumTrack;
}
36
37
38
39
40

class MediaLibraryTester : public MediaLibrary
{
public:
    MediaLibraryTester();
41
    std::vector<MediaPtr> files();
42
43
44
    // Use the filename getter
    using MediaLibrary::media;
    // And override the ID getter to return a Media instead of IMedia
45
    std::shared_ptr<Media> media( int64_t id );
46
    std::shared_ptr<Folder> folder( const std::string& path );
47
48
    std::shared_ptr<Playlist> playlist( int64_t playlistId );
    void deleteAlbum( int64_t albumId );
49
    std::shared_ptr<Album> createAlbum( const std::string& title );
50
    std::shared_ptr<Genre> createGenre( const std::string& name );
51
52
    void deleteGenre( int64_t genreId );
    void deleteArtist( int64_t artistId );
53
54
    std::shared_ptr<Device> addDevice( const std::string& uuid, bool isRemovable );
    void setFsFactory( std::shared_ptr<factory::IFileSystem> fsFactory );
55
56
    void deleteTrack( int64_t trackId );
    std::shared_ptr<AlbumTrack> albumTrack( int64_t id );
57
    // Use to run tests that fiddles with file properties (modification dates, size...)
58
    std::shared_ptr<Media> addFile( std::shared_ptr<fs::IFile> file);
59
60
    // Used when we need an actual file instead of an external media
    std::shared_ptr<Media> addFile( const std::string& path );
61
62
63
    std::shared_ptr<Media> addFile( std::shared_ptr<fs::IFile> fileFs,
                                    std::shared_ptr<Folder> parentFolder,
                                    std::shared_ptr<fs::IDirectory> parentFolderFs );
64
    virtual void addLocalFsFactory() override;
65
    std::shared_ptr<Device> device( const std::string& uuid );
66
    std::vector<const char*> getSupportedExtensions() const;
67
68
    virtual void addDiscoveredFile( std::shared_ptr<fs::IFile> fileFs,
                                    std::shared_ptr<Folder> parentFolder,
69
70
                                    std::shared_ptr<fs::IDirectory> parentFolderFs,
                                    std::pair<std::shared_ptr<Playlist>, unsigned int> parentPlaylist ) override;
71
72

private:
73
    std::shared_ptr<fs::IDirectory> dummyDirectory;
74
    std::shared_ptr<factory::IFileSystem> fsFactory;
75
    std::shared_ptr<Folder> dummyFolder;
76
77
78
79
80
81
82
83
84
};

class MediaLibraryWithoutParser : public MediaLibraryTester
{
    virtual void startParser() override {}
};

class MediaLibraryWithoutBackground : public MediaLibraryTester
{
85
    virtual void startDiscoverer() override {}
86
87
88
89
90
    virtual void startParser() override {}
};

class MediaLibraryWithNotifier : public MediaLibraryTester
{
91
    virtual void startDiscoverer() override {}
92
93
    virtual void startParser() override {}
};