summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-06-01 13:03:38 +0200
committerCarl Hetherington <cth@carlh.net>2022-06-07 17:01:06 +0200
commit5a820bb8fae34591be5ac6d19a73461b9dab532a (patch)
tree098e2dc959b6df0fefa62b2976976afc9f81b96b /test
parent9a7b67aee32a40539f29bc2d7017edd4a4f65f11 (diff)
Rearrange subtitle font management.
With this change each subtitle coming out of the player has a reference to a dcpomatic::Font that belongs to the TextContent. This hopefully solves a few problems which all basically stemmed from the fact that previously the decoders/player were deciding what the font ID in the output DCP would be - they can't do that properly.
Diffstat (limited to 'test')
-rw-r--r--test/dcp_subtitle_test.cc2
-rw-r--r--test/render_subtitles_test.cc7
-rw-r--r--test/srt_subtitle_test.cc15
-rw-r--r--test/writer_test.cc60
4 files changed, 75 insertions, 9 deletions
diff --git a/test/dcp_subtitle_test.cc b/test/dcp_subtitle_test.cc
index fb8888d0c..640f6510e 100644
--- a/test/dcp_subtitle_test.cc
+++ b/test/dcp_subtitle_test.cc
@@ -238,7 +238,7 @@ BOOST_AUTO_TEST_CASE (test_font_override)
film->set_interop(true);
BOOST_REQUIRE_EQUAL(content->text.size(), 1U);
- content->text.front()->add_font(make_shared<dcpomatic::Font>("theFontId", "test/data/Inconsolata-VF.ttf"));
+ content->text.front()->get_font("theFontId")->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/render_subtitles_test.cc b/test/render_subtitles_test.cc
index 5774c8e9a..d850062c2 100644
--- a/test/render_subtitles_test.cc
+++ b/test/render_subtitles_test.cc
@@ -18,15 +18,19 @@
*/
+
/** @file test/render_text_test.cc
* @brief Check markup of subtitles for rendering.
* @ingroup feature
*/
+
#include "lib/render_text.h"
+#include "lib/string_text.h"
#include <dcp/subtitle_string.h>
#include <boost/test/unit_test.hpp>
+
static void
add (std::list<StringText>& s, std::string text, bool italic, bool bold, bool underline)
{
@@ -54,7 +58,8 @@ add (std::list<StringText>& s, std::string text, bool italic, bool bold, bool un
dcp::Time (),
0
),
- 2
+ 2,
+ std::shared_ptr<dcpomatic::Font>()
)
);
}
diff --git a/test/srt_subtitle_test.cc b/test/srt_subtitle_test.cc
index cd4ce3a05..11b6b28b9 100644
--- a/test/srt_subtitle_test.cc
+++ b/test/srt_subtitle_test.cc
@@ -170,13 +170,14 @@ BOOST_AUTO_TEST_CASE (srt_subtitle_test5)
film->set_name ("frobozz");
film->set_interop (true);
film->set_sequence (false);
- auto content = make_shared<StringTextFileContent>("test/data/subrip2.srt");
- content->only_text()->set_use (true);
- content->only_text()->set_burn (false);
- film->examine_and_add_content (content);
- film->examine_and_add_content (content);
- BOOST_REQUIRE (!wait_for_jobs());
- content->set_position (film, DCPTime());
+ for (auto i = 0; i < 2; ++i) {
+ auto content = make_shared<StringTextFileContent>("test/data/subrip2.srt");
+ content->only_text()->set_use (true);
+ content->only_text()->set_burn (false);
+ film->examine_and_add_content (content);
+ BOOST_REQUIRE (!wait_for_jobs());
+ content->set_position (film, DCPTime());
+ }
make_and_verify_dcp (film, {dcp::VerificationNote::Code::INVALID_STANDARD});
check_dcp ("test/data/xml_subtitle_test2", film->dir (film->dcp_name ()));
diff --git a/test/writer_test.cc b/test/writer_test.cc
index 1dfc75bfc..e0df0610e 100644
--- a/test/writer_test.cc
+++ b/test/writer_test.cc
@@ -36,6 +36,7 @@
using std::make_shared;
using std::shared_ptr;
+using std::vector;
BOOST_AUTO_TEST_CASE (test_write_odd_amount_of_silence)
@@ -101,3 +102,62 @@ BOOST_AUTO_TEST_CASE (interrupt_writer)
cl.run ();
}
+
+BOOST_AUTO_TEST_CASE (writer_disambiguate_font_ids1)
+{
+ auto film = new_test_film2("writer_disambiguate_font_ids1", {});
+ Writer writer(film, {});
+
+ auto fonts = vector<shared_ptr<dcpomatic::Font>> {
+ make_shared<dcpomatic::Font>("a"),
+ make_shared<dcpomatic::Font>("b"),
+ make_shared<dcpomatic::Font>("c")
+ };
+
+ writer.write(fonts);
+
+ BOOST_CHECK_EQUAL(writer._fonts.get(fonts[0]), "a");
+ BOOST_CHECK_EQUAL(writer._fonts.get(fonts[1]), "b");
+ BOOST_CHECK_EQUAL(writer._fonts.get(fonts[2]), "c");
+}
+
+
+BOOST_AUTO_TEST_CASE (writer_disambiguate_font_ids2)
+{
+ auto film = new_test_film2("writer_disambiguate_font_ids2", {});
+ Writer writer(film, {});
+
+ auto fonts = vector<shared_ptr<dcpomatic::Font>> {
+ make_shared<dcpomatic::Font>("a"),
+ make_shared<dcpomatic::Font>("a"),
+ make_shared<dcpomatic::Font>("a")
+ };
+
+ writer.write(fonts);
+
+ BOOST_CHECK_EQUAL(writer._fonts.get(fonts[0]), "a");
+ BOOST_CHECK_EQUAL(writer._fonts.get(fonts[1]), "a_0");
+ BOOST_CHECK_EQUAL(writer._fonts.get(fonts[2]), "a_1");
+}
+
+
+BOOST_AUTO_TEST_CASE (writer_disambiguate_font_ids3)
+{
+ auto film = new_test_film2("writer_disambiguate_font_ids3", {});
+ Writer writer(film, {});
+
+ auto fonts = vector<shared_ptr<dcpomatic::Font>> {
+ make_shared<dcpomatic::Font>("a_2"),
+ make_shared<dcpomatic::Font>("a_1"),
+ make_shared<dcpomatic::Font>("a_1"),
+ make_shared<dcpomatic::Font>("b")
+ };
+
+ writer.write(fonts);
+
+ BOOST_CHECK_EQUAL(writer._fonts.get(fonts[1]), "a_1");
+ BOOST_CHECK_EQUAL(writer._fonts.get(fonts[0]), "a_2");
+ BOOST_CHECK_EQUAL(writer._fonts.get(fonts[2]), "a_3");
+ BOOST_CHECK_EQUAL(writer._fonts.get(fonts[3]), "b");
+}
+