Hide Font members behind accessors.
[dcpomatic.git] / test / srt_subtitle_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 /** @file  test/subtitle_write_test.cc
21  *  @brief Test writing DCPs with XML subtitles.
22  */
23
24 #include "lib/film.h"
25 #include "lib/subrip_content.h"
26 #include "lib/dcp_content_type.h"
27 #include "lib/font.h"
28 #include "test.h"
29 #include <boost/test/unit_test.hpp>
30
31 using boost::shared_ptr;
32
33 /** Make a very short DCP with a single subtitle from .srt with no specified fonts */
34 BOOST_AUTO_TEST_CASE (srt_subtitle_test)
35 {
36         shared_ptr<Film> film = new_test_film ("srt_subtitle_test");
37         film->set_container (Ratio::from_id ("185"));
38         film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
39         film->set_name ("frobozz");
40         film->set_burn_subtitles (false);
41         shared_ptr<SubRipContent> content (new SubRipContent (film, "test/data/subrip2.srt"));
42         film->examine_and_add_content (content);
43         wait_for_jobs ();
44
45         content->set_use_subtitles (true);
46         film->make_dcp ();
47         wait_for_jobs ();
48
49         check_dcp ("test/data/srt_subtitle_test", film->dir (film->dcp_name ()));
50 }
51
52 /** Same again but with a `font' specified */
53 BOOST_AUTO_TEST_CASE (srt_subtitle_test2)
54 {
55         shared_ptr<Film> film = new_test_film ("srt_subtitle_test2");
56         film->set_container (Ratio::from_id ("185"));
57         film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
58         film->set_name ("frobozz");
59         film->set_burn_subtitles (false);
60         shared_ptr<SubRipContent> content (new SubRipContent (film, "test/data/subrip2.srt"));
61         film->examine_and_add_content (content);
62         wait_for_jobs ();
63
64         content->set_use_subtitles (true);
65         /* Use test/data/subrip2.srt as if it were a font file  */
66         content->fonts().front()->set_file ("test/data/subrip2.srt");
67         
68         film->make_dcp ();
69         wait_for_jobs ();
70
71         check_dcp ("test/data/srt_subtitle_test2", film->dir (film->dcp_name ()));
72 }
73