- wait_for_jobs ();
-
- shared_ptr<DCPDecoder> decoder = make_shared<DCPDecoder> (content, film->log(), false);
-
- list<ContentTimePeriod> ctp = decoder->text_subtitles_during (
- ContentTimePeriod (
- ContentTime::from_seconds (25),
- ContentTime::from_seconds (26)
- ),
- true
- );
-
- BOOST_REQUIRE_EQUAL (ctp.size(), 2);
- BOOST_CHECK_EQUAL (ctp.front().from, ContentTime::from_seconds (25 + 12 * 0.04));
- BOOST_CHECK_EQUAL (ctp.front().to, ContentTime::from_seconds (26 + 4 * 0.04));
- BOOST_CHECK_EQUAL (ctp.back().from, ContentTime::from_seconds (25 + 12 * 0.04));
- BOOST_CHECK_EQUAL (ctp.back().to, ContentTime::from_seconds (26 + 4 * 0.04));
-
- list<ContentTextSubtitle> subs = decoder->subtitle->get_text (
- ContentTimePeriod (
- ContentTime::from_seconds (25),
- ContentTime::from_seconds (26)
- ),
- true,
- true
- );
-
- BOOST_REQUIRE_EQUAL (subs.size(), 1);
- BOOST_REQUIRE_EQUAL (subs.front().subs.size(), 2);
- BOOST_CHECK_EQUAL (subs.front().subs.front().text(), "Noch mal.");
- BOOST_CHECK_EQUAL (subs.front().subs.back().text(), "Encore une fois.");
+ BOOST_REQUIRE (!wait_for_jobs ());
+
+ film->make_dcp ();
+ BOOST_REQUIRE (!wait_for_jobs ());
+
+ shared_ptr<DCPSubtitleDecoder> decoder (new DCPSubtitleDecoder (film, content));
+ stored = optional<ContentStringText> ();
+ while (!decoder->pass ()) {
+ decoder->only_text()->PlainStart.connect (bind (store, _1));
+ if (stored && stored->from() == ContentTime::from_seconds(0.08)) {
+ list<dcp::SubtitleString> s = stored->subs;
+ list<dcp::SubtitleString>::const_iterator i = s.begin ();
+ BOOST_CHECK_EQUAL (i->text(), "This");
+ ++i;
+ BOOST_REQUIRE (i != s.end ());
+ BOOST_CHECK_EQUAL (i->text(), " is ");
+ ++i;
+ BOOST_REQUIRE (i != s.end ());
+ BOOST_CHECK_EQUAL (i->text(), "wrong.");
+ ++i;
+ BOOST_REQUIRE (i == s.end ());
+ }
+ }
+}
+
+/** Check that Interop DCPs aren't made with more than one <LoadFont> (#1273) */
+BOOST_AUTO_TEST_CASE (dcp_subtitle_test4)
+{
+ shared_ptr<Film> film = new_test_film2 ("dcp_subtitle_test4");
+ film->set_interop (true);
+
+ shared_ptr<DCPSubtitleContent> content (new DCPSubtitleContent ("test/data/dcp_sub3.xml"));
+ film->examine_and_add_content (content);
+ shared_ptr<DCPSubtitleContent> content2 (new DCPSubtitleContent ("test/data/dcp_sub3.xml"));
+ film->examine_and_add_content (content2);
+ BOOST_REQUIRE (!wait_for_jobs ());
+
+ content->only_text()->add_font (shared_ptr<Font> (new Font ("font1")));
+ content2->only_text()->add_font (shared_ptr<Font> (new Font ("font2")));
+
+ film->make_dcp ();
+ BOOST_REQUIRE (!wait_for_jobs ());
+
+ cxml::Document doc ("DCSubtitle");
+ doc.read_file (subtitle_file (film));
+ BOOST_REQUIRE_EQUAL (doc.node_children("LoadFont").size(), 1U);
+}
+
+static
+void
+check_font_tags (list<cxml::NodePtr> nodes)
+{
+ BOOST_FOREACH (cxml::NodePtr i, nodes) {
+ if (i->name() == "Font") {
+ BOOST_CHECK (!i->optional_string_attribute("Id") || i->string_attribute("Id") != "");
+ }
+ check_font_tags (i->node_children());
+ }
+}
+
+/** Check that imported <LoadFont> tags with empty IDs (or corresponding Font tags with empty IDs)
+ * are not passed through into the DCP.
+ */
+BOOST_AUTO_TEST_CASE (dcp_subtitle_test5)
+{
+ shared_ptr<Film> film = new_test_film2 ("dcp_subtitle_test5");
+ film->set_interop (true);
+
+ shared_ptr<DCPSubtitleContent> content (new DCPSubtitleContent("test/data/dcp_sub6.xml"));
+ film->examine_and_add_content (content);
+ BOOST_REQUIRE (!wait_for_jobs());
+
+ film->make_dcp ();
+ BOOST_REQUIRE (!wait_for_jobs());
+ film->write_metadata ();
+
+ cxml::Document doc ("DCSubtitle");
+ doc.read_file (subtitle_file(film));
+ BOOST_REQUIRE_EQUAL (doc.node_children("LoadFont").size(), 1U);
+ BOOST_CHECK (doc.node_children("LoadFont").front()->string_attribute("Id") != "");
+
+ check_font_tags (doc.node_children());