Fix test.
[dcpomatic.git] / test / vf_test.cc
1 /*
2     Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include "lib/film.h"
21 #include "lib/dcp_content.h"
22 #include "lib/ffmpeg_content.h"
23 #include "test.h"
24 #include <boost/test/unit_test.hpp>
25 #include <boost/foreach.hpp>
26
27 using std::list;
28 using std::string;
29 using boost::shared_ptr;
30
31 /** Test the logic which decides whether a DCP can be referenced or not */
32 BOOST_AUTO_TEST_CASE (vf_test1)
33 {
34         shared_ptr<Film> film = new_test_film ("vf_test1");
35         shared_ptr<DCPContent> dcp (new DCPContent (film, "test/data/reels_test2"));
36         film->examine_and_add_content (dcp);
37         wait_for_jobs ();
38
39         /* Multi-reel DCP can't be referenced if we are using a single reel for the project */
40         film->set_reel_type (REELTYPE_SINGLE);
41         list<string> why_not;
42         BOOST_CHECK (!dcp->can_reference_video(why_not));
43         BOOST_CHECK (!dcp->can_reference_audio(why_not));
44         BOOST_CHECK (!dcp->can_reference_subtitle(why_not));
45
46         /* Multi-reel DCP can be referenced if we are using by-video-content */
47         film->set_reel_type (REELTYPE_BY_VIDEO_CONTENT);
48         BOOST_CHECK (dcp->can_reference_video(why_not));
49         BOOST_CHECK (dcp->can_reference_audio(why_not));
50         /* (but reels_test2 has no subtitles to reference) */
51         BOOST_CHECK (!dcp->can_reference_subtitle(why_not));
52
53         shared_ptr<FFmpegContent> other (new FFmpegContent (film, "test/data/test.mp4"));
54         film->examine_and_add_content (other);
55         wait_for_jobs ();
56
57         /* Not possible if there is overlap */
58         other->set_position (DCPTime (0));
59         BOOST_CHECK (!dcp->can_reference_video(why_not));
60         BOOST_CHECK (!dcp->can_reference_audio(why_not));
61         BOOST_CHECK (!dcp->can_reference_subtitle(why_not));
62
63         /* This should not be considered an overlap */
64         other->set_position (dcp->end ());
65         BOOST_CHECK (dcp->can_reference_video(why_not));
66         BOOST_CHECK (dcp->can_reference_audio(why_not));
67         /* (reels_test2 has no subtitles to reference) */
68         BOOST_CHECK (!dcp->can_reference_subtitle(why_not));
69 }