2 Copyright (C) 2022 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
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.
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.
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/>.
22 /** @file test/subtitle_font_id_change_test.cc
23 * @brief Check that old projects can still be used after the changes in 5a820bb8fae34591be5ac6d19a73461b9dab532a
27 #include "lib/check_content_job.h"
28 #include "lib/content.h"
31 #include "lib/text_content.h"
33 #include <dcp/verify.h>
34 #include <boost/filesystem.hpp>
35 #include <boost/test/unit_test.hpp>
41 BOOST_AUTO_TEST_CASE(subtitle_font_id_change_test1)
43 auto film = new_test_film2("subtitle_font_id_change_test1");
44 boost::filesystem::remove(film->file("metadata.xml"));
45 boost::filesystem::copy_file("test/data/subtitle_font_id_change_test1.xml", film->file("metadata.xml"));
46 film->read_metadata();
48 auto content = film->content();
49 BOOST_REQUIRE_EQUAL(content.size(), 1U);
50 BOOST_REQUIRE_EQUAL(content[0]->text.size(), 1U);
52 content[0]->set_paths({"test/data/short.srt"});
53 content[0]->only_text()->set_language(dcp::LanguageTag("de"));
55 CheckContentJob check(film);
57 BOOST_REQUIRE (!wait_for_jobs());
59 make_and_verify_dcp(film, { dcp::VerificationNote::Code::INVALID_STANDARD });
63 BOOST_AUTO_TEST_CASE(subtitle_font_id_change_test2)
65 auto film = new_test_film2("subtitle_font_id_change_test2");
66 boost::filesystem::remove(film->file("metadata.xml"));
67 boost::filesystem::copy_file("test/data/subtitle_font_id_change_test2.xml", film->file("metadata.xml"));
69 Editor editor(film->file("metadata.xml"));
70 editor.replace("/usr/share/fonts/truetype/inconsolata/Inconsolata.otf", "test/data/Inconsolata-VF.ttf");
72 film->read_metadata();
74 auto content = film->content();
75 BOOST_REQUIRE_EQUAL(content.size(), 1U);
76 BOOST_REQUIRE_EQUAL(content[0]->text.size(), 1U);
78 content[0]->set_paths({"test/data/short.srt"});
79 /* Make sure the content doesn't look like it's changed, otherwise it will be re-examined
80 * which obscures the point of this test.
82 content[0]->_last_write_times[0] = boost::filesystem::last_write_time("test/data/short.srt");
84 CheckContentJob check(film);
86 BOOST_REQUIRE (!wait_for_jobs());
88 auto font = content[0]->text.front()->get_font("");
89 BOOST_REQUIRE(font->file());
90 BOOST_CHECK_EQUAL(*font->file(), "test/data/Inconsolata-VF.ttf");
92 make_and_verify_dcp(film, { dcp::VerificationNote::Code::INVALID_STANDARD });
96 BOOST_AUTO_TEST_CASE(subtitle_font_id_change_test3)
98 auto film = new_test_film2("subtitle_font_id_change_test3");
99 boost::filesystem::remove(film->file("metadata.xml"));
100 boost::filesystem::copy_file("test/data/subtitle_font_id_change_test3.xml", film->file("metadata.xml"));
102 Editor editor(film->file("metadata.xml"));
103 editor.replace("/usr/share/fonts/truetype/inconsolata/Inconsolata.otf", "test/data/Inconsolata-VF.ttf");
105 film->read_metadata();
107 auto content = film->content();
108 BOOST_REQUIRE_EQUAL(content.size(), 1U);
109 BOOST_REQUIRE_EQUAL(content[0]->text.size(), 1U);
111 content[0]->set_paths({"test/data/fonts.ass"});
112 content[0]->only_text()->set_language(dcp::LanguageTag("de"));
114 CheckContentJob check(film);
116 BOOST_REQUIRE (!wait_for_jobs());
118 auto font = content[0]->text.front()->get_font("Arial Black");
120 BOOST_REQUIRE(font->file());
121 BOOST_CHECK_EQUAL(*font->file(), "test/data/Inconsolata-VF.ttf");
123 font = content[0]->text.front()->get_font("Helvetica Neue");
125 BOOST_REQUIRE(font->file());
126 BOOST_CHECK_EQUAL(*font->file(), "test/data/Inconsolata-VF.ttf");
128 make_and_verify_dcp(film, { dcp::VerificationNote::Code::INVALID_STANDARD });
132 BOOST_AUTO_TEST_CASE(subtitle_font_id_change_test4)
136 auto film = new_test_film2("subtitle_font_id_change_test4", {}, &cl);
137 boost::filesystem::remove(film->file("metadata.xml"));
138 boost::filesystem::copy_file("test/data/subtitle_font_id_change_test4.xml", film->file("metadata.xml"));
141 Editor editor(film->file("metadata.xml"));
142 editor.replace("dcpomatic-test-private", TestPaths::private_data().string());
145 film->read_metadata();
147 auto content = film->content();
148 BOOST_REQUIRE_EQUAL(content.size(), 1U);
149 BOOST_REQUIRE_EQUAL(content[0]->text.size(), 1U);
151 CheckContentJob check(film);
153 BOOST_REQUIRE(!wait_for_jobs());
155 make_and_verify_dcp(film, { dcp::VerificationNote::Code::INVALID_STANDARD });