Tests.cpp 910 Bytes
Newer Older
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
1
2
#include "gtest/gtest.h"

3
#include "IMediaLibrary.h"
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
4

5
class MLTest : public testing::Test
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
6
{
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
    public:
        static IMediaLibrary* ml;

    protected:
        virtual void SetUp()
        {
            ml = MediaLibraryFactory::create();
            bool res = ml->initialize( "test.db" );
            ASSERT_TRUE( res );
        }

        virtual void TearDown()
        {
            delete ml;
            unlink("test.db");
        }
};

IMediaLibrary* MLTest::ml;

TEST_F( MLTest, Init )
{
    // only test for correct test fixture behavior
}

TEST_F( MLTest, InsertFile )
{
    IFile* f = ml->addFile( "/dev/null" );
    ASSERT_TRUE( f != NULL );

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
37
38
39
40
    ASSERT_EQ( f->playCount(), 0 );
    ASSERT_TRUE( f->albumTrack() == NULL );
    ASSERT_TRUE( f->showEpisode() == NULL );

41
42
43
    std::vector<IFile*> files = ml->files();
    ASSERT_EQ( files.size(), 1u );
    ASSERT_EQ( files[0]->mrl(), f->mrl() );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
44
}