summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-01-13 23:34:35 +0100
committerCarl Hetherington <cth@carlh.net>2024-01-15 10:21:59 +0100
commitdb22f81ccce9e1a5f205e6d8b3c0631fc039a173 (patch)
tree263c2a28165fe5d3cf03bae25d19cd60b0640bfd /test
parent7a301e22de2a3c47a81ebc4c9f19b68131b482aa (diff)
Fix handling of empty font IDs and default DCP fonts (#2721) (part of #2722).
Previously we used an empty font ID as the default for when a subtitle has no Font, but in #2721 we saw a DCP with an empty font ID which raised an assertion (because we'd already added our default font with the empty ID). Here we try to fix this (and also make the default font correctly be that from the first <LoadFont>).
Diffstat (limited to 'test')
m---------test/data0
-rw-r--r--test/dcp_subtitle_test.cc4
-rw-r--r--test/hints_test.cc3
-rw-r--r--test/subtitle_font_id_test.cc38
4 files changed, 38 insertions, 7 deletions
diff --git a/test/data b/test/data
-Subproject a4ad4c1a4880d02aabf2790e11c4e5c2c28034d
+Subproject 314e09cbac2e023a7acb61e1b32db76fe6dd775
diff --git a/test/dcp_subtitle_test.cc b/test/dcp_subtitle_test.cc
index 9b7b77279..4928d92c1 100644
--- a/test/dcp_subtitle_test.cc
+++ b/test/dcp_subtitle_test.cc
@@ -246,7 +246,9 @@ BOOST_AUTO_TEST_CASE (test_font_override)
film->set_interop(true);
BOOST_REQUIRE_EQUAL(content->text.size(), 1U);
- content->text.front()->get_font("theFontId")->set_file("test/data/Inconsolata-VF.ttf");
+ auto font = content->text.front()->get_font("0_theFontId");
+ BOOST_REQUIRE(font);
+ font->set_file("test/data/Inconsolata-VF.ttf");
make_and_verify_dcp (film, { dcp::VerificationNote::Code::INVALID_STANDARD });
check_file (subtitle_file(film).parent_path() / "font_0.ttf", "test/data/Inconsolata-VF.ttf");
diff --git a/test/hints_test.cc b/test/hints_test.cc
index a989d3aeb..949ba18c0 100644
--- a/test/hints_test.cc
+++ b/test/hints_test.cc
@@ -198,7 +198,8 @@ BOOST_AUTO_TEST_CASE (hint_subtitle_mxf_too_big)
content->text[0]->set_language(dcp::LanguageTag("en-US"));
film->examine_and_add_content(content);
BOOST_REQUIRE (!wait_for_jobs());
- auto const font = content->text[0]->get_font(String::compose("font_%1", i));
+ auto const font = content->text[0]->get_font(String::compose("0_font_%1", i));
+ BOOST_REQUIRE(font);
font->set_file("build/test/hint_subtitle_mxf_too_big.ttf");
}
diff --git a/test/subtitle_font_id_test.cc b/test/subtitle_font_id_test.cc
index f6bd48c51..56207bfcb 100644
--- a/test/subtitle_font_id_test.cc
+++ b/test/subtitle_font_id_test.cc
@@ -47,8 +47,7 @@ BOOST_AUTO_TEST_CASE(full_dcp_subtitle_font_id_test)
auto text = content[0]->only_text();
BOOST_REQUIRE(text);
- /* There's the font from the DCP and also a dummy one with an empty ID */
- BOOST_REQUIRE_EQUAL(text->fonts().size(), 2U);
+ BOOST_REQUIRE_EQUAL(text->fonts().size(), 1U);
auto font = text->fonts().front();
BOOST_CHECK_EQUAL(font->id(), "0_theFontId");
BOOST_REQUIRE(font->data());
@@ -66,10 +65,9 @@ BOOST_AUTO_TEST_CASE(dcp_subtitle_font_id_test)
auto text = content[0]->only_text();
BOOST_REQUIRE(text);
- /* There's the font from the DCP and also a dummy one with an empty ID */
- BOOST_REQUIRE_EQUAL(text->fonts().size(), 2U);
+ BOOST_REQUIRE_EQUAL(text->fonts().size(), 1U);
auto font = text->fonts().front();
- BOOST_CHECK_EQUAL(font->id(), "theFontId");
+ BOOST_CHECK_EQUAL(font->id(), "0_theFontId");
BOOST_REQUIRE(font->data());
BOOST_CHECK_EQUAL(font->data()->size(), 367112);
}
@@ -261,3 +259,33 @@ BOOST_AUTO_TEST_CASE(subtitle_with_no_font_test)
make_and_verify_dcp(check_film);
}
+
+BOOST_AUTO_TEST_CASE(load_dcp_with_empty_font_id_test)
+{
+ auto dcp = std::make_shared<DCPContent>(TestPaths::private_data() / "kr_vf");
+ auto film = new_test_film2("load_dcp_with_empty_font_id_test", { dcp });
+}
+
+
+BOOST_AUTO_TEST_CASE(use_first_loadfont_as_default)
+{
+ auto dcp = std::make_shared<DCPContent>("test/data/use_default_font");
+ auto film = new_test_film2("use_first_loadfont_as_default", { dcp });
+ dcp->only_text()->set_use(true);
+ dcp->only_text()->set_language(dcp::LanguageTag("de"));
+ make_and_verify_dcp(
+ film,
+ { dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME }
+ );
+
+ dcp::DCP test(film->dir(film->dcp_name()));
+ test.read();
+ BOOST_REQUIRE(!test.cpls().empty());
+ auto cpl = test.cpls()[0];
+ BOOST_REQUIRE(!cpl->reels().empty());
+ auto reel = cpl->reels()[0];
+ BOOST_REQUIRE(reel->main_subtitle()->asset());
+ auto subtitle = std::dynamic_pointer_cast<dcp::SMPTESubtitleAsset>(reel->main_subtitle()->asset());
+ BOOST_REQUIRE_EQUAL(subtitle->font_data().size(), 1U);
+ BOOST_CHECK(subtitle->font_data().begin()->second == dcp::ArrayData("test/data/Inconsolata-VF.ttf"));
+}