Tests.h 2.48 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
/*****************************************************************************
 * 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.
 *****************************************************************************/

23
24
#include "gtest/gtest.h"

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
25
26
class Playlist;

27
#include "factory/IFileSystem.h"
28
#include "MediaLibrary.h"
29
#include "Folder.h"
30

31
32
33
class MediaLibraryTester : public MediaLibrary
{
public:
34
    MediaLibraryTester();
35
36
    std::shared_ptr<Media> media( unsigned int id );
    MediaPtr media( const std::string& path );
37
    std::shared_ptr<Folder> folder( const std::string& path );
38
    std::shared_ptr<Media> addFile( const std::string& path );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
39
    std::shared_ptr<Playlist> playlist( unsigned int playlistId );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
40
    void deleteAlbum( unsigned int albumId );
41
    std::shared_ptr<Genre> createGenre( const std::string& name );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
42
    void deleteGenre( unsigned int genreId );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
43
    void deleteArtist( unsigned int artistId );
44
    std::shared_ptr<Device> addDevice( const std::string& uuid, bool isRemovable );
45
46
47
48

private:
    std::unique_ptr<fs::IDirectory> dummyDirectory;
    Folder dummyFolder;
49
50
51
};

class MediaLibraryWithoutParser : public MediaLibraryTester
52
53
54
55
56
57
58
59
60
{
    virtual void startParser() override {}
};

class MediaLibraryWithoutBackground : public MediaLibraryWithoutParser
{
    virtual void startDiscoverer() override {}
};

61
62
63
class Tests : public testing::Test
{
protected:
64
    std::unique_ptr<MediaLibraryTester> ml;
65
66

    virtual void SetUp() override;
67
    virtual void InstantiateMediaLibrary();
68
    void Reload( std::shared_ptr<factory::IFileSystem> fs = nullptr, IMediaLibraryCb* metadataCb = nullptr );
69
70
    virtual void TearDown() override;
};