Revert "Use make_shared<>."
[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
28 using std::list;
29 using std::string;
30 using boost::shared_ptr;
31
32 /** Test the logic which decides whether a DCP can be referenced or not */
33 BOOST_AUTO_TEST_CASE (vf_test1)
34 {
35         shared_ptr<Film> film = new_test_film ("vf_test1");
36         shared_ptr<DCPContent> dcp (new DCPContent (film, "test/data/reels_test2"));
37         film->examine_and_add_content (dcp);
38         wait_for_jobs ();
39
40         /* Multi-reel DCP can't be referenced if we are using a single reel for the project */
41         film->set_reel_type (REELTYPE_SINGLE);
42         list<string> why_not;
43         BOOST_CHECK (!dcp->can_reference_video(why_not));
44         BOOST_CHECK (!dcp->can_reference_audio(why_not));
45         BOOST_CHECK (!dcp->can_reference_subtitle(why_not));
46
47         /* Multi-reel DCP can be referenced if we are using by-video-content */
48         film->set_reel_type (REELTYPE_BY_VIDEO_CONTENT);
49         BOOST_CHECK (dcp->can_reference_video(why_not));
50         BOOST_CHECK (dcp->can_reference_audio(why_not));
51         /* (but reels_test2 has no subtitles to reference) */
52         BOOST_CHECK (!dcp->can_reference_subtitle(why_not));
53
54         shared_ptr<FFmpegContent> other (new FFmpegContent (film, "test/data/test.mp4"));
55         film->examine_and_add_content (other);
56         wait_for_jobs ();
57
58         /* Not possible if there is overlap */
59         other->set_position (DCPTime (0));
60         BOOST_CHECK (!dcp->can_reference_video(why_not));
61         BOOST_CHECK (!dcp->can_reference_audio(why_not));
62         BOOST_CHECK (!dcp->can_reference_subtitle(why_not));
63
64         /* This should not be considered an overlap */
65         other->set_position (dcp->end ());
66         BOOST_CHECK (dcp->can_reference_video(why_not));
67         BOOST_CHECK (dcp->can_reference_audio(why_not));
68         /* (reels_test2 has no subtitles to reference) */
69         BOOST_CHECK (!dcp->can_reference_subtitle(why_not));
70 }