Cleanup: missing word in comment.
[dcpomatic.git] / test / text_entry_point_test.cc
1 /*
2     Copyright (C) 2024 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 "test.h"
23 #include "lib/dcp_content.h"
24 #include "lib/film.h"
25 #include <dcp/cpl.h>
26 #include <dcp/dcp.h>
27 #include <dcp/reel.h>
28 #include <dcp/reel_smpte_subtitle_asset.h>
29 #include <dcp/smpte_subtitle_asset.h>
30 #include <boost/test/unit_test.hpp>
31
32
33 using std::make_shared;
34 using std::string;
35
36
37 BOOST_AUTO_TEST_CASE(test_text_entry_point)
38 {
39         auto const path = boost::filesystem::path("build/test/test_text_entry_point");
40         boost::filesystem::remove_all(path);
41         boost::filesystem::create_directories(path);
42
43         /* Make a "bad" DCP with a non-zero text entry point */
44         dcp::DCP bad_dcp(path / "dcp");
45         auto sub = make_shared<dcp::SMPTESubtitleAsset>();
46         sub->write(path / "dcp" / "subs.mxf");
47         auto reel_sub = make_shared<dcp::ReelSMPTESubtitleAsset>(sub, dcp::Fraction{24, 1}, 42, 6);
48         auto reel = make_shared<dcp::Reel>();
49         reel->add(reel_sub);
50
51         auto cpl = make_shared<dcp::CPL>("foo", dcp::ContentKind::FEATURE, dcp::Standard::SMPTE);
52         bad_dcp.add(cpl);
53         cpl->add(reel);
54
55         bad_dcp.write_xml();
56
57         /* Make a film and add the bad DCP, so that the examiner spots the problem */
58         auto dcp_content = make_shared<DCPContent>(path / "dcp");
59         auto film = new_test_film2("test_text_entry_point/film", { dcp_content });
60         film->write_metadata();
61
62         /* Reload the film to check that the examiner's output is saved and recovered */
63         auto film2 = make_shared<Film>(path / "film");
64         film2->read_metadata();
65
66         string why_not;
67         BOOST_CHECK(!dcp_content->can_reference_text(film2, TextType::OPEN_SUBTITLE, why_not));
68         BOOST_CHECK_EQUAL(why_not, "one of its subtitle reels has a non-zero entry point so it must be re-written.");
69 }
70