Movies.cpp 3.09 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
#include "Tests.h"
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
24

25 26
#include "MediaLibrary.h"
#include "Movie.h"
27
#include "Media.h"
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
28

29
class Movies : public Tests
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
{
};

TEST_F( Movies, Create )
{
    auto m = ml->createMovie( "movie" );
    ASSERT_NE( m, nullptr );
    ASSERT_EQ( m->title(), "movie" );
}

TEST_F( Movies, Fetch )
{
    auto m = ml->createMovie( "movie" );
    auto m2 = ml->movie( "movie" );

    ASSERT_EQ( m, m2 );

47
    Reload();
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
48 49 50 51 52 53 54 55 56 57 58 59 60

    m2 = ml->movie( "movie" );
    ASSERT_NE( m2, nullptr );
    ASSERT_EQ( m2->title(), "movie" );
}

TEST_F( Movies, SetReleaseDate )
{
    auto m = ml->createMovie( "movie" );
    ASSERT_EQ( m->releaseDate(), 0u );
    m->setReleaseDate( 1234 );
    ASSERT_EQ( m->releaseDate(), 1234u );

61
    Reload();
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
62

63 64
    auto m2 = ml->movie( "movie" );
    ASSERT_EQ( m2->releaseDate(), 1234u );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
65 66 67 68 69 70 71 72 73
}

TEST_F( Movies, SetShortSummary )
{
    auto m = ml->createMovie( "movie" );
    ASSERT_EQ( m->shortSummary().length(), 0u );
    m->setShortSummary( "great movie" );
    ASSERT_EQ( m->shortSummary(), "great movie" );

74
    Reload();
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
75

76 77
    auto m2 = ml->movie( "movie" );
    ASSERT_EQ( m2->shortSummary(), "great movie" );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
78 79 80 81 82 83 84 85 86
}

TEST_F( Movies, SetArtworkUrl )
{
    auto m = ml->createMovie( "movie" );
    ASSERT_EQ( m->artworkUrl().length(), 0u );
    m->setArtworkUrl( "artwork" );
    ASSERT_EQ( m->artworkUrl(), "artwork" );

87
    Reload();
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
88

89 90
    auto m2 = ml->movie( "movie" );
    ASSERT_EQ( m2->artworkUrl(), "artwork" );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
91 92 93 94 95 96 97 98 99
}

TEST_F( Movies, SetImdbId )
{
    auto m = ml->createMovie( "movie" );
    ASSERT_EQ( m->imdbId().length(), 0u );
    m->setImdbId( "id" );
    ASSERT_EQ( m->imdbId(), "id" );

100
    Reload();
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
101

102 103
    auto m2 = ml->movie( "movie" );
    ASSERT_EQ( m2->imdbId(), "id" );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
104 105 106 107
}

TEST_F( Movies, AssignToFile )
{
108
    auto f = ml->addFile( "file.avi", nullptr );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
109 110 111 112 113 114
    auto m = ml->createMovie( "movie" );

    ASSERT_EQ( f->movie(), nullptr );
    f->setMovie( m );
    ASSERT_EQ( f->movie(), m );

115
    Reload();
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
116

117 118 119 120
    auto f2 = ml->file( "file.avi" );
    auto m2 = f2->movie();
    ASSERT_NE( m2, nullptr );
    ASSERT_EQ( m2->title(), "movie" );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
121
}