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