Missed update to private test repo version.
[dcpomatic.git] / test / subtitle_reel_number_test.cc
1 /*
2     Copyright (C) 2017-2021 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
22 #include "lib/string_text_file_content.h"
23 #include "lib/film.h"
24 #include "lib/ratio.h"
25 #include "lib/text_content.h"
26 #include "lib/dcp_content_type.h"
27 #include "test.h"
28 #include <dcp/cpl.h>
29 #include <dcp/dcp.h>
30 #include <dcp/reel.h>
31 #include <dcp/interop_subtitle_asset.h>
32 #include <dcp/reel_subtitle_asset.h>
33 #include <dcp/raw_convert.h>
34 #include <boost/test/unit_test.hpp>
35
36
37 using std::dynamic_pointer_cast;
38 using std::make_shared;
39 using std::string;
40
41
42 /* Check that ReelNumber is setup correctly when making multi-reel subtitled DCPs */
43 BOOST_AUTO_TEST_CASE (subtitle_reel_number_test)
44 {
45         auto film = new_test_film ("subtitle_reel_number_test");
46         film->set_container (Ratio::from_id ("185"));
47         film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
48         film->set_name ("frobozz");
49         auto content = make_shared<StringTextFileContent>("test/data/subrip5.srt");
50         film->examine_and_add_content (content);
51         BOOST_REQUIRE (!wait_for_jobs ());
52         content->only_text()->set_use (true);
53         content->only_text()->set_burn (false);
54         content->only_text()->set_language(dcp::LanguageTag("de"));
55         film->set_reel_type (ReelType::BY_LENGTH);
56         film->set_interop (true);
57         film->set_reel_length (1024 * 1024 * 512);
58         make_and_verify_dcp (film, {dcp::VerificationNote::Code::INVALID_STANDARD});
59
60         dcp::DCP dcp ("build/test/subtitle_reel_number_test/" + film->dcp_name());
61         dcp.read ();
62         BOOST_REQUIRE_EQUAL (dcp.cpls().size(), 1U);
63         auto cpl = dcp.cpls()[0];
64         BOOST_REQUIRE_EQUAL (cpl->reels().size(), 6U);
65
66         int n = 1;
67         for (auto i: cpl->reels()) {
68                 if (i->main_subtitle()) {
69                         auto ass = dynamic_pointer_cast<dcp::InteropSubtitleAsset>(i->main_subtitle()->asset());
70                         BOOST_REQUIRE (ass);
71                         BOOST_CHECK_EQUAL (ass->reel_number(), dcp::raw_convert<string>(n));
72                         ++n;
73                 }
74         }
75 }