Subtitle language handling tweaks; write multiple subtitle languages
[dcpomatic.git] / test / subtitle_language_test.cc
1 /*
2     Copyright (C) 2020 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 /** @file  test/subtitle_language_test.cc
22  *  @brief Test that subtitle language information is correctly written to DCPs.
23  */
24
25
26 #include "lib/content_factory.h"
27 #include "lib/film.h"
28 #include "test.h"
29 #include <dcp/language_tag.h>
30 #include <boost/test/unit_test.hpp>
31 #include <vector>
32
33
34 using std::string;
35 using std::vector;
36 using boost::shared_ptr;
37
38
39 BOOST_AUTO_TEST_CASE (subtitle_language_interop_test)
40 {
41         string const name = "subtitle_language_interop_test";
42         shared_ptr<Film> film = new_test_film2 (name);
43         film->examine_and_add_content (content_factory("test/data/frames.srt").front());
44         BOOST_REQUIRE (!wait_for_jobs());
45
46         vector<dcp::LanguageTag> langs;
47         langs.push_back(dcp::LanguageTag("fr-FR"));
48         langs.push_back(dcp::LanguageTag("de-DE"));
49         film->set_subtitle_languages(langs);
50         film->set_interop (true);
51
52         film->make_dcp ();
53         BOOST_REQUIRE (!wait_for_jobs());
54
55         check_dcp (String::compose("test/data/%1", name), String::compose("build/test/%1/%2", name, film->dcp_name()));
56 }
57
58
59 BOOST_AUTO_TEST_CASE (subtitle_language_smpte_test)
60 {
61         string const name = "subtitle_language_smpte_test";
62         shared_ptr<Film> film = new_test_film2 (name);
63         film->examine_and_add_content (content_factory("test/data/frames.srt").front());
64         BOOST_REQUIRE (!wait_for_jobs());
65
66         vector<dcp::LanguageTag> langs;
67         langs.push_back(dcp::LanguageTag("fr-FR"));
68         langs.push_back(dcp::LanguageTag("de-DE"));
69         film->set_subtitle_languages(langs);
70         film->set_interop (false);
71
72         film->make_dcp ();
73         BOOST_REQUIRE (!wait_for_jobs());
74
75         check_dcp (String::compose("test/data/%1", name), String::compose("build/test/%1/%2", name, film->dcp_name()));
76 }
77